// src/app/app.config.ts

import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { provideHttpClient, withInterceptors } from '@angular/common/http'; // 导入 withInterceptors
import { provideAnimations } from '@angular/platform-browser/animations';
import { registerLocaleData } from '@angular/common';
import en from '@angular/common/locales/en';

import { en_US, provideNzI18n } from 'ng-zorro-antd/i18n';

// 导入我们创建的图标提供者
import { provideNzIcons } from './icons-provider';

import { routes } from './app.routes';
// 导入自定义的函数式拦截器
import { AuthInterceptor } from './interceptors/auth.interceptor';

registerLocaleData(en);

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
    provideNzIcons,
    provideNzI18n(en_US),
    provideAnimations(),
    // 使用 withInterceptors 注册函数式拦截器
    // 这将自动处理拦截器的依赖注入
    provideHttpClient(withInterceptors([AuthInterceptor]))
  ]
};
