mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
8c5120c2a6
Apparently caused by a mistake in I8697232, and the QA for T340256 not covering the full functionality of what was changed in the patch. Bug: T345829 Change-Id: I482d32183ef7f2226c7ad114be0fbaf97bc7b898
1 line
211 KiB
JSON
1 line
211 KiB
JSON
{"version":3,"sources":["/w/extensions/Popups/webpack/bootstrap","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/arrayLikeToArray.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/arrayWithHoles.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/defineProperty.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/iterableToArray.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/nonIterableRest.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/nonIterableSpread.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/slicedToArray.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/toConsumableArray.js","/w/extensions/Popups/./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","/w/extensions/Popups/./node_modules/redux-thunk/dist/redux-thunk.min.js","/w/extensions/Popups/./node_modules/redux/dist/redux.min.js","/w/extensions/Popups/(webpack)/buildin/global.js","/w/extensions/Popups/(webpack)/buildin/module.js","/w/extensions/Popups/./src/canSaveToUserPreferences.js","/w/extensions/Popups/./src/constants.js","/w/extensions/Popups/./src/bracketedPixelRatio.js","/w/extensions/Popups/./src/preview/model.js","/w/extensions/Popups/./src/formatter.js","/w/extensions/Popups/./src/gateway/index.js","/w/extensions/Popups/./src/gateway/mediawiki.js","/w/extensions/Popups/./src/gateway/rest.js","/w/extensions/Popups/./src/gateway/restFormatters.js","/w/extensions/Popups/./src/gateway/page.js","/w/extensions/Popups/./src/gateway/reference.js","/w/extensions/Popups/./src/previewBehavior.js","/w/extensions/Popups/./src/ui/templates/templateUtil.js","/w/extensions/Popups/./src/ui/templates/settingsDialog/settingsDialog.js","/w/extensions/Popups/./src/ui/settingsDialogRenderer.js","/w/extensions/Popups/./src/ui/settingsDialog.js","/w/extensions/Popups/./src/changeListener.js","/w/extensions/Popups/./src/isPagePreviewsEnabled.js","/w/extensions/Popups/./src/title.js","/w/extensions/Popups/./src/wait.js","/w/extensions/Popups/./src/ui/thumbnail.js","/w/extensions/Popups/./src/ui/templates/popup/popup.js","/w/extensions/Popups/./src/ui/templates/preview/preview.js","/w/extensions/Popups/./src/instrumentation/referencePreviews.js","/w/extensions/Popups/./src/ui/templates/referencePreview/referencePreview.js","/w/extensions/Popups/./src/ui/templates/pagePreview/pagePreview.js","/w/extensions/Popups/./src/ui/renderer.js","/w/extensions/Popups/./src/changeListeners/syncUserSettings.js","/w/extensions/Popups/./src/changeListeners/index.js","/w/extensions/Popups/./src/changeListeners/footerLink.js","/w/extensions/Popups/./src/changeListeners/linkTitle.js","/w/extensions/Popups/./src/changeListeners/pageviews.js","/w/extensions/Popups/./src/changeListeners/render.js","/w/extensions/Popups/./src/changeListeners/settings.js","/w/extensions/Popups/./src/changeListeners/statsv.js","/w/extensions/Popups/./src/actionTypes.js","/w/extensions/Popups/./src/actions.js","/w/extensions/Popups/./src/reducers/nextState.js","/w/extensions/Popups/./src/reducers/index.js","/w/extensions/Popups/./src/reducers/pageviews.js","/w/extensions/Popups/./src/reducers/preview.js","/w/extensions/Popups/./src/reducers/settings.js","/w/extensions/Popups/./src/reducers/statsv.js","/w/extensions/Popups/./src/isReferencePreviewsEnabled.js","/w/extensions/Popups/./src/index.js","/w/extensions/Popups/./src/setUserConfigFlags.js","/w/extensions/Popups/./src/experiments.js","/w/extensions/Popups/./src/userSettings.js","/w/extensions/Popups/./src/instrumentation/statsv.js","/w/extensions/Popups/./src/integrations/mwpopups.js","/w/extensions/Popups/./src/ui/pointer-mask.svg"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","arr","len","length","arr2","Array","isArray","arrayLikeToArray","obj","configurable","writable","iter","iterator","from","_i","_s","_e","_arr","_n","_d","next","done","push","err","TypeError","arrayWithHoles","iterableToArrayLimit","unsupportedIterableToArray","nonIterableRest","arrayWithoutHoles","iterableToArray","nonIterableSpread","minLen","toString","slice","constructor","test","e","id","loaded","dispatch","getState","withExtraArgument","default","observable","self","window","global","Math","random","substring","split","join","INIT","REPLACE","PROBE_UNKNOWN_ACTION","type","apply","this","arguments","u","a","reduce","createStore","Error","f","h","indexOf","splice","y","getPrototypeOf","subscribe","replaceReducer","unsubscribe","combineReducers","keys","forEach","bindActionCreators","applyMiddleware","map","getOwnPropertySymbols","concat","filter","getOwnPropertyDescriptor","compose","__DO_NOT_USE__ActionTypes","g","Function","webpackPolyfill","deprecate","paths","children","user","isAnon","isNamed","bpr","dpr","devicePixelRatio","bracketedPixelRatio","BRACKETED_DEVICE_PIXEL_RATIO","THUMBNAIL_SIZE","max","EXTRACT_LENGTH","previewTypes","TYPE_GENERIC","TYPE_PAGE","TYPE_DISAMBIGUATION","TYPE_REFERENCE","createModel","title","url","languageCode","languageDirection","extract","thumbnail","pageId","processedExtract","processExtract","undefined","getPagePreviewType","createNullModel","registeredPreviewTypes","getPreviewType","el","candidates","element","selector","matches","selectors","dwellDelay","getDwellDelay","registerModel","delay","setDwellTime","formatPlainTextExtract","plainTextExtract","elements","boldIdentifier","snip","replace","trim","escapedTitle","mw","util","escapeRegExp","regExp","RegExp","part","highlightNode","document","createElement","textContent","createTextNode","makeTitleInExtractBold","abortablePromise","promise","abort","gatewayMap","registerGatewayForPreviewType","gateway","extractPageFromResponse","data","query","pages","result","assign","formatter","convertPageToModel","page","canonicalurl","pagelanguagehtmlcode","pagelanguagedir","pageid","createRESTBaseGateway","ajax","config","extractParser","fetch","endpoint","encodeURIComponent","headers","Accept","acceptLanguage","fetchPreviewForTitle","titleText","getPrefixedDb","xhr","then","catch","jqXHR","textStatus","errorThrown","Promise","reject","exception","generateThumbnailData","original","thumbSize","parts","source","lastPart","originalIsSafe","filename","isSafeImgFormat","filenamePxIndex","width","height","floor","Title","getUrl","lang","dir","originalimage","parseHTMLResponse","extract_html","extractNode","innerHTML","childNodes","parsePlainTextResponse","options","controller","AbortController","signal","resp","json","createPagePreviewGateway","gatewayConfig","constants","restConfig","api","action","prop","formatversion","redirects","exintro","exchars","explaintext","exsectionformat","piprop","pithumbsize","pilicense","rvprop","inprop","titles","smaxage","maxage","uselang","createMediaWikiApiGateway","Api","formatters","createReferenceGateway","getFragment","referenceNode","idSelector","CSS","escape","querySelector","scrapeReferenceText","textContext","readyState","referenceText","KNOWN_TYPES","citeTags","model","referenceType","querySelectorAll","classNames","className","sourceElementId","parentNode","resolve","canSaveToUserPreferences","require","escapeHTML","str","html","templates","createNodeFromTemplate","div","firstElementChild","cloneNode","renderSettingsDialog","heading","saveLabel","closeLabel","helpText","okLabel","choices","description","isChecked","escapeChoices","node","createSettingsDialogRenderer","referencePreviewsAvaliable","dialog","overlay","boundActions","msg","createSettingsDialog","classList","add","addEventListener","enabled","saveSettings","hideSettings","appendTo","appendChild","show","style","display","hide","toggleHelp","visible","hideAll","showAll","setEnabled","checked","nodes","registerChangeListener","store","callback","previousState","state","fromElement","dataset","newFromText","hash","host","location","pathname","search","isOwnPageAnchorLink","decodeURIComponent","contentNamespaces","mwTitle","namespace","isValid","href","linkHref","Uri","hostname","queryLength","pattern","exec","path","fragment","getTitle","wait","setTimeout","SIZES","w","createThumbnail","rawThumbnail","useCSSClipPath","thumbWidth","thumbHeight","tall","x","aspectRatio","isSquare","img","isNarrow","src","thumbnailWidth","thumbnailHeight","nsSvg","line","createElementNS","points","setAttribute","thumbnailSVGImage","setAttributeNS","addAttributes","xmlns","createThumbnailSVG","isTall","offset","attrs","renderPopup","container","renderPreview","message","linkMsg","popup","messageElement","remove","readLink","isTracking","LOGGING_SCHEMA","isTrackingEnabled","replaceWith","htmlOrOtherNode","insertAdjacentHTML","renderReferencePreview","titleMsg","exists","text","target","rel","otherNode","icon","label","undoHeaderSort","headerSort","removeAttribute","settingsButton","settingsIcon","settingsButtonLabel","append","ev","track","scrolledToBottom","scrollTop","scrollHeight","clientHeight","isOpenRecorded","scrollbarsPresent","isScrollRecorded","isScrolling","hasHorizontalScroll","scrollWidth","clientWidth","scrollbarHeight","offsetHeight","hasVerticalScroll","scrollbarWidth","offsetWidth","fade","bottom","right","toggle","renderPagePreview","withCSSClipPath","linkTitle","linkDiscreet","labelText","extractWidth","getExtractWidth","init","supportsCSSClipPath","body","pointerMaskSVG","render","preview","renderers","createEmptyPreview","createPreviewWithType","event","token","measures","_link","behavior","layout","isPreviewTall","pointerSpaceSize","offsetLeft","flippedX","flippedY","offsetTop","pageY","getClosestYPosition","clientRects","top","clientTop","clientY","pageX","left","windowWidth","windowHeight","createLayout","classes","predefinedLandscapeImageHeight","hasThumbnail","marginTop","maskID","getThumbnailClipPathID","matrix","scaleX","translateX","min","getElementById","setThumbnailClipPath","layoutPreview","hasPointerOnImage","getClasses","contains","dispatchEvent","Event","previewDwell","previewAbandon","click","button","settingsUrl","stopPropagation","showSettings","errorLogger","logError","bindBehavior","previewShow","documentElement","getAttribute","fadeInClass","fadeOutClass","registerPreviewUI","previewFn","createPagePreview","supports","createDisambiguationPreview","createReferencePreview","rects","isTop","minY","rect","deltaY","abs","ceil","syncIfChanged","oldState","newState","sync","current","footerLink","footerLinkElement","footerListItem","footer","footerLegacy","createFooterLink","preventDefault","settings","shouldShowFooterLink","savedTitle","oldLink","activeLink","previewType","destroyTitleAttr","pageviews","pageviewTracker","pageview","source_page_id","source_namespace","namespaceId","source_title","source_url","page_id","page_namespace","page_title","pageviewLogged","previewBehavior","shouldShow","renderer","fetchResponse","activeToken","settingsObj","showHelp","statsv","statsvObj","statsvLogged","syncUserSettings","userSettings","storePagePreviewsEnabled","storeReferencePreviewsEnabled","timedAction","baseAction","timestamp","now","boot","initiallyEnabled","editCount","types","isNavPopupsEnabled","sessionToken","sessionId","pageToken","getPageviewToken","isTemp","chain","fetchType","all","ex","showNullPreview","linkDwell","generateToken","isNewInteraction","enabledValue","abandon","linkClick","currentToken","validType","oldValue","newValue","nextState","updates","hasOwn","clone","actionTypes","isUserDwelling","wasClicked","nothingChanged","every","userOptedOut","some","anyDisabled","fetchStartedAt","linkDwellStartedAt","EXCLUDED_LINK_SELECTORS","handleDOMEventIfEligible","handler","nodeType","closest","titleFromElement","tagName","popupsFlags","parseInt","set","mwExperiments","storage","Redux","generateRandomSessionId","pagePreviewGateway","referenceGateway","isPagePreviewsEnabled","isReferencePreviewsEnabled","referencePreviewsState","settingsDialog","experiments","weightedBoolean","trueWeight","getBucket","buckets","true","false","statsvTracker","bucketingRate","isStatsvEnabled","getStatsvTracker","getPageviewTracker","createIsPagePreviewsEnabled","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","onHover","onHoverOut","onClick","reducers","ReduxThunk","actions","createPreviewBehavior","registerActions","changeListeners","registerChangeListeners","popups","isEnabled","register","renderFn","subTypes","subTypePreview","createMediaWikiPopupsObject","excludedLinksSelector","FETCH_COMPLETE_TARGET_DELAY","navigator","sendBeacon","rendererInit","getGatewayForPreviewType","scrollY","bbox","getBoundingClientRect","scrollX","getClientRects","innerWidth","innerHeight","log","warn"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAI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AEvB4F,EAAW,CAChBgB,MAAOlB,EAAMkB,MACbN,MAAOZ,EAAMY,MACbK,QAASjB,EAAMiB,QACfnQ,MAAOgM,EAAO6B,YACd5N,OAAQ+L,EAAO0B,aACf/C,SACAqF,YAAahE,EAAO4Q,iBACpBtM,YAAara,OAAO4mB,WACpBtM,aAActa,OAAO6mB,YACrB/P,aAGDpH,EAAa4R,UAAWtP,EAAS+D,EAAQoD,EAAUlS,EAASsa,EAAe7gB,OAEtEukB,EAAalC,IAA0B,WAC5CrT,EAAagS,aAERwD,EAAUnC,IAA0B,SAAWhN,GAC/CtS,EAAaE,YAAciB,EAAgBmR,IAC/CrG,EAAaiS,UAAW5L,MAG1BxP,SAASwJ,iBAAkB,YAAaiV,GACxCze,SAASwJ,iBAAkB,QAASiV,GACpCze,SAASwJ,iBAAkB,WAAYkV,GACvC1e,SAASwJ,iBAAkB,OAAQkV,GACnC1e,SAASwJ,iBAAkB,QAASmV,IAlDpClf,GAAG8gB,IAAIC,KAAM,oDA1Fb,GAiJF/mB,OAAO0jB,MAAQA,EACf1jB,OAAOolB,WAAaA,G,0CMzUpBlqB,EAAOD,QAAU","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\n","function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n}\n\nmodule.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}\n\nmodule.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\n\nfunction _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return arrayLikeToArray(arr);\n}\n\nmodule.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nmodule.exports = _defineProperty, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n}\n\nmodule.exports = _iterableToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _iterableToArrayLimit(arr, i) {\n var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"];\n\n if (_i == null) return;\n var _arr = [];\n var _n = true;\n var _d = false;\n\n var _s, _e;\n\n try {\n for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}\n\nmodule.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nmodule.exports = _nonIterableRest, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nmodule.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var arrayWithHoles = require(\"./arrayWithHoles.js\");\n\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit.js\");\n\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\n\nvar nonIterableRest = require(\"./nonIterableRest.js\");\n\nfunction _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}\n\nmodule.exports = _slicedToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var arrayWithoutHoles = require(\"./arrayWithoutHoles.js\");\n\nvar iterableToArray = require(\"./iterableToArray.js\");\n\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\n\nvar nonIterableSpread = require(\"./nonIterableSpread.js\");\n\nfunction _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}\n\nmodule.exports = _toConsumableArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\n\nfunction _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}\n\nmodule.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","!function(t,e){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=e():\"function\"==typeof define&&define.amd?define([],e):\"object\"==typeof exports?exports.ReduxThunk=e():t.ReduxThunk=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p=\"\",e(0)}([function(t,e,n){t.exports=n(1)},function(t,e){\"use strict\";function n(t){return function(e){var n=e.dispatch,o=e.getState;return function(e){return function(r){return\"function\"==typeof r?r(n,o,t):e(r)}}}}e.__esModule=!0;var o=n();o.withExtraArgument=n,e.default=o}])});","!function(e,t){\"object\"==typeof exports&&\"undefined\"!=typeof module?t(exports):\"function\"==typeof define&&define.amd?define([\"exports\"],t):t(e.Redux={})}(this,function(e){\"use strict\";var t=function(e){var t,r=e.Symbol;return\"function\"==typeof r?r.observable?t=r.observable:(t=r(\"observable\"),r.observable=t):t=\"@@observable\",t}(\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof module?module:Function(\"return this\")()),r=function(){return Math.random().toString(36).substring(7).split(\"\").join(\".\")},n={INIT:\"@@redux/INIT\"+r(),REPLACE:\"@@redux/REPLACE\"+r(),PROBE_UNKNOWN_ACTION:function(){return\"@@redux/PROBE_UNKNOWN_ACTION\"+r()}};function o(e,t){var r=t&&t.type;return\"Given \"+(r&&'action \"'+r+'\"'||\"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 i(e,t){return function(){return t(e.apply(this,arguments))}}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];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))}})}e.createStore=function e(r,o,i){var u;if(\"function\"==typeof o&&\"function\"==typeof i||\"function\"==typeof i&&\"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 o&&void 0===i&&(i=o,o=void 0),void 0!==i){if(\"function\"!=typeof i)throw Error(\"Expected the enhancer to be a function.\");return i(e)(r,o)}if(\"function\"!=typeof r)throw Error(\"Expected the reducer to be a function.\");var a=r,c=o,f=[],s=f,d=!1;function l(){s===f&&(s=f.slice())}function p(){if(d)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 h(e){if(\"function\"!=typeof e)throw Error(\"Expected the listener to be a function.\");if(d)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 l(),s.push(e),function(){if(t){if(d)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,l();var r=s.indexOf(e);s.splice(r,1)}}}function y(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(d)throw Error(\"Reducers may not dispatch actions.\");try{d=!0,c=a(c,e)}finally{d=!1}for(var t=f=s,r=0;t.length>r;r++)(0,t[r])();return e}return y({type:n.INIT}),(u={dispatch:y,subscribe:h,getState:p,replaceReducer:function(e){if(\"function\"!=typeof e)throw Error(\"Expected the nextReducer to be a function.\");a=e,y({type:n.REPLACE})}})[t]=function(){var e,r=h;return(e={subscribe:function(e){if(\"object\"!=typeof e||null===e)throw new TypeError(\"Expected the observer to be an object.\");function t(){e.next&&e.next(p())}return t(),{unsubscribe:r(t)}}})[t]=function(){return this},e},u},e.combineReducers=function(e){for(var t=Object.keys(e),r={},i=0;t.length>i;i++){var u=t[i];\"function\"==typeof e[u]&&(r[u]=e[u])}var a,c=Object.keys(r);try{!function(e){Object.keys(e).forEach(function(t){var r=e[t];if(void 0===r(void 0,{type:n.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===r(void 0,{type:n.PROBE_UNKNOWN_ACTION()}))throw Error('Reducer \"'+t+\"\\\" returned undefined when probed with a random type. Don't try to handle \"+n.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.')})}(r)}catch(e){a=e}return function(e,t){if(void 0===e&&(e={}),a)throw a;for(var n=!1,i={},u=0;c.length>u;u++){var f=c[u],s=e[f],d=(0,r[f])(s,t);if(void 0===d){var l=o(f,t);throw Error(l)}i[f]=d,n=n||d!==s}return n?i:e}},e.bindActionCreators=function(e,t){if(\"function\"==typeof e)return i(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 r=Object.keys(e),n={},o=0;r.length>o;o++){var u=r[o],a=e[u];\"function\"==typeof a&&(n[u]=i(a,t))}return n},e.applyMiddleware=function(){for(var e=arguments.length,t=Array(e),r=0;e>r;r++)t[r]=arguments[r];return function(e){return function(){var r=e.apply(void 0,arguments),n=function(){throw Error(\"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.\")},o={getState:r.getState,dispatch:function(){return n.apply(void 0,arguments)}},i=t.map(function(e){return e(o)});return function(e){for(var t=1;arguments.length>t;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);\"function\"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){u(e,t,r[t])})}return e}({},r,{dispatch:n=a.apply(void 0,i)(r.dispatch)})}}},e.compose=a,e.__DO_NOT_USE__ActionTypes=n,Object.defineProperty(e,\"__esModule\",{value:!0})});\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","module.exports = function(module) {\n\tif (!module.webpackPolyfill) {\n\t\tmodule.deprecate = function() {};\n\t\tmodule.paths = [];\n\t\t// module.parent = undefined by default\n\t\tif (!module.children) module.children = [];\n\t\tObject.defineProperty(module, \"loaded\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.l;\n\t\t\t}\n\t\t});\n\t\tObject.defineProperty(module, \"id\", {\n\t\t\tenumerable: true,\n\t\t\tget: function() {\n\t\t\t\treturn module.i;\n\t\t\t}\n\t\t});\n\t\tmodule.webpackPolyfill = 1;\n\t}\n\treturn module;\n};\n","/**\n * Can the current user save to user preferences?\n *\n * @param {User} user\n * @return {boolean}\n */\nconst canSaveToUserPreferences = ( user ) => {\n\treturn !user.isAnon() && user.isNamed();\n};\n\nmodule.exports = canSaveToUserPreferences;\n","import bracketedPixelRatio from './bracketedPixelRatio';\n\nconst bpr = bracketedPixelRatio();\n\n// See the following for context around this value.\n//\n// * https://phabricator.wikimedia.org/T161284\n// * https://phabricator.wikimedia.org/T70861#3129780\nexport const FETCH_START_DELAY = 150; // ms.\n// The delay after which a FETCH_COMPLETE action should be dispatched.\n//\n// If the API endpoint responds faster than 350 ms (or, say, the API\n// response is served from the UA's cache), then we introduce a delay of\n// 350 ms - t to make the preview delay consistent to the user. The total\n// delay from start to finish is 500 ms.\nexport const FETCH_COMPLETE_TARGET_DELAY = 350 + FETCH_START_DELAY; // ms.\n// The minimum time a preview must be open before we judge it\n// has been seen.\n// See https://phabricator.wikimedia.org/T184793\nexport const PREVIEW_SEEN_DURATION = 1000; // ms\nexport const ABANDON_END_DELAY = 300;\n\n//\n// Reference previews specific config\n//\nexport const FETCH_DELAY_REFERENCE_TYPE = 150; // ms.\n\nexport default {\n\tBRACKETED_DEVICE_PIXEL_RATIO: bpr,\n\t// See https://phabricator.wikimedia.org/T272169: requesting a larger thumbnail to avoid bluriness\n\tTHUMBNAIL_SIZE: 320 * Math.max( bpr, 1.5 ),\n\tEXTRACT_LENGTH: 525\n};\n","/**\n * @module bracketedPixelRatio\n */\n\n/**\n * Normalizes a user's device pixel ratio to either 1, 1.5, or 2.\n *\n * This is important when the server resizes images on the fly in order to\n * reduce the work it has to do for device pixel ratios that deviate from a\n * set of common ratios.\n *\n * Adapted from mediawiki/core /resources/src/jquery/jquery.hidpi.js\n *\n * @param {number} [dpr=window.devicePixelRatio]\n * @return {number} The bracketed device pixel ratio\n */\nexport default function ( dpr = window.devicePixelRatio ) {\n\tif ( !dpr ) {\n\t\t// Probably legacy browser so assume 1\n\t\treturn 1;\n\t}\n\n\tif ( dpr > 1.5 ) {\n\t\treturn 2;\n\t}\n\n\tif ( dpr > 1 ) {\n\t\treturn 1.5;\n\t}\n\n\treturn 1;\n}\n","/**\n * @module preview/model\n */\n\n/**\n * Page Preview types as defined in Schema:Popups\n * https://meta.wikimedia.org/wiki/Schema:Popups\n *\n * @constant {Object}\n */\nconst previewTypes = {\n\t/** Empty preview used in error situations */\n\tTYPE_GENERIC: 'generic',\n\t/** Standard page preview with or without thumbnail */\n\tTYPE_PAGE: 'page',\n\t/** Disambiguation page preview */\n\tTYPE_DISAMBIGUATION: 'disambiguation',\n\t/** Reference preview */\n\tTYPE_REFERENCE: 'reference'\n};\n\nexport { previewTypes };\n\n/**\n * Preview Model\n *\n * @typedef {Object} PreviewModel\n * @property {string} url The canonical URL of the page being previewed\n * @property {string} type One of the previewTypes.TYPE_… constants.\n *\n * @global\n */\n\n/**\n * @typedef {Object} PagePreviewModel\n * @extends PreviewModel\n * @property {string} title\n * @property {Array|undefined} extract `undefined` if the extract isn't\n * viable, e.g. if it's empty after having ellipsis and parentheticals\n * removed; this can be used to present default or error states\n * @property {string} languageCode\n * @property {string} languageDirection Either \"ltr\" or \"rtl\", or an empty string if undefined.\n * @property {{source: string, width: number, height: number}|undefined} thumbnail\n * @property {number} pageId Currently not used by any known popup type.\n *\n * @global\n */\n\n/**\n * @typedef {Object} ReferencePreviewModel\n * @extends PreviewModel\n * @property {string} extract An HTML snippet, not necessarily with a single top-level node\n * @property {string} referenceType A type identifier, e.g. \"web\"\n * @property {string} sourceElementId ID of the parent element that triggered the preview\n *\n * @global\n */\n\n/**\n * Creates a page preview model.\n *\n * @param {string} title\n * @param {string} url The canonical URL of the page being previewed\n * @param {string} languageCode\n * @param {string} languageDirection Either \"ltr\" or \"rtl\"\n * @param {Array|undefined|null} extract\n * @param {string} type\n * @param {{source: string, width: number, height: number}|undefined} [thumbnail]\n * @param {number} [pageId]\n * @return {PagePreviewModel}\n */\nexport function createModel(\n\ttitle,\n\turl,\n\tlanguageCode,\n\tlanguageDirection,\n\textract,\n\ttype,\n\tthumbnail,\n\tpageId\n) {\n\tconst processedExtract = processExtract( extract ),\n\t\tpreviewType = getPagePreviewType( type, processedExtract );\n\n\treturn {\n\t\ttitle,\n\t\turl,\n\t\tlanguageCode,\n\t\tlanguageDirection,\n\t\textract: processedExtract,\n\t\ttype: previewType,\n\t\tthumbnail,\n\t\tpageId\n\t};\n}\n\n/**\n * Creates an empty page preview model.\n *\n * @param {string} title\n * @param {string} url\n * @return {PagePreviewModel}\n */\nexport function createNullModel( title, url ) {\n\treturn createModel( title, url, '', '', [], '' );\n}\n\n/**\n * @param {Element} element\n * @param {string} selector\n * @return {boolean}\n */\nconst elementMatchesSelector = ( element, selector ) => {\n\treturn element.matches( selector );\n};\n\n/**\n * Recursively checks the element and its parents.\n *\n * @param {Element} element\n * @return {Element|null}\n */\nexport function findNearestEligibleTarget( element ) {\n\tconst selector = selectors.join( ', ' );\n\treturn element.closest( selector );\n}\n\n/**\n * @typedef {Object} PreviewType\n * @property {string} name identifier for preview type\n * @property {string} selector a CSS selector\n * @type {PreviewType[]}\n */\nconst registeredPreviewTypes = [];\n\n/**\n * Determines the applicable popup type based on title and link element.\n *\n * @param {HTMLAnchorElement} el\n * @return {string|null} One of the previewTypes.TYPE_… constants\n */\nexport function getPreviewType( el ) {\n\tconst candidates = registeredPreviewTypes.filter( ( type ) => elementMatchesSelector( el, type.selector ) );\n\n\t// If the filter returned some possibilities, use the last registered one.\n\tif ( candidates.length > 0 ) {\n\t\treturn candidates[ candidates.length - 1 ].name;\n\t}\n\n\treturn null;\n}\n\n/**\n * Processes the extract returned by the TextExtracts MediaWiki API query\n * module.\n *\n * If the extract is `undefined`, `null`, or empty, then `undefined` is\n * returned.\n *\n * @param {Array|undefined|null} extract\n * @return {Array|undefined} Array when extract is an not empty array, undefined\n * otherwise\n */\nfunction processExtract( extract ) {\n\tif ( extract === undefined || extract === null || extract.length === 0 ) {\n\t\treturn undefined;\n\t}\n\treturn extract;\n}\n\n/**\n * Determines the page preview type based on whether or not:\n * a. Is the preview empty.\n * b. The preview type matches one of previewTypes.\n * c. Assume standard page preview if both above are false\n *\n * @param {string} type\n * @param {Array|undefined} [processedExtract]\n * @return {string} One of the previewTypes.TYPE_… constants.\n */\n\nfunction getPagePreviewType( type, processedExtract ) {\n\tif ( processedExtract === undefined ) {\n\t\treturn previewTypes.TYPE_GENERIC;\n\t}\n\n\tswitch ( type ) {\n\t\tcase previewTypes.TYPE_GENERIC:\n\t\tcase previewTypes.TYPE_DISAMBIGUATION:\n\t\tcase previewTypes.TYPE_PAGE:\n\t\t\treturn type;\n\t\tdefault:\n\t\t\t/**\n\t\t\t * Assume type=\"page\" if extract exists & not one of previewTypes.\n\t\t\t * Note:\n\t\t\t * - Restbase response includes \"type\" prop but other gateways don't.\n\t\t\t * - event-logging Schema:Popups requires type=\"page\" but restbase\n\t\t\t * provides type=\"standard\". Model must conform to event-logging schema.\n\t\t\t */\n\t\t\treturn previewTypes.TYPE_PAGE;\n\t}\n}\n\nconst selectors = [];\n\nconst dwellDelay = {};\n\n/**\n * Determines the delay before showing the preview when dwelling a link.\n *\n * @param {string} type\n * @return {number}\n */\nexport function getDwellDelay( type ) {\n\treturn dwellDelay[ type ] || 0;\n}\n\n/***\n * Set the delay before showing the preview when dwelling a link.\n *\n * @param {string} type\n * @param {number} delay\n */\nexport function setDwellTime( type, delay ) {\n\tdwellDelay[ type ] = delay;\n}\n\n/**\n * Allows extensions to register their own page previews.\n *\n * @stable\n * @param {string} type\n * @param {string} selector A valid CSS selector to associate preview with\n * @param {number} [delay] optional delay between hovering and displaying preview.\n * If not defined, delay will be zero.\n */\nexport function registerModel( type, selector, delay ) {\n\tselectors.push( selector );\n\tregisteredPreviewTypes.push( {\n\t\tname: type,\n\t\tselector\n\t} );\n\tif ( delay ) {\n\t\tsetDwellTime( type, delay );\n\t}\n}\n\n/**\n * Check whether any kind of preview is enabled.\n *\n * @return {boolean}\n */\nexport function isAnythingEligible() {\n\treturn !!selectors.length;\n}\n\nexport const test = {\n\t/** For testing only */\n\treset: () => {\n\t\twhile ( registeredPreviewTypes.length ) {\n\t\t\tregisteredPreviewTypes.pop();\n\t\t}\n\t}\n};\n","/**\n * Improves the plain text extracts\n *\n * @param {string} plainTextExtract\n * @param {string} title\n * @return {Array}\n */\nexport function formatPlainTextExtract( plainTextExtract, title ) {\n\tlet extract = plainTextExtract;\n\tif ( plainTextExtract === undefined ) {\n\t\treturn [];\n\t}\n\n\t// After cleaning the extract it may have been blanked\n\tif ( extract.length === 0 ) {\n\t\treturn [];\n\t}\n\n\textract = makeTitleInExtractBold( extract, title );\n\treturn extract;\n}\n\n/**\n * Converts the extract into a list of elements, which correspond to fragments\n * of the extract. Fragments that match the title verbatim are wrapped in a\n * `<b>` element.\n *\n * Using the bolded elements of the extract of the page directly is covered by\n * [T141651](https://phabricator.wikimedia.org/T141651).\n *\n * Extracted from `mw.popups.renderer.article.getProcessedElements`.\n *\n * @param {string} extract\n * @param {string} title\n * @return {Array} A set of HTML Elements\n */\nfunction makeTitleInExtractBold( extract, title ) {\n\tconst elements = [],\n\t\tboldIdentifier = `<bi-${Math.random()}>`,\n\t\tsnip = `<snip-${Math.random()}>`;\n\n\ttitle = title.replace( /\\s+/g, ' ' ).trim(); // Remove extra white spaces\n\tconst escapedTitle = mw.util.escapeRegExp( title );\n\tconst regExp = new RegExp( `(^|\\\\s)(${escapedTitle})(|$)`, 'i' );\n\n\t// Remove text in parentheses along with the parentheses\n\textract = extract.replace( /\\s+/, ' ' ); // Remove extra white spaces\n\n\t// Make title bold in the extract text\n\t// As the extract is html escaped there can be no such string in it\n\t// Also, the title is escaped of RegExp elements thus can't have \"*\"\n\textract = extract.replace(\n\t\tregExp,\n\t\t`$1${snip}${boldIdentifier}$2${snip}$3`\n\t);\n\textract = extract.split( snip );\n\n\textract.forEach( ( part ) => {\n\t\tif ( part.indexOf( boldIdentifier ) === 0 ) {\n\t\t\tconst highlightNode = document.createElement( 'b' );\n\t\t\thighlightNode.textContent = part.slice( boldIdentifier.length );\n\t\t\telements.push( highlightNode );\n\t\t} else {\n\t\t\telements.push( document.createTextNode( part ) );\n\t\t}\n\t} );\n\n\treturn elements;\n}\n","/**\n * @module gateway\n */\n\n/**\n * The interface implemented by all preview gateways.\n *\n * @typedef Gateway\n * @property {function(string): JQuery.jqXHR} fetch\n * @property {FetchPreviewForTitle} fetchPreviewForTitle\n * @property {ConvertPageToModel} convertPageToModel\n */\n\n/**\n * A Promise, usually for a long running or costly task such as an HTTP request,\n * that is abortable.\n *\n * @template T\n * @typedef {Promise<T>} AbortPromise\n * @property {function(): void} abort\n */\n\n/**\n * @param {Promise|jQuery.Promise<T>} promise\n * @param {function(): void} [abort]\n * @return {AbortPromise}\n */\nexport function abortablePromise( promise, abort = () => {} ) {\n\t// JQuery provided.\n\tif ( promise.promise ) {\n\t\treturn promise.promise( {\n\t\t\tabort\n\t\t} );\n\t}\n\tpromise.abort = abort;\n\treturn promise;\n}\n\n/**\n * Fetches a preview for a page or reference.\n *\n * If the underlying request is successful and contains data for the requested title,\n * then the resulting promise will resolve. If not, then it will reject.\n *\n * @typedef {function(mw.Title, HTMLAnchorElement): AbortPromise<PreviewModel>} FetchPreviewForTitle\n */\n\n/**\n * Converts the API response to a preview model. Exposed for testing only.\n *\n * @typedef {function(Object, ...any): PagePreviewModel} ConvertPageToModel\n */\n\nconst gatewayMap = {};\n\n/**\n * @param {string} type Type of preview we are handling\n * @return {Gateway|undefined}\n */\nexport function getGatewayForPreviewType( type ) {\n\treturn gatewayMap[ type ];\n}\n\n/**\n * Register a gateway for a given preview type.\n *\n * @param {string} type preview type\n * @param {Gateway} gateway\n */\nexport function registerGatewayForPreviewType( type, gateway ) {\n\tgatewayMap[ type ] = gateway;\n}\n","/**\n * @module gateway/mediawiki\n */\n\nimport { createModel } from '../preview/model';\nimport * as formatter from '../formatter';\nimport { abortablePromise } from './index.js';\n\n// Public and private cache lifetime (5 minutes)\n//\n// FIXME: Move this to src/constants.js.\nconst CACHE_LIFETIME = 300;\n\n/**\n * @typedef {Gateway} MediaWikiGateway\n * @property {function(Object): Object} extractPageFromResponse\n * @property {function(Object): Object} formatPlainTextExtract\n */\n\n/**\n * Creates an instance of the MediaWiki API gateway.\n *\n * @param {mw.Api} api\n * @param {Object} config Configuration that affects the major behavior of the\n * gateway.\n * @param {number} config.THUMBNAIL_SIZE The length of the major dimension of\n * the thumbnail.\n * @param {number} config.EXTRACT_LENGTH The maximum length, in characters,\n * of the extract.\n * @param {string} config.acceptLanguage The accepted language sent in the\n * header\n * @return {MediaWikiGateway}\n */\nexport default function createMediaWikiApiGateway( api, config ) {\n\tfunction fetch( title ) {\n\t\treturn api.get( {\n\t\t\taction: 'query',\n\t\t\tprop: 'info|extracts|pageimages|revisions|info',\n\t\t\tformatversion: 2,\n\t\t\tredirects: true,\n\t\t\texintro: mw.config.get( 'wgPopupsTextExtractsIntroOnly', true ),\n\t\t\texchars: config.EXTRACT_LENGTH,\n\n\t\t\t// There is an added geometric limit on .mwe-popups-extract\n\t\t\t// so that text does not overflow from the card.\n\t\t\texplaintext: true,\n\t\t\texsectionformat: 'plain',\n\n\t\t\tpiprop: 'thumbnail',\n\t\t\tpithumbsize: config.THUMBNAIL_SIZE,\n\t\t\tpilicense: 'any',\n\t\t\trvprop: 'timestamp',\n\t\t\tinprop: 'url',\n\t\t\ttitles: title,\n\t\t\tsmaxage: CACHE_LIFETIME,\n\t\t\tmaxage: CACHE_LIFETIME,\n\t\t\tuselang: 'content'\n\t\t}, {\n\t\t\theaders: {\n\t\t\t\t'X-Analytics': 'preview=1',\n\t\t\t\t'Accept-Language': config.acceptLanguage\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * @param {mw.Title} title\n\t * @return {AbortPromise<PagePreviewModel>}\n\t */\n\tfunction fetchPreviewForTitle( title ) {\n\t\tconst xhr = fetch( title.getPrefixedDb() );\n\t\treturn abortablePromise( xhr.then( ( data ) => {\n\t\t\tconst page = extractPageFromResponse( data );\n\t\t\tconst plainTextExtract = formatPlainTextExtract( page );\n\t\t\treturn convertPageToModel( plainTextExtract );\n\t\t} ), () => xhr.abort() );\n\t}\n\n\treturn {\n\t\tfetch,\n\t\textractPageFromResponse,\n\t\tconvertPageToModel,\n\t\tfetchPreviewForTitle,\n\t\tformatPlainTextExtract\n\t};\n}\n\n/**\n * Extracts page data from the API response.\n *\n * @method\n * @name MediaWikiGateway#extractPageFromResponse\n * @param {Object} data The response\n * @throws {Error} If the response is empty or doesn't contain data about the\n * page\n * @return {Object}\n */\nfunction extractPageFromResponse( data ) {\n\tif (\n\t\tdata.query &&\n\t\tdata.query.pages &&\n\t\tdata.query.pages.length\n\t) {\n\t\treturn data.query.pages[ 0 ];\n\t}\n\n\tthrow new Error( 'API response `query.pages` is empty.' );\n}\n\n/**\n * Make plain text nicer by applying formatter.\n *\n * @method\n * @name MediaWikiGateway#formatPlainTextExtract\n * @param {Object} data The response\n * @return {Object}\n */\nfunction formatPlainTextExtract( data ) {\n\tconst result = Object.assign( {}, data );\n\tresult.extract = formatter.formatPlainTextExtract( data.extract, data.title );\n\treturn result;\n}\n\n/**\n * Converts the API response to a preview model.\n *\n * @method\n * @name MediaWikiGateway#convertPageToModel\n * @param {Object} page\n * @return {PagePreviewModel}\n */\nfunction convertPageToModel( page ) {\n\treturn createModel(\n\t\tpage.title,\n\t\tpage.canonicalurl,\n\t\tpage.pagelanguagehtmlcode,\n\t\tpage.pagelanguagedir,\n\t\tpage.extract,\n\t\tpage.type,\n\t\tpage.thumbnail,\n\t\tpage.pageid\n\t);\n}\n","/**\n * @module gateway/rest\n */\n\nimport { createModel } from '../preview/model';\nimport { abortablePromise } from './index.js';\n\nconst RESTBASE_PROFILE = 'https://www.mediawiki.org/wiki/Specs/Summary/1.2.0';\n\n/** @typedef {function(JQuery.AjaxSettings=): JQuery.jqXHR} Ajax */\n\n/**\n * Creates an instance of the RESTBase gateway.\n *\n * This gateway differs from the {@link MediaWikiGateway MediaWiki gateway} in\n * that it fetches page data from [the RESTBase page summary endpoint][0].\n *\n * [0]: https://en.wikipedia.org/api/rest_v1/#!/Page_content/get_page_summary_title\n *\n * @param {Ajax} ajax A function with the same signature as `jQuery.ajax`\n * @param {Object} config Configuration that affects the major behavior of the\n * gateway.\n * @param {Function} extractParser A function that takes response and returns\n * parsed extract\n * @return {Gateway}\n */\nexport default function createRESTBaseGateway( ajax, config, extractParser ) {\n\t/**\n\t * Fetches page data from [the RESTBase page summary endpoint][0].\n\t *\n\t * [0]: https://en.wikipedia.org/api/rest_v1/#!/Page_content/get_page_summary_title\n\t *\n\t * @method\n\t * @name RESTBaseGateway#fetch\n\t * @param {string} title\n\t * @return {jQuery.jqXHR}\n\t */\n\tfunction fetch( title ) {\n\t\tconst endpoint = config.endpoint;\n\n\t\treturn ajax( {\n\t\t\turl: endpoint + encodeURIComponent( title ),\n\t\t\theaders: {\n\t\t\t\tAccept: `application/json; charset=utf-8; profile=\"${RESTBASE_PROFILE}\"`,\n\t\t\t\t'Accept-Language': config.acceptLanguage\n\t\t\t}\n\t\t} );\n\t}\n\n\t/**\n\t * @param {mw.Title} title\n\t * @return {AbortPromise<PagePreviewModel>}\n\t */\n\tfunction fetchPreviewForTitle( title ) {\n\t\tconst titleText = title.getPrefixedDb(),\n\t\t\txhr = fetch( titleText );\n\t\treturn abortablePromise( xhr.then( ( page ) => {\n\t\t\t// Endpoint response may be empty or simply missing a title.\n\t\t\tpage = page || {};\n\t\t\tpage.title = page.title || titleText;\n\t\t\t// And extract may be omitted if empty string\n\t\t\tpage.extract = page.extract || '';\n\t\t\treturn convertPageToModel(\n\t\t\t\tpage, config.THUMBNAIL_SIZE, extractParser\n\t\t\t);\n\t\t} ).catch( ( jqXHR, textStatus, errorThrown ) => {\n\t\t\t// The client will choose how to handle these errors which may include\n\t\t\t// those due to HTTP 4xx and 5xx status. The rejection typing matches\n\t\t\t// fetch failures.\n\t\t\treturn Promise.reject( 'http', {\n\t\t\t\txhr: jqXHR,\n\t\t\t\ttextStatus,\n\t\t\t\texception: errorThrown\n\t\t\t} );\n\t\t} ), () => xhr.abort() );\n\t}\n\n\treturn {\n\t\tfetch,\n\t\tconvertPageToModel,\n\t\tfetchPreviewForTitle\n\t};\n}\n\n/**\n * Checks whether the `originalImage` property contains an image\n * format that's safe to render.\n * https://www.mediawiki.org/wiki/Help:Images#Supported_media_types_for_images\n *\n * @param {string} filename\n *\n * @return {boolean}\n */\nfunction isSafeImgFormat( filename ) {\n\tconst safeImage = new RegExp( /\\.(jpg|jpeg|png|gif)$/i );\n\treturn safeImage.test( filename );\n}\n\n/**\n * Resizes the thumbnail to the requested width, preserving its aspect ratio.\n *\n * The requested width is limited to that of the original image unless the image\n * is an SVG, which can be scaled infinitely.\n *\n * This function is only intended to mangle the pretty thumbnail URLs used on\n * Wikimedia Commons. Once [an official thumb API](https://phabricator.wikimedia.org/T66214)\n * is fully specified and implemented, this function can be made more general.\n *\n * @param {Object} thumbnail The thumbnail image\n * @param {Object} original The original image\n * @param {number} thumbSize The requested size\n * @return {{source: string, width: number, height: number}|undefined}\n */\nfunction generateThumbnailData( thumbnail, original, thumbSize ) {\n\tconst parts = thumbnail.source.split( '/' ),\n\t\tlastPart = parts[ parts.length - 1 ],\n\t\toriginalIsSafe = isSafeImgFormat( original.source ) || undefined;\n\n\t// The last part, the thumbnail's full filename, is in the following form:\n\t// ${width}px-${filename}.${extension}. Splitting the thumbnail's filename\n\t// makes this function resilient to the thumbnail not having the same\n\t// extension as the original image, which is definitely the case for SVG's\n\t// where the thumbnail's extension is .svg.png.\n\tconst filenamePxIndex = lastPart.indexOf( 'px-' );\n\tif ( filenamePxIndex === -1 ) {\n\t\t// The thumbnail size is not customizable. Presumably, RESTBase requested a\n\t\t// width greater than the original and so MediaWiki returned the original's\n\t\t// URL instead of a thumbnail compatible URL. An original URL does not have\n\t\t// a \"thumb\" path, e.g.:\n\t\t//\n\t\t// https://upload.wikimedia.org/wikipedia/commons/a/aa/Red_Giant_Earth_warm.jpg\n\t\t//\n\t\t// Instead of:\n\t\t//\n\t\t// https://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Red_Giant_Earth_warm.jpg/512px-Red_Giant_Earth_warm.jpg\n\t\t//\n\t\t// Use the original if it's a supported image format.\n\t\treturn originalIsSafe && original;\n\t}\n\tconst filename = lastPart.slice( filenamePxIndex + 3 );\n\n\t// Scale the thumbnail's largest dimension.\n\tlet width, height;\n\tif ( thumbnail.width > thumbnail.height ) {\n\t\twidth = thumbSize;\n\t\theight = Math.floor( ( thumbSize / thumbnail.width ) * thumbnail.height );\n\t} else {\n\t\twidth = Math.floor( ( thumbSize / thumbnail.height ) * thumbnail.width );\n\t\theight = thumbSize;\n\t}\n\n\t// If the image isn't an SVG, then it shouldn't be scaled past its original\n\t// dimensions.\n\tif ( width >= original.width && filename.indexOf( '.svg' ) === -1 ) {\n\t\t// if the image format is not supported, it shouldn't be rendered.\n\t\treturn originalIsSafe && original;\n\t}\n\n\tparts[ parts.length - 1 ] = `${width}px-${filename}`;\n\n\treturn {\n\t\tsource: parts.join( '/' ),\n\t\twidth,\n\t\theight\n\t};\n}\n\n/**\n * Converts the API response to a preview model.\n *\n * @method\n * @name RESTBaseGateway#convertPageToModel\n * @param {Object} page\n * @param {number} thumbSize\n * @param {Function} extractParser\n * @return {PagePreviewModel}\n */\nexport function convertPageToModel( page, thumbSize, extractParser ) {\n\treturn createModel(\n\t\tpage.title,\n\t\tnew mw.Title( page.title ).getUrl(),\n\t\tpage.lang,\n\t\tpage.dir,\n\t\textractParser( page ),\n\t\tpage.type,\n\t\tpage.thumbnail ?\n\t\t\tgenerateThumbnailData(\n\t\t\t\tpage.thumbnail, page.originalimage, thumbSize\n\t\t\t) : undefined,\n\t\tpage.pageid\n\t);\n}\n","import * as formatter from '../formatter';\n\n/**\n * Prepare extract\n *\n * @param {Object} page Rest response\n * @return {Array} An array of DOM Elements\n */\nexport function parseHTMLResponse( page ) {\n\tconst extract = page.extract_html;\n\tconst extractNode = document.createElement( 'div' );\n\textractNode.innerHTML = extract;\n\treturn extract.length === 0 ? [] : extractNode.childNodes;\n}\n\n/**\n * Prepare extract\n *\n * @param {Object} page Rest response\n * @return {Array} An array of DOM Elements\n */\nexport function parsePlainTextResponse( page ) {\n\treturn formatter.formatPlainTextExtract( page.extract, page.title );\n}\n","/**\n * @module gateway/page\n */\n\nimport constants from '../constants';\nimport createMediaWikiApiGateway from './mediawiki';\nimport createRESTBaseGateway from './rest';\nimport * as formatters from './restFormatters';\nimport { abortablePromise } from './index.js';\n\n/**\n * @param {Object} options\n * @return {Promise}\n */\nfunction ajax( options ) {\n\tconst controller = new AbortController();\n\tconst signal = controller.signal;\n\n\treturn abortablePromise(\n\t\tfetch( options.url, {\n\t\t\theaders: options.headers,\n\t\t\tsignal\n\t\t} ).then( ( resp ) => resp.json() ),\n\t\t() => {\n\t\t\tcontroller.abort();\n\t\t}\n\t);\n}\n\n/**\n * Creates a page preview gateway with sensible values for the dependencies.\n *\n * @param {mw.Map} config\n * @return {Gateway}\n */\nexport default function createPagePreviewGateway( config ) {\n\tconst gatewayConfig = Object.assign( {}, constants, {\n\t\tacceptLanguage: config.get( 'wgPageContentLanguage' )\n\t} );\n\tconst restConfig = Object.assign( {}, gatewayConfig, {\n\t\tendpoint: config.get( 'wgPopupsRestGatewayEndpoint' )\n\t} );\n\tswitch ( config.get( 'wgPopupsGateway' ) ) {\n\t\tcase 'mwApiPlain':\n\t\t\treturn createMediaWikiApiGateway( new mw.Api(), gatewayConfig );\n\t\tcase 'restbasePlain':\n\t\t\treturn createRESTBaseGateway(\n\t\t\t\tajax, restConfig, formatters.parsePlainTextResponse );\n\t\tcase 'restbaseHTML':\n\t\t\treturn createRESTBaseGateway(\n\t\t\t\tajax, restConfig, formatters.parseHTMLResponse );\n\t\tdefault:\n\t\t\tthrow new Error( 'Unknown gateway' );\n\t}\n}\n","/**\n * @module gateway/reference\n */\n\nimport { previewTypes } from '../preview/model';\nimport { abortablePromise } from './index.js';\n\n/**\n * @return {Gateway}\n */\nexport default function createReferenceGateway() {\n\n\t/**\n\t * @param {string} id\n\t * @return {HTMLElement}\n\t */\n\tfunction scrapeReferenceText( id ) {\n\t\tconst idSelector = `#${CSS.escape( id )}`;\n\n\t\t/**\n\t\t * Same alternative selectors with and without mw-… as in the RESTbased endpoint.\n\t\t *\n\t\t * @see https://phabricator.wikimedia.org/diffusion/GMOA/browse/master/lib/transformations/references/structureReferenceListContent.js$138\n\t\t */\n\t\treturn document.querySelector( `${idSelector} .mw-reference-text, ${idSelector} .reference-text` );\n\t}\n\n\t/**\n\t * Attempts to find a single reference type identifier, limited to a list of known types.\n\t * - When a `class=\"…\"` attribute mentions multiple known types, the last one is used, following\n\t * CSS semantics.\n\t * - When there are multiple <cite> tags, the first with a known type is used.\n\t *\n\t * @param {HTMLElement} referenceText\n\t * @return {string|null}\n\t */\n\tfunction scrapeReferenceType( referenceText ) {\n\t\tconst KNOWN_TYPES = [ 'book', 'journal', 'news', 'note', 'web' ];\n\t\tlet type = null;\n\t\tconst citeTags = referenceText.querySelectorAll( 'cite[class]' );\n\t\tArray.prototype.forEach.call( citeTags, ( element ) => {\n\t\t\t// don't need to keep scanning if one is found.\n\t\t\tif ( type ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst classNames = element.className.split( /\\s+/ );\n\t\t\tfor ( let i = classNames.length; i--; ) {\n\t\t\t\tif ( KNOWN_TYPES.indexOf( classNames[ i ] ) !== -1 ) {\n\t\t\t\t\ttype = classNames[ i ];\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t\treturn type;\n\t}\n\n\t/**\n\t * @param {mw.Title} title\n\t * @param {HTMLAnchorElement} el\n\t * @return {AbortPromise<ReferencePreviewModel>}\n\t */\n\tfunction fetchPreviewForTitle( title, el ) {\n\t\t// Need to encode the fragment again as mw.Title returns it as decoded text\n\t\tconst id = title.getFragment().replace( / /g, '_' ),\n\t\t\treferenceNode = scrapeReferenceText( id );\n\n\t\tif ( !referenceNode ||\n\t\t\t// Skip references that don't contain anything but whitespace, e.g. a single \n\t\t\t( !referenceNode.textContent.trim() && !referenceNode.children.length )\n\t\t) {\n\t\t\treturn Promise.reject(\n\t\t\t\t// Required to set `showNullPreview` to false and not open an error popup\n\t\t\t\t{ textStatus: 'abort', textContext: 'Footnote not found or empty', xhr: { readyState: 0 } }\n\t\t\t);\n\t\t}\n\n\t\tconst model = {\n\t\t\turl: `#${id}`,\n\t\t\textract: referenceNode.innerHTML,\n\t\t\ttype: previewTypes.TYPE_REFERENCE,\n\t\t\treferenceType: scrapeReferenceType( referenceNode ),\n\t\t\t// Note: Even the top-most HTMLHtmlElement is guaranteed to have a parent.\n\t\t\tsourceElementId: el.parentNode.id\n\t\t};\n\n\t\treturn abortablePromise( Promise.resolve( model ) );\n\t}\n\n\treturn {\n\t\tfetchPreviewForTitle\n\t};\n}\n","/**\n * @module previewBehaviour\n */\nconst canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );\n\n/**\n * A collection of event handlers specific to how the user interacts with all\n * previews. The event handlers are are agnostic to how/when they are bound\n * //but not to what they are bound//, i.e. the showSettings event handler is\n * written to be bound to either an `<a>` or `<button>` element.\n *\n * @typedef {Object} ext.popups.PreviewBehavior\n * @property {string} settingsUrl\n * @property {Function} showSettings\n * @property {Function} previewDwell\n * @property {Function} previewAbandon\n * @property {Function} previewShow\n * @property {Function} click handler for the entire preview\n */\n\n/**\n * Creates an instance of `ext.popups.PreviewBehavior`.\n *\n * If the user is logged out, then clicking the cog should show the settings\n * modal.\n *\n * If the user is logged in, then clicking the cog should send them to the\n * the \"Appearance\" tab otherwise.\n *\n * @param {mw.User} user\n * @param {Object} actions The action creators bound to the Redux store\n * @return {ext.popups.PreviewBehavior}\n */\nexport default function createPreviewBehavior( user, actions ) {\n\tlet settingsUrl, showSettings = () => {};\n\n\tif ( !canSaveToUserPreferences( user ) ) {\n\t\tshowSettings = ( event ) => {\n\t\t\tevent.preventDefault();\n\n\t\t\tactions.showSettings();\n\t\t};\n\t} else {\n\t\tconst rawTitle = 'Special:Preferences#mw-prefsection-rendering';\n\n\t\tsettingsUrl = mw.Title.newFromText( rawTitle )\n\t\t\t.getUrl();\n\t}\n\n\treturn {\n\t\tsettingsUrl,\n\t\tshowSettings,\n\t\tpreviewDwell: actions.previewDwell,\n\t\tpreviewAbandon: actions.abandon,\n\t\tpreviewShow: actions.previewShow,\n\t\tclick: actions.linkClick\n\t};\n}\n","/**\n * @module templateUtil\n */\n\n/**\n * @param {string} str\n * @return {string} The string with any HTML entities escaped.\n */\nexport function escapeHTML( str ) {\n\treturn mw.html.escape( str );\n}\n\nconst templates = {};\n/**\n * @param {string} html markup of the template\n * @return {Element} a cloned root element of the template\n */\nexport function createNodeFromTemplate( html ) {\n\tif ( !templates[ html ] ) {\n\t\t// TODO: use <template> element when IE11 dies\n\t\tconst div = document.createElement( 'div' );\n\t\tdiv.innerHTML = html;\n\t\ttemplates[ html ] = div.firstElementChild;\n\t}\n\n\treturn templates[ html ].cloneNode( true );\n}\n","/**\n * @module settingsDialog\n */\n\nimport { escapeHTML } from '../templateUtil';\n\n/**\n * @typedef {Object} SettingsModel\n * @property {string} heading\n * @property {string} closeLabel\n * @property {string} saveLabel\n * @property {string} helpText\n * @property {string} okLabel\n * @property {SettingsChoiceModel[]} [choices]\n *\n * @global\n */\n\n/**\n * @typedef {Object} SettingsChoiceModel\n * @property {string} id Portion of the elements' IDs and value of the input.\n * @property {string} name\n * @property {string} [description]\n * @property {boolean} [isChecked] Whether the setting is checked.\n *\n * @global\n */\n\n/**\n * @param {SettingsChoiceModel[]} [choices]\n * @return {SettingsChoiceModel}\n */\nfunction escapeChoices( choices = [] ) {\n\treturn choices.map(\n\t\t( { id, name, description, isChecked } ) =>\n\t\t\t( {\n\t\t\t\tid: escapeHTML( id ),\n\t\t\t\tname: escapeHTML( name ),\n\t\t\t\tdescription: description ? escapeHTML( description ) : '',\n\t\t\t\tisChecked\n\t\t\t} )\n\t);\n}\n\n/**\n * @param {SettingsModel} model\n * @return {Element}\n */\nexport function renderSettingsDialog( model ) {\n\tconst heading = escapeHTML( model.heading ),\n\t\tsaveLabel = escapeHTML( model.saveLabel ),\n\t\tcloseLabel = escapeHTML( model.closeLabel ),\n\t\thelpText = escapeHTML( model.helpText ),\n\t\tokLabel = escapeHTML( model.okLabel ),\n\t\tchoices = escapeChoices( model.choices );\n\tconst node = document.createElement( 'div' );\n\tnode.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 mw-ui-icon-popups-close close'></span>\n\t\t\t\t\t\t<span>${closeLabel}</span>\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t\t<h1>${heading}</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'>${saveLabel}</button>\n\t\t\t\t\t<button class='okay cdx-button cdx-button--weight-primary cdx-button--action-progressive' style='display:none;'>${okLabel}</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${choices.map( ( { id, name, description, isChecked } ) => `\n\t\t\t\t\t<p class=\"mw-ui-checkbox\">\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\t${isChecked ? 'checked' : ''}\n\t\t\t\t\t\t\tvalue='${id}'\n\t\t\t\t\t\t\ttype='checkbox'\n\t\t\t\t\t\t\tid='mwe-popups-settings-${id}'>\n\t\t\t\t\t\t<label for='mwe-popups-settings-${id}'>\n\t\t\t\t\t\t\t<span>${name}</span>\n\t\t\t\t\t\t\t${description}\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 mw-ui-icon-footer\"></div>\n\t\t\t\t<p>${helpText}</p>\n\t\t\t</div>\n\t\t</section>\n\t`.trim();\n\treturn node.querySelector( 'section' );\n}\n","/**\n * @module settingsDialogRenderer\n */\n\nimport { createSettingsDialog } from './settingsDialog';\n\n/**\n * Creates a render function that will create the settings dialog and return\n * a set of methods to operate on it\n *\n * @param {boolean} referencePreviewsAvaliable\n * @return {Function} render function\n */\nexport default function createSettingsDialogRenderer( referencePreviewsAvaliable ) {\n\t/**\n\t * Cached settings dialog\n\t *\n\t * @type {HTMLElement}\n\t */\n\tlet dialog,\n\t\t/**\n\t\t * Cached settings overlay\n\t\t *\n\t\t * @type {HTMLElement}\n\t\t */\n\t\toverlay;\n\n\t/**\n\t * Renders the relevant form and labels in the settings dialog\n\t *\n\t * @param {Object} boundActions\n\t * @return {Object} object with methods to affect the rendered UI\n\t */\n\treturn ( boundActions ) => {\n\t\tif ( !dialog ) {\n\t\t\tdialog = createSettingsDialog( referencePreviewsAvaliable );\n\t\t\toverlay = document.createElement( 'div' );\n\t\t\toverlay.classList.add( 'mwe-popups-overlay' );\n\n\t\t\t// Setup event bindings\n\n\t\t\tdialog.querySelector( '.save' ).addEventListener( 'click', () => {\n\t\t\t\tconst enabled = {};\n\t\t\t\tArray.prototype.forEach.call( dialog.querySelectorAll( 'input' ), ( el ) => {\n\t\t\t\t\tenabled[ el.value ] = el.matches( ':checked' );\n\t\t\t\t} );\n\t\t\t\tboundActions.saveSettings( enabled );\n\t\t\t} );\n\t\t\tdialog.querySelector( '.close' ).addEventListener( 'click', boundActions.hideSettings );\n\t\t\tdialog.querySelector( '.okay' ).addEventListener( 'click', boundActions.hideSettings );\n\t\t}\n\n\t\treturn {\n\t\t\t/**\n\t\t\t * Append the dialog and overlay to a DOM element\n\t\t\t *\n\t\t\t * @param {HTMLElement} el\n\t\t\t */\n\t\t\tappendTo( el ) {\n\t\t\t\tel.appendChild( overlay );\n\t\t\t\toverlay.appendChild( dialog );\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Show the settings element and position it correctly\n\t\t\t */\n\t\t\tshow() {\n\t\t\t\toverlay.style.display = '';\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Hide the settings dialog.\n\t\t\t */\n\t\t\thide() {\n\t\t\t\toverlay.style.display = 'none';\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Toggle the help dialog on or off\n\t\t\t *\n\t\t\t * @param {boolean} visible if you want to show or hide the help dialog\n\t\t\t */\n\t\t\ttoggleHelp( visible ) {\n\t\t\t\ttoggleHelp( dialog, visible );\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Update the form depending on the enabled flag\n\t\t\t *\n\t\t\t * @param {Object} enabled Mapping preview type identifiers to boolean flags\n\t\t\t */\n\t\t\tsetEnabled( enabled ) {\n\t\t\t\tObject.keys( enabled ).forEach( ( type ) => {\n\t\t\t\t\tconst node = dialog.querySelector( `#mwe-popups-settings-${type}` );\n\t\t\t\t\tif ( node ) {\n\t\t\t\t\t\tnode.checked = enabled[ type ];\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t}\n\t\t};\n\t};\n}\n\n/**\n * @param {NodeList} nodes\n */\nfunction hideAll( nodes ) {\n\tArray.prototype.forEach.call( nodes, ( node ) => {\n\t\tnode.style.display = 'none';\n\t} );\n}\n\n/**\n * @param {NodeList} nodes\n */\nfunction showAll( nodes ) {\n\tArray.prototype.forEach.call( nodes, ( node ) => {\n\t\tnode.style.display = '';\n\t} );\n}\n\n/**\n * Toggles the visibility between a form and the help\n *\n * @param {HTMLElement} dialog element that contains form and help\n * @param {boolean} visible if the help should be visible, or the form\n */\nexport function toggleHelp( dialog, visible ) {\n\tconst\n\t\tformSelectors = 'main, .save, .close',\n\t\thelpSelectors = '.mwe-popups-settings-help, .okay';\n\n\tif ( visible ) {\n\t\thideAll( dialog.querySelectorAll( formSelectors ) );\n\t\tshowAll( dialog.querySelectorAll( helpSelectors ) );\n\t} else {\n\t\tshowAll( dialog.querySelectorAll( formSelectors ) );\n\t\thideAll( dialog.querySelectorAll( helpSelectors ) );\n\t}\n}\n","/**\n * @module settingsDialog\n */\n\nimport { renderSettingsDialog } from './templates/settingsDialog/settingsDialog';\nimport { previewTypes } from '../preview/model';\n\n/**\n * Create the settings dialog shown to anonymous users.\n *\n * @param {boolean} referencePreviewsAvaliable\n * @return {HTMLElement} settings dialog\n */\nexport function createSettingsDialog( referencePreviewsAvaliable ) {\n\tconst choices = [\n\t\t{\n\t\t\tid: previewTypes.TYPE_PAGE,\n\t\t\tname: mw.msg( 'popups-settings-option-page' ),\n\t\t\tdescription: mw.msg( 'popups-settings-option-page-description' )\n\t\t},\n\t\t{\n\t\t\tid: previewTypes.TYPE_REFERENCE,\n\t\t\tname: mw.msg( 'popups-settings-option-reference' ),\n\t\t\tdescription: mw.msg( 'popups-settings-option-reference-description' )\n\t\t}\n\t];\n\n\t// TODO: Remove when not in Beta any more\n\tif ( !referencePreviewsAvaliable ) {\n\t\t// Anonymous users can't access reference previews as long as they are in beta\n\t\tchoices.splice( 1, 1 );\n\t}\n\n\treturn renderSettingsDialog( {\n\t\theading: mw.msg( 'popups-settings-title' ),\n\t\tcloseLabel: mw.msg( 'popups-settings-cancel' ),\n\t\tsaveLabel: mw.msg( 'popups-settings-save' ),\n\t\thelpText: mw.msg( 'popups-settings-help' ),\n\t\tokLabel: mw.msg( 'popups-settings-help-ok' ),\n\t\tchoices\n\t} );\n}\n","/**\n * @module changeListener\n */\n\n/**\n * @typedef {Function} ext.popups.ChangeListener\n * @param {Object} oldState The previous state\n * @param {Object} newState The current state\n */\n\n/**\n * Registers a change listener, which is bound to the\n * [store](http://redux.js.org/docs/api/Store.html).\n *\n * A change listener is a function that is only invoked when the state in the\n * [store](http://redux.js.org/docs/api/Store.html) changes. N.B. that there\n * may not be a 1:1 correspondence with actions being dispatched to the store\n * and the state in the store changing.\n *\n * See [Store#subscribe](http://redux.js.org/docs/api/Store.html#subscribe)\n * for more information about what change listeners may and may not do.\n *\n * @param {Redux.Store} store\n * @param {ext.popups.ChangeListener} callback\n * @return {void}\n */\nexport default function registerChangeListener( store, callback ) {\n\t// This function is based on the example in [the documentation for\n\t// Store#subscribe](http://redux.js.org/docs/api/Store.html#subscribe),\n\t// which was written by Dan Abramov.\n\n\tlet previousState;\n\n\tstore.subscribe( () => {\n\t\tconst state = store.getState();\n\n\t\tif ( previousState !== state ) {\n\t\t\tcallback( previousState, state );\n\t\t\tpreviousState = state;\n\t\t}\n\t} );\n}\n","/**\n * @module isPagePreviewsEnabled\n */\nconst canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );\n\n/**\n * Given the global state of the application, creates a function that gets\n * whether or not the user should have Page Previews enabled.\n *\n * Page Previews is disabled when the Navigation Popups gadget is enabled.\n *\n * If Page Previews is configured as a user preference, then the user must\n * either be logged in and have enabled the preference or be logged out and have\n * not disabled previews via the settings modal.\n *\n * @param {mw.user} user The `mw.user` singleton instance\n * @param {Object} userSettings An object returned by `userSettings.js`\n * @param {mw.Map} config\n *\n * @return {boolean|null} Null when there is no way the popup type can be enabled at run-time.\n */\nexport default function isPagePreviewsEnabled( user, userSettings, config ) {\n\t// T160081: Unavailable when in conflict with the Navigation Popups gadgets.\n\tif ( config.get( 'wgPopupsConflictsWithNavPopupGadget' ) ) {\n\t\treturn null;\n\t}\n\n\t// For anonymous users, and for IP masked usersm the code loads always,\n\t// but the feature can be toggled at run-time via local storage.\n\tif ( !canSaveToUserPreferences( user ) ) {\n\t\treturn userSettings.isPagePreviewsEnabled();\n\t}\n\n\t// Registered users never can enable popup types at run-time.\n\treturn mw.user.options.get( 'popups' ) === '1' ? true : null;\n}\n","/**\n * @module title\n */\n\n/**\n * Fast, native check if we are parsing a self-link, with the only difference beeing the hash.\n *\n * @param {HTMLAnchorElement} el\n * @return {boolean}\n */\nfunction isOwnPageAnchorLink( el ) {\n\treturn el.hash &&\n\t\t// Note: The protocol is ignored for the sake of simplicity.\n\t\t// Can't compare username and password because they aren't readable from `location`.\n\t\tel.host === location.host &&\n\t\tel.pathname === location.pathname &&\n\t\tel.search === location.search;\n}\n\n/**\n * Gets the title of a local page from an href given some configuration.\n *\n * @param {string} href\n * @param {mw.Map} config\n * @return {string|undefined}\n */\nexport function getTitle( href, config ) {\n\t// Skip every URI that mw.Uri cannot parse\n\tlet linkHref;\n\ttry {\n\t\tlinkHref = new mw.Uri( href );\n\t} catch ( e ) {\n\t\treturn undefined;\n\t}\n\n\t// External links\n\tif ( linkHref.host !== location.hostname ) {\n\t\treturn undefined;\n\t}\n\n\tconst queryLength = Object.keys( linkHref.query ).length;\n\tlet title;\n\n\t// No query params (pretty URL)\n\tif ( !queryLength ) {\n\t\tconst pattern = mw.util.escapeRegExp( config.get( 'wgArticlePath' ) ).replace( '\\\\$1', '([^?#]+)' ),\n\t\t\tmatches = new RegExp( pattern ).exec( linkHref.path );\n\n\t\t// We can't be sure decodeURIComponent() is able to parse every possible match\n\t\ttry {\n\t\t\ttitle = matches && decodeURIComponent( matches[ 1 ] );\n\t\t} catch ( e ) {\n\t\t\t// Will return undefined below\n\t\t}\n\t} else if ( queryLength === 1 && 'title' in linkHref.query ) {\n\t\t// URL is not pretty, but only has a `title` parameter\n\t\ttitle = linkHref.query.title;\n\t}\n\n\treturn title ? `${title}${linkHref.fragment ? `#${linkHref.fragment}` : ''}` : undefined;\n}\n\n/**\n * Given a page title it will return the mediawiki.Title if it is an eligible\n * link for showing page previews, null otherwise\n *\n * @param {string|undefined} title page title to check if it should show preview\n * @param {number[]} contentNamespaces contentNamespaces as specified in\n * wgContentNamespaces\n * @return {mw.Title|null}\n */\nexport function isValid( title, contentNamespaces ) {\n\tif ( !title ) {\n\t\treturn null;\n\t}\n\n\t// Is title in a content namespace?\n\tconst mwTitle = mw.Title.newFromText( title );\n\tif ( mwTitle && contentNamespaces.indexOf( mwTitle.namespace ) >= 0 ) {\n\t\treturn mwTitle;\n\t}\n\n\treturn null;\n}\n\n/**\n * Return an mw.Title from an HTMLAnchorElement if valid for page previews. Convenience\n * method\n *\n * @param {HTMLAnchorElement} el\n * @param {mw.Map} config\n * @return {mw.Title|null}\n */\nexport function fromElement( el, config ) {\n\tif ( el.dataset.title ) {\n\t\treturn mw.Title.newFromText( el.dataset.title );\n\t}\n\tif ( isOwnPageAnchorLink( el ) ) {\n\t\t// No need to check the namespace. A self-link can't point to different one.\n\t\ttry {\n\t\t\treturn mw.Title.newFromText( config.get( 'wgPageName' ) + decodeURIComponent( el.hash ) );\n\t\t} catch ( e ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn isValid(\n\t\tgetTitle( el.href, config ),\n\t\tconfig.get( 'wgContentNamespaces' )\n\t);\n}\n","/**\n * @module wait\n */\n\n/**\n * Sugar around `window.setTimeout`.\n *\n * @example\n * import wait from './wait';\n *\n * wait( 150 )\n * .then( () => {\n * // Continue processing...\n * } );\n *\n * @param {number} delay The number of milliseconds to wait\n * @return {Promise}\n */\nexport default function wait( delay ) {\n\treturn new Promise( ( resolve ) => {\n\t\tsetTimeout( () => {\n\t\t\tresolve();\n\t\t}, delay );\n\t} );\n}\n","/**\n * @module thumbnail\n */\n\nimport constants from '../constants';\n\nexport const SIZES = {\n\tportraitImage: {\n\t\th: 250, // Exact height\n\t\tw: 203 // Max width\n\t},\n\tlandscapeImage: {\n\t\th: 200, // Max height\n\t\tw: 320 // Exact Width\n\t}\n};\n\n/**\n * @typedef {Object} ext.popups.Thumbnail\n * @property {JQuery} el\n * @property {boolean} isTall Whether or not the thumbnail is portrait\n * @property {number} width\n * @property {number} height\n * @property {boolean} isNarrow whether the thumbnail is portrait and also\n * thinner than the default portrait thumbnail width\n * (as defined in SIZES.portraitImage.w)\n * @property {number} offset in pixels between the thumbnail width and the\n * standard portrait thumbnail width (as defined in SIZES.portraitImage.w)\n */\n\n/**\n * Creates a thumbnail from the representation of a thumbnail returned by the\n * PageImages MediaWiki API query module.\n *\n * If there's no thumbnail, the thumbnail is too small, or the thumbnail's URL\n * contains characters that could be used to perform an\n * [XSS attack via CSS](https://www.owasp.org/index.php/Testing_for_CSS_Injection_(OTG-CLIENT-005)),\n * then `null` is returned.\n *\n * Extracted from `mw.popups.renderer.article.createThumbnail`.\n *\n * @param {Object} rawThumbnail\n * @param {boolean} useCSSClipPath\n * @return {ext.popups.Thumbnail|null}\n */\nexport function createThumbnail( rawThumbnail, useCSSClipPath ) {\n\tconst devicePixelRatio = constants.BRACKETED_DEVICE_PIXEL_RATIO;\n\n\tif ( !rawThumbnail ) {\n\t\treturn null;\n\t}\n\n\tconst thumbWidth = rawThumbnail.width / devicePixelRatio;\n\tconst thumbHeight = rawThumbnail.height / devicePixelRatio;\n\t// For images less than 320 wide, try to display a 250 high vertical slice instead\n\tconst tall = rawThumbnail.height > rawThumbnail.width || thumbWidth < SIZES.landscapeImage.w;\n\n\tif (\n\t\t// Image too small for portrait display\n\t\t( tall && thumbHeight < SIZES.portraitImage.h &&\n\t\t\trawThumbnail.height < SIZES.portraitImage.h ) ||\n\t\t// These characters in URL that could inject CSS and thus JS\n\t\t(\n\t\t\trawThumbnail.source.indexOf( '\\\\' ) > -1 ||\n\t\t\trawThumbnail.source.indexOf( '\\'' ) > -1 ||\n\t\t\trawThumbnail.source.indexOf( '\"' ) > -1\n\t\t)\n\t) {\n\t\treturn null;\n\t}\n\n\tconst aspectRatio = thumbWidth / thumbHeight;\n\tconst isSquare = aspectRatio > 0.7 && aspectRatio < 1.3;\n\n\tlet x, y, width, height;\n\tif ( tall ) {\n\t\tx = ( thumbWidth > SIZES.portraitImage.w ) ?\n\t\t\t( ( thumbWidth - SIZES.portraitImage.w ) / -2 ) :\n\t\t\t( SIZES.portraitImage.w - thumbWidth );\n\t\ty = ( thumbHeight > SIZES.portraitImage.h ) ?\n\t\t\t( ( thumbHeight - SIZES.portraitImage.h ) / -2 ) : 0;\n\t\twidth = SIZES.portraitImage.w;\n\t\theight = SIZES.portraitImage.h;\n\n\t\t// Special handling for thin tall images\n\t\t// https://phabricator.wikimedia.org/T192928#4312088\n\t\tif ( thumbWidth < width ) {\n\t\t\tx = 0;\n\t\t\twidth = thumbWidth;\n\t\t}\n\t} else {\n\t\tx = 0;\n\t\ty = ( thumbHeight > SIZES.landscapeImage.h ) ?\n\t\t\t( ( thumbHeight - SIZES.landscapeImage.h ) / -2 ) : 0;\n\t\twidth = SIZES.landscapeImage.w;\n\t\theight = ( thumbHeight > SIZES.landscapeImage.h ) ?\n\t\t\tSIZES.landscapeImage.h : thumbHeight;\n\t}\n\n\tconst isNarrow = tall && thumbWidth < SIZES.portraitImage.w;\n\tconst el = useCSSClipPath ? createThumbnailImg( rawThumbnail.source ) : createThumbnailSVG(\n\t\ttall ? 'mwe-popups-is-tall' : 'mwe-popups-is-not-tall',\n\t\trawThumbnail.source,\n\t\tx,\n\t\ty,\n\t\tthumbWidth,\n\t\tthumbHeight,\n\t\twidth,\n\t\theight\n\t);\n\n\treturn {\n\t\tel,\n\t\tisTall: tall || isSquare,\n\t\tisNarrow,\n\t\toffset: isNarrow ? SIZES.portraitImage.w - thumbWidth : 0,\n\t\twidth: thumbWidth,\n\t\theight: thumbHeight\n\t};\n}\n\nfunction createThumbnailImg( url ) {\n\tconst img = document.createElement( 'img' );\n\timg.className = 'mwe-popups-thumbnail';\n\timg.src = url;\n\treturn img;\n}\n\n/**\n * Sets multiple attributes on a node.\n *\n * @param {HTMLElement} node\n * @param {Record<String, String>} attrs\n */\nconst addAttributes = ( node, attrs ) => {\n\tObject.keys( attrs ).forEach( ( key ) => {\n\t\tnode.setAttribute( key, attrs[ key ] );\n\t} );\n};\n\n/**\n * Creates the SVG image element that represents the thumbnail.\n *\n * This function is distinct from `createThumbnail` as it abstracts away some\n * browser issues that are uncovered when manipulating elements across\n * namespaces.\n *\n * @param {string} className\n * @param {string} url\n * @param {number} x\n * @param {number} y\n * @param {number} thumbnailWidth\n * @param {number} thumbnailHeight\n * @param {number} width\n * @param {number} height\n * @return {HTMLElement}\n */\n\nexport function createThumbnailSVG(\n\tclassName, url, x, y, thumbnailWidth, thumbnailHeight, width, height\n) {\n\tconst nsSvg = 'http://www.w3.org/2000/svg',\n\t\tnsXlink = 'http://www.w3.org/1999/xlink';\n\n\t// We want to visually separate the image from the summary\n\t// Given we use an SVG mask, we cannot rely on border to do this\n\t// and instead must insert a polyline element to visually separate\n\tconst line = document.createElementNS( nsSvg, 'polyline' );\n\tconst isTall = className.indexOf( 'not-tall' ) === -1;\n\tconst points = isTall ? [ 0, 0, 0, height ] :\n\t\t[ 0, height - 1, width, height - 1 ];\n\n\tline.setAttribute( 'stroke', 'rgba(0,0,0,0.1)' );\n\tline.setAttribute( 'points', points.join( ' ' ) );\n\tline.setAttribute( 'stroke-width', 1 );\n\n\tconst thumbnailSVGImage = document.createElementNS( nsSvg, 'image' );\n\tthumbnailSVGImage.setAttributeNS( nsXlink, 'href', url );\n\t// The following classes are used here:\n\t// * mwe-popups-is-not-tall\n\t// * mwe-popups-is-tall\n\tthumbnailSVGImage.classList.add( className );\n\taddAttributes(\n\t\tthumbnailSVGImage,\n\t\t{\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth: thumbnailWidth,\n\t\t\theight: thumbnailHeight\n\t\t}\n\t);\n\n\tconst thumbnail = document.createElementNS( nsSvg, 'svg' );\n\taddAttributes(\n\t\tthumbnail, {\n\t\t\txmlns: nsSvg,\n\t\t\twidth,\n\t\t\theight\n\t\t}\n\t);\n\tthumbnail.appendChild( thumbnailSVGImage );\n\tthumbnail.appendChild( line );\n\treturn thumbnail;\n}\n","/**\n * @module popup\n */\n\nimport { createNodeFromTemplate } from '../templateUtil';\n\nconst templateHTML = `\n\t<div class=\"mwe-popups\" aria-hidden></div>\n`;\n/**\n * @param {ext.popups.previewTypes} type\n * @param {Element} element The contents of the popup.\n * @return {Element}\n */\n\nexport function renderPopup( type, container ) {\n\tconst element = createNodeFromTemplate( templateHTML );\n\t// The following classes are used here:\n\t// * mwe-popups-type-reference\n\t// * mwe-popups-type-unknown\n\t// * mwe-popups-type-generic\n\t// * mwe-popups-type-disambiguation\n\telement.className = `mwe-popups mwe-popups-type-${type}`;\n\tcontainer.className = 'mwe-popups-container';\n\telement.appendChild( container );\n\treturn element;\n}\n","/**\n * @module preview\n */\n\nimport { renderPopup } from '../popup/popup';\nimport { createNodeFromTemplate, escapeHTML } from '../templateUtil';\n\nconst templateHTML = `\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`;\n\n/**\n * Render generic and disambiguation previews\n *\n * @param {ext.popups.PagePreviewModel} model\n * @param {string|null} message\n * @param {string} linkMsg\n * @return {JQuery}\n */\nexport function renderPreview(\n\tmodel, message, linkMsg\n) {\n\tconst popup = renderPopup( model.type, createNodeFromTemplate( templateHTML ) );\n\n\t// The following classes are used here:\n\t// * mw-icon-preview-unknown\n\t// * mw-icon-preview-generic\n\t// * mw-icon-preview-disambiguation\n\tpopup.querySelector( '.popups-icon' ).classList.add( `mw-ui-icon-preview-${model.type}` );\n\tpopup.querySelector( '.mwe-popups-extract' ).setAttribute( 'href', model.url );\n\tconst messageElement = popup.querySelector( '.mwe-popups-message' );\n\tif ( message ) {\n\t\tmessageElement.innerHTML = escapeHTML( message );\n\t} else {\n\t\tmessageElement.remove();\n\t}\n\tconst readLink = popup.querySelector( '.mwe-popups-read-link' );\n\treadLink.innerHTML = escapeHTML( linkMsg );\n\treadLink.setAttribute( 'href', model.url );\n\tconst title = popup.querySelector( '.mwe-popups-title' );\n\ttitle.innerHTML += escapeHTML( model.title );\n\treturn popup;\n}\n","let isTracking = false;\n\nexport const LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';\n\n/**\n * Run once the preview is initialized.\n */\nexport function initReferencePreviewsInstrumentation() {\n\tif ( mw.config.get( 'wgPopupsReferencePreviews' ) &&\n\t\tnavigator.sendBeacon &&\n\t\tmw.config.get( 'wgIsArticle' ) &&\n\t\t!isTracking\n\t) {\n\t\tisTracking = true;\n\t\tmw.track( LOGGING_SCHEMA, { action: 'pageview' } );\n\t}\n}\n\nexport function isTrackingEnabled() {\n\treturn isTracking;\n}\n","/**\n * @module referencePreview\n */\nimport { isTrackingEnabled, LOGGING_SCHEMA } from '../../../instrumentation/referencePreviews';\nimport { renderPopup } from '../popup/popup';\nimport { createNodeFromTemplate, escapeHTML } from '../templateUtil';\n\nconst templateHTML = `\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 <div class=\"mw-parser-output\"></div>\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>`;\n\n/**\n * @param {HTMLElement} node\n * @param {HTMLElement|string} htmlOrOtherNode\n */\nconst replaceWith = ( node, htmlOrOtherNode ) => {\n\tif ( typeof htmlOrOtherNode === 'string' ) {\n\t\tnode.insertAdjacentHTML( 'afterend', htmlOrOtherNode );\n\t} else {\n\t\tnode.parentNode.appendChild( htmlOrOtherNode );\n\t}\n\tnode.remove();\n};\n\n/**\n * @param {ext.popups.ReferencePreviewModel} model\n * @return {JQuery}\n */\nexport function renderReferencePreview(\n\tmodel\n) {\n\tconst type = model.referenceType || 'generic';\n\t// The following messages are used here:\n\t// * popups-refpreview-book\n\t// * popups-refpreview-journal\n\t// * popups-refpreview-news\n\t// * popups-refpreview-note\n\t// * popups-refpreview-web\n\tlet titleMsg = mw.message( `popups-refpreview-${type}` );\n\tif ( !titleMsg.exists() ) {\n\t\ttitleMsg = mw.message( 'popups-refpreview-reference' );\n\t}\n\n\tconst el = renderPopup( model.type, createNodeFromTemplate( templateHTML ) );\n\treplaceWith( el.querySelector( '.mwe-popups-title-placeholder' ), escapeHTML( titleMsg.text() ) );\n\t// The following classes are used here:\n\t// * mw-ui-icon-reference-generic\n\t// * mw-ui-icon-reference-book\n\t// * mw-ui-icon-reference-journal\n\t// * mw-ui-icon-reference-news\n\t// * mw-ui-icon-reference-note\n\t// * mw-ui-icon-reference-web\n\tel.querySelector( '.mwe-popups-title .popups-icon' )\n\t\t.classList.add( `mw-ui-icon-reference-${type}` );\n\tel.querySelector( '.mw-parser-output' )\n\t\t.innerHTML = model.extract;\n\n\t// Make sure to not destroy existing targets, if any\n\tArray.prototype.forEach.call(\n\t\tel.querySelectorAll( '.mwe-popups-extract a[href][class~=\"external\"]:not([target])' ),\n\t\t( a ) => {\n\t\t\ta.target = '_blank';\n\t\t\t// Don't let the external site access and possibly manipulate window.opener.location\n\t\t\ta.rel = `${a.rel ? `${a.rel} ` : ''}noopener`;\n\t\t}\n\t);\n\n\t// We assume elements that benefit from being collapsible are to large for the popup\n\tArray.prototype.forEach.call( el.querySelectorAll( '.mw-collapsible' ), ( node ) => {\n\t\tconst otherNode = document.createElement( 'div' );\n\t\totherNode.classList.add( 'mwe-collapsible-placeholder' );\n\t\tconst icon = document.createElement( 'span' );\n\t\ticon.classList.add( 'popups-icon', 'mw-ui-icon-infoFilled' );\n\t\tconst label = document.createElement( 'span' );\n\t\tlabel.classList.add( 'mwe-collapsible-placeholder-label' );\n\t\tlabel.textContent = mw.msg( 'popups-refpreview-collapsible-placeholder' );\n\t\totherNode.appendChild( icon );\n\t\totherNode.appendChild( label );\n\t\treplaceWith( node, otherNode );\n\t} );\n\n\t// Undo remaining effects from the jquery.tablesorter.js plugin\n\tconst undoHeaderSort = ( headerSort ) => {\n\t\theaderSort.classList.remove( 'headerSort' );\n\t\theaderSort.removeAttribute( 'tabindex' );\n\t\theaderSort.removeAttribute( 'title' );\n\t};\n\tArray.prototype.forEach.call( el.querySelectorAll( 'table.sortable' ), ( node ) => {\n\t\tnode.classList.remove( 'sortable', 'jquery-tablesorter' );\n\t\tArray.prototype.forEach.call( node.querySelectorAll( '.headerSort' ), undoHeaderSort );\n\t} );\n\n\t// TODO: Remove when not in Beta any more\n\tif ( !mw.config.get( 'wgPopupsReferencePreviewsBetaFeature' ) ) {\n\t\t// TODO: Do not remove this but move it up into the templateHTML constant!\n\t\tconst settingsButton = document.createElement( 'a' );\n\t\tsettingsButton.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' );\n\t\tconst settingsIcon = document.createElement( 'span' );\n\t\tsettingsIcon.classList.add( 'popups-icon', 'popups-icon--size-small', 'mw-ui-icon-settings' );\n\t\tconst settingsButtonLabel = document.createElement( 'span' );\n\t\tsettingsButtonLabel.textContent = mw.msg( 'popups-settings-icon-gear-title' );\n\t\tsettingsButton.append( settingsIcon );\n\t\tsettingsButton.append( settingsButtonLabel );\n\t\tel.querySelector( '.mwe-popups-settings' ).appendChild( settingsButton );\n\t} else {\n\t\t// Change the styling when there is no content in the footer (to prevent empty space)\n\t\tel.querySelector( '.mwe-popups-container' ).classList.add( 'footer-empty' );\n\t}\n\n\tif ( isTrackingEnabled() ) {\n\t\tel.querySelector( '.mw-parser-output' ).addEventListener( 'click', ( ev ) => {\n\t\t\tif ( !ev.target.matches( 'a' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmw.track( LOGGING_SCHEMA, {\n\t\t\t\taction: 'clickedReferencePreviewsContentLink'\n\t\t\t} );\n\t\t} );\n\t}\n\n\tel.querySelector( '.mwe-popups-scroll' ).addEventListener( 'scroll', function ( e ) {\n\t\tconst element = e.target,\n\t\t\t// We are dealing with floating point numbers here when the page is zoomed!\n\t\t\tscrolledToBottom = element.scrollTop >= element.scrollHeight - element.clientHeight - 1;\n\n\t\tif ( isTrackingEnabled() ) {\n\t\t\tif ( !element.isOpenRecorded ) {\n\t\t\t\tmw.track( LOGGING_SCHEMA, {\n\t\t\t\t\taction: 'poppedOpen',\n\t\t\t\t\tscrollbarsPresent: element.scrollHeight > element.clientHeight\n\t\t\t\t} );\n\t\t\t\telement.isOpenRecorded = true;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\telement.scrollTop > 0 &&\n\t\t\t\t!element.isScrollRecorded\n\t\t\t) {\n\t\t\t\tmw.track( LOGGING_SCHEMA, {\n\t\t\t\t\taction: 'scrolled'\n\t\t\t\t} );\n\t\t\t\telement.isScrollRecorded = true;\n\t\t\t}\n\t\t}\n\n\t\tif ( !scrolledToBottom && element.isScrolling ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst extract = element.parentNode,\n\t\t\thasHorizontalScroll = element.scrollWidth > element.clientWidth,\n\t\t\tscrollbarHeight = element.offsetHeight - element.clientHeight,\n\t\t\thasVerticalScroll = element.scrollHeight > element.clientHeight,\n\t\t\tscrollbarWidth = element.offsetWidth - element.clientWidth;\n\t\tconst fade = extract.querySelector( '.mwe-popups-fade' );\n\t\tfade.style.bottom = hasHorizontalScroll ? `${scrollbarHeight}px` : 0;\n\t\tfade.style.right = hasVerticalScroll ? `${scrollbarWidth}px` : 0;\n\n\t\telement.isScrolling = !scrolledToBottom;\n\t\textract.classList.toggle( 'mwe-popups-fade-out', element.isScrolling );\n\t} );\n\n\treturn el;\n}\n","/**\n * @module pagePreview\n */\n\nimport { renderPopup } from '../popup/popup';\nimport { escapeHTML, createNodeFromTemplate } from '../templateUtil';\n\nconst defaultExtractWidth = 215;\nconst templateHTML = `\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 mw-ui-icon-settings\"></span>\n\t\t\t<span class=\"mwe-popups-settings-button-label\"></span>\n </a>\n </footer>\n</div>\n\t`;\n\n/**\n * @param {ext.popups.PagePreviewModel} model\n * @param {ext.popups.Thumbnail|null} thumbnail\n * @param {boolean} withCSSClipPath\n * @param {string} linkTitle\n * @return {Element}\n */\nexport function renderPagePreview(\n\tmodel, thumbnail, withCSSClipPath, linkTitle\n) {\n\tconst el = renderPopup( model.type, createNodeFromTemplate( templateHTML ) );\n\n\tconst linkDiscreet = el.querySelector( '.mwe-popups-discreet' );\n\tconst extract = el.querySelector( '.mwe-popups-extract' );\n\textract.setAttribute( 'href', model.url );\n\tlinkDiscreet.setAttribute( 'href', model.url );\n\textract.setAttribute( 'dir', model.languageDirection );\n\textract.setAttribute( 'lang', model.languageCode );\n\n\tel.querySelector( '.mwe-popups-settings-button' )\n\t\t.setAttribute( 'title', linkTitle );\n\n\t// Set label on settings icon button\n\tconst labelText = escapeHTML( mw.msg( 'popups-settings-icon-gear-title' ) );\n\tconst label = el.querySelector( '.mwe-popups-settings-button-label' );\n\tlabel.textContent = labelText;\n\n\tif ( thumbnail ) {\n\t\tel.querySelector( '.mwe-popups-discreet' ).appendChild( thumbnail.el );\n\t} else {\n\t\tlinkDiscreet.remove();\n\t}\n\n\tif ( model.extract ) {\n\t\tif ( typeof model.extract === 'string' ) {\n\t\t\textract.innerHTML = model.extract;\n\t\t} else {\n\t\t\textract.append( ...model.extract );\n\t\t}\n\t\tconst extractWidth = getExtractWidth( thumbnail );\n\t\tif ( !withCSSClipPath ) {\n\t\t\textract.style.width = extractWidth;\n\t\t\tel.querySelector( 'footer' ).style.width = extractWidth;\n\t\t}\n\t}\n\n\treturn el;\n}\n\nexport { defaultExtractWidth }; // for testing\n\n/**\n * Calculates width of extract based on the associated thumbnail\n *\n * @param {ext.popups.Thumbnail|null} thumbnail model\n * @return {string} representing the css width attribute to be\n * used for the extract\n */\nexport function getExtractWidth( thumbnail ) {\n\treturn thumbnail && thumbnail.isNarrow ? `${defaultExtractWidth + thumbnail.offset}px` : '';\n}\n","/**\n * @module renderer\n */\n\nimport wait from '../wait';\nimport pointerMaskSVG from './pointer-mask.svg';\nimport { SIZES, createThumbnail } from './thumbnail';\nimport { renderPreview } from './templates/preview/preview';\nimport { renderReferencePreview } from './templates/referencePreview/referencePreview';\nimport { renderPagePreview } from './templates/pagePreview/pagePreview';\n\nconst landscapePopupWidth = 450,\n\tportraitPopupWidth = 320,\n\tpointerSize = 8, // Height of the pointer.\n\tmaxLinkWidthForCenteredPointer = 28; // Link with roughly < 4 chars.\n\nexport { pointerSize, landscapePopupWidth, portraitPopupWidth }; // for use in storybook\n\n/**\n * @typedef {Object} ext.popups.Measures\n * @property {number} pageX\n * @property {number} pageY\n * @property {number} clientY\n * @property {ClientRectList} clientRects list of rectangles defined by\n * four edges\n * @property {Object} offset\n * @property {number} width\n * @property {number} height\n * @property {number} scrollTop\n * @property {number} windowWidth\n * @property {number} windowHeight\n */\n\n/**\n * Extracted from `mw.popups.createSVGMasks`. This is just an SVG mask to point\n * or \"point\" at the link that's hovered over. The \"pointer\" appears to be cut\n * out of the image itself:\n * _______ link\n * | | _/\\_____ _/\\____ <-- Pointer pointing at link\n * | :-] | + |xxxxxxx = | :-] |\n * |_______| |xxxxxxx |_______|\n * :\n * Thumbnail Pointer Page preview\n * image clip-path bubble w/ pointer\n *\n * SVG masks are used in place of CSS masks for browser support issues (see\n * https://caniuse.com/#feat=css-masks).\n *\n * @private\n * @param {Object} container DOM object to which pointer masks are appended\n * @return {void}\n */\nexport function createPointerMasks( container ) {\n\tconst node = document.createElement( 'div' );\n\tnode.setAttribute( 'id', 'mwe-popups-svg' );\n\tnode.innerHTML = pointerMaskSVG;\n\tcontainer.appendChild( node );\n}\n\n/**\n * Initializes the renderer.\n *\n * @return {void}\n */\nexport function init() {\n\tif ( !supportsCSSClipPath() ) {\n\t\tcreatePointerMasks( document.body );\n\t}\n}\n\n/**\n * The model of how a view is rendered, which is constructed from a response\n * from the gateway.\n *\n * TODO: Rename `isTall` to `isPortrait`.\n *\n * @typedef {Object} ext.popups.Preview\n * @property {JQuery} el\n * @property {boolean} hasThumbnail\n * @property {Object} thumbnail\n * @property {boolean} isTall Sugar around\n * `preview.hasThumbnail && thumbnail.isTall`\n */\n\n/**\n * Renders a preview given data from the {@link gateway Gateway}.\n * The preview is rendered and added to the DOM but will remain hidden until\n * the `show` method is called.\n *\n * Previews are rendered at:\n *\n * # The position of the mouse when the user dwells on the link with their\n * mouse.\n * # The centermost point of the link when the user dwells on the link with\n * their keyboard or other assistive device.\n *\n * Since the content of the preview doesn't change but its position might, we\n * distinguish between \"rendering\" - generating HTML from a MediaWiki API\n * response - and \"showing/hiding\" - positioning the layout and changing its\n * orientation, if necessary.\n *\n * @param {ext.popups.PreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function render( model ) {\n\tconst preview = createPreviewWithType( model );\n\n\treturn {\n\t\t/**\n\t\t * Shows the preview given an event representing the user's interaction\n\t\t * with the active link, e.g. an instance of\n\t\t * [MouseEvent](https://developer.mozilla.org/en/docs/Web/API/MouseEvent).\n\t\t *\n\t\t * See `show` for more detail.\n\t\t *\n\t\t * @param {Event} event\n\t\t * @param {Object} boundActions The\n\t\t * [bound action creators](http://redux.js.org/docs/api/bindActionCreators.html)\n\t\t * that were (likely) created in [boot.js](./boot.js).\n\t\t * @param {string} token The unique token representing the link interaction\n\t\t * that resulted in showing the preview\n\t\t * @return {jQuery.Promise<void>}\n\t\t */\n\t\tshow( event, boundActions, token ) {\n\t\t\treturn show(\n\t\t\t\tpreview, event, event.target, boundActions, token,\n\t\t\t\tdocument.body, document.documentElement.getAttribute( 'dir' )\n\t\t\t);\n\t\t},\n\n\t\t/**\n\t\t * Hides the preview.\n\t\t *\n\t\t * See `hide` for more detail.\n\t\t *\n\t\t * @return {jQuery.Promise<void>}\n\t\t */\n\t\thide() {\n\t\t\treturn hide( preview );\n\t\t}\n\t};\n}\n\nlet renderers = {};\n\n/**\n * @param {string} type\n * @param {function( ext.popups.PreviewModel ): ext.popups.Preview} [previewFn]\n *\n */\nexport function registerPreviewUI( type, previewFn ) {\n\trenderers[ type ] = previewFn || createPagePreview;\n}\n\n/**\n * Creates an instance of a Preview based on\n * the type property of the PreviewModel\n *\n * @param {ext.popups.PreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createPreviewWithType( model ) {\n\tconst fn = renderers[ model.type ] || createEmptyPreview;\n\treturn fn( model );\n}\n\nfunction supportsCSSClipPath() {\n\treturn window.CSS &&\n\t\ttypeof CSS.supports === 'function' &&\n\t\tCSS.supports( 'clip-path', 'polygon(1px 1px)' );\n\t/* eslint-enable compat/compat */\n}\n\n/**\n * Creates an instance of the DTO backing a preview.\n *\n * @param {ext.popups.PagePreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createPagePreview( model ) {\n\tconst thumbnail = createThumbnail( model.thumbnail, supportsCSSClipPath() ),\n\t\thasThumbnail = thumbnail !== null,\n\t\twithCSSClipPath = supportsCSSClipPath(),\n\t\tlinkTitle = mw.msg( 'popups-settings-icon-gear-title' );\n\n\treturn {\n\t\tel: renderPagePreview( model, thumbnail, withCSSClipPath, linkTitle ),\n\t\thasThumbnail,\n\t\tthumbnail,\n\t\tisTall: hasThumbnail && thumbnail.isTall\n\t};\n}\n\n/**\n * Creates an instance of the DTO backing a preview. In this case the DTO\n * represents a generic preview, which covers the following scenarios:\n *\n * * The page doesn't exist, i.e. the user hovered over a redlink or a\n * redirect to a page that doesn't exist.\n * * The page doesn't have a viable extract.\n *\n * @param {ext.popups.PagePreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createEmptyPreview( model ) {\n\tmodel.title = mw.msg( 'popups-preview-no-preview' );\n\tconst linkMsg = mw.msg( 'popups-preview-footer-read' );\n\n\treturn {\n\t\tel: renderPreview( model, null, linkMsg ),\n\t\thasThumbnail: false,\n\t\tisTall: false\n\t};\n}\n\n/**\n * Creates an instance of the disambiguation preview.\n *\n * @param {ext.popups.PagePreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createDisambiguationPreview( model ) {\n\tconst extractMsg = mw.msg( 'popups-preview-disambiguation' );\n\tconst linkMsg = mw.msg( 'popups-preview-disambiguation-link' );\n\n\treturn {\n\t\tel: renderPreview( model, extractMsg, linkMsg ),\n\t\thasThumbnail: false,\n\t\tisTall: false\n\t};\n}\n\n/**\n * @param {ext.popups.ReferencePreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createReferencePreview( model ) {\n\treturn {\n\t\tel: renderReferencePreview( model ),\n\t\thasThumbnail: false,\n\t\tisTall: false\n\t};\n}\n\n/**\n * Shows the preview.\n *\n * Extracted from `mw.popups.render.openPopup`.\n *\n * TODO: From the perspective of the client, there's no need to distinguish\n * between rendering and showing a preview. Merge #render and Preview#show.\n *\n * @param {ext.popups.Preview} preview\n * @param {ext.popups.Measures} measures\n * @param {HTMLElement} _link event target (unused)\n * @param {ext.popups.PreviewBehavior} behavior\n * @param {string} token\n * @param {Object} container DOM object to which pointer masks are appended\n * @param {string} dir 'ltr' if left-to-right, 'rtl' if right-to-left.\n * @return {jQuery.Promise<void>} A promise that resolves when the promise has\n * faded in.\n */\nexport function show(\n\tpreview, measures, _link, behavior, token, container, dir\n) {\n\tconst layout = createLayout(\n\t\tpreview.isTall,\n\t\tmeasures,\n\t\tpointerSize,\n\t\tdir\n\t);\n\n\tcontainer.appendChild( preview.el );\n\n\tlayoutPreview(\n\t\tpreview, layout, getClasses( preview, layout ),\n\t\tSIZES.landscapeImage.h, pointerSize, measures.windowHeight\n\t);\n\n\tpreview.el.style.display = 'block';\n\n\t// Trigger fading effect for reference previews after the popup has been rendered\n\tif ( preview.el.classList.contains( 'mwe-popups-type-reference' ) ) {\n\t\tpreview.el.querySelector( '.mwe-popups-scroll' ).dispatchEvent( new Event( 'scroll' ) );\n\t}\n\n\treturn wait( 200 )\n\t\t.then( () => {\n\t\t\tbindBehavior( preview, behavior );\n\t\t\tbehavior.previewShow( token );\n\t\t} );\n}\n\n/**\n * Binds the behavior to the interactive elements of the preview.\n *\n * @param {ext.popups.Preview} preview\n * @param {ext.popups.PreviewBehavior} behavior\n * @return {void}\n */\nexport function bindBehavior( preview, behavior ) {\n\tpreview.el.addEventListener( 'mouseenter', behavior.previewDwell );\n\tpreview.el.addEventListener( 'mouseleave', behavior.previewAbandon );\n\n\tpreview.el.addEventListener( 'click', behavior.click );\n\n\tconst button = preview.el.querySelector( 'a.mwe-popups-settings-button' );\n\tif ( button ) {\n\t\tbutton.href = behavior.settingsUrl;\n\t\tbutton.addEventListener( 'click', ( event ) => {\n\t\t\tevent.stopPropagation();\n\n\t\t\tbehavior.showSettings( event );\n\t\t} );\n\t} else {\n\t\tconst err = new Error( 'Page previews: No settings button found in preview.' );\n\t\tmw.errorLogger.logError( err, 'error.web-team' );\n\t}\n}\n\n/**\n * Extracted from `mw.popups.render.closePopup`.\n *\n * @param {ext.popups.Preview} preview\n * @return {jQuery.Promise<void>} A promise that resolves when the preview has\n * faded out.\n */\nexport function hide( preview ) {\n\t// FIXME: This method clearly needs access to the layout of the preview.\n\tconst fadeInClass = ( preview.el.classList.contains( 'mwe-popups-fade-in-up' ) ) ?\n\t\t'mwe-popups-fade-in-up' :\n\t\t'mwe-popups-fade-in-down';\n\n\tconst fadeOutClass = ( fadeInClass === 'mwe-popups-fade-in-up' ) ?\n\t\t'mwe-popups-fade-out-down' :\n\t\t'mwe-popups-fade-out-up';\n\n\t// Classes documented above\n\t// eslint-disable-next-line mediawiki/class-doc\n\tpreview.el.classList.remove( fadeInClass );\n\t// eslint-disable-next-line mediawiki/class-doc\n\tpreview.el.classList.add( fadeOutClass );\n\n\treturn wait( 150 ).then( () => {\n\t\tpreview.el.remove();\n\t} );\n}\n\n/**\n * Represents the layout of a preview, which consists of a position (`offset`)\n * and whether or not the preview should be flipped horizontally or\n * vertically (`flippedX` and `flippedY` respectively).\n *\n * @typedef {Object} ext.popups.PreviewLayout\n * @property {Object} offset\n * @property {number} offset.top\n * @property {number} offset.left\n * @property {boolean} flippedX\n * @property {boolean} flippedY\n * @property {string} dir 'ltr' if left-to-right, 'rtl' if right-to-left.\n */\n\n/**\n * @param {boolean} isPreviewTall\n * @param {ext.popups.Measures} measures\n * @param {number} pointerSpaceSize Space reserved for the pointer\n * @param {string} dir 'ltr' if left-to-right, 'rtl' if right-to-left.\n * @return {ext.popups.PreviewLayout}\n */\nexport function createLayout(\n\tisPreviewTall, measures, pointerSpaceSize, dir\n) {\n\tlet flippedX = false,\n\t\tflippedY = false,\n\t\toffsetTop = measures.pageY ?\n\t\t\t// If it was a mouse event, position according to mouse\n\t\t\t// Since client rectangles are relative to the viewport,\n\t\t\t// take scroll position into account.\n\t\t\tgetClosestYPosition(\n\t\t\t\tmeasures.pageY - measures.scrollTop,\n\t\t\t\tmeasures.clientRects,\n\t\t\t\tfalse\n\t\t\t) + measures.scrollTop + pointerSpaceSize :\n\t\t\t// Position according to link position or size\n\t\t\tmeasures.offset.top + measures.height + pointerSize,\n\t\toffsetLeft;\n\tconst clientTop = measures.clientY ? measures.clientY : offsetTop;\n\n\tif ( measures.pageX ) {\n\t\tif ( measures.width > maxLinkWidthForCenteredPointer ) {\n\t\t\t// For wider links, position the popup's pointer at the\n\t\t\t// mouse pointer's location. (x-axis)\n\t\t\toffsetLeft = measures.pageX;\n\t\t} else {\n\t\t\t// For smaller links, position the popup's pointer at\n\t\t\t// the link's center. (x-axis)\n\t\t\toffsetLeft = measures.offset.left + measures.width / 2;\n\t\t}\n\t} else {\n\t\toffsetLeft = measures.offset.left;\n\t}\n\n\t// X Flip\n\tif ( offsetLeft > ( measures.windowWidth / 2 ) ) {\n\t\toffsetLeft += ( !measures.pageX ) ? measures.width : 0;\n\t\toffsetLeft -= !isPreviewTall ?\n\t\t\tportraitPopupWidth :\n\t\t\tlandscapePopupWidth;\n\t\tflippedX = true;\n\t}\n\n\tif ( measures.pageX ) {\n\t\toffsetLeft += ( flippedX ) ? 18 : -18;\n\t}\n\n\t// Y Flip\n\tif ( clientTop > ( measures.windowHeight / 2 ) ) {\n\t\tflippedY = true;\n\n\t\t// Mirror the positioning of the preview when there's no \"Y flip\": rest\n\t\t// the pointer on the edge of the link's bounding rectangle. In this case\n\t\t// the edge is the top-most.\n\t\toffsetTop = measures.offset.top;\n\n\t\t// Change the Y position to the top of the link\n\t\tif ( measures.pageY ) {\n\t\t\t// Since client rectangles are relative to the viewport,\n\t\t\t// take scroll position into account.\n\t\t\toffsetTop = getClosestYPosition(\n\t\t\t\tmeasures.pageY - measures.scrollTop,\n\t\t\t\tmeasures.clientRects,\n\t\t\t\ttrue\n\t\t\t) + measures.scrollTop;\n\t\t}\n\n\t\toffsetTop -= pointerSpaceSize;\n\t}\n\n\treturn {\n\t\toffset: {\n\t\t\ttop: offsetTop,\n\t\t\tleft: offsetLeft\n\t\t},\n\t\tflippedX: dir === 'rtl' ? !flippedX : flippedX,\n\t\tflippedY,\n\t\tdir\n\t};\n}\n\n/**\n * is there a pointer on the image of the preview?\n *\n * @param {ext.popups.Preview} preview\n * @param {ext.popups.PreviewLayout} layout\n * @return {boolean}\n */\nexport function hasPointerOnImage( preview, layout ) {\n\tif ( ( !preview.hasThumbnail || preview.isTall && !layout.flippedX ) &&\n\t\t!layout.flippedY ) {\n\t\treturn false;\n\t}\n\tif ( preview.hasThumbnail ) {\n\t\tif (\n\t\t\t( !preview.isTall && !layout.flippedY ) ||\n\t\t\t( preview.isTall && layout.flippedX )\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n * Generates a list of declarative CSS classes that represent the layout of\n * the preview.\n *\n * @param {ext.popups.Preview} preview\n * @param {ext.popups.PreviewLayout} layout\n * @return {string[]}\n */\nexport function getClasses( preview, layout ) {\n\tconst classes = [];\n\n\tif ( layout.flippedY ) {\n\t\tclasses.push( 'mwe-popups-fade-in-down' );\n\t} else {\n\t\tclasses.push( 'mwe-popups-fade-in-up' );\n\t}\n\n\tif ( layout.flippedY && layout.flippedX ) {\n\t\tclasses.push( 'flipped-x-y' );\n\t} else if ( layout.flippedY ) {\n\t\tclasses.push( 'flipped-y' );\n\t} else if ( layout.flippedX ) {\n\t\tclasses.push( 'flipped-x' );\n\t}\n\n\tclasses.push(\n\t\thasPointerOnImage( preview, layout ) ?\n\t\t\t'mwe-popups-image-pointer' : 'mwe-popups-no-image-pointer'\n\t);\n\n\tif ( preview.isTall ) {\n\t\tclasses.push( 'mwe-popups-is-tall' );\n\t} else {\n\t\tclasses.push( 'mwe-popups-is-not-tall' );\n\t}\n\n\treturn classes;\n}\n\n/**\n * Lays out the preview given the layout.\n *\n * If the thumbnail is landscape and isn't the full height of the thumbnail\n * container, then pull the extract up to keep whitespace consistent across\n * previews.\n *\n * @param {ext.popups.Preview} preview\n * @param {ext.popups.PreviewLayout} layout\n * @param {string[]} classes class names used for layout out the preview\n * @param {number} predefinedLandscapeImageHeight landscape image height\n * @param {number} pointerSpaceSize\n * @param {number} windowHeight\n * @return {void}\n */\nexport function layoutPreview(\n\tpreview, layout, classes, predefinedLandscapeImageHeight, pointerSpaceSize, windowHeight\n) {\n\tconst popup = preview.el,\n\t\tisTall = preview.isTall,\n\t\thasThumbnail = preview.hasThumbnail,\n\t\tthumbnail = preview.thumbnail,\n\t\tflippedY = layout.flippedY;\n\n\tif (\n\t\t!flippedY && !isTall && hasThumbnail &&\n\t\t\tthumbnail.height < predefinedLandscapeImageHeight && !supportsCSSClipPath()\n\t) {\n\t\tconst popupExtract = popup.querySelector( '.mwe-popups-extract' );\n\t\tpopupExtract.style.marginTop = `${( thumbnail.height - pointerSpaceSize )}px`;\n\t}\n\n\t// The following classes are used here:\n\t// * flipped-x\n\t// * flipped-x-y\n\t// * flipped-y\n\t// * mwe-popups-fade-in-down\n\t// * mwe-popups-fade-in-up\n\t// * mwe-popups-image-pointer\n\t// * mwe-popups-is-not-tall\n\t// * mwe-popups-is-tall\n\t// * mwe-popups-no-image-pointer\n\tpopup.classList.add.apply( popup.classList, classes );\n\n\tpopup.style.left = `${layout.offset.left}px`;\n\tpopup.style.top = flippedY ? 'auto' : `${layout.offset.top}px`;\n\tpopup.style.bottom = flippedY ? `${windowHeight - layout.offset.top}px` : 'auto';\n\n\tif ( hasThumbnail && !supportsCSSClipPath() ) {\n\t\tsetThumbnailClipPath( preview, layout );\n\t}\n}\n\n/**\n * Sets the thumbnail SVG clip-path.\n *\n * If the preview should be oriented differently, then the pointer is updated,\n * e.g. if the preview should be flipped vertically, then the pointer is\n * removed.\n *\n * Note: SVG clip-paths are supported everywhere but clip-paths as CSS\n * properties are not (https://caniuse.com/#feat=css-clip-path). For this\n * reason, RTL flipping is handled in JavaScript instead of CSS.\n *\n * @param {ext.popups.Preview} preview\n * @param {ext.popups.PreviewLayout} layout\n * @return {void}\n */\nexport function setThumbnailClipPath(\n\t{ el, isTall, thumbnail }, { flippedY, flippedX, dir }\n) {\n\tconst maskID = getThumbnailClipPathID( isTall, flippedY, flippedX );\n\tif ( maskID ) {\n\t\t// CSS matrix transform entries:\n\t\t// ⎡ sx c tx ⎤\n\t\t// ⎣ sy d ty ⎦\n\t\tconst matrix = {\n\t\t\tscaleX: 1,\n\t\t\t// moving the mask horizontally if the image is less than the maximum width\n\t\t\ttranslateX: isTall ? Math.min( thumbnail.width - SIZES.portraitImage.w, 0 ) : 0\n\t\t};\n\n\t\tif ( dir === 'rtl' ) {\n\t\t\t// flipping the mask horizontally\n\t\t\tmatrix.scaleX = -1;\n\t\t\t// moving the mask horizontally to the max width of the thumbnail\n\t\t\tmatrix.translateX = isTall ? SIZES.portraitImage.w : SIZES.landscapeImage.w;\n\t\t}\n\n\t\t// Transform the clip-path not the image it is applied to.\n\t\tconst mask = document.getElementById( maskID );\n\t\tmask.setAttribute(\n\t\t\t'transform',\n\t\t\t`matrix(${matrix.scaleX} 0 0 1 ${matrix.translateX} 0)`\n\t\t);\n\n\t\tel.querySelector( 'image' )\n\t\t\t.setAttribute( 'clip-path', `url(#${maskID})` );\n\t}\n}\n\n/**\n * Gets the thumbnail SVG clip-path element ID as specified in pointer-mask.svg.\n *\n * @param {boolean} isTall Sugar around\n * `preview.hasThumbnail && thumbnail.isTall`\n * @param {boolean} flippedY\n * @param {boolean} flippedX\n * @return {string|undefined}\n */\nexport function getThumbnailClipPathID( isTall, flippedY, flippedX ) {\n\t// Clip-paths are only needed when the pointer is in a corner that is covered by the thumbnail.\n\t// This is only the case in 4 of 8 situations:\n\tif ( !isTall && !flippedY ) {\n\t\t// 1. Landscape thumbnails cover the upper half of the popup. This is only the case when the\n\t\t// pointer is not flipped to the bottom.\n\t\treturn flippedX ? 'mwe-popups-mask-flip' : 'mwe-popups-mask';\n\t} else if ( isTall && flippedX ) {\n\t\t// 2. Tall thumbnails cover the right half of the popup. This is only the case when the\n\t\t// pointer is flipped to the right.\n\t\treturn flippedY ? 'mwe-popups-landscape-mask-flip' : 'mwe-popups-landscape-mask';\n\t}\n\n\t// The 4 combinations not covered above don't need a clip-path.\n\treturn undefined;\n}\n\n/**\n * Given the rectangular box(es) find the 'y' boundary of the closest\n * rectangle to the point 'y'. The point 'y' is the location of the mouse\n * on the 'y' axis and the rectangular box(es) are the borders of the\n * element over which the mouse is located. There will be more than one\n * rectangle in case the element spans multiple lines.\n *\n * In the majority of cases the mouse pointer will be inside a rectangle.\n * However, some browsers (i.e. Chrome) trigger a hover action even when\n * the mouse pointer is just outside a bounding rectangle. That's why\n * we need to look at all rectangles and not just the rectangle that\n * encloses the point.\n *\n * @private\n * @param {number} y the point for which the closest location is being\n * looked for\n * @param {ClientRectList} rects list of rectangles defined by four edges\n * @param {boolean} [isTop] should the resulting rectangle's top 'y'\n * boundary be returned. By default the bottom 'y' value is returned.\n * @return {number}\n */\nexport function getClosestYPosition( y, rects, isTop ) {\n\tlet minY = null, result;\n\n\tArray.prototype.slice.call( rects ).forEach( ( rect ) => {\n\t\tconst deltaY = Math.abs( y - rect.top + y - rect.bottom );\n\n\t\tif ( minY === null || minY > deltaY ) {\n\t\t\tminY = deltaY;\n\t\t\t// Make sure the resulting point is at or outside the rectangle\n\t\t\t// boundaries.\n\t\t\tresult = ( isTop ) ? Math.floor( rect.top ) : Math.ceil( rect.bottom );\n\t\t}\n\t} );\n\n\treturn result;\n}\n\nexport const test = {\n\t/** For testing only */\n\treset: () => {\n\t\trenderers = {};\n\t}\n};\n","/**\n * @module changeListeners/syncUserSettings\n */\n\nimport { previewTypes } from '../preview/model';\n\n/**\n * Creates an instance of the user settings sync change listener.\n *\n * This change listener syncs certain parts of the state tree to user\n * settings when they change.\n *\n * Used for:\n *\n * * Enabled state: If the previews are enabled or disabled.\n * * Preview count: When the user dwells on a link for long enough that\n * a preview is shown, then their preview count will be incremented (see\n * `reducers/eventLogging.js`, and is persisted to local storage.\n *\n * @param {ext.popups.UserSettings} userSettings\n * @return {ext.popups.ChangeListener}\n */\nexport default function syncUserSettings( userSettings ) {\n\treturn ( oldState, newState ) => {\n\t\tsyncIfChanged(\n\t\t\toldState, newState, 'preview.enabled.' + previewTypes.TYPE_PAGE,\n\t\t\tuserSettings.storePagePreviewsEnabled\n\t\t);\n\t\tsyncIfChanged(\n\t\t\toldState, newState, 'preview.enabled.' + previewTypes.TYPE_REFERENCE,\n\t\t\tuserSettings.storeReferencePreviewsEnabled\n\t\t);\n\t};\n}\n\n/**\n * Given a state tree, reducer and property, safely return the value of the\n * property if the reducer and property exist\n *\n * @param {Object} state tree\n * @param {string} path dot-separated path in the state tree\n * @return {*}\n */\nfunction get( state, path ) {\n\treturn path.split( '.' ).reduce(\n\t\t( element, key ) => element && element[ key ],\n\t\tstate\n\t);\n}\n\n/**\n * Calls a sync function if the property prop on the property reducer on\n * the state trees has changed value.\n *\n * @param {Object} oldState\n * @param {Object} newState\n * @param {string} path dot-separated path in the state tree\n * @param {Function} sync function to be called with the newest value if\n * changed\n * @return {void}\n */\nfunction syncIfChanged( oldState, newState, path, sync ) {\n\tconst current = get( newState, path );\n\tif ( oldState && ( get( oldState, path ) !== current ) ) {\n\t\tsync( current );\n\t}\n}\n","import footerLink from './footerLink';\nimport linkTitle from './linkTitle';\nimport pageviews from './pageviews';\nimport render from './render';\nimport settings from './settings';\nimport statsv from './statsv';\nimport syncUserSettings from './syncUserSettings';\n\nexport default {\n\tfooterLink,\n\tlinkTitle,\n\tpageviews,\n\trender,\n\tsettings,\n\tstatsv,\n\tsyncUserSettings\n};\n","/**\n * @module changeListeners/footerLink\n */\n\n/**\n * Creates the link element and appends it to the footer element.\n *\n * The following elements are considered to be the footer element (highest\n * priority to lowest):\n *\n * # `#footer-places`\n * # `#f-list`\n * # The parent element of `#footer li`, which is either an `ol` or `ul`.\n *\n * @return {HTMLElement} The link element\n */\nfunction createFooterLink() {\n\tconst footerListItem = document.createElement( 'li' );\n\tconst footerLinkElement = document.createElement( 'a' );\n\tfooterLinkElement.href = '#';\n\tfooterLinkElement.textContent = mw.message( 'popups-settings-enable' ).text();\n\tfooterListItem.appendChild( footerLinkElement );\n\n\t// As yet, we don't know whether the link should be visible.\n\tfooterListItem.style.display = 'none';\n\n\t// From https://en.wikipedia.org/wiki/MediaWiki:Gadget-ReferenceTooltips.js,\n\t// which was written by Yair rand <https://en.wikipedia.org/wiki/User:Yair_rand>.\n\tlet footer = document.querySelector( '#footer-places, #f-list' );\n\n\tif ( !footer ) {\n\t\tconst footerLegacy = document.querySelector( '#footer li' );\n\t\tif ( footerLegacy ) {\n\t\t\tfooter = footerLegacy.parentNode;\n\t\t}\n\t}\n\n\tif ( footer ) {\n\t\tfooter.appendChild( footerListItem );\n\t}\n\treturn footerListItem;\n}\n\n/**\n * Creates an instance of the footer link change listener.\n *\n * The change listener covers the following behaviour:\n *\n * * The \"Edit preview settings\" link (the \"link\") is appended to the footer menu\n * (see `createFooterLink` above).\n * * When at least one popup type is disabled, then the link is shown;\n * otherwise, the link is hidden.\n * * When the user clicks the link, then the `showSettings` bound action\n * creator is called.\n *\n * @param {Object} boundActions\n * @return {ext.popups.ChangeListener}\n */\nexport default function footerLink( boundActions ) {\n\tlet footerLinkElement;\n\n\treturn ( oldState, newState ) => {\n\t\tif ( footerLinkElement === undefined ) {\n\t\t\tfooterLinkElement = createFooterLink();\n\t\t\tfooterLinkElement.addEventListener( 'click', ( e ) => {\n\t\t\t\te.preventDefault();\n\t\t\t\tboundActions.showSettings();\n\t\t\t} );\n\t\t}\n\n\t\tif ( newState.settings.shouldShowFooterLink ) {\n\t\t\tfooterLinkElement.style.display = '';\n\t\t} else {\n\t\t\tfooterLinkElement.style.display = 'none';\n\t\t}\n\t};\n}\n","/**\n * Creates an instance of the link title change listener.\n *\n * While the user dwells on a link, then it becomes the active link. The\n * change listener will remove a link's `title` attribute while it's the\n * active link.\n *\n * @return {ext.popups.ChangeListener}\n */\nexport default function linkTitle() {\n\tlet savedTitle;\n\n\t/**\n\t * Destroys the title attribute of the element, storing its value in local\n\t * state so that it can be restored later (see `restoreTitleAttr`).\n\t *\n\t * @param {Element|undefined} el\n\t */\n\tfunction destroyTitleAttr( el ) {\n\t\t// Has the user dwelled on a link? If we've already removed its title attribute, then NOOP.\n\t\tif ( el && !savedTitle ) {\n\t\t\tsavedTitle = el.getAttribute( 'title' );\n\t\t\tel.setAttribute( 'title', '' );\n\t\t}\n\t}\n\n\t/**\n\t * Restores the title attribute of the element.\n\t *\n\t * @param {Element|undefined} el\n\t */\n\tfunction restoreTitleAttr( el ) {\n\t\t// Avoid overwriting a non-empty title with an empty one, just to be sure\n\t\tif ( el && savedTitle ) {\n\t\t\tel.setAttribute( 'title', savedTitle );\n\t\t\tsavedTitle = undefined;\n\t\t}\n\t}\n\n\treturn ( oldState, newState ) => {\n\t\tconst oldLink = oldState && oldState.preview.activeLink;\n\n\t\t// Usually only one side is set when the user enters or leaves a link. Both sides contain\n\t\t// two different links when the user dwelled on a link immediately after abandoning another\n\t\t// (remembering that the ABANDON_END action is delayed by ~100 ms).\n\t\tif ( oldLink !== newState.preview.activeLink ) {\n\t\t\trestoreTitleAttr( oldLink );\n\n\t\t\t// FIXME: This will not work on anything other than 'reference' or 'preview' types as\n\t\t\t// mw.popups.register does not register the previewType as a key in newState.preview.enabled\n\t\t\t// This is not a problem at time of writing (November 2022) but will become a problem if we\n\t\t\t// introduce custom preview types that must remove the title attribute.\n\t\t\tif ( newState.preview.enabled[ newState.preview.previewType ] ) {\n\t\t\t\tdestroyTitleAttr( newState.preview.activeLink );\n\t\t\t}\n\t\t}\n\t};\n}\n","/**\n * @module changeListeners/pageviews\n */\n\n/**\n * Creates an instance of the pageviews change listener.\n *\n * When a pageview enqueued it'll be logged using the VirtualPageView schema.\n * Note, it's the responsibility of Event Logging (and the UA) to\n * deliver logged events.\n *\n * @param {Object} boundActions\n * @param {EventTracker} pageviewTracker\n * @return {ext.popups.ChangeListener}\n */\nexport default function pageviews(\n\tboundActions, pageviewTracker\n) {\n\treturn ( oldState, newState ) => {\n\t\tlet page, pageview;\n\t\tif ( newState.pageviews && newState.pageviews.pageview && newState.pageviews.page ) {\n\t\t\tpage = newState.pageviews.page;\n\t\t\tpageview = newState.pageviews.pageview;\n\t\t\tpageviewTracker( 'event.VirtualPageView', {\n\t\t\t\t/* eslint-disable camelcase */\n\t\t\t\tsource_page_id: page.id,\n\t\t\t\tsource_namespace: page.namespaceId,\n\t\t\t\tsource_title: mw.Title.newFromText( page.title ).getPrefixedDb(),\n\t\t\t\tsource_url: page.url,\n\t\t\t\tpage_id: pageview.page_id,\n\t\t\t\tpage_namespace: pageview.page_namespace,\n\t\t\t\tpage_title: mw.Title.newFromText( pageview.page_title ).getPrefixedDb()\n\t\t\t\t/* eslint-enable camelcase */\n\t\t\t} );\n\t\t\t// Clear the pageview now its been logged.\n\t\t\tboundActions.pageviewLogged();\n\t\t}\n\t};\n}\n","import * as renderer from '../ui/renderer';\n\n/**\n * Creates an instance of the render change listener.\n *\n * FIXME: Remove hard coupling with renderer, inject it as a parameter\n * * Wire it up in index.js\n * * Fix tests to remove require mocking\n *\n * @param {ext.popups.PreviewBehavior} previewBehavior\n * @return {ext.popups.ChangeListener}\n */\nexport default function render( previewBehavior ) {\n\tlet preview;\n\n\treturn ( oldState, newState ) => {\n\t\tif ( newState.preview.shouldShow && !preview ) {\n\t\t\tpreview = renderer.render( newState.preview.fetchResponse );\n\t\t\tpreview.show(\n\t\t\t\tnewState.preview.measures,\n\t\t\t\tpreviewBehavior,\n\t\t\t\tnewState.preview.activeToken\n\t\t\t);\n\t\t} else if ( !newState.preview.shouldShow && preview ) {\n\t\t\tpreview.hide();\n\t\t\tpreview = undefined;\n\t\t}\n\t};\n}\n","/**\n * Creates an instance of the settings change listener.\n *\n * @param {Object} boundActions\n * @param {Object} render function that renders a jQuery el with the settings\n * @return {ext.popups.ChangeListener}\n */\nexport default function settings( boundActions, render ) {\n\tlet settingsObj;\n\n\treturn ( oldState, newState ) => {\n\t\tif ( !oldState ) {\n\t\t\t// Nothing to do on initialization\n\t\t\treturn;\n\t\t}\n\n\t\t// Update global modal visibility\n\t\tif ( oldState.settings.shouldShow === false && newState.settings.shouldShow ) {\n\t\t\t// Lazily instantiate the settings UI\n\t\t\tif ( !settingsObj ) {\n\t\t\t\tsettingsObj = render( boundActions );\n\t\t\t\tsettingsObj.appendTo( document.body );\n\t\t\t}\n\n\t\t\t// Update the UI settings with the current settings\n\t\t\tsettingsObj.setEnabled( newState.preview.enabled );\n\t\t\tsettingsObj.show();\n\t\t} else if ( oldState.settings.shouldShow && newState.settings.shouldShow === false ) {\n\t\t\tsettingsObj.hide();\n\t\t}\n\n\t\t// Update help visibility\n\t\tif ( oldState.settings.showHelp !== newState.settings.showHelp ) {\n\t\t\tsettingsObj.toggleHelp( newState.settings.showHelp );\n\t\t}\n\t};\n}\n","/**\n * Creates an instance of the statsv change listener.\n *\n * The listener will log events to StatsD via the [the \"StatsD timers and\n * counters\" analytics event protocol][0].\n *\n * [0]: https://github.com/wikimedia/mediawiki-extensions-WikimediaEvents/blob/29c864a0/modules/ext.wikimediaEvents.statsd.js\n *\n * @param {Object} boundActions\n * @param {EventTracker} track\n * @return {ext.popups.ChangeListener}\n */\nexport default function statsv( boundActions, track ) {\n\treturn ( oldState, newState ) => {\n\t\tconst statsvObj = newState.statsv;\n\n\t\tif ( statsvObj.action ) {\n\t\t\ttrack( statsvObj.action, statsvObj.data );\n\n\t\t\tboundActions.statsvLogged();\n\t\t}\n\t};\n}\n","/**\n * @module actionTypes\n */\n\nexport default {\n\tBOOT: 'BOOT',\n\tLINK_DWELL: 'LINK_DWELL',\n\tABANDON_START: 'ABANDON_START',\n\tABANDON_END: 'ABANDON_END',\n\tLINK_CLICK: 'LINK_CLICK',\n\t/** Precedes a fetch. */\n\tFETCH_START: 'FETCH_START',\n\t/** Follows a successful fetch. */\n\tFETCH_END: 'FETCH_END',\n\t/** Follows a fetch regardless of whether it was successful. */\n\tFETCH_COMPLETE: 'FETCH_COMPLETE',\n\t/** Follows an unsuccessful fetch. */\n\tFETCH_FAILED: 'FETCH_FAILED',\n\t/** Follows an aborted fetch */\n\tFETCH_ABORTED: 'FETCH_ABORTED',\n\tPAGEVIEW_LOGGED: 'PAGEVIEW_LOGGED',\n\tPREVIEW_DWELL: 'PREVIEW_DWELL',\n\tPREVIEW_SHOW: 'PREVIEW_SHOW',\n\tPREVIEW_CLICK: 'PREVIEW_CLICK',\n\t/**\n\t * Occurs when a preview has been opened for a significant amount of time and\n\t * is assumed to have been viewed.\n\t */\n\tPREVIEW_SEEN: 'PREVIEW_SEEN',\n\tSETTINGS_SHOW: 'SETTINGS_SHOW',\n\tSETTINGS_HIDE: 'SETTINGS_HIDE',\n\tSETTINGS_CHANGE: 'SETTINGS_CHANGE',\n\tSTATSV_LOGGED: 'STATSV_LOGGED'\n};\n","/**\n * @module actions\n */\n\nimport types from './actionTypes';\nimport wait from './wait';\nimport { createNullModel, previewTypes, getDwellDelay } from './preview/model';\nimport { FETCH_START_DELAY, PREVIEW_SEEN_DURATION, ABANDON_END_DELAY } from './constants';\n\n/**\n * Mixes in timing information to an action.\n *\n * Warning: the `baseAction` parameter is modified and returned.\n *\n * @param {Object} baseAction\n * @return {Object}\n */\nfunction timedAction( baseAction ) {\n\tbaseAction.timestamp = mw.now();\n\n\treturn baseAction;\n}\n\n/**\n * Represents Page Previews booting.\n *\n * When a Redux store is created, the `@@INIT` action is immediately\n * dispatched to it. To avoid overriding the term, we refer to booting rather\n * than initializing.\n *\n * Page Previews persists critical pieces of information to local storage.\n * Since reading from and writing to local storage are synchronous, Page\n * Previews is booted when the browser is idle (using\n * [`mw.requestIdleCallback`](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback))\n * so as not to impact latency-critical events.\n *\n * @param {Object} initiallyEnabled Allows to disable individual popup types while still showing the\n * footer link\n * @param {mw.user} user\n * @param {ext.popups.UserSettings} userSettings\n * @param {mw.Map} config The config of the MediaWiki client-side application,\n * i.e. `mw.config`\n * @param {string} url\n * @return {Object}\n */\nexport function boot(\n\tinitiallyEnabled,\n\tuser,\n\tuserSettings,\n\tconfig,\n\turl\n) {\n\tconst editCount = config.get( 'wgUserEditCount' );\n\n\treturn {\n\t\ttype: types.BOOT,\n\t\tinitiallyEnabled,\n\t\t// This is only used for logging\n\t\tisNavPopupsEnabled: config.get( 'wgPopupsConflictsWithNavPopupGadget' ),\n\t\tsessionToken: user.sessionId(),\n\t\tpageToken: user.getPageviewToken(),\n\t\tpage: {\n\t\t\turl,\n\t\t\ttitle: config.get( 'wgTitle' ),\n\t\t\tnamespaceId: config.get( 'wgNamespaceNumber' ),\n\t\t\tid: config.get( 'wgArticleId' )\n\t\t},\n\t\tuser: {\n\t\t\tisAnon: user.isAnon() || mw.user.isTemp(),\n\t\t\teditCount\n\t\t}\n\t};\n}\n\n/**\n * Represents Page Previews fetching data via the gateway.\n *\n * @param {Gateway} gateway\n * @param {mw.Title} title\n * @param {HTMLAnchorElement} el\n * @param {string} token The unique token representing the link interaction that\n * triggered the fetch\n * @param {string} type One of the previewTypes.TYPE_… constants\n * @return {Redux.Thunk}\n */\nexport function fetch( gateway, title, el, token, type ) {\n\tconst titleText = title.getPrefixedDb(),\n\t\tnamespaceId = title.namespace;\n\n\treturn ( dispatch ) => {\n\t\tconst xhr = gateway.fetchPreviewForTitle( title, el );\n\n\t\tdispatch( timedAction( {\n\t\t\ttype: types.FETCH_START,\n\t\t\tel,\n\t\t\ttitle: titleText,\n\t\t\tnamespaceId,\n\t\t\tpromise: xhr\n\t\t} ) );\n\n\t\tconst chain = xhr\n\t\t\t.then( ( result ) => {\n\t\t\t\tdispatch( timedAction( {\n\t\t\t\t\ttype: types.FETCH_END,\n\t\t\t\t\tel\n\t\t\t\t} ) );\n\n\t\t\t\treturn result;\n\t\t\t} )\n\t\t\t.catch( ( err, data ) => {\n\t\t\t\tconst exception = new Error( err );\n\t\t\t\tconst fetchType = data && data.textStatus && data.textStatus === 'abort' ?\n\t\t\t\t\ttypes.FETCH_ABORTED : types.FETCH_FAILED;\n\n\t\t\t\texception.data = data;\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: fetchType,\n\t\t\t\t\tel,\n\t\t\t\t\ttoken\n\t\t\t\t} );\n\t\t\t\t// Keep the request promise in a rejected status since it failed.\n\t\t\t\tthrow exception;\n\t\t\t} );\n\n\t\treturn Promise.all( [\n\t\t\tchain,\n\t\t\twait( getDwellDelay( type ) )\n\t\t] )\n\t\t\t.then( ( [ result ] ) => {\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: types.FETCH_COMPLETE,\n\t\t\t\t\tel,\n\t\t\t\t\tresult,\n\t\t\t\t\ttoken\n\t\t\t\t} );\n\t\t\t} )\n\t\t\t.catch( ( ex ) => {\n\t\t\t\tconst result = ex.data;\n\t\t\t\tlet showNullPreview = true;\n\t\t\t\t// All failures, except those due to being offline or network error,\n\t\t\t\t// should present \"There was an issue displaying this preview\".\n\t\t\t\t// e.g.:\n\t\t\t\t// - Show (timeout): data=\"http\" {xhr: {…}, textStatus: \"timeout\",\n\t\t\t\t// exception: \"timeout\"}\n\t\t\t\t// - Show (bad MW request): data=\"unknown_action\" {error: {…}}\n\t\t\t\t// - Show (RB 4xx): data=\"http\" {xhr: {…}, textStatus: \"error\",\n\t\t\t\t// exception: \"Bad Request\"}\n\t\t\t\t// - Show (RB 5xx): data=\"http\" {xhr: {…}, textStatus: \"error\",\n\t\t\t\t// exception: \"Service Unavailable\"}\n\t\t\t\t// - Suppress (offline or network error): data=\"http\"\n\t\t\t\t// result={xhr: {…}, textStatus: \"error\", exception: \"\"}\n\t\t\t\t// - Abort: data=\"http\"\n\t\t\t\t// result={xhr: {…}, textStatus: \"abort\", exception: \"abort\"}\n\n\t\t\t\tif ( result && result.xhr && result.xhr.readyState === 0 ) {\n\t\t\t\t\tconst isNetworkError = result.textStatus === 'error' && result.exception === '';\n\t\t\t\t\tshowNullPreview = !( isNetworkError || result.textStatus === 'abort' );\n\t\t\t\t}\n\n\t\t\t\tif ( showNullPreview ) {\n\t\t\t\t\tdispatch( {\n\t\t\t\t\t\ttype: types.FETCH_COMPLETE,\n\t\t\t\t\t\tel,\n\t\t\t\t\t\tresult: createNullModel( titleText, title.getUrl() ),\n\t\t\t\t\t\ttoken\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t};\n}\n\n/**\n * Represents the user dwelling on a link, either by hovering over it with\n * their mouse or by focussing it using their keyboard or an assistive device.\n *\n * @param {mw.Title} title\n * @param {HTMLAnchorElement} el\n * @param {ext.popups.Measures} measures\n * @param {Gateway} gateway\n * @param {Function} generateToken\n * @param {string} type One of the previewTypes.TYPE_… constants\n * @return {Redux.Thunk}\n */\nexport function linkDwell( title, el, measures, gateway, generateToken, type ) {\n\tconst token = generateToken(),\n\t\ttitleText = title.getPrefixedDb(),\n\t\tnamespaceId = title.namespace;\n\n\treturn ( dispatch, getState ) => {\n\t\tconst promise = wait( FETCH_START_DELAY );\n\t\tconst action = timedAction( {\n\t\t\ttype: types.LINK_DWELL,\n\t\t\tel,\n\t\t\tpreviewType: type,\n\t\t\tmeasures,\n\t\t\ttoken,\n\t\t\ttitle: titleText,\n\t\t\tnamespaceId,\n\t\t\tpromise\n\t\t} );\n\n\t\tdispatch( action );\n\n\t\t// Has the new generated token been accepted?\n\t\tfunction isNewInteraction() {\n\t\t\treturn getState().preview.activeToken === token;\n\t\t}\n\n\t\tif ( !isNewInteraction() ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\treturn promise.then( () => {\n\t\t\tconst previewState = getState().preview;\n\t\t\tconst enabledValue = previewState.enabled[ type ];\n\t\t\t// Note: Only reference previews and default previews can be disabled at this point.\n\t\t\t// If there is no UI the enabledValue is always true.\n\t\t\tconst isEnabled = typeof enabledValue === 'undefined' ? true : enabledValue;\n\n\t\t\t// The `enabled` flags allow to disable individual popup types while still showing the\n\t\t\t// footer link. This comes from the boot() action (called `initiallyEnabled` there) and\n\t\t\t// the preview() reducer.\n\t\t\t// If the preview type has not been enabled, we ignore it as it cannot be disabled (currently)\n\t\t\t// by the UI.\n\t\t\tif ( isEnabled && isNewInteraction() ) {\n\t\t\t\treturn dispatch( fetch( gateway, title, el, token, type ) );\n\t\t\t}\n\t\t} );\n\t};\n}\n\n/**\n * Represents the user abandoning a link, either by moving their mouse away\n * from it or by shifting focus to another UI element using their keyboard or\n * an assistive device, or abandoning a preview by moving their mouse away\n * from it.\n *\n * @return {Redux.Thunk}\n */\nexport function abandon() {\n\treturn ( dispatch, getState ) => {\n\t\tconst { activeToken: token, promise } = getState().preview;\n\n\t\tif ( !token ) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\tdispatch( timedAction( {\n\t\t\ttype: types.ABANDON_START,\n\t\t\ttoken\n\t\t} ) );\n\n\t\tif ( 'abort' in promise ) {\n\t\t\t// Immediately request that any outstanding fetch request be abandoned. Do not wait.\n\t\t\tpromise.abort();\n\t\t}\n\n\t\treturn wait( ABANDON_END_DELAY )\n\t\t\t.then( () => {\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: types.ABANDON_END,\n\t\t\t\t\ttoken\n\t\t\t\t} );\n\t\t\t} );\n\t};\n}\n\n/**\n * Represents the user clicking on a link with their mouse, keyboard, or an\n * assistive device.\n *\n * @param {HTMLAnchorElement} el\n * @return {Object}\n */\nexport function linkClick( el ) {\n\treturn timedAction( {\n\t\ttype: types.LINK_CLICK,\n\t\tel\n\t} );\n}\n\n/**\n * Represents the user dwelling on a preview with their mouse.\n *\n * @return {Object}\n */\nexport function previewDwell() {\n\treturn {\n\t\ttype: types.PREVIEW_DWELL\n\t};\n}\n\n/**\n * Represents a preview being shown to the user.\n *\n * This action is dispatched by the `./changeListeners/render.js` change\n * listener.\n *\n * @param {string} token\n * @return {Object}\n */\nexport function previewShow( token ) {\n\treturn ( dispatch, getState ) => {\n\t\tdispatch(\n\t\t\ttimedAction( {\n\t\t\t\ttype: types.PREVIEW_SHOW,\n\t\t\t\ttoken\n\t\t\t} )\n\t\t);\n\n\t\treturn wait( PREVIEW_SEEN_DURATION )\n\t\t\t.then( () => {\n\t\t\t\tconst state = getState(),\n\t\t\t\t\tpreview = state.preview,\n\t\t\t\t\tfetchResponse = preview && preview.fetchResponse,\n\t\t\t\t\tcurrentToken = preview && preview.activeToken,\n\t\t\t\t\tvalidType = fetchResponse && [\n\t\t\t\t\t\tpreviewTypes.TYPE_PAGE,\n\t\t\t\t\t\tpreviewTypes.TYPE_DISAMBIGUATION\n\t\t\t\t\t].indexOf( fetchResponse.type ) > -1;\n\n\t\t\t\tif (\n\t\t\t\t\t// Check the pageview can still be associated with original event\n\t\t\t\t\tcurrentToken && currentToken === token &&\n\t\t\t\t\t// and the preview is still active and of type `page`\n\t\t\t\t\tfetchResponse && validType\n\t\t\t\t) {\n\t\t\t\t\tdispatch( {\n\t\t\t\t\t\ttype: types.PREVIEW_SEEN,\n\t\t\t\t\t\ttitle: fetchResponse.title,\n\t\t\t\t\t\tpageId: fetchResponse.pageId,\n\t\t\t\t\t\t// The existing version of summary endpoint does not\n\t\t\t\t\t\t// provide namespace information, but new version\n\t\t\t\t\t\t// will. Given we only show pageviews for main namespace\n\t\t\t\t\t\t// this is hardcoded until the newer version is available.\n\t\t\t\t\t\tnamespace: 0\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t};\n}\n\n/**\n * Represents the situation when a pageview has been logged\n * (see previewShow and PREVIEW_SEEN action type)\n *\n * @return {Object}\n */\nexport function pageviewLogged() {\n\treturn {\n\t\ttype: types.PAGEVIEW_LOGGED\n\t};\n}\n\n/**\n * Represents the user clicking either the \"Enable previews\" footer menu link,\n * or the \"cog\" icon that's present on each preview.\n *\n * @return {Object}\n */\nexport function showSettings() {\n\treturn {\n\t\ttype: types.SETTINGS_SHOW\n\t};\n}\n\n/**\n * Represents the user closing the settings dialog and saving their settings.\n *\n * @return {Object}\n */\nexport function hideSettings() {\n\treturn {\n\t\ttype: types.SETTINGS_HIDE\n\t};\n}\n\n/**\n * Represents the user saving their settings.\n *\n * N.B. This action returns a Redux.Thunk not because it needs to perform\n * asynchronous work, but because it needs to query the global state for the\n * current enabled state. In order to keep the enabled state in a single\n * place (the preview reducer), we query it and dispatch it as `oldValue`\n * so that other reducers (like settings) can act on it without having to\n * duplicate the `enabled` state locally.\n * See docs/adr/0003-keep-enabled-state-only-in-preview-reducer.md for more\n * details.\n *\n * @param {Object} enabled Mapping preview type identifiers to boolean flags\n * @return {Redux.Thunk}\n */\nexport function saveSettings( enabled ) {\n\treturn ( dispatch, getState ) => {\n\t\tdispatch( {\n\t\t\ttype: types.SETTINGS_CHANGE,\n\t\t\toldValue: getState().preview.enabled,\n\t\t\tnewValue: enabled\n\t\t} );\n\t};\n}\n\n/**\n * Represents the queued statsv event being logged.\n * See `mw.popups.changeListeners.statsv` change listener.\n *\n * @return {Object}\n */\nexport function statsvLogged() {\n\treturn {\n\t\ttype: types.STATSV_LOGGED\n\t};\n}\n","/**\n * Creates the next state tree from the current state tree and some updates.\n *\n * N.B. OO.copy doesn't copy Element instances, whereas $.extend does.\n * However, OO.copy does copy properties whose values are undefined or null,\n * whereas $.extend doesn't. Since the state tree contains an Element instance\n * - the preview.activeLink property - and we want to copy undefined/null into\n * the state we need to manually iterate over updates and check with\n * hasOwnProperty to copy over to the new state.\n *\n * In [change listeners](/docs/change_listener.md), for example, we talk about\n * the previous state and the current state (the `oldState` and `newState`\n * parameters, respectively). Since\n * [reducers](http://redux.js.org/docs/basics/Reducers.html) take the current\n * state and an action and make updates, \"next state\" seems appropriate.\n *\n * @param {Object} state\n * @param {Object} updates\n * @return {Object}\n */\nexport default function nextState( state, updates ) {\n\tconst hasOwn = Object.prototype.hasOwnProperty,\n\t\tresult = {};\n\n\t// Flat clone of everything that's not updated\n\tfor ( const key in state ) {\n\t\tif ( hasOwn.call( state, key ) && !hasOwn.call( updates, key ) ) {\n\t\t\tresult[ key ] = state[ key ];\n\t\t}\n\t}\n\n\tfor ( const key in updates ) {\n\t\tif ( !hasOwn.call( updates, key ) ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Deep clone only if there is an update\n\t\tif ( isObject( updates[ key ] ) ) {\n\t\t\tconst clone = state[ key ] ? nextState( {}, state[ key ] ) : {};\n\t\t\t// Recursion\n\t\t\tresult[ key ] = nextState( clone, updates[ key ] );\n\t\t} else {\n\t\t\tresult[ key ] = updates[ key ];\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * @param {*} obj\n * @return {boolean}\n */\nfunction isObject( obj ) {\n\t// https://javascript.plainenglish.io/javascript-check-if-a-variable-is-an-object-and-nothing-else-not-an-array-a-set-etc-a3987ea08fd7\n\treturn obj && obj.constructor === Object;\n}\n","import pageviews from './pageviews';\nimport preview from './preview';\nimport settings from './settings';\nimport statsv from './statsv';\n\nexport default {\n\tpageviews,\n\tpreview,\n\tsettings,\n\tstatsv\n};\n","/**\n * @module reducers/pageviews\n */\n\nimport actionTypes from '../actionTypes';\nimport nextState from './nextState';\n\n/**\n * Reducer for actions that queues and clears events for\n * being logged as virtual pageviews [0]\n *\n * [0]: https://meta.wikimedia.org/wiki/Schema:VirtualPageViews\n *\n * @param {Object|undefined} state\n * @param {Object} action\n * @return {Object} The state resulting from reducing the action with the\n * current state\n */\nexport default function pageviews( state, action ) {\n\tif ( state === undefined ) {\n\t\tstate = {\n\t\t\tpageview: undefined\n\t\t};\n\t}\n\n\tswitch ( action.type ) {\n\t\tcase actionTypes.BOOT:\n\t\t\treturn nextState( state, {\n\t\t\t\tpage: action.page\n\t\t\t} );\n\t\tcase actionTypes.PAGEVIEW_LOGGED:\n\t\t\treturn nextState( state, {\n\t\t\t\tpageview: undefined\n\t\t\t} );\n\t\tcase actionTypes.PREVIEW_SEEN:\n\t\t\treturn nextState( state, {\n\t\t\t\tpageview: {\n\t\t\t\t\t/* eslint-disable camelcase */\n\t\t\t\t\tpage_title: action.title,\n\t\t\t\t\tpage_id: action.pageId,\n\t\t\t\t\tpage_namespace: action.namespace\n\t\t\t\t\t/* eslint-enable camelcase */\n\t\t\t\t}\n\t\t\t} );\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n","import actionTypes from '../actionTypes';\nimport nextState from './nextState';\n\n/**\n * Reducer for actions that modify the state of the preview model\n *\n * @param {Object|undefined} state before action\n * @param {Object} action Redux action that modified state.\n * Must have `type` property.\n * @return {Object} state after action\n */\nexport default function preview( state, action ) {\n\tif ( state === undefined ) {\n\t\tstate = {\n\t\t\tenabled: {},\n\t\t\tactiveLink: undefined,\n\t\t\tpreviewType: undefined,\n\t\t\tmeasures: undefined,\n\t\t\tactiveToken: '',\n\t\t\tshouldShow: false,\n\t\t\tisUserDwelling: false,\n\t\t\twasClicked: false\n\t\t};\n\t}\n\n\tswitch ( action.type ) {\n\t\tcase actionTypes.BOOT:\n\t\t\treturn nextState( state, {\n\t\t\t\tenabled: action.initiallyEnabled\n\t\t\t} );\n\n\t\tcase actionTypes.SETTINGS_CHANGE: {\n\t\t\treturn nextState( state, {\n\t\t\t\tenabled: action.newValue\n\t\t\t} );\n\t\t}\n\n\t\tcase actionTypes.LINK_DWELL:\n\t\t\tif ( action.el !== state.activeLink ) {\n\t\t\t\t// New interaction\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tactiveLink: action.el,\n\t\t\t\t\tpreviewType: action.previewType,\n\t\t\t\t\tmeasures: action.measures,\n\t\t\t\t\tactiveToken: action.token,\n\n\t\t\t\t\t// When the user dwells on a link with their keyboard, a preview is\n\t\t\t\t\t// renderered, and then dwells on another link, the ABANDON_END\n\t\t\t\t\t// action will be ignored.\n\t\t\t\t\t//\n\t\t\t\t\t// Ensure that all the preview is hidden.\n\t\t\t\t\tshouldShow: false,\n\n\t\t\t\t\tisUserDwelling: true,\n\t\t\t\t\tpromise: action.promise\n\t\t\t\t} );\n\t\t\t}\n\t\t\t// Dwelling back into the same link.\n\t\t\treturn nextState( state, {\n\t\t\t\tisUserDwelling: true\n\t\t\t} );\n\n\t\tcase actionTypes.FETCH_ABORTED:\n\t\tcase actionTypes.ABANDON_END:\n\t\t\tif ( action.token === state.activeToken && !state.isUserDwelling ) {\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tactiveLink: undefined,\n\t\t\t\t\tpreviewType: undefined,\n\t\t\t\t\tactiveToken: undefined,\n\t\t\t\t\tmeasures: undefined,\n\t\t\t\t\tfetchResponse: undefined,\n\t\t\t\t\tshouldShow: false\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn state;\n\n\t\tcase actionTypes.PREVIEW_DWELL:\n\t\t\treturn nextState( state, {\n\t\t\t\tisUserDwelling: true\n\t\t\t} );\n\n\t\tcase actionTypes.ABANDON_START:\n\t\t\treturn nextState( state, {\n\t\t\t\tisUserDwelling: false,\n\t\t\t\twasClicked: false\n\t\t\t} );\n\n\t\tcase actionTypes.FETCH_START:\n\t\t\treturn nextState( state, {\n\t\t\t\tfetchResponse: undefined,\n\t\t\t\tpromise: action.promise\n\t\t\t} );\n\n\t\tcase actionTypes.FETCH_COMPLETE:\n\t\t\tif ( action.token === state.activeToken ) {\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tfetchResponse: action.result,\n\t\t\t\t\tshouldShow: state.isUserDwelling\n\t\t\t\t} );\n\t\t\t} // else fall through\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n","import actionTypes from '../actionTypes';\nimport nextState from './nextState';\n\n/**\n * Reducer for actions that modify the state of the settings\n *\n * @param {Object|undefined} state\n * @param {Object} action\n * @return {Object} state after action\n */\nexport default function settings( state, action ) {\n\tif ( state === undefined ) {\n\t\tstate = {\n\t\t\tshouldShow: false,\n\t\t\tshowHelp: false,\n\t\t\tshouldShowFooterLink: false\n\t\t};\n\t}\n\n\tswitch ( action.type ) {\n\t\tcase actionTypes.SETTINGS_SHOW:\n\t\t\treturn nextState( state, {\n\t\t\t\tshouldShow: true,\n\t\t\t\tshowHelp: false\n\t\t\t} );\n\t\tcase actionTypes.SETTINGS_HIDE:\n\t\t\treturn nextState( state, {\n\t\t\t\tshouldShow: false,\n\t\t\t\tshowHelp: false\n\t\t\t} );\n\t\tcase actionTypes.SETTINGS_CHANGE: {\n\t\t\tconst types = Object.keys( action.newValue ),\n\t\t\t\tnothingChanged = types\n\t\t\t\t\t.every( ( type ) => action.oldValue[ type ] === action.newValue[ type ] ),\n\t\t\t\t// Check if at least one setting has been deactivated that was active before\n\t\t\t\tuserOptedOut = types\n\t\t\t\t\t.some( ( type ) => action.oldValue[ type ] && !action.newValue[ type ] ),\n\t\t\t\t// Warning, when the state is null the user can't re-enable this popup type!\n\t\t\t\tanyDisabled = types\n\t\t\t\t\t.some( ( type ) => action.newValue[ type ] === false );\n\n\t\t\tif ( nothingChanged ) {\n\t\t\t\t// If the setting is the same, just hide the dialogs\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tshouldShow: false\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn nextState( state, {\n\t\t\t\t// If we enabled, we just hide directly, no help\n\t\t\t\t// If we disabled, keep it showing and let the ui show the help.\n\t\t\t\tshouldShow: userOptedOut,\n\t\t\t\tshowHelp: userOptedOut,\n\n\t\t\t\t// Since the footer link is only ever shown to anonymous users (see\n\t\t\t\t// the BOOT case below), state.userIsAnon is always truthy here.\n\t\t\t\tshouldShowFooterLink: anyDisabled\n\t\t\t} );\n\t\t}\n\t\tcase actionTypes.BOOT: {\n\t\t\t// Warning, when the state is null the user can't re-enable this popup type!\n\t\t\tconst anyDisabled = Object.keys( action.initiallyEnabled )\n\t\t\t\t.some( ( type ) => action.initiallyEnabled[ type ] === false );\n\n\t\t\treturn nextState( state, {\n\t\t\t\tshouldShowFooterLink: action.user.isAnon && anyDisabled\n\t\t\t} );\n\t\t}\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n","import actionTypes from './../actionTypes';\nimport nextState from './nextState';\n\n/**\n * Reducer for actions that may result in an event being logged via statsv.\n *\n * @param {Object|undefined} state\n * @param {Object} action\n * @return {Object} state after action\n */\nexport default function statsv( state, action ) {\n\tstate = state || {};\n\n\tswitch ( action.type ) {\n\t\tcase actionTypes.FETCH_START:\n\t\t\treturn nextState( state, {\n\t\t\t\tfetchStartedAt: action.timestamp\n\t\t\t} );\n\n\t\tcase actionTypes.FETCH_END:\n\t\t\treturn nextState( state, {\n\t\t\t\taction: 'timing.PagePreviewsApiResponse',\n\t\t\t\tdata: action.timestamp - state.fetchStartedAt\n\t\t\t} );\n\n\t\tcase actionTypes.FETCH_FAILED:\n\t\t\treturn nextState( state, {\n\t\t\t\taction: 'counter.PagePreviewsApiFailure',\n\t\t\t\tdata: 1\n\t\t\t} );\n\n\t\tcase actionTypes.LINK_DWELL:\n\t\t\treturn nextState( state, {\n\t\t\t\tlinkDwellStartedAt: action.timestamp\n\t\t\t} );\n\n\t\tcase actionTypes.PREVIEW_SHOW:\n\t\t\treturn nextState( state, {\n\t\t\t\taction: 'timing.PagePreviewsPreviewShow',\n\t\t\t\tdata: action.timestamp - state.linkDwellStartedAt\n\t\t\t} );\n\n\t\tcase actionTypes.STATSV_LOGGED:\n\t\t\treturn nextState( state, {\n\t\t\t\taction: null,\n\t\t\t\tdata: null\n\t\t\t} );\n\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n","/**\n * @module isReferencePreviewsEnabled\n */\nconst canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );\n\n/**\n * Given the global state of the application, creates a function that gets\n * whether or not the user should have Reference Previews enabled.\n *\n * @param {mw.user} user The `mw.user` singleton instance\n * @param {Object} userSettings An object returned by `userSettings.js`\n * @param {mw.Map} config\n *\n * @return {boolean|null} Null when there is no way the popup type can be enabled at run-time.\n */\nexport default function isReferencePreviewsEnabled( user, userSettings, config ) {\n\t// TODO: This and the final `mw.user.options` check are currently redundant. Only this here\n\t// should be removed when the feature flag is not needed any more.\n\tif ( !config.get( 'wgPopupsReferencePreviews' ) ) {\n\t\treturn null;\n\t}\n\n\t// T265872: Unavailable when in conflict with (one of the) reference tooltips gadgets.\n\tif ( config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ) ||\n\t\t// T243822: Temporarily disabled in the mobile skin\n\t\tconfig.get( 'skin' ) === 'minerva'\n\t) {\n\t\treturn null;\n\t}\n\n\t// For anonymous users, the code loads always, but the feature can be toggled at run-time via\n\t// local storage.\n\tif ( !canSaveToUserPreferences( user ) ) {\n\t\treturn userSettings.isReferencePreviewsEnabled();\n\t}\n\n\t// TODO: Remove when not in Beta any more\n\tif ( config.get( 'wgPopupsReferencePreviews' ) ) {\n\t\treturn true;\n\t}\n\n\t// Registered users never can enable popup types at run-time.\n\treturn mw.user.options.get( 'popups-reference-previews' ) === '1' ? true : null;\n}\n","/**\n * @module popups\n */\n\nimport * as Redux from 'redux';\nimport * as ReduxThunk from 'redux-thunk';\n\nimport createPagePreviewGateway from './gateway/page';\nimport createReferenceGateway from './gateway/reference';\nimport createUserSettings from './userSettings';\nimport createPreviewBehavior from './previewBehavior';\nimport createSettingsDialogRenderer from './ui/settingsDialogRenderer';\nimport registerChangeListener from './changeListener';\nimport createIsPagePreviewsEnabled from './isPagePreviewsEnabled';\nimport { fromElement as titleFromElement } from './title';\nimport { init as rendererInit, registerPreviewUI, createPagePreview,\n\tcreateDisambiguationPreview,\n\tcreateReferencePreview\n} from './ui/renderer';\nimport createExperiments from './experiments';\nimport { isEnabled as isStatsvEnabled } from './instrumentation/statsv';\nimport changeListeners from './changeListeners';\nimport * as actions from './actions';\nimport reducers from './reducers';\nimport createMediaWikiPopupsObject from './integrations/mwpopups';\nimport { previewTypes, getPreviewType,\n\tregisterModel,\n\tisAnythingEligible, findNearestEligibleTarget } from './preview/model';\nimport isReferencePreviewsEnabled from './isReferencePreviewsEnabled';\nimport setUserConfigFlags from './setUserConfigFlags';\nimport { registerGatewayForPreviewType, getGatewayForPreviewType } from './gateway';\nimport { initReferencePreviewsInstrumentation } from './instrumentation/referencePreviews';\nimport { FETCH_START_DELAY, FETCH_COMPLETE_TARGET_DELAY, FETCH_DELAY_REFERENCE_TYPE } from './constants';\n\nconst EXCLUDED_LINK_SELECTORS = [\n\t'.extiw',\n\t// ignore links that point to the same article\n\t'.mw-selflink',\n\t'.image',\n\t'.new',\n\t'.internal',\n\t'.external',\n\t'.mw-cite-backlink a',\n\t'.oo-ui-buttonedElement-button',\n\t'.ve-ce-surface a', // T259889\n\t'.cancelLink a',\n\t// T198652: lists to hash fragments are ignored.\n\t// Note links that include the path will still trigger a hover,\n\t// e.g. <a href=\"Foo#foo\"> will trigger a preview but <a href=\"#foo\"> will not.\n\t// This is intentional behaviour that will not be handled by page previews, to avoid\n\t// introducing complex behaviour. If a link must include the path it should make use of\n\t// the .mw-selflink-fragment class.\n\t'.mw-selflink-fragment',\n\t'[href^=\"#\"]'\n];\n\n/**\n * @typedef {Function} EventTracker\n *\n * An analytics event tracker, i.e. `mw.track`.\n *\n * @param {string} topic\n * @param {Object} data\n *\n * @global\n */\n\n/**\n * Gets the appropriate analytics event tracker for logging metrics to StatsD\n * via [the \"StatsD timers and counters\" analytics event protocol][0].\n *\n * If logging metrics to StatsD is enabled for the duration of the user's\n * session, then the appriopriate function is `mw.track`; otherwise it's\n * `() => {}`.\n *\n * [0]: https://github.com/wikimedia/mediawiki-extensions-WikimediaEvents/blob/29c864a0/modules/ext.wikimediaEvents.statsd.js\n *\n * @param {Object} user\n * @param {Object} config\n * @param {Experiments} experiments\n * @return {EventTracker}\n */\nfunction getStatsvTracker( user, config, experiments ) {\n\treturn isStatsvEnabled( user, config, experiments ) ? mw.track : () => {};\n}\n\n/**\n * Gets the appropriate analytics event tracker for logging virtual pageviews.\n *\n * @param {Object} config\n * @return {EventTracker}\n */\nfunction getPageviewTracker( config ) {\n\treturn config.get( 'wgPopupsVirtualPageViews' ) ? mw.track : () => {\n\t\t// NOP\n\t};\n}\n\n/**\n * Subscribes the registered change listeners to the\n * [store](http://redux.js.org/docs/api/Store.html#store).\n *\n * @param {Redux.Store} store\n * @param {Object} registerActions\n * @param {UserSettings} userSettings\n * @param {Function} settingsDialog\n * @param {PreviewBehavior} previewBehavior\n * @param {EventTracker} statsvTracker\n * @param {EventTracker} pageviewTracker\n * @return {void}\n */\nfunction registerChangeListeners(\n\tstore, registerActions, userSettings, settingsDialog, previewBehavior,\n\tstatsvTracker, pageviewTracker\n) {\n\tregisterChangeListener( store, changeListeners.footerLink( registerActions ) );\n\tregisterChangeListener( store, changeListeners.linkTitle() );\n\tregisterChangeListener( store, changeListeners.render( previewBehavior ) );\n\tregisterChangeListener(\n\t\tstore, changeListeners.statsv( registerActions, statsvTracker ) );\n\tregisterChangeListener(\n\t\tstore, changeListeners.syncUserSettings( userSettings ) );\n\tregisterChangeListener(\n\t\tstore, changeListeners.settings( registerActions, settingsDialog ) );\n\tregisterChangeListener( store,\n\t\tchangeListeners.pageviews( registerActions, pageviewTracker )\n\t);\n}\n\n/**\n * Creates an event handler that only executes if the current target\n * is eligible for page previews and a title can be associated with the element.\n *\n * @param {Function} handler\n * @return {Function}\n */\nfunction handleDOMEventIfEligible( handler ) {\n\treturn function ( event ) {\n\t\tlet target = event && event.target;\n\t\tif ( !target ) {\n\t\t\treturn;\n\t\t}\n\t\t// if the element is a text node, as events can be triggered on text nodes\n\t\t// it won't have a closest method, so we get its parent element (T340081)\n\t\tif ( target.nodeType === 3 ) {\n\t\t\ttarget = target.parentNode;\n\t\t}\n\n\t\t// If the event bubbles up all the way,\n\t\t// document does not have closest method, so exit early (T336650).\n\t\tif ( target === document ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the closest method is not defined, let's return early and\n\t\t// understand this better by logging an error. (T340081)\n\t\tif ( target && !target.closest ) {\n\t\t\tconst err = new Error( `T340081: Unexpected DOM element ${target.tagName} with nodeType ${target.nodeType}` );\n\t\t\tmw.errorLogger.logError( err, 'error.web-team' );\n\t\t\treturn;\n\t\t}\n\n\t\ttarget = findNearestEligibleTarget( target );\n\t\tif ( target === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst mwTitle = titleFromElement( target, mw.config );\n\t\tif ( mwTitle ) {\n\t\t\thandler( target, mwTitle, event );\n\t\t}\n\t};\n}\n/*\n * Initialize the application by:\n * 1. Initializing side-effects and \"services\"\n * 2. Creating the state store\n * 3. Binding the actions to such store\n * 4. Registering change listeners\n * 5. Triggering the boot action to bootstrap the system\n * 6. When the page content is ready:\n * - Initializing the renderer\n * - Binding hover and click events to the eligible links to trigger actions\n */\n( function init() {\n\tsetUserConfigFlags( mw.config );\n\n\tlet compose = Redux.compose;\n\tconst\n\t\t// So-called \"services\".\n\t\tgenerateToken = mw.user.generateRandomSessionId,\n\t\tpagePreviewGateway = createPagePreviewGateway( mw.config ),\n\t\treferenceGateway = createReferenceGateway(),\n\t\tuserSettings = createUserSettings( mw.storage ),\n\t\treferencePreviewsState = isReferencePreviewsEnabled( mw.user, userSettings, mw.config ),\n\t\tsettingsDialog = createSettingsDialogRenderer( referencePreviewsState !== null ),\n\t\texperiments = createExperiments( mw.experiments ),\n\t\tstatsvTracker = getStatsvTracker( mw.user, mw.config, experiments ),\n\t\tpageviewTracker = getPageviewTracker( mw.config ),\n\t\tinitiallyEnabled = {\n\t\t\t[ previewTypes.TYPE_PAGE ]:\n\t\t\t\tcreateIsPagePreviewsEnabled( mw.user, userSettings, mw.config ),\n\t\t\t[ previewTypes.TYPE_REFERENCE ]: referencePreviewsState\n\t\t};\n\n\t// If debug mode is enabled, then enable Redux DevTools.\n\tif ( mw.config.get( 'debug' ) ||\n\t\t/* global process */\n\t\tprocess.env.NODE_ENV !== 'production' ) {\n\t\t// eslint-disable-next-line no-underscore-dangle\n\t\tcompose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n\t}\n\n\tconst store = Redux.createStore(\n\t\tRedux.combineReducers( reducers ),\n\t\tcompose( Redux.applyMiddleware(\n\t\t\tReduxThunk.default\n\t\t) )\n\t);\n\tconst boundActions = Redux.bindActionCreators( actions, store.dispatch );\n\tconst previewBehavior = createPreviewBehavior( mw.user, boundActions );\n\n\tregisterChangeListeners(\n\t\tstore, boundActions, userSettings, settingsDialog,\n\t\tpreviewBehavior, statsvTracker, pageviewTracker\n\t);\n\n\tboundActions.boot(\n\t\tinitiallyEnabled,\n\t\tmw.user,\n\t\tuserSettings,\n\t\tmw.config,\n\t\twindow.location.href\n\t);\n\n\t/*\n\t * Register external interface exposing popups internals so that other\n\t * extensions can query it (T171287)\n\t */\n\tmw.popups = createMediaWikiPopupsObject(\n\t\tstore, registerModel, registerPreviewUI, registerGatewayForPreviewType\n\t);\n\n\tif ( initiallyEnabled[ previewTypes.TYPE_PAGE ] !== null ) {\n\t\tconst excludedLinksSelector = EXCLUDED_LINK_SELECTORS.join( ', ' );\n\t\t// Register default preview type\n\t\tmw.popups.register( {\n\t\t\ttype: previewTypes.TYPE_PAGE,\n\t\t\tselector: `#mw-content-text a[href][title]:not(${excludedLinksSelector})`,\n\t\t\tdelay: FETCH_COMPLETE_TARGET_DELAY - FETCH_START_DELAY,\n\t\t\tgateway: pagePreviewGateway,\n\t\t\trenderFn: createPagePreview,\n\t\t\tsubTypes: [\n\t\t\t\t{\n\t\t\t\t\ttype: previewTypes.TYPE_DISAMBIGUATION,\n\t\t\t\t\trenderFn: createDisambiguationPreview\n\t\t\t\t}\n\t\t\t]\n\t\t} );\n\t}\n\tif ( initiallyEnabled[ previewTypes.TYPE_REFERENCE ] !== null ) {\n\t\t// Register the reference preview type\n\t\tmw.popups.register( {\n\t\t\ttype: previewTypes.TYPE_REFERENCE,\n\t\t\tselector: '#mw-content-text .reference a[ href*=\"#\" ]',\n\t\t\tdelay: FETCH_DELAY_REFERENCE_TYPE,\n\t\t\tgateway: referenceGateway,\n\t\t\trenderFn: createReferencePreview,\n\t\t\tinit: () => {\n\t\t\t\tinitReferencePreviewsInstrumentation();\n\t\t\t}\n\t\t} );\n\t}\n\tif ( !isAnythingEligible() ) {\n\t\tmw.log.warn( 'ext.popups was loaded but everything is disabled' );\n\t\treturn;\n\t}\n\n\trendererInit();\n\n\t/*\n\t * Binding hover and click events to the eligible links to trigger actions\n\t */\n\tfunction setupEventListeners() {\n\t\tconst onHover = handleDOMEventIfEligible( function ( target, mwTitle, event ) {\n\t\t\tconst type = getPreviewType( target );\n\t\t\tconst gateway = getGatewayForPreviewType( type );\n\t\t\tif ( !gateway ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst scrollTop = window.scrollY;\n\t\t\tconst bbox = target.getBoundingClientRect();\n\t\t\tconst offset = {\n\t\t\t\ttop: scrollTop + bbox.y,\n\t\t\t\tleft: window.scrollX + bbox.x\n\t\t\t};\n\t\t\tconst measures = {\n\t\t\t\tpageX: event.pageX,\n\t\t\t\tpageY: event.pageY,\n\t\t\t\tclientY: event.clientY,\n\t\t\t\twidth: target.offsetWidth,\n\t\t\t\theight: target.offsetHeight,\n\t\t\t\toffset,\n\t\t\t\tclientRects: target.getClientRects(),\n\t\t\t\twindowWidth: window.innerWidth,\n\t\t\t\twindowHeight: window.innerHeight,\n\t\t\t\tscrollTop\n\t\t\t};\n\n\t\t\tboundActions.linkDwell( mwTitle, target, measures, gateway, generateToken, type );\n\t\t} );\n\t\tconst onHoverOut = handleDOMEventIfEligible( function () {\n\t\t\tboundActions.abandon();\n\t\t} );\n\t\tconst onClick = handleDOMEventIfEligible( function ( target ) {\n\t\t\tif ( previewTypes.TYPE_PAGE === getPreviewType( target ) ) {\n\t\t\t\tboundActions.linkClick( target );\n\t\t\t}\n\t\t} );\n\t\tdocument.addEventListener( 'mouseover', onHover );\n\t\tdocument.addEventListener( 'keyup', onHover );\n\t\tdocument.addEventListener( 'mouseout', onHoverOut );\n\t\tdocument.addEventListener( 'blur', onHoverOut );\n\t\tdocument.addEventListener( 'click', onClick );\n\t}\n\tsetupEventListeners();\n}() );\n\nwindow.Redux = Redux;\nwindow.ReduxThunk = ReduxThunk;\n","/**\n * @module setUserConfigFlags\n */\n\n/**\n * Same as in includes/PopupsContext.php\n */\nconst NAV_POPUPS_ENABLED = 1,\n\tREF_TOOLTIPS_ENABLED = 2,\n\tREFERENCE_PREVIEWS_ENABLED = 4,\n\tREFERENCE_PREVIEWS_BETA = 8;\n\n/**\n * Decodes the bitmask that represents preferences to the related config options.\n *\n * @param {mw.Map} config\n */\nexport default function setUserConfigFlags( config ) {\n\tconst popupsFlags = parseInt( config.get( 'wgPopupsFlags' ), 10 );\n\n\t/* eslint-disable no-bitwise */\n\tconfig.set(\n\t\t'wgPopupsConflictsWithNavPopupGadget',\n\t\t!!( popupsFlags & NAV_POPUPS_ENABLED )\n\t);\n\tconfig.set(\n\t\t'wgPopupsConflictsWithRefTooltipsGadget',\n\t\t!!( popupsFlags & REF_TOOLTIPS_ENABLED )\n\t);\n\tconfig.set(\n\t\t'wgPopupsReferencePreviews',\n\t\t!!( popupsFlags & REFERENCE_PREVIEWS_ENABLED )\n\t);\n\tconfig.set(\n\t\t'wgPopupsReferencePreviewsBetaFeature',\n\t\t!!( popupsFlags & REFERENCE_PREVIEWS_BETA )\n\t);\n\t/* eslint-enable no-bitwise */\n}\n","/**\n * @module experiments\n */\n\n/**\n * @interface Experiments\n *\n * @global\n */\n\n/**\n * Creates a helper wrapper for the MediaWiki-provided\n * `mw.experiments#getBucket` bucketing function.\n *\n * @param {mw.experiments} mwExperiments The `mw.experiments` singleton instance\n * @return {Experiments}\n */\nexport default function createExperiments( mwExperiments ) {\n\treturn {\n\t\t/**\n\t\t * Gets whether something is true given a name and a token.\n\t\t *\n\t\t * @example\n\t\t * import createExperiments from './src/experiments';\n\t\t * const experiments = createExperiments( mw.experiments );\n\t\t * const isFooEnabled = experiments.weightedBoolean(\n\t\t * 'foo',\n\t\t * 10 / 100, // 10% of all unique tokens should have foo enabled.\n\t\t * token\n\t\t * );\n\t\t *\n\t\t * @method\n\t\t * @name Experiments#weightedBoolean\n\t\t * @param {string} name The name of the thing. Since this is used as the\n\t\t * name of the underlying experiment it should be unique to reduce the\n\t\t * likelihood of collisions with other enabled experiments\n\t\t * @param {number} trueWeight A number between 0 and 1, representing the\n\t\t * probability of the thing being true\n\t\t * @param {string} token A token associated with the user for the duration\n\t\t * of the experiment\n\t\t * @return {boolean}\n\t\t */\n\t\tweightedBoolean( name, trueWeight, token ) {\n\t\t\treturn mwExperiments.getBucket( {\n\t\t\t\tenabled: true,\n\n\t\t\t\tname,\n\t\t\t\tbuckets: {\n\t\t\t\t\ttrue: trueWeight,\n\t\t\t\t\tfalse: 1 - trueWeight\n\t\t\t\t}\n\t\t\t}, token ) === 'true';\n\t\t}\n\t};\n}\n","/**\n * @module userSettings\n */\n\n/**\n * @interface UserSettings\n *\n * @global\n */\n\nconst PAGE_PREVIEWS_ENABLED_KEY = 'mwe-popups-enabled',\n\tREFERENCE_PREVIEWS_ENABLED_KEY = 'mwe-popups-referencePreviews-enabled',\n\tREFERENCE_PREVIEWS_LOGGING_SCHEMA = 'event.ReferencePreviewsPopups';\n\n/**\n * Creates an object whose methods encapsulate all interactions with the UA's\n * storage.\n *\n * @param {mw.storage} storage The `mw.storage` singleton instance\n *\n * @return {UserSettings}\n */\nexport default function createUserSettings( storage ) {\n\treturn {\n\t\t/**\n\t\t * Gets whether the user has previously enabled Page Previews.\n\t\t *\n\t\t * N.B. that if the user hasn't previously enabled or disabled Page\n\t\t * Previews, i.e. userSettings.storePagePreviewsEnabled(true), then they are treated as\n\t\t * if they have enabled them.\n\t\t *\n\t\t * @method\n\t\t * @name UserSettings#isPagePreviewsEnabled\n\t\t * @return {boolean}\n\t\t */\n\t\tisPagePreviewsEnabled() {\n\t\t\treturn storage.get( PAGE_PREVIEWS_ENABLED_KEY ) !== '0';\n\t\t},\n\n\t\t/**\n\t\t * Permanently persists (typically in localStorage) whether the user has enabled Page\n\t\t * Previews.\n\t\t *\n\t\t * @method\n\t\t * @name UserSettings#storePagePreviewsEnabled\n\t\t * @param {boolean} enabled\n\t\t */\n\t\tstorePagePreviewsEnabled( enabled ) {\n\t\t\tif ( enabled ) {\n\t\t\t\tstorage.remove( PAGE_PREVIEWS_ENABLED_KEY );\n\t\t\t} else {\n\t\t\t\tstorage.set( PAGE_PREVIEWS_ENABLED_KEY, '0' );\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * @method\n\t\t * @name UserSettings#isReferencePreviewsEnabled\n\t\t * @return {boolean}\n\t\t */\n\t\tisReferencePreviewsEnabled() {\n\t\t\treturn storage.get( REFERENCE_PREVIEWS_ENABLED_KEY ) !== '0';\n\t\t},\n\n\t\t/**\n\t\t * @method\n\t\t * @name UserSettings#storeReferencePreviewsEnabled\n\t\t * @param {boolean} enabled\n\t\t */\n\t\tstoreReferencePreviewsEnabled( enabled ) {\n\t\t\tif ( enabled ) {\n\t\t\t\tstorage.remove( REFERENCE_PREVIEWS_ENABLED_KEY );\n\t\t\t} else {\n\t\t\t\tstorage.set( REFERENCE_PREVIEWS_ENABLED_KEY, '0' );\n\t\t\t}\n\n\t\t\tmw.track( REFERENCE_PREVIEWS_LOGGING_SCHEMA, {\n\t\t\t\taction: enabled ? 'anonymousEnabled' : 'anonymousDisabled'\n\t\t\t} );\n\t\t}\n\t};\n}\n","/**\n * @module instrumentation/statsv\n */\n\n/**\n * Gets whether Graphite logging (via [the statsv HTTP endpoint][0]) is enabled\n * for the duration of the user's session. The bucketing rate is controlled by\n * `wgPopupsStatsvSamplingRate`.\n *\n * [0]: https://wikitech.wikimedia.org/wiki/Graphite#statsv\n *\n * @param {mw.user} user The `mw.user` singleton instance\n * @param {mw.Map} config The `mw.config` singleton instance\n * @param {Experiments} experiments\n * @return {boolean}\n */\nexport function isEnabled( user, config, experiments ) {\n\tconst bucketingRate = config.get( 'wgPopupsStatsvSamplingRate', 0 );\n\n\treturn experiments.weightedBoolean(\n\t\t'ext.Popups.statsv',\n\t\tbucketingRate,\n\t\tuser.sessionId()\n\t);\n}\n","/**\n * @module MediaWiki-Popups Integration\n */\n\nimport { previewTypes } from '../preview/model';\n\n/**\n * This function provides a mw.popups object which can be used by 3rd party\n * to interact with Popups.\n *\n * @param {Redux.Store} store Popups store\n * @param {Function} registerModel allows extensions to register custom preview handlers.\n * @param {Function} registerPreviewUI allows extensions to register custom preview renderers.\n * @param {Function} registerGatewayForPreviewType allows extensions to register gateways for preview types.\n * @return {Object} external Popups interface\n */\nexport default function createMwPopups( store, registerModel, registerPreviewUI, registerGatewayForPreviewType ) {\n\treturn {\n\t\t/**\n\t\t * @return {boolean} If Page Previews are currently active\n\t\t */\n\t\tisEnabled: function isEnabled() {\n\t\t\treturn store.getState().preview.enabled[ previewTypes.TYPE_PAGE ];\n\t\t},\n\t\t/**\n\t\t * @stable Do not remove properties in the type PopupModule without providing backwards\n\t\t * compatibility and code that handles migrations.\n\t\t *\n\t\t * @typedef {Object} PopupSubtype\n\t\t * @property {string} type A unique string for identifying the subtype of a page preview\n\t\t * @property {function(ext.popups.PreviewModel): ext.popups.Preview}[renderFn] How the custom preview type will render the preview.\n\t\t * If not provided default renderer is used.\n\t\t *\n\t\t * @typedef {Object} PopupModule\n\t\t * @property {string} type A unique string for identifying the type of page preview\n\t\t * @property {string} selector A CSS selector which identifies elements that will display this type of page preview\n\t\t * @property {Gateway} gateway A Gateway for obtaining the preview data.\n\t\t * @property {function(ext.popups.PreviewModel): ext.popups.Preview}[renderFn] How the custom preview type will render the preview.\n\t\t * If not provided default renderer is used.\n\t\t * @property {PopupSubtype[]} subTypes this is for registering types that are subsets of the current type e.g. share the same selector.\n\t\t * @property {number} [delay] optional delay between hovering and displaying preview.\n\t\t * If not defined, delay will be zero.\n\t\t */\n\t\t/**\n\t\t * Register a custom preview type.\n\t\t *\n\t\t * @internal for use inside Extension:Popups only. If you want to register a preview\n\t\t * type, please define `attributes` key in Extension:Popups like so:\n\t\t * ```\n\t\t * \"attributes\": {\n\t\t * \"Popups\": {\n\t\t * \"PluginModules\": [\n\t\t * \"modulename\"\n\t\t * ]\n\t\t * }\n\t\t * ```\n\t\t *\n\t\t * @unstable\n\t\t * @param {PopupModule} module\n\t\t */\n\t\tregister: function ( module ) {\n\t\t\tconst { type, selector, gateway, renderFn, subTypes, delay, init } = module;\n\t\t\tif ( !type || !selector || !gateway ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Registration of Popups custom preview type \"${type}\" failed: You must specify a type, a selector, and a gateway.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tregisterModel( type, selector, delay );\n\t\t\tregisterGatewayForPreviewType( type, gateway );\n\t\t\tregisterPreviewUI( type, renderFn );\n\t\t\tif ( subTypes ) {\n\t\t\t\tsubTypes.forEach( function ( subTypePreview ) {\n\t\t\t\t\tregisterPreviewUI( subTypePreview.type, subTypePreview.renderFn );\n\t\t\t\t} );\n\t\t\t}\n\t\t\t// Run initialization function if provided.\n\t\t\tif ( typeof init === 'function' ) {\n\t\t\t\tinit();\n\t\t\t}\n\t\t}\n\t};\n}\n","module.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>\""],"sourceRoot":""} |