import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
import style from "./styles/footer.scss"
import { version } from "../../package.json"
import { i18n } from "../i18n"

interface Options {
  links: Record<string, string>
}

export default ((opts?: Options) => {
  const Footer: QuartzComponent = ({ displayClass, cfg }: QuartzComponentProps) => {
    const year = new Date().getFullYear()
    const links = opts?.links ?? []
    return (
      <footer class={`${displayClass ?? ""}`}>
        <hr />
        <p style="display: flex; flex-wrap: wrap; justify-content: space-between;">
          <span>Copyright © {year} Sam Dalfuss</span>
          <span>
            {i18n(cfg.locale).components.footer.createdWith}{" "}
            <a href="https://quartz.jzhao.xyz/" rel="nofollow noreferrer noopener" target="_blank">Quartz</a> v{version}+<a href="https://corteximplant.net/users/marta" rel="nofollow noreferrer noopener" target="_blank">marta</a>+sam 
          </span>
        </p>
        <ul style="margin-bottom: 8px;">
          {Object.entries(links).map(([text, link]) => (
            <li>
              <a href={link} rel="me">{text}</a>
            </li>
          ))}
        </ul>
        <span class="footer-w1">
          <a href="https://obeythesystem.com/" rel="nofollow" target="_blank">
            <img src="/static/obeythesystem1.gif" class="w1-button"></img>
          </a>
          <a href="https://corteximplant.com/@dalfuss" rel="me nofollow" target="_blank">
            <img src="/static/addmeon.jpg" class="w1-button"></img>
          </a>
          <img src="/static/88x31_dalfuss.png" class="w1-button"></img>
          <a href="https://elftwinks.gay/" rel="nofollow" target="_blank">
            <img src="/static/88x31_ElfTwinks.png" class="w1-button"></img>
          </a>
          <img src="/static/88x31_enby.png" class="w1-button"></img>
          <img src="/static/88x31_trans.png" class="w1-button"></img>
          <img src="/static/88x31_pan.png" class="w1-button"></img>
          <img src="/static/dursti.gif" class="w1-button"></img>
          <img src="/static/sendnudes.png" class="w1-button"></img>
          <img src="/static/ilovegothgirls.gif" class="w1-button"></img>
        </span>
      </footer>
    )
  }

  Footer.css = style
  return Footer
}) satisfies QuartzComponentConstructor
