'use client' import React from 'react' import { useRouter, usePathname, useSearchParams } from 'next/navigation' import { getCookie } from 'cookies-next' import { useTranslations } from 'next-intl' import { Hovercard, HovercardContent, HovercardTrigger, } from '~components/common/Hovercard' import Button from '~components/common/Button' import WeaponLabelIcon from '~components/weapon/WeaponLabelIcon' import UncapIndicator from '~components/uncap/UncapIndicator' import { overMastery, aetherialMastery, permanentMastery, } from '~data/overMastery' import { ExtendedMastery } from '~types' import styles from './index.module.scss' import HovercardHeader from '~components/HovercardHeader' interface Props { gridCharacter: GridCharacter children: React.ReactNode onTriggerClick: () => void } const CharacterHovercard = (props: Props) => { const router = useRouter() const pathname = usePathname() const searchParams = useSearchParams() const t = useTranslations('common') const routerLocale = getCookie('NEXT_LOCALE') const locale = routerLocale && ['en', 'ja'].includes(routerLocale) ? routerLocale : 'en' const Element = ['null', 'wind', 'fire', 'water', 'earth', 'dark', 'light'] const tintElement = Element[props.gridCharacter.object.element] function goTo() { const urlSafeName = props.gridCharacter.object.name.en.replaceAll(' ', '_') const url = `https://gbf.wiki/${urlSafeName}` window.open(url, '_blank') } function masteryElement(dictionary: ItemSkill[], mastery: ExtendedMastery) { const canonicalMastery = dictionary.find( (item) => item.id === mastery.modifier ) if (canonicalMastery) { return (
  • {canonicalMastery.name[locale]} {canonicalMastery.name[locale]}  {`+${mastery.strength}${canonicalMastery.suffix}`}
  • ) } } const overMasterySection = () => { if ( props.gridCharacter && props.gridCharacter.over_mastery && props.gridCharacter.over_mastery.length > 0 ) { return (
    {t('modals.characters.subtitles.ring')}
    ) } } const aetherialMasterySection = () => { if ( props.gridCharacter && props.gridCharacter.over_mastery && props.gridCharacter.aetherial_mastery && props.gridCharacter.aetherial_mastery?.modifier > 0 ) { return (
    {t('modals.characters.subtitles.earring')}
    ) } } const permanentMasterySection = () => { if (props.gridCharacter && props.gridCharacter.perpetuity) { return (
    {t('modals.characters.subtitles.permanent')}
    ) } } const awakeningSection = () => { if (props.gridCharacter.awakening) { const gridAwakening = props.gridCharacter.awakening return (
    {t('modals.characters.subtitles.awakening')}
    {gridAwakening.type.slug !== 'character-balanced' && ( {gridAwakening.type.name[locale]} )} {`${gridAwakening.type.name[locale]}`}  {`Lv${gridAwakening.level}`}
    ) } } const wikiButton = (