import {
  SCOPE_CONFIG,
  API_CONFIG
} from "@nextsparkjs/registries/scope-registry";
class ScopeService {
  /**
   * Get base scopes for authentication
   *
   * @returns Array of base scope strings
   *
   * @example
   * ```typescript
   * const scopes = ScopeService.getBaseScopes()
   * // ['tasks:read', 'tasks:write', ...]
   * ```
   */
  static getBaseScopes() {
    return [...SCOPE_CONFIG.base];
  }
  /**
   * Get scopes for a specific role
   *
   * @param role - Role name (e.g., 'admin', 'member')
   * @returns Array of scope strings for the role
   *
   * @example
   * ```typescript
   * const scopes = ScopeService.getRoleScopes('admin')
   * // ['admin:users', 'tasks:delete', ...]
   * ```
   */
  static getRoleScopes(role) {
    return SCOPE_CONFIG.roles[role] ? [...SCOPE_CONFIG.roles[role]] : [];
  }
  /**
   * Get scopes for a specific flag
   *
   * @param flag - Flag name (e.g., 'beta_tester', 'vip')
   * @returns Array of scope strings for the flag
   *
   * @example
   * ```typescript
   * const scopes = ScopeService.getFlagScopes('vip')
   * // ['vip:features', 'advanced:export']
   * ```
   */
  static getFlagScopes(flag) {
    return SCOPE_CONFIG.flags[flag] ? [...SCOPE_CONFIG.flags[flag]] : [];
  }
  /**
   * Get allowed API filters
   *
   * @returns Array of allowed filter names
   *
   * @example
   * ```typescript
   * const filters = ScopeService.getAllowedFilters()
   * // ['status', 'role', 'completed', 'userId']
   * ```
   */
  static getAllowedFilters() {
    return [...API_CONFIG.filters.allowed];
  }
  /**
   * Get restriction rules for a flag
   *
   * @param flag - Flag name (e.g., 'restricted', 'limited_access')
   * @returns Restriction rules object or empty object
   *
   * @example
   * ```typescript
   * const rules = ScopeService.getRestrictionRules('restricted')
   * // { remove: ['delete', 'admin'] }
   * ```
   */
  static getRestrictionRules(flag) {
    return SCOPE_CONFIG.restrictions[flag] || {};
  }
  /**
   * Get entity API paths for route optimization
   *
   * @returns Array of entity API paths
   *
   * @example
   * ```typescript
   * const paths = ScopeService.getEntityApiPaths()
   * // ['/api/v1/tasks', '/api/v1/products', ...]
   * ```
   */
  static getEntityApiPaths() {
    return [...API_CONFIG.entityPaths];
  }
  // === Additional Helper Methods ===
  /**
   * Get all available roles
   *
   * @returns Array of role names
   *
   * @example
   * ```typescript
   * const roles = ScopeService.getRoles()
   * // ['superadmin', 'admin', 'manager', 'member']
   * ```
   */
  static getRoles() {
    return Object.keys(SCOPE_CONFIG.roles);
  }
  /**
   * Get all available flags
   *
   * @returns Array of flag names
   *
   * @example
   * ```typescript
   * const flags = ScopeService.getFlags()
   * // ['beta_tester', 'vip', 'early_adopter', 'power_user']
   * ```
   */
  static getFlags() {
    return Object.keys(SCOPE_CONFIG.flags);
  }
  /**
   * Check if a role exists
   *
   * @param role - Role name to check
   * @returns True if role exists
   *
   * @example
   * ```typescript
   * ScopeService.hasRole('admin') // true
   * ScopeService.hasRole('invalid') // false
   * ```
   */
  static hasRole(role) {
    return role in SCOPE_CONFIG.roles;
  }
  /**
   * Check if a flag exists
   *
   * @param flag - Flag name to check
   * @returns True if flag exists
   *
   * @example
   * ```typescript
   * ScopeService.hasFlag('vip') // true
   * ScopeService.hasFlag('invalid') // false
   * ```
   */
  static hasFlag(flag) {
    return flag in SCOPE_CONFIG.flags;
  }
  /**
   * Get the full scope configuration
   *
   * @returns The complete SCOPE_CONFIG object
   *
   * @example
   * ```typescript
   * const config = ScopeService.getScopeConfig()
   * // { base: [...], roles: {...}, flags: {...}, restrictions: {...} }
   * ```
   */
  static getScopeConfig() {
    return SCOPE_CONFIG;
  }
  /**
   * Get the full API configuration
   *
   * @returns The complete API_CONFIG object
   *
   * @example
   * ```typescript
   * const config = ScopeService.getApiConfig()
   * // { filters: { allowed: [...] }, entityPaths: [...] }
   * ```
   */
  static getApiConfig() {
    return API_CONFIG;
  }
}
const getBaseScopes = ScopeService.getBaseScopes;
const getRoleScopes = ScopeService.getRoleScopes;
const getFlagScopes = ScopeService.getFlagScopes;
const getAllowedFilters = ScopeService.getAllowedFilters;
const getRestrictionRules = ScopeService.getRestrictionRules;
const getEntityApiPaths = ScopeService.getEntityApiPaths;
export {
  ScopeService,
  getAllowedFilters,
  getBaseScopes,
  getEntityApiPaths,
  getFlagScopes,
  getRestrictionRules,
  getRoleScopes
};
