mediawiki-extensions-Popups/resources/dist/index.js.json
Stephen Niedzielski c4b50b04ac Hygiene: remove unused resources
In I7395e3438836149becdd576942bdaf6f21b4163f the settings templates
were rewritten so that they no longer displayed an image.

descriptionText and images were dropped from the template but not from
the template provider. These are artifacts from relating to that patch
and are no longer used.

Change-Id: I1be7ef288d37f338e83dab3cf041e628a06608d2
2018-03-21 17:07:18 -05:00

1 line
170 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"sources":["/w/extensions/Popups/webpack/bootstrap","/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/./src/counts.js","/w/extensions/Popups/./src/constants.js","/w/extensions/Popups/./src/preview/model.js","/w/extensions/Popups/./src/formatter.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/index.js","/w/extensions/Popups/./src/userSettings.js","/w/extensions/Popups/./src/previewBehavior.js","/w/extensions/Popups/./src/ui/templates/templateUtil.js","/w/extensions/Popups/./src/ui/templates/settingsDialog.js","/w/extensions/Popups/./src/ui/settingsDialog.js","/w/extensions/Popups/./src/ui/settingsDialogRenderer.js","/w/extensions/Popups/./src/changeListener.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/preview.js","/w/extensions/Popups/./src/ui/renderer.js","/w/extensions/Popups/./src/ui/templates/pagePreview.js","/w/extensions/Popups/./src/changeListeners/footerLink.js","/w/extensions/Popups/./src/changeListeners/eventLogging.js","/w/extensions/Popups/./src/changeListeners/linkTitle.js","/w/extensions/Popups/./src/changeListeners/syncUserSettings.js","/w/extensions/Popups/./src/changeListeners/index.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/eventLogging.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/getUserBucket.js","/w/extensions/Popups/./src/index.js","/w/extensions/Popups/./src/instrumentation/eventLogging.js","/w/extensions/Popups/./src/experiments.js","/w/extensions/Popups/./src/instrumentation/statsv.js","/w/extensions/Popups/./src/isEnabled.js","/w/extensions/Popups/./src/integrations/mwpopups.js","/w/extensions/Popups/./src/ui/pokey-mask.svg"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","r","value","n","__esModule","object","property","prototype","hasOwnProperty","p","s","t","e","id","loaded","dispatch","getState","withExtraArgument","default","compose","applyMiddleware","bindActionCreators","combineReducers","createStore","u","a","f","y","arguments","length","Array","slice","reduceRight","apply","ActionTypes","b","h","v","Error","push","indexOf","splice","type","INIT","subscribe","replaceReducer","next","TypeError","unsubscribe","this","console","error","Function","toString","constructor","assign","map","keys","forEach","Math","random","substring","split","join","getPrototypeOf","window","Symbol","observable","getEditCountBucket","count","bucket","getPreviewCountBucket","undefined","constants_$","jQuery","BUCKETS","off","on","control","constants","THUMBNAIL_SIZE","bracketedDevicePixelRatio","EXTRACT_LENGTH","previewTypes","TYPE_GENERIC","TYPE_PAGE","TYPE_DISAMBIGUATION","createModel","title","url","languageCode","languageDirection","extract","thumbnail","pageId","processedExtract","processExtract","getPreviewType","createNullModel","formatter_$","formatter_mw","mediaWiki","formatter_formatPlainTextExtract","plainTextExtract","elements","boldIdentifier","snip","replace","trim","escapedTitle","RegExp","escape","regExp","part","text","document","createTextNode","makeTitleInExtractBold","mediawiki_CACHE_LIFETIME","mediawiki_$","mediawiki_extractPageFromResponse","data","query","pages","mediawiki_formatPlainTextExtract","result","extend","mediawiki_convertPageToModel","page","canonicalurl","pagelanguagehtmlcode","pagelanguagedir","pageid","rest_RESTBASE_PROFILE","rest_mw","rest_$","rest_createRESTBaseGateway","ajax","config","extractParser","fetch","endpoint","encodeURIComponent","headers","Accept","convertPageToModel","rest_convertPageToModel","getPageSummary","Deferred","then","resolve","jqXHR","textStatus","errorThrown","status","Title","getUrl","reject","xhr","exception","promise","thumbSize","lang","dir","original","parts","source","lastPart","filenamePxIndex","filename","substr","width","height","floor","rest_generateThumbnailData","originalimage","restFormatters_parseHTMLResponse","extract_html","$","parseHTML","restFormatters_parsePlainTextResponse","gateway_mw","gateway_$","gateway_createGateway","restConfig","api","action","prop","formatversion","redirects","exintro","exchars","explaintext","piprop","pithumbsize","pilicense","rvprop","inprop","titles","smaxage","maxage","uselang","X-Analytics","extractPageFromResponse","formatPlainTextExtract","mediawiki_createMediaWikiApiGateway","Api","IS_ENABLED_KEY","PREVIEW_COUNT_KEY","previewBehavior_mw","previewBehavior_$","templateUtil_mw","escapeHTML","str","html","settingsDialog_renderSettingsDialog","model","heading","saveLabel","closeLabel","helpText","okLabel","_ref","description","isChecked","settingsDialog_escapeChoices","choices","_ref2","settingsDialog_mw","settingsDialogRenderer_$","settingsDialogRenderer_createSettingsDialogRenderer","$dialog","$overlay","boundActions","navPopupsEnabled","settingsDialogRenderer_isNavPopupsEnabled","msg","addClass","find","click","enabled","val","saveSettings","hideSettings","appendTo","el","show","hide","toggleHelp","visible","$el","settingsDialogRenderer_toggleHelp","setEnabled","pg","fn","disablePopups","registerChangeListener","store","callback","state","prevState","title_mw","fromElement","contentNamespaces","mwTitle","newFromText","inArray","namespace","isValid","href","titleRegex","linkHref","Uri","host","location","hostname","queryLength","matches","exec","path","decodeURIComponent","getTitle","wait_$","wait","delay","setTimeout","SIZES","portraitImage","w","landscapeImage","thumbnail_$","createThumbnail","rawThumbnail","devicePixelRatio","tall","thumbWidth","thumbHeight","x","clipPath","className","thumbnailWidth","thumbnailHeight","nsSvg","$thumbnailSVGImage","createElementNS","setAttributeNS","attr","clip-path","xmlns","append","createThumbnailElement","isTall","preview_renderPreview","showTitle","extractMsg","linkMsg","renderer_mw","renderer_$","renderer_$window","renderer_landscapePopupWidth","renderer_portraitPopupWidth","renderer_pokeySize","renderer_init","container","body","pokey_mask_default","renderer_render","preview","hasThumbnail","renderPagePreview","renderer_createPagePreview","renderer_createDisambiguationPreview","renderer_createEmptyPreview","renderer_createPreviewWithType","event","token","$link","behavior","layout","isPreviewTall","eventData","linkData","windowData","pokeySize","flippedX","flippedY","offsetTop","pageY","renderer_getClosestYPosition","scrollTop","clientRects","offset","top","offsetLeft","pageX","left","clientTop","clientY","renderer_createLayout","getClientRects","classes","predefinedLandscapeImageHeight","popup","css","outerHeight","removeAttribute","setAttribute","removeClass","renderer_layoutPreview","renderer_getClasses","previewDwell","previewAbandon","settingsUrl","stopPropagation","showSettings","renderer_bindBehavior","previewShow","renderer_show","target","fadeInClass","hasClass","fadeOutClass","remove","renderer_hide","rects","isTop","minY","rect","deltaY","abs","bottom","ceil","footerLink_mw","footerLink_$","eventLogging_$","linkTitle_$","reducer","syncIfChanged","sync","current","changeListeners","footerLink","$footerLink","message","$footer","parent","createFooterLink","preventDefault","settings","shouldShowFooterLink","eventLogging","eventLoggingTracker","getCurrentTimestamp","_","baseData","timestamp","eventLogged","linkTitle","hasPrevActiveLink","activeLink","destroyTitleAttr","pageviews","pageviewTracker","pageview","source_page_id","source_namespace","namespaceId","source_title","source_url","pageviewLogged","render","previewBehavior","shouldShow","fetchResponse","activeEvent","activeToken","showHelp","statsv","track","statsvLogged","syncUserSettings","userSettings","setPreviewCount","setIsEnabled","actionTypes","BOOT","LINK_DWELL","ABANDON_START","ABANDON_END","LINK_CLICK","FETCH_START","FETCH_END","FETCH_COMPLETE","FETCH_FAILED","PAGEVIEW_LOGGED","PREVIEW_DWELL","PREVIEW_SHOW","PREVIEW_CLICK","PREVIEW_SEEN","SETTINGS_SHOW","SETTINGS_HIDE","SETTINGS_CHANGE","EVENT_LOGGED","STATSV_LOGGED","actions_$","actions_mw","actions_FETCH_START_DELAY","actions_PREVIEW_SEEN_DURATION","actions_FETCH_COMPLETE_TARGET_DELAY","actions_ABANDON_END_DELAY","actions_timedAction","baseAction","now","actions_boot","isEnabled","user","generateToken","editCount","previewCount","getPreviewCount","isNavPopupsEnabled","sessionToken","sessionId","pageToken","isAnon","actions_fetch","gateway","titleText","getPrefixedDb","request","catch","err","when","readyState","actions_linkDwell","isNewInteraction","actions_abandon","actions_linkClick","actions_previewDwell","actions_previewShow","currentToken","validType","actions_pageviewLogged","actions_showSettings","actions_hideSettings","actions_saveSettings","wasEnabled","actions_eventLogged","actions_statsvLogged","nextState","updates","key","eventLogging_createEvent","interaction","actionData","linkInteractionToken","pageTitleHover","namespaceIdHover","timeToPreviewShow","previewType","perceivedWait","eventLogging_createClosingEvent","totalInteractionTime","round","finished","started","finalized","reducers","bootAction","nextCount","newState","actionTypesWithTokens","pageTitleSource","namespaceIdSource","pageIdSource","popupEnabled","previewCountBucket","counts","hovercardsSuppressedByGadget","editCountBucket","link","isUserDwelling","page_title","page_id","page_namespace","fetchStartedAt","linkDwellStartedAt","src_getUserBucket","experiments","experimentGroupSize","getBucket","buckets","src_mw","src_$","src_BLACKLISTED_LINKS","src_getEventLoggingTracker","navigator","isFunction","sendBeacon","eventLogging_isEnabled","noop","src_getCurrentTimestamp","performance","requestIdleCallback","storage","mwExperiments","redux_min","generateRandomSessionId","userBucket","getIsEnabled","set","hasIsEnabled","Boolean","parseInt","isNaN","settingsDialog","weightedBoolean","trueWeight","true","false","statsvTracker","bucketingRate","statsv_isEnabled","src_getStatsvTracker","isEnabled_isEnabled","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","redux_thunk_min_default","actions_namespaceObject","actions","isBetaFeature","rawTitle","abandon","linkClick","createPreviewBehavior","src_registerChangeListeners","boot","popups","createMwPopups","hook","add","$container","validLinkSelector","linkDwell","Redux","ReduxThunk","redux_thunk_min"],"mappings":"aACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,GAAA,EACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAAb,EAAAS,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAjB,GACAY,OAAAC,eAAAb,EAAA,cAAiDkB,OAAA,KAIjDpB,EAAAqB,EAAA,SAAAlB,GACA,IAAAS,EAAAT,KAAAmB,WACA,WAA2B,OAAAnB,EAAA,SAC3B,WAAiC,OAAAA,GAEjC,OADAH,EAAAU,EAAAE,EAAA,IAAAA,GACAA,GAIAZ,EAAAa,EAAA,SAAAU,EAAAC,GAAsD,OAAAV,OAAAW,UAAAC,eAAAnB,KAAAgB,EAAAC,IAGtDxB,EAAA2B,EAAA,GAIA3B,IAAA4B,EAAA,yFCnEezB,EAAAD,QAA0M,SAAA2B,GAAmB,SAAAC,EAAAjB,GAAc,GAAAQ,EAAAR,GAAA,OAAAQ,EAAAR,GAAAX,QAA4B,IAAAiB,EAAAE,EAAAR,IAAYX,WAAU6B,GAAAlB,EAAAmB,QAAA,GAAiB,OAAAH,EAAAhB,GAAAN,KAAAY,EAAAjB,QAAAiB,IAAAjB,QAAA4B,GAAAX,EAAAa,QAAA,EAA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,EAAauW,UAAW/hB,YAM7BgB,OAAO0hB,MAAQrC,EACfrf,OAAO2hB,WAAaC,2CM9QpB5mB,EAAAD,QAAA","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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\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(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(t,e){\"object\"==typeof exports&&\"object\"==typeof module?module.exports=e():\"function\"==typeof define&&define.amd?define([],e):\"object\"==typeof exports?exports.Redux=e():t.Redux=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p=\"\",e(0)}([function(t,e,n){\"use strict\";function r(t){return t&&t.__esModule?t:{\"default\":t}}e.__esModule=!0,e.compose=e.applyMiddleware=e.bindActionCreators=e.combineReducers=e.createStore=void 0;var o=n(2),u=r(o),i=n(7),c=r(i),a=n(6),f=r(a),s=n(5),d=r(s),l=n(1),p=r(l),y=n(3);r(y);e.createStore=u[\"default\"],e.combineReducers=c[\"default\"],e.bindActionCreators=f[\"default\"],e.applyMiddleware=d[\"default\"],e.compose=p[\"default\"]},function(t,e){\"use strict\";function n(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];if(0===e.length)return function(t){return t};if(1===e.length)return e[0];var r=e[e.length-1],o=e.slice(0,-1);return function(){return o.reduceRight(function(t,e){return e(t)},r.apply(void 0,arguments))}}e.__esModule=!0,e[\"default\"]=n},function(t,e,n){\"use strict\";function r(t){return t&&t.__esModule?t:{\"default\":t}}function o(t,e,n){function r(){b===h&&(b=h.slice())}function u(){return v}function c(t){if(\"function\"!=typeof t)throw Error(\"Expected listener to be a function.\");var e=!0;return r(),b.push(t),function(){if(e){e=!1,r();var n=b.indexOf(t);b.splice(n,1)}}}function s(t){if(!(0,i[\"default\"])(t))throw Error(\"Actions must be plain objects. Use custom middleware for async actions.\");if(void 0===t.type)throw Error('Actions may not have an undefined \"type\" property. Have you misspelled a constant?');if(m)throw Error(\"Reducers may not dispatch actions.\");try{m=!0,v=y(v,t)}finally{m=!1}for(var e=h=b,n=0;e.length>n;n++)e[n]();return t}function d(t){if(\"function\"!=typeof t)throw Error(\"Expected the nextReducer to be a function.\");y=t,s({type:f.INIT})}function l(){var t,e=c;return t={subscribe:function(t){function n(){t.next&&t.next(u())}if(\"object\"!=typeof t)throw new TypeError(\"Expected the observer to be an object.\");n();var r=e(n);return{unsubscribe:r}}},t[a[\"default\"]]=function(){return this},t}var p;if(\"function\"==typeof e&&void 0===n&&(n=e,e=void 0),void 0!==n){if(\"function\"!=typeof n)throw Error(\"Expected the enhancer to be a function.\");return n(o)(t,e)}if(\"function\"!=typeof t)throw Error(\"Expected the reducer to be a function.\");var y=t,v=e,h=[],b=h,m=!1;return s({type:f.INIT}),p={dispatch:s,subscribe:c,getState:u,replaceReducer:d},p[a[\"default\"]]=l,p}e.__esModule=!0,e.ActionTypes=void 0,e[\"default\"]=o;var u=n(4),i=r(u),c=n(12),a=r(c),f=e.ActionTypes={INIT:\"@@redux/INIT\"}},function(t,e){\"use strict\";function n(t){\"undefined\"!=typeof console&&\"function\"==typeof console.error&&console.error(t);try{throw Error(t)}catch(e){}}e.__esModule=!0,e[\"default\"]=n},function(t,e,n){function r(t){if(!i(t)||p.call(t)!=c||u(t))return!1;var e=o(t);if(null===e)return!0;var n=d.call(e,\"constructor\")&&e.constructor;return\"function\"==typeof n&&n instanceof n&&s.call(n)==l}var o=n(8),u=n(9),i=n(11),c=\"[object Object]\",a=Function.prototype,f=Object.prototype,s=a.toString,d=f.hasOwnProperty,l=s.call(Object),p=f.toString;t.exports=r},function(t,e,n){\"use strict\";function r(t){return t&&t.__esModule?t:{\"default\":t}}function o(){for(var t=arguments.length,e=Array(t),n=0;t>n;n++)e[n]=arguments[n];return function(t){return function(n,r,o){var i=t(n,r,o),a=i.dispatch,f=[],s={getState:i.getState,dispatch:function(t){return a(t)}};return f=e.map(function(t){return t(s)}),a=c[\"default\"].apply(void 0,f)(i.dispatch),u({},i,{dispatch:a})}}}e.__esModule=!0;var u=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};e[\"default\"]=o;var i=n(1),c=r(i)},function(t,e){\"use strict\";function n(t,e){return function(){return e(t.apply(void 0,arguments))}}function r(t,e){if(\"function\"==typeof t)return n(t,e);if(\"object\"!=typeof t||null===t)throw Error(\"bindActionCreators expected an object or a function, instead received \"+(null===t?\"null\":typeof t)+'. Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?');for(var r=Object.keys(t),o={},u=0;r.length>u;u++){var i=r[u],c=t[i];\"function\"==typeof c&&(o[i]=n(c,e))}return o}e.__esModule=!0,e[\"default\"]=r},function(t,e,n){\"use strict\";function r(t){return t&&t.__esModule?t:{\"default\":t}}function o(t,e){var n=e&&e.type,r=n&&'\"'+n+'\"'||\"an action\";return\"Given action \"+r+', reducer \"'+t+'\" returned undefined. To ignore an action, you must explicitly return the previous state.'}function u(t){Object.keys(t).forEach(function(e){var n=t[e],r=n(void 0,{type:c.ActionTypes.INIT});if(void 0===r)throw Error('Reducer \"'+e+'\" 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.');var o=\"@@redux/PROBE_UNKNOWN_ACTION_\"+Math.random().toString(36).substring(7).split(\"\").join(\".\");if(void 0===n(void 0,{type:o}))throw Error('Reducer \"'+e+'\" returned undefined when probed with a random type. '+(\"Don't try to handle \"+c.ActionTypes.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.\")})}function i(t){for(var e=Object.keys(t),n={},r=0;e.length>r;r++){var i=e[r];\"function\"==typeof t[i]&&(n[i]=t[i])}var c,a=Object.keys(n);try{u(n)}catch(f){c=f}return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];if(c)throw c;for(var r=!1,u={},i=0;a.length>i;i++){var f=a[i],s=n[f],d=t[f],l=s(d,e);if(void 0===l){var p=o(f,e);throw Error(p)}u[f]=l,r=r||l!==d}return r?u:t}}e.__esModule=!0,e[\"default\"]=i;var c=n(2),a=n(4),f=(r(a),n(3));r(f)},function(t,e,n){var r=n(10),o=r(Object.getPrototypeOf,Object);t.exports=o},function(t,e){function n(t){var e=!1;if(null!=t&&\"function\"!=typeof t.toString)try{e=!!(t+\"\")}catch(n){}return e}t.exports=n},function(t,e){function n(t,e){return function(n){return t(e(n))}}t.exports=n},function(t,e){function n(t){return!!t&&\"object\"==typeof t}t.exports=n},function(t,e,n){t.exports=n(13)},function(t,e,n){(function(t){\"use strict\";function r(t){return t&&t.__esModule?t:{\"default\":t}}Object.defineProperty(e,\"__esModule\",{value:!0});var o=n(14),u=r(o),i=void 0;void 0!==t?i=t:\"undefined\"!=typeof window&&(i=window);var c=(0,u[\"default\"])(i);e[\"default\"]=c}).call(e,function(){return this}())},function(t,e){\"use strict\";function n(t){var e,n=t.Symbol;return\"function\"==typeof n?n.observable?e=n.observable:(e=n(\"observable\"),n.observable=e):e=\"@@observable\",e}Object.defineProperty(e,\"__esModule\",{value:!0}),e[\"default\"]=n}])});","/**\n * @module counts\n */\n\n/**\n * Gets the count bucket for the number of edits a user has made.\n *\n * The buckets are defined as part of\n * [the Popups schema](https://meta.wikimedia.org/wiki/Schema:Popups).\n *\n * Extracted from `mw.popups.schemaPopups.getEditCountBucket`.\n *\n * @param {Number} count\n * @return {String}\n */\nexports.getEditCountBucket = function getEditCountBucket( count ) {\n\tlet bucket;\n\n\tif ( count === 0 ) {\n\t\tbucket = '0';\n\t} else if ( count >= 1 && count <= 4 ) {\n\t\tbucket = '1-4';\n\t} else if ( count >= 5 && count <= 99 ) {\n\t\tbucket = '5-99';\n\t} else if ( count >= 100 && count <= 999 ) {\n\t\tbucket = '100-999';\n\t} else if ( count >= 1000 ) {\n\t\tbucket = '1000+';\n\t}\n\n\treturn `${ bucket } edits`;\n};\n\n/**\n * Gets the count bucket for the number of previews a user has seen.\n *\n * If local storage isn't available - because the user has disabled it\n * or the browser doesn't support it - then then \"unknown\" is returned.\n *\n * The buckets are defined as part of\n * [the Popups schema](https://meta.wikimedia.org/wiki/Schema:Popups).\n *\n * Extracted from `mw.popups.getPreviewCountBucket`.\n *\n * @param {Number} count\n * @return {String}\n */\nexports.getPreviewCountBucket = function getPreviewCountBucket( count ) {\n\tlet bucket;\n\n\tif ( count === 0 ) {\n\t\tbucket = '0';\n\t} else if ( count >= 1 && count <= 4 ) {\n\t\tbucket = '1-4';\n\t} else if ( count >= 5 && count <= 20 ) {\n\t\tbucket = '5-20';\n\t} else if ( count >= 21 ) {\n\t\tbucket = '21+';\n\t}\n\n\treturn bucket !== undefined ? ( `${ bucket } previews` ) : 'unknown';\n};\n","/**\n * @module constants\n */\nconst $ = jQuery,\n\t// If bracketedDevicePixelRatio is not available default to 1 (in tests for\n\t// example)\n\tpixelRatio = $.bracketedDevicePixelRatio &&\n\t\t$.bracketedDevicePixelRatio() || 1,\n\tBUCKETS = {\n\t\toff: 'off',\n\t\ton: 'on',\n\t\tcontrol: 'control'\n\t};\n\nexport { BUCKETS };\n\nexport default {\n\tTHUMBNAIL_SIZE: 320 * pixelRatio,\n\tEXTRACT_LENGTH: 525\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 */\n\tTYPE_GENERIC: 'generic',\n\t/** standard preview */\n\tTYPE_PAGE: 'page',\n\t/** disambiguation preview */\n\tTYPE_DISAMBIGUATION: 'disambiguation'\n};\n\nexport { previewTypes };\n\n/**\n * Preview Model\n *\n * @typedef {Object} PreviewModel\n * @property {String} title\n * @property {String} url The canonical URL of the page being previewed\n * @property {String} languageCode\n * @property {String} languageDirection Either \"ltr\" or \"rtl\"\n * @property {?Array} 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} type One of TYPE_GENERIC, TYPE_PAGE, TYPE_DISAMBIGUATION\n * @property {?Object} thumbnail\n *\n * @global\n */\n\n/**\n * Creates a 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} extract\n * @param {String} type\n * @param {?Object} thumbnail\n * @param {?Number} pageId\n * @return {PreviewModel}\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 = getPreviewType( 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 preview model.\n *\n * @param {!String} title\n * @param {!String} url\n * @return {!PreviewModel}\n */\nexport function createNullModel( title, url ) {\n\treturn createModel( title, url, '', '', [], '' );\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 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 {string} [processedExtract]\n * @return {String} one of TYPE_GENERIC, TYPE_PAGE, TYPE_DISAMBIGUATION.\n */\n\nfunction getPreviewType( type, processedExtract ) {\n\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","const $ = jQuery,\n\tmw = window.mediaWiki;\n\n/**\n * Improves the plain text extracts\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.RegExp.escape( title ); // Escape RegExp elements\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\telements.push( $( '<b>' )\n\t\t\t\t.text( part.substring( boldIdentifier.length ) ) );\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/mediawiki\n */\n\n/**\n * @interface MediaWikiGateway\n * @extends Gateway\n *\n * @global\n */\n\nimport { createModel } from '../preview/model';\nimport * as formatter from '../formatter';\n\n// Public and private cache lifetime (5 minutes)\n//\n// FIXME: Move this to src/constants.js.\nconst CACHE_LIFETIME = 300,\n\t$ = jQuery;\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 * @return {MediaWikiGateway}\n */\nexport default function createMediaWikiApiGateway( api, config ) {\n\n\t/**\n\t * Fetches page data from the API.\n\t *\n\t * @function\n\t * @name MediaWikiGateway#fetch\n\t * @param {String} title\n\t * @return {jQuery.Promise}\n\t */\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: 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\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}\n\t\t} );\n\t}\n\n\tfunction getPageSummary( title ) {\n\t\treturn fetch( title )\n\t\t\t.then( extractPageFromResponse )\n\t\t\t.then( formatPlainTextExtract )\n\t\t\t.then( convertPageToModel );\n\t}\n\n\treturn {\n\t\tfetch,\n\t\textractPageFromResponse,\n\t\tconvertPageToModel,\n\t\tgetPageSummary,\n\t\tformatPlainTextExtract\n\t};\n}\n\n/**\n * Extracts page data from the API response.\n *\n * @function\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 * @function\n * @name MediaWikiGateway#formatPlainTextExtract\n * @param {Object} data The response\n * @return {Object}\n */\nfunction formatPlainTextExtract( data ) {\n\tconst result = $.extend( {}, 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 * @function\n * @name MediaWikiGateway#convertPageToModel\n * @param {Object} page\n * @return {PreviewModel}\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, createNullModel } from '../preview/model';\n\nconst RESTBASE_PROFILE = 'https://www.mediawiki.org/wiki/Specs/Summary/1.2.0',\n\tmw = window.mediaWiki,\n\t$ = jQuery;\n/**\n * @interface RESTBaseGateway\n * @extends Gateway\n *\n * @global\n */\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 {Function} 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 {RESTBaseGateway}\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 * @function\n\t * @name MediaWikiGateway#fetch\n\t * @param {String} title\n\t * @return {jQuery.Promise}\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}\n\t\t} );\n\t}\n\n\tfunction getPageSummary( title ) {\n\t\tconst result = $.Deferred();\n\n\t\tfetch( title )\n\t\t\t.then(\n\t\t\t\t( page ) => {\n\t\t\t\t\t// Endpoint response may be empty or simply missing a title.\n\t\t\t\t\tif ( !page || !page.title ) {\n\t\t\t\t\t\tpage = $.extend( true, page || {}, { title } );\n\t\t\t\t\t}\n\t\t\t\t\t// And extract may be omitted if empty string\n\t\t\t\t\tif ( page.extract === undefined ) {\n\t\t\t\t\t\tpage.extract = '';\n\t\t\t\t\t}\n\t\t\t\t\tresult.resolve(\n\t\t\t\t\t\tconvertPageToModel( page, config.THUMBNAIL_SIZE, extractParser ) );\n\t\t\t\t},\n\t\t\t\t( jqXHR, textStatus, errorThrown ) => {\n\t\t\t\t\t// Adapt the response to the ideal API.\n\t\t\t\t\t// TODO: should we just let the client handle this too?\n\t\t\t\t\tif ( jqXHR.status === 404 ) {\n\t\t\t\t\t\tresult.resolve(\n\t\t\t\t\t\t\tcreateNullModel( title, new mw.Title( title ).getUrl() )\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// The client will choose how to handle these errors which may\n\t\t\t\t\t\t// include those due to HTTP 5xx status. The rejection typing\n\t\t\t\t\t\t// matches Fetch failures.\n\t\t\t\t\t\tresult.reject( 'http', {\n\t\t\t\t\t\t\txhr: jqXHR,\n\t\t\t\t\t\t\ttextStatus,\n\t\t\t\t\t\t\texception: errorThrown\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\treturn result.promise();\n\t}\n\n\treturn {\n\t\tfetch,\n\t\tconvertPageToModel,\n\t\tgetPageSummary\n\t};\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 {Object}\n */\nfunction generateThumbnailData( thumbnail, original, thumbSize ) {\n\tconst parts = thumbnail.source.split( '/' ),\n\t\tlastPart = parts[ parts.length - 1 ];\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.\n\t\treturn original;\n\t}\n\tconst filename = lastPart.substr( 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\treturn 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 * @function\n * @name RESTBaseGateway#convertPageToModel\n * @param {Object} page\n * @param {Number} thumbSize\n * @param {Function} extractParser\n * @return {PreviewModel}\n */\nfunction 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 * @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\n\treturn extract.length === 0 ? [] : $.parseHTML( extract );\n}\n\n/**\n * Prepare extract\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","import constants from '../constants';\nimport createMediaWikiApiGateway from './mediawiki';\nimport createRESTBaseGateway from './rest';\nimport * as formatters from './restFormatters';\n\nconst mw = mediaWiki,\n\t$ = jQuery;\n\n// Note that this interface definition is in the global scope.\n/**\n * The interface implemented by all preview gateways.\n *\n * @interface Gateway\n */\n\n/**\n * Fetches a preview for a page.\n *\n * If the underlying request is successful and contains data about the page,\n * then the resulting promise will resolve. If not, then it will reject.\n *\n * @function\n * @name Gateway#getPageSummary\n * @param {String} title The title of the page\n * @return {jQuery.Promise<PreviewModel>}\n */\n\n/**\n * Creates a gateway with sensible values for the dependencies.\n *\n * @param {mw.Map} config\n * @return {Gateway}\n */\nexport default function createGateway( config ) {\n\tconst restConfig = $.extend( {}, constants,\n\t\t{\n\t\t\tendpoint: config.get( 'wgPopupsRestGatewayEndpoint' )\n\t\t}\n\t);\n\tswitch ( config.get( 'wgPopupsGateway' ) ) {\n\t\tcase 'mwApiPlain':\n\t\t\treturn createMediaWikiApiGateway( new mw.Api(), constants );\n\t\tcase 'restbasePlain':\n\t\t\treturn createRESTBaseGateway(\n\t\t\t\t$.ajax, restConfig, formatters.parsePlainTextResponse );\n\t\tcase 'restbaseHTML':\n\t\t\treturn createRESTBaseGateway(\n\t\t\t\t$.ajax, restConfig, formatters.parseHTMLResponse );\n\t\tdefault:\n\t\t\tthrow new Error( 'Unknown gateway' );\n\t}\n}\n","/**\n * @module userSettings\n */\n\n/**\n * @interface UserSettings\n *\n * @global\n */\n\nconst IS_ENABLED_KEY = 'mwe-popups-enabled',\n\tPREVIEW_COUNT_KEY = 'ext.popups.core.previewCount';\n\n/**\n * Creates an object whose methods encapsulate all interactions with the UA's\n * storage.\n *\n * @param {Object} storage The `mw.storage` singleton instance\n *\n * @return {UserSettings}\n */\nexport default function createUserSettings( storage ) {\n\treturn {\n\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.setIsEnabled(true), then they are treated as\n\t\t * if they have enabled them.\n\t\t *\n\t\t * @function\n\t\t * @name UserSettings#getIsEnabled\n\t\t * @return {Boolean}\n\t\t */\n\t\tgetIsEnabled() {\n\t\t\treturn storage.get( IS_ENABLED_KEY ) !== '0';\n\t\t},\n\n\t\t/**\n\t\t * Sets whether the user has enabled Page Previews.\n\t\t *\n\t\t * @function\n\t\t * @name UserSettings#setIsEnabled\n\t\t * @param {Boolean} isEnabled\n\t\t */\n\t\tsetIsEnabled( isEnabled ) {\n\t\t\tstorage.set( IS_ENABLED_KEY, isEnabled ? '1' : '0' );\n\t\t},\n\n\t\t/**\n\t\t * Gets whether the user has previously enabled **or disabled** Page\n\t\t * Previews.\n\t\t *\n\t\t * @function\n\t\t * @name UserSettings#hasIsEnabled\n\t\t * @return {Boolean}\n\t\t */\n\t\thasIsEnabled() {\n\t\t\tconst value = storage.get( IS_ENABLED_KEY );\n\n\t\t\treturn Boolean( value ) !== false;\n\t\t},\n\n\t\t/**\n\t\t * Gets the number of previews that the user has seen.\n\t\t *\n\t\t * - If the storage isn't available, then -1 is returned.\n\t\t * - If the value in storage is not a number it will override stored value\n\t\t * to 0\n\t\t *\n\t\t * @function\n\t\t * @name UserSettings#getPreviewCount\n\t\t * @return {Number}\n\t\t */\n\t\tgetPreviewCount() {\n\t\t\tconst result = storage.get( PREVIEW_COUNT_KEY );\n\n\t\t\tif ( result === false ) {\n\t\t\t\treturn -1;\n\t\t\t} else if ( result === null ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tlet count = parseInt( result, 10 );\n\n\t\t\t// stored number is not a zero, override it to zero and store new value\n\t\t\tif ( isNaN( count ) ) {\n\t\t\t\tcount = 0;\n\t\t\t\tthis.setPreviewCount( count );\n\t\t\t}\n\t\t\treturn count;\n\t\t},\n\n\t\t/**\n\t\t * Sets the number of previews that the user has seen.\n\t\t *\n\t\t * @function\n\t\t * @name UserSettings#setPreviewCount\n\t\t * @param {Number} count\n\t\t */\n\t\tsetPreviewCount( count ) {\n\t\t\tstorage.set( PREVIEW_COUNT_KEY, count.toString() );\n\t\t}\n\t};\n}\n","/**\n * @module previewBehaviour\n */\n\nconst mw = window.mediaWiki,\n\t$ = jQuery;\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} 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 * Special:Preferences page with the \"Beta features\" tab open if Page Previews\n * is enabled as a beta feature, or the \"Appearance\" tab otherwise.\n *\n * @param {mw.Map} config\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( config, user, actions ) {\n\tconst isBetaFeature = config.get( 'wgPopupsBetaFeature' );\n\tlet settingsUrl, showSettings = $.noop;\n\n\tif ( user.isAnon() ) {\n\t\tshowSettings = ( event ) => {\n\t\t\tevent.preventDefault();\n\n\t\t\tactions.showSettings();\n\t\t};\n\t} else {\n\t\tlet rawTitle = 'Special:Preferences#mw-prefsection-';\n\t\trawTitle += isBetaFeature ? 'betafeatures' : '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\nconst mw = window.mediaWiki;\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","/**\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 {string} HTML string.\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\treturn `\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<div class='mw-ui-icon mw-ui-icon-element mw-ui-icon-popups-close close'>${ closeLabel }</div>\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 mw-ui-button mw-ui-progressive'>${ saveLabel }</button>\n\t\t\t\t\t<button class='okay mw-ui-button mw-ui-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>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\tname='mwe-popups-setting'\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='radio'\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<p>${ helpText }</p>\n\t\t\t</div>\n\t\t</section>\n\t`.trim();\n}\n","/**\n * @module settingsDialog\n */\n\nimport { renderSettingsDialog } from './templates/settingsDialog';\n\nconst mw = window.mediaWiki;\n\n/**\n * Create the settings dialog shown to anonymous users.\n *\n * @param {boolean} navPopupsEnabled\n * @return {jQuery} settings dialog\n */\nexport function createSettingsDialog( navPopupsEnabled ) {\n\tconst choices = [\n\t\t{\n\t\t\tid: 'simple',\n\t\t\tname: mw.msg( 'popups-settings-option-simple' ),\n\t\t\tdescription: mw.msg( 'popups-settings-option-simple-description' ),\n\t\t\tisChecked: true\n\t\t},\n\t\t{\n\t\t\tid: 'advanced',\n\t\t\tname: mw.msg( 'popups-settings-option-advanced' ),\n\t\t\tdescription: mw.msg( 'popups-settings-option-advanced-description' )\n\t\t},\n\t\t{\n\t\t\tid: 'off',\n\t\t\tname: mw.msg( 'popups-settings-option-off' )\n\t\t}\n\t];\n\n\tif ( !navPopupsEnabled ) {\n\t\t// remove the advanced option\n\t\tchoices.splice( 1, 1 );\n\t}\n\n\t// render the template\n\tconst $el = $( $.parseHTML( 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\treturn $el;\n}\n","import { createSettingsDialog } from './settingsDialog';\n\n/**\n * @module settingsDialogRenderer\n */\n\nconst $ = jQuery;\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 * @return {Function} render function\n */\nexport default function createSettingsDialogRenderer() {\n\n\t/**\n\t * Cached settings dialog\n\t *\n\t * @type {jQuery}\n\t */\n\tlet $dialog,\n\t\t/**\n\t\t * Cached settings overlay\n\t\t *\n\t\t * @type {jQuery}\n\t\t */\n\t\t$overlay;\n\n\t/**\n\t * Renders the relevant form and labels in the settings dialog\n\t * @param {Object} boundActions\n\t * @return {Object} object with methods to affect the rendered UI\n\t */\n\treturn ( boundActions ) => {\n\n\t\tif ( !$dialog ) {\n\t\t\t$dialog = createSettingsDialog( isNavPopupsEnabled() );\n\t\t\t$overlay = $( '<div>' ).addClass( 'mwe-popups-overlay' );\n\n\t\t\t// Setup event bindings\n\n\t\t\t$dialog.find( '.save' ).click( () => {\n\t\t\t\t// Find the selected value (simple|advanced|off)\n\t\t\t\tconst selected = getSelectedSetting( $dialog ),\n\t\t\t\t\t// Only simple means enabled, advanced is disabled in favor of\n\t\t\t\t\t// NavPops and off means disabled.\n\t\t\t\t\tenabled = selected === 'simple';\n\n\t\t\t\tboundActions.saveSettings( enabled );\n\t\t\t} );\n\t\t\t$dialog.find( '.close, .okay' ).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 * @param {HTMLElement} el\n\t\t\t */\n\t\t\tappendTo( el ) {\n\t\t\t\t$overlay.appendTo( el );\n\t\t\t\t$dialog.appendTo( $overlay );\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\t$overlay.show();\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\t$overlay.hide();\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Toggle the help dialog on or off\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 * If false and no navpops, then checks 'off'\n\t\t\t * If true, then checks 'on'\n\t\t\t * If false, and there are navpops, then checks 'advanced'\n\t\t\t *\n\t\t\t * @param {Boolean} enabled if page previews are enabled\n\t\t\t */\n\t\t\tsetEnabled( enabled ) {\n\t\t\t\tlet name = 'off';\n\t\t\t\tif ( enabled ) {\n\t\t\t\t\tname = 'simple';\n\t\t\t\t} else if ( isNavPopupsEnabled() ) {\n\t\t\t\t\tname = 'advanced';\n\t\t\t\t}\n\n\t\t\t\t// Check the appropriate radio button\n\t\t\t\t$dialog.find( `#mwe-popups-settings-${ name }` )\n\t\t\t\t\t.prop( 'checked', true );\n\t\t\t}\n\t\t};\n\t};\n}\n\n/**\n * Get the selected value on the radio button\n *\n * @param {jQuery.Object} $el the element to extract the setting from\n * @return {String} Which should be (simple|advanced|off)\n */\nfunction getSelectedSetting( $el ) {\n\treturn $el.find(\n\t\t'input[name=mwe-popups-setting]:checked, #mwe-popups-settings'\n\t).val();\n}\n\n/**\n * Toggles the visibility between a form and the help\n * @param {jQuery.Object} $el element that contains form and help\n * @param {Boolean} visible if the help should be visible, or the form\n */\nfunction toggleHelp( $el, visible ) {\n\tconst $dialog = $( '#mwe-popups-settings' ),\n\t\tformSelectors = 'main, .save, .close',\n\t\thelpSelectors = '.mwe-popups-settings-help, .okay';\n\n\tif ( visible ) {\n\t\t$dialog.find( formSelectors ).hide();\n\t\t$dialog.find( helpSelectors ).show();\n\t} else {\n\t\t$dialog.find( formSelectors ).show();\n\t\t$dialog.find( helpSelectors ).hide();\n\t}\n}\n\n/**\n * Checks if the NavigationPopups gadget is enabled by looking at the global\n * variables\n * @return {Boolean} if navpops was found to be enabled\n */\nfunction isNavPopupsEnabled() {\n\t/* global pg: false*/\n\treturn typeof pg !== 'undefined' && pg.fn.disablePopups !== undefined;\n}\n","/**\n * @module changeListener\n */\n\n/**\n * @typedef {Function} ext.popups.ChangeListener\n * @param {Object} prevState The previous state\n * @param {Object} state 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 */\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 state;\n\n\tstore.subscribe( () => {\n\t\tconst prevState = state;\n\n\t\tstate = store.getState();\n\n\t\tif ( prevState !== state ) {\n\t\t\tcallback( prevState, state );\n\t\t}\n\t} );\n}\n","/**\n * @module title\n */\n\nconst mw = window.mediaWiki;\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\tconst titleRegex = new RegExp( mw.RegExp.escape( config.get( 'wgArticlePath' ) )\n\t\t.replace( '\\\\$1', '(.+)' ) );\n\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\n\t// No query params (pretty URL)\n\tif ( !queryLength ) {\n\t\tconst matches = titleRegex.exec( linkHref.path );\n\t\treturn matches ? decodeURIComponent( matches[ 1 ] ) : undefined;\n\t} else if ( queryLength === 1 && linkHref.query.hasOwnProperty( 'title' ) ) {\n\t\t// URL is not pretty, but only has a `title` parameter\n\t\treturn linkHref.query.title;\n\t}\n\n\treturn 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} 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 && ( $.inArray( mwTitle.namespace, contentNamespaces ) >= 0 ) ) {\n\t\treturn mwTitle;\n\t}\n\n\treturn null;\n}\n\n/**\n * Return a mw.Title from a HTMLElement if valid for hovercards. Convenience\n * method\n *\n * @param {Element} el\n * @param {mw.Map} config\n * @return {mw.Title|null}\n */\nexport function fromElement( el, config ) {\n\treturn isValid(\n\t\tgetTitle( el.href, config ),\n\t\tconfig.get( 'wgContentNamespaces' )\n\t);\n}\n","/**\n * @module wait\n */\n\nconst $ = jQuery;\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 {jQuery.Promise}\n */\nexport default function wait( delay ) {\n\tconst result = $.Deferred();\n\n\tsetTimeout( () => {\n\t\tresult.resolve();\n\t}, delay );\n\n\treturn result.promise();\n}\n","/**\n * @module thumbnail\n */\n\nconst SIZES = {\n\t\tportraitImage: {\n\t\t\th: 250, // Exact height\n\t\t\tw: 203 // Max width\n\t\t},\n\t\tlandscapeImage: {\n\t\t\th: 200, // Max height\n\t\t\tw: 320 // Exact Width\n\t\t}\n\t},\n\t$ = jQuery;\n\nexport { SIZES };\n\n/**\n * @typedef {Object} ext.popups.Thumbnail\n * @property {Element} el\n * @property {Boolean} isTall Whether or not the thumbnail is portrait\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 * @return {ext.popups.Thumbnail|null}\n */\nexport function createThumbnail( rawThumbnail ) {\n\tconst devicePixelRatio = $.bracketedDevicePixelRatio();\n\n\tif ( !rawThumbnail ) {\n\t\treturn null;\n\t}\n\n\tconst tall = rawThumbnail.width < rawThumbnail.height;\n\tconst thumbWidth = rawThumbnail.width / devicePixelRatio;\n\tconst thumbHeight = rawThumbnail.height / devicePixelRatio;\n\n\tif (\n\t\t// Image too small for landscape display\n\t\t( !tall && thumbWidth < SIZES.landscapeImage.w ) ||\n\t\t// Image too small for portrait display\n\t\t( tall && thumbHeight < 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\tlet x, y, width, height, clipPath;\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\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 + 3;\n\t\theight = ( thumbHeight > SIZES.landscapeImage.h ) ?\n\t\t\tSIZES.landscapeImage.h : thumbHeight;\n\t\tclipPath = 'mwe-popups-mask';\n\t}\n\n\treturn {\n\t\tel: createThumbnailElement(\n\t\t\ttall ? 'mwe-popups-is-tall' : 'mwe-popups-is-not-tall',\n\t\t\trawThumbnail.source,\n\t\t\tx,\n\t\t\ty,\n\t\t\tthumbWidth,\n\t\t\tthumbHeight,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tclipPath\n\t\t),\n\t\tisTall: tall,\n\t\twidth: thumbWidth,\n\t\theight: thumbHeight\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 * @param {String} clipPath\n * @return {jQuery}\n */\nexport function createThumbnailElement(\n\tclassName, url, x, y, thumbnailWidth, thumbnailHeight, width, height, clipPath\n) {\n\tconst nsSvg = 'http://www.w3.org/2000/svg',\n\t\tnsXlink = 'http://www.w3.org/1999/xlink';\n\n\tconst $thumbnailSVGImage = $( document.createElementNS( nsSvg, 'image' ) );\n\t$thumbnailSVGImage[ 0 ].setAttributeNS( nsXlink, 'href', url );\n\t$thumbnailSVGImage\n\t\t.addClass( className )\n\t\t.attr( {\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth: thumbnailWidth,\n\t\t\theight: thumbnailHeight,\n\t\t\t'clip-path': `url(#${ clipPath })`\n\t\t} );\n\n\tconst $thumbnail = $( document.createElementNS( nsSvg, 'svg' ) )\n\t\t.attr( {\n\t\t\txmlns: nsSvg,\n\t\t\twidth,\n\t\t\theight\n\t\t} )\n\t\t.append( $thumbnailSVGImage );\n\n\treturn $thumbnail;\n}\n","/**\n * @module preview\n */\n\nimport { escapeHTML } from './templateUtil';\n\n/**\n * @param {ext.popups.PreviewModel} model\n * @param {boolean} showTitle\n * @param {string} extractMsg\n * @param {string} linkMsg\n * @return {string} HTML string.\n */\nexport function renderPreview(\n\t{ title, url, type }, showTitle, extractMsg, linkMsg\n) {\n\ttitle = escapeHTML( title );\n\textractMsg = escapeHTML( extractMsg );\n\tlinkMsg = escapeHTML( linkMsg );\n\treturn `\n\t<div class='mwe-popups mwe-popups-type-${ type }' role='tooltip' aria-hidden>\n\t\t<div class='mwe-popups-container'>\n\t\t\t<div class='mw-ui-icon mw-ui-icon-element mw-ui-icon-preview-${ type }'></div>\n\t\t\t${ showTitle ? `<strong class='mwe-popups-title'>${ title }</strong>` : '' }\n\t\t\t<a href='${ url }' class='mwe-popups-extract'>\n\t\t\t\t\t<span class='mwe-popups-message'>${ extractMsg }</span>\n\t\t\t</a>\n\t\t\t<footer>\n\t\t\t\t<a href='${ url }' class='mwe-popups-read-link'>${ linkMsg }</a>\n\t\t\t</footer>\n\t\t</div>\n\t</div>\n\t`.trim();\n}\n","/**\n * @module renderer\n */\n\nimport wait from '../wait';\nimport pokeyMaskSVG from './pokey-mask.svg';\nimport { SIZES, createThumbnail } from './thumbnail';\nimport { previewTypes } from '../preview/model';\nimport { renderPreview } from './templates/preview';\nimport { renderPagePreview } from './templates/pagePreview';\n\nconst mw = window.mediaWiki,\n\t$ = jQuery,\n\t$window = $( window ),\n\tlandscapePopupWidth = 450,\n\tportraitPopupWidth = 320,\n\tpokeySize = 8; // Height of the pokey.;\n\n/**\n * Extracted from `mw.popups.createSVGMasks`. This is just an SVG mask to point\n * or \"poke\" at the link that's hovered over. The \"pokey\" appears to be cut out\n * of the image itself:\n * _______ _______ link\n * | | |_/\\____| _/\\____ <-- Pokey pointing at link\n * | | + = | |\n * |_______| |_______|\n * Background Pokey Page preview\n * image mask bubble w/ pokey\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 pokey masks are appended\n */\nexport function createPokeyMasks( container ) {\n\t$( '<div>' )\n\t\t.attr( 'id', 'mwe-popups-svg' )\n\t\t.html( pokeyMaskSVG )\n\t\t.appendTo( container );\n}\n\n/**\n * Initializes the renderer.\n */\nexport function init() {\n\tcreatePokeyMasks( document.body );\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\n\tconst preview = createPreviewWithType( model );\n\n\treturn {\n\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}\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\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}\n\t\t */\n\t\thide() {\n\t\t\treturn hide( preview );\n\t\t}\n\t};\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\tswitch ( model.type ) {\n\t\tcase previewTypes.TYPE_PAGE:\n\t\t\treturn createPagePreview( model );\n\t\tcase previewTypes.TYPE_DISAMBIGUATION:\n\t\t\treturn createDisambiguationPreview( model );\n\t\tdefault:\n\t\t\treturn createEmptyPreview( model );\n\t}\n}\n\n/**\n * Creates an instance of the DTO backing a preview.\n *\n * @param {ext.popups.PreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createPagePreview( model ) {\n\tconst thumbnail = createThumbnail( model.thumbnail ),\n\t\thasThumbnail = thumbnail !== null,\n\t\textract = model.extract;\n\n\tconst $el = $( $.parseHTML( renderPagePreview( model, hasThumbnail ) ) );\n\n\tif ( hasThumbnail ) {\n\t\t$el.find( '.mwe-popups-discreet' ).append( thumbnail.el );\n\t}\n\tif ( extract ) {\n\t\t$el.find( '.mwe-popups-extract' ).append( extract );\n\t}\n\n\treturn {\n\t\tel: $el,\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.PreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createEmptyPreview( model ) {\n\tconst showTitle = false,\n\t\textractMsg = mw.msg( 'popups-preview-no-preview' ),\n\t\tlinkMsg = mw.msg( 'popups-preview-footer-read' );\n\n\tconst $el = $(\n\t\t$.parseHTML( renderPreview( model, showTitle, extractMsg, linkMsg ) )\n\t);\n\n\treturn {\n\t\tel: $el,\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.PreviewModel} model\n * @return {ext.popups.Preview}\n */\nexport function createDisambiguationPreview( model ) {\n\tconst showTitle = true,\n\t\textractMsg = mw.msg( 'popups-preview-disambiguation' ),\n\t\tlinkMsg = mw.msg( 'popups-preview-disambiguation-link' );\n\n\tconst $el = $(\n\t\t$.parseHTML( renderPreview( model, showTitle, extractMsg, linkMsg ) )\n\t);\n\n\treturn {\n\t\tel: $el,\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 {Event} event\n * @param {jQuery} $link event target\n * @param {ext.popups.PreviewBehavior} behavior\n * @param {String} token\n * @param {Object} container DOM object to which pokey masks are appended\n * @return {jQuery.Promise} A promise that resolves when the promise has faded\n * in\n */\nexport function show( preview, event, $link, behavior,\n\ttoken, container\n) {\n\tconst layout = createLayout(\n\t\tpreview.isTall,\n\t\t{\n\t\t\tpageX: event.pageX,\n\t\t\tpageY: event.pageY,\n\t\t\tclientY: event.clientY\n\t\t},\n\t\t{\n\t\t\tclientRects: $link.get( 0 ).getClientRects(),\n\t\t\toffset: $link.offset(),\n\t\t\twidth: $link.width(),\n\t\t\theight: $link.height()\n\t\t},\n\t\t{\n\t\t\tscrollTop: $window.scrollTop(),\n\t\t\twidth: $window.width(),\n\t\t\theight: $window.height()\n\t\t},\n\t\tpokeySize\n\t);\n\n\tpreview.el.appendTo( container );\n\n\tlayoutPreview(\n\t\tpreview, layout, getClasses( preview, layout ),\n\t\tSIZES.landscapeImage.h, pokeySize\n\t);\n\n\tpreview.el.show();\n\n\treturn wait( 200 )\n\t\t.then( () => {\n\t\t\tbindBehavior( preview, behavior );\n\t\t} )\n\t\t.then( () => {\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 */\nexport function bindBehavior( preview, behavior ) {\n\tpreview.el.on( 'mouseenter', behavior.previewDwell )\n\t\t.on( 'mouseleave', behavior.previewAbandon );\n\n\tpreview.el.click( behavior.click );\n\n\tpreview.el.find( '.mwe-popups-settings-icon' )\n\t\t.attr( 'href', behavior.settingsUrl )\n\t\t.click( ( event ) => {\n\t\t\tevent.stopPropagation();\n\n\t\t\tbehavior.showSettings( event );\n\t\t} );\n}\n\n/**\n * Extracted from `mw.popups.render.closePopup`.\n *\n * @param {ext.popups.Preview} preview\n * @return {jQuery.Promise} A promise that resolves when the preview has faded\n * 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.hasClass( '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\tpreview.el\n\t\t.removeClass( fadeInClass )\n\t\t.addClass( 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 */\n\n/**\n * @param {isPreviewTall} isPreviewTall\n * @param {Object} eventData Data related to the event that triggered showing\n * a popup\n * @param {number} eventData.pageX\n * @param {number} eventData.pageY\n * @param {number} eventData.clientY\n * @param {Object} linkData Data related to the link thats used for showing\n * a popup\n * @param {ClientRectList} linkData.clientRects list of rectangles defined by\n * four edges\n * @param {Object} linkData.offset\n * @param {number} linkData.width\n * @param {number} linkData.height\n * @param {Object} windowData Data related to the window\n * @param {number} windowData.scrollTop\n * @param {number} windowData.width\n * @param {number} windowData.height\n * @param {number} pokeySize Space reserved for the pokey\n * @return {ext.popups.PreviewLayout}\n */\nexport function createLayout(\n\tisPreviewTall, eventData, linkData, windowData, pokeySize\n) {\n\tlet flippedX = false,\n\t\tflippedY = false,\n\t\toffsetTop = eventData.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\teventData.pageY - windowData.scrollTop,\n\t\t\t\tlinkData.clientRects,\n\t\t\t\tfalse\n\t\t\t) + windowData.scrollTop + pokeySize :\n\t\t\t// Position according to link position or size\n\t\t\tlinkData.offset.top + linkData.height + pokeySize,\n\t\toffsetLeft = eventData.pageX ? eventData.pageX : linkData.offset.left;\n\tconst clientTop = eventData.clientY ? eventData.clientY : offsetTop;\n\n\t// X Flip\n\tif ( offsetLeft > ( windowData.width / 2 ) ) {\n\t\toffsetLeft += ( !eventData.pageX ) ? linkData.width : 0;\n\t\toffsetLeft -= !isPreviewTall ?\n\t\t\tportraitPopupWidth :\n\t\t\tlandscapePopupWidth;\n\t\tflippedX = true;\n\t}\n\n\tif ( eventData.pageX ) {\n\t\toffsetLeft += ( flippedX ) ? 20 : -20;\n\t}\n\n\t// Y Flip\n\tif ( clientTop > ( windowData.height / 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 pokey on the edge of the link's bounding rectangle. In this case\n\t\t// the edge is the top-most.\n\t\toffsetTop = linkData.offset.top;\n\n\t\t// Change the Y position to the top of the link\n\t\tif ( eventData.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\teventData.pageY - windowData.scrollTop,\n\t\t\t\tlinkData.clientRects,\n\t\t\t\ttrue\n\t\t\t) + windowData.scrollTop;\n\t\t}\n\n\t\toffsetTop -= pokeySize;\n\t}\n\n\treturn {\n\t\toffset: {\n\t\t\ttop: offsetTop,\n\t\t\tleft: offsetLeft\n\t\t},\n\t\tflippedX,\n\t\tflippedY\n\t};\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}\n\n\tif ( layout.flippedY && !layout.flippedX ) {\n\t\tclasses.push( 'flipped_y' );\n\t}\n\n\tif ( layout.flippedX && !layout.flippedY ) {\n\t\tclasses.push( 'flipped_x' );\n\t}\n\n\tif ( ( !preview.hasThumbnail || preview.isTall ) && !layout.flippedY ) {\n\t\tclasses.push( 'mwe-popups-no-image-tri' );\n\t}\n\n\tif ( ( preview.hasThumbnail && !preview.isTall ) && !layout.flippedY ) {\n\t\tclasses.push( 'mwe-popups-image-tri' );\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 preview should be oriented differently, then the pokey is updated,\n * e.g. if the preview should be flipped vertically, then the pokey is\n * removed.\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} pokeySize\n */\nexport function layoutPreview(\n\tpreview, layout, classes, predefinedLandscapeImageHeight, pokeySize\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\t\tflippedX = layout.flippedX;\n\tlet offsetTop = layout.offset.top;\n\n\tif (\n\t\t!flippedY && !isTall && hasThumbnail &&\n\t\t\tthumbnail.height < predefinedLandscapeImageHeight\n\t) {\n\t\tpopup.find( '.mwe-popups-extract' ).css(\n\t\t\t'margin-top',\n\t\t\tthumbnail.height - pokeySize\n\t\t);\n\t}\n\n\tpopup.addClass( classes.join( ' ' ) );\n\n\tif ( flippedY ) {\n\t\toffsetTop -= popup.outerHeight();\n\t}\n\n\tpopup.css( {\n\t\ttop: offsetTop,\n\t\tleft: `${ layout.offset.left }px`\n\t} );\n\n\tif ( flippedY && hasThumbnail ) {\n\t\tpopup.find( 'image' )[ 0 ]\n\t\t\t.removeAttribute( 'clip-path' );\n\t}\n\n\tif ( flippedY && flippedX && hasThumbnail && isTall ) {\n\t\tpopup.find( 'image' )[ 0 ]\n\t\t\t.setAttribute( 'clip-path', 'url(#mwe-popups-landscape-mask-flip)' );\n\t}\n\n\tif ( flippedX && !flippedY && hasThumbnail && !isTall ) {\n\t\tpopup.find( 'image' )[ 0 ]\n\t\t\t.setAttribute( 'clip-path', 'url(#mwe-popups-mask-flip)' );\n\t}\n\n\tif ( flippedX && !flippedY && hasThumbnail && isTall ) {\n\t\tpopup.removeClass( 'mwe-popups-no-image-tri' )\n\t\t\t.find( 'image' )[ 0 ]\n\t\t\t.setAttribute( 'clip-path', 'url(#mwe-popups-landscape-mask)' );\n\t}\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","/**\n * @module pagePreview\n */\n\n/**\n * @param {ext.popups.PreviewModel} model\n * @param {boolean} hasThumbnail\n * @return {string} HTML string.\n */\nexport function renderPagePreview(\n\t{ url, languageCode, languageDirection }, hasThumbnail\n) {\n\treturn `\n\t\t<div class='mwe-popups' role='tooltip' aria-hidden>\n\t\t\t<div class='mwe-popups-container'>\n\t\t\t\t${ hasThumbnail ? `<a href='${ url }' class='mwe-popups-discreet'></a>` : '' }\n\t\t\t\t<a dir='${ languageDirection }' lang='${ languageCode }' class='mwe-popups-extract' href='${ url }'></a>\n\t\t\t\t<footer>\n\t\t\t\t\t<a class='mwe-popups-settings-icon mw-ui-icon mw-ui-icon-element mw-ui-icon-popups-settings'></a>\n\t\t\t\t</footer>\n\t\t\t</div>\n\t\t</div>\n\t`.trim();\n}\n","/**\n * @module changeListeners/footerLink\n */\n\nconst mw = window.mediaWiki,\n\t$ = jQuery;\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 {jQuery} The link element\n */\nfunction createFooterLink() {\n\tconst $link = $( '<li>' ).append(\n\t\t$( '<a>' )\n\t\t\t.attr( 'href', '#' )\n\t\t\t.text( mw.message( 'popups-settings-enable' ).text() )\n\t);\n\n\t// As yet, we don't know whether the link should be visible.\n\t$link.hide();\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 = $( '#footer-places, #f-list' );\n\n\tif ( $footer.length === 0 ) {\n\t\t$footer = $( '#footer li' ).parent();\n\t}\n\n\t$footer.append( $link );\n\n\treturn $link;\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 \"Enable previews\" link (the \"link\") is appended to the footer menu\n * (see `createFooterLink` above).\n * * When Page Previews are disabled, then the link is shown; otherwise, the\n * 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 $footerLink;\n\n\treturn ( prevState, state ) => {\n\t\tif ( $footerLink === undefined ) {\n\t\t\t$footerLink = createFooterLink();\n\t\t\t$footerLink.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 ( state.settings.shouldShowFooterLink ) {\n\t\t\t$footerLink.show();\n\t\t} else {\n\t\t\t$footerLink.hide();\n\t\t}\n\t};\n}\n","/**\n * @module changeListeners/eventLogging\n */\n\nconst $ = jQuery;\n\n/**\n * Creates an instance of the event logging change listener.\n *\n * When an event is enqueued it'll be logged using the schema. Since it's the\n * responsibility of Event Logging (and the UA) to deliver logged events,\n * `EVENT_LOGGED` is immediately dispatched rather than waiting for some\n * indicator of completion.\n *\n * @param {Object} boundActions\n * @param {EventTracker} eventLoggingTracker\n * @param {Function} getCurrentTimestamp\n * @return {ext.popups.ChangeListener}\n */\nexport default function eventLogging(\n\tboundActions, eventLoggingTracker, getCurrentTimestamp\n) {\n\treturn ( _, state ) => {\n\t\tconst eventLogging = state.eventLogging;\n\t\tlet event = eventLogging.event;\n\n\t\tif ( !event ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Per https://meta.wikimedia.org/wiki/Schema:Popups, the timestamp\n\t\t// property should be the time at which the event is logged and not the\n\t\t// time at which the interaction started.\n\t\t//\n\t\t// Rightly or wrongly, it's left as an exercise for the analyst to\n\t\t// calculate the time at which the interaction started as part of their\n\t\t// analyses, e.g. https://phabricator.wikimedia.org/T186016#4002923.\n\t\tevent = $.extend( true, {}, eventLogging.baseData, event, {\n\t\t\ttimestamp: getCurrentTimestamp()\n\t\t} );\n\n\t\teventLoggingTracker( 'event.Popups', event );\n\t\t// Dispatch the eventLogged action so that the state tree can be\n\t\t// cleared/updated.\n\t\tboundActions.eventLogged( event );\n\t};\n}\n","const $ = jQuery;\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 title;\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} el\n\t */\n\tfunction destroyTitleAttr( el ) {\n\t\tconst $el = $( el );\n\n\t\t// Has the user dwelled on a link? If we've already removed its title\n\t\t// attribute, then NOOP.\n\t\tif ( title ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttitle = $el.attr( 'title' );\n\n\t\t$el.attr( 'title', '' );\n\t}\n\n\t/**\n\t * Restores the title attribute of the element.\n\t *\n\t * @param {Element} el\n\t */\n\tfunction restoreTitleAttr( el ) {\n\t\t$( el ).attr( 'title', title );\n\n\t\ttitle = undefined;\n\t}\n\n\treturn ( prevState, state ) => {\n\t\tconst hasPrevActiveLink = prevState && prevState.preview.activeLink;\n\n\t\tif ( !state.preview.enabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( hasPrevActiveLink ) {\n\n\t\t\t// Has the user dwelled on a link immediately after abandoning another\n\t\t\t// (remembering that the ABANDON_END action is delayed by\n\t\t\t// ~10e2 ms).\n\t\t\tif ( prevState.preview.activeLink !== state.preview.activeLink ) {\n\t\t\t\trestoreTitleAttr( prevState.preview.activeLink );\n\t\t\t}\n\t\t}\n\n\t\tif ( state.preview.activeLink ) {\n\t\t\tdestroyTitleAttr( state.preview.activeLink );\n\t\t}\n\t};\n}\n","/**\n * @module changeListeners/syncUserSettings\n */\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\n\treturn ( prevState, state ) => {\n\n\t\tsyncIfChanged(\n\t\t\tprevState, state, 'eventLogging', 'previewCount',\n\t\t\tuserSettings.setPreviewCount\n\t\t);\n\t\tsyncIfChanged(\n\t\t\tprevState, state, 'preview', 'enabled',\n\t\t\tuserSettings.setIsEnabled\n\t\t);\n\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 * @param {Object} state tree\n * @param {String} reducer key to access on the state tree\n * @param {String} prop key to access on the reducer key of the state tree\n * @return {*}\n */\nfunction get( state, reducer, prop ) {\n\treturn state[ reducer ] && state[ reducer ][ prop ];\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 * @param {Object} prevState\n * @param {Object} state\n * @param {String} reducer key to access on the state tree\n * @param {String} prop key to access on the reducer key of the state tree\n * @param {Function} sync function to be called with the newest value if\n * changed\n */\nfunction syncIfChanged( prevState, state, reducer, prop, sync ) {\n\tconst current = get( state, reducer, prop );\n\tif ( prevState && ( get( prevState, reducer, prop ) !== current ) ) {\n\t\tsync( current );\n\t}\n}\n","import footerLink from './footerLink';\nimport eventLogging from './eventLogging';\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\teventLogging,\n\tlinkTitle,\n\tpageviews,\n\trender,\n\tsettings,\n\tstatsv,\n\tsyncUserSettings\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 ( _, state ) => {\n\t\tlet page;\n\t\tif ( state.pageviews && state.pageviews.pageview && state.pageviews.page ) {\n\t\t\tpage = state.pageviews.page;\n\t\t\tpageviewTracker( 'event.VirtualPageView', $.extend( {},\n\t\t\t\t{\n\t\t\t\t\t/* eslint-disable camelcase */\n\t\t\t\t\tsource_page_id: page.id,\n\t\t\t\t\tsource_namespace: page.namespaceId,\n\t\t\t\t\tsource_title: page.title,\n\t\t\t\t\tsource_url: page.url\n\t\t\t\t\t/* eslint-enable camelcase */\n\t\t\t\t},\n\t\t\t\tstate.pageviews.pageview )\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 ( prevState, state ) => {\n\t\tif ( state.preview.shouldShow && !preview ) {\n\t\t\tpreview = renderer.render( state.preview.fetchResponse );\n\t\t\tpreview.show(\n\t\t\t\tstate.preview.activeEvent,\n\t\t\t\tpreviewBehavior,\n\t\t\t\tstate.preview.activeToken\n\t\t\t);\n\t\t} else if ( !state.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 settings;\n\n\treturn ( prevState, state ) => {\n\t\tif ( !prevState ) {\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 (\n\t\t\tprevState.settings.shouldShow === false &&\n\t\t\tstate.settings.shouldShow === true\n\t\t) {\n\t\t\t// Lazily instantiate the settings UI\n\t\t\tif ( !settings ) {\n\t\t\t\tsettings = render( boundActions );\n\t\t\t\tsettings.appendTo( document.body );\n\t\t\t}\n\n\t\t\t// Update the UI settings with the current settings\n\t\t\tsettings.setEnabled( state.preview.enabled );\n\n\t\t\tsettings.show();\n\t\t} else if (\n\t\t\tprevState.settings.shouldShow === true &&\n\t\t\tstate.settings.shouldShow === false\n\t\t) {\n\t\t\tsettings.hide();\n\t\t}\n\n\t\t// Update help visibility\n\t\tif ( prevState.settings.showHelp !== state.settings.showHelp ) {\n\t\t\tsettings.toggleHelp( state.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 ( _, state ) => {\n\t\tconst statsv = state.statsv;\n\n\t\tif ( statsv.action ) {\n\t\t\ttrack( statsv.action, statsv.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\tPAGEVIEW_LOGGED: 'PAGEVIEW_LOGGED',\n\tPREVIEW_DWELL: 'PREVIEW_DWELL',\n\tPREVIEW_SHOW: 'PREVIEW_SHOW',\n\tPREVIEW_CLICK: 'PREVIEW_CLICK',\n\t/* Occurs when a preview has been opened for a significant amount of\n\ttime and can be assumed to have been 'seen' */\n\tPREVIEW_SEEN: 'PREVIEW_SEEN',\n\tSETTINGS_SHOW: 'SETTINGS_SHOW',\n\tSETTINGS_HIDE: 'SETTINGS_HIDE',\n\tSETTINGS_CHANGE: 'SETTINGS_CHANGE',\n\tEVENT_LOGGED: 'EVENT_LOGGED',\n\tSTATSV_LOGGED: 'STATSV_LOGGED'\n};\n","/**\n * @module actions\n */\n\nimport types from './actionTypes';\nimport wait from './wait';\nimport { createNullModel, previewTypes } from './preview/model';\n\nconst $ = jQuery,\n\tmw = window.mediaWiki,\n\n\t// See the following for context around this value.\n\t//\n\t// * https://phabricator.wikimedia.org/T161284\n\t// * https://phabricator.wikimedia.org/T70861#3129780\n\tFETCH_START_DELAY = 150, // ms.\n\n\t// The minimum time a preview must be open before we judge it\n\t// has been seen.\n\t// See https://phabricator.wikimedia.org/T184793\n\tPREVIEW_SEEN_DURATION = 1000, // ms\n\n\t// The delay after which a FETCH_COMPLETE action should be dispatched.\n\t//\n\t// If the API endpoint responds faster than 500 ms (or, say, the API\n\t// response is served from the UA's cache), then we introduce a delay of\n\t// 500 - t to make the preview delay consistent to the user.\n\tFETCH_COMPLETE_TARGET_DELAY = 500, // ms.\n\n\tABANDON_END_DELAY = 300; // ms.\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 {Boolean} isEnabled See `isEnabled.js`\n * @param {mw.user} user\n * @param {ext.popups.UserSettings} userSettings\n * @param {Function} generateToken\n * @param {mw.Map} config The config of the MediaWiki client-side application,\n * i.e. `mw.config`\n * @param {String} url url\n * @return {Object}\n */\nexport function boot(\n\tisEnabled,\n\tuser,\n\tuserSettings,\n\tgenerateToken,\n\tconfig,\n\turl\n) {\n\tconst editCount = config.get( 'wgUserEditCount' ),\n\t\tpreviewCount = userSettings.getPreviewCount();\n\n\treturn {\n\t\ttype: types.BOOT,\n\t\tisEnabled,\n\t\tisNavPopupsEnabled: config.get( 'wgPopupsConflictsWithNavPopupGadget' ),\n\t\tsessionToken: user.sessionId(),\n\t\tpageToken: generateToken(),\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(),\n\t\t\teditCount,\n\t\t\tpreviewCount\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 {Element} el\n * @param {String} token The unique token representing the link interaction that\n * triggered the fetch\n * @return {Redux.Thunk}\n */\nexport function fetch( gateway, title, el, token ) {\n\tconst titleText = title.getPrefixedDb(),\n\t\tnamespaceId = title.namespace;\n\n\treturn ( dispatch ) => {\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} ) );\n\n\t\tconst request = gateway.getPageSummary( titleText )\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 ) => {\n\t\t\t\tdispatch( {\n\t\t\t\t\ttype: types.FETCH_FAILED,\n\t\t\t\t\tel\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 err;\n\t\t\t} );\n\n\t\treturn $.when(\n\t\t\trequest,\n\t\t\twait( FETCH_COMPLETE_TARGET_DELAY - FETCH_START_DELAY )\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( ( data, result ) => {\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\tconst networkError = result && result.xhr &&\n\t\t\t\t\tresult.xhr.readyState === 0 && result.textStatus === 'error' &&\n\t\t\t\t\tresult.exception === '';\n\t\t\t\tif ( !networkError ) {\n\t\t\t\t\tdispatch( {\n\t\t\t\t\t\t// Both FETCH_FAILED and FETCH_END conclude with FETCH_COMPLETE.\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 {Element} el\n * @param {Event} event\n * @param {Gateway} gateway\n * @param {Function} generateToken\n * @return {Redux.Thunk}\n */\nexport function linkDwell( title, el, event, gateway, generateToken ) {\n\tconst token = generateToken(),\n\t\ttitleText = title.getPrefixedDb(),\n\t\tnamespaceId = title.namespace;\n\n\treturn ( dispatch, getState ) => {\n\t\tconst action = timedAction( {\n\t\t\ttype: types.LINK_DWELL,\n\t\t\tel,\n\t\t\tevent,\n\t\t\ttoken,\n\t\t\ttitle: titleText,\n\t\t\tnamespaceId\n\t\t} );\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\tdispatch( action );\n\n\t\tif ( !isNewInteraction() ) {\n\t\t\treturn $.Deferred().resolve().promise();\n\t\t}\n\n\t\treturn wait( FETCH_START_DELAY )\n\t\t\t.then( () => {\n\t\t\t\tconst previewState = getState().preview;\n\n\t\t\t\tif ( previewState.enabled && isNewInteraction() ) {\n\t\t\t\t\treturn dispatch( fetch( gateway, title, el, token ) );\n\t\t\t\t}\n\t\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 token = getState().preview.activeToken;\n\n\t\tif ( !token ) {\n\t\t\treturn $.Deferred().resolve().promise();\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\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 {Element} 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 `wasEnabled`\n * so that other reducers (like settings) can act on it without having to\n * duplicate the `enabled` state locally.\n * See doc/adr/0003-keep-enabled-state-only-in-preview-reducer.md for more\n * details.\n *\n * @param {Boolean} enabled if previews are enabled or not\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\twasEnabled: getState().preview.enabled,\n\t\t\tenabled\n\t\t} );\n\t};\n}\n\n/**\n * Represents the queued event being logged `changeListeners/eventLogging.js`\n * change listener.\n *\n * @param {Object} event\n * @return {Object}\n */\nexport function eventLogged( event ) {\n\treturn {\n\t\ttype: types.EVENT_LOGGED,\n\t\tevent\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](/doc/change_listeners.md), for example, we talk about\n * the previous state and the current state (the `prevState` and `state`\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 result = {};\n\n\tfor ( const key in state ) {\n\t\tif ( state.hasOwnProperty( key ) && !updates.hasOwnProperty( key ) ) {\n\t\t\tresult[ key ] = state[ key ];\n\t\t}\n\t}\n\n\tfor ( const key in updates ) {\n\t\tif ( updates.hasOwnProperty( key ) ) {\n\t\t\tresult[ key ] = updates[ key ];\n\t\t}\n\t}\n\n\treturn result;\n}\n","/**\n * @module reducers/eventLogging\n */\n\nimport actionTypes from '../actionTypes';\nimport nextState from './nextState';\nimport * as counts from '../counts';\n\n/**\n * Initialize the data that's shared between all events.\n *\n * @param {Object} bootAction\n * @return {Object}\n */\nfunction getBaseData( bootAction ) {\n\tconst result = {\n\t\tpageTitleSource: bootAction.page.title,\n\t\tnamespaceIdSource: bootAction.page.namespaceId,\n\t\tpageIdSource: bootAction.page.id,\n\t\tisAnon: bootAction.user.isAnon,\n\t\tpopupEnabled: bootAction.isEnabled,\n\t\tpageToken: bootAction.pageToken,\n\t\tsessionToken: bootAction.sessionToken,\n\t\tpreviewCountBucket: counts.getPreviewCountBucket(\n\t\t\tbootAction.user.previewCount\n\t\t),\n\t\thovercardsSuppressedByGadget: bootAction.isNavPopupsEnabled\n\t};\n\n\tif ( !bootAction.user.isAnon ) {\n\t\tresult.editCountBucket =\n\t\t\tcounts.getEditCountBucket( bootAction.user.editCount );\n\t}\n\n\treturn result;\n}\n\n/**\n * Takes data specific to the action and adds the following properties:\n *\n * * `linkInteractionToken`;\n * * `pageTitleHover` and `namespaceIdHover`; and\n * * `previewType` and `perceivedWait`, if a preview has been shown.\n *\n * @param {Object} interaction\n * @param {Object} actionData Data specific to the action, e.g. see\n * {@link module:reducers/eventLogging~createClosingEvent `createClosingEvent`}\n * @return {Object}\n */\nfunction createEvent( interaction, actionData ) {\n\tactionData.linkInteractionToken = interaction.token;\n\tactionData.pageTitleHover = interaction.title;\n\tactionData.namespaceIdHover = interaction.namespaceId;\n\n\t// Has the preview been shown?\n\tif ( interaction.timeToPreviewShow !== undefined ) {\n\t\tactionData.previewType = interaction.previewType;\n\t\tactionData.perceivedWait = interaction.timeToPreviewShow;\n\t}\n\n\treturn actionData;\n}\n\n/**\n * Creates an event that, when mixed into the base data (see\n * {@link module:reducers/eventLogging~getBaseData `getBaseData`}), represents\n * the user abandoning a link or preview.\n *\n * Since the event should be logged when the user has either abandoned a link or\n * dwelled on a different link, we refer to these events as \"closing\" events as\n * the link interaction has finished and a new one will be created later.\n *\n * If the link interaction is finalized, then no closing event is created.\n *\n * @param {Object} interaction\n * @return {Object|undefined}\n */\nfunction createClosingEvent( interaction ) {\n\tconst actionData = {\n\t\ttotalInteractionTime:\n\t\t\tMath.round( interaction.finished - interaction.started )\n\t};\n\n\tif ( interaction.finalized ) {\n\t\treturn undefined;\n\t}\n\n\t// Has the preview been shown? If so, then, in the context of the\n\t// instrumentation, then the preview has been dismissed by the user\n\t// rather than the user has abandoned the link.\n\tactionData.action =\n\t\tinteraction.timeToPreviewShow ? 'dismissed' : 'dwelledButAbandoned';\n\n\treturn createEvent( interaction, actionData );\n}\n\n/**\n * Reducer for actions that may result in an event being logged with [the\n * Popups schema][0] via EventLogging.\n *\n * The complexity of this reducer reflects the complexity of [the schema][0],\n * which is compounded by the introduction of two delays introduced by the\n * system to provide reasonable performance and a consistent UX.\n *\n * The reducer must:\n *\n * * Accumulate the state required to log events. This state is\n * referred to as \"the interaction state\" or \"the interaction\";\n * * Enforce the invariant that one event is logged per interaction;\n * * Defend against delayed actions being dispatched; and, as a direct\n * consequence\n * * Handle transitioning from one interaction to another at the same time.\n *\n * Furthermore, we distinguish between \"finalizing\" and \"closing\" the current\n * interaction state. Since only one event should be logged per link\n * interaction, we say that the interaction state is *finalized* when an event\n * has been logged and is *closed* when a new interaction should be created.\n * In practice, the interaction state is only finalized when the user clicks a\n * link or a preview.\n *\n * [0]: https://meta.wikimedia.org/wiki/Schema:Popups\n *\n * @param {Object} state\n * @param {Object} action\n * @return {Object} The state resulting from reducing the action with the\n * current state\n */\nexport default function eventLogging( state, action ) {\n\tlet nextCount, newState;\n\tconst actionTypesWithTokens = [\n\t\tactionTypes.FETCH_COMPLETE,\n\t\tactionTypes.ABANDON_END,\n\t\tactionTypes.PREVIEW_SHOW\n\t];\n\n\tif ( state === undefined ) {\n\t\tstate = {\n\t\t\tpreviewCount: undefined,\n\t\t\tbaseData: {},\n\t\t\tinteraction: undefined,\n\t\t\tevent: undefined\n\t\t};\n\t}\n\n\t// Was the action delayed? Then it requires a token to be reduced. Enforce\n\t// this here to avoid repetion and reduce nesting below.\n\tif (\n\t\tactionTypesWithTokens.indexOf( action.type ) !== -1 &&\n\t\t( !state.interaction || action.token !== state.interaction.token )\n\t) {\n\t\treturn state;\n\t}\n\n\t// If there is no interaction ongoing, ignore all actions except for:\n\t// * Application initialization\n\t// * New link dwells (which start a new interaction)\n\t// * Clearing queued events\n\t//\n\t// For example, after ctrl+clicking a link or preview, any other actions\n\t// until the new interaction should be ignored.\n\tif (\n\t\t!state.interaction &&\n\t\taction.type !== actionTypes.BOOT &&\n\t\taction.type !== actionTypes.LINK_DWELL &&\n\t\taction.type !== actionTypes.EVENT_LOGGED &&\n\t\taction.type !== actionTypes.SETTINGS_CHANGE\n\t) {\n\t\treturn state;\n\t}\n\tswitch ( action.type ) {\n\t\tcase actionTypes.BOOT:\n\t\t\treturn nextState( state, {\n\t\t\t\tpreviewCount: action.user.previewCount,\n\t\t\t\tbaseData: getBaseData( action ),\n\t\t\t\tevent: {\n\t\t\t\t\taction: 'pageLoaded'\n\t\t\t\t}\n\t\t\t} );\n\n\t\tcase actionTypes.EVENT_LOGGED:\n\t\t\tnewState = nextState( state, {\n\t\t\t\tevent: undefined\n\t\t\t} );\n\n\t\t\t// If an event was logged with an interaction token, and it is still\n\t\t\t// the current interaction, finish the interaction since logging is\n\t\t\t// the exit point of the state machine and an interaction should never\n\t\t\t// be logged twice.\n\t\t\tif (\n\t\t\t\taction.event.linkInteractionToken &&\n\t\t\t\tstate.interaction &&\n\t\t\t\t( action.event.linkInteractionToken === state.interaction.token )\n\t\t\t) {\n\t\t\t\tnewState.interaction = undefined;\n\t\t\t}\n\t\t\treturn newState;\n\n\t\tcase actionTypes.FETCH_COMPLETE:\n\t\t\treturn nextState( state, {\n\t\t\t\tinteraction: nextState( state.interaction, {\n\t\t\t\t\tpreviewType: action.result.type\n\t\t\t\t} )\n\t\t\t} );\n\n\t\tcase actionTypes.PREVIEW_SHOW:\n\t\t\tnextCount = state.previewCount + 1;\n\n\t\t\treturn nextState( state, {\n\t\t\t\tpreviewCount: nextCount,\n\t\t\t\tbaseData: nextState( state.baseData, {\n\t\t\t\t\tpreviewCountBucket: counts.getPreviewCountBucket( nextCount )\n\t\t\t\t} ),\n\t\t\t\tinteraction: nextState( state.interaction, {\n\t\t\t\t\ttimeToPreviewShow:\n\t\t\t\t\t\tMath.round( action.timestamp - state.interaction.started )\n\t\t\t\t} )\n\t\t\t} );\n\n\t\tcase actionTypes.LINK_DWELL:\n\n\t\t\t// Not a new interaction?\n\t\t\tif ( state.interaction && action.el === state.interaction.link ) {\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tinteraction: nextState( state.interaction, {\n\t\t\t\t\t\tisUserDwelling: true\n\t\t\t\t\t} )\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn nextState( state, {\n\n\t\t\t\t// TODO: Extract this object into a module that can be shared between\n\t\t\t\t// this and the preview reducer.\n\t\t\t\tinteraction: {\n\t\t\t\t\tlink: action.el,\n\t\t\t\t\ttitle: action.title,\n\t\t\t\t\tnamespaceId: action.namespaceId,\n\t\t\t\t\ttoken: action.token,\n\t\t\t\t\tstarted: action.timestamp,\n\n\t\t\t\t\tisUserDwelling: true\n\t\t\t\t},\n\n\t\t\t\t// Was the user interacting with another link? If so, then log the\n\t\t\t\t// abandoned event.\n\t\t\t\tevent: state.interaction ?\n\t\t\t\t\tcreateClosingEvent( state.interaction ) : undefined\n\t\t\t} );\n\n\t\tcase actionTypes.PREVIEW_DWELL:\n\t\t\treturn nextState( state, {\n\t\t\t\tinteraction: nextState( state.interaction, {\n\t\t\t\t\tisUserDwelling: true\n\t\t\t\t} )\n\t\t\t} );\n\n\t\tcase actionTypes.LINK_CLICK:\n\t\t\treturn nextState( state, {\n\t\t\t\tinteraction: nextState( state.interaction, {\n\t\t\t\t\tfinalized: true\n\t\t\t\t} ),\n\t\t\t\tevent: createEvent( state.interaction, {\n\t\t\t\t\taction: 'opened',\n\t\t\t\t\ttotalInteractionTime:\n\t\t\t\t\t\tMath.round( action.timestamp - state.interaction.started )\n\t\t\t\t} )\n\t\t\t} );\n\n\t\tcase actionTypes.ABANDON_START:\n\t\t\treturn nextState( state, {\n\t\t\t\tinteraction: nextState( state.interaction, {\n\t\t\t\t\tfinished: action.timestamp,\n\n\t\t\t\t\tisUserDwelling: false\n\t\t\t\t} )\n\t\t\t} );\n\n\t\tcase actionTypes.ABANDON_END:\n\t\t\tif ( !state.interaction.isUserDwelling ) {\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tinteraction: undefined,\n\t\t\t\t\tevent: createClosingEvent( state.interaction )\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn state;\n\n\t\tcase actionTypes.SETTINGS_SHOW:\n\t\t\treturn nextState( state, {\n\t\t\t\tevent: createEvent( state.interaction, {\n\t\t\t\t\taction: 'tapped settings cog'\n\t\t\t\t} )\n\t\t\t} );\n\n\t\tcase actionTypes.SETTINGS_CHANGE:\n\t\t\tif ( action.wasEnabled && !action.enabled ) {\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tevent: {\n\t\t\t\t\t\taction: 'disabled',\n\t\t\t\t\t\tpopupEnabled: false\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\treturn state;\n\t\t\t}\n\t\tdefault:\n\t\t\treturn state;\n\t}\n}\n","import eventLogging from './eventLogging';\nimport pageviews from './pageviews';\nimport preview from './preview';\nimport settings from './settings';\nimport statsv from './statsv';\n\nexport default {\n\teventLogging,\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} 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} 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: undefined,\n\t\t\tactiveLink: undefined,\n\t\t\tactiveEvent: undefined,\n\t\t\tactiveToken: '',\n\t\t\tshouldShow: false,\n\t\t\tisUserDwelling: 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.isEnabled\n\t\t\t} );\n\n\t\tcase actionTypes.SETTINGS_CHANGE:\n\t\t\treturn nextState( state, {\n\t\t\t\tenabled: action.enabled\n\t\t\t} );\n\n\t\tcase actionTypes.LINK_DWELL:\n\t\t\t// New interaction\n\t\t\tif ( action.el !== state.activeLink ) {\n\t\t\t\treturn nextState( state, {\n\t\t\t\t\tactiveLink: action.el,\n\t\t\t\t\tactiveEvent: action.event,\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} );\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.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\tactiveToken: undefined,\n\t\t\t\t\tactiveEvent: 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} );\n\n\t\tcase actionTypes.FETCH_START:\n\t\t\treturn nextState( state, {\n\t\t\t\tfetchResponse: undefined\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} 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\treturn action.wasEnabled === action.enabled ?\n\t\t\t\t// If the setting is the same, just hide the dialogs\n\t\t\t\tnextState( state, {\n\t\t\t\t\tshouldShow: false\n\t\t\t\t} ) :\n\t\t\t\t// If the settings have changed...\n\t\t\t\tnextState( state, {\n\t\t\t\t\t// If we enabled, we just hide directly, no help\n\t\t\t\t\t// If we disabled, keep it showing and let the ui show the help.\n\t\t\t\t\tshouldShow: !action.enabled,\n\t\t\t\t\tshowHelp: !action.enabled,\n\n\t\t\t\t\t// Since the footer link is only ever shown to anonymous users (see\n\t\t\t\t\t// the BOOT case below), state.userIsAnon is always truthy here.\n\t\t\t\t\tshouldShowFooterLink: !action.enabled\n\t\t\t\t} );\n\n\t\tcase actionTypes.BOOT:\n\t\t\treturn nextState( state, {\n\t\t\t\tshouldShowFooterLink: action.user.isAnon && !action.isEnabled\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 may result in an event being logged via statsv.\n *\n * @param {Object} 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 * What is the bucket for the given user given the enabled sampling rate?\n *\n * @param {mw.experiments} experiments The `mw.experiments` singleton instance\n * @param {Number} experimentGroupSize [0,1] of users of which should be\n * subjected to an A/B test. The remaining users will be put in the 'off'\n * bucket.\n * @param {string} sessionId a unique session token\n *\n * @return {string} bucket that the user belongs to (off/control/on)\n */\nfunction getUserBucket( experiments, experimentGroupSize, sessionId ) {\n\tconst control = experimentGroupSize / 2;\n\tif ( !experimentGroupSize ) {\n\t\t// no users are subject to experiment\n\t\treturn 'on';\n\t}\n\n\treturn experiments.getBucket( {\n\t\tname: 'ext.Popups.visibility',\n\t\tenabled: true,\n\t\tbuckets: {\n\t\t\toff: 1 - experimentGroupSize,\n\t\t\tcontrol,\n\t\t\ton: control\n\t\t}\n\t}, sessionId );\n}\n\nexport default getUserBucket;\n","/**\n * @module popups\n */\n\nimport * as Redux from 'redux';\nimport * as ReduxThunk from 'redux-thunk';\n\nimport createGateway from './gateway';\nimport createUserSettings from './userSettings';\nimport createPreviewBehavior from './previewBehavior';\nimport createSettingsDialogRenderer from './ui/settingsDialogRenderer';\nimport registerChangeListener from './changeListener';\nimport createIsEnabled from './isEnabled';\nimport { fromElement as titleFromElement } from './title';\nimport { init as rendererInit } from './ui/renderer';\nimport createExperiments from './experiments';\nimport { isEnabled as isStatsvEnabled } from './instrumentation/statsv';\nimport { isEnabled as isEventLoggingEnabled }\n\tfrom './instrumentation/eventLogging';\nimport changeListeners from './changeListeners';\nimport * as actions from './actions';\nimport reducers from './reducers';\nimport createMediaWikiPopupsObject from './integrations/mwpopups';\nimport getUserBucket from './getUserBucket';\n\nconst mw = mediaWiki,\n\t$ = jQuery,\n\n\tBLACKLISTED_LINKS = [\n\t\t'.extiw',\n\t\t'.image',\n\t\t'.new',\n\t\t'.internal',\n\t\t'.external',\n\t\t'.oo-ui-buttonedElement-button',\n\t\t'.cancelLink a'\n\t];\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 * `$.noop`.\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 : $.noop;\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 : $.noop;\n}\n\n/**\n * Gets the appropriate analytics event tracker for logging EventLogging events\n * via [the \"EventLogging subscriber\" analytics event protocol][0].\n *\n * If logging EventLogging events is enabled for the duration of the user's\n * session, then the appriopriate function is `mw.track`; otherwise it's\n * `$.noop`.\n *\n * [0]: https://github.com/wikimedia/mediawiki-extensions-EventLogging/blob/d1409759/modules/ext.eventLogging.subscriber.js\n *\n * @param {Object} user\n * @param {Object} config\n * @param {String} bucket for user\n * @param {Window} window\n * @return {EventTracker}\n */\nfunction getEventLoggingTracker( user, config, bucket, window ) {\n\treturn isEventLoggingEnabled(\n\t\tuser,\n\t\tconfig,\n\t\tbucket,\n\t\twindow\n\t) ? mw.track : $.noop;\n}\n\n/**\n * Returns timestamp since the beginning of the current document's origin\n * as reported by `window.performance.now()`. See\n * https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#The_time_origin\n * for a detailed explanation of the time origin.\n *\n * The value returned by this function is used for [the `timestamp` property\n * of the Schema:Popups events sent by the EventLogging\n * instrumentation](./src/changeListeners/eventLogging.js).\n *\n * @return {number|null}\n */\nfunction getCurrentTimestamp() {\n\tif ( window.performance && window.performance.now ) {\n\t\t// return an integer; see T182000\n\t\treturn Math.round( window.performance.now() );\n\t}\n\treturn null;\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} actions\n * @param {UserSettings} userSettings\n * @param {Function} settingsDialog\n * @param {PreviewBehavior} previewBehavior\n * @param {EventTracker} statsvTracker\n * @param {EventTracker} eventLoggingTracker\n * @param {EventTracker} pageviewTracker\n * @param {Function} getCurrentTimestamp\n */\nfunction registerChangeListeners(\n\tstore, actions, userSettings, settingsDialog, previewBehavior,\n\tstatsvTracker, eventLoggingTracker, pageviewTracker, getCurrentTimestamp\n) {\n\tregisterChangeListener( store, changeListeners.footerLink( actions ) );\n\tregisterChangeListener( store, changeListeners.linkTitle() );\n\tregisterChangeListener( store, changeListeners.render( previewBehavior ) );\n\tregisterChangeListener(\n\t\tstore, changeListeners.statsv( actions, statsvTracker ) );\n\tregisterChangeListener(\n\t\tstore, changeListeners.syncUserSettings( userSettings ) );\n\tregisterChangeListener(\n\t\tstore, changeListeners.settings( actions, settingsDialog ) );\n\tregisterChangeListener(\n\t\tstore,\n\t\tchangeListeners.eventLogging(\n\t\t\tactions, eventLoggingTracker, getCurrentTimestamp\n\t\t) );\n\tregisterChangeListener( store,\n\t\tchangeListeners.pageviews( actions, pageviewTracker )\n\t);\n}\n\n/*\n * Initialize the application by:\n * 1. Creating the state store\n * 2. Binding the actions to such store\n * 3. Trigger the boot action to bootstrap the system\n * 4. When the page content is ready:\n * - Process the eligible links for page previews\n * - Initialize the renderer\n * - Bind hover and click events to the eligible links to trigger actions\n */\nmw.requestIdleCallback( function () {\n\tlet compose = Redux.compose;\n\tconst\n\t\t// So-called \"services\".\n\t\tgenerateToken = mw.user.generateRandomSessionId,\n\t\tgateway = createGateway( mw.config );\n\n\tconst userBucket = getUserBucket(\n\t\tmw.experiments,\n\t\tmw.config.get( 'wgPopupsAnonsExperimentalGroupSize' ),\n\t\tmw.user.sessionId() );\n\tconst userSettings = createUserSettings( mw.storage );\n\tconst settingsDialog = createSettingsDialogRenderer();\n\tconst experiments = createExperiments( mw.experiments );\n\tconst statsvTracker = getStatsvTracker( mw.user, mw.config, experiments );\n\t// Virtual pageviews are always tracked.\n\tconst pageviewTracker = getPageViewTracker( mw.config );\n\tconst eventLoggingTracker = getEventLoggingTracker(\n\t\tmw.user,\n\t\tmw.config,\n\t\tuserBucket,\n\t\twindow\n\t);\n\n\tconst isEnabled =\n\t\tcreateIsEnabled( mw.user, userSettings, mw.config, userBucket );\n\n\t// If debug mode is enabled, then enable Redux DevTools.\n\tif ( mw.config.get( 'debug' ) === true ) {\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\n\tconst previewBehavior =\n\t\tcreatePreviewBehavior( mw.config, mw.user, boundActions );\n\n\tregisterChangeListeners(\n\t\tstore, boundActions, userSettings, settingsDialog,\n\t\tpreviewBehavior, statsvTracker, eventLoggingTracker,\n\t\tpageviewTracker,\n\t\tgetCurrentTimestamp\n\t);\n\n\tboundActions.boot(\n\t\tisEnabled,\n\t\tmw.user,\n\t\tuserSettings,\n\t\tgenerateToken,\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( store );\n\n\tmw.hook( 'wikipage.content' ).add( function ( $container ) {\n\t\tconst invalidLinksSelector = BLACKLISTED_LINKS.join( ', ' ),\n\t\t\tvalidLinkSelector = `a[href][title]:not(${ invalidLinksSelector })`;\n\n\t\trendererInit();\n\n\t\t$container\n\t\t\t.on( 'mouseover keyup', validLinkSelector, function ( event ) {\n\t\t\t\tconst mwTitle = titleFromElement( this, mw.config );\n\n\t\t\t\tif ( mwTitle ) {\n\t\t\t\t\tboundActions.linkDwell(\n\t\t\t\t\t\tmwTitle, this, event, gateway, generateToken\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.on( 'mouseout blur', validLinkSelector, function () {\n\t\t\t\tconst mwTitle = titleFromElement( this, mw.config );\n\n\t\t\t\tif ( mwTitle ) {\n\t\t\t\t\tboundActions.abandon( this );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.on( 'click', validLinkSelector, function () {\n\t\t\t\tconst mwTitle = titleFromElement( this, mw.config );\n\n\t\t\t\tif ( mwTitle ) {\n\t\t\t\t\tboundActions.linkClick( this );\n\t\t\t\t}\n\t\t\t} );\n\t} );\n} );\n\nwindow.Redux = Redux;\nwindow.ReduxThunk = ReduxThunk;\n","/**\n * @module instrumentation/eventLogging\n */\nimport { BUCKETS } from './../constants';\n\n/**\n * Gets whether EventLogging logging is enabled for the duration of the user's\n * session.\n * If wgPopupsEventLogging is false this will return false unless debug=true has\n * been enabled.\n * If an experiment is being run (ie. wgPopupsAnonsExperimentalGroupSize has\n * been defined) then event logging will only be enabled for those in the `on`\n * or `control` groups.\n * However, if the UA doesn't support [the Beacon API][1], then bucketing is\n * disabled.\n *\n * [1]: https://w3c.github.io/beacon/\n *\n * @param {mw.user} user The `mw.user` singleton instance\n * @param {mw.Map} config The `mw.config` singleton instance\n * @param {String} bucket that the user is in (see constants.js)\n * @param {Window} window\n * @return {Boolean}\n */\nexport function isEnabled( user, config, bucket, window ) {\n\t// if debug mode is on, always enable event logging. @see T168847\n\tif ( config.get( 'debug' ) === true ) {\n\t\treturn true;\n\t}\n\n\tif ( !config.get( 'wgPopupsEventLogging' ) ) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\t!window.navigator ||\n\t\t!$.isFunction( window.navigator.sendBeacon )\n\t) {\n\t\treturn false;\n\t}\n\n\treturn user.isAnon() && bucket !== BUCKETS.off;\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\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 * @function\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\t'true': trueWeight,\n\t\t\t\t\t'false': 1 - trueWeight\n\t\t\t\t}\n\t\t\t}, token ) === 'true';\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 isEnabled\n */\nimport { BUCKETS } from './constants';\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 beta feature (see\n * `$wgPopupsBetaFeature`), the user must be logged in and have enabled the\n * beta feature in order to see previews. Logged out users won't be able\n * to see the feature.\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. Logged out users who have not\n * disabled or enabled the previews via the settings modal will be subject to\n * wgPopupsAnonsExperimentalGroupSize if defined.\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 * @param {String} bucket the user belongs to (off, on or control)\n *\n * @return {Boolean}\n */\nexport default function isEnabled( user, userSettings, config, bucket ) {\n\tif ( config.get( 'wgPopupsConflictsWithNavPopupGadget' ) ) {\n\t\treturn false;\n\t}\n\n\tif ( !user.isAnon() ) {\n\t\treturn config.get( 'wgPopupsShouldSendModuleToUser' );\n\t}\n\n\tif ( config.get( 'wgPopupsBetaFeature' ) ) {\n\t\treturn false;\n\t}\n\n\tif ( !userSettings.hasIsEnabled() ) {\n\t\treturn bucket === BUCKETS.on;\n\t}\n\n\treturn userSettings.getIsEnabled();\n}\n","/**\n * @module MediaWiki-Popups Integration\n */\n\n/**\n * This function provides a mw.popups object which can be used by 3rd party\n * to interact with Popups. Currently it allows only to read isEnabled flag.\n *\n * @param {Redux.Store} store Popups store\n * @return {Object} external Popups interface\n */\nexport default function createMwPopups( store ) {\n\treturn {\n\t\tisEnabled: function isEnabled() {\n\t\t\treturn store.getState().preview.enabled;\n\t\t}\n\t};\n\n}\n","module.exports = \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"0\\\" height=\\\"0\\\"><defs><clippath id=\\\"mwe-popups-mask\\\"><polygon points=\\\"0 8, 10 8, 18 0, 26 8, 1000 8, 1000 1000, 0 1000\\\"></polygon></clippath><clippath id=\\\"mwe-popups-mask-flip\\\"><polygon points=\\\"0 8, 274 8, 282 0, 290 8, 1000 8, 1000 1000, 0 1000\\\"></polygon></clippath><clippath id=\\\"mwe-popups-landscape-mask\\\"><polygon points=\\\"0 8, 174 8, 182 0, 190 8, 1000 8, 1000 1000, 0 1000\\\"></polygon></clippath><clippath id=\\\"mwe-popups-landscape-mask-flip\\\"><polygon points=\\\"0 0, 1000 0, 1000 242, 190 242, 182 250, 174 242, 0 242\\\"></polygon></clippath></defs></svg>\""],"sourceRoot":""}