{% extends "base.html" %}
{% load vite_tags %}

{% block title %}{{ library_page_title|default:"AI Agent Templates & Workers | Gobii" }}{% endblock %}
{% block head_extras %}
  {{ block.super }}
  <meta name="description" content="{{ library_page_description|default:"Explore Gobii’s library of AI agents and workers for sales, research, recruiting, operations, spreadsheets, email, and more. Start from a template or build your own." }}">
  <meta property="og:type" content="website">
  <meta property="og:title" content="{{ library_page_title|default:"AI Agent Templates & Workers | Gobii" }}">
  <meta property="og:description" content="{{ library_page_description|default:"Explore Gobii’s library of AI agents and workers for sales, research, recruiting, operations, spreadsheets, email, and more. Start from a template or build your own." }}">
  <meta property="og:url" content="{{ canonical_url }}">
  <meta property="og:site_name" content="Gobii">
  <meta name="twitter:card" content="summary">
  <meta name="twitter:title" content="AI Agent Templates & Workers | Gobii">
  <meta name="twitter:description" content="Explore Gobii’s library of AI agents and workers for sales, research, recruiting, operations, spreadsheets, email, and more. Start from a template or build your own.">
  <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "CollectionPage",
      "name": "Gobii Agent Discovery",
      "description": "Discover public Gobii agent templates by category, then deploy and customize them for your workflows.",
      "url": "{{ canonical_url|escapejs }}",
      "isPartOf": {
        "@type": "WebSite",
        "name": "Gobii",
        "url": "{{ request.scheme }}://{{ request.get_host }}"
      }
    }
  </script>
  {% if library_initial_payload.agents %}
    <script type="application/ld+json">
      {
        "@context": "https://schema.org",
        "@type": "ItemList",
        "name": "Popular Gobii agent templates",
        "url": "{{ canonical_url|escapejs }}",
        "itemListElement": [
          {% for agent in library_initial_payload.agents %}
            {
              "@type": "ListItem",
              "position": {{ forloop.counter }},
              "item": {
                "@type": "SoftwareApplication",
                "name": "{{ agent.name|escapejs }}",
                "description": "{{ agent.description|default:agent.tagline|truncatechars:160|escapejs }}",
                "applicationCategory": "{{ agent.category|escapejs }}",
                "creator": {
                  "@type": "Person",
                  "name": "{{ agent.publicProfileHandle|escapejs }}"
                },
                "url": "{{ request.scheme }}://{{ request.get_host }}{{ agent.templateUrl|escapejs }}"
              }
            }{% if not forloop.last %},{% endif %}
          {% endfor %}
        ]
      }
    </script>
  {% endif %}
  <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "BreadcrumbList",
      "itemListElement": [
        {
          "@type": "ListItem",
          "position": 1,
          "name": "Home",
          "item": "{{ request.scheme }}://{{ request.get_host }}{% url 'pages:home' %}"
        },
        {
          "@type": "ListItem",
          "position": 2,
          "name": "Agent Discovery",
          "item": "{{ request.scheme }}://{{ request.get_host }}{% url 'pages:library' %}"
        }
      ]
    }
  </script>
{% endblock %}

{% block content %}
<div class="bg-gradient-to-b from-white via-indigo-50/40 to-white">
  <section class="mx-auto w-full max-w-7xl px-4 py-10 sm:px-6 lg:px-8">
    {{ library_initial_payload|json_script:"library-initial-payload" }}
    <div
      id="gobii-frontend-root"
      data-app="library"
      data-props-json-id="library-initial-payload"
      data-library-list-url="{% url 'pages:library_agents_api' %}"
      data-library-like-url="{% url 'pages:library_agent_like_api' %}"
      data-library-can-like="{{ user.is_authenticated|yesno:'true,false' }}"
      data-library-initial-category="{{ library_initial_category|default:'' }}"
    >
      {% include "library/_fallback.html" with payload=library_initial_payload selected_category=library_initial_category %}
    </div>
  </section>
</div>
{% endblock %}

{% block extra_js %}
  {{ block.super }}
  {% vite_asset 'src/main.tsx' %}
{% endblock %}
