<script lang="ts">
  import type { HuggingFaceLibs } from '$lib/types';
  
  interface Props {
    hfAuth: HuggingFaceLibs | null;
  }
  
  let { hfAuth = null }: Props = $props();
  
  async function handleSignIn() {
    if (!hfAuth) return;
    
    const url = await hfAuth.oauthLoginUrl({ scopes: ["inference-api"] });
    window.location.href = url;
  }
</script>

<button 
  class="signin-button" 
  onclick={handleSignIn}
  disabled={!hfAuth}
>
  Sign in with Hugging Face
</button>

<style>
  .signin-button {
    background: #ff7b7b;
    color: #fff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
  }
  
  .signin-button:hover:not(:disabled) {
    background: #ff6565;
  }
  
  .signin-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
</style>