import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
import { getBoolFromConfigValue } from "@applicaster/zapp-react-native-utils/configurationUtils";

class DebugFeatures {
  debugToolsNamespace = "debug_tools";

  private static instance: DebugFeatures;
  public static getInstance() {
    if (!DebugFeatures.instance) {
      DebugFeatures.instance = new DebugFeatures();
    }

    return DebugFeatures.instance;
  }

  public isFeatureFlagEnabled = async (featureId: string): Promise<boolean> => {
    const result = await localStorage.getItem(
      featureId,
      this.debugToolsNamespace
    );

    return result && getBoolFromConfigValue(result);
  };
}

export default DebugFeatures;
