import { SubscriptionProviderBase } from './base.js';
export class ZhiPuSubscriptionProvider extends SubscriptionProviderBase {
    provider = 'zhipu';
    async fetchQuota(config) {
        const url = 'https://bigmodel.cn/api/monitor/usage/quota/limit';
        const res = await fetch(url, {
            method: 'GET',
            headers: {
                'Accept': 'application/json, text/plain, */*',
                'Set-Language': 'zh',
                ...config.headers,
            },
        });
        if (!res.ok) {
            throw new Error(`ZhiPu API returned ${res.status}: ${res.statusText}`);
        }
        const json = await res.json();
        if (json.code !== 200 || !json.success) {
            throw new Error(`ZhiPu API error: ${json.msg}`);
        }
        return {
            provider: 'zhipu',
            label: config.label,
            limits: json.data.limits.map(l => ({
                type: l.type,
                unit: l.unit,
                number: l.number,
                usage: l.usage,
                currentValue: l.currentValue,
                remaining: l.remaining,
                percentage: l.percentage,
                nextResetTime: l.nextResetTime,
                usageDetails: l.usageDetails,
            })),
            fetchedAt: new Date().toISOString(),
        };
    }
}
//# sourceMappingURL=zhipu.js.map