-1;o&&o===e&&i&&a&&t({type:fe.PREVIEW_SEEN,title:i.title,pageId:i.pageId,namespace:0})}))}}function Ie(){return{type:fe.PAGEVIEW_LOGGED}}function ke(){return{type:fe.SETTINGS_SHOW}}function Ae(){return{type:fe.SETTINGS_HIDE}}function Ce(e){return function(t,n){t({type:fe.SETTINGS_CHANGE,oldValue:n().preview.enabled,newValue:e})}}function Ne(){return{type:fe.STATSV_LOGGED}}function Oe(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]?Oe({},e[a]):{};i[a]=Oe(s,t[a])}else i[a]=t[a];return i}var Re={pageviews:function(e,t){switch(void 0===e&&(e={pageview:void 0}),t.type){case fe.BOOT:return Oe(e,{page:t.page});case fe.PAGEVIEW_LOGGED:return Oe(e,{pageview:void 0});case fe.PREVIEW_SEEN:return Oe(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 fe.BOOT:return Oe(e,{enabled:t.initiallyEnabled});case fe.SETTINGS_CHANGE:return Oe(e,{enabled:t.newValue});case fe.LINK_DWELL:return t.el!==e.activeLink?Oe(e,{activeLink:t.el,previewType:t.previewType,measures:t.measures,activeToken:t.token,shouldShow:!1,isUserDwelling:!0,promise:t.promise}):Oe(e,{isUserDwelling:!0});case fe.FETCH_ABORTED:case fe.ABANDON_END:return t.token!==e.activeToken||e.isUserDwelling?e:Oe(e,{activeLink:void 0,previewType:void 0,activeToken:void 0,measures:void 0,fetchResponse:void 0,shouldShow:!1});case fe.PREVIEW_DWELL:return Oe(e,{isUserDwelling:!0});case fe.ABANDON_START:return Oe(e,{isUserDwelling:!1,wasClicked:!1});case fe.FETCH_START:return Oe(e,{fetchResponse:void 0,promise:t.promise});case fe.FETCH_COMPLETE:if(t.token===e.activeToken)return Oe(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 fe.SETTINGS_SHOW:return Oe(e,{shouldShow:!0,showHelp:!1});case fe.SETTINGS_HIDE:return Oe(e,{shouldShow:!1,showHelp:!1});case fe.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 Oe(e,r?{shouldShow:!1}:{shouldShow:i,showHelp:i,shouldShowFooterLink:o});case fe.BOOT:var a=Object.keys(t.initiallyEnabled).some((function(e){return!1===t.initiallyEnabled[e]}));return Oe(e,{shouldShowFooterLink:t.user.isAnon&&a});default:return e}},statsv:function(e,t){switch(e=e||{},t.type){case fe.FETCH_START:return Oe(e,{fetchStartedAt:t.timestamp});case fe.FETCH_END:return Oe(e,{action:"timing.PagePreviewsApiResponse",data:t.timestamp-e.fetchStartedAt});case fe.FETCH_FAILED:return Oe(e,{action:"counter.PagePreviewsApiFailure",data:1});case fe.LINK_DWELL:return Oe(e,{linkDwellStartedAt:t.timestamp});case fe.PREVIEW_SHOW:return Oe(e,{action:"timing.PagePreviewsPreviewShow",data:t.timestamp-e.linkDwellStartedAt});case fe.STATSV_LOGGED:return Oe(e,{action:null,data:null});default:return e}}},Le={};function De(e,t){Le[e]=t}var He=$(window),Ge=[".extiw",".mw-selflink",".image",".new",".internal",".external",".mw-cite-backlink a",".oo-ui-buttonedElement-button",".ve-ce-surface a",".cancelLink a",".mw-selflink-fragment",'[href^="#"]'];function Fe(e){return function(t){var n=f(t.target);if(null!==n){var r=function(e,t){if(e.dataset.title)return mw.Title.newFromText(e.dataset.title);if(function(e){return e.hash&&e.host===location.host&&e.pathname===location.pathname&&e.search===location.search}(e))try{return mw.Title.newFromText(t.get("wgPageName")+decodeURIComponent(e.hash))}catch(e){return null}return function(e,t){if(!e)return null;var n=mw.Title.newFromText(e);return n&&t.indexOf(n.namespace)>=0?n:null}(function(e,t){var n;try{n=new mw.Uri(e)}catch(e){return}if(n.host===location.hostname){var r,i=Object.keys(n.query).length;if(i)1===i&&"title"in n.query&&(r=n.query.title);else{var o=mw.util.escapeRegExp(t.get("wgArticlePath")).replace("\\$1","([^?#]+)"),a=new RegExp(o).exec(n.path);try{r=a&&decodeURIComponent(a[1])}catch(e){}}return r?"".concat(r).concat(n.fragment?"#".concat(n.fragment):""):void 0}}(e.href,t),t.get("wgContentNamespaces"))}(n,mw.config);r&&e(n,r,t)}}}!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,l=r.compose,d=mw.user.generateRandomSessionId,f=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:E,convertPageToModel:b,fetchPreviewForTitle:function(e){var t=n(e.getPrefixedDb());return t.then((function(e){return b(T(E(e)))})).promise({abort:function(){t.abort()}})},formatPlainTextExtract:T}}(new mw.Api,t);case"restbasePlain":return P($.ajax,n,S);case"restbaseHTML":return P($.ajax,n,_);default:throw new Error("Unknown gateway")}}(mw.config),w=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(){}})}}}(),v=(p=mw.storage,{isPagePreviewsEnabled:function(){return"0"!==p.get(I)},storePagePreviewsEnabled:function(e){e?p.remove(I):p.set(I,"0")},isReferencePreviewsEnabled:function(){return"0"!==p.get(k)},storeReferencePreviewsEnabled:function(e){e?p.remove(k):p.set(k,"0"),mw.track("event.ReferencePreviewsPopups",{action:e?"anonymousEnabled":"anonymousDisabled"})}}),y=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,v,mw.config),x=O(null!==y),A=(c=mw.experiments,{weightedBoolean:function(e,t,n){return"true"===c.getBucket({enabled:!0,name:e,buckets:{true:t,false:1-t}},n)}}),C=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,A),N=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,v)),t(n,u.TYPE_REFERENCE,y),n);mw.config.get("debug")&&(l=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||l);var D,G=r.createStore(r.combineReducers(Re),l(r.applyMiddleware(o()))),F=r.bindActionCreators(e,G.dispatch),j=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,F);if(function(e,t,n,r,i,o,a){R(e,ae(t)),R(e,se()),R(e,ce(i)),R(e,le(t,o)),R(e,de(n)),R(e,pe(t,r)),R(e,ue(t,a))}(G,F,v,x,j,C,N),F.boot(L,mw.user,v,mw.config,window.location.href),mw.popups=function(e,t,n,r){return{isEnabled:function(){return e.getState().preview.enabled[u.TYPE_PAGE]},register:function(e){var i=e.type,o=e.selector,a=e.gateway,s=e.renderFn,u=e.subTypes;if(!i||!o||!a)throw new Error('Registration of Popups custom preview type "'.concat(i,'" failed: You must specify a type, a selector, and a gateway.'));t(i,o),r(i,a),n(i,s),u&&u.forEach((function(e){n(e.type,e.renderFn)}))}}}(G,g,Z,De),null!==L[u.TYPE_PAGE]){var W=Ge.join(", ");mw.popups.register({type:u.TYPE_PAGE,selector:"#mw-content-text a[href][title]:not(".concat(W,")"),gateway:f,renderFn:Q,subTypes:[{type:u.TYPE_DISAMBIGUATION,renderFn:te}]})}null!==L[u.TYPE_REFERENCE]&&mw.popups.register({type:u.TYPE_REFERENCE,selector:'#mw-content-text .reference a[ href*="#" ]',gateway:w,renderFn:ne}),h.length?(J()||(D=document.body,$("").attr("id","mwe-popups-svg").html(H()).appendTo(D)),$(document).on("mouseover keyup",Fe((function(e,t,n){var r=$(e),i=m(e),o=function(e){return Le[e]}(i);if(o){var a={pageX:n.pageX,pageY:n.pageY,clientY:n.clientY,width:r.width(),height:r.height(),offset:r.offset(),clientRects:e.getClientRects(),windowWidth:He.width(),windowHeight:He.height(),scrollTop:He.scrollTop()};F.linkDwell(t,e,a,o,d,i)}}))).on("mouseout blur",Fe((function(){F.abandon()}))).on("click",Fe((function(e){u.TYPE_PAGE===m(e)&&F.linkClick(e)})))):mw.log.warn("ext.popups was loaded but everything is disabled")}(),window.Redux=r,window.ReduxThunk=i}()}();
//# sourceMappingURL=index.js.map.json