mediawiki-extensions-Popups/resources/dist/index.js
Stephen Niedzielski 8ca0cf2088 Fix: preview page URL for 404 RESTBase responses
Functional changes:

- Require page URL when constructing a PreviewModel null object. These
  models have valid titles and are used to display a preview when an
  extract is unobtainable. When presented with an empty URL, their
  linkage incorrectly pointed to the browser's current URL. Additional
  tests were added to verify the fix.

- Check missing title in addition to falsy response in RESTBase gateway
  and update the test assertion to check title. It isn't clear if this
  can happen in the wild.

- Forbid state mutation in the conclusion of
  MediaWikiGateway.getPageSummary() with a call to Deferred.promise().
  This is consistent with the rest of repo including RESTBaseGateway.

  http://api.jquery.com/deferred.promise/

Nonfunctional changes:

- Collapse two RESTBase gateway 404 tests into one as the scenarios and
  expectations were very similar.

- Add failure HTTP status to 'MediaWiki API gateway handles API failure'
  test stub HTTP response for consistency with other cases.

- Add nullity expectations to JSDocs touched and fix a couple typos
  throughout.

- Make the gateway tests a little more consistent by collapsing Deferred
  variable usage where appropriate.

This change is necessary to the completion of T183151 which uses the
PreviewModel null objects for additional error cases.

Bug: T183151
Change-Id: Ib77627fb9c80d8e806208bbafcfc615b130e3278
2018-01-16 18:36:48 -06:00

2 lines
36 KiB
JavaScript

