{#
  Review-form gate. `eligibility` comes from StorefrontSubmissionGuard::eligibility() —
  the same rules the REST endpoint enforces — so the notice shown here can never
  disagree with what the server accepts.
#}
{% set reason = eligibility.reason|default(null) %}
{% if eligibility.can_review|default(false) %}
    {% include "storefront/widget/Features/ReviewForm/index.twig" %}
{% elseif reason == 'login_required' %}
    <div class="rvx-review-gate rvx-review-gate--login rvx-mx-auto rvx-w-full rvx-max-w-[640px]">
      {% set login_action %}
        <div class="rvx-flex rvx-flex-wrap rvx-justify-center rvx-gap-space8">
          {% include 'storefront/ui/button.twig' with { tag: 'a', label: __('Log in', 'reviewx'), variant: 'merchant', class: 'rvx-review-gate__login', attrs: 'href="' ~ login_url ~ '"' } %}
          {% if registration_enabled %}{% include 'storefront/ui/button.twig' with { tag: 'a', label: __('Create an account', 'reviewx'), variant: 'secondary', class: 'rvx-review-gate__register', attrs: 'href="' ~ register_url ~ '"' } %}{% endif %}
        </div>
      {% endset %}
      {% include 'storefront/ui/empty-state.twig' with { icon: 'person', title: eligibility.verified_only|default(false) ? __('Log in to review a product you have purchased', 'reviewx') : __('Log in to write a review', 'reviewx'), text: __('Reviews help other shoppers decide - it only takes a minute.', 'reviewx'), action: login_action } %}
    </div>
{% elseif reason == 'purchase_required' %}
    <div class="rvx-review-gate rvx-review-gate--purchase rvx-mx-auto rvx-w-full rvx-max-w-[640px]">
      {% include 'storefront/ui/empty-state.twig' with { icon: 'check-circle', title: __('Reviews are open to verified buyers', 'reviewx'), text: __('Only customers who have purchased this product can leave a review.', 'reviewx') } %}
    </div>
{% elseif reason == 'already_reviewed' %}
    <div class="rvx-review-gate rvx-review-gate--reviewed rvx-mx-auto rvx-w-full rvx-max-w-[640px]">
      {% include 'storefront/ui/empty-state.twig' with { icon: 'check-circle', title: __('Thanks - you have already reviewed this product', 'reviewx') } %}
    </div>
{% endif %}
