"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const react_1 = require("react");
const DashboardContext_1 = require("../../../DashboardContext");
const DashboardSidebarProvider_1 = require("../../../DashboardSidebarProvider");
const useViewportType_1 = require("../../../useViewportType");
const useLogic = ({ profile, menuOrganization }) => {
    const { isFocusedMode, isLoading, hasMenuOrganizationRef, hasProfileRef, alertHeight, mobileHeaderPriorityFeature, } = (0, react_1.useContext)(DashboardContext_1.DashboardContext);
    const { collapsedIn, onToggleSidebar, isPinned } = (0, react_1.useContext)(DashboardSidebarProvider_1.DashboardSidebarContext);
    (0, react_1.useEffect)(() => {
        hasMenuOrganizationRef.current = Boolean(menuOrganization);
        hasProfileRef.current = Boolean(profile);
    }, [menuOrganization, profile]);
    const { isMobile } = (0, useViewportType_1.useViewportType)();
    const hasMenu = Boolean(profile?.menu || profile?.menuList);
    const isShowProfile = (Boolean(profile) && !isMobile) ||
        (hasMenu && isMobile && mobileHeaderPriorityFeature === 'profile');
    const isShowExitButton = isMobile &&
        !hasMenu &&
        Boolean(profile?.exitButton) &&
        mobileHeaderPriorityFeature === 'profile';
    const headerStyle = {
        '--alert-height': `${alertHeight}px`,
    };
    return {
        isShowExitButton,
        isShowProfile,
        isMobile,
        isFocusedMode,
        mobileHeaderPriorityFeature,
        isLoading,
        collapsedIn,
        onToggleSidebar,
        alertHeight,
        isPinned,
        headerStyle,
    };
};
exports.useLogic = useLogic;
