<?php
/**
 * HubSpot config bridge for the admin app.
 * Loads the token from the same locations used by hubspot-create-deal.php.
 */
if (defined('HUBSPOT_PRIVATE_APP_TOKEN') && HUBSPOT_PRIVATE_APP_TOKEN !== '' && HUBSPOT_PRIVATE_APP_TOKEN !== 'YOUR_PRIVATE_APP_TOKEN_HERE') {
    return;
}

$candidates = [
    __DIR__ . '/demo_pandadoc/hubspot/api/hubspot-config.php',
    __DIR__ . '/hubspot/api/hubspot-config.php',
    dirname(__DIR__) . '/hubspot/api/hubspot-config.php',
];

foreach ($candidates as $path) {
    if (is_file($path)) {
        require_once $path;
        return;
    }
}

$envToken = getenv('HUBSPOT_PRIVATE_APP_TOKEN');
if ($envToken !== false && $envToken !== '' && !defined('HUBSPOT_PRIVATE_APP_TOKEN')) {
    define('HUBSPOT_PRIVATE_APP_TOKEN', $envToken);
}
