<Route
  @name={{routeName}}
  @title='Consul'
  @titleSeparator=" - "
>

{{#if (env 'CONSUL_ACLS_ENABLED')}}
  {{document-attrs class="has-acls"}}
{{/if}}
{{#if (env 'CONSUL_NSPACES_ENABLED')}}
  {{document-attrs class="has-nspaces"}}
{{/if}}

<DataSource
  @src="settings://consul:theme"
as |source|>
{{#each-in source.data as |key value|}}
  {{#if (and value (contains key (array "color-scheme" "contrast")))}}
    {{document-attrs class=(concat 'prefers-' key '-' value)}}
  {{/if}}
{{/each-in}}
</DataSource>

{{#if (not-eq router.currentRouteName 'application')}}
  <HashicorpConsul
    id="wrapper"
    @dcs={{dcs}}
    @dc={{or dc dcs.firstObject}}
    @nspaces={{nspaces}}
    @nspace={{or nspace nspaces.firstObject}}
    @onchange={{action "reauthorize"}}
  as |consul|>
    <Outlet
    @name="application"
    @model={{hash
      app=consul
    }}
    as |o|>
      {{outlet}}
    </Outlet>
    <Consul::Loader
      class="view-loader"
    />
  </HashicorpConsul>
{{/if}}
</Route>
