import { getSystemConfig } from '../admin/system-config.service';
import { CLOUD_ICONS, CLOUD_LABELS } from '../config/cloud-constants';
export interface CloudTypeInfo { type: string; label: string; icon: string; enabled: boolean; }
export const ALL_CLOUD_TYPES = [
  { type:'quark', label:CLOUD_LABELS.quark, icon:CLOUD_ICONS.quark },
  { type:'baidu', label:CLOUD_LABELS.baidu, icon:CLOUD_ICONS.baidu },
  { type:'aliyun', label:CLOUD_LABELS.aliyun, icon:CLOUD_ICONS.aliyun },
  { type:'115', label:CLOUD_LABELS['115'], icon:CLOUD_ICONS['115'] },
  { type:'tianyi', label:CLOUD_LABELS.tianyi, icon:CLOUD_ICONS.tianyi },
  { type:'123pan', label:CLOUD_LABELS['123pan'], icon:CLOUD_ICONS['123pan'] },
  { type:'uc', label:CLOUD_LABELS.uc, icon:CLOUD_ICONS.uc },
  { type:'xunlei', label:CLOUD_LABELS.xunlei, icon:CLOUD_ICONS.xunlei },
  { type:'pikpak', label:CLOUD_LABELS.pikpak, icon:CLOUD_ICONS.pikpak },
  { type:'magnet', label:CLOUD_LABELS.magnet, icon:CLOUD_ICONS.magnet },
  { type:'ed2k', label:CLOUD_LABELS.ed2k, icon:CLOUD_ICONS.ed2k },
  { type:'others', label:CLOUD_LABELS.others, icon:CLOUD_ICONS.others }];
export function isCloudTypeEnabled(type: string): boolean { const v = getSystemConfig('cloud_type_'+type+'_enabled'); return v===null ? type!=='others' : v==='true'||v==='1'; }
export function getAllCloudTypes(): CloudTypeInfo[] { return ALL_CLOUD_TYPES.map(ct=>({...ct,enabled:isCloudTypeEnabled(ct.type)})); }
export function getEnabledCloudTypeSet(): Set<string> { const s=new Set<string>(); for(const ct of ALL_CLOUD_TYPES) if(isCloudTypeEnabled(ct.type)) s.add(ct.type); return s; }
