"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useModularDrawerVisibility = void 0;
const react_1 = require("react");
const featureFlags_1 = require("../featureFlags");
const enums_1 = require("./enums");
function useModularDrawerVisibility({ modularDrawerFeatureFlagKey, }) {
    const featureModularDrawer = (0, featureFlags_1.useFeature)(modularDrawerFeatureFlagKey);
    const isModularDrawerVisible = (0, react_1.useCallback)((params) => {
        if (!featureModularDrawer?.enabled)
            return false;
        if (params.location === enums_1.ModularDrawerLocation.LIVE_APP) {
            const isLiveAppEnabled = featureModularDrawer.params?.[params.location] ?? false;
            if (!isLiveAppEnabled)
                return false;
            const { liveAppId } = params;
            const allowed = featureModularDrawer.params?.live_apps_allowlist ?? [];
            const blocked = featureModularDrawer.params?.live_apps_blocklist ?? [];
            if (allowed.length > 0 && !allowed.includes(liveAppId)) {
                return false;
            }
            if (blocked.includes(liveAppId)) {
                return false;
            }
            return true;
        }
        return featureModularDrawer.params?.[params.location] ?? false;
    }, [featureModularDrawer]);
    return {
        isModularDrawerVisible,
    };
}
exports.useModularDrawerVisibility = useModularDrawerVisibility;
//# sourceMappingURL=useModularDrawerVisibility.js.map