import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { AuthModule, AuthHttpInterceptor } from '@auth0/auth0-angular';
import { PublicComponent } from './components/public/public.component';
import { PrivateComponent } from './components/private/private.component';
import { AgregarResComponent } from './components/agregar-res/agregar-res.component';
import { AgregarUsuarioComponent } from './components/agregar-usuario/agregar-usuario.component';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { ModalComponent } from './components/modal/modal.component';
import { ModalUsuarioComponent } from './components/modal-usuario/modal-usuario.component';
import { MesasRestarantComponent } from './components/mesas-restarant/mesas-restarant.component';
import { SectoresComponent } from './components/sectores/sectores.component';

@NgModule({
  declarations: [
    AppComponent,
    PublicComponent,
    PrivateComponent,
    AgregarResComponent,
    AgregarUsuarioComponent,
    ModalComponent,
    ModalUsuarioComponent,
    MesasRestarantComponent,
    SectoresComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    AuthModule.forRoot({
      domain: 'dev-ygnrzo5i.us.auth0.com',
      clientId: '2MCYrmwNWAkeJyYYYRCS1gscDbiwAIfq',
      cacheLocation: 'localstorage',
      useRefreshTokens:true,
      audience: 'https://api.unified.restaurant',
      scope: 'read:current_user',
      httpInterceptor:{
        allowedList: [
          {
            // Match any request that starts 'https://dev-6scsp8es.us.auth0.com/api/v2/' (note the asterisk)
            uri: 'https://api.unified.restaurant/api/v1/*',
            tokenOptions: {
              // The attached token should target this audience
              audience: 'https://api.unified.restaurant',

              // The attached token should have these scopes
              scope: 'read:current_user'
            }
          }
        ]
      }
    }),


    HttpClientModule,
    FormsModule,
    NgbModule
  ],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