!function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./src/index.js")}({"./node_modules/redux-thunk/dist/redux-thunk.min.js":function(e,t,n){!function(t,n){e.exports=n()}(0,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t){"use strict";function n(e){return function(t){var n=t.dispatch,i=t.getState;return function(t){return function(r){return"function"==typeof r?r(n,i,e):t(r)}}}}t.__esModule=!0;var i=n();i.withExtraArgument=n,t.default=i}])})},"./node_modules/redux/dist/redux.min.js":function(e,t,n){!function(t,n){e.exports=n()}(0,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.compose=t.applyMiddleware=t.bindActionCreators=t.combineReducers=t.createStore=void 0;var r=n(2),o=i(r),s=n(7),a=i(s),u=n(6),c=i(u),p=n(5),l=i(p),d=n(1),f=i(d);i(n(3)),t.createStore=o.default,t.combineReducers=a.default,t.bindActionCreators=c.default,t.applyMiddleware=l.default,t.compose=f.default},function(e,t){"use strict";function n(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];if(0===t.length)return function(e){return e};if(1===t.length)return t[0];var i=t[t.length-1],r=t.slice(0,-1);return function(){return r.reduceRight(function(e,t){return t(e)},i.apply(void 0,arguments))}}t.__esModule=!0,t.default=n},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){function i(){w===v&&(w=v.slice())}function o(){return h}function a(e){if("function"!=typeof e)throw Error("Expected listener to be a function.");var t=!0;return i(),w.push(e),function(){if(t){t=!1,i();var n=w.indexOf(e);w.splice(n,1)}}}function p(e){if(!(0,s.default)(e))throw Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(m)throw Error("Reducers may not dispatch actions.");try{m=!0,h=g(h,e)}finally{m=!1}for(var t=v=w,n=0;t.length>n;n++)t[n]();return e}function l(e){if("function"!=typeof e)throw Error("Expected the nextReducer to be a function.");g=e,p({type:c.INIT})}function d(){var e,t=a;return e={subscribe:function(e){function n(){e.next&&e.next(o())}if("object"!=typeof e)throw new TypeError("Expected the observer to be an object.");return n(),{unsubscribe:t(n)}}},e[u.default]=function(){return this},e}var f;if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw Error("Expected the enhancer to be a function.");return n(r)(e,t)}if("function"!=typeof e)throw Error("Expected the reducer to be a function.");var g=e,h=t,v=[],w=v,m=!1;return p({type:c.INIT}),f={dispatch:p,subscribe:a,getState:o,replaceReducer:l},f[u.default]=d,f}t.__esModule=!0,t.ActionTypes=void 0,t.default=r;var o=n(4),s=i(o),a=n(12),u=i(a),c=t.ActionTypes={INIT:"@@redux/INIT"}},function(e,t){"use strict";function n(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw Error(e)}catch(e){}}t.__esModule=!0,t.default=n},function(e,t,n){function i(e){if(!s(e)||f.call(e)!=a||o(e))return!1;var t=r(e);if(null===t)return!0;var n=l.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&p.call(n)==d}var r=n(8),o=n(9),s=n(11),a="[object Object]",u=Function.prototype,c=Object.prototype,p=u.toString,l=c.hasOwnProperty,d=p.call(Object),f=c.toString;e.exports=i},function(e,t,n){"use strict";function i(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(e){return function(n,i,o){var a=e(n,i,o),u=a.dispatch,c=[],p={getState:a.getState,dispatch:function(e){return u(e)}};return c=t.map(function(e){return e(p)}),u=s.default.apply(void 0,c)(a.dispatch),r({},a,{dispatch:u})}}}t.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e};t.default=i;var o=n(1),s=function(e){return e&&e.__esModule?e:{default:e}}(o)},function(e,t){"use strict";function n(e,t){return function(){return t(e.apply(void 0,arguments))}}function i(e,t){if("function"==typeof e)return n(e,t);if("object"!=typeof e||null===e)throw Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var i=Object.keys(e),r={},o=0;i.length>o;o++){var s=i[o],a=e[s];"function"==typeof a&&(r[s]=n(a,t))}return r}t.__esModule=!0,t.default=i},function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=t&&t.type;return"Given action "+(n&&'"'+n+'"'||"an action")+', reducer "'+e+'" returned undefined. To ignore an action, you must explicitly return the previous state.'}function o(e){Object.keys(e).forEach(function(t){var n=e[t];if(void 0===n(void 0,{type:a.ActionTypes.INIT}))throw Error('Reducer "'+t+'" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.');if(void 0===n(void 0,{type:"@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".")}))throw Error('Reducer "'+t+"\" returned undefined when probed with a random type. Don't try to handle "+a.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 s(e){for(var t=Object.keys(e),n={},i=0;t.length>i;i++){var s=t[i];"function"==typeof e[s]&&(n[s]=e[s])}var a,u=Object.keys(n);try{o(n)}catch(e){a=e}return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];if(a)throw a;for(var i=!1,o={},s=0;u.length>s;s++){var c=u[s],p=n[c],l=e[c],d=p(l,t);if(void 0===d){var f=r(c,t);throw Error(f)}o[c]=d,i=i||d!==l}return i?o:e}}t.__esModule=!0,t.default=s;var a=n(2);i((i(n(4)),n(3)))},function(e,t,n){var i=n(10),r=i(Object.getPrototypeOf,Object);e.exports=r},function(e,t){function n(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}e.exports=n},function(e,t){function n(e,t){return function(n){return e(t(n))}}e.exports=n},function(e,t){function n(e){return!!e&&"object"==typeof e}e.exports=n},function(e,t,n){e.exports=n(13)},function(e,t,n){(function(e){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(14),r=function(e){return e&&e.__esModule?e:{default:e}}(i),o=void 0;void 0!==e?o=e:"undefined"!=typeof window&&(o=window);var s=(0,r.default)(o);t.default=s}).call(t,function(){return this}())},function(e,t){"use strict";function n(e){var t,n=e.Symbol;return"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n}])})},"./src/actionTypes.js":function(e,t,n){"use strict";t.a={BOOT:"BOOT",LINK_DWELL:"LINK_DWELL",ABANDON_START:"ABANDON_START",ABANDON_END:"ABANDON_END",LINK_CLICK:"LINK_CLICK",FETCH_START:"FETCH_START",FETCH_END:"FETCH_END",FETCH_COMPLETE:"FETCH_COMPLETE",FETCH_FAILED:"FETCH_FAILED",PREVIEW_DWELL:"PREVIEW_DWELL",PREVIEW_SHOW:"PREVIEW_SHOW",PREVIEW_CLICK:"PREVIEW_CLICK",SETTINGS_SHOW:"SETTINGS_SHOW",SETTINGS_HIDE:"SETTINGS_HIDE",SETTINGS_CHANGE:"SETTINGS_CHANGE",EVENT_LOGGED:"EVENT_LOGGED",STATSV_LOGGED:"STATSV_LOGGED"}},"./src/actions.js":function(e,t,n){"use strict";function i(e){return e.timestamp=T.now(),e}function r(e,t,n,i,r){var o=r.get("wgUserEditCount"),s=n.getPreviewCount();return{type:v.a.BOOT,isEnabled:e,isNavPopupsEnabled:r.get("wgPopupsConflictsWithNavPopupGadget"),sessionToken:t.sessionId(),pageToken:i(),page:{title:r.get("wgTitle"),namespaceID:r.get("wgNamespaceNumber"),id:r.get("wgArticleId")},user:{isAnon:t.isAnon(),editCount:o,previewCount:s}}}function o(e,t,r,o){var s=t.getPrefixedDb(),a=t.namespace;return function(t){var u;return t(i({type:v.a.FETCH_START,el:r,title:s,namespaceID:a})),u=e.getPageSummary(s).then(function(e){return t(i({type:v.a.FETCH_END,el:r})),e}).fail(function(){t({type:v.a.FETCH_FAILED,el:r})}),m.when(u,n.i(w.a)(y-E)).then(function(e){t(i({type:v.a.FETCH_COMPLETE,el:r,result:e,token:o}))})}}function s(e,t,r,s,a){var u=a(),c=e.getPrefixedDb(),p=e.namespace;return function(a,l){function d(){return l().preview.activeToken===u}var f=i({type:v.a.LINK_DWELL,el:t,event:r,token:u,title:c,namespaceID:p});a(f),d()&&n.i(w.a)(E).then(function(){l().preview.enabled&&d()&&a(o(s,e,t,u))})}}function a(){return function(e,t){var r=t().preview.activeToken;r&&(e(i({type:v.a.ABANDON_START,token:r})),n.i(w.a)(b).then(function(){e({type:v.a.ABANDON_END,token:r})}))}}function u(e){return i({type:v.a.LINK_CLICK,el:e})}function c(){return{type:v.a.PREVIEW_DWELL}}function p(e){return i({type:v.a.PREVIEW_SHOW,token:e})}function l(){return{type:v.a.SETTINGS_SHOW}}function d(){return{type:v.a.SETTINGS_HIDE}}function f(e){return function(t,n){t({type:v.a.SETTINGS_CHANGE,wasEnabled:n().preview.enabled,enabled:e})}}function g(e){return{type:v.a.EVENT_LOGGED,event:e}}function h(){return{type:v.a.STATSV_LOGGED}}Object.defineProperty(t,"__esModule",{value:!0}),t.boot=r,t.fetch=o,t.linkDwell=s,t.abandon=a,t.linkClick=u,t.previewDwell=c,t.previewShow=p,t.showSettings=l,t.hideSettings=d,t.saveSettings=f,t.eventLogged=g,t.statsvLogged=h;var v=n("./src/actionTypes.js"),w=n("./src/wait.js"),m=jQuery,T=window.mediaWiki,E=150,y=500,b=300},"./src/changeListener.js":function(e,t,n){"use strict";function i(e,t){var n;e.subscribe(function(){var i=n;n=e.getState(),i!==n&&t(i,n)})}t.a=i},"./src/changeListeners/eventLogging.js":function(e,t,n){"use strict";function i(e,t,n){return function(i,o){var s=o.eventLogging,a=s.event;a&&(a=r.extend(!0,{},s.baseData,a,{timestamp:n()}),t("event.Popups",a),e.eventLogged(a))}}t.a=i;var r=jQuery},"./src/changeListeners/footerLink.js":function(e,t,n){"use strict";function i(){var e,t=s("<li>").append(s("<a>").attr("href","#").text(o.message("popups-settings-enable").text()));return t.hide(),e=s("#footer-places, #f-list"),0===e.length&&(e=s("#footer li").parent()),e.append(t),t}function r(e){var t;return function(n,r){void 0===t&&(t=i(),t.click(function(t){t.preventDefault(),e.showSettings()})),r.settings.shouldShowFooterLink?t.show():t.hide()}}t.a=r;var o=window.mediaWiki,s=jQuery},"./src/changeListeners/index.js":function(e,t,n){"use strict";var i=n("./src/changeListeners/footerLink.js"),r=n("./src/changeListeners/eventLogging.js"),o=n("./src/changeListeners/linkTitle.js"),s=n("./src/changeListeners/render.js"),a=n("./src/changeListeners/settings.js"),u=n("./src/changeListeners/statsv.js"),c=n("./src/changeListeners/syncUserSettings.js");t.a={footerLink:i.a,eventLogging:r.a,linkTitle:o.a,render:s.a,settings:a.a,statsv:u.a,syncUserSettings:c.a}},"./src/changeListeners/linkTitle.js":function(e,t,n){"use strict";function i(){function e(e){var t=r(e);n||(n=t.attr("title"),t.attr("title",""))}function t(e){r(e).attr("title",n),n=void 0}var n;return function(n,i){var r=n&&n.preview.activeLink;i.preview.enabled&&(r&&n.preview.activeLink!==i.preview.activeLink&&t(n.preview.activeLink),i.preview.activeLink&&e(i.preview.activeLink))}}t.a=i;var r=jQuery},"./src/changeListeners/render.js":function(e,t,n){"use strict";function i(e){var t;return function(n,i){i.preview.shouldShow&&!t?(t=r.b(i.preview.fetchResponse),t.show(i.preview.activeEvent,e,i.preview.activeToken)):!i.preview.shouldShow&&t&&(t.hide(),t=void 0)}}t.a=i;var r=n("./src/ui/renderer.js")},"./src/changeListeners/settings.js":function(e,t,n){"use strict";function i(e,t){var n;return function(i,r){i&&(!1===i.settings.shouldShow&&!0===r.settings.shouldShow?(n||(n=t(e),n.appendTo(document.body)),n.setEnabled(r.preview.enabled),n.show()):!0===i.settings.shouldShow&&!1===r.settings.shouldShow&&n.hide(),i.settings.showHelp!==r.settings.showHelp&&n.toggleHelp(r.settings.showHelp))}}t.a=i},"./src/changeListeners/statsv.js":function(e,t,n){"use strict";function i(e,t){return function(n,i){var r=i.statsv;r.action&&(t(r.action,r.data),e.statsvLogged())}}t.a=i},"./src/changeListeners/syncUserSettings.js":function(e,t,n){"use strict";function i(e){return function(t,n){o(t,n,"eventLogging","previewCount",e.setPreviewCount),o(t,n,"preview","enabled",e.setIsEnabled)}}function r(e,t,n){return e[t]&&e[t][n]}function o(e,t,n,i,o){var s=r(t,n,i);e&&r(e,n,i)!==s&&o(s)}t.a=i},"./src/constants.js":function(e,t,n){"use strict";n.d(t,"a",function(){return o});var i=jQuery,r=i.bracketedDevicePixelRatio&&i.bracketedDevicePixelRatio()||1,o={off:"off",on:"on",control:"control"};t.b={THUMBNAIL_SIZE:320*r,EXTRACT_LENGTH:525}},"./src/counts.js":function(e,t){t.getEditCountBucket=function(e){var t;return 0===e?t="0":e>=1&&e<=4?t="1-4":e>=5&&e<=99?t="5-99":e>=100&&e<=999?t="100-999":e>=1e3&&(t="1000+"),t+" edits"},t.getPreviewCountBucket=function(e){var t;return 0===e?t="0":e>=1&&e<=4?t="1-4":e>=5&&e<=20?t="5-20":e>=21&&(t="21+"),void 0!==t?t+" previews":"unknown"}},"./src/experiments.js":function(e,t,n){"use strict";function i(e){return{weightedBoolean:function(t,n,i){return"true"===e.getBucket({enabled:!0,name:t,buckets:{true:n,false:1-n}},i)}}}t.a=i},"./src/formatter.js":function(e,t,n){"use strict";function i(e,t){var n=e;return void 0===e?[]:(n=s(n),n=o(n),0===n.length?[]:n=r(n,t))}function r(e,t){var n,i,r=[],o="<bi-"+Math.random()+">",s="<snip-"+Math.random()+">";return t=t.replace(/\s+/g," ").trim(),i=u.RegExp.escape(t),n=new RegExp("(^|\\s)("+i+")(|$)","i"),e=e.replace(/\s+/," "),e=e.replace(n,"$1"+s+o+"$2"+s+"$3"),e=e.split(s),a.each(e,function(e,t){0===t.indexOf(o)?r.push(a("<b>").text(t.substring(o.length))):r.push(document.createTextNode(t))}),r}function o(e){return e.replace(/\.\.\.$/,"")}function s(e){var t,n="",i=0,r=0;for(r;r<e.length;r++){if(")"===(t=e.charAt(r))&&0===i)return e;if("("!==t)if(")"!==t){if(0===i){if(" "===t&&"("===e.charAt(r+1))continue;n+=t}}else i--;else i++}return 0===i?n:e}t.c=i,t.a=o,t.b=s;var a=jQuery,u=window.mediaWiki},"./src/gateway/index.js":function(e,t,n){"use strict";function i(e){switch(e.get("wgPopupsGateway")){case"mwApiPlain":return n.i(o.a)(new u.Api,r.b);case"restbasePlain":return n.i(s.a)(c.ajax,r.b,a.a);case"restbaseHTML":return n.i(s.a)(c.ajax,r.b,a.b);default:throw new Error("Unknown gateway")}}t.a=i;var r=n("./src/constants.js"),o=n("./src/gateway/mediawiki.js"),s=n("./src/gateway/rest.js"),a=n("./src/gateway/restFormatters.js"),u=mediaWiki,c=jQuery},"./src/gateway/mediawiki.js":function(e,t,n){"use strict";function i(e,t){function n(n){return e.get({action:"query",prop:"info|extracts|pageimages|revisions|info",formatversion:2,redirects:!0,exintro:!0,exchars:t.EXTRACT_LENGTH,explaintext:!0,piprop:"thumbnail",pithumbsize:t.THUMBNAIL_SIZE,pilicense:"any",rvprop:"timestamp",inprop:"url",titles:n,smaxage:c,maxage:c,uselang:"content"},{headers:{"X-Analytics":"preview=1"}})}function i(e){return n(e).then(r).then(o).then(s).promise()}return{fetch:n,extractPageFromResponse:r,convertPageToModel:s,getPageSummary:i,formatPlainTextExtract:o}}function r(e){if(e.query&&e.query.pages&&e.query.pages.length)return e.query.pages[0];throw new Error("API response `query.pages` is empty.")}function o(e){var t=p.extend({},e);return t.extract=u.c(e.extract,e.title),t}function s(e){return n.i(a.b)(e.title,e.canonicalurl,e.pagelanguagehtmlcode,e.pagelanguagedir,e.extract,e.thumbnail)}t.a=i;var a=n("./src/preview/model.js"),u=n("./src/formatter.js"),c=300,p=jQuery},"./src/gateway/rest.js":function(e,t,n){"use strict";function i(e,t,i){function r(t){return e({url:a+encodeURIComponent(t),headers:{Accept:'application/json; charset=utf-8; profile="'+u+'"'}})}function l(e){var a=p.Deferred();return r(e).then(function(n){n&&n.title||(n=p.extend(!0,n||{},{title:e})),void 0===n.extract&&(n.extract=""),a.resolve(o(n,t.THUMBNAIL_SIZE,i))},function(t){404===t.status?a.resolve(n.i(s.a)(e,new c.Title(e).getUrl())):a.reject()}),a.promise()}return{fetch:r,convertPageToModel:o,getPageSummary:l}}function r(e,t,n){var i,r,o,s=e.source.split("/"),a=s[s.length-1];return i=a.substr(a.indexOf("px-")+3),e.width>e.height?(r=n,o=Math.floor(n/e.width*e.height)):(r=Math.floor(n/e.height*e.width),o=n),r>=t.width&&-1===i.indexOf(".svg")?t:(s[s.length-1]=r+"px-"+i,{source:s.join("/"),width:r,height:o})}function o(e,t,i){return n.i(s.b)(e.title,new c.Title(e.title).getUrl(),e.lang,e.dir,i(e),e.thumbnail?r(e.thumbnail,e.originalimage,t):void 0)}t.a=i;var s=n("./src/preview/model.js"),a="/api/rest_v1/page/summary/",u="https://www.mediawiki.org/wiki/Specs/Summary/1.2.0",c=window.mediaWiki,p=jQuery},"./src/gateway/restFormatters.js":function(e,t,n){"use strict";function i(e){var t=e.extract_html;return t=o.a(t),t=o.b(t),0===t.length?[]:$.parseHTML(t)}function r(e){return o.c(e.extract,e.title)}t.b=i,t.a=r;var o=n("./src/formatter.js")},"./src/getUserBucket.js":function(e,t,n){"use strict";function i(e,t,n){var i=t/2;return t?e.getBucket({name:"ext.Popups.visibility",enabled:!0,buckets:{off:1-t,control:i,on:i}},n):"on"}t.a=i},"./src/index.js":function(e,t,n){"use strict";function i(e,t,i){return n.i(m.a)(e,t,i)?x.track:j.noop}function r(e,t,i,r){return n.i(T.a)(e,t,i,r)?x.track:j.noop}function o(){return window.performance&&window.performance.now?Math.round(window.performance.now()):null}function s(e,t,i,r,o,s,a,u){n.i(f.a)(e,E.a.footerLink(t)),n.i(f.a)(e,E.a.linkTitle()),n.i(f.a)(e,E.a.render(o)),n.i(f.a)(e,E.a.statsv(t,s)),n.i(f.a)(e,E.a.syncUserSettings(i)),n.i(f.a)(e,E.a.settings(t,r)),n.i(f.a)(e,E.a.eventLogging(t,a,u))}Object.defineProperty(t,"__esModule",{value:!0});var a=n("./node_modules/redux/dist/redux.min.js"),u=(n.n(a),n("./node_modules/redux-thunk/dist/redux-thunk.min.js")),c=(n.n(u),n("./src/gateway/index.js")),p=n("./src/userSettings.js"),l=n("./src/previewBehavior.js"),d=n("./src/ui/settingsDialog.js"),f=n("./src/changeListener.js"),g=n("./src/isEnabled.js"),h=n("./src/title.js"),v=n("./src/ui/renderer.js"),w=n("./src/experiments.js"),m=n("./src/instrumentation/statsv.js"),T=n("./src/instrumentation/eventLogging.js"),E=n("./src/changeListeners/index.js"),y=n("./src/actions.js"),b=n("./src/reducers/index.js"),S=n("./src/integrations/mwpopups.js"),k=n("./src/getUserBucket.js"),x=mediaWiki,j=jQuery,_=[".extiw",".image",".new",".internal",".external",".oo-ui-buttonedElement-button",".cancelLink a"];x.requestIdleCallback(function(){var e,t,f,m,T,E,j,L,I,A,N=a.compose,C=x.user.generateRandomSessionId,D=n.i(c.a)(x.config);e=n.i(k.a)(x.experiments,x.config.get("wgPopupsAnonsExperimentalGroupSize"),x.user.sessionId()),m=n.i(p.a)(x.storage),T=n.i(d.a)(),E=n.i(w.a)(x.experiments),j=i(x.user,x.config,E),L=r(x.user,x.config,e,window),I=n.i(g.a)(x.user,m,x.config,e),!0===x.config.get("debug")&&(N=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||N),t=a.createStore(a.combineReducers(b.a),N(a.applyMiddleware(u.default))),f=a.bindActionCreators(y,t.dispatch),A=n.i(l.a)(x.config,x.user,f),s(t,f,m,T,A,j,L,o),f.boot(I,x.user,m,C,x.config),x.popups=n.i(S.a)(t),x.hook("wikipage.content").add(function(e){var t=_.join(", "),i="a[href][title]:not("+t+")";n.i(v.a)(),e.on("mouseover keyup",i,function(e){var t=n.i(h.a)(this,x.config);t&&f.linkDwell(t,this,e,D,C)}).on("mouseout blur",i,function(){n.i(h.a)(this,x.config)&&f.abandon(this)}).on("click",i,function(){n.i(h.a)(this,x.config)&&f.linkClick(this)})})}),window.Redux=a,window.ReduxThunk=u},"./src/instrumentation/eventLogging.js":function(e,t,n){"use strict";function i(e,t,n,i){return!0===t.get("debug")||!!t.get("wgPopupsEventLogging")&&(!(!i.navigator||!$.isFunction(i.navigator.sendBeacon))&&(e.isAnon()&&n!==r.a.off))}t.a=i;var r=n("./src/constants.js")},"./src/instrumentation/statsv.js":function(e,t,n){"use strict";function i(e,t,n){var i=t.get("wgPopupsStatsvSamplingRate",0);return n.weightedBoolean("ext.Popups.statsv",i,e.sessionId())}t.a=i},"./src/integrations/mwpopups.js":function(e,t,n){"use strict";function i(e){return{isEnabled:function(){return e.getState().preview.enabled}}}t.a=i},"./src/isEnabled.js":function(e,t,n){"use strict";function i(e,t,n,i){return!n.get("wgPopupsConflictsWithNavPopupGadget")&&(e.isAnon()?!n.get("wgPopupsBetaFeature")&&(t.hasIsEnabled()?t.getIsEnabled():i===r.a.on):n.get("wgPopupsShouldSendModuleToUser"))}t.a=i;var r=n("./src/constants.js")},"./src/preview/model.js":function(e,t,n){"use strict";function i(e,t,n,i,r,u){var c=o(r);return{title:e,url:t,languageCode:n,languageDirection:i,extract:c,type:void 0===c?s:a,thumbnail:u}}function r(e,t){return i(e,t,"","",[],"")}function o(e){if(void 0!==e&&null!==e&&0!==e.length)return e}t.b=i,t.a=r;var s="generic",a="page"},"./src/previewBehavior.js":function(e,t,n){"use strict";function i(e,t,n){var i,s,a=e.get("wgPopupsBetaFeature"),u=o.noop;return t.isAnon()?u=function(e){e.preventDefault(),n.showSettings()}:(i="Special:Preferences#mw-prefsection-",i+=a?"betafeatures":"rendering",s=r.Title.newFromText(i).getUrl()),{settingsUrl:s,showSettings:u,previewDwell:n.previewDwell,previewAbandon:n.abandon,previewShow:n.previewShow,click:n.linkClick}}t.a=i;var r=window.mediaWiki,o=jQuery},"./src/reducers/eventLogging.js":function(e,t,n){"use strict";function i(e){var t={pageTitleSource:e.page.title,namespaceIdSource:e.page.namespaceID,pageIdSource:e.page.id,isAnon:e.user.isAnon,popupEnabled:e.isEnabled,pageToken:e.pageToken,sessionToken:e.sessionToken,previewCountBucket:c.getPreviewCountBucket(e.user.previewCount),hovercardsSuppressedByGadget:e.isNavPopupsEnabled};return e.user.isAnon||(t.editCountBucket=c.getEditCountBucket(e.user.editCount)),t}function r(e,t){return t.linkInteractionToken=e.token,t.pageTitleHover=e.title,t.namespaceIdHover=e.namespaceID,void 0!==e.timeToPreviewShow&&(t.previewType=e.previewType,t.perceivedWait=e.timeToPreviewShow),t}function o(e){var t={totalInteractionTime:Math.round(e.finished-e.started)};if(!e.finalized)return t.action=e.timeToPreviewShow?"dismissed":"dwelledButAbandoned",r(e,t)}function s(e,t){var s,p,l=[a.a.FETCH_COMPLETE,a.a.ABANDON_END,a.a.PREVIEW_SHOW];if(void 0===e&&(e={previewCount:void 0,baseData:{},interaction:void 0,event:void 0}),-1!==l.indexOf(t.type)&&(!e.interaction||t.token!==e.interaction.token))return e;if(!e.interaction&&t.type!==a.a.BOOT&&t.type!==a.a.LINK_DWELL&&t.type!==a.a.EVENT_LOGGED&&t.type!==a.a.SETTINGS_CHANGE)return e;switch(t.type){case a.a.BOOT:return n.i(u.a)(e,{previewCount:t.user.previewCount,baseData:i(t),event:{action:"pageLoaded"}});case a.a.EVENT_LOGGED:return p=n.i(u.a)(e,{event:void 0}),t.event.linkInteractionToken&&e.interaction&&t.event.linkInteractionToken===e.interaction.token&&(p.interaction=void 0),p;case a.a.FETCH_COMPLETE:return n.i(u.a)(e,{interaction:n.i(u.a)(e.interaction,{previewType:t.result.type})});case a.a.PREVIEW_SHOW:return s=e.previewCount+1,n.i(u.a)(e,{previewCount:s,baseData:n.i(u.a)(e.baseData,{previewCountBucket:c.getPreviewCountBucket(s)}),interaction:n.i(u.a)(e.interaction,{timeToPreviewShow:Math.round(t.timestamp-e.interaction.started)})});case a.a.LINK_DWELL:return e.interaction&&t.el===e.interaction.link?n.i(u.a)(e,{interaction:n.i(u.a)(e.interaction,{isUserDwelling:!0})}):n.i(u.a)(e,{interaction:{link:t.el,title:t.title,namespaceID:t.namespaceID,token:t.token,started:t.timestamp,isUserDwelling:!0},event:e.interaction?o(e.interaction):void 0});case a.a.PREVIEW_DWELL:return n.i(u.a)(e,{interaction:n.i(u.a)(e.interaction,{isUserDwelling:!0})});case a.a.LINK_CLICK:return n.i(u.a)(e,{interaction:n.i(u.a)(e.interaction,{finalized:!0}),event:r(e.interaction,{action:"opened",totalInteractionTime:Math.round(t.timestamp-e.interaction.started)})});case a.a.ABANDON_START:return n.i(u.a)(e,{interaction:n.i(u.a)(e.interaction,{finished:t.timestamp,isUserDwelling:!1})});case a.a.ABANDON_END:return e.interaction.isUserDwelling?e:n.i(u.a)(e,{interaction:void 0,event:o(e.interaction)});case a.a.SETTINGS_SHOW:return n.i(u.a)(e,{event:r(e.interaction,{action:"tapped settings cog"})});case a.a.SETTINGS_CHANGE:return t.wasEnabled&&!t.enabled?n.i(u.a)(e,{event:{action:"disabled",popupEnabled:!1}}):e;default:return e}}t.a=s;var a=n("./src/actionTypes.js"),u=n("./src/reducers/nextState.js"),c=n("./src/counts.js");n.n(c)},"./src/reducers/index.js":function(e,t,n){"use strict";var i=n("./src/reducers/eventLogging.js"),r=n("./src/reducers/preview.js"),o=n("./src/reducers/settings.js"),s=n("./src/reducers/statsv.js");t.a={eventLogging:i.a,preview:r.a,settings:o.a,statsv:s.a}},"./src/reducers/nextState.js":function(e,t,n){"use strict";function i(e,t){var n,i={};for(n in e)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(i[n]=e[n]);for(n in t)t.hasOwnProperty(n)&&(i[n]=t[n]);return i}t.a=i},"./src/reducers/preview.js":function(e,t,n){"use strict";function i(e,t){switch(void 0===e&&(e={enabled:void 0,activeLink:void 0,activeEvent:void 0,activeToken:"",shouldShow:!1,isUserDwelling:!1}),t.type){case r.a.BOOT:return n.i(o.a)(e,{enabled:t.isEnabled});case r.a.SETTINGS_CHANGE:return n.i(o.a)(e,{enabled:t.enabled});case r.a.LINK_DWELL:return t.el!==e.activeLink?n.i(o.a)(e,{activeLink:t.el,activeEvent:t.event,activeToken:t.token,shouldShow:!1,isUserDwelling:!0}):n.i(o.a)(e,{isUserDwelling:!0});case r.a.ABANDON_END:return t.token!==e.activeToken||e.isUserDwelling?e:n.i(o.a)(e,{activeLink:void 0,activeToken:void 0,activeEvent:void 0,fetchResponse:void 0,shouldShow:!1});case r.a.PREVIEW_DWELL:return n.i(o.a)(e,{isUserDwelling:!0});case r.a.ABANDON_START:return n.i(o.a)(e,{isUserDwelling:!1});case r.a.FETCH_START:return n.i(o.a)(e,{fetchResponse:void 0});case r.a.FETCH_COMPLETE:if(t.token===e.activeToken)return n.i(o.a)(e,{fetchResponse:t.result,shouldShow:e.isUserDwelling});default:return e}}t.a=i;var r=n("./src/actionTypes.js"),o=n("./src/reducers/nextState.js")},"./src/reducers/settings.js":function(e,t,n){"use strict";function i(e,t){switch(void 0===e&&(e={shouldShow:!1,showHelp:!1,shouldShowFooterLink:!1}),t.type){case r.a.SETTINGS_SHOW:return n.i(o.a)(e,{shouldShow:!0,showHelp:!1});case r.a.SETTINGS_HIDE:return n.i(o.a)(e,{shouldShow:!1,showHelp:!1});case r.a.SETTINGS_CHANGE:return t.wasEnabled===t.enabled?n.i(o.a)(e,{shouldShow:!1}):n.i(o.a)(e,{shouldShow:!t.enabled,showHelp:!t.enabled,shouldShowFooterLink:!t.enabled});case r.a.BOOT:return n.i(o.a)(e,{shouldShowFooterLink:t.user.isAnon&&!t.isEnabled});default:return e}}t.a=i;var r=n("./src/actionTypes.js"),o=n("./src/reducers/nextState.js")},"./src/reducers/statsv.js":function(e,t,n){"use strict";function i(e,t){switch(e=e||{},t.type){case r.a.FETCH_START:return n.i(o.a)(e,{fetchStartedAt:t.timestamp});case r.a.FETCH_END:return n.i(o.a)(e,{action:"timing.PagePreviewsApiResponse",data:t.timestamp-e.fetchStartedAt});case r.a.FETCH_FAILED:return n.i(o.a)(e,{action:"counter.PagePreviewsApiFailure",data:1});case r.a.LINK_DWELL:return n.i(o.a)(e,{linkDwellStartedAt:t.timestamp});case r.a.PREVIEW_SHOW:return n.i(o.a)(e,{action:"timing.PagePreviewsPreviewShow",data:t.timestamp-e.linkDwellStartedAt});case r.a.STATSV_LOGGED:return n.i(o.a)(e,{action:null,data:null});default:return e}}t.a=i;var r=n("./src/actionTypes.js"),o=n("./src/reducers/nextState.js")},"./src/title.js":function(e,t,n){"use strict";function i(e,t){var n,i,r,o=new RegExp(s.RegExp.escape(t.get("wgArticlePath")).replace("\\$1","(.+)"));try{n=new s.Uri(e)}catch(e){return}if(n.host===location.hostname)return r=Object.keys(n.query).length,r?1===r&&n.query.hasOwnProperty("title")?n.query.title:void 0:(i=o.exec(n.path),i?decodeURIComponent(i[1]):void 0)}function r(e,t){var n;return e?(n=s.Title.newFromText(e),n&&$.inArray(n.namespace,t)>=0?n:null):null}function o(e,t){return r(i(e.href,t),t.get("wgContentNamespaces"))}t.a=o;var s=window.mediaWiki},"./src/ui/renderer.js":function(e,t,n){"use strict";function i(e){T("<div>").attr("id","mwe-popups-svg").html('<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"/></clippath><clippath id="mwe-popups-mask-flip"><polygon points="0 8, 274 8, 282 0, 290 8, 1000 8, 1000 1000, 0 1000"/></clippath><clippath id="mwe-popups-landscape-mask"><polygon points="0 8, 174 8, 182 0, 190 8, 1000 8, 1000 1000, 0 1000"/></clippath><clippath id="mwe-popups-landscape-mask-flip"><polygon points="0 0, 1000 0, 1000 242, 190 242, 182 250, 174 242, 0 242"/></clippath></defs></svg>').appendTo(e)}function r(){i(document.body)}function o(e){var t=void 0===e.extract?a(e):s(e);return{show:function(e,n,i){return u(t,e,T(e.target),n,i,document.body)},hide:function(){return p(t)}}}function s(e){var t,n,i=l(e.thumbnail),r=null!==i,o=e.extract;return t=T.extend({},e,{hasThumbnail:r}),n=m.template.get("ext.popups","preview.mustache").render(t),r&&n.find(".mwe-popups-discreet").append(i.el),o&&n.find(".mwe-popups-extract").append(o),{el:n,hasThumbnail:r,thumbnail:i,isTall:r&&i.isTall}}function a(e){var t,n;return t=T.extend({},e,{extractMsg:m.msg("popups-preview-no-preview"),readMsg:m.msg("popups-preview-footer-read")}),n=m.template.get("ext.popups","preview-empty.mustache").render(t),{el:n,hasThumbnail:!1,isTall:!1}}function u(e,t,i,r,o,s){var a=f(e.isTall,{pageX:t.pageX,pageY:t.pageY,clientY:t.clientY},{clientRects:i.get(0).getClientRects(),offset:i.offset(),width:i.width(),height:i.height()},{scrollTop:y.scrollTop(),width:y.width(),height:y.height()},E.pokeySize);return e.el.appendTo(s),h(e,a,g(e,a),E.landscapeImage.h,E.pokeySize),e.el.show(),n.i(w.a)(200).then(function(){c(e,r)}).then(function(){r.previewShow(o)})}function c(e,t){e.el.on("mouseenter",t.previewDwell).on("mouseleave",t.previewAbandon),e.el.click(t.click),e.el.find(".mwe-popups-settings-icon").attr("href",t.settingsUrl).click(function(e){e.stopPropagation(),t.showSettings(e)})}function p(e){var t,i;return t=e.el.hasClass("mwe-popups-fade-in-up")?"mwe-popups-fade-in-up":"mwe-popups-fade-in-down",i="mwe-popups-fade-in-up"===t?"mwe-popups-fade-out-down":"mwe-popups-fade-out-up",e.el.removeClass(t).addClass(i),n.i(w.a)(150).then(function(){e.el.remove()})}function l(e){var t,n,i,r,o,s,a,u,c=T.bracketedDevicePixelRatio();return e?(t=e.width<e.height,n=e.width/c,i=e.height/c,!t&&n<E.landscapeImage.w||t&&i<E.portraitImage.h||e.source.indexOf("\\")>-1||e.source.indexOf("'")>-1||e.source.indexOf('"')>-1?null:(t?(r=n>E.portraitImage.w?(n-E.portraitImage.w)/-2:E.portraitImage.w-n,o=i>E.portraitImage.h?(i-E.portraitImage.h)/-2:0,s=E.portraitImage.w,a=E.portraitImage.h):(r=0,o=i>E.landscapeImage.h?(i-E.landscapeImage.h)/-2:0,s=E.landscapeImage.w+3,a=i>E.landscapeImage.h?E.landscapeImage.h:i,u="mwe-popups-mask"),{el:d(t?"mwe-popups-is-tall":"mwe-popups-is-not-tall",e.source,r,o,n,i,s,a,u),isTall:t,width:n,height:i})):null}function d(e,t,n,i,r,o,s,a,u){var c,p="http://www.w3.org/2000/svg";return c=T(document.createElementNS(p,"image")),c[0].setAttributeNS("http://www.w3.org/1999/xlink","href",t),c.addClass(e).attr({x:n,y:i,width:r,height:o,"clip-path":"url(#"+u+")"}),T(document.createElementNS(p,"svg")).attr({xmlns:p,width:s,height:a}).append(c)}function f(e,t,n,i,r){var o=!1,s=!1,a=t.pageY?v(t.pageY-i.scrollTop,n.clientRects,!1)+i.scrollTop+r:n.offset.top+n.height+r,u=t.clientY?t.clientY:a,c=t.pageX?t.pageX:n.offset.left;return c>i.width/2&&(c+=t.pageX?0:n.width,c-=e?E.landscapePopupWidth:E.portraitPopupWidth,o=!0),t.pageX&&(c+=o?20:-20),u>i.height/2&&(s=!0,a=n.offset.top,t.pageY&&(a=v(t.pageY-i.scrollTop,n.clientRects,!0)+i.scrollTop),a-=r),{offset:{top:a,left:c},flippedX:o,flippedY:s}}function g(e,t){var n=[];return t.flippedY?n.push("mwe-popups-fade-in-down"):n.push("mwe-popups-fade-in-up"),t.flippedY&&t.flippedX&&n.push("flipped_x_y"),t.flippedY&&!t.flippedX&&n.push("flipped_y"),t.flippedX&&!t.flippedY&&n.push("flipped_x"),e.hasThumbnail&&!e.isTall||t.flippedY||n.push("mwe-popups-no-image-tri"),!e.hasThumbnail||e.isTall||t.flippedY||n.push("mwe-popups-image-tri"),e.isTall?n.push("mwe-popups-is-tall"):n.push("mwe-popups-is-not-tall"),n}function h(e,t,n,i,r){var o=e.el,s=e.isTall,a=e.hasThumbnail,u=e.thumbnail,c=t.flippedY,p=t.flippedX,l=t.offset.top;!c&&!s&&a&&u.height<i&&o.find(".mwe-popups-extract").css("margin-top",u.height-r),o.addClass(n.join(" ")),c&&(l-=o.outerHeight()),o.css({top:l,left:t.offset.left+"px"}),c&&a&&o.find("image")[0].removeAttribute("clip-path"),c&&p&&a&&s&&o.find("image")[0].setAttribute("clip-path","url(#mwe-popups-landscape-mask-flip)"),p&&!c&&a&&!s&&o.find("image")[0].setAttribute("clip-path","url(#mwe-popups-mask-flip)"),p&&!c&&a&&s&&o.removeClass("mwe-popups-no-image-tri").find("image")[0].setAttribute("clip-path","url(#mwe-popups-landscape-mask)")}function v(e,t,n){var i,r,o=null;return T.each(t,function(t,s){r=Math.abs(e-s.top+e-s.bottom),(null===o||o>r)&&(o=r,i=n?Math.floor(s.top):Math.ceil(s.bottom))}),i}t.a=r,t.b=o;var w=n("./src/wait.js"),m=window.mediaWiki,T=jQuery,E={portraitImage:{h:250,w:203},landscapeImage:{h:200,w:320},landscapePopupWidth:450,portraitPopupWidth:320,pokeySize:8},y=T(window)},"./src/ui/settingsDialog.js":function(e,t,n){"use strict";function i(){var e,t;return function(n){return e||(e=r(),t=c("<div>").addClass("mwe-popups-overlay"),e.find(".save").click(function(){var t=o(e),i="simple"===t;n.saveSettings(i)}),e.find(".close, .okay").click(n.hideSettings)),{appendTo:function(n){t.appendTo(n),e.appendTo(n)},show:function(){var n=c(window).height(),i=c(window).width();t.show(),e.show().css("left",(i-e.outerWidth(!0))/2).css("top",(n-e.outerHeight(!0))/2)},hide:function(){t.hide(),e.hide()},toggleHelp:function(t){s(e,t)},setEnabled:function(t){var n="off";t?n="simple":a()&&(n="advanced"),e.find("#mwe-popups-settings-"+n).prop("checked",!0)}}}}function r(){var e=u.config.get("wgExtensionAssetsPath")+"/Popups/resources/ext.popups/images/",t=[{id:"simple",name:u.msg("popups-settings-option-simple"),description:u.msg("popups-settings-option-simple-description"),image:e+"hovercard.svg",isChecked:!0},{id:"advanced",name:u.msg("popups-settings-option-advanced"),description:u.msg("popups-settings-option-advanced-description"),image:e+"navpop.svg"},{id:"off",name:u.msg("popups-settings-option-off")}];return a()||t.splice(1,1),u.template.get("ext.popups","settings.mustache").render({heading:u.msg("popups-settings-title"),closeLabel:u.msg("popups-settings-cancel"),saveLabel:u.msg("popups-settings-save"),helpText:u.msg("popups-settings-help"),okLabel:u.msg("popups-settings-help-ok"),descriptionText:u.msg("popups-settings-description"),choices:t})}function o(e){return e.find("input[name=mwe-popups-setting]:checked, #mwe-popups-settings").val()}function s(e,t){var n=c("#mwe-popups-settings");t?(n.find("main, .save, .close").hide(),n.find(".mwe-popups-settings-help, .okay").show()):(n.find("main, .save, .close").show(),n.find(".mwe-popups-settings-help, .okay").hide())}function a(){return"undefined"!=typeof pg&&void 0!==pg.fn.disablePopups}t.a=i;var u=window.mediaWiki,c=jQuery},"./src/userSettings.js":function(e,t,n){"use strict";function i(e){return{getIsEnabled:function(){return"0"!==e.get(r)},setIsEnabled:function(t){e.set(r,t?"1":"0")},hasIsEnabled:function(){var t=e.get(r);return!1!==Boolean(t)},getPreviewCount:function(){var t,n=e.get(o);return!1===n?-1:null===n?0:(t=parseInt(n,10),isNaN(t)&&(t=0,this.setPreviewCount(t)),t)},setPreviewCount:function(t){e.set(o,t.toString())}}}t.a=i;var r="mwe-popups-enabled",o="ext.popups.core.previewCount"},"./src/wait.js":function(e,t,n){"use strict";function i(e){var t=r.Deferred();return setTimeout(function(){t.resolve()},e),t.promise()}t.a=i;var r=jQuery}});
//# sourceMappingURL=index.js.json