"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").then(e=>{console.log("Service worker registered",e.scope)}).catch(e=>{console.error("Failed to register service worker",e)});let e=(t,n)=>{let o=(t.document||t.ownerDocument).querySelectorAll(n),r=e.length;for(;--r>=0&&o.item(r)!==t;);return r>-1},t={noop:()=>{},$(e,t=null){if("string"!=typeof e)return e;t=null!==t&&1===t.nodeType?t:document;let n=[];return e.match(/^#([\w]+$)/)?n.push(document.getElementById(e.split("#")[1])):n=[].slice.apply(t.querySelectorAll(e)),n},hasElement:e=>t.$(e).length>0,scrollToTop(){t.$("header")[0].scrollIntoView(!0)},hide(e){"string"==typeof e&&(e=t.$(e)),Array.isArray(e)?e.forEach(e=>e.setAttribute("hidden","hidden")):e.setAttribute("hidden","hidden")},show(e){"string"==typeof e&&(e=t.$(e)),Array.isArray(e)?e.forEach(e=>e.removeAttribute("hidden")):e.removeAttribute("hidden")},showMessage(e,n){let o=`
`,r=t.$(".message");void 0!==r[0]&&r[0].remove(),t.$("header")[0].insertAdjacentHTML("beforeend",o)},closestParent(t,n){if(void 0!==Element.prototype.closest)return t.closest(n);for(;t!==document.documentElement;){if(e(t,n))return t;t=t.parentElement}return null},url:e=>`//${document.location.host}`+("/"===e.charAt(0)?e:`/${e}`),throttle(e,t,n){let o=!1;return function(...r){o||(t.apply(n||this,r),o=!0,setTimeout(function(){o=!1},e))}}};function n(e,t,o){t.match(/^([\w\-]+)$/)||t.split(" ").forEach(t=>{n(e,t,o)}),e.addEventListener(t,o,!1)}function o(e){let t=[];return Object.keys(e).forEach(n=>{let o=e[n].toString();n=encodeURIComponent(n),o=encodeURIComponent(o),t.push(`${n}=${o}`)}),t.join("&")}t.on=(e,o,r,a)=>{void 0===a?(a=r,t.$(e).forEach(e=>{n(e,o,a)})):t.$(e).forEach(e=>{var s;s=a,n(e,o,n=>{t.$(r,e).forEach(e=>{n.target==e&&(s.call(e,n),n.stopPropagation())})})})},t.ajax=(e,n)=>{n={data:{},type:"GET",dataType:"",success:t.noop,mimeType:"application/x-www-form-urlencoded",error:t.noop,...n};let r=new XMLHttpRequest,a=String(n.type).toUpperCase();return"GET"===a&&(e+=e.match(/\?/)?o(n.data):`?${o(n.data)}`),r.open(a,e),r.onreadystatechange=()=>{if(4===r.readyState){let e="";e="json"===r.responseType?JSON.parse(r.responseText):r.responseText,r.status>299?n.error.call(null,r.status,e,r.response):n.success.call(null,e,r.status)}},"json"===n.dataType?(n.data=JSON.stringify(n.data),n.mimeType="application/json"):n.data=o(n.data),r.setRequestHeader("Content-Type",n.mimeType),"GET"===a?r.send(null):r.send(n.data),r},t.get=(e,n,o=null)=>(null===o&&(o=n,n={}),t.ajax(e,{data:n,success:o}));t.on("header","click",".message",function(e){t.hide(e.target)}),t.on("form.js-delete","submit",function(t){!1===confirm("Are you ABSOLUTELY SURE you want to delete this item?")&&(t.preventDefault(),t.stopPropagation())}),t.on(".js-clear-cache","click",function(){t.get("/cache_purge",()=>{t.showMessage("success","Successfully purged api cache")})}),t.on(".vertical-tabs input","change",function(t){let e=t.currentTarget.parentElement.getBoundingClientRect().top+window.pageYOffset;window.scrollTo({top:e,behavior:"smooth"})}),t.on(".media-filter","input",function(e){let i=e.target.value,n=RegExp(i,"i");""!==i?(t.$("article.media").forEach(e=>{let i=String(t.$(".name a",e)[0].textContent).trim();n.test(i)?t.show(e):t.hide(e)}),t.$("table.media-wrap tbody tr").forEach(e=>{let i=t.$("td.align-left",e)[0];n.test(String(t.$("a",i)[0].textContent).trim())||n.test(String(i.textContent).trim())?t.show(e):t.hide(e)})):(t.show("article.media"),t.show("table.media-wrap tbody tr"))});(()=>{let i=null,n=null;void 0!==document.hidden?(i="hidden",n="visibilitychange"):void 0!==document.msHidden?(i="msHidden",n="msvisibilitychange"):void 0!==document.webkitHidden&&(i="webkitHidden",n="webkitvisibilitychange"),null===i?console.info("Page visibility API not supported, JS session check will not work"):document.addEventListener(n,function t1(){document[i]||t.get("/heartbeat",e=>{!0!==JSON.parse(e).hasAuth&&(document.removeEventListener(n,t1,!1),location.reload())})},!1)})();t.on("main","change",".big-check",a=>{let i=a.target.id;document.getElementById(`mal_${i}`).checked=!0,document.getElementById(`anilist_${i}`).checked=!0});function renderSearchResults(a,i,e=!1){return i.map(i=>{let l=i.titles.join("