<?php

declare(strict_types=1);

namespace App\Services\SupportCenter;

use App\Enums\SupportCenter\SiteConnectionStatus;

/**
 * 本地站点连接就绪状态解析（本步骤不调用远程 Support Center）。
 *
 * 口径与 {@see SupportCenterConnectivityGuard} 一致：host_key 可选；登记信息同步不影响本状态。
 */
final class HostSiteConnectionStatusResolver
{
    public function __construct(
        private readonly SupportCenterRuntimeConfig $runtimeConfig,
        private readonly SupportCenterConnectivityGuard $connectivityGuard,
    ) {}

    public function resolve(): SiteConnectionStatus
    {
        if (! $this->runtimeConfig->enabled()) {
            return SiteConnectionStatus::NotConnected;
        }

        return $this->connectivityGuard->canMakeRealCalls()
            ? SiteConnectionStatus::Ready
            : SiteConnectionStatus::Pending;
    }
}
