"""
JamPulse AI – zentrale Module (Video, Kalender, Bezahlung, Social).

  python -m jam.jampulse_ai status
  python -m jam.jampulse_ai calendar --generate
  python -m jam.jampulse_ai checkout pro_monthly
"""

from __future__ import annotations

from jam.jampulse_brand import MINUTE_OFFER, SUBSCRIPTION_OFFER
from jam.jampulse_calendar import generate_calendar, list_entries, run_due
from jam.jampulse_checkout import create_checkout_session, product_catalog, verify_session
from jam.jampulse_license import can_generate, license_status
from jam.jampulse_templates import INDUSTRY_TEMPLATES

__all__ = [
    "MINUTE_OFFER",
    "SUBSCRIPTION_OFFER",
    "INDUSTRY_TEMPLATES",
    "can_generate",
    "license_status",
    "generate_calendar",
    "list_entries",
    "run_due",
    "create_checkout_session",
    "product_catalog",
    "verify_session",
]


def main() -> int:
    import argparse

    p = argparse.ArgumentParser(description="JamPulse AI CLI")
    sub = p.add_subparsers(dest="cmd")

    sub.add_parser("status", help="Lizenz-Status")
    cal = sub.add_parser("calendar", help="Content-Kalender")
    cal.add_argument("--generate", action="store_true")
    cal.add_argument("--run-due", action="store_true")
    chk = sub.add_parser("checkout", help="Stripe Checkout URL")
    chk.add_argument("product", nargs="?", default="pro_monthly")

    args = p.parse_args()
    if args.cmd == "status":
        print(license_status())
        return 0
    if args.cmd == "calendar":
        if args.generate:
            print(generate_calendar())
        if args.run_due:
            print(run_due())
        if not args.generate and not args.run_due:
            print(list_entries())
        return 0
    if args.cmd == "checkout":
        r = create_checkout_session(args.product)
        print(r.get("url") or r.get("error"))
        return 0 if r.get("ok") else 1
    p.print_help()
    return 1


if __name__ == "__main__":
    raise SystemExit(main())
