/**
 * Theme: theme-Serenity
 * Author: Serenity
 * Build: 2026-04-12 21:46:28
 * Fingerprint: 3d12f6e686831ac7
 * Copyright © 2026 Serenity. All rights reserved.
 * Unauthorized copying or distribution is prohibited.
 */
var currentLinkUrl='';document.addEventListener('DOMContentLoaded',function(){var linkCards=document.querySelectorAll('.link-card[data-link]');var confirmModal=document.getElementById('linkConfirmModal');var confirmButton=document.querySelector('.link-confirm-cta');fetchInvalidLinkGroup();linkCards.forEach(function(card){card.addEventListener('click',function(event){event.preventDefault();var url=this.href;var name=this.querySelector('.link-name')?.textContent||'该站点';showLinkConfirm(url,name);});});function handleKeydown(event){if(event.key==='Escape'&&confirmModal?.classList.contains('active')){closeLinkConfirm();}}document.addEventListener('keydown',handleKeydown);document.addEventListener('pjax:beforeReplace',function(){document.removeEventListener('keydown',handleKeydown);},{once:true});});async function fetchInvalidLinkGroup(){try{var response=await fetch('/apis/link.submit.kunkunyu.com/v1alpha1/cronlinksubmits/cron-link-submit-default');if(!response.ok)return;var data=await response.json();var moveGroupName=data.spec?.cleanConfig?.moveGroupName;if(!moveGroupName)return;var groupResponse=await fetch('/apis/core.halo.run/v1alpha1/linkgroups/'+moveGroupName);if(!groupResponse.ok)return;var groupData=await groupResponse.json();var invalidGroupDisplayName=groupData.spec?.displayName;if(!invalidGroupDisplayName)return;markInvalidLinks(invalidGroupDisplayName);}catch(error){}}function markInvalidLinks(invalidGroupName){var linkCards=document.querySelectorAll('.link-card[data-link]');var offlineLabel=window.LINK_CONFIG?.offlineLabel||'失联咯';linkCards.forEach(function(card){var groupTag=card.querySelector('.link-group-tag');if(groupTag&&groupTag.textContent===invalidGroupName){card.classList.add('link-offline');if(!card.querySelector('.link-status-offline')){var statusTag=document.createElement('span');statusTag.className='link-status-offline';statusTag.textContent=offlineLabel;card.insertBefore(statusTag,card.firstChild);}}});}function showLinkConfirm(url,name){currentLinkUrl=url;var modal=document.getElementById('linkConfirmModal');var targetName=document.querySelector('.link-target-name');var confirmButton=document.querySelector('.link-confirm-cta');if(targetName){targetName.textContent=name;}if(modal){modal.classList.add('active');}if(confirmButton){confirmButton.focus();}}function confirmLinkVisit(){if(!currentLinkUrl)return;window.open(currentLinkUrl,'_blank','noopener,noreferrer');closeLinkConfirm();}function closeLinkConfirm(){var modal=document.getElementById('linkConfirmModal');currentLinkUrl='';if(modal){modal.classList.remove('active');}}function visitRandomLink(){var links=document.querySelectorAll('.link-card[data-link]');if(links.length>0){var randomIndex=Math.floor(Math.random()*links.length);links[randomIndex].click();}}