@inherits LayoutComponentBase
@layout MasterInit
@inject IJSRuntime JS

@using Layout._Helpers
@using Layout
@using Layout.Partials.HeaderLayout
@using Starterkit.Shared.Partials

<!--begin::App-->
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
	<!--begin::Page-->
	<div class="app-page flex-column flex-column-fluid" id="kt_app_page">
		<_Header></_Header>
		<!--begin::Wrapper-->
		<div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
			<!--begin::Main-->
			<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
				<!--begin::Content wrapper-->
				<div class="d-flex flex-column flex-column-fluid">
					<_Toolbar></_Toolbar>
					<!--begin::Content-->
                    <div id="kt_app_content" class="app-content flex-column-fluid">
                        <!--begin::Content container-->
                        <div id="kt_app_content_container" class="app-container container-xxl">
                            @Body
                        </div>
                        <!--end::Content container-->
                    </div>
                    <!--end::Content-->
				</div>
				<!--end::Content wrapper-->
				<_Footer></_Footer>
			</div>
			<!--end:::Main-->
		</div>
		<!--end::Wrapper-->
	</div>
	<!--end::Page-->
</div>
<!--end::App-->

<_Drawers></_Drawers>
<_ModalComponents></_ModalComponents>
<_Scrolltop></_Scrolltop>

@code {
	private IKTThemeHelpers _helper;

	protected override void OnInitialized() // = On Page Load
	{
		_helper = new KTThemeHelpers(JS);   
		_helper.addBodyAttribute("data-kt-app-page-loading", "on");
	}
	
	protected override void OnAfterRender(bool firstRender){
		_helper = new KTThemeHelpers(JS);

		_helper.addBodyAttribute("data-kt-app-reset-transition", "true");

		_helper.addBodyAttribute("data-kt-app-layout", "dark-header");
		_helper.addBodyAttribute("data-kt-app-header-fixed", "true");
		_helper.addBodyAttribute("data-kt-app-toolbar-enabled", "true");
        
		_helper.addBodyClass("app-default");

		JS.InvokeVoidAsync("KTModalUpgradePlan.init");
		JS.InvokeVoidAsync("KTCreateApp.init");
		JS.InvokeVoidAsync("KTModalUserSearch.init");
		JS.InvokeVoidAsync("KTModalNewTarget.init");
		JS.InvokeVoidAsync("KTAppSidebar.init");
	}

	protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        await Task.Delay(300);
		await JS.InvokeVoidAsync("document.body.removeAttribute", "data-kt-app-reset-transition");
		await JS.InvokeVoidAsync("document.body.removeAttribute", "data-kt-app-page-loading");
    }
}