"use client"; import { createBroadcastClient, type BroadcastClient } from "@bytelyst/broadcast-client"; import { PLATFORM_SERVICE_URL, PRODUCT_ID } from "@/lib/product-config"; function getAccessToken(): string { if (typeof window === "undefined") return ""; return localStorage.getItem(`${PRODUCT_ID}_access_token`) ?? ""; } let _client: BroadcastClient | null = null; export function getBroadcastClient(): BroadcastClient { if (!_client) { _client = createBroadcastClient({ baseUrl: PLATFORM_SERVICE_URL, productId: PRODUCT_ID, getAuthToken: getAccessToken, platform: "web", appVersion: "0.1.0", osVersion: typeof navigator !== "undefined" ? navigator.userAgent.slice(0, 40) : "unknown", }); } return _client; }