").attr("href","#").text(mw.message("popups-settings-enable").text()));e.hide();var t=$("#footer-places, #f-list");return 0===t.length&&(t=$("#footer li").parent()),t.append(e),e}()).on("click",(function(t){t.preventDefault(),e.showSettings()})),r.settings.shouldShowFooterLink?t.show():t.hide()}},Z=function(){var e;return function(t,n){var r,i=t&&t.preview.activeLink;i!==n.preview.activeLink&&((r=i)&&e&&($(r).attr("title",e),e=void 0),n.preview.enabled[n.preview.previewType]&&function(t){if(t&&!e){var n=$(t);e=n.attr("title"),n.attr("title","")}}(n.preview.activeLink))}},J=function(e,t){return function(n,r){var i,o;r.pageviews&&r.pageviews.pageview&&r.pageviews.page&&(i=r.pageviews.page,o=r.pageviews.pageview,t("event.VirtualPageView",{source_page_id:i.id,source_namespace:i.namespaceId,source_title:mw.Title.newFromText(i.title).getPrefixedDb(),source_url:i.url,page_id:o.page_id,page_namespace:o.page_namespace,page_title:mw.Title.newFromText(o.page_title).getPrefixedDb()}),e.pageviewLogged())}},Q=function(e){var t;return function(n,r){r.preview.shouldShow&&!t?(t=B(r.preview.fetchResponse)).show(r.preview.measures,e,r.preview.activeToken):!r.preview.shouldShow&&t&&(t.hide(),t=void 0)}},ee=function(e,t){var n;return function(r,i){r&&(!1===r.settings.shouldShow&&i.settings.shouldShow?(n||(n=t(e)).appendTo(document.body),n.setEnabled(i.preview.enabled),n.show()):r.settings.shouldShow&&!1===i.settings.shouldShow&&n.hide(),r.settings.showHelp!==i.settings.showHelp&&n.toggleHelp(i.settings.showHelp))}},te=function(e,t){return function(n,r){var i=r.statsv;i.action&&(t(i.action,i.data),e.statsvLogged())}},ne=function(e){return function(t,n){q(t,n,"eventLogging.previewCount",e.storePreviewCount),q(t,n,"preview.enabled."+u.TYPE_PAGE,e.storePagePreviewsEnabled),q(t,n,"preview.enabled."+u.TYPE_REFERENCE,e.storeReferencePreviewsEnabled)}},re={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",FETCH_ABORTED:"FETCH_ABORTED",PAGEVIEW_LOGGED:"PAGEVIEW_LOGGED",PREVIEW_DWELL:"PREVIEW_DWELL",PREVIEW_SHOW:"PREVIEW_SHOW",PREVIEW_CLICK:"PREVIEW_CLICK",PREVIEW_SEEN:"PREVIEW_SEEN",SETTINGS_SHOW:"SETTINGS_SHOW",SETTINGS_HIDE:"SETTINGS_HIDE",SETTINGS_CHANGE:"SETTINGS_CHANGE",STATSV_LOGGED:"STATSV_LOGGED"},ie=150,oe=1e3,ae=350+ie,se=150,ue=300;function ce(e){return e.timestamp=mw.now(),e}function pe(e,t,n,r,i){var o=r.get("wgUserEditCount");return{type:re.BOOT,initiallyEnabled:e,isNavPopupsEnabled:r.get("wgPopupsConflictsWithNavPopupGadget"),sessionToken:t.sessionId(),pageToken:t.getPageviewToken(),page:{url:i,title:r.get("wgTitle"),namespaceId:r.get("wgNamespaceNumber"),id:r.get("wgArticleId")},user:{isAnon:t.isAnon(),editCount:o}}}function le(e,t,n,r,i){var o=t.getPrefixedDb(),a=t.namespace;return function(s){var c=e.fetchPreviewForTitle(t,n);s(ce({type:re.FETCH_START,el:n,title:o,namespaceId:a,promise:c}));var l=c.then((function(e){return s(ce({type:re.FETCH_END,el:n})),e})).catch((function(e,t){var i=new Error(e),o=t&&t.textStatus&&"abort"===t.textStatus?re.FETCH_ABORTED:re.FETCH_FAILED;throw i.data=t,s({type:o,el:n,token:r}),i}));return $.when(l,A(function(e){switch(e){case u.TYPE_PAGE:return ae-ie;case u.TYPE_REFERENCE:return se;default:return 0}}(i))).then((function(e){s({type:re.FETCH_COMPLETE,el:n,result:e,token:r})})).catch((function(e){var i=e.data,a=!0;i&&i.xhr&&0===i.xhr.readyState&&(a=!("error"===i.textStatus&&""===i.exception||"abort"===i.textStatus)),a&&s({type:re.FETCH_COMPLETE,el:n,result:p(o,t.getUrl()),token:r})}))}}function de(e,t,n,r,i,o){var a=i(),s=e.getPrefixedDb(),u=e.namespace;return function(i,c){var p=A(ie),l=ce({type:re.LINK_DWELL,el:t,previewType:o,measures:n,token:a,title:s,namespaceId:u,promise:p});function d(){return c().preview.activeToken===a}return i(l),d()?p.then((function(){if(c().preview.enabled[o]&&d())return i(le(r,e,t,a,o))})):$.Deferred().resolve().promise()}}function fe(){return function(e,t){var n=t().preview,r=n.activeToken,i=n.promise;return r?(e(ce({type:re.ABANDON_START,token:r})),"abort"in i&&i.abort(),A(ue).then((function(){e({type:re.ABANDON_END,token:r})}))):$.Deferred().resolve().promise()}}function we(e){return ce({type:re.LINK_CLICK,el:e})}function me(){return{type:re.PREVIEW_DWELL}}function he(e){return function(t,n){return t(ce({type:re.PREVIEW_SHOW,token:e})),A(oe).then((function(){var r=n().preview,i=r&&r.fetchResponse,o=r&&r.activeToken,a=i&&[u.TYPE_PAGE,u.TYPE_DISAMBIGUATION].indexOf(i.type)>-1;o&&o===e&&i&&a&&t({type:re.PREVIEW_SEEN,title:i.title,pageId:i.pageId,namespace:0})}))}}function ge(){return{type:re.PAGEVIEW_LOGGED}}function ve(){return{type:re.SETTINGS_SHOW}}function Ee(){return{type:re.SETTINGS_HIDE}}function Te(e){return function(t,n){t({type:re.SETTINGS_CHANGE,oldValue:n().preview.enabled,newValue:e})}}function be(){return{type:re.STATSV_LOGGED}}function ye(e,t){var n,r=Object.prototype.hasOwnProperty,i={};for(var o in e)r.call(e,o)&&!r.call(t,o)&&(i[o]=e[o]);for(var a in t)if(r.call(t,a))if((n=t[a])&&n.constructor===Object){var s=e[a]?ye({},e[a]):{};i[a]=ye(s,t[a])}else i[a]=t[a];return i}var Pe={pageviews:function(e,t){switch(void 0===e&&(e={pageview:void 0}),t.type){case re.BOOT:return ye(e,{page:t.page});case re.PAGEVIEW_LOGGED:return ye(e,{pageview:void 0});case re.PREVIEW_SEEN:return ye(e,{pageview:{page_title:t.title,page_id:t.pageId,page_namespace:t.namespace}});default:return e}},preview:function(e,t){switch(void 0===e&&(e={enabled:{},activeLink:void 0,previewType:void 0,measures:void 0,activeToken:"",shouldShow:!1,isUserDwelling:!1,wasClicked:!1}),t.type){case re.BOOT:return ye(e,{enabled:t.initiallyEnabled});case re.SETTINGS_CHANGE:return ye(e,{enabled:t.newValue});case re.LINK_DWELL:return t.el!==e.activeLink?ye(e,{activeLink:t.el,previewType:t.previewType,measures:t.measures,activeToken:t.token,shouldShow:!1,isUserDwelling:!0,promise:t.promise}):ye(e,{isUserDwelling:!0});case re.FETCH_ABORTED:case re.ABANDON_END:return t.token!==e.activeToken||e.isUserDwelling?e:ye(e,{activeLink:void 0,previewType:void 0,activeToken:void 0,measures:void 0,fetchResponse:void 0,shouldShow:!1});case re.PREVIEW_DWELL:return ye(e,{isUserDwelling:!0});case re.ABANDON_START:return ye(e,{isUserDwelling:!1,wasClicked:!1});case re.FETCH_START:return ye(e,{fetchResponse:void 0,promise:t.promise});case re.FETCH_COMPLETE:if(t.token===e.activeToken)return ye(e,{fetchResponse:t.result,shouldShow:e.isUserDwelling});default:return e}},settings:function(e,t){switch(void 0===e&&(e={shouldShow:!1,showHelp:!1,shouldShowFooterLink:!1}),t.type){case re.SETTINGS_SHOW:return ye(e,{shouldShow:!0,showHelp:!1});case re.SETTINGS_HIDE:return ye(e,{shouldShow:!1,showHelp:!1});case re.SETTINGS_CHANGE:var n=Object.keys(t.newValue),r=n.every((function(e){return t.oldValue[e]===t.newValue[e]})),i=n.some((function(e){return t.oldValue[e]&&!t.newValue[e]})),o=n.some((function(e){return!1===t.newValue[e]}));return ye(e,r?{shouldShow:!1}:{shouldShow:i,showHelp:i,shouldShowFooterLink:o});case re.BOOT:var a=Object.keys(t.initiallyEnabled).some((function(e){return!1===t.initiallyEnabled[e]}));return ye(e,{shouldShowFooterLink:t.user.isAnon&&a});default:return e}},statsv:function(e,t){switch(e=e||{},t.type){case re.FETCH_START:return ye(e,{fetchStartedAt:t.timestamp});case re.FETCH_END:return ye(e,{action:"timing.PagePreviewsApiResponse",data:t.timestamp-e.fetchStartedAt});case re.FETCH_FAILED:return ye(e,{action:"counter.PagePreviewsApiFailure",data:1});case re.LINK_DWELL:return ye(e,{linkDwellStartedAt:t.timestamp});case re.PREVIEW_SHOW:return ye(e,{action:"timing.PagePreviewsPreviewShow",data:t.timestamp-e.linkDwellStartedAt});case re.STATSV_LOGGED:return ye(e,{action:null,data:null});default:return e}}},xe=[".extiw",".image",".new",".internal",".external",".mw-cite-backlink a",".oo-ui-buttonedElement-button",".ve-ce-surface a",".cancelLink a"];!function(n){var i,a;i=mw.config,a=parseInt(i.get("wgPopupsFlags"),10),i.set("wgPopupsConflictsWithNavPopupGadget",!!(1&a)),i.set("wgPopupsConflictsWithRefTooltipsGadget",!!(2&a)),i.set("wgPopupsReferencePreviews",!!(4&a)),i.set("wgPopupsReferencePreviewsBetaFeature",!!(8&a));var c,p,d=r.compose,h=mw.user.generateRandomSessionId,v=function(e){var t=$.extend({},s,{acceptLanguage:e.get("wgPageContentLanguage")}),n=$.extend({},t,{endpoint:e.get("wgPopupsRestGatewayEndpoint")});switch(e.get("wgPopupsGateway")){case"mwApiPlain":return function(e,t){function n(n){return e.get({action:"query",prop:"info|extracts|pageimages|revisions|info",formatversion:2,redirects:!0,exintro:mw.config.get("wgPopupsTextExtractsIntroOnly",!0),exchars:t.EXTRACT_LENGTH,explaintext:!0,exsectionformat:"plain",piprop:"thumbnail",pithumbsize:t.THUMBNAIL_SIZE,pilicense:"any",rvprop:"timestamp",inprop:"url",titles:n,smaxage:300,maxage:300,uselang:"content"},{headers:{"X-Analytics":"preview=1","Accept-Language":t.acceptLanguage}})}return{fetch:n,extractPageFromResponse:f,convertPageToModel:m,fetchPreviewForTitle:function(e){var t=n(e.getPrefixedDb());return t.then((function(e){return m(w(f(e)))})).promise({abort:function(){t.abort()}})},formatPlainTextExtract:w}}(new mw.Api,t);case"restbasePlain":return g($.ajax,n,T);case"restbaseHTML":return g($.ajax,n,E);default:throw new Error("Unknown gateway")}}(mw.config),P=function(){function e(e){var t=["book","journal","news","note","web"],n=null;return e.find("cite[class]").each((function(e,r){for(var i=r.className.split(/\s+/),o=i.length;o--;)if(-1!==t.indexOf(i[o]))return n=i[o],!1})),n}return{fetchPreviewForTitle:function(t,n){var r=t.getFragment().replace(/ /g,"_"),i=function(e){var t="#".concat($.escapeSelector(e));return $("".concat(t," .mw-reference-text, ").concat(t," .reference-text"))}(r);if(!i.length||!i.text().trim()&&!i.children().length)return $.Deferred().reject("Footnote not found or empty",{textStatus:"abort",xhr:{readyState:0}}).promise({abort:function(){}});var o={url:"#".concat(r),extract:i.html(),type:u.TYPE_REFERENCE,referenceType:e(i),sourceElementId:n.parentNode.id};return $.Deferred().resolve(o).promise({abort:function(){}})}}}(),x=(p=mw.storage,{isPagePreviewsEnabled:function(){return"0"!==p.get(b)},storePagePreviewsEnabled:function(e){e?p.remove(b):p.set(b,"0")},isReferencePreviewsEnabled:function(){return"0"!==p.get(y)},storeReferencePreviewsEnabled:function(e){e?p.remove(y):p.set(y,"0"),mw.track("event.ReferencePreviewsPopups",{action:e?"anonymousEnabled":"anonymousDisabled"})}}),_=function(e,t,n){return n.get("wgPopupsReferencePreviews")?n.get("wgPopupsConflictsWithRefTooltipsGadget")||"minerva"===n.get("skin")?null:e.isAnon()?t.isReferencePreviewsEnabled():!!n.get("wgPopupsReferencePreviews")||"1"===mw.user.options.get("popups-reference-previews")||null:null}(mw.user,x,mw.config),A=S(null!==_),C=(c=mw.experiments,{weightedBoolean:function(e,t,n){return"true"===c.getBucket({enabled:!0,name:e,buckets:{true:t,false:1-t}},n)}}),O=function(e,t,n){return function(e,t,n){var r=t.get("wgPopupsStatsvSamplingRate",0);return n.weightedBoolean("ext.Popups.statsv",r,e.sessionId())}(e,t,n)?mw.track:function(){}}(mw.user,mw.config,C),R=mw.config.get("wgPopupsVirtualPageViews")?mw.track:function(){},L=(t(n={},u.TYPE_PAGE,function(e,t,n){return mw.config.get("wgPopupsConflictsWithNavPopupGadget")?null:e.isAnon()?t.isPagePreviewsEnabled():"1"===mw.user.options.get("popups")||null}(mw.user,x)),t(n,u.TYPE_REFERENCE,_),n);mw.config.get("debug")&&(d=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||d);var D=r.createStore(r.combineReducers(Pe),d(r.applyMiddleware(o()))),H=r.bindActionCreators(e,D.dispatch),G=function(e,t){var n,r=function(){};return e.isAnon()?r=function(e){e.preventDefault(),t.showSettings()}:n=mw.Title.newFromText("Special:Preferences#mw-prefsection-rendering").getUrl(),{settingsUrl:n,showSettings:r,previewDwell:t.previewDwell,previewAbandon:t.abandon,previewShow:t.previewShow,click:t.linkClick}}(mw.user,H);!function(e,t,n,r,i,o,a){I(e,z(t)),I(e,Z()),I(e,Q(i)),I(e,te(t,o)),I(e,ne(n)),I(e,ee(t,r)),I(e,J(t,a))}(D,H,x,A,G,O,R),H.boot(L,mw.user,x,mw.config,window.location.href),mw.popups=function(e){return{isEnabled:function(){return e.getState().preview.enabled[u.TYPE_PAGE]}}}(D);var F,j=[];if(null!==L[u.TYPE_PAGE]){var Y=xe.join(", ");j.push("#mw-content-text a[href][title]:not(".concat(Y,")"))}if(null!==L[u.TYPE_REFERENCE]&&j.push('#mw-content-text .reference a[ href*="#" ]'),j.length){var W=j.join(", ");U()||(F=document.body,$("").attr("id","mwe-popups-svg").html(N()).appendTo(F)),$(document).on("mouseover keyup",W,(function(e){var t=k(this,mw.config);if(t){var n,r=l(this,mw.config,t);switch(r){case u.TYPE_PAGE:n=v;break;case u.TYPE_REFERENCE:n=P;break;default:return}var i=$(this),o=$(window),a={pageX:e.pageX,pageY:e.pageY,clientY:e.clientY,width:i.width(),height:i.height(),offset:i.offset(),clientRects:this.getClientRects(),windowWidth:o.width(),windowHeight:o.height(),scrollTop:o.scrollTop()};H.linkDwell(t,this,a,n,h,r)}})).on("mouseout blur",W,(function(){k(this,mw.config)&&H.abandon()})).on("click",W,(function(){var e=k(this,mw.config);e&&u.TYPE_PAGE===l(this,mw.config,e)&&H.linkClick(this)}))}else mw.log.warn("ext.popups was loaded but everything is disabled")}(),window.Redux=r,window.ReduxThunk=i}()}();
//# sourceMappingURL=index.js.map.json