/*
Copyright (C) 2025 QuantumNous

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

For commercial licensing, please contact support@quantumnous.com
*/

import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { StatusContext } from '../../../context/Status';

const HomePageFooter = () => {
  const { t } = useTranslation();
  const [statusState] = useContext(StatusContext);
  const systemName = statusState?.status?.system_name || 'New API';
  const footerInfo = statusState?.status?.footer_info || '';

  const currentYear = new Date().getFullYear();

  const footerLinks = [
    { label: t('服务条款'), href: '/terms', external: false },
    { label: t('使用政策'), href: '/usage-policy', external: false },
  ];

  return (
    <footer className="home-snap-section home-footer">
      <div className="mx-auto w-full max-w-[1110px]">
        {/* 链接区域 */}
        <div className="mb-6 flex flex-col items-center justify-center gap-3 md:flex-row md:gap-4">
          {footerLinks.filter(link => link.href).map((link, index) => (
            <React.Fragment key={link.label}>
              <a
                href={link.href}
                target={link.external ? '_blank' : undefined}
                rel={link.external ? 'noopener noreferrer' : undefined}
                className="home-footer-link"
              >
                {link.label}
              </a>
              {index < footerLinks.filter(l => l.href).length - 1 && (
                <div className="hidden h-4 w-px bg-semi-color-border md:block" />
              )}
            </React.Fragment>
          ))}
        </div>

        {/* 分割线 */}
        <div className="border-t border-semi-color-border pt-6">
          <div className="flex flex-col items-center justify-between gap-4 md:flex-row">
            {/* 版权信息 */}
            {/*<div className="flex flex-col items-center gap-3 md:flex-row">*/}
            {/*  <span className="text-sm text-semi-color-text-1">*/}
            {/*    © {currentYear} {systemName}. {t('版权所有')}*/}
            {/*  </span>*/}
            {/*</div>*/}

            {/* 附加信息 */}
            {footerInfo && (
              <div
                className="text-center text-sm text-semi-color-text-2 md:text-right"
                dangerouslySetInnerHTML={{ __html: footerInfo }}
              />
            )}
          </div>
        </div>
      </div>
    </footer>
  );
};

export default HomePageFooter;
