mediawiki-extensions-Popups/resources/dist/index.js
James D. Forrester 863c442c32 .nvmrc: Update now we're using Node 18, and make CI pass
* Babel upgraded to a version that works with new Node's OpenSSL.
* Various loaders upgraded to match
* Babel config changed as plugin-proposal-private-property-in-object is now official
* Webpack config updated as noEmitOnErrors was renamed to not be a negation
* Webpack config updated as namedModules was renamed to the wider moduleIds
* Ignore the built Webpack output from eslint

Bug: T354943
Change-Id: I449f601b8218925d96bfb423fc0f349214d08385
2024-01-12 13:50:19 -05:00

2 lines
45 KiB
JavaScript

(()=>{var e={"./src/canSaveToUserPreferences.js":e=>{e.exports=function(e){return!e.isAnon()&&e.isNamed()}},"./node_modules/redux-thunk/dist/redux-thunk.min.js":function(e){e.exports=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t){"use strict";function n(e){return function(t){var n=t.dispatch,r=t.getState;return function(t){return function(o){return"function"==typeof o?o(n,r,e):t(o)}}}}t.__esModule=!0;var r=n();r.withExtraArgument=n,t.default=r}])},"./node_modules/redux/dist/redux.min.js":function(e,t,n){e=n.nmd(e),function(t){"use strict";var r=function(e){var t,n=e.Symbol;return"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==n.g?n.g:e),o=function(){return Math.random().toString(36).substring(7).split("").join(".")},i={INIT:"@@redux/INIT"+o(),REPLACE:"@@redux/REPLACE"+o(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+o()}};function a(e,t){var n=t&&t.type;return"Given "+(n&&'action "'+n+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.'}function s(e,t){return function(){return t(e.apply(this,arguments))}}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce((function(e,t){return function(){return e(t.apply(void 0,arguments))}}))}t.createStore=function e(t,n,o){var a;if("function"==typeof n&&"function"==typeof o||"function"==typeof o&&"function"==typeof arguments[3])throw Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function");if("function"==typeof n&&void 0===o&&(o=n,n=void 0),void 0!==o){if("function"!=typeof o)throw Error("Expected the enhancer to be a function.");return o(e)(t,n)}if("function"!=typeof t)throw Error("Expected the reducer to be a function.");var s=t,c=n,u=[],p=u,l=!1;function d(){p===u&&(p=u.slice())}function f(){if(l)throw Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return c}function m(e){if("function"!=typeof e)throw Error("Expected the listener to be a function.");if(l)throw Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return d(),p.push(e),function(){if(t){if(l)throw Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,d();var n=p.indexOf(e);p.splice(n,1)}}}function w(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw Error("Reducers may not dispatch actions.");try{l=!0,c=s(c,e)}finally{l=!1}for(var t=u=p,n=0;t.length>n;n++)(0,t[n])();return e}return w({type:i.INIT}),(a={dispatch:w,subscribe:m,getState:f,replaceReducer:function(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");s=e,w({type:i.REPLACE})}})[r]=function(){var e,t=m;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new TypeError("Expected the observer to be an object.");function n(){e.next&&e.next(f())}return n(),{unsubscribe:t(n)}}})[r]=function(){return this},e},a},t.combineReducers=function(e){for(var t=Object.keys(e),n={},r=0;t.length>r;r++){var o=t[r];"function"==typeof e[o]&&(n[o]=e[o])}var s,c=Object.keys(n);try{!function(e){Object.keys(e).forEach((function(t){var n=e[t];if(void 0===n(void 0,{type:i.INIT}))throw Error('Reducer "'+t+"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.");if(void 0===n(void 0,{type:i.PROBE_UNKNOWN_ACTION()}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+i.INIT+' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.')}))}(n)}catch(e){s=e}return function(e,t){if(void 0===e&&(e={}),s)throw s;for(var r=!1,o={},i=0;c.length>i;i++){var u=c[i],p=e[u],l=(0,n[u])(p,t);if(void 0===l){var d=a(u,t);throw Error(d)}o[u]=l,r=r||l!==p}return r?o:e}},t.bindActionCreators=function(e,t){if("function"==typeof e)return s(e,t);if("object"!=typeof e||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var n=Object.keys(e),r={},o=0;n.length>o;o++){var i=n[o],a=e[i];"function"==typeof a&&(r[i]=s(a,t))}return r},t.applyMiddleware=function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(e){return function(){var n=e.apply(void 0,arguments),r=function(){throw Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},i=t.map((function(e){return e(o)}));return function(e){for(var t=1;arguments.length>t;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){c(e,t,n[t])}))}return e}({},n,{dispatch:r=u.apply(void 0,i)(n.dispatch)})}}},t.compose=u,t.__DO_NOT_USE__ActionTypes=i,Object.defineProperty(t,"__esModule",{value:!0})}(t)},"./src/ui/pointer-mask.svg":e=>{e.exports='<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0"><defs><clipPath id="mwe-popups-mask"><path d="M0 8h10l8-8 8 8h974v992H0z"></path></clipPath><clipPath id="mwe-popups-mask-flip"><path d="M0 8h294l8-8 8 8h690v992H0z"></path></clipPath><clipPath id="mwe-popups-landscape-mask"><path d="M0 8h174l8-8 8 8h810v992H0z"></path></clipPath><clipPath id="mwe-popups-landscape-mask-flip"><path d="M0 0h1000v242H190l-8 8-8-8H0z"></path></clipPath></defs></svg>'}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e={};n.r(e),n.d(e,{abandon:()=>Ce,boot:()=>ke,fetch:()=>Ne,hideSettings:()=>qe,linkClick:()=>Re,linkDwell:()=>Oe,pageviewLogged:()=>Ge,previewDwell:()=>De,previewShow:()=>He,registerSetting:()=>Le,saveSettings:()=>Fe,showSettings:()=>je,statsvLogged:()=>We});var t=n("./node_modules/redux/dist/redux.min.js"),r=n("./node_modules/redux-thunk/dist/redux-thunk.min.js"),o=n.n(r),i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.devicePixelRatio;return e?e>1.5?2:e>1?1.5:1:1}(),a=150,s=350+a,c=1e3,u=300;const p={BRACKETED_DEVICE_PIXEL_RATIO:i,THUMBNAIL_SIZE:320*Math.max(i,1.5),EXTRACT_LENGTH:525};function l(e){return new Promise((function(t){setTimeout((function(){t()}),e)}))}var d=n("./src/ui/pointer-mask.svg"),f=n.n(d),m={portraitImage:{h:250,w:203},landscapeImage:{h:200,w:320}};var w=function(e,t){Object.keys(t).forEach((function(n){e.setAttribute(n,t[n])}))};function h(e){return mw.html.escape(e)}var g={};function v(e){if(!g[e]){var t=document.createElement("div");t.innerHTML=e,g[e]=t.firstElementChild}return g[e].cloneNode(!0)}var y='\n\t<div class="mwe-popups" aria-hidden></div>\n';function E(e,t){var n=v(y);return n.className="mwe-popups mwe-popups-type-".concat(e),t.className="mwe-popups-container",n.appendChild(t),n}var b='\n\t<div class="mwe-popups-container">\n\t\t<a class="mwe-popups-extract">\n \t\t<div class="mwe-popups-scroll">\n\t\t\t\t<strong class="mwe-popups-title">\n\t\t\t\t\t<span class="popups-icon"></span>\n\t\t\t\t</strong>\n\t\t\t\t<div class="mwe-popups-message"></div>\n\t\t\t</div>\n\t\t</a>\n\t\t<footer>\n\t\t\t<a class="mwe-popups-read-link"></a>\n\t\t</footer>\n\t</div>\n';function T(e,t,n){var r=E(e.type,v(b));r.querySelector(".popups-icon").classList.add("popups-icon--preview-".concat(e.type)),r.querySelector(".mwe-popups-extract").setAttribute("href",e.url);var o=r.querySelector(".mwe-popups-message");t?o.innerHTML=h(t):o.remove();var i=r.querySelector(".mwe-popups-read-link");return i.innerHTML=h(n),i.setAttribute("href",e.url),r.querySelector(".mwe-popups-title").innerHTML+=h(e.title),r}var S=!1,x="event.ReferencePreviewsPopups";function P(){return S}var _='\n<div class="mwe-popups-container">\n <div class="mwe-popups-extract">\n <div class="mwe-popups-scroll">\n <strong class="mwe-popups-title">\n <span class="popups-icon"></span>\n <span class="mwe-popups-title-placeholder"></span>\n </strong>\n <bdi><div class="mw-parser-output"></div></bdi>\n </div>\n <div class="mwe-popups-fade"></div>\n </div>\n\t<footer>\n\t\t<div class="mwe-popups-settings"></div>\n\t</footer>\n</div>',A=function(e,t){"string"==typeof t?e.insertAdjacentHTML("afterend",t):e.parentNode.appendChild(t),e.remove()};function I(e){var t=e.referenceType||"generic",n=mw.message("popups-refpreview-".concat(t));n.exists()||(n=mw.message("popups-refpreview-reference"));var r=E(e.type,v(_));A(r.querySelector(".mwe-popups-title-placeholder"),h(n.text())),r.querySelector(".mwe-popups-title .popups-icon").classList.add("popups-icon--reference-".concat(t)),r.querySelector(".mw-parser-output").innerHTML=e.extract,Array.prototype.forEach.call(r.querySelectorAll('.mwe-popups-extract a[href][class~="external"]:not([target])'),(function(e){e.target="_blank",e.rel="".concat(e.rel?"".concat(e.rel," "):"","noopener")})),Array.prototype.forEach.call(r.querySelectorAll(".mw-collapsible"),(function(e){var t=document.createElement("div");t.classList.add("mwe-collapsible-placeholder");var n=document.createElement("span");n.classList.add("popups-icon","popups-icon--infoFilled");var r=document.createElement("span");r.classList.add("mwe-collapsible-placeholder-label"),r.textContent=mw.msg("popups-refpreview-collapsible-placeholder"),t.appendChild(n),t.appendChild(r),A(e,t)}));var o=function(e){e.classList.remove("headerSort"),e.removeAttribute("tabindex"),e.removeAttribute("title")};Array.prototype.forEach.call(r.querySelectorAll("table.sortable"),(function(e){e.classList.remove("sortable","jquery-tablesorter"),Array.prototype.forEach.call(e.querySelectorAll(".headerSort"),o)}));var i=document.createElement("a");i.classList.add("cdx-button","cdx-button--fake-button","cdx-button--fake-button--enabled","cdx-button--weight-quiet","cdx-button--icon-only","mwe-popups-settings-button");var a=document.createElement("span");a.classList.add("popups-icon","popups-icon--size-small","popups-icon--settings");var s=document.createElement("span");return s.textContent=mw.msg("popups-settings-icon-gear-title"),i.append(a),i.append(s),r.querySelector(".mwe-popups-settings").appendChild(i),P()&&r.querySelector(".mw-parser-output").addEventListener("click",(function(e){e.target.matches("a")&&mw.track(x,{action:"clickedReferencePreviewsContentLink"})})),r.querySelector(".mwe-popups-scroll").addEventListener("scroll",(function(e){var t=e.target,n=t.scrollTop>=t.scrollHeight-t.clientHeight-1;if(P()&&(t.isOpenRecorded||(mw.track(x,{action:"poppedOpen",scrollbarsPresent:t.scrollHeight>t.clientHeight}),t.isOpenRecorded=!0),t.scrollTop>0&&!t.isScrollRecorded&&(mw.track(x,{action:"scrolled"}),t.isScrollRecorded=!0)),n||!t.isScrolling){var r=t.parentNode,o=t.scrollWidth>t.clientWidth,i=t.offsetHeight-t.clientHeight,a=t.scrollHeight>t.clientHeight,s=t.offsetWidth-t.clientWidth,c=r.querySelector(".mwe-popups-fade");c.style.bottom=o?"".concat(i,"px"):0,c.style.right=a?"".concat(s,"px"):0,t.isScrolling=!n,r.classList.toggle("mwe-popups-fade-out",t.isScrolling),r.setAttribute("lang",mw.config.get("wgPageContentLanguage"))}})),r}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function L(e,t){if(e){if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?k(e,t):void 0}}var N=215,O='\n<div>\n <a class="mwe-popups-discreet"></a>\n <a class="mwe-popups-extract"></a>\n <footer>\n\t\t<a class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only mwe-popups-settings-button">\n\t\t\t<span class="popups-icon popups-icon--size-small popups-icon--settings"></span>\n\t\t\t<span class="mwe-popups-settings-button-label"></span>\n </a>\n </footer>\n</div>\n\t';function C(e,t,n,r){var o=E(e.type,v(O)),i=o.querySelector(".mwe-popups-discreet"),a=o.querySelector(".mwe-popups-extract");a.setAttribute("href",e.url),i.setAttribute("href",e.url),a.setAttribute("dir",e.languageDirection),a.setAttribute("lang",e.languageCode),o.querySelector(".mwe-popups-settings-button").setAttribute("title",r);var s,c=h(mw.msg("popups-settings-icon-gear-title"));if(o.querySelector(".mwe-popups-settings-button-label").textContent=c,t?o.querySelector(".mwe-popups-discreet").appendChild(t.el):i.remove(),e.extract){"string"==typeof e.extract?a.innerHTML=e.extract:a.append.apply(a,function(e){if(Array.isArray(e))return k(e)}(s=e.extract)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(s)||L(s)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}());var u=function(e){return e&&e.isNarrow?"".concat(N+e.offset,"px"):""}(t);n||(a.style.width=u,o.querySelector("footer").style.width=u)}return o}var R={},D={};function H(e,t,n){R[e]=t||j,D[e]={requireSummary:!n}}function G(){return window.CSS&&"function"==typeof CSS.supports&&CSS.supports("clip-path","polygon(1px 1px)")}function j(e){var t=function(e,t){var n=p.BRACKETED_DEVICE_PIXEL_RATIO;if(!e)return null;var r=e.width/n,o=e.height/n,i=e.height>e.width||r<m.landscapeImage.w;if(i&&o<m.portraitImage.h&&e.height<m.portraitImage.h||e.source.indexOf("\\")>-1||e.source.indexOf("'")>-1||e.source.indexOf('"')>-1)return null;var a,s,c,u,l=r/o,d=l>.7&&l<1.3;i?(a=r>m.portraitImage.w?(r-m.portraitImage.w)/-2:m.portraitImage.w-r,s=o>m.portraitImage.h?(o-m.portraitImage.h)/-2:0,c=m.portraitImage.w,u=m.portraitImage.h,r<c&&(a=0,c=r)):(a=0,s=o>m.landscapeImage.h?(o-m.landscapeImage.h)/-2:0,c=m.landscapeImage.w,u=o>m.landscapeImage.h?m.landscapeImage.h:o);var f,h,g=i&&r<m.portraitImage.w,v=t?(f=e.source,(h=document.createElement("img")).className="mwe-popups-thumbnail",h.src=f,h):function(e,t,n,r,o,i,a,s){var c="http://www.w3.org/2000/svg",u=document.createElementNS(c,"polyline"),p=-1===e.indexOf("not-tall")?[0,0,0,s]:[0,s-1,a,s-1];u.setAttribute("stroke","rgba(0,0,0,0.1)"),u.setAttribute("points",p.join(" ")),u.setAttribute("stroke-width",1);var l=document.createElementNS(c,"image");l.setAttributeNS("http://www.w3.org/1999/xlink","href",t),l.classList.add(e),w(l,{x:n,y:r,width:o,height:i});var d=document.createElementNS(c,"svg");return w(d,{xmlns:c,width:a,height:s}),d.appendChild(l),d.appendChild(u),d}(i?"mwe-popups-is-tall":"mwe-popups-is-not-tall",e.source,a,s,r,o,c,u);return{el:v,isTall:i||d,isNarrow:g,offset:g?m.portraitImage.w-r:0,width:r,height:o}}(e.thumbnail,G()),n=null!==t;return{el:C(e,t,G(),mw.msg("popups-settings-icon-gear-title")),hasThumbnail:n,thumbnail:t,isTall:n&&t.isTall}}function q(e){return e.title=mw.msg("popups-preview-no-preview"),{el:T(e,null,mw.msg("popups-preview-footer-read")),hasThumbnail:!1,isTall:!1}}function F(e){return{el:T(e,mw.msg("popups-preview-disambiguation"),mw.msg("popups-preview-disambiguation-link")),hasThumbnail:!1,isTall:!1}}function W(e){return{el:I(e),hasThumbnail:!1,isTall:!1}}function M(e,t,n){var r,o=null;return Array.prototype.slice.call(t).forEach((function(t){var i=Math.abs(e-t.top+e-t.bottom);(null===o||o>i)&&(o=i,r=n?Math.floor(t.top):Math.ceil(t.bottom))})),r}var Y=[],V={TYPE_GENERIC:"generic",TYPE_PAGE:"page",TYPE_DISAMBIGUATION:"disambiguation",TYPE_REFERENCE:"reference"};function U(e,t,n,r,o,i,a,s){var c=function(e){if(null!=e&&0!==e.length)return e}(o),u=function(e,t){if(void 0===t&&function(e){return(D[e]||{requireSummary:!0}).requireSummary}(e))return V.TYPE_GENERIC;switch(e){case V.TYPE_GENERIC:case V.TYPE_DISAMBIGUATION:case V.TYPE_PAGE:return e;default:return V.TYPE_PAGE}}(i,c);return{title:e,url:t,languageCode:n,languageDirection:r,extract:c,type:u,thumbnail:a,pageId:s}}function B(e,t){return U(e,t,"","",[],"")}var X=[];function K(e){var t=X.filter((function(t){return n=e,r=t.selector,n.matches(r);var n,r}));return t.length>0?t[t.length-1].name:null}var z={};function $(e){return z[e]||0}function Z(e,t,n){Y.push(t),X.push({name:e,selector:t}),n&&function(e,t){z[e]=t}(e,n)}function J(e,t){var n=e;return void 0===e||0===n.length?[]:(n=function(e,t){var n=[],r="<bi-".concat(Math.random(),">"),o="<snip-".concat(Math.random(),">");t=t.replace(/\s+/g," ").trim();var i=mw.util.escapeRegExp(t),a=new RegExp("(^|\\s)(".concat(i,")(|$)"),"i");return(e=(e=(e=e.replace(/\s+/," ")).replace(a,"$1".concat(o).concat(r,"$2").concat(o,"$3"))).split(o)).forEach((function(e){if(0===e.indexOf(r)){var t=document.createElement("b");t.textContent=e.slice(r.length),n.push(t)}else n.push(document.createTextNode(e))})),n}(n,t),n)}function Q(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};return e.promise?e.promise({abort:t}):(e.abort=t,e)}var ee={};function te(e,t){ee[e]=t}function ne(e){if(e.query&&e.query.pages&&e.query.pages.length)return e.query.pages[0];throw new Error("API response `query.pages` is empty.")}function re(e){var t=Object.assign({},e);return t.extract=J(e.extract,e.title),t}function oe(e){return U(e.title,e.canonicalurl,e.pagelanguagehtmlcode,e.pagelanguagedir,e.extract,e.type,e.thumbnail,e.pageid)}var ie="https://www.mediawiki.org/wiki/Specs/Summary/1.2.0";function ae(e,t,n){function r(n){var r=t.endpoint;return e({url:r+encodeURIComponent(n),headers:{Accept:'application/json; charset=utf-8; profile="'.concat(ie,'"'),"Accept-Language":t.acceptLanguage}})}return{fetch:r,convertPageToModel:se,fetchPreviewForTitle:function(e){var o=e.getPrefixedDb(),i=r(o);return Q(i.then((function(e){return(e=e||{}).title=e.title||o,e.extract=e.extract||"",se(e,t.THUMBNAIL_SIZE,n)})).catch((function(e,t,n){return Promise.reject("http",{xhr:e,textStatus:t,exception:n})})),(function(){return i.abort()}))}}}function se(e,t,n){return U(e.title,new mw.Title(e.title).getUrl(),e.lang,e.dir,n(e),e.type,e.thumbnail?function(e,t,n){var r=e.source.split("/"),o=r[r.length-1],i=function(e){return new RegExp(/\.(jpg|jpeg|png|gif)$/i).test(e)}(t.source)||void 0,a=o.indexOf("px-");if(-1===a)return i&&t;var s,c,u=o.slice(a+3);return e.width>e.height?(s=n,c=Math.floor(n/e.width*e.height)):(s=Math.floor(n/e.height*e.width),c=n),s>=t.width&&-1===u.indexOf(".svg")?i&&t:(r[r.length-1]="".concat(s,"px-").concat(u),{source:r.join("/"),width:s,height:c})}(e.thumbnail,e.originalimage,t):void 0,e.pageid)}function ce(e){var t=e.extract_html,n=document.createElement("div");return n.innerHTML=t,0===t.length?[]:n.childNodes}function ue(e){return J(e.extract,e.title)}function pe(e){var t=new AbortController,n=t.signal;return Q(fetch(e.url,{headers:e.headers,signal:n}).then((function(e){return e.json()})),(function(){t.abort()}))}var le="mwe-popups-enabled",de="mwe-popups-referencePreviews-enabled",fe=n("./src/canSaveToUserPreferences.js");var me=function(e,t){var n=function(e){var t=Object.keys(e).map((function(t){return{id:t,name:mw.msg("popups-settings-option-".concat(t)),description:mw.msg("popups-settings-option-".concat(t,"-description")),isChecked:e[t]}}));return function(e){var t=h(e.heading),n=h(e.saveLabel),r=h(e.closeLabel),o=h(e.helpText),i=h(e.okLabel),a=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){var t=e.id,n=e.name,r=e.description,o=e.isChecked;return{id:h(t),name:h(n),description:r?h(r):"",isChecked:o}}))}(e.choices),s=document.createElement("div");return s.innerHTML="\n\t\t<section id='mwe-popups-settings'>\n\t\t\t<header>\n\t\t\t\t<div>\n\t\t\t\t\t<button class='cdx-button cdx-button--weight-quiet cdx-button--icon-only'>\n\t\t\t\t\t\t<span class='popups-icon popups-icon--close close'></span>\n\t\t\t\t\t\t<span>".concat(r,"</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<h1>").concat(t,"</h1>\n\t\t\t\t<div>\n\t\t\t\t\t<button class='save cdx-button cdx-button--weight-primary cdx-button--action-progressive'>").concat(n,"</button>\n\t\t\t\t\t<button class='okay cdx-button cdx-button--weight-primary cdx-button--action-progressive' style='display:none;'>").concat(i,"</button>\n\t\t\t\t</div>\n\t\t\t</header>\n\t\t\t<main id='mwe-popups-settings-form'>\n\t\t\t\t<form>\n\t\t\t\t\t").concat(a.map((function(e){var t=e.id,n=e.name,r=e.description,o=e.isChecked;return'\n\t\t\t\t\t<p class="cdx-checkbox">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t'.concat(o?"checked":"","\n\t\t\t\t\t\t\tvalue='").concat(t,"'\n\t\t\t\t\t\t\ttype='checkbox'\n\t\t\t\t\t\t\tid='mwe-popups-settings-").concat(t,"'\n\t\t\t\t\t\t\tclass='cdx-checkbox__input'>\n\t\t\t\t\t\t<span class=\"cdx-checkbox__icon\">&nbsp;</span>\n\t\t\t\t\t\t<label class=\"cdx-checkbox__label\" for='mwe-popups-settings-").concat(t,"'>\n\t\t\t\t\t\t\t<span>").concat(n,"</span>\n\t\t\t\t\t\t\t").concat(r,"\n\t\t\t\t\t\t</label>\n\t\t\t\t\t</p>")})).join(""),"\n\t\t\t\t</form>\n\t\t\t</main>\n\t\t\t<div class='mwe-popups-settings-help' style='display:none;'>\n\t\t\t\t<div class=\"popups-icon popups-icon--footer\"></div>\n\t\t\t\t<p>").concat(o,"</p>\n\t\t\t</div>\n\t\t</section>\n\t").trim(),s.querySelector("section")}({heading:mw.msg("popups-settings-title"),closeLabel:mw.msg("popups-settings-cancel"),saveLabel:mw.msg("popups-settings-save"),helpText:mw.msg("popups-settings-help"),okLabel:mw.msg("popups-settings-help-ok"),choices:t})}(t);return n.querySelector(".save").addEventListener("click",(function(){e.saveSettings(Array.from(n.querySelectorAll("input")).reduce((function(e,t){return e[t.value]=t.matches(":checked"),e}),{}))})),n.querySelector(".okay").addEventListener("click",e.hideSettings),n.querySelector(".close").addEventListener("click",e.hideSettings),n};function we(e){Array.prototype.forEach.call(e,(function(e){e.style.display="none"}))}function he(e){Array.prototype.forEach.call(e,(function(e){e.style.display=""}))}function ge(e,t){var n;e.subscribe((function(){var r=e.getState();n!==r&&(t(n,r),n=r)}))}var ve=n("./src/canSaveToUserPreferences.js");function ye(e,t){return t.split(".").reduce((function(e,t){return e&&e[t]}),e)}const Ee=function(e){var t;return function(n,r){void 0===t&&(t=function(){var e=document.createElement("li"),t=document.createElement("a");t.href="#",t.textContent=mw.message("popups-settings-enable").text(),e.appendChild(t),e.style.display="none";var n=document.querySelector("#footer-places, #f-list");if(!n){var r=document.querySelector("#footer li");r&&(n=r.parentNode)}return n&&n.appendChild(e),e}()).addEventListener("click",(function(t){t.preventDefault(),e.showSettings()})),r.settings.shouldShowFooterLink?t.style.display="":t.style.display="none"}},be=function(){var e;return function(t,n){var r,o=t&&t.preview.activeLink;o!==n.preview.activeLink&&((r=o)&&e&&(r.setAttribute("title",e),e=void 0),n.preview.enabled[n.preview.previewType]&&function(t){t&&!e&&(e=t.getAttribute("title"),t.setAttribute("title",""))}(n.preview.activeLink))}},Te=function(e,t){return function(n,r){var o,i;r.pageviews&&r.pageviews.pageview&&r.pageviews.page&&(o=r.pageviews.page,i=r.pageviews.pageview,t("event.VirtualPageView",{source_page_id:o.id,source_namespace:o.namespaceId,source_title:mw.Title.newFromText(o.title).getPrefixedDb(),source_url:o.url,page_id:i.page_id,page_namespace:i.page_namespace,page_title:mw.Title.newFromText(i.page_title).getPrefixedDb()}),e.pageviewLogged())}},Se=function(e){var t;return function(n,r){r.preview.shouldShow&&!t?(t=function(e){var t=function(e){return(R[e.type]||q)(e)}(e);return{show:function(e,n,r){return function(e,t,n,r,o,i,a){var s=function(e,t,n,r){var o,i=!1,a=!1,s=t.pageY?M(t.pageY-t.scrollTop,t.clientRects,!1)+t.scrollTop+8:t.offset.top+t.height+8,c=t.clientY?t.clientY:s;return(o=t.pageX?t.width>28?t.pageX:t.offset.left+t.width/2:t.offset.left)>t.windowWidth/2&&(o+=t.pageX?0:t.width,o-=e?450:320,i=!0),t.pageX&&(o+=i?18:-18),c>t.windowHeight/2&&(a=!0,s=t.offset.top,t.pageY&&(s=M(t.pageY-t.scrollTop,t.clientRects,!0)+t.scrollTop),s-=8),{offset:{top:s,left:o},flippedX:"rtl"===r?!i:i,flippedY:a,dir:r}}(e.isTall,t,0,a);return i.appendChild(e.el),function(e,t,n,r,o,i){var a=e.el,s=e.isTall,c=e.hasThumbnail,u=e.thumbnail,p=t.flippedY;!p&&!s&&c&&u.height<r&&!G()&&(a.querySelector(".mwe-popups-extract").style.marginTop="".concat(u.height-8,"px")),a.classList.add.apply(a.classList,n),a.style.left="".concat(t.offset.left,"px"),a.style.top=p?"auto":"".concat(t.offset.top,"px"),a.style.bottom=p?"".concat(i-t.offset.top,"px"):"auto",c&&!G()&&function(e,t){var n=e.el,r=e.isTall,o=e.thumbnail,i=t.flippedY,a=t.flippedX,s=t.dir,c=function(e,t,n){return e||t?e&&n?t?"mwe-popups-landscape-mask-flip":"mwe-popups-landscape-mask":void 0:n?"mwe-popups-mask-flip":"mwe-popups-mask"}(r,i,a);if(c){var u={scaleX:1,translateX:r?Math.min(o.width-m.portraitImage.w,0):0};"rtl"===s&&(u.scaleX=-1,u.translateX=r?m.portraitImage.w:m.landscapeImage.w),document.getElementById(c).setAttribute("transform","matrix(".concat(u.scaleX," 0 0 1 ").concat(u.translateX," 0)")),n.querySelector("image").setAttribute("clip-path","url(#".concat(c,")"))}}(e,t)}(e,s,function(e,t){var n=[];return t.flippedY?n.push("mwe-popups-fade-in-down"):n.push("mwe-popups-fade-in-up"),t.flippedY&&t.flippedX?n.push("flipped-x-y"):t.flippedY?n.push("flipped-y"):t.flippedX&&n.push("flipped-x"),n.push(function(e,t){return!((!e.hasThumbnail||e.isTall&&!t.flippedX)&&!t.flippedY||!e.hasThumbnail||!(!e.isTall&&!t.flippedY||e.isTall&&t.flippedX))}(e,t)?"mwe-popups-image-pointer":"mwe-popups-no-image-pointer"),e.isTall?n.push("mwe-popups-is-tall"):n.push("mwe-popups-is-not-tall"),n}(e,s),m.landscapeImage.h,0,t.windowHeight),e.el.style.display="block",e.el.classList.contains("mwe-popups-type-reference")&&e.el.querySelector(".mwe-popups-scroll").dispatchEvent(new Event("scroll")),l(200).then((function(){!function(e,t){e.el.addEventListener("mouseenter",t.previewDwell),e.el.addEventListener("mouseleave",t.previewAbandon),e.el.addEventListener("click",t.click);var n=e.el.querySelector("a.mwe-popups-settings-button");n&&(n.href=t.settingsUrl,n.addEventListener("click",(function(e){e.stopPropagation(),t.showSettings(e)})))}(e,r),r.previewShow(o)}))}(t,e,e.target,n,r,document.body,document.documentElement.getAttribute("dir"))},hide:function(){return function(e){var t=e.el.classList.contains("mwe-popups-fade-in-up")?"mwe-popups-fade-in-up":"mwe-popups-fade-in-down",n="mwe-popups-fade-in-up"===t?"mwe-popups-fade-out-down":"mwe-popups-fade-out-up";return e.el.classList.remove(t),e.el.classList.add(n),l(150).then((function(){e.el.remove()}))}(t)}}}(r.preview.fetchResponse)).show(r.preview.measures,e,r.preview.activeToken):!r.preview.shouldShow&&t&&(t.hide(),t=void 0)}},xe=function(e,t){var n;return function(r,o){r&&(n&&Object.keys(r.settings.previewTypesEnabled).length!==Object.keys(o.settings.previewTypesEnabled).length&&n.refresh(o.settings.previewTypesEnabled),!1===r.settings.shouldShow&&o.settings.shouldShow?(n||(n=t(e,o.settings.previewTypesEnabled)).appendTo(document.body),n.setEnabled(o.preview.enabled),n.show()):r.settings.shouldShow&&!1===o.settings.shouldShow&&n.hide(),r.settings.showHelp!==o.settings.showHelp&&n.toggleHelp(o.settings.showHelp))}},Pe=function(e,t){return function(n,r){var o=r.statsv;o.action&&(t(o.action,o.data),e.statsvLogged())}},_e=function(e){return function(t,n){Object.keys(n.preview.enabled).forEach((function(r){!function(t,n,o,i){var a,s=ye(n,o);t&&ye(t,o)!==s&&(a=s,e.storePreviewTypeEnabled(r,a))}(t,n,"preview.enabled.".concat(r))}))}};const Ae={BOOT:"BOOT",LINK_DWELL:"LINK_DWELL",REGISTER_SETTING:"REGISTER_SETTING",ABANDON_START:"ABANDON_START",ABANDON_END:"ABANDON_END",LINK_CLICK:"LINK_CLICK",FETCH_START:"FETCH_START",FETCH_END:"FETCH_END",FETCH_COMPLETE:"FETCH_COMPLETE",FETCH_FAILED:"FETCH_FAILED",FETCH_ABORTED:"FETCH_ABORTED",PAGEVIEW_LOGGED:"PAGEVIEW_LOGGED",PREVIEW_DWELL:"PREVIEW_DWELL",PREVIEW_SHOW:"PREVIEW_SHOW",PREVIEW_CLICK:"PREVIEW_CLICK",PREVIEW_SEEN:"PREVIEW_SEEN",SETTINGS_SHOW:"SETTINGS_SHOW",SETTINGS_HIDE:"SETTINGS_HIDE",SETTINGS_CHANGE:"SETTINGS_CHANGE",STATSV_LOGGED:"STATSV_LOGGED"};function Ie(e){return e.timestamp=mw.now(),e}function ke(e,t,n,r,o){var i=r.get("wgUserEditCount");return{type:Ae.BOOT,initiallyEnabled:e,isNavPopupsEnabled:r.get("wgPopupsConflictsWithNavPopupGadget"),sessionToken:t.sessionId(),pageToken:t.getPageviewToken(),page:{url:o,title:r.get("wgTitle"),namespaceId:r.get("wgNamespaceNumber"),id:r.get("wgArticleId")},user:{isAnon:t.isAnon()||mw.user.isTemp(),editCount:i}}}function Le(e,t){return{type:Ae.REGISTER_SETTING,name:e,enabled:t}}function Ne(e,t,n,r,o){var i=t.getPrefixedDb(),a=t.namespace;return function(s){var c=e.fetchPreviewForTitle(t,n);s(Ie({type:Ae.FETCH_START,el:n,title:i,namespaceId:a,promise:c}));var u=c.then((function(e){return s(Ie({type:Ae.FETCH_END,el:n})),e})).catch((function(e,t){var o=new Error(e),i=t&&t.textStatus&&"abort"===t.textStatus?Ae.FETCH_ABORTED:Ae.FETCH_FAILED;throw o.data=t,s({type:i,el:n,token:r}),o}));return Promise.all([u,l($(o))]).then((function(e){var t,o,i=(t=e,o=1,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}}(t,o)||L(t,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];s({type:Ae.FETCH_COMPLETE,el:n,result:i,token:r})})).catch((function(e){var o=e.data,a=!0;o&&o.xhr&&0===o.xhr.readyState&&(a=!("error"===o.textStatus&&""===o.exception||"abort"===o.textStatus)),a&&s({type:Ae.FETCH_COMPLETE,el:n,result:B(i,t.getUrl()),token:r})}))}}function Oe(e,t,n,r,o,i){var s=o(),c=e.getPrefixedDb(),u=e.namespace;return function(o,p){var d=l(a),f=Ie({type:Ae.LINK_DWELL,el:t,previewType:i,measures:n,token:s,title:c,namespaceId:u,promise:d});function m(){return p().preview.activeToken===s}return o(f),m()?d.then((function(){var n=p().preview.enabled[i];if((void 0===n||n)&&m())return o(Ne(r,e,t,s,i))})):Promise.resolve()}}function Ce(){return function(e,t){var n=t().preview,r=n.activeToken,o=n.promise;return r?(e(Ie({type:Ae.ABANDON_START,token:r})),"abort"in o&&o.abort(),l(u).then((function(){e({type:Ae.ABANDON_END,token:r})}))):Promise.resolve()}}function Re(e){return Ie({type:Ae.LINK_CLICK,el:e})}function De(){return{type:Ae.PREVIEW_DWELL}}function He(e){return function(t,n){return t(Ie({type:Ae.PREVIEW_SHOW,token:e})),l(c).then((function(){var r=n().preview,o=r&&r.fetchResponse,i=r&&r.activeToken,a=o&&[V.TYPE_PAGE,V.TYPE_DISAMBIGUATION].indexOf(o.type)>-1;i&&i===e&&o&&a&&t({type:Ae.PREVIEW_SEEN,title:o.title,pageId:o.pageId,namespace:0})}))}}function Ge(){return{type:Ae.PAGEVIEW_LOGGED}}function je(){return{type:Ae.SETTINGS_SHOW}}function qe(){return{type:Ae.SETTINGS_HIDE}}function Fe(e){return function(t,n){t({type:Ae.SETTINGS_CHANGE,oldValue:n().preview.enabled,newValue:e})}}function We(){return{type:Ae.STATSV_LOGGED}}function Me(e,t){var n,r=Object.prototype.hasOwnProperty,o={};for(var i in e)r.call(e,i)&&!r.call(t,i)&&(o[i]=e[i]);for(var a in t)if(r.call(t,a))if((n=t[a])&&n.constructor===Object){var s=e[a]?Me({},e[a]):{};o[a]=Me(s,t[a])}else o[a]=t[a];return o}function Ye(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Ve={pageviews:function(e,t){switch(void 0===e&&(e={pageview:void 0}),t.type){case Ae.BOOT:return Me(e,{page:t.page});case Ae.PAGEVIEW_LOGGED:return Me(e,{pageview:void 0});case Ae.PREVIEW_SEEN:return Me(e,{pageview:{page_title:t.title,page_id:t.pageId,page_namespace:t.namespace}});default:return e}},preview:function(e,t){switch(void 0===e&&(e={enabled:{},activeLink:void 0,previewType:void 0,measures:void 0,activeToken:"",shouldShow:!1,isUserDwelling:!1,wasClicked:!1}),t.type){case Ae.BOOT:return Me(e,{enabled:t.initiallyEnabled});case Ae.REGISTER_SETTING:return Me(e,{enabled:Object.assign({},e.enabled,Ye({},t.name,t.enabled))});case Ae.SETTINGS_CHANGE:return Me(e,{enabled:t.newValue});case Ae.LINK_DWELL:return t.el!==e.activeLink?Me(e,{activeLink:t.el,previewType:t.previewType,measures:t.measures,activeToken:t.token,shouldShow:!1,isUserDwelling:!0,promise:t.promise}):Me(e,{isUserDwelling:!0});case Ae.FETCH_ABORTED:case Ae.ABANDON_END:return t.token!==e.activeToken||e.isUserDwelling?e:Me(e,{activeLink:void 0,previewType:void 0,activeToken:void 0,measures:void 0,fetchResponse:void 0,shouldShow:!1});case Ae.PREVIEW_DWELL:return Me(e,{isUserDwelling:!0});case Ae.ABANDON_START:return Me(e,{isUserDwelling:!1,wasClicked:!1});case Ae.FETCH_START:return Me(e,{fetchResponse:void 0,promise:t.promise});case Ae.FETCH_COMPLETE:if(t.token===e.activeToken)return Me(e,{fetchResponse:t.result,shouldShow:e.isUserDwelling});default:return e}},settings:function(e,t){switch(void 0===e&&(e={shouldShow:!1,previewTypesEnabled:{},showHelp:!1,shouldShowFooterLink:!1}),t.type){case Ae.SETTINGS_SHOW:return Me(e,{shouldShow:!0,showHelp:!1});case Ae.SETTINGS_HIDE:return Me(e,{shouldShow:!1,showHelp:!1});case Ae.SETTINGS_CHANGE:var n=Object.keys(t.newValue),r=n.every((function(e){return t.oldValue[e]===t.newValue[e]})),o=n.some((function(e){return t.oldValue[e]&&!t.newValue[e]})),i=n.some((function(e){return!1===t.newValue[e]}));return Me(e,r?{shouldShow:!1}:{shouldShow:o,showHelp:o,shouldShowFooterLink:i});case Ae.REGISTER_SETTING:return Me(e,{previewTypesEnabled:Object.assign({},e.previewTypesEnabled,Ye({},t.name,t.enabled)),shouldShowFooterLink:e.shouldShowFooterLink||!t.enabled});case Ae.BOOT:var a=Object.keys(t.initiallyEnabled).some((function(e){return!1===t.initiallyEnabled[e]}));return Me(e,{previewTypesEnabled:Object.assign({},t.initiallyEnabled),shouldShowFooterLink:t.user.isAnon&&a});default:return e}},statsv:function(e,t){switch(e=e||{},t.type){case Ae.FETCH_START:return Me(e,{fetchStartedAt:t.timestamp});case Ae.FETCH_END:return Me(e,{action:"timing.PagePreviewsApiResponse",data:t.timestamp-e.fetchStartedAt});case Ae.FETCH_FAILED:return Me(e,{action:"counter.PagePreviewsApiFailure",data:1});case Ae.LINK_DWELL:return Me(e,{linkDwellStartedAt:t.timestamp});case Ae.PREVIEW_SHOW:return Me(e,{action:"timing.PagePreviewsPreviewShow",data:t.timestamp-e.linkDwellStartedAt});case Ae.STATSV_LOGGED:return Me(e,{action:null,data:null});default:return e}}};var Ue=n("./src/canSaveToUserPreferences.js"),Be=[".extiw",".mw-selflink",".image",".new",".internal",".external",".mw-cite-backlink a",".oo-ui-buttonElement-button",".ve-ce-surface a",".cancelLink a",".mw-selflink-fragment",'[href^="#"]'];function Xe(e){return function(t){var n=t&&t.target;if(n&&(3===n.nodeType&&(n=n.parentNode),n!==document))if(!n||n.closest){var r,o;if(r=n,o=Y.join(", "),null!==(n=r.closest(o))){var i=function(e,t){if(e.dataset.title)return mw.Title.newFromText(e.dataset.title);if(function(e){return e.hash&&e.host===location.host&&e.pathname===location.pathname&&e.search===location.search}(e))try{return mw.Title.newFromText(t.get("wgPageName")+decodeURIComponent(e.hash))}catch(e){return null}return function(e,t){if(!e)return null;var n=mw.Title.newFromText(e);return n&&t.indexOf(n.namespace)>=0?n:null}(function(e,t){var n;try{n=new mw.Uri(e)}catch(e){return}if(n.host===location.hostname){var r,o=Object.keys(n.query).length;if(o)1===o&&"title"in n.query&&(r=n.query.title);else{var i=mw.util.escapeRegExp(t.get("wgArticlePath")).replace("\\$1","([^?#]+)"),a=new RegExp(i).exec(n.path);try{r=a&&decodeURIComponent(a[1])}catch(e){}}return r?"".concat(r).concat(n.fragment?"#".concat(n.fragment):""):void 0}}(e.href,t),t.get("wgContentNamespaces"))}(n,mw.config);i&&e(n,i,t)}}else{var a=new Error("T340081: Unexpected DOM element ".concat(n.tagName," with nodeType ").concat(n.nodeType));mw.errorLogger.logError(a,"error.web-team")}}}!function(){var n,r;n=mw.config,r=parseInt(n.get("wgPopupsFlags"),10),n.set("wgPopupsConflictsWithNavPopupGadget",!!(1&r)),n.set("wgPopupsConflictsWithRefTooltipsGadget",!!(2&r)),n.set("wgPopupsReferencePreviews",!!(4&r));var i,c,u,l,d=t.compose,m=mw.user.generateRandomSessionId,w=function(e){var t=Object.assign({},p,{acceptLanguage:e.get("wgPageContentLanguage")}),n=Object.assign({},t,{endpoint:e.get("wgPopupsRestGatewayEndpoint")});switch(e.get("wgPopupsGateway")){case"mwApiPlain":return function(e,t){function n(n){return e.get({action:"query",prop:"info|extracts|pageimages|revisions|info",formatversion:2,redirects:!0,exintro:mw.config.get("wgPopupsTextExtractsIntroOnly",!0),exchars:t.EXTRACT_LENGTH,explaintext:!0,exsectionformat:"plain",piprop:"thumbnail",pithumbsize:t.THUMBNAIL_SIZE,pilicense:"any",rvprop:"timestamp",inprop:"url",titles:n,smaxage:300,maxage:300,uselang:"content"},{headers:{"X-Analytics":"preview=1","Accept-Language":t.acceptLanguage}})}return{fetch:n,extractPageFromResponse:ne,convertPageToModel:oe,fetchPreviewForTitle:function(e){var t=n(e.getPrefixedDb());return Q(t.then((function(e){return oe(re(ne(e)))})),(function(){return t.abort()}))},formatPlainTextExtract:re}}(new mw.Api,t);case"restbasePlain":return ae(pe,n,ue);case"restbaseHTML":return ae(pe,n,ce);default:throw new Error("Unknown gateway")}}(mw.config),h={fetchPreviewForTitle:function(e,t){var n=e.getFragment().replace(/ /g,"_"),r=function(e){var t="#".concat(CSS.escape(e));return document.querySelector("".concat(t," .mw-reference-text, ").concat(t," .reference-text"))}(n);if(!r||!r.textContent.trim()&&!r.children.length)return Promise.reject({textStatus:"abort",textContext:"Footnote not found or empty",xhr:{readyState:0}});var o,i,a,s,c={url:"#".concat(n),extract:r.innerHTML,type:V.TYPE_REFERENCE,referenceType:(o=r,i=["book","journal","news","note","web"],a=null,s=o.querySelectorAll("cite[class]"),Array.prototype.forEach.call(s,(function(e){if(!a)for(var t=e.className.split(/\s+/),n=t.length;n--;)if(-1!==i.indexOf(t[n]))return a=t[n],!1})),a),sourceElementId:t.parentNode.id};return Q(Promise.resolve(c))}},g=(c=mw.storage,{migrateOldPreferences:function(){!!c.get(le)&&(c.remove(le),this.storePreviewTypeEnabled(V.TYPE_PAGE,!1)),c.get(de)&&(c.remove(de),this.storePreviewTypeEnabled(V.TYPE_REFERENCE,!1))},isPreviewTypeEnabled:function(e){var t="mwe-popups-".concat(e,"-enabled");return null===c.get(t)},storePreviewTypeEnabled:function(e,t){e===V.TYPE_REFERENCE&&mw.track("event.ReferencePreviewsPopups",{action:t?"anonymousEnabled":"anonymousDisabled"});var n="mwe-popups-".concat(e,"-enabled");t?c.remove(n):c.set(n,"0")}}),v=function(e,t,n){return n.get("wgPopupsReferencePreviews")?n.get("wgPopupsConflictsWithRefTooltipsGadget")||n.get("wgPopupsConflictsWithNavPopupGadget")||"minerva"===n.get("skin")?null:Ue(e)?"1"===mw.user.options.get("popups-reference-previews")||null:t.isPreviewTypeEnabled(V.TYPE_REFERENCE):null}(mw.user,g,mw.config),y=function(e,t){return u||((l=document.createElement("div")).classList.add("mwe-popups-overlay"),u=me(e,t)),{refresh:function(t){var n=u.parentNode;u.remove(),u=me(e,t),n&&u.appendTo(n)},appendTo:function(e){e.appendChild(l),l.appendChild(u)},show:function(){mw.loader.using("codex-styles").then((function(){mw.requestIdleCallback((function(){l.style.display=""}))}))},hide:function(){l.style.display="none"},toggleHelp:function(e){!function(e,t){var n="main, .save, .close",r=".mwe-popups-settings-help, .okay";t?(we(e.querySelectorAll(n)),he(e.querySelectorAll(r))):(he(e.querySelectorAll(n)),we(e.querySelectorAll(r)))}(u,e)},setEnabled:function(e){Object.keys(e).forEach((function(t){var n=u.querySelector("#mwe-popups-settings-".concat(t));n&&(n.checked=e[t])}))}}},E=(i=mw.experiments,{weightedBoolean:function(e,t,n){return"true"===i.getBucket({enabled:!0,name:e,buckets:{true:t,false:1-t}},n)}}),b=function(e,t,n){return function(e,t,n){var r=t.get("wgPopupsStatsvSamplingRate",0);return n.weightedBoolean("ext.Popups.statsv",r,e.sessionId())}(e,t,n)?mw.track:function(){}}(mw.user,mw.config,E),T=mw.config.get("wgPopupsVirtualPageViews")?mw.track:function(){},P=function(e,t,n){return mw.config.get("wgPopupsConflictsWithNavPopupGadget")?null:ve(e)?"1"===mw.user.options.get("popups")||null:t.isPreviewTypeEnabled(V.TYPE_PAGE)}(mw.user,g);mw.config.get("debug")&&(d=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||d);var _,A,I,k,L,N=t.createStore(t.combineReducers(Ve),d(t.applyMiddleware(o()))),O=t.bindActionCreators(e,N.dispatch),C=function(e,t){var n,r=function(){};return fe(e)?n=mw.Title.newFromText("Special:Preferences#mw-prefsection-rendering").getUrl():r=function(e){e.preventDefault(),t.showSettings()},{settingsUrl:n,showSettings:r,previewDwell:t.previewDwell,previewAbandon:t.abandon,previewShow:t.previewShow,click:t.linkClick}}(mw.user,O);if(function(e,t,n,r,o,i,a){ge(e,Ee(t)),ge(e,be()),ge(e,Se(o)),ge(e,Pe(t,i)),ge(e,_e(n)),ge(e,xe(t,r)),ge(e,Te(t,a))}(N,O,g,y,C,b,T),O.boot({},mw.user,g,mw.config,window.location.href),mw.popups=function(e,t,n,r,o,i){return{isEnabled:function(){return!!e.getState().preview.enabled[V.TYPE_PAGE]},register:function(e){var a=e.type,s=e.selector,c=e.gateway,u=e.renderFn,p=e.subTypes,l=e.delay,d=e.init,f=e.doNotRequireSummary;if(!a||!s||!c)throw new Error('Registration of Popups custom preview type "'.concat(a,'" failed: You must specify a type, a selector, and a gateway.'));t(a,s,l),r(a,c),n(a,u,f),function(e){return mw.message("popups-settings-option-".concat(e)).exists()}(a)?o(a,i.isPreviewTypeEnabled(a)):mw.log.warn("[Popups] No setting for ".concat(a,' registered.\nPlease create message with key "popups-settings-option-').concat(a,'" if this is a mistake.')),p&&p.forEach((function(e){n(e.type,e.renderFn,e.doNotRequireSummary)})),"function"==typeof d&&d()}}}(N,Z,H,te,O.registerSetting,g),g.migrateOldPreferences(),null!==P){var R=Be.join(", ");mw.popups.register({type:V.TYPE_PAGE,selector:"#mw-content-text a[href][title]:not(".concat(R,")"),delay:s-a,gateway:w,renderFn:j,subTypes:[{type:V.TYPE_DISAMBIGUATION,renderFn:F,doNotRequireSummary:!0}]})}null!==v&&mw.popups.register({type:V.TYPE_REFERENCE,selector:'#mw-content-text .reference a[ href*="#" ]',delay:150,gateway:h,renderFn:W,init:function(){mw.config.get("wgPopupsReferencePreviews")&&navigator.sendBeacon&&mw.config.get("wgIsArticle")&&!S&&(S=!0,mw.track(x,{action:"pageview"}))}}),Y.length?(G()||(k=document.body,(L=document.createElement("div")).setAttribute("id","mwe-popups-svg"),L.innerHTML=f(),k.appendChild(L)),_=Xe((function(e,t,n){var r=K(e),o=function(e){return ee[e]}(r);if(o){var i=window.scrollY,a=e.getBoundingClientRect(),s={top:i+a.y,left:window.scrollX+a.x},c={pageX:n.pageX,pageY:n.pageY,clientY:n.clientY,width:e.offsetWidth,height:e.offsetHeight,offset:s,clientRects:e.getClientRects(),windowWidth:window.innerWidth,windowHeight:window.innerHeight,scrollTop:i};O.linkDwell(t,e,c,o,m,r)}})),A=Xe((function(){O.abandon()})),I=Xe((function(e){V.TYPE_PAGE===K(e)&&O.linkClick(e)})),document.addEventListener("mouseover",_),document.addEventListener("keyup",_),document.addEventListener("mouseout",A),document.addEventListener("blur",A),document.addEventListener("click",I)):mw.log.warn("ext.popups was loaded but everything is disabled")}(),window.Redux=t,window.ReduxThunk=r})()})();
//# sourceMappingURL=index.js.map.json