!function(){if("serviceWorker"in navigator){var e=function(){var t=this,e=$("#offline");e.length&&(e.append($("<dd>").append(this.switch=$("<a>").click(function(){return t.toggleState()}))),this.message=$("<div>").addClass("wy-alert"),this.message.append($("<div>").addClass("wy-alert-title").text(_("Offline Mode")).append($("<a>").addClass("fa").addClass("fa-close").click(function(){return t.message.fadeOut()}))).append(this.message.text=$("<p>")).hide(),$("div[role=main]").before(this.message),navigator.serviceWorker.ready.then(function(e){return t.registration=e}),this.updateState(navigator.serviceWorker.controller),navigator.serviceWorker.addEventListener("controllerchange",function(){return t.updateState(navigator.serviceWorker.controller)}))};e.prototype.showMessage=function(e,t){return this.message.type&&this.message.removeClass(this.message.type),t&&(t="wy-alert-"+t,this.message.addClass(t),this.message.type=t),this.message.text.text(e),this.message.show(),$(window).scrollTop(0),$("[data-toggle=wy-nav-shift]").removeClass("shift"),$("[data-toggle=rst-versions]").removeClass("shift"),this.message.text},e.prototype.showError=function(){this.showMessage(_("Failed to enable offline mode. Please try again later."),"danger")},e.prototype.toggleState=function(){var t=this;this.state?confirm(_("Disable Offline Mode?")+"\n\n"+_("Offline Mode will be unavailable until you download the full documentation again."))&&(this.registration?this.registration.unregister().then(function(){return t.updateState()}):this.registration=navigator.serviceWorker.getRegistration(DOCUMENTATION_OPTIONS.URL_ROOT).then(function(e){return e.unregister()}).then(function(){return t.updateState()})):confirm(_("Enable Offline Mode?")+"\n\n"+_("When enabled, we will download the full documentation (about 5 MB) and store it locally on your device. You won't get any updates until you switch to online mode again."))&&(this.showMessage(_("Downloading documentation...")),navigator.serviceWorker.register(DOCUMENTATION_OPTIONS.URL_ROOT+"worker.js").then(function(e){((t.registration=e).installing||e.waiting||e.active).addEventListener("statechange",function(e){"redundant"===e.target.state&&(t.showError(),t.registration=null)})}).catch(function(){return t.showError()}))},e.prototype.updateState=function(e){var t=this;this.state=Boolean(e),this.state?(this.switch.text(_("Disable Offline Mode")).addClass("current"),this.showMessage(_("You are reading the cached, offline version of the documentation. Disable offline mode to update it with the latest changes."),"success").append($("<a>").text(" "+_("Disable Offline Mode")).click(function(){return t.toggleState()}))):(this.registration=null,this.switch.text(_("Offline Mode")).removeClass("current"),this.message.filter(":visible").fadeOut())},$(function(){return new e})}}(),DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX=".txt";var r=[{name:_("Light")},{name:_("Dark"),id:"tomorrow-night"}];r.find=function(e){if(e)for(var t=0,n=r;t<n.length;t+=1){var i=n[t];if(i.id===e)return i}};var e=function(){for(var t=this,n=$("<dl>").append($("<dt>").text(_("Code theme"))),e=function(){var e=a[i];n.append($("<dd>").append(e.switch=$("<a>").text(e.name).click(function(){return t.apply(e)})))},i=0,a=r;i<a.length;i+=1)e();$("#versions").append(n),this.apply(r.find(localStorage["code-theme"])||r[0])};e.prototype.apply=function(e){this.currentTheme!=e&&(this.currentTheme&&(this.currentTheme.id&&$(".highlight").removeClass(this.currentTheme.id),this.currentTheme.switch.removeClass("current")),e.id?(localStorage["code-theme"]=e.id,$(".highlight").addClass(e.id)):delete localStorage["code-theme"],e.switch.addClass("current"),this.currentTheme=e)},$(function(){return new e});