MediaWiki:Gadget-HotCat.js:修订间差异
外观
AnnAngela-dbot(留言 | 贡献) 代码变动:103d1a56 - feat: rename (#594) by U:AnnAngela, co-authored-by: GH:github-actions[bot] 标签:由机器人或全自动脚本执行的操作 |
AnnAngela-dbot(留言 | 贡献) 代码变动:103d1a56 - feat: rename (#594) by U:AnnAngela, co-authored-by: GH:github-actions[bot] 标签:由机器人或全自动脚本执行的操作 |
||
| 第8行: | 第8行: | ||
/* <pre> */ | /* <pre> */ | ||
"use strict";window. | |||
/* </pre> */ | /* </pre> */ | ||
2025年7月25日 (五) 23:58的最新版本
/**
* -------------------------------------------------------------------------
* !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
* -------------------------------------------------------------------------
*/
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/HotCat/Gadget-HotCat.js|user=[[U:AnnAngela]]|co-authors=GH:github-actions[bot]|longId=103d1a563ea4ccc8ff29fb55c9bcd88329a56eb5|shortId=103d1a56|summary=feat: rename (#594)|body=<nowiki>Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}';
/* <pre> */
"use strict";window.hotcat_translations_from_commons=!1,(async()=>{function autoLocalize(t,i){function createRegexpStr(t){if(!t||!t.length)return"";let i="";for(let e=0;e<t.length;e++){const n=t.charAt(e),s=n.toLowerCase(),o=n.toUpperCase();i+=s===o?n:`[${s}${o}]`}return i.replace(/([\\^$.?*+()])/g,"\\$1").replace(wikiTextBlankRE,wikiTextBlank)}let e=i;e=e.toLowerCase();const n=formattedNamespaces[`${t}`].toLowerCase();let s=createRegexpStr(n);if(e&&n!==e&&(s+=`|${createRegexpStr(e)}`),namespaceIds)for(const i in namespaceIds)"string"==typeof i&&i.toLowerCase()!==n&&i.toLowerCase()!==e&&namespaceIds[i]===t&&(s+=`|${createRegexpStr(i)}`);return s}function make(t,i){return t?i?document.createTextNode(t):document.createElement(t):null}function param(t,i){const e=i||document.location.href,n=new RegExp(`[&?]${t}=([^&#]*)`).exec(e);return n&&n.length>1?decodeURIComponent(n[1]):null}function title(t){if(!t)return null;const i=`${conf.wgScript}?`;if(0===t.indexOf(i)||0===t.indexOf(`${conf.wgServer}${i}`)||"//"===conf.wgServer.substring(0,2)&&0===t.indexOf(`${document.location.protocol}${conf.wgServer}${i}`))return param("title",t);let e=conf.wgArticlePath.replace("$1","");return t.indexOf(e)&&(e=`${conf.wgServer}${e}`),t.indexOf(e)&&"//"===e.substring(0,2)&&(e=document.location.protocol+e),0===t.indexOf(e)?decodeURIComponent(t.substring(e.length)):null}function hasClass(t,i){return` ${t.className} `.indexOf(` ${i} `)>=0}function capitalize(t){return t&&t.length?t.substr(0,1).toUpperCase()+t.substr(1):t}function wikiPagePath(t){return conf.wgArticlePath.replace("$1",encodeURIComponent(t).replace(/%3A/g,":").replace(/%2F/g,"/"))}function escapeRE(t){return t.replace(/([\\^$.?*+()[\]])/g,"\\$1")}function substituteFactory(t){const i=t||{},e=i.indicator||"$",n=escapeRE(e),s=escapeRE(i.lbrace||"{"),o=escapeRE(i.rbrace||"}"),r=new RegExp(`(?:${n}(${n}))|(?:${n}(\\d+))|(?:${n}(?:${s}([^${s}${o}]+)${o}))|(?:${n}(?!(?:[${n}${s}]|\\d))(\\S+?)\\b)`,"g");return function(t,i){return i?t.replace(r,(t,n,s,o,r)=>{if(n===e)return e;const a=r||o||s,l="function"==typeof i[a]?i[a](t,a):i[a];return"string"==typeof l?l:l||t}):t}}function replaceByBlanks(t){return t.replace(/(\s|\S)/g," ")}function find_category(t,i,e){let n=null;if(HC.template_categories[i])n=new RegExp(`\\{\\{${wikiTextBlankOrBidi}(${HC.template_regexp}(?=${wikiTextBlankOrBidi}:))?${wikiTextBlankOrBidi}(?:${HC.template_categories[i]})${wikiTextBlankOrBidi}(\\|.*?)?\\}\\}`,"g");else{const t=escapeRE(i),e=t.substr(0,1);n=new RegExp(`\\[\\[${wikiTextBlankOrBidi}(${HC.category_regexp})${wikiTextBlankOrBidi}:${wikiTextBlankOrBidi}${"\\"!==e&&HC.capitalizePageNames?`[${e.toUpperCase()}${e.toLowerCase()}]`:e}${t.substring(1).replace(wikiTextBlankRE,wikiTextBlank)}${wikiTextBlankOrBidi}(\\|.*?)?\\]\\]`,"g")}if(e)return n.exec(t);const s=t.replace(/<!--(\s|\S)*?-->/g,replaceByBlanks).replace(/<nowiki>(\s|\S)*?<\/nowiki>/g,replaceByBlanks),o=[];let r=null;for(;null!==(r=n.exec(s));)o.push({match:r});return o.re=n,o}function change_category(t,i,e,n,s){let o=n,r=t;const a=[],l=HC.category_canonical,c=i&&e&&i===e&&e.length;let u,h=-1;if(o&&(o=`|${o}`),i&&i.length){if(u=find_category(r,i),!u||!u.length)return{text:r,summary:a,error:HC.messages.cat_notFound.replace(/\$1/g,i)};let t=r.substring(0,u[0].match.index),n=r.substring(u[0].match.index+u[0].match[0].length);u.length>1&&(u.re.lastIndex=0,n=n.replace(u.re,"")),e&&null===o&&(o=u[0].match[2]);let s=t.length-1;for(;s>=0&&"\n"!==t.charAt(s)&&t.substr(s,1).search(/\s/)>=0;)s--;let l=0;for(;l<n.length&&"\n"!==n.charAt(l)&&n.substr(l,1).search(/\s/)>=0;)l++;s>=0&&"\n"===t.charAt(s)&&(!n.length||l<n.length&&"\n"===n.charAt(l))&&s--,t=s>=0?t.substring(0,s+1):"",n=l<n.length?n.substring(l):"",t.length&&t.substring(t.length-1).search(/\S/)>=0&&n.length&&n.substr(0,1).search(/\S/)>=0&&(t+=" "),h=t.length,0===h&&n.length&&"\n"===n.substr(0,1)&&(n=n.substr(1)),r=t+n,c||(HC.template_categories[i]?a.push(HC.messages.template_removed.replace(/\$1/g,i)):a.push(HC.messages.cat_removed.replace(/\$1/g,i)))}if(e&&e.length){if(u=find_category(r,e),u&&u.length)return{text:r,summary:a,error:HC.messages.cat_exists.replace(/\$1/g,e)};let t=!1;if(h<0){const i=function find_insertionpoint(t){const i=t.replace(/<!--(\s|\S)*?-->/g,replaceByBlanks).replace(/<nowiki>(\s|\S)*?<\/nowiki>/g,replaceByBlanks);let e=-1;for(findCatsRE.lastIndex=0;null!==findCatsRE.exec(i);)e=findCatsRE.lastIndex;if(e<0){let t=null;return t=interlanguageRE?interlanguageRE.exec(i):/((^|\n\r?)(\[\[\s*(([a-z]{2,3}(-[a-z]+)*)|simple|tokipona)\s*:[^\]]+\]\]\s*))+$/.exec(i),t&&(e=t.index),{idx:e,onCat:!1}}return{idx:e,onCat:e>=0}}(r);h=i.idx,t=i.onCat}else t=!0;const i=`[[${l}:${e}${o||""}]]`;if(h>=0){const e=r.substring(h);r=r.substring(0,h)+(h>0?"\n":"")+i+(t?"":"\n"),e.length&&"\n"!==e.substr(0,1)?r+=`\n${e}`:r+=e}else r.length&&"\n"!==r.substr(r.length-1,1)&&(r+="\n"),r+=(r.length?"\n":"")+i;if(c){let t=o||"";t.length&&(t=t.substr(1)),a.push(substitute(HC.messages.cat_keychange,[null,e,t]))}else a.push(HC.messages.cat_added.replace(/\$1/g,e));if(HC.uncat_regexp&&!s){const t=r.replace(HC.uncat_regexp,"");t.length!==r.length&&(r=t,a.push(HC.messages.uncat_removed))}}return{text:r,summary:a,error:null}}function evtKeys(t){let i=0;return t.ctrlKey&&((t.ctrlKey||t.metaKey)&&(i|=1),t.shiftKey&&(i|=2)),i}function evtKill(t){return t.preventDefault?(t.preventDefault(),t.stopPropagation()):t.cancelBubble=!0,!1}function setPage(t){let i=null;if(t&&t.query){if(t.query.pages){const e=t.query.pages[conf.wgArticleId?`${conf.wgArticleId}`:"-1"];if(e&&(e.revisions&&e.revisions.length&&(pageText=e.revisions[0]["*"],e.revisions[0].timestamp&&(pageTime=e.revisions[0].timestamp.replace(/\D/g,"")),e.revisions[0].revid&&(pageTextRevId=e.revisions[0].revid),e.revisions.length>1&&(conflictingUser=e.revisions[1].user)),e.lastrevid&&(lastRevId=e.lastrevid),e.starttimestamp&&(i=e.starttimestamp.replace(/\D/g,"")),pageWatched="string"==typeof e.watched,t.query.tokens&&(editToken=t.query.tokens.csrftoken),e.langlinks&&(!t["query-continue"]||!t["query-continue"].langlinks))){let t="";for(let i=0;i<e.langlinks.length;i++)t+=(i>0?"|":"")+e.langlinks[i].lang.replace(/([\\^$.?*+()])/g,"\\$1");t.length&&(interlanguageRE=new RegExp(`((^|\\n\\r?)(\\[\\[\\s*(${t})\\s*:[^\\]]+\\]\\]\\s*))+$`))}}t.query.general&&(t.query.general.time&&!i&&(i=t.query.general.time.replace(/\D/g,"")),null===HC.capitalizePageNames&&(HC.capitalizePageNames="first-letter"===t.query.general.case)),serverTime=i,t.query.userinfo&&t.query.userinfo.options&&(watchCreate=!HC.dont_add_to_watchlist&&"1"===t.query.userinfo.options.watchcreations,watchEdit=!HC.dont_add_to_watchlist&&"1"===t.query.userinfo.options.watchdefault,minorEdits=1===t.query.userinfo.options.minordefault,minorEdits&&(HC.single_minor=!0))}}async function initiateEdit(t,i){function fail(...t){saveInProgress=!1,commitButton&&(commitButton.disabled=e),i(...t)}if(saveInProgress)return;let e;saveInProgress=!0,commitButton&&(e=commitButton.disabled,commitButton.disabled=!0);try{setPage(await $.getJSON(`${conf.wgServer}${conf.wgScriptPath}/api.php?format=json&action=query&rawcontinue=&titles=${encodeURIComponent(conf.wgPageName)}&prop=info%7Crevisions%7Clanglinks&inprop=watched&rvprop=content%7Ctimestamp%7Cids%7Cuser&lllimit=500&rvlimit=2&rvdir=newer&rvstartid=${conf.wgCurRevisionId}&meta=siteinfo%7Cuserinfo%7Ctokens&type=csrf&uiprop=options`)),t(fail)}catch(t){fail(`${t.status} ${t.statusText}`)}}function multiChangeMsg(t){let i=HC.messages.multi_change;return"string"!=typeof i&&i.length&&(i=mw.language&&mw.language.convertPlural?mw.language.convertPlural(t,i):i[i.length-1]),substitute(i,[null,`${t}`])}function currentTimestamp(){function two(t){return t.substr(t.length-2)}const t=new Date;let i=`${t.getUTCFullYear()}`;return i+=two(`0${t.getUTCMonth()+1}`)+two(`0${t.getUTCDate()}`)+two(`00${t.getUTCHours()}`)+two(`00${t.getUTCMinutes()}`)+two(`00${t.getUTCSeconds()}`),i}function performChanges(t,i){if(null===pageText)return void t(HC.messages.multi_error);let e;HC.messages.cat_keychange.indexOf("$2")<0&&(HC.messages.cat_keychange+='"$2"'),HC.messages.short_catchange||(HC.messages.short_catchange=`[[${HC.category_canonical}:$1]]`);const n=(null!==lastRevId&&lastRevId!==conf.wgCurRevisionId||null!==pageTextRevId&&pageTextRevId!==conf.wgCurRevisionId)&&conflictingUser&&conflictingUser===conf.wgUserName;!i||i.noCommit||HC.no_autocommit||!editToken||n?(e=commitForm.wpSave,e&&(e.name=e.value="wpDiff")):(commitForm.wpEditToken.value=editToken,e=commitForm.wpDiff,e&&(e.name=e.value="wpSave",commitForm.wpChangeTags.value+=`,${HC.automationChangeTag}`));let s={text:pageText};const o=[],r=[],a=[],l=i?[i]:editors;let c,u,h=0,d=null;for(u=0;u<l.length;u++)c=l[u],c.state===CategoryEditor.CHANGED?(s=change_category(s.text,c.originalCategory,c.currentCategory,c.currentKey,c.currentHidden),s.error?null===d&&(d=s.error):(h++,c.originalCategory&&c.originalCategory.length?o.push({from:c.originalCategory,to:c.currentCategory}):r.push(c.currentCategory))):c.state===CategoryEditor.DELETED&&c.originalCategory&&c.originalCategory.length&&(s=change_category(s.text,c.originalCategory,null,null,!1),s.error?null===d&&(d=s.error):(h++,a.push(c.originalCategory)));if(null!==d&&(e=commitForm.wpSave,e&&(e.name=e.value="wpDiff")),commitForm.wpMinoredit.checked=minorEdits,commitForm.wpWatchthis.checked=!conf.wgArticleId&&watchCreate||watchEdit||pageWatched,conf.wgArticleId||i)if(e&&"wpSave"===e.value?HC.changeTag&&(commitForm.wpChangeTags.value=`${HC.changeTag},${HC.automationChangeTag}`,HC.messages.using="",HC.messages.prefix=""):commitForm.wpAutoSummary.value=HC.changeTag,1===h)s.summary&&s.summary.length&&(commitForm.wpSummary.value=HC.messages.prefix+s.summary.join(HC.messages.separator)+HC.messages.using),commitForm.wpMinoredit.checked=HC.single_minor||minorEdits;else if(h){let t=[];const i=[];for(u=0;u<a.length;u++)t.push(`-${substitute(HC.messages.short_catchange,[null,a[u]])}`);for(1===a.length?i.push(`-${substitute(HC.messages.short_catchange,[null,a[0]])}`):a.length&&i.push(`- ${multiChangeMsg(a.length)}`),u=0;u<r.length;u++)t.push(`+${substitute(HC.messages.short_catchange,[null,r[u]])}`)
;1===r.length?i.push(`+${substitute(HC.messages.short_catchange,[null,r[0]])}`):r.length&&i.push(`+ ${multiChangeMsg(r.length)}`);const e=is_rtl?"←":"→";for(u=0;u<o.length;u++)o[u].from!==o[u].to?t.push(`±${substitute(HC.messages.short_catchange,[null,o[u].from])}${e}${substitute(HC.messages.short_catchange,[null,o[u].to])}`):t.push(`±${substitute(HC.messages.short_catchange,[null,o[u].from])}`);1===o.length?o[0].from!==o[0].to?i.push(`±${substitute(HC.messages.short_catchange,[null,o[0].from])}${e}${substitute(HC.messages.short_catchange,[null,o[0].to])}`):i.push(`±${substitute(HC.messages.short_catchange,[null,o[0].from])}`):o.length&&i.push(`± ${multiChangeMsg(o.length)}`),t.length&&(t=t.join(HC.messages.separator),t.length>200-HC.messages.prefix.length-HC.messages.using.length&&(t=i.join(HC.messages.separator)),commitForm.wpSummary.value=HC.messages.prefix+t+HC.messages.using)}commitForm.wpTextbox1.value=s.text,commitForm.wpStarttime.value=serverTime||currentTimestamp(),commitForm.wpEdittime.value=pageTime||commitForm.wpStarttime.value,n&&(commitForm.oldid.value=`${pageTextRevId||conf.wgCurRevisionId}`),commitForm.hcCommit.click()}function resolveOne(t,i){const e=t.categories,n=t.links,s=t.categoryinfo&&"string"==typeof t.categoryinfo.hidden,o="string"==typeof t.missing;let r,a=!1,l="string"==typeof t.redirect;for(r=0;r<i.length;r++)r&&i[r].dabInputCleaned!==t.title.substring(t.title.indexOf(":")+1)||(i[r].currentHidden=s,i[r].inputExists=!o,i[r].icon.src=o?HC.existsNo:HC.existsYes);if(o)return;if(!l&&e&&(HC.disambig_category||HC.redir_category))for(let t=0;t<e.length;t++){let i=e[t].title;if(i){if(i=i.substring(i.indexOf(":")+1).replace(/_/g," "),i===HC.disambig_category){a=!0;break}if(i===HC.redir_category){l=!0;break}}}if(!l&&!a)return;if(!n||!n.length)return;const c=[];for(r=0;r<n.length;r++)if(14===n[r].ns&&n[r].title&&n[r].title.length){let t=n[r].title;t=t.substring(t.indexOf(":")+1),HC.blacklist&&HC.blacklist.test(t)||c.push(t)}if(c.length)for(r=0;r<i.length;r++)r&&i[r].dabInputCleaned!==t.title.substring(t.title.indexOf(":")+1)||(i[r].inputExists=!0,i[r].icon.src=HC.existsYes,c.length>1?i[r].dab=c:i[r].text.value=c[0]+(null!==i[r].currentKey?`|${i[r].currentKey}`:""))}function resolveRedirects(t,i){if(i&&i.query&&i.query.pages)for(const e in i.query.pages)resolveOne(i.query.pages[e],t)}async function resolveMulti(t,i){let e;for(e=0;e<t.length;e++)t[e].dab=null,t[e].dabInput=t[e].lastInput;if(noSuggestions)return void i(t);let n=`action=query&prop=info%7Clinks%7Ccategories%7Ccategoryinfo&plnamespace=14&pllimit=${10*t.length}&cllimit=${10*t.length}&format=json&titles=`;for(e=0;e<t.length;e++){let i=t[e].dabInput;i=replaceShortcuts(i,HC.shortcuts),t[e].dabInputCleaned=i,n+=encodeURIComponent(`Category:${i}`),e+1<t.length&&(n+="%7C")}try{resolveRedirects(t,await $.getJSON(`${conf.wgServer}${conf.wgScriptPath}/api.php?${n}`)),i(t)}catch(e){e||(noSuggestions=!0),i(t)}}function makeActive(t){if(!t.is_active){for(let i=0;i<editors.length;i++)editors[i]!==t&&editors[i].inactivate();if(t.is_active=!0,t.dab)showDab(t);else{const i=t.lastRealInput||t.lastInput||"",e=t.text.value||"";if(!i.length&&e.length||i.length&&e.indexOf(i)){t.showsList=!1;const i=e.split("|");t.lastRealInput=t.lastInput=i[0],i.length>1&&(t.currentKey=i[1]),t.lastSelection&&(t.lastSelection={start:i[0].length,end:i[0].length})}t.showsList&&t.displayList(),t.lastSelection&&(is_webkit?window.setTimeout(()=>{t.setSelection(t.lastSelection.start,t.lastSelection.end)},1):t.setSelection(t.lastSelection.start,t.lastSelection.end))}}}function showDab(t){t.is_active?(t.showSuggestions(t.dab,!1,null,null),t.dab=null):makeActive(t)}function multiSubmit(){const t=[];for(let i=0;i<editors.length;i++)editors[i].state!==CategoryEditor.CHANGE_PENDING&&editors[i].state!==CategoryEditor.OPEN||t.push(editors[i]);t.length?resolveMulti(t,t=>{let i=null,e=!1;for(let n=0;n<t.length;n++)t[n].lastInput!==t[n].dabInput?e=!0:t[n].dab?i||(i=t[n]):t[n].acceptCheck(!0)&&t[n].commit();i?showDab(i):e||initiateEdit(t=>{performChanges(t)},t=>{oouiDialog.alert(oouiDialog.sanitize(t),{title:"HotCat 小工具"})})}):initiateEdit(t=>{performChanges(t)},t=>{oouiDialog.alert(oouiDialog.sanitize(t),{title:"HotCat 小工具"})})}function setMultiInput(){commitButton||onUpload||(commitButton=make("input"),commitButton.type="button",commitButton.value=HC.messages.commit,commitButton.onclick=multiSubmit,multiSpan?multiSpan.parentNode.replaceChild(commitButton,multiSpan):catLine.appendChild(commitButton))}function checkMultiInput(){if(!commitButton)return;let t=!1;for(let i=0;i<editors.length;i++)if(editors[i].state!==CategoryEditor.UNCHANGED){t=!0;break}commitButton.disabled=!t}function forceRedraw(){dummyElement.parentNode?document.body.removeChild(dummyElement):document.body.appendChild(dummyElement)}function initialize(){const t=void 0!==window.JSconfig&&window.JSconfig.keys?window.JSconfig.keys:{};if(HC.dont_add_to_watchlist=void 0!==window.hotcat_dont_add_to_watchlist?!!window.hotcat_dont_add_to_watchlist:void 0!==t.HotCatDontAddToWatchlist?t.HotCatDontAddToWatchlist:HC.dont_add_to_watchlist,HC.no_autocommit=void 0!==window.hotcat_no_autocommit?!!window.hotcat_no_autocommit:void 0!==t.HotCatNoAutoCommit?t.HotCatNoAutoCommit:!!(conf.wgNamespaceNumber%2)||HC.no_autocommit,HC.del_needs_diff=void 0!==window.hotcat_del_needs_diff?!!window.hotcat_del_needs_diff:void 0!==t.HotCatDelNeedsDiff?t.HotCatDelNeedsDiff:HC.del_needs_diff,HC.suggest_delay=window.hotcat_suggestion_delay||t.HotCatSuggestionDelay||HC.suggest_delay,HC.editbox_width=window.hotcat_editbox_width||t.HotCatEditBoxWidth||HC.editbox_width,HC.suggestions=window.hotcat_suggestions||t.HotCatSuggestions||HC.suggestions,"string"==typeof HC.suggestions&&suggestionConfigs[HC.suggestions]||(HC.suggestions="combined"),HC.fixed_search=void 0!==window.hotcat_suggestions_fixed?!!window.hotcat_suggestions_fixed:void 0!==t.HotCatFixedSuggestions?t.HotCatFixedSuggestions:HC.fixed_search,HC.single_minor=void 0!==window.hotcat_single_changes_are_minor?!!window.hotcat_single_changes_are_minor:void 0!==t.HotCatMinorSingleChanges?t.HotCatMinorSingleChanges:HC.single_minor,HC.bg_changed=window.hotcat_changed_background||t.HotCatChangedBackground||HC.bg_changed,HC.use_up_down=void 0!==window.hotcat_use_category_links?!!window.hotcat_use_category_links:void 0!==t.HotCatUseCategoryLinks?t.HotCatUseCategoryLinks:HC.use_up_down,HC.listSize=window.hotcat_list_size||t.HotCatListSize||HC.listSize,"commonswiki"!==conf.wgDBname&&(HC.changeTag=t.HotCatChangeTag||""),HC.changeTag){const t=document.editform,i=new RegExp(`^\\[\\[(${HC.category_regexp}):`);let e;const isMinorChange=function(){let n,s=t.wpTextbox1;if(s)return s=s.value,n=function(t,i){const e=[];let n,s;t.length<i.length?(n=i,s=t):(n=t,s=i);for(let t=0;t<n.length;t++){const i=n[t],o=$.inArray(i,s);-1===o?e.push(i):s.splice(o,1)}return e.concat(s)}(e.match(/^.*$/gm),s.match(/^.*$/gm)),n.length&&(n=$.grep(n,t=>{const e=$.trim(t);return e&&!i.test(e)})),n.length?void 0:(e=s,!0)};if("submit"===conf.wgAction&&conf.wgArticleId&&t&&t.wpSummary&&document.getElementById("wikiDiff")){const i=t.wpSummary,n=t.wpAutoSummary;if(i.value&&n.value===HC.changeTag){n.value=n.value.replace(HC.changeTag,"d41d8cd98f00b204e9800998ecf8427e");const s=$('<input type="hidden" name="wpChangeTags">').val(HC.changeTag);$(t).append(s),e=t.wpTextbox1.value,$("#wpSave").one("click",()=>{s.val()&&(i.value=i.value.replace(HC.messages.using||HC.messages.prefix,""))});const removeChangeTag=()=>{$(t.wpTextbox1).add(i).one("input",()=>{window.setTimeout(()=>{isMinorChange()?removeChangeTag():s.val("")},500)})};removeChangeTag()}}}if(HC.listSize=parseInt(HC.listSize,10),(isNaN(HC.listSize)||HC.listSize<5)&&(HC.listSize=5),HC.listSize=Math.min(HC.listSize,30),HC.engine_names)for(const t in HC.engine_names)suggestionConfigs[t]&&HC.engine_names[t]&&(suggestionConfigs[t].name=HC.engine_names[t]);is_rtl=hasClass(document.body,"rtl"),is_rtl||(is_rtl=document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(document.body,null).getPropertyValue("direction"):document.body.currentStyle?document.body.currentStyle.direction:document.body.style.direction,is_rtl="rtl"===is_rtl)}function can_edit(){let t=null;switch(mw.config.get("skin")){case"cologneblue":t=document.getElementById("quickbar");case"standard":case"nostalgia":{t||(t=document.getElementById("topbar"));const i=t.getElementsByTagName("a");for(let t=0;t<i.length;t++)if(param("title",i[t].href)===conf.wgPageName&&"edit"===param("action",i[t].href))return!0;return!1}default:return null!==document.getElementById("ca-edit")}}function closeForm(){for(let t=0;t<editors.length;t++){const i=editors[t];if(i.state===CategoryEditor.OPEN)i.cancel();else if(i.state===CategoryEditor.CHANGE_PENDING){i.sanitizeInput();const t=i.text.value.split("|");let e=null;t.length>1&&(e=t[1]);const n=t[0].replace(/_/g," ").replace(/^\s+|\s+$/g,"");n.length?(i.currentCategory=n,i.currentKey=e,i.currentExists=this.inputExists,i.close()):i.cancel()}}}function setup_upload(){onUpload=!0;let ip=document.getElementById("mw-htmlform-description")||document.getElementById("wpDestFile");if(!ip)for(ip=document.getElementById("wpDestFile");ip&&"table"!==ip.nodeName.toLowerCase();)ip=ip.parentNode;if(!ip)return;const reupload=document.getElementById("wpForReUpload"),destFile=document.getElementById("wpDestFile");if(reupload&&reupload.value||destFile&&(destFile.disabled||destFile.readOnly))return;const labelCell=make("td"),lineCell=make("td");catLine=make("div"),catLine.className="catlinks",catLine.id="catlinks",catLine.style.textAlign=is_rtl?"right":"left",catLine.style.margin="0",catLine.style.border="none",lineCell.appendChild(catLine);let label=null;if(window.UFUI&&window.UIElements&&window.UFUI.getLabel instanceof Function)try{label=window.UFUI.getLabel("wpCategoriesUploadLbl")}catch(t){label=null}label?(labelCell.id="hotcatLabelTranslated",labelCell.appendChild(label)):(labelCell.id="hotcatLabel",labelCell.appendChild(make(HC.categories,!0))),labelCell.className="mw-label",labelCell.style.textAlign="right",labelCell.style.verticalAlign="middle"
;const form=document.getElementById("upload")||document.getElementById("mw-upload-form");if(form&&ip&&ip.insertRow){const newRow=ip.insertRow(-1);newRow.appendChild(labelCell),newRow.appendChild(lineCell),form.onsubmit=function(oldSubmit){return function(...args){let do_submit=!0;if(oldSubmit&&("string"==typeof oldSubmit?do_submit=eval(oldSubmit):oldSubmit instanceof Function&&(do_submit=oldSubmit.bind(form)(...args))),!do_submit)return!1;closeForm();const eb=document.getElementById("wpUploadDescription")||document.getElementById("wpDesc");let addedOne=!1;for(let t=0;t<editors.length;t++){const i=editors[t].currentCategory;if(!i)continue;const e=editors[t].currentKey,n=`[[${HC.category_canonical}:${i}${e?`|${e}`:""}]]`,s=eb.value.replace(/<!--(\s|\S)*?-->/g,"").replace(/<nowiki>(\s|\S)*?<\/nowiki>/g,"");find_category(s,i,!0)||(eb.value+=`\n${n}`,addedOne=!0)}return addedOne&&(eb.value=eb.value.replace(/\{\{subst:unc\}\}/g,"")),!0}}(form.onsubmit)}}function getTitle(t){if(t.firstChild.nodeType!==Node.ELEMENT_NODE)return null;let i=title(t.firstChild.getAttribute("href"));return i?(i=i.substr(i.indexOf(":")+1).replace(/_/g," "),HC.blacklist&&HC.blacklist.test(i)?null:i):null}function isOnPage(t){const i=getTitle(t),e={title:i,match:["","",""]};return null===pageText||(null===cleanedText&&(cleanedText=pageText.replace(/<!--(\s|\S)*?-->/g,"").replace(/<nowiki>(\s|\S)*?<\/nowiki>/g,"")),e.match=find_category(cleanedText,i,!0)),e}function findByClass(t,i,e){const n=$(t).find(`${i}.${e}`);return n&&n.length?n[0]:null}function list_categorys(){if(null===pageText)return[];null===cleanedText&&(cleanedText=pageText.replace(/<!--(\s|\S)*?-->/g,"").replace(/<nowiki>(\s|\S)*?<\/nowiki>/g,""));const t=new RegExp(`\\[\\[${wikiTextBlankOrBidi}(${HC.category_regexp})${wikiTextBlankOrBidi}:${wikiTextBlankOrBidi}([^\\[\\]]+?)${wikiTextBlankOrBidi}(\\|.*?)?\\]\\]`,"g"),i=[];let e=null;for(;null!==(e=t.exec(cleanedText));)i.push({match:e});return i.re=t,i}function setup(t){function createEditors(t,i,s){let o,r=t,a=r.getElementsByTagName("li");a.length?(newDOM=!0,r=a[0].parentNode):a=r.getElementsByTagName("span");const l=Array.from({length:a.length}),c={};let u=null;for(o=0;o<a.length;o++)l[o]=a[o],u=getTitle(l[o]),u&&(c[u]=o);const h=list_categorys();for(o=0;o<h.length;o++){let t=h[o].match[2].replace(wikiTextBlankRE," ");HC.capitalizePageNames&&(t=t.substr(0,1).toUpperCase()+t.substr(1)),Reflect.has(c,t)&&r?(new CategoryEditor(r,l[c[t]],h[o].match[2],h[o].match[3],i),i&&Reflect.has(n,t)&&(e.splice(e.indexOf(`${HC.category_canonical}:${t}`),1),Reflect.deleteProperty(n,t))):!i&&r&&(e.push(`${HC.category_canonical}:${t}`),n[t]=o)}if(e.length&&(!i&&!s||i)){const t=e.join("|");$.getJSON(`${conf.wgServer}${conf.wgScriptPath}/api.php?action=query&format=json&titles=${encodeURIComponent(t)}&redirects=1&converttitles=1`,s=>{let a=s.query.converted;for((!a||a.length<e.length)&&console.log(t),a||(a=[]),o=0;o<a.length;o++){const t=a[o].to.replace(`${HC.category_canonical}:`,""),e=n[a[o].from.replace(`${HC.category_canonical}:`,"")];Reflect.has(c,t)&&r?new CategoryEditor(r,l[c[t]],[h[e].match[2],t],h[e].match[3],i):console.log(t)}})}return l.length?l[l.length-1]:null}if(initialized)return;initialized=!0,setupTimeout&&(window.clearTimeout(setupTimeout),setupTimeout=null),catLine||(catLine=document.getElementById("mw-normal-catlinks"));const i=document.getElementById("mw-hidden-catlinks");if(!catLine){let t=null;if(!i&&(t=findByClass(document,"div","printfooter"),!t))return;catLine=make("div"),catLine.id="mw-normal-catlinks",catLine.style.textAlign=is_rtl?"right":"left";const e=make("a");e.href=conf.wgArticlePath.replace("$1","Special:Categories"),e.title=HC.categories,e.appendChild(make(HC.categories,!0)),catLine.appendChild(e),catLine.appendChild(make(":",!0));let n=i?i.parentNode:document.getElementById("catlinks");n||(n=make("div"),n.id="catlinks",t.parentNode.insertBefore(n,t.nextSibling)),n.className="catlinks noprint",n.style.display="",i?n.insertBefore(catLine,i):n.appendChild(catLine)}is_rtl&&(catLine.dir="rtl");const e=[],n={},s=createEditors(catLine,!1,!!i);if(new CategoryEditor(newDOM?catLine.getElementsByTagName("ul")[0]:catLine,null,null,null!==s,!1),!onUpload){null!==pageText&&i&&(is_rtl&&(i.dir="rtl"),createEditors(i,!0,!0));const t=make("span");t.className="noprint",is_rtl&&(t.dir="rtl"),catLine.insertBefore(t,catLine.firstChild.nextSibling),t.appendChild(make(" ",!0)),multiSpan=make("span"),t.appendChild(multiSpan),multiSpan.innerHTML=`(<a>${HC.addmulti}</a>)`;const e=multiSpan.getElementsByTagName("a")[0];e.onclick=function(t){return setMultiInput(),checkMultiInput(),evtKill(t)},e.title=HC.multi_tooltip,e.style.cursor="pointer"}cleanedText=null,t instanceof Function&&t(),mw.hook("hotcat.ready").fire(),$("body").trigger("hotcatSetupCompleted")}function createCommitForm(){if(commitForm)return;const t=make("div");t.style.display="none",document.body.appendChild(t),t.innerHTML=`<form id="hotcatCommitForm" method="post" enctype="multipart/form-data" action="${conf.wgScript}?title=${encodeURIComponent(conf.wgPageName)}&action=submit"><input type="hidden" name="wpTextbox1"><input type="hidden" name="model" value="${conf.wgPageContentModel}"><input type="hidden" name="format" value="text/x-wiki"><input type="hidden" name="wpSummary" value=""><input type="checkbox" name="wpMinoredit" value="1"><input type="checkbox" name="wpWatchthis" value="1"><input type="hidden" name="wpAutoSummary" value="d41d8cd98f00b204e9800998ecf8427e"><input type="hidden" name="wpEdittime"><input type="hidden" name="wpStarttime"><input type="hidden" name="wpDiff" value="wpDiff"><input type="hidden" name="oldid" value="0"><input type="hidden" name="wpIgnoreBlankSummary" value="1"><input type="submit" name="hcCommit" value="hcCommit"><input type="hidden" name="wpEditToken"><input type="hidden" name="wpUltimateParam" value="1"><input type="hidden" name="wpChangeTags"><input type="hidden" value="ℳ𝒲♥𝓊𝓃𝒾𝒸ℴ𝒹ℯ" name="wpUnicodeCheck"></form>`,commitForm=document.getElementById("hotcatCommitForm")}function getPage(){if(conf.wgArticleId){const t=`${conf.wgServer}${conf.wgScriptPath}/api.php?format=json&callback=HotCat.start&action=query&rawcontinue=&titles=${encodeURIComponent(conf.wgPageName)}&prop=info%7Crevisions&rvprop=content%7Ctimestamp%7Cids&meta=siteinfo&rvlimit=1&rvstartid=${conf.wgCurRevisionId}`;$.getJSON(t.replace("&callback=HotCat.start",""),t=>{setPage(t),setup(createCommitForm)}),setupTimeout=window.setTimeout(()=>{setup(createCommitForm)},4e3)}else{if(2===conf.wgNamespaceNumber)return;pageText="",pageTime=null,setup(createCommitForm)}}function setState(t){const i=t.split("\n");if(!i.length)return null;if(initialized&&1===editors.length&&editors[0].isAddCategory){const t=[],e=1===editors.length?editors[0].span:null;let n;for(n=0;n<i.length;n++){if(!i[n].length)continue;let s=i[n].split("|");const o=s.length>1?s[1]:null;s=s[0];const r=make("a");r.href=wikiPagePath(`${HC.category_canonical}:${s}`),r.appendChild(make(s,!0)),r.title=s;const a=make("span");a.appendChild(r),n||catLine.insertBefore(make(" ",!0),e),catLine.insertBefore(a,e),e&&n+1<i.length&&parent.insertBefore(make(" | ",!0),e),t.push({element:a,title:s,key:o})}for(e&&e.parentNode.insertBefore(make(" | ",!0),e),n=0;n<t.length;n++)new CategoryEditor(catLine,t[n].element,t[n].title,t[n].key)}return null}function getState(){let t=null;for(let i=0;i<editors.length;i++){let e=editors[i].currentCategory;const n=editors[i].currentKey;e&&e.length&&(null!==n&&(e+=`|${n}`),null===t?t=e:t+=`\n${e}`)}return t}function really_run(){if(initialize(),!HC.upload_disabled&&-1===conf.wgNamespaceNumber&&"Upload"===conf.wgCanonicalSpecialPageName&&conf.wgUserName)setup_upload(),setup(()=>{window.UploadForm&&window.UploadForm.previous_hotcat_state&&(window.UploadForm.previous_hotcat_state=setState(window.UploadForm.previous_hotcat_state))});else{if(!conf.wgIsArticle||"view"!==conf.wgAction||null!==param("diff")||null!==param("oldid")||!can_edit()||HC.disable())return;getPage()}}function run(){HC.started||(HC.started=!0,loadTrigger.register(really_run))}await $.ready;const conf=new Proxy({},{get:(t,i)=>"wgServer"===i?`https://${location.hostname}`:mw.config.get(i)});if(window.HotCat&&!window.HotCat.nodeName||"edit"===conf.wgAction)return;const userRights=await mw.user.getRights(),autopatrol=userRights.includes("autopatrol");window.hotcat_no_autocommit=!autopatrol,window.hotcat_del_needs_diff=!autopatrol;const HC=window.HotCat={messages:{cat_removed:"removed [[Category:$1]]",template_removed:"removed {{[[Category:$1]]}}",cat_added:"added [[Category:$1]]",cat_keychange:'new key for [[Category:$1]]: "$2"',cat_notFound:'Category "$1" not found',cat_exists:'Category "$1" already exists; not added.',cat_resolved:" (redirect [[Category:$1]] resolved)",uncat_removed:"removed {{uncategorized}}",separator:"; ",prefix:"",using:" using [[Help:Gadget-HotCat|HotCat]]",multi_change:"$1 categories",commit:"Save",ok:"OK",cancel:"Cancel",multi_error:"Could not retrieve the page text from the server. Therefore, your category changes cannot be saved. We apologize for the inconvenience.",short_catchange:null},categories:"Categories",disambig_category:"Disambiguation",redir_category:"Category redirects",links:{change:"(±)",remove:"(−)",add:"(+)",restore:"(×)",undo:"(×)",down:"(↓)",up:"(↑)"},changeTag:"HotCat",automationChangeTag:"Automation tool",tooltips:{change:"Modify",remove:"Remove",add:"Add a new category",restore:"Undo changes",undo:"Undo changes",down:"Open for modifying and display subcategories",up:"Open for modifying and display parent categories"},addmulti:"<span>+<sup>+</sup></span>",multi_tooltip:"Modify several categories",disable:()=>{const t=mw.config.get("wgNamespaceNumber"),i=mw.config.get("wgNamespaceIds");return t<0||t===i.template||t===i.module||t===i.mediawiki||t===i.file&&!mw.config.get("wgArticleId")||t===i.creator||t===i.timedtext||t===i.institution||"wikitext"!==mw.config.get("wgPageContentModel")},uncat_regexp:/\{\{\s*[Uu]ncategorized\s*[^}]*\}\}\s*(<!--.*?-->\s*)?/g,existsYes:"https://img.moegirl.org.cn/common/thumb/b/be/P_yes.svg/20px-P_yes.svg.png",existsNo:"https://img.moegirl.org.cn/common/thumb/4/42/P_no.svg/20px-P_no.svg.png",
template_categories:{},engine_names:{searchindex:"Search index",pagelist:"Page list",combined:"Combined search",subcat:"Subcategories",parentcat:"Parent categories"},capitalizePageNames:null,upload_disabled:!1,blacklist:null,bg_changed:"#FCA",no_autocommit:!autopatrol,del_needs_diff:!autopatrol,suggest_delay:100,editbox_width:40,suggestions:"combined",fixed_search:!1,use_up_down:!0,listSize:5,single_minor:!0,dont_add_to_watchlist:!1,shortcuts:null,addShortcuts:t=>{var i;if(t){(i=window.HotCat).shortcuts||(i.shortcuts={});for(let i in t){if(!Object.prototype.hasOwnProperty.bind(t)(i)||"string"!=typeof i)continue;let e=t[i];"string"==typeof e&&(i=i.replace(/^\s+|\s+$/g,""),e=e.replace(/^\s+|\s+$/g,""),i.length&&e.length&&(window.HotCat.shortcuts[i]=e))}}}},ua=navigator.userAgent.toLowerCase(),is_webkit=/applewebkit\/\d+/.test(ua)&&ua.indexOf("spoofer")<0;let cat_prefix=null,noSuggestions=!1;class LoadTrigger{constructor(t){this.queue=[],this.needed=t}register(t){this.needed<=0?t():this.queue.push(t)}loaded(){if(this.needed--,0===this.needed){for(let t=0;t<this.queue.length;t++)this.queue[t]();this.queue=[]}}}const loadTrigger=new LoadTrigger(2);if(loadTrigger.loaded(),"en"!==conf.wgUserLanguage){const t={messages:{cat_removed:"移除[[分类:$1]]",template_removed:"移除{{[[分类:$1]]}}",cat_added:"添加[[分类:$1]]",cat_keychange:"为[[分类:$1]]设定新索引:“$2”",cat_notFound:"分类“$1”未找到",cat_exists:"分类“$1”已存在,不执行添加操作",cat_resolved:"(已处理[[分类:$1]]的重定向)",uncat_removed:"",separator:"; ",prefix:"",using:"——[[Help:HotCat小工具|HotCat]]",multi_change:"$1个分类",commit:"保存",ok:"确定",cancel:"取消",multi_error:"无法连接到萌百服务器,因此您的分类更改无法保存,由此引发的不便我们深表歉意。",short_catchange:null},categories:"分类",redir_category:"分类重定向",tooltips:{change:"修改",remove:"移除",add:"新增一个分类",restore:"回退更改",undo:"回退更改",down:"打开以便修改并显示子分类",up:"打开以便修改并显示父分类"},multi_tooltip:"修改多个分类",engine_names:{searchindex:"搜索索引",pagelist:"页面列表",combined:"合并搜索",subcat:"子分类",parentcat:"父分类"},disambig_category:"消歧义页",blacklist:/(?:不可|已)索引页面|(?:调用重复模板参数|有(?:过多高开销解析器函数调用|忽略显示标题|模板循环|脚本错误|投票|参考文献错误)|含有(?:略过模板参数|受损文件链接)|展开模板后长度超过上限|扩展深度超出限制|使用无效自封闭HTML标签|受到保护无法编辑|即将删除)的页面|有错误的Scribunto模块|隐藏分类|页面的节点数超出限制|需要帮助/i};$.extend(HC,t,!0)}loadTrigger.loaded();const wikiTextBlank="[\\t _\\xA0\\u1680\\u180E\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]+",wikiTextBlankRE=new RegExp(wikiTextBlank,"g"),wikiTextBlankOrBidi="[\\t _\\xA0\\u1680\\u180E\\u2000-\\u200B\\u200E\\u200F\\u2028-\\u202F\\u205F\\u3000]*",formattedNamespaces=conf.wgFormattedNamespaces,namespaceIds=conf.wgNamespaceIds;HC.category_canonical=formattedNamespaces[14],HC.category_regexp=autoLocalize(14,"category"),formattedNamespaces[10]&&(HC.template_regexp=autoLocalize(10,"template"));const substitute=substituteFactory(),replaceShortcuts=function(){const t=substituteFactory({indicator:"#",lbrace:"[",rbrace:"]"});return function(i,e){const n=t(i,e);return HC.capitalizePageNames?capitalize(n):n}}(),findCatsRE=new RegExp(`\\[\\[${wikiTextBlankOrBidi}(?:${HC.category_regexp})${wikiTextBlankOrBidi}:[^\\]]+\\]\\]`,"g");let interlanguageRE=null,catLine=null,onUpload=!1,editors=[],commitButton=null,commitForm=null,multiSpan=null,pageText=null,pageTime=null,pageWatched=!1,watchCreate=!1,watchEdit=!1,minorEdits=!1,editToken=null,is_rtl=!1,serverTime=null,lastRevId=null,pageTextRevId=null,conflictingUser=null,newDOM=!1;class CategoryEditor{constructor(t,i,e,n,s){this.callbackObj=null;let o=i,r=e;if(o)is_rtl&&(o.dir="rtl"),this.isAddCategory=!1,this.catLink=o.firstChild,this.originalCategory=Array.isArray(r)?r[0]:r,this.originalKey=n&&n.length>1?n.substr(1):null,this.originalExists=!hasClass(this.catLink,"new"),this.makeLinkSpan(),!this.originalExists&&this.upDownLinks&&(this.upDownLinks.style.display="none"),o.appendChild(this.linkSpan);else{this.isAddCategory=!0,this.originalCategory="",this.originalKey=null,this.originalExists=!1,newDOM||(o=make("span"),o.className="noprint",n?(o.appendChild(make(" | ",!0)),r?(r.parentNode.insertBefore(o,r.nextSibling),r=r.nextSibling):t.appendChild(o)):t.firstChild&&(o.appendChild(make(" ",!0)),t.appendChild(o))),this.linkSpan=make("span"),this.linkSpan.className="noprint nopopups hotcatlink";const i=make("a");i.href="#catlinks",i.onclick=this.open.bind(this),i.appendChild(make(HC.links.add,!0)),i.title=HC.tooltips.add,this.linkSpan.appendChild(i),o=make(newDOM?"li":"span"),o.className="noprint",is_rtl&&(o.dir="rtl"),o.appendChild(this.linkSpan),r?r.parentNode.insertBefore(o,r.nextSibling):t.appendChild(o),this.normalLinks=null,this.undelLink=null,this.catLink=null}this.originalHidden=s,this.line=t,this.engine=HC.suggestions,this.span=o,this.currentCategory=!this.isAddCategory&&Array.isArray(r)?r[1]:this.originalCategory,this.currentExists=this.originalExists,this.currentHidden=this.originalHidden,this.currentKey=this.originalKey,this.state=CategoryEditor.UNCHANGED,this.lastSavedState=CategoryEditor.UNCHANGED,this.lastSavedCategory=this.currentCategory,this.lastSavedKey=this.originalKey,this.lastSavedExists=this.originalExists,this.lastSavedHidden=this.originalHidden,this.catLink&&this.currentKey&&(this.catLink.title=this.currentKey),editors[editors.length]=this}makeLinkSpan(){this.normalLinks=make("span");let t=null;this.originalCategory&&this.originalCategory.length&&(t=make("a"),t.href="#catlinks",t.onclick=this.remove.bind(this),t.appendChild(make(HC.links.remove,!0)),t.title=HC.tooltips.remove,this.normalLinks.appendChild(make(" ",!0)),this.normalLinks.appendChild(t)),HC.template_categories[this.originalCategory]||(t=make("a"),t.href="#catlinks",t.onclick=this.open.bind(this),t.appendChild(make(HC.links.change,!0)),t.title=HC.tooltips.change,this.normalLinks.appendChild(make(" ",!0)),this.normalLinks.appendChild(t),!noSuggestions&&HC.use_up_down&&(this.upDownLinks=make("span"),t=make("a"),t.href="#catlinks",t.onclick=this.down.bind(this),t.appendChild(make(HC.links.down,!0)),t.title=HC.tooltips.down,this.upDownLinks.appendChild(make(" ",!0)),this.upDownLinks.appendChild(t),t=make("a"),t.href="#catlinks",t.onclick=this.up.bind(this),t.appendChild(make(HC.links.up,!0)),t.title=HC.tooltips.up,this.upDownLinks.appendChild(make(" ",!0)),this.upDownLinks.appendChild(t),this.normalLinks.appendChild(this.upDownLinks))),this.linkSpan=make("span"),this.linkSpan.className="noprint nopopups hotcatlink",this.linkSpan.appendChild(this.normalLinks),this.undelLink=make("span"),this.undelLink.className="nopopups hotcatlink",this.undelLink.style.display="none",t=make("a"),t.href="#catlinks",t.onclick=this.restore.bind(this),t.appendChild(make(HC.links.restore,!0)),t.title=HC.tooltips.restore,this.undelLink.appendChild(make(" ",!0)),this.undelLink.appendChild(t),this.linkSpan.appendChild(this.undelLink)}invokeSuggestions(t){this.engine&&suggestionConfigs[this.engine]&&suggestionConfigs[this.engine].temp&&!t&&(this.engine=HC.suggestions),this.state=CategoryEditor.CHANGE_PENDING;const i=this;window.setTimeout(()=>{i.textchange(t)},HC.suggest_delay)}makeForm(){function button_label(t,i){let e=null;if(onUpload&&void 0!==window.UFUI&&void 0!==window.UIElements&&window.UFUI.getLabel instanceof Function)try{for(e=window.UFUI.getLabel(t,!0);e&&3!==e.nodeType;)e=e.firstChild}catch(t){e=null}return e&&e.data?e.data:i}const t=make("form");t.method="POST",t.onsubmit=this.accept.bind(this),this.form=t;const i=this,e=make("input");if(e.type="text",e.size=HC.editbox_width,!noSuggestions){e.onkeyup=function(t){const e=t.keyCode||0;if(!i.ime||i.lastKey!==IME||i.usesComposition||e!==TAB&&e!==RET&&e!==ESC&&e!==SPACE||(i.ime=!1),i.ime)return!0;if(e===UP||e===DOWN||e===PGUP||e===PGDOWN){if(0===i.keyCount)return i.processKey(t)}else{if(e===ESC&&i.lastKey!==IME&&!i.resetKeySelection())return void i.cancel();i.invokeSuggestions(e===BS||e===DEL||e===ESC)}return!0},e.onkeydown=function(t){const e=t.keyCode||0;return i.lastKey=e,i.keyCount=0,i.ime||e!==IME||i.usesComposition?i.ime&&e!==IME&&!(e>=16&&e<=20||e>=91&&e<=93||144===e)&&(i.ime=!1):i.ime=!0,!!i.ime||(e===RET?i.accept(t):e!==ESC||evtKill(t))},e.onkeypress=function(t){return i.keyCount++,i.processKey(t)},$(e).on("focus",()=>{makeActive(i)}),$(e).on(void 0!==e.onbeforedeactivate&&e.createTextRange?"beforedeactivate":"blur",this.saveView.bind(this));try{$(e).on("compositionstart",()=>{i.lastKey=IME,i.usesComposition=!0,i.ime=!0}),$(e).on("compositionend",()=>{i.lastKey=IME,i.usesComposition=!0,i.ime=!1}),$(e).on("textInput",()=>{i.ime=!1,i.invokeSuggestions(!1)})}catch{}$(e).on("blur",()=>{i.usesComposition=!1,i.ime=!1})}this.text=e,this.icon=make("img");let n=null;if(!noSuggestions&&(n=make("select"),n.onclick=function(){i.highlightSuggestion(0)&&i.textchange(!1,!0)},n.ondblclick=function(t){i.highlightSuggestion(0)&&i.accept(t)},n.onchange=function(){i.highlightSuggestion(0),i.text.focus()},n.onkeyup=function(t){t.keyCode===ESC?(i.resetKeySelection(),i.text.focus(),window.setTimeout(()=>{i.textchange(!0)},HC.suggest_delay)):t.keyCode===RET&&i.accept(t)},!HC.fixed_search)){const t=make("select");for(const i in suggestionConfigs)if(suggestionConfigs[i].show){const e=make("option");e.value=i,i===this.engine&&(e.selected=!0),e.appendChild(make(suggestionConfigs[i].name,!0)),t.appendChild(e)}t.onchange=function(){i.engine=i.engineSelector.options[i.engineSelector.selectedIndex].value,i.text.focus(),i.textchange(!0,!0)},this.engineSelector=t}this.list=n;const s=make("input");s.type="button",s.value=button_label("wpOkUploadLbl",HC.messages.ok),s.onclick=this.accept.bind(this),this.ok=s;const o=make("input");o.type="button",o.value=button_label("wpCancelUploadLbl",HC.messages.cancel),o.onclick=this.cancel.bind(this),this.cancelButton=o;const r=make("span");r.className="hotcatinput",r.style.position="relative",r.appendChild(e),r.appendChild(make(" ",!0)),r.style.whiteSpace="nowrap",n&&r.appendChild(n),this.engineSelector&&r.appendChild(this.engineSelector),noSuggestions||r.appendChild(this.icon),r.appendChild(s),r.appendChild(o),t.appendChild(r),t.style.display="none",this.span.appendChild(t)}display(t){if(this.isAddCategory&&!onUpload&&new CategoryEditor(this.line,null,this.span,!0),!commitButton&&!onUpload)for(let t=0;t<editors.length;t++)if(editors[t].state!==CategoryEditor.UNCHANGED){setMultiInput();break}this.form||this.makeForm(),
this.list&&(this.list.style.display="none"),this.engineSelector&&(this.engineSelector.style.display="none"),this.currentCategory=this.lastSavedCategory,this.currentExists=this.lastSavedExists,this.currentHidden=this.lastSavedHidden,this.currentKey=this.lastSavedKey,this.icon.src=this.currentExists?HC.existsYes:HC.existsNo,this.text.value=this.currentCategory+(null!==this.currentKey?`|${this.currentKey}`:""),this.originalState=this.state,this.lastInput=this.currentCategory,this.inputExists=this.currentExists,this.state=this.state===CategoryEditor.UNCHANGED?CategoryEditor.OPEN:CategoryEditor.CHANGE_PENDING,this.lastSelection={start:this.currentCategory.length,end:this.currentCategory.length},this.showsList=!1,this.catLink&&(this.catLink.style.display="none"),this.linkSpan.style.display="none",this.form.style.display="inline",this.ok.disabled=!1;const i=evtKill(t);return this.text.focus(),this.text.readOnly=!1,checkMultiInput(),i}show(t,i,e){const n=this.display(t);return this.lastSavedCategory.length?(this.text.readOnly=!!e,this.engine=i,this.textchange(!1,!0),forceRedraw(),n):n}open(t){return this.show(t,this.engine&&suggestionConfigs[this.engine].temp?HC.suggestions:this.engine)}down(t){return this.show(t,"subcat",!0)}up(t){return this.show(t,"parentcat")}cancel(){if(!this.isAddCategory||onUpload){if(this.inactivate(),this.form.style.display="none",this.catLink&&(this.catLink.style.display=""),this.linkSpan.style.display="",this.state=this.originalState,this.currentCategory=this.lastSavedCategory,this.currentKey=this.lastSavedKey,this.currentExists=this.lastSavedExists,this.currentHidden=this.lastSavedHidden,this.catLink&&(this.currentKey&&this.currentKey.length?this.catLink.title=this.currentKey:this.catLink.title=""),this.state===CategoryEditor.UNCHANGED)this.catLink&&(this.catLink.style.backgroundColor="transparent");else if(!onUpload)try{this.catLink.style.backgroundColor=HC.bg_changed}catch{}checkMultiInput(),forceRedraw()}else this.removeEditor()}removeEditor(){if(!newDOM){const t=this.span.nextSibling;t&&t.parentNode.removeChild(t)}this.span&&this.span.parentNode&&this.span.parentNode.removeChild(this.span);for(let t=0;t<editors.length;t++)if(editors[t]===this){editors.splice(t,1);break}checkMultiInput()}rollback(t){return this.undoLink.parentNode.removeChild(this.undoLink),this.undoLink=null,this.currentCategory=this.originalCategory,this.currentKey=this.originalKey,this.currentExists=this.originalExists,this.currentHidden=this.originalHidden,this.lastSavedCategory=this.originalCategory,this.lastSavedKey=this.originalKey,this.lastSavedExists=this.originalExists,this.lastSavedHidden=this.originalHidden,this.state=CategoryEditor.UNCHANGED,this.currentCategory&&this.currentCategory.length?(this.catLink.removeChild(this.catLink.firstChild),this.catLink.appendChild(make(this.currentCategory,!0)),this.catLink.href=wikiPagePath(`${HC.category_canonical}:${this.currentCategory}`),this.catLink.title=this.currentKey||"",this.catLink.className=this.currentExists?"":"new",this.catLink.style.backgroundColor="transparent",this.upDownLinks&&(this.upDownLinks.style.display=this.currentExists?"":"none"),checkMultiInput()):this.removeEditor(),evtKill(t)}inactivate(){this.list&&(this.list.style.display="none"),this.engineSelector&&(this.engineSelector.style.display="none"),this.is_active=!1}acceptCheck(t){this.sanitizeInput();const i=this.text.value.split("|");let e=null;i.length>1&&(e=i[1]);let n=i[0].replace(/_/g," ").replace(/^\s+|\s+$/g,"");return HC.capitalizePageNames&&(n=capitalize(n)),this.lastInput=n,n=replaceShortcuts(n,HC.shortcuts),n.length?!t&&(14===conf.wgNamespaceNumber&&n===conf.wgTitle||HC.blacklist&&HC.blacklist.test(n))?(this.cancel(),!1):(this.currentCategory=n,this.currentKey=e,this.currentExists=this.inputExists,!0):(this.cancel(),!1)}accept(t){this.noCommit=!!(1&evtKeys(t));const i=evtKill(t);if(this.acceptCheck()){const t=[this],i=this.currentCategory;resolveMulti(t,t=>{t[0].dab?showDab(t[0]):t[0].acceptCheck(!0)&&t[0].commit(t[0].currentCategory!==i?HC.messages.cat_resolved.replace(/\$1/g,i):null)})}return i}close(){if(this.catLink||(this.catLink=make("a"),this.catLink.appendChild(make("foo",!0)),this.catLink.style.display="none",this.span.insertBefore(this.catLink,this.span.firstChild.nextSibling)),this.catLink.removeChild(this.catLink.firstChild),this.catLink.appendChild(make(this.currentCategory,!0)),this.catLink.href=wikiPagePath(`${HC.category_canonical}:${this.currentCategory}`),this.catLink.className=this.currentExists?"":"new",this.lastSavedCategory=this.currentCategory,this.lastSavedKey=this.currentKey,this.lastSavedExists=this.currentExists,this.lastSavedHidden=this.currentHidden,this.inactivate(),this.form.style.display="none",this.catLink.title=this.currentKey||"",this.catLink.style.display="",this.isAddCategory&&(onUpload&&new CategoryEditor(this.line,null,this.span,!0),this.isAddCategory=!1,this.linkSpan.parentNode.removeChild(this.linkSpan),this.makeLinkSpan(),this.span.appendChild(this.linkSpan)),!this.undoLink){const t=make("span"),i=make("a");if(i.href="#catlinks",i.onclick=this.rollback.bind(this),i.appendChild(make(HC.links.undo,!0)),i.title=HC.tooltips.undo,t.appendChild(make(" ",!0)),t.appendChild(i),this.normalLinks.appendChild(t),this.undoLink=t,!onUpload)try{this.catLink.style.backgroundColor=HC.bg_changed}catch{}}this.upDownLinks&&(this.upDownLinks.style.display=this.lastSavedExists?"":"none"),this.linkSpan.style.display="",this.state=CategoryEditor.CHANGED,checkMultiInput(),forceRedraw()}commit(){if(this.currentCategory===this.originalCategory&&(this.currentKey===this.originalKey||null===this.currentKey&&!this.originalKey.length)||14===conf.wgNamespaceNumber&&this.currentCategory===conf.wgTitle||HC.blacklist&&HC.blacklist.test(this.currentCategory))this.cancel();else if(this.close(),!commitButton&&!onUpload){const t=this;initiateEdit(i=>{performChanges(i,t)},t=>{oouiDialog.alert(oouiDialog.sanitize(t),{title:"HotCat 小工具"})})}}remove(t){return this.doRemove(1&evtKeys(t)),evtKill(t)}doRemove(t){if(this.isAddCategory)this.cancel();else{if(!commitButton&&!onUpload)for(let t=0;t<editors.length;t++)if(editors[t].state!==CategoryEditor.UNCHANGED){setMultiInput();break}if(commitButton){this.catLink.title="",this.catLink.style.cssText+="; text-decoration : line-through !important;";try{this.catLink.style.backgroundColor=HC.bg_changed}catch{}this.originalState=this.state,this.state=CategoryEditor.DELETED,this.normalLinks.style.display="none",this.undelLink.style.display="",checkMultiInput()}else if(onUpload)this.removeEditor();else{this.originalState=this.state,this.state=CategoryEditor.DELETED,this.noCommit=t||HC.del_needs_diff;const i=this;initiateEdit(t=>{performChanges(t,i)},t=>{i.state=i.originalState,oouiDialog.alert(oouiDialog.sanitize(t),{title:"HotCat 小工具"})})}}}restore(t){if(this.catLink.title=this.currentKey||"",this.catLink.style.textDecoration="",this.state=this.originalState,this.state===CategoryEditor.UNCHANGED)this.catLink.style.backgroundColor="transparent";else try{this.catLink.style.backgroundColor=HC.bg_changed}catch{}return this.normalLinks.style.display="",this.undelLink.style.display="none",checkMultiInput(),evtKill(t)}selectEngine(t){if(this.engineSelector)for(let i=0;i<this.engineSelector.options.length;i++)this.engineSelector.options[i].selected=this.engineSelector.options[i].value===t}sanitizeInput(){let t=this.text.value||"";if(t=t.replace(/^(\s|_)+/,""),new RegExp(`^(${HC.category_regexp}):`).test(t)&&(t=t.substring(t.indexOf(":")+1).replace(/^(\s|_)+/,"")),t=t.replace(/\u200E$/,""),HC.capitalizePageNames&&(t=capitalize(t)),null!==this.text.value&&this.text.value!==t){const i=this.text.selectionStart;this.text.value=t,this.text.setSelectionRange(i,i)}}makeCall(t,i,e,n,s){let o=i;const r=e,a=n,l=s;$.ajax({url:t,method:"GET",dataType:"json",success:t=>{const i=r.handler(t,l);i&&i.length&&(null===o.allTitles?o.allTitles=i:o.allTitles=o.allTitles.concat(i),i.exists&&(o.exists=!0),i.normalized&&(o.normalized=i.normalized))},error:t=>{t||(noSuggestions=!0),o.dontCache=!0},complete:()=>{o.callsMade++,o.callsMade===o.nofCalls&&(o.exists&&(o.allTitles.exists=!0),o.normalized&&(o.allTitles.normalized=o.normalized),o.dontCache||suggestionConfigs[o.engineName].cache[l]||(suggestionConfigs[o.engineName].cache[l]=o.allTitles),this.text.readOnly=!1,o.cancelled||this.showSuggestions(o.allTitles,o.noCompletion,a,o.engineName),o===this.callbackObj&&(this.callbackObj=null),o=void 0)}})}textchange(t,i){makeActive(this),this.sanitizeInput();let e=this.text.value;const n=e.indexOf("|");if(n>=0?(this.currentKey=e.substring(n+1),e=e.substring(0,n)):this.currentKey=null,this.lastInput===e&&!i)return;if(this.lastInput!==e&&checkMultiInput(),this.lastInput=e,this.lastRealInput=e,this.ok.disabled=e.length&&HC.blacklist&&HC.blacklist.test(e),noSuggestions)return this.list&&(this.list.style.display="none"),this.engineSelector&&(this.engineSelector.style.display="none"),void(this.icon&&(this.icon.style.display="none"));if(!e.length)return void this.showSuggestions([]);let s=e.replace(/[\u200E\u200F\u202A-\u202E]/g,"").replace(wikiTextBlankRE," ");if(s=replaceShortcuts(s,HC.shortcuts),s=s.replace(/^\s+|\s+$/g,""),!s.length)return void this.showSuggestions([]);this.callbackObj&&(this.callbackObj.cancelled=!0);const o=suggestionConfigs[this.engine]?this.engine:"combined",r=t||suggestionConfigs[o].noCompletion;if(suggestionConfigs[o].cache[s])return void this.showSuggestions(suggestionConfigs[o].cache[s],r,e,o);const a=suggestionConfigs[o].engines;this.callbackObj={allTitles:null,callsMade:0,nofCalls:a.length,noCompletion:r,engineName:o},this.makeCalls(a,this.callbackObj,e,s)}makeCalls(t,i,e,n){for(let s=0;s<t.length;s++){const o=suggestionEngines[t[s]],r=`${conf.wgServer}${conf.wgScriptPath}${o.uri.replace(/\$1/g,encodeURIComponent(n))}`;this.makeCall(r,i,o,e,n)}}showSuggestions(t,i,e,n){if(this.text.readOnly=!1,this.dab=null,this.showsList=!1,!this.list)return;if(noSuggestions)return this.list&&(this.list.style.display="none"),this.engineSelector&&(this.engineSelector.style.display="none"),this.icon&&(this.icon.style.display="none"),void(this.inputExists=!0);if(this.engineName=n,
n?this.engineSelector||(this.engineName=null):this.engineSelector&&(this.engineSelector.style.display="none"),e){if(this.lastInput.indexOf(e))return;if(this.lastQuery&&0===this.lastInput.indexOf(this.lastQuery)&&this.lastQuery.length>e.length)return}this.lastQuery=e;let s=this.text.value.split("|");const o=s.length>1?`|${s[1]}`:"";s=HC.capitalizePageNames?capitalize(s[0]):s[0];let r=s;const a=t&&t.exists;let l;if(t){t.normalized&&0===s.indexOf(e)&&(r=t.normalized+s.substring(e.length));const i=r.toLowerCase();if(HC.blacklist)for(l=0;l<t.length;l++)HC.blacklist.test(t[l])&&(t.splice(l,1),l--);for(t.sort((t,e)=>{if(t===e)return 0;if(0===t.indexOf(e))return 1;if(0===e.indexOf(t))return-1;let n=0===t.indexOf(r)?1:0,s=0===e.indexOf(r)?1:0;if(n!==s)return s-n;const o=t.toLowerCase(),a=e.toLowerCase();return n=0===o.indexOf(i)?1:0,s=0===a.indexOf(i)?1:0,n!==s?s-n:t<e?-1:e<t?1:0}),l=0;l<t.length;l++)(l+1<t.length&&t[l]===t[l+1]||14===conf.wgNamespaceNumber&&t[l]===conf.wgTitle)&&(t.splice(l,1),l--)}if(!t||!t.length)return this.list&&(this.list.style.display="none"),this.engineSelector&&(this.engineSelector.style.display="none"),void(n&&suggestionConfigs[n]&&!suggestionConfigs[n].temp&&(this.icon&&(this.icon.src=HC.existsNo),this.inputExists=!1));const c=t[0],u=this.autoComplete(c,s,r,o,i),h=u||a||c===replaceShortcuts(s,HC.shortcuts);if(n&&suggestionConfigs[n]&&!suggestionConfigs[n].temp&&(this.icon.src=h?HC.existsYes:HC.existsNo,this.inputExists=h),u&&(this.lastInput=c,1===t.length))return this.list.style.display="none",void(this.engineSelector&&(this.engineSelector.style.display="none"));for(;this.list.firstChild;)this.list.removeChild(this.list.firstChild);for(l=0;l<t.length;l++){const i=make("option");i.appendChild(make(t[l],!0)),i.selected=u&&0===l,this.list.appendChild(i)}this.displayList()}displayList(){function viewport(t){if(is_webkit&&!document.evaluate)return window[`inner${t}`];const i=`client${t}`;return window.opera?document.body[i]:(document.documentElement?document.documentElement[i]:0)||document.body[i]||0}function scroll_offset(t){const i=`scroll${t}`;let e=(document.documentElement?document.documentElement[i]:0)||document.body[i]||0;return is_rtl&&"Left"===t&&(e<0&&(e=-e),is_webkit||(e=scroll_offset("Width")-viewport("Width")-e)),e}function position(t){let i=t;if(i.getBoundingClientRect){const t=i.getBoundingClientRect();return{x:Math.round(t.left+scroll_offset("Left")),y:Math.round(t.top+scroll_offset("Top"))}}let e=0,n=0;do{e+=i.offsetTop||0,n+=i.offsetLeft||0,i=i.offsetParent}while(i);return{x:n,y:e}}if(this.showsList=!0,!this.is_active)return this.list.style.display="none",void(this.engineSelector&&(this.engineSelector.style.display="none"));let t=this.list.options.length>HC.listSize?HC.listSize:this.list.options.length;t<=1&&(t=2),this.list.size=t,this.list.style.align=is_rtl?"right":"left",this.list.style.zIndex=5,this.list.style.position="absolute";const i=is_rtl?"right":"left";let e=0;"none"===this.list.style.display?(this.list.style.top=`${this.text.offsetTop}px`,this.list.style[i]="-10000px",this.list.style.display="",e=this.list.offsetHeight,this.list.style.display="none"):e=this.list.offsetHeight;let n=e;t<HC.listSize&&(n=e/t*HC.listSize);const s=position(this.text),o=this.text.offsetWidth||this.text.clientWidth;let r=0,a=0;if(this.engineName&&(this.engineSelector.style.zIndex=5,this.engineSelector.style.position="absolute",this.engineSelector.style.width=`${o}px`,"none"===this.engineSelector.style.display?(this.engineSelector.style[i]="-10000px",this.engineSelector.style.top="0",this.engineSelector.style.display="",a=this.engineSelector.offsetHeight,this.engineSelector.style.display="none"):a=this.engineSelector.offsetHeight,this.engineSelector.style[i]="0px"),s.y<n+a+1?(r=this.text.offsetHeight+a+1,this.engineName&&(this.engineSelector.style.top=`${this.text.offsetHeight}px`)):(r=-e-a-1,this.engineName&&(this.engineSelector.style.top=-(a+1)+"px")),this.list.style.top=`${r}px`,this.list.style.width="",this.list.style[i]="0px",this.engineName&&(this.selectEngine(this.engineName),this.engineSelector.style.display=""),this.list.style.display="block",this.list.offsetWidth<o)return void(this.list.style.width=`${o}px`);const l=scroll_offset("Left"),c=viewport("Width");let u=this.list.offsetWidth,h=position(this.list).x,d=h+u;if(h<l||d>l+c){u>c&&(u=c,this.list.style.width=`${u}px`,is_rtl?h=d-u:d=h+u);let t=0;h<l?t=l-h:d>l+c&&(t=-(d-l-c)),is_rtl&&(t=-t),t&&(this.list.style[i]=`${0+t}px`)}}autoComplete(t,i,e,n,s){let o=i;if(t===o)return!0;if(s||this.ime||!this.canSelect())return!1;if(t.indexOf(o)){if(!e||0!==t.indexOf(e))return!1;this.lastRealInput===o&&(this.lastRealInput=e),o=e}return this.text.focus(),this.text.value=t+n,this.setSelection(o.length,t.length),!0}canSelect(){return this.text.setSelectionRange||this.text.createTextRange||void 0!==this.text.selectionStart&&void 0!==this.text.selectionEnd}setSelection(t,i){if(this.text.value)if(this.text.setSelectionRange)this.text.setSelectionRange(t,i);else if(void 0!==this.text.selectionStart)t>this.text.selectionStart?(this.text.selectionEnd=i,this.text.selectionStart=t):(this.text.selectionStart=t,this.text.selectionEnd=i);else if(this.text.createTextRange){const e=this.text.createTextRange();e.move("character",t),e.moveEnd("character",i-t),e.select()}}getSelection(){let t=0,i=0;if(!this.text.value)return{start:t,end:i};if(void 0!==this.text.selectionStart)t=this.text.selectionStart,i=this.text.selectionEnd;else if(document.selection&&document.selection.createRange){const e=document.selection.createRange().duplicate();if(e.parentElement()===this.text)try{const n=this.text.createTextRange();n.move("character",0),n.setEndPoint("EndToEnd",e),i=n.text.length,n.setEndPoint("EndToStart",e),t=n.text.length}catch(e){t=this.text.value.length,i=t}}return{start:t,end:i}}saveView(){this.lastSelection=this.getSelection()}processKey(t){let i=0;switch(this.lastKey){case UP:i=-1;break;case DOWN:i=1;break;case PGUP:i=-HC.listSize;break;case PGDOWN:i=HC.listSize;break;case ESC:return evtKill(t)}if(i){if("none"!==this.list.style.display)return this.highlightSuggestion(i),evtKill(t);this.keyCount<=1&&(!this.callbackObj||this.callbackObj.callsMade===this.callbackObj.nofCalls)&&this.textchange()}return!0}highlightSuggestion(t){if(noSuggestions||!this.list||"none"===this.list.style.display)return!1;const i=this.list.selectedIndex;let e=-1;if(0===t){if(i<0||i>=this.list.options.length)return!1;e=i}else e=i<0?0:i+t,e=e<0?0:e,e>=this.list.options.length&&(e=this.list.options.length-1);if(e!==i||0===t){i>=0&&i<this.list.options.length&&0!==t&&(this.list.options[i].selected=!1),this.list.options[e].selected=!0;const n=this.text.value.split("|"),s=n.length>1?`|${n[1]}`:"";this.autoComplete(this.list.options[e].text,this.lastRealInput,null,s,!1)&&this.list.options[e].text!==this.lastRealInput||(this.text.value=this.list.options[e].text+s,this.canSelect()&&this.setSelection(this.list.options[e].text.length,this.list.options[e].text.length)),this.lastInput=this.list.options[e].text,this.inputExists=!0,this.icon&&(this.icon.src=HC.existsYes),this.state=CategoryEditor.CHANGE_PENDING}return!0}resetKeySelection(){if(noSuggestions||!this.list||"none"===this.list.style.display)return!1;const t=this.list.selectedIndex;if(t>=0&&t<this.list.options.length){this.list.options[t].selected=!1;const i=this.text.value.split("|"),e=i.length>1?`|${i[1]}`:"";let n=i[0]!==this.lastInput;return i[0]!==this.lastRealInput&&(this.text.value=this.lastRealInput+e,n=!0),this.lastInput=this.lastRealInput,n}return!1}}CategoryEditor.UNCHANGED=0,CategoryEditor.OPEN=1,CategoryEditor.CHANGE_PENDING=2,CategoryEditor.CHANGED=3,CategoryEditor.DELETED=4;let saveInProgress=!1;const suggestionEngines={opensearch:{uri:"/api.php?format=json&action=opensearch&namespace=14&limit=30&search=Category:$1",handler:function(t,i){if(t&&t.length>=2){const e=t[0].substring(t[0].indexOf(":")+1),n=t[1];let s=!1;cat_prefix||(cat_prefix=new RegExp(`^(${HC.category_regexp}):`));for(let t=0;t<n.length;t++){cat_prefix.lastIndex=0;const i=cat_prefix.exec(n[t]);i&&i.length>1?(n[t]=n[t].substring(n[t].indexOf(":")+1),e===n[t]&&(s=!0)):(n.splice(t,1),t--)}return n.exists=s,i!==e&&(n.normalized=e),n}return null}},internalsearch:{uri:"/api.php?format=json&action=query&list=allpages&apnamespace=14&aplimit=30&apfrom=$1&apprefix=$1",handler:function(t){if(t&&t.query&&t.query.allpages){const i=t.query.allpages;for(let t=0;t<i.length;t++)i[t]=i[t].title.substring(i[t].title.indexOf(":")+1);return i}return null}},exists:{uri:"/api.php?format=json&action=query&prop=info&titles=Category:$1",handler:function(t,i){if(t&&t.query&&t.query.pages&&!t.query.pages[-1])for(const e in t.query.pages){let n=t.query.pages[e].title;n=n.substring(n.indexOf(":")+1);const s=[n];return s.exists=!0,i!==n&&(s.normalized=n),s}return null}},subcategories:{uri:"/api.php?format=json&action=query&list=categorymembers&cmtype=subcat&cmlimit=max&cmtitle=Category:$1",handler:function(t){if(t&&t.query&&t.query.categorymembers){const i=t.query.categorymembers;for(let t=0;t<i.length;t++)i[t]=i[t].title.substring(i[t].title.indexOf(":")+1);return i}return null}},parentcategories:{uri:"/api.php?format=json&action=query&prop=categories&titles=Category:$1&cllimit=max",handler:function(t){if(t&&t.query&&t.query.pages)for(const i in t.query.pages)if(t.query.pages[i].categories){const e=t.query.pages[i].categories;for(let t=0;t<e.length;t++)e[t]=e[t].title.substring(e[t].title.indexOf(":")+1);return e}return null}}},suggestionConfigs={searchindex:{name:"Search index",engines:["opensearch"],cache:{},show:!0,temp:!1,noCompletion:!1},pagelist:{name:"Page list",engines:["internalsearch","exists"],cache:{},show:!0,temp:!1,noCompletion:!1},combined:{name:"Combined search",engines:["opensearch","internalsearch"],cache:{},show:!0,temp:!1,noCompletion:!1},subcat:{name:"Subcategories",engines:["subcategories"],cache:{},show:!0,temp:!0,noCompletion:!0},parentcat:{name:"Parent categories",engines:["parentcategories"],cache:{},show:!0,temp:!0,noCompletion:!0}},dummyElement=make(" ",!0),BS=8,TAB=9,RET=13,ESC=27,SPACE=32,PGUP=33,PGDOWN=34,UP=38,DOWN=40,DEL=46,IME=229;let cleanedText=null,initialized=!1,setupTimeout=null
;window.hotcat_get_state=function(){return getState()},window.hotcat_set_state=function(t){return setState(t)},window.hotcat_close_form=function(){closeForm()},HC.runWhenReady=function(t){mw.hook("hotcat.ready").add(t)},mw.config.set("disableAJAXCategories",!0),"Upload"!==conf.wgCanonicalSpecialPageName&&mw.hook("postEdit").add(()=>{catLine=null,editors=[],initialized=!1,HC.started=!1,run()}),run()})();
/* </pre> */