<?php
/**
 * Free-tier helpers — build-time differentiation.
 *
 * The free WordPress.org zip is a genuinely smaller build, NOT a license-gated
 * one (WP.org forbids gating present features behind a license). build.py
 * injects `INSTINCTOR_FREE_TIER` into the free zip and strips every
 * `PRO-START … PRO-END` region below, so the free build ships ONLY the static
 * list branches — zero license/tier-check logic. Standalone and the licensed
 * Pro build (-pro.zip, self-distributed) keep the TierManager-driven branches.
 *
 * Mechanisms, by feature:
 *   - STRIP   : Pro-only code removed from the free zip (catalog effects, etc.).
 *   - CAP     : present-but-limited via instinctor_locked()/build-time constant.
 *   - WATERMARK: premium 3D/depth output is marked in free (instinctor_free_watermark()).
 *
 * @package Instinctor
 */

if (!defined('ABSPATH')) { exit; }

// Pro feature slugs LOCKED in the free build. 3D depth + environments are NOT
// in this list because they are handled separately (2026-07-05): they render
// live in the EDITOR as a Pro demo but PUBLISH FLAT on the free build
// (instinctor_env_locked() returns true on the front-end path). No watermark.
if (!defined('INSTINCTOR_FREE_LOCKED')) {
    define('INSTINCTOR_FREE_LOCKED', array(
        'section_fx',
        'chat_pro',
        'seo_advanced',
        'network',
        'multipage',
        // Premium commerce suite — the WooCommerce paid-extension equivalents.
        // The basic store stays free: products (unlimited), cart, a working
        // standard checkout, Stripe, AND all the visible product/cart effects
        // (flip cards, side cart) — visible beauty is never locked. Pro gates the
        // FUNCTIONAL extensions WC charges for.
        'custom_checkout',     // configurable checkout field grid / layout / styling
        'store_subscriptions', // recurring billing (wired at the product editor)
        'store_bundles',       // product bundles / build-your-own
        'store_bookings',      // service booking
    ));
}

/** True only in the stripped free WordPress.org build. */
function instinctor_is_free_build(): bool {
    return defined('INSTINCTOR_FREE_TIER') && INSTINCTOR_FREE_TIER;
}

/** Is a Pro feature slug locked in THIS build? */
function instinctor_locked(string $feature): bool {
    
    return in_array($feature, INSTINCTOR_FREE_LOCKED, true);
}

/** Is a cloud/environment effect locked in THIS build? */
function instinctor_env_locked(string $effect): bool {
    
    // WP.org free build (2026-07-05): 3D/depth environments are an EDITOR-ONLY
    // demo, never published. This gate runs only on the FRONT-END render path
    // (impulse-page.php; impulse-animation-helpers guards it with !$isPreview),
    // so returning true publishes flat pages while the editor preview
    // (impulse-preview.php, which never calls this) still shows live 3D.
    return true;
}

/** Should premium 3D / depth OUTPUT carry the free-tier watermark in THIS build? */
function instinctor_free_watermark(): bool {
    
    // No watermark on the free build. 3D/depth is an editor-only demo now, so
    // there is no published output to mark, and forced front-end branding would
    // violate WP.org Guideline 10.
    return false;
}

/** Editor's notion of "licensed" (drives Pro-upsell affordances). Free build = false. */
function instinctor_editor_has_license(): bool {
    
    return false;
}

/** Build-time replacement for TierManager::isPro(). Free build = false (no license call). */
function instinctor_has_pro(): bool {
    
    return false;
}

/** Build-time replacement for TierManager::tier(). Free build = 'free' (no license call). */
function instinctor_tier(): string {
    
    return 'free';
}
