{% comment %}
  OpenAgent chat widget for Shopify.

  Install (about 2 minutes):
  1. In your OpenAgent dashboard, allowlist your storefront domain
     (both your-store.myshopify.com and your custom domain).
  2. Shopify admin -> Online Store -> Themes -> ... -> Edit code.
  3. Under "Snippets", click "Add a new snippet", name it: openagent-chat
     and paste this whole file in.
  4. Replace YOUR_WORKSPACE_SLUG below with the slug shown in your
     OpenAgent dashboard under Settings -> Install widget.
  5. Open layout/theme.liquid and add this line just before </body>:

       {% render 'openagent-chat' %}

  6. Save. The chat bubble is live on every storefront page.

  The widget renders in a Shadow DOM, so it will not collide with your
  theme's CSS. The script is async and ~27 KB gzipped.
  Full guide: https://openagent.in/install
{% endcomment %}

{%- assign openagent_tenant = 'YOUR_WORKSPACE_SLUG' -%}

{%- unless openagent_tenant == 'YOUR_WORKSPACE_SLUG' -%}
<script
  async
  src="https://app.openagent.in/openagent.js"
  data-tenant="{{ openagent_tenant }}"
  data-api-url="https://app.openagent.in"
  data-ws-url="wss://app.openagent.in"
  {%- if customer %} data-external-id="shopify-{{ customer.id }}"{% endif -%}
></script>
{%- else -%}
{% comment %} Not configured yet: nothing is rendered on the storefront. {% endcomment %}
{%- endunless -%}
