#!/bin/sh
set -eu

site='https://minimaxh3.art'

url_for() {
  case "${1:-home}" in
    home) printf '%s/\n' "$site" ;;
    studio) printf '%s/#studio\n' "$site" ;;
    pricing) printf '%s/#pricing\n' "$site" ;;
    blog) printf '%s/blog/\n' "$site" ;;
    about) printf '%s/about/\n' "$site" ;;
    contact) printf '%s/contact/\n' "$site" ;;
    privacy) printf '%s/privacy/\n' "$site" ;;
    terms) printf '%s/terms/\n' "$site" ;;
    refund-policy) printf '%s/refund-policy/\n' "$site" ;;
    zh-home) printf '%s/zh/\n' "$site" ;;
    *)
      printf 'Unknown page: %s\n' "$1" >&2
      return 64
      ;;
  esac
}

open_url() {
  target="$1"
  if command -v open >/dev/null 2>&1; then
    open "$target"
  elif command -v xdg-open >/dev/null 2>&1; then
    xdg-open "$target"
  else
    printf '%s\n' "$target"
  fi
}

case "${1:-help}" in
  home|studio|pricing|blog|about|contact|privacy|terms|refund-policy|zh-home)
    url_for "$1"
    ;;
  metadata)
    cat <<'EOF'
name=MiniMax H3
homepage=https://minimaxh3.art
description=2K AI video generator with synced audio — text-to-video and image-to-video.
EOF
    ;;
  open)
    target="$(url_for "${2:-home}")"
    open_url "$target"
    ;;
  help|--help|-h)
    cat <<'EOF'
Usage: minimaxh3-site-kit <command>

Commands:
  home            Print the MiniMax H3 homepage URL
  studio       Print the MiniMax H3 studio URL
  pricing         Print the pricing section URL
  blog            Print the blog URL
  about           Print the about page URL
  contact         Print the contact page URL
  privacy         Print the privacy page URL
  terms           Print the terms page URL
  refund-policy   Print the refund policy URL
  zh-home         Print the Simplified Chinese homepage URL
  metadata        Print basic public metadata
  open [command]  Open a URL in the system browser, or print it on headless systems
EOF
    ;;
  *)
    printf 'Unknown command: %s\n\n' "$1" >&2
    "$0" help >&2
    exit 64
    ;;
esac
