MediaWiki:Gadget-interfaceVariantConverter.js

来自萌娘共享
跳转至: 导航搜索

注意:在保存之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:前往菜单 → 设置(Mac为Opera → Preferences),然后隐私和安全 → 清除浏览数据 → 缓存的图片和文件
/**
 * -------------------------------------------------------------------------
 * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
 * -------------------------------------------------------------------------
 */
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/interfaceVariantConverter/MediaWiki:Gadget-interfaceVariantConverter.js|user=[[U:AnnAngela]]|co-authors=[[U:Bhsd]]、GH:github-actions[bot]|longId=bf83eaea8eb4d94405bdf6885ec072fec997dd56|shortId=bf83eaea|summary=ci: use eslint flat config (#400)|body=<nowiki>Co-authored-by: Bhsd <55071315+bhsd-harry📧users.noreply.github.com>↩Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}'; 

/* <pre> */

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
$(function () { return (function () { return __awaiter(void 0, void 0, void 0, function () {
    var pagename, username, pageid, basepage, api, zhAPI, lrAivc, prepopContent, _a, _b, toParams, variantPage, REGEXP, escapeWikitext, restoreWikitext, AIVCWindow, $body, windowManager, aivcDialog;
    return __generator(this, function (_c) {
        switch (_c.label) {
            case 0:
                pagename = mw.config.get("wgPageName");
                username = mw.config.get("wgUserName");
                if (mw.config.get("wgNamespaceNumber") !== 8 || pagename.includes(".js") || pagename.includes(".css")) {
                    return [2];
                }
                pageid = mw.config.get("wgArticleId");
                basepage = pagename.replace(/\/.*?$/, "");
                api = new mw.Api(), zhAPI = /m?zh\.moegirl\.org\.cn/.test(location.hostname) ? api : new mw.ForeignApi("https://mzh.moegirl.org.cn/api.php", { anonymous: true });
                lrAivc = $.extend({
                    main: ["zh-cn", "zh-tw", "zh-hk"],
                    dependent: {
                        "(main)": "zh-cn",
                        "zh-hans": "zh-cn",
                        "zh-hant": "zh-tw"
                    },
                    noteTA: {
                        G1: "MediaWiki"
                    },
                    autoPopulate: true,
                    useOpenCC: true,
                    manualAction: {
                        "zh-hk": function (t) { return t.replaceAll("户", "戶"); },
                        "zh-tw": function (t) { return t.replaceAll("名稱空間", "命名空間").replaceAll("記憶體", "內存"); }
                    },
                    watchlist: "nochange"
                }, window.lr_aivc);
                prepopContent = "";
                _c.label = 1;
            case 1:
                _c.trys.push([1, 5, , 6]);
                if (!lrAivc.autoPopulate) return [3, 3];
                return [4, api.get({
                        action: "parse",
                        assertuser: username,
                        pageid: pageid,
                        prop: "wikitext"
                    })];
            case 2:
                _a = (_c.sent()).parse.wikitext["*"];
                return [3, 4];
            case 3:
                _a = "";
                _c.label = 4;
            case 4:
                prepopContent = _a;
                return [3, 6];
            case 5:
                _b = _c.sent();
                return [3, 6];
            case 6:
                toParams = function (obj) { return Object.entries(obj).map(function (_a) {
                    var _b = __read(_a, 2), k = _b[0], v = _b[1];
                    return "".concat(k, "=").concat(v);
                }).join("|"); };
                variantPage = function (variant) { return variant === "(main)" ? "".concat(basepage) : "".concat(basepage, "/").concat(variant); };
                REGEXP = {
                    lcMarker: /-{([\s\S]*?)}-/g,
                    lcMarkerEsc: /-\\{([\s\S]*?)}\\-/g,
                    nowiki: /<nowiki>([\s\S]*?)<\/nowiki>/g,
                    link: /\[\[([\s\S]*?)(?:#([\s\S]*?))?(\|[\s\S]*?)?\]\]/g,
                    extLink: /([^[])\[([^[]+?)( [\s\S]+?)?\]([^\]])/g,
                    template: /\{\{([\s\S]*?)\}\}/g,
                    htmlEntity: /&([a-zA-Z0-9#]+);/g,
                    noOCC: /<!--noOCC-->([\s\S]*?)<!--\/noOCC-->/gi
                };
                escapeWikitext = function (original) {
                    var nowikis = [], mappings = [];
                    var replaced = original;
                    replaced = replaced.replace(REGEXP.lcMarker, function (_, content) { return "-\\{".concat(content, "}\\-"); });
                    replaced = replaced.replace(REGEXP.nowiki, function (_, content) { return "<nowiki>".concat(nowikis.push(content) - 1, "</nowiki>"); });
                    replaced = replaced.replace(REGEXP.link, function (match, target, anchor, text) { return anchor || text ? "[[".concat(text ? mappings.push(target) - 1 : target).concat(anchor ? "#".concat(mappings.push(anchor) - 1) : "").concat(text || "", "]]") : match; });
                    replaced = replaced.replace(REGEXP.extLink, function (_, before, target, text, after) { return "".concat(before, "[").concat(mappings.push(target) - 1).concat(text || "", "]").concat(after); });
                    replaced = replaced.replace(REGEXP.template, function (_, params) {
                        var paramList = params.split("|");
                        mappings.push(paramList[0]);
                        paramList.shift();
                        return "".concat(paramList.reduce(function (acc, param) {
                            var _a = __read(param.split("=")), first = _a[0], rest = _a.slice(1);
                            return rest.length ? "".concat(acc, "|").concat(mappings.push(first) - 1, "=").concat(rest.join("=")) : "".concat(acc, "|").concat(param);
                        }, "{{".concat(mappings.length - 1)), "}}");
                    });
                    replaced = replaced.replace(REGEXP.lcMarkerEsc, function (_, content) { return "-\\{".concat(mappings.push(content || "") - 1, "}\\-"); });
                    replaced = replaced.replace(REGEXP.htmlEntity, function (_, entity) { return "&".concat(mappings.push(entity) - 1, ";"); });
                    replaced = replaced.replace(REGEXP.nowiki, function (_, index) { return "<nowiki><nowiki>".concat(nowikis[index], "</nowiki></nowiki>"); });
                    return { replaced: replaced, mappings: mappings };
                };
                restoreWikitext = function (original, mappings) {
                    var nowikis = [];
                    var replaced = original;
                    replaced = replaced.replace(REGEXP.nowiki, function (_, content) { return "<nowiki>".concat(nowikis.push(content) - 1, "</nowiki>"); });
                    replaced = replaced.replace(REGEXP.htmlEntity, function (_, index) { return "&".concat(mappings[index], ";"); });
                    replaced = replaced.replace(REGEXP.template, function (_, params) {
                        var paramList = params.split("|");
                        var name = mappings[paramList[0]];
                        paramList.shift();
                        return "".concat(paramList.reduce(function (acc, param) {
                            var _a = __read(param.split("=")), first = _a[0], rest = _a.slice(1);
                            return rest.length ? "".concat(acc, "|").concat(mappings[first], "=").concat(rest.join("=")) : "".concat(acc, "|").concat(param);
                        }, "{{".concat(name)), "}}");
                    });
                    replaced = replaced.replace(REGEXP.extLink, function (_, before, target, text, after) { return "".concat(before, "[").concat(mappings[target]).concat(text || "", "]").concat(after); });
                    replaced = replaced.replace(REGEXP.link, function (match, target, anchor, text) { return anchor || text ? "[[".concat(text ? mappings[target] : target).concat(mappings[anchor] ? "#".concat(mappings[anchor]) : "").concat(text || "", "]]") : match; });
                    replaced = replaced.replace(REGEXP.nowiki, function (_, index) { return "<nowiki>".concat(nowikis[index], "</nowiki>"); });
                    replaced = replaced.replace(REGEXP.lcMarkerEsc, function (_, index) { var _a; return "-{".concat((_a = mappings[index]) !== null && _a !== void 0 ? _a : index, "}-"); });
                    return replaced;
                };
                AIVCWindow = (function (_super) {
                    __extends(AIVCWindow, _super);
                    function AIVCWindow(config) {
                        var _this = _super.call(this, config) || this;
                        _this.config = config.data.config;
                        _this.prepopContent = config.data.prepopContent;
                        return _this;
                    }
                    AIVCWindow.prototype.initialize = function () {
                        _super.prototype.initialize.call(this);
                        this.configPanel = new OO.ui.PanelLayout({
                            scrollable: false,
                            expanded: false,
                            padded: true
                        });
                        this.confirmPanel = new OO.ui.PanelLayout({
                            scrollable: false,
                            expanded: false,
                            padded: true
                        });
                        this.ogText = new OO.ui.MultilineTextInputWidget({
                            value: this.prepopContent,
                            autosize: true
                        });
                        var textField = new OO.ui.FieldLayout(this.ogText, {
                            label: wgULS("原始内容", "原始內容"),
                            align: "top"
                        });
                        this.mainVariants = new OO.ui.TextInputWidget({
                            value: this.config.main.join(";")
                        });
                        var mainField = new OO.ui.FieldLayout(this.mainVariants, {
                            label: wgULS("主要变体", "主要變体"),
                            align: "top"
                        });
                        this.depVariants = new OO.ui.TextInputWidget({
                            value: Object.entries(this.config.dependent).map(function (_a) {
                                var _b = __read(_a, 2), k = _b[0], v = _b[1];
                                return "".concat(k, ":").concat(v);
                            }).join(";")
                        });
                        var depField = new OO.ui.FieldLayout(this.depVariants, {
                            label: wgULS("依赖变体", "依賴變体"),
                            align: "top"
                        });
                        this.noteTAParams = new OO.ui.TextInputWidget({
                            value: toParams(this.config.noteTA)
                        });
                        var noteTAField = new OO.ui.FieldLayout(this.noteTAParams, {
                            label: wgULS("NoteTA参数", "NoteTA參數"),
                            align: "top"
                        });
                        this.occCheckbox = new OO.ui.CheckboxInputWidget({
                            selected: this.config.useOpenCC
                        });
                        var occField = new OO.ui.FieldLayout(this.occCheckbox, {
                            label: "使用OpenCC",
                            align: "inline"
                        });
                        this.configPanel.$element.append(textField.$element, mainField.$element, depField.$element, noteTAField.$element, occField.$element);
                        this.stackLayout = new OO.ui.StackLayout({
                            items: [this.configPanel, this.confirmPanel]
                        });
                        this.ogText.connect(this, { resize: "updateSize" });
                        this.$body.append(this.stackLayout.$element);
                    };
                    AIVCWindow.prototype.getBodyHeight = function () {
                        return this.stackLayout.getCurrentItem().$element.outerHeight(true);
                    };
                    AIVCWindow.prototype.getSetupProcess = function (data) {
                        var _this = this;
                        return _super.prototype.getSetupProcess.call(this, data).next(function () {
                            _this.actions.setMode("config");
                            _this.stackLayout.setItem(_this.configPanel);
                        }, this);
                    };
                    AIVCWindow.prototype.getReadyProcess = function (data) {
                        var _this = this;
                        return _super.prototype.getReadyProcess.call(this, data)
                            .next(function () {
                            _this.ogText.focus();
                        }, this);
                    };
                    AIVCWindow.prototype.getActionProcess = function (action) {
                        var _this = this;
                        if (action === "cancel") {
                            return new OO.ui.Process(function () {
                                _this.close({ action: action });
                            }, this);
                        }
                        else if (action === "continue") {
                            return new OO.ui.Process($.when((function () { return __awaiter(_this, void 0, void 0, function () {
                                var e_1;
                                var _this = this;
                                return __generator(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            this.config = $.extend(this.config, {
                                                main: this.mainVariants.getValue().split(";"),
                                                dependent: Object.fromEntries(this.depVariants.getValue().split(";").map(function (v) { return v.split(":"); })),
                                                noteTAStr: this.noteTAParams.getValue(),
                                                useOpenCC: this.occCheckbox.isSelected(),
                                                dependentInv: {}
                                            });
                                            if (this.config.main.includes("(main)")) {
                                                throw new OO.ui.Error(wgULS("主页面不得作为主要变体", "主頁面不得作為主要變体"));
                                            }
                                            this.config.main.forEach(function (v) { return _this.config.dependentInv[v] = [v]; });
                                            try {
                                                Object.entries(this.config.dependent).forEach(function (_a) {
                                                    var _b = __read(_a, 2), k = _b[0], v = _b[1];
                                                    return _this.config.dependentInv[v].push(k);
                                                });
                                            }
                                            catch (_b) {
                                                console.error("[VariantConverter] Error: Key not found in dependentInv. Config dump:", this.config);
                                                throw new OO.ui.Error(wgULS("依赖变体格式错误,请检查控制台", "依賴變体格式錯誤,請檢查控制臺"));
                                            }
                                            this.textInputs = {};
                                            this.confirmPanel.$element.empty();
                                            _a.label = 1;
                                        case 1:
                                            _a.trys.push([1, 3, , 4]);
                                            return [4, this.getVariants(this.ogText.getValue())];
                                        case 2:
                                            _a.sent();
                                            this.actions.setMode("confirm");
                                            this.stackLayout.setItem(this.confirmPanel);
                                            this.updateSize();
                                            return [3, 4];
                                        case 3:
                                            e_1 = _a.sent();
                                            console.error("[VariantConverter] Error:", e_1);
                                            throw new OO.ui.Error(e_1);
                                        case 4: return [2];
                                    }
                                });
                            }); })()).promise(), this);
                        }
                        else if (action === "back") {
                            this.actions.setMode("config");
                            this.stackLayout.setItem(this.configPanel);
                            this.updateSize();
                        }
                        else if (action === "submit") {
                            return new OO.ui.Process($.when((function () { return __awaiter(_this, void 0, void 0, function () {
                                var e_2;
                                return __generator(this, function (_a) {
                                    switch (_a.label) {
                                        case 0:
                                            _a.trys.push([0, 2, , 3]);
                                            return [4, this.saveChanges()];
                                        case 1:
                                            _a.sent();
                                            this.close({ action: action });
                                            mw.notify("保存成功!", {
                                                title: wgULS("自动繁简转换工具", "自動繁簡轉換工具"),
                                                type: "success",
                                                tag: "lr-aivc"
                                            });
                                            setTimeout(function () { return location.reload(); }, 730);
                                            return [3, 3];
                                        case 2:
                                            e_2 = _a.sent();
                                            console.error("[VariantConverter] Error:", e_2);
                                            throw new OO.ui.Error(e_2);
                                        case 3: return [2];
                                    }
                                });
                            }); })()).promise(), this);
                        }
                        return _super.prototype.getActionProcess.call(this, action);
                    };
                    AIVCWindow.prototype.addVariant = function (variant, text) {
                        var _this = this;
                        var _a;
                        this.textInputs[variant] = new OO.ui.MultilineTextInputWidget({
                            value: text,
                            autosize: true
                        });
                        var field = new OO.ui.FieldLayout(this.textInputs[variant], {
                            label: variant,
                            align: "top"
                        });
                        this.textInputs[variant].connect(this, { resize: "updateSize" });
                        this.confirmPanel.$element.append(field.$element);
                        if ((_a = window === null || window === void 0 ? void 0 : window.InPageEdit) === null || _a === void 0 ? void 0 : _a.quickDiff) {
                            this.confirmPanel.$element.append(new OO.ui.FieldLayout(new OO.ui.Widget({
                                content: [
                                    new OO.ui.HorizontalLayout({
                                        items: this.config.dependentInv[variant].map(function (v) { return new OO.ui.ButtonWidget({
                                            label: "".concat(wgULS("对比", "對比")).concat(v === "(main)" ? wgULS("主页面", "主頁面") : v)
                                        }).on("click", function () { return window.InPageEdit.quickDiff({
                                            fromtitle: variantPage(v),
                                            totext: _this.textInputs[variant].getValue(),
                                            pageName: variantPage(v),
                                            isPreview: true
                                        }); }); })
                                    }),
                                ]
                            })).$element);
                        }
                    };
                    AIVCWindow.prototype.getVariants = function (original) {
                        return __awaiter(this, void 0, void 0, function () {
                            var _a, replaced, mappings, _loop_1, this_1, _b, _c, variant, e_3_1;
                            var e_3, _d;
                            var _e, _f;
                            return __generator(this, function (_g) {
                                switch (_g.label) {
                                    case 0:
                                        this.confirmPanel.$element.append("<p>".concat(wgULS("请确认以下转换是否正确", "請確認以下轉換是否正確"), "\uFF1A</p>"));
                                        if (!(!window.OpenCC && this.config.useOpenCC)) return [3, 2];
                                        return [4, libCachedCode.injectCachedCode("https://npm.elemecdn.com/opencc-js@latest", "script")];
                                    case 1:
                                        _g.sent();
                                        _g.label = 2;
                                    case 2:
                                        _a = escapeWikitext(original), replaced = _a.replaced, mappings = _a.mappings;
                                        _loop_1 = function (variant) {
                                            var text, parsed, _h, _j, _k, converted, occMappings_1, occVariant, converter, final, restored;
                                            return __generator(this, function (_l) {
                                                switch (_l.label) {
                                                    case 0:
                                                        if (variant === "(main)") {
                                                            return [2, "continue"];
                                                        }
                                                        text = "{{NoteTA|".concat(this_1.config.noteTAStr, "}}<pre id=\"converted\">-{}-").concat(replaced, "</pre>");
                                                        _h = $;
                                                        _k = (_j = $).parseHTML;
                                                        return [4, zhAPI.post({
                                                                action: "parse",
                                                                assertuser: username,
                                                                text: text,
                                                                contentmodel: "wikitext",
                                                                prop: "text",
                                                                uselang: variant,
                                                                disablelimitreport: true,
                                                                pst: true
                                                            })];
                                                    case 1:
                                                        parsed = _h.apply(void 0, [_k.apply(_j, [(_l.sent()).parse.text["*"]])]);
                                                        converted = parsed.find("#converted").text();
                                                        if (this_1.config.useOpenCC) {
                                                            occMappings_1 = [];
                                                            converted = converted.replace(REGEXP.noOCC, function (_, content) { return "<!--noOCC-->".concat(occMappings_1.push(content) - 1, "<!--/noOCC-->"); });
                                                            occVariant = variant.replace("hans", "cn").replace(/zh-(?:han)?/, "").replace("tw", "twp");
                                                            converter = OpenCC.Converter({ from: occVariant, to: occVariant });
                                                            converted = converter(converted);
                                                            converted = converted.replace(REGEXP.noOCC, function (_, index) { return "<!--noOCC-->".concat(occMappings_1[index], "<!--/noOCC-->"); });
                                                        }
                                                        final = ((_f = (_e = this_1.config.manualAction)[variant]) === null || _f === void 0 ? void 0 : _f.call(_e, converted)) || converted;
                                                        restored = restoreWikitext(final, mappings);
                                                        this_1.addVariant(variant, restored);
                                                        return [2];
                                                }
                                            });
                                        };
                                        this_1 = this;
                                        _g.label = 3;
                                    case 3:
                                        _g.trys.push([3, 8, 9, 10]);
                                        _b = __values(this.config.main), _c = _b.next();
                                        _g.label = 4;
                                    case 4:
                                        if (!!_c.done) return [3, 7];
                                        variant = _c.value;
                                        return [5, _loop_1(variant)];
                                    case 5:
                                        _g.sent();
                                        _g.label = 6;
                                    case 6:
                                        _c = _b.next();
                                        return [3, 4];
                                    case 7: return [3, 10];
                                    case 8:
                                        e_3_1 = _g.sent();
                                        e_3 = { error: e_3_1 };
                                        return [3, 10];
                                    case 9:
                                        try {
                                            if (_c && !_c.done && (_d = _b["return"])) _d.call(_b);
                                        }
                                        finally { if (e_3) throw e_3.error; }
                                        return [7];
                                    case 10: return [2];
                                }
                            });
                        });
                    };
                    AIVCWindow.prototype.saveChanges = function () {
                        return __awaiter(this, void 0, void 0, function () {
                            var _a, _b, _c;
                            var _this = this;
                            return __generator(this, function (_d) {
                                switch (_d.label) {
                                    case 0:
                                        _b = (_a = console).log;
                                        _c = ["[VariantConverter] Saved changes"];
                                        return [4, Promise.allSettled(this.config.main.map(function (variant) {
                                                var text = _this.textInputs[variant].getValue();
                                                return api.postWithToken("csrf", {
                                                    action: "edit",
                                                    assertuser: username,
                                                    title: variantPage(variant),
                                                    text: text,
                                                    summary: "\u81EA\u52A8\u8F6C\u6362\u81EA[[".concat(pagename, "]]"),
                                                    tags: "VariantConverter|Automation tool",
                                                    watchlist: _this.config.watchlist
                                                });
                                            }).concat(Object.entries(this.config.dependent).map(function (_a) {
                                                var _b = __read(_a, 2), variant = _b[0], parent = _b[1];
                                                var text = _this.textInputs[parent].getValue();
                                                return api.postWithToken("csrf", {
                                                    action: "edit",
                                                    assertuser: username,
                                                    title: variantPage(variant),
                                                    text: text,
                                                    summary: "\u81EA\u52A8\u8F6C\u6362\u81EA[[".concat(pagename, "]]\uFF08\u540C\u6B65").concat(parent, "\uFF09"),
                                                    tags: "VariantConverter|Automation tool",
                                                    watchlist: _this.config.watchlist
                                                });
                                            })))];
                                    case 1:
                                        _b.apply(_a, _c.concat([_d.sent()]));
                                        return [2];
                                }
                            });
                        });
                    };
                    AIVCWindow.static = __assign(__assign({}, _super.static), { tagName: "div", name: "lr-aivc", title: wgULS("自动繁简转换工具", "自動繁簡轉換工具"), actions: [
                            {
                                action: "cancel",
                                label: "取消",
                                flags: ["safe", "close", "destructive"],
                                modes: "config"
                            },
                            {
                                action: "continue",
                                label: wgULS("继续", "繼續"),
                                flags: ["primary", "progressive"],
                                modes: "config"
                            },
                            {
                                action: "back",
                                label: "返回",
                                flags: ["safe", "back"],
                                modes: "confirm"
                            },
                            {
                                action: "submit",
                                label: wgULS("确认", "確認"),
                                flags: ["primary", "progressive"],
                                modes: "confirm"
                            },
                        ] });
                    return AIVCWindow;
                }(OO.ui.ProcessDialog));
                $body = $(document.body);
                windowManager = new OO.ui.WindowManager();
                $body.append(windowManager.$element);
                aivcDialog = new AIVCWindow({
                    size: "large",
                    data: {
                        config: lrAivc,
                        prepopContent: prepopContent
                    }
                });
                windowManager.addWindows([aivcDialog]);
                $(mw.util.addPortletLink("p-cactions", "#", wgULS("自动繁简转换", "自動繁簡轉換"), "ca-VariantConverter", wgULS("自动同步界面消息的繁简版本", "自動同步介面消息的繁簡版本"))).on("click", function (e) {
                    e.preventDefault();
                    $("#mw-notification-area").appendTo($body);
                    windowManager.openWindow(aivcDialog);
                });
                return [2];
        }
    });
}); })(); }); 

/* </pre> */