import { enableProdMode, NgZone } from "@angular/core"
import { applyPolyfills, defineCustomElements } from '@duetds/components/lib/loader'

import { environment } from "./environments/environment"
import { createApplication } from "@angular/platform-browser"
import { AppComponent } from "./app/app.component"
import { PreloadAllModules, provideRouter, withDebugTracing, withPreloading } from "@angular/router"
import { routes } from "./app/app-routing.module"

(async () => {

  const app = await createApplication({
    providers: [
      provideRouter(routes,
        withPreloading(PreloadAllModules),
        withDebugTracing(),
      ),
    ],
  });

  if (environment.production) {
    enableProdMode()
  }

// Register Duet’s custom elements
  applyPolyfills().then(() => {
    defineCustomElements(window)
  })

  app.injector.get(NgZone).run(() => {
    app.bootstrap(AppComponent);
  });

})();

