| 
						
						
							
								
							
						
						
					 | 
					@ -6,9 +6,11 @@ import { hasPermission, permissions } from '@ghostfolio/common/permissions'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { GfFireCalculatorComponent } from '@ghostfolio/ui/fire-calculator'; | 
					 | 
					 | 
					import { GfFireCalculatorComponent } from '@ghostfolio/ui/fire-calculator'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; | 
					 | 
					 | 
					import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { GfValueComponent } from '@ghostfolio/ui/value'; | 
					 | 
					 | 
					import { GfValueComponent } from '@ghostfolio/ui/value'; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import { FormsModule } from '@angular/forms'; | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					import { CommonModule, NgStyle } from '@angular/common'; | 
					 | 
					 | 
					import { CommonModule, NgStyle } from '@angular/common'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; | 
					 | 
					 | 
					import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import { FormControl } from '@angular/forms'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { Big } from 'big.js'; | 
					 | 
					 | 
					import { Big } from 'big.js'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { DeviceDetectorService } from 'ngx-device-detector'; | 
					 | 
					 | 
					import { DeviceDetectorService } from 'ngx-device-detector'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; | 
					 | 
					 | 
					import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -19,6 +21,7 @@ import { takeUntil } from 'rxjs/operators'; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  imports: [ | 
					 | 
					 | 
					  imports: [ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    CommonModule, | 
					 | 
					 | 
					    CommonModule, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    FormsModule, | 
					 | 
					 | 
					    FormsModule, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    ReactiveFormsModule, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    GfFireCalculatorComponent, | 
					 | 
					 | 
					    GfFireCalculatorComponent, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    GfPremiumIndicatorComponent, | 
					 | 
					 | 
					    GfPremiumIndicatorComponent, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    GfValueComponent, | 
					 | 
					 | 
					    GfValueComponent, | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -40,6 +43,8 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public withdrawalRatePerMonth: Big; | 
					 | 
					 | 
					  public withdrawalRatePerMonth: Big; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public withdrawalRatePerYear: Big; | 
					 | 
					 | 
					  public withdrawalRatePerYear: Big; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					  public safeWithdrawalRateControl: FormControl; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  private unsubscribeSubject = new Subject<void>(); | 
					 | 
					 | 
					  private unsubscribeSubject = new Subject<void>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public constructor( | 
					 | 
					 | 
					  public constructor( | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -54,6 +59,8 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.isLoading = true; | 
					 | 
					 | 
					    this.isLoading = true; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.deviceType = this.deviceService.getDeviceInfo().deviceType; | 
					 | 
					 | 
					    this.deviceType = this.deviceService.getDeviceInfo().deviceType; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    this.safeWithdrawalRateControl = new FormControl(0.025); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.dataService | 
					 | 
					 | 
					    this.dataService | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      .fetchPortfolioDetails() | 
					 | 
					 | 
					      .fetchPortfolioDetails() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      .pipe(takeUntil(this.unsubscribeSubject)) | 
					 | 
					 | 
					      .pipe(takeUntil(this.unsubscribeSubject)) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -66,7 +73,7 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          this.fireWealth = new Big(10000); | 
					 | 
					 | 
					          this.fireWealth = new Big(10000); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        this._calculateWithdrawalRates(); | 
					 | 
					 | 
					        this.calculateWithdrawalRates(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        this.isLoading = false; | 
					 | 
					 | 
					        this.isLoading = false; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -86,6 +93,14 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (state?.user) { | 
					 | 
					 | 
					        if (state?.user) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          this.user = state.user; | 
					 | 
					 | 
					          this.user = state.user; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          const newSWR = this.user?.settings?.safeWithdrawalRate ?? 0.025; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          if (this.safeWithdrawalRateControl.value !== newSWR) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            this.safeWithdrawalRateControl.setValue(newSWR, { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					              emitEvent: false | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					          } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          this.hasPermissionToUpdateUserSettings = | 
					 | 
					 | 
					          this.hasPermissionToUpdateUserSettings = | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            this.user.subscription?.type === 'Basic' | 
					 | 
					 | 
					            this.user.subscription?.type === 'Basic' | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					              ? false | 
					 | 
					 | 
					              ? false | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -94,10 +109,16 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                  permissions.updateUserSettings | 
					 | 
					 | 
					                  permissions.updateUserSettings | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                ); | 
					 | 
					 | 
					                ); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					          this._calculateWithdrawalRates(); | 
					 | 
					 | 
					          this.calculateWithdrawalRates(); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          this.changeDetectorRef.markForCheck(); | 
					 | 
					 | 
					          this.changeDetectorRef.markForCheck(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      }); | 
					 | 
					 | 
					      }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    this.safeWithdrawalRateControl.valueChanges.subscribe((value: number) => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      console.log('New SWR selected:', value); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					      this.onSafeWithdrawalRateChange(Number(value)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public onAnnualInterestRateChange(annualInterestRate: number) { | 
					 | 
					 | 
					  public onAnnualInterestRateChange(annualInterestRate: number) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -137,7 +158,7 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public onSafeWithdrawalRateChange(safeWithdrawalRate: number) { | 
					 | 
					 | 
					  public onSafeWithdrawalRateChange(safeWithdrawalRate: number) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.dataService | 
					 | 
					 | 
					    this.dataService | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					      .putUserSetting({ safeWithdrawalRate }) // No need for Number() conversion
 | 
					 | 
					 | 
					      .putUserSetting({ safeWithdrawalRate }) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					      .pipe(takeUntil(this.unsubscribeSubject)) | 
					 | 
					 | 
					      .pipe(takeUntil(this.unsubscribeSubject)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      .subscribe(() => { | 
					 | 
					 | 
					      .subscribe(() => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        this.userService | 
					 | 
					 | 
					        this.userService | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -145,11 +166,14 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          .pipe(takeUntil(this.unsubscribeSubject)) | 
					 | 
					 | 
					          .pipe(takeUntil(this.unsubscribeSubject)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          .subscribe((user) => { | 
					 | 
					 | 
					          .subscribe((user) => { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            this.user = user; | 
					 | 
					 | 
					            this.user = user; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            this._calculateWithdrawalRates(); | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            this.calculateWithdrawalRates(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            this.changeDetectorRef.markForCheck(); | 
					 | 
					 | 
					            this.changeDetectorRef.markForCheck(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					          }); | 
					 | 
					 | 
					          }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      }); | 
					 | 
					 | 
					      }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  public onSavingsRateChange(savingsRate: number) { | 
					 | 
					 | 
					  public onSavingsRateChange(savingsRate: number) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.dataService | 
					 | 
					 | 
					    this.dataService | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      .putUserSetting({ savingsRate }) | 
					 | 
					 | 
					      .putUserSetting({ savingsRate }) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -190,7 +214,7 @@ export class GfFirePageComponent implements OnDestroy, OnInit { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    this.unsubscribeSubject.complete(); | 
					 | 
					 | 
					    this.unsubscribeSubject.complete(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					  } | 
					 | 
					 | 
					  } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					  private _calculateWithdrawalRates() { | 
					 | 
					 | 
					  private calculateWithdrawalRates() { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    if (this.fireWealth && this.user?.settings?.safeWithdrawalRate) { | 
					 | 
					 | 
					    if (this.fireWealth && this.user?.settings?.safeWithdrawalRate) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					      this.withdrawalRatePerYear = this.fireWealth.mul( | 
					 | 
					 | 
					      this.withdrawalRatePerYear = this.fireWealth.mul( | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        this.user.settings.safeWithdrawalRate | 
					 | 
					 | 
					        this.user.settings.safeWithdrawalRate | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |