import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class SearchStateService {
  private searchTermsMap = new Map<string, string>();

  setLastSearchTerms(tableId: string, terms: string): void {
    this.searchTermsMap.set(tableId, terms);
  }

  getLastSearchTerms(tableId: string): string {
    return this.searchTermsMap.get(tableId) || '';
  }

  clearLastSearchTerms(tableId: string): void {
    this.searchTermsMap.delete(tableId);
  }

  hasLastSearchTerms(tableId: string): boolean {
    return this.searchTermsMap.has(tableId) && 
           this.searchTermsMap.get(tableId)!.trim().length > 0;
  }
} 