import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2019-2026 GoodData Corporation
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import cx from "classnames";
import { defineMessage, useIntl } from "react-intl";
import { ValidationContextStore, createInvalidNode, useValidationContextValue } from "@gooddata/sdk-ui";
import { Button, ConfirmDialogBase, ContentDivider, Hyperlink, Message, Overlay, OverlayController, OverlayControllerProvider, RecurrenceForm, ScrollablePanel, UiIcon, UiTabs, isEnterKey, useIdPrefixed, } from "@gooddata/sdk-ui-kit";
import { useDashboardSelector } from "../../../../model/react/DashboardStoreProvider.js";
import { useExportTemplates } from "../../../../model/react/useExportTemplates.js";
import { selectDateFormat, selectEnableAutomationManagement, selectEnableCustomizableCsvDelimiter, selectEnableNewScheduledExport, selectExternalRecipient, selectIsWhiteLabeled, selectLocale, selectSettings, selectWeekStart, } from "../../../../model/store/config/configSelectors.js";
import { selectIsCrossFiltering } from "../../../../model/store/drill/drillSelectors.js";
import { selectEntitlementMinimumRecurrenceMinutes, selectMaxAutomationRecipients, } from "../../../../model/store/entitlements/entitlementsSelectors.js";
import { selectDashboardTitle } from "../../../../model/store/meta/metaSelectors.js";
import { selectTabs } from "../../../../model/store/tabs/tabsSelectors.js";
import { selectIsAutomationDialogSecondaryTitleVisible } from "../../../../model/store/topBar/topBarSelectors.js";
import { selectExecutionTimestamp } from "../../../../model/store/ui/uiSelectors.js";
import { getWidgetTitle } from "../../../../model/utils/dashboardItemUtils.js";
import { DASHBOARD_DIALOG_OVERS_Z_INDEX } from "../../../constants/zIndex.js";
import { IntlWrapper } from "../../../localization/IntlWrapper.js";
import { useBuildAutomationsContext } from "../../connectors/hooks/useBuildAutomationsContext.js";
import { AutomationsContextProvider } from "../../contexts/AutomationsContext.js";
import { ApplyCurrentFiltersConfirmDialog } from "../../shared/automationFilters/components/ApplyLatestFiltersConfirmDialog.js";
import { AutomationFiltersSelect } from "../../shared/automationFilters/components/AutomationFiltersSelect.js";
import { useValidateExistingAutomationFilters } from "../../shared/automationFilters/hooks/useValidateExistingAutomationFilters.js";
import { useAutomationExportParameters } from "../../shared/automationFilters/useAutomationExportParameters.js";
import { useAutomationFiltersSelect } from "../../shared/automationFilters/useAutomationFiltersSelect.js";
import { DeleteScheduleConfirmDialog } from "../DefaultScheduledEmailManagementDialog/components/DeleteScheduleConfirmDialog.js";
import { useScheduleEmailDialogAccessibility } from "../hooks/useScheduleEmailDialogAccessibility.js";
import { getDefaultCronExpression } from "../utils/cron.js";
import { getDefaultPdfPageSize } from "../utils/pdfPageSize.js";
import { isMobileView } from "../utils/responsive.js";
import { TIMEZONE_DEFAULT } from "../utils/timezone.js";
import { DashboardAttachments } from "./components/Attachments/DashboardAttachments.js";
import { WidgetAttachments } from "./components/Attachments/WidgetAttachments.js";
import { DestinationSelect } from "./components/DestinationSelect/DestinationSelect.js";
import { EvaluationModeCheckbox } from "./components/EvaluationModeCheckbox/EvaluationModeCheckbox.js";
import { ScheduledEmailDialogHeader } from "./components/Header/ScheduleEmailDialogHeader.js";
import { MessageForm } from "./components/MessageForm/MessageForm.js";
import { RecipientsSelect } from "./components/RecipientsSelect/RecipientsSelect.js";
import { SubjectForm } from "./components/SubjectForm/SubjectForm.js";
import { SCHEDULED_EMAIL_DIALOG_ID } from "./constants.js";
import { DefaultLoadingScheduledEmailDialog } from "./DefaultLoadingScheduledEmailDialog.js";
import { useEditScheduledEmail } from "./hooks/useEditScheduledEmail.js";
import { useSaveScheduledEmailToBackend } from "./hooks/useSaveScheduledEmailToBackend.js";
const DEFAULT_MIN_RECURRENCE_MINUTES = "60";
const OVERLAY_POSITION_TYPE = "sameAsTarget";
const CLOSE_ON_PARENT_SCROLL = true;
const overlayController = OverlayController.getInstance(DASHBOARD_DIALOG_OVERS_Z_INDEX);
function ScheduledEmailDialogFooter({ isWhiteLabeled, helpTextId, scheduledExportToEdit, isSavingScheduledEmail, onDeleteClick, }) {
    const intl = useIntl();
    return (_jsxs("div", { className: "gd-notifications-channels-dialog-footer-link", children: [isWhiteLabeled ? null : (_jsx(Hyperlink, { text: intl.formatMessage({ id: helpTextId }), href: "https://www.gooddata.com/docs/cloud/create-dashboards/automation/scheduled-exports/#ScheduleExportsinDashboards-ScheduleExport", iconClass: "gd-icon-circle-question" })), scheduledExportToEdit ? (_jsx(Button, { className: "gd-button-link-dimmed", value: intl.formatMessage({ id: "delete" }), onClick: onDeleteClick, disabled: isSavingScheduledEmail })) : null] }));
}
export function ScheduledMailDialogRenderer({ scheduledExportToEdit, users, usersError, notificationChannels, insight, widget, dashboardFilters, widgetFilters, onBack, onCancel, onDeleteSuccess, onDeleteError, onError, onSave, onSaveError, onSaveSuccess, onSubmit, onSuccess, }) {
    const intl = useIntl();
    const dialogTitleRef = useRef(null);
    const generalTabContentRef = useRef(null);
    const filtersTabContentRef = useRef(null);
    const [scheduledEmailToDelete, setScheduledEmailToDelete] = useState(null);
    const [selectedTabId, setSelectedTabId] = useState("general");
    const [tabContentHeight, setTabContentHeight] = useState(undefined);
    const isWhiteLabeled = useDashboardSelector(selectIsWhiteLabeled);
    const externalRecipientOverride = useDashboardSelector(selectExternalRecipient);
    const isSecondaryTitleVisible = useDashboardSelector(selectIsAutomationDialogSecondaryTitleVisible);
    const enableAutomationManagement = useDashboardSelector(selectEnableAutomationManagement);
    const dashboardTabs = useDashboardSelector(selectTabs);
    const hasMultipleTabs = (dashboardTabs?.length ?? 0) > 1;
    const exportTemplates = useExportTemplates();
    const handleScheduleDeleteSuccess = () => {
        onDeleteSuccess?.();
        setScheduledEmailToDelete(null);
    };
    const { editedAutomationFilters, setEditedAutomationFilters, storeFilters, setStoreFilters, availableFilters, availableFiltersAsVisibleFilters, filtersForNewAutomation, 
    // filter by tab data
    filtersByTab, editedAutomationFiltersByTab, setEditedAutomationFiltersByTab, availableFiltersAsVisibleFiltersByTab, } = useAutomationFiltersSelect({
        automationToEdit: scheduledExportToEdit,
        widget,
    });
    const { locale, dashboardTitle, dateFormat, weekStart, maxAutomationsRecipients, allowHourlyRecurrence, isCrossFiltering, isExecutionTimestampMode, enableNewScheduledExport, enableCustomizableCsvDelimiter, defaultPdfPageSize, } = useDefaultScheduledEmailDialogData();
    const { defaultUser, editedAutomation, originalAutomation, isSubmitDisabled, xlsxSettings, pdfSettings, csvSettings, csvRawSettings, startDate, allowExternalRecipients, allowOnlyLoggedUserRecipients, validationErrorMessage, selectedAttachments, isParentValid, onDashboardAttachmentsChange, onWidgetAttachmentsChange, onXlsxSettingsChange, onPdfSettingsChange, onCsvSettingsChange, onCsvRawSettingsChange, slidesTemplateIds, onSlidesTemplateIdChange, onDestinationChange, onMessageChange, onRecipientsChange, onRecurrenceChange, onEvaluationModeChange, onSubjectChange, onTitleChange, onFiltersChange, onApplyCurrentFilters, onStoreFiltersChange, onFiltersByTabChange, setParametersWire, enableAutomationEvaluationMode, } = useEditScheduledEmail({
        notificationChannels,
        insight,
        widget,
        scheduledExportToEdit,
        storeFilters,
        editedAutomationFilters,
        dashboardFilters,
        widgetFilters,
        maxAutomationsRecipients,
        setEditedAutomationFilters,
        setStoreFilters,
        availableFiltersAsVisibleFilters,
        filtersForNewAutomation,
        externalRecipientOverride,
        enableNewScheduledExport,
        filtersDataByTab: filtersByTab,
        editedAutomationFiltersByTab,
        setEditedAutomationFiltersByTab,
        availableFiltersAsVisibleFiltersByTab,
    });
    const { parametersEnabled, visibleParametersByTab, availableParametersByTab, flatTabId, onParameterAdd, onParameterChange, onParameterDelete, onParameterAddByTab, onParameterChangeByTab, onParameterDeleteByTab, applyLatest: applyLatestParameters, onStoreParametersChange, } = useAutomationExportParameters({
        automationToEdit: scheduledExportToEdit,
        widget,
        storeParameters: storeFilters,
        setParametersWire,
    });
    // The store-filters checkbox gates parameter persistence too; the new value is passed to both
    // sides because the `storeFilters` prop still holds the old one at call time.
    const handleStoreFiltersChange = useCallback((value, filters, filtersByTabParam) => {
        onStoreFiltersChange(value, filters, filtersByTabParam);
        onStoreParametersChange(value);
    }, [onStoreFiltersChange, onStoreParametersChange]);
    const { isValid } = useValidateExistingAutomationFilters({
        automationToEdit: scheduledExportToEdit,
        widget,
        insight,
    });
    const [isApplyCurrentFiltersDialogOpen, setIsApplyCurrentFiltersDialogOpen] = useState(!isValid);
    const { handleSaveScheduledEmail, isSavingScheduledEmail, savingErrorMessage } = useSaveScheduledEmailToBackend(editedAutomation, {
        onSuccess,
        onError,
        onSubmit,
        onSaveSuccess,
        onSaveError,
        onSave,
    });
    const { returnFocusTo } = useScheduleEmailDialogAccessibility();
    const missingAttachmentsErrorMessage = selectedAttachments.length === 0 &&
        intl.formatMessage({ id: "scheduledEmail.attachments.error.noAttachmentsSelected" });
    const validationContextValue = useValidationContextValue(createInvalidNode({ id: "ScheduledEmailDialog" }));
    const { getInvalidDatapoints } = validationContextValue;
    const errorMessage = savingErrorMessage ?? validationErrorMessage ?? missingAttachmentsErrorMessage;
    const helpTextId = isMobileView()
        ? defineMessage({ id: "dialogs.schedule.email.footer.title.short" }).id
        : defineMessage({ id: "dialogs.schedule.email.footer.title" }).id;
    const titleElementId = useIdPrefixed("title");
    const submitDisabled = isSubmitDisabled || isSavingScheduledEmail || isExecutionTimestampMode;
    const handleSubmitForm = useCallback((e) => {
        if (isEnterKey(e) && !submitDisabled) {
            handleSaveScheduledEmail();
        }
    }, [submitDisabled, handleSaveScheduledEmail]);
    const { secondaryTitle, secondaryTitleIcon } = useMemo(() => {
        if (widget) {
            return {
                secondaryTitle: getWidgetTitle(widget),
                secondaryTitleIcon: (_jsx(UiIcon, { type: "visualization", size: 16, color: "complementary-6", accessibilityConfig: {
                        ariaLabel: intl.formatMessage({
                            id: "dialogs.automation.icon.ariaLabel.sourceVisualization",
                        }),
                    } })),
            };
        }
        return {
            secondaryTitle: dashboardTitle,
            secondaryTitleIcon: (_jsx(UiIcon, { type: "dashboard", size: 16, color: "complementary-6", accessibilityConfig: {
                    ariaLabel: intl.formatMessage({
                        id: "dialogs.automation.icon.ariaLabel.sourceDashboard",
                    }),
                } })),
        };
    }, [widget, dashboardTitle, intl]);
    const tabs = useMemo(() => [
        {
            id: "general",
            label: intl.formatMessage({ id: "dialogs.schedule.email.tabs.general" }),
        },
        {
            id: "filters",
            label: intl.formatMessage({ id: "dialogs.schedule.email.tabs.filters" }),
        },
    ], [intl]);
    const handleTabSelect = useCallback((tab) => {
        setSelectedTabId(tab.id);
    }, []);
    // Measure General tab content height to maintain consistent dialog size
    useEffect(() => {
        if (generalTabContentRef.current && selectedTabId === "general") {
            // Use requestAnimationFrame to ensure DOM is fully rendered
            requestAnimationFrame(() => {
                if (generalTabContentRef.current) {
                    const height = generalTabContentRef.current.scrollHeight;
                    setTabContentHeight(height);
                }
            });
        }
    }, [selectedTabId]);
    if (isApplyCurrentFiltersDialogOpen) {
        return (_jsx(ApplyCurrentFiltersConfirmDialog, { automationType: "schedule", onCancel: () => onCancel?.(), onEdit: () => {
                onApplyCurrentFilters();
                applyLatestParameters();
                setIsApplyCurrentFiltersDialogOpen(false);
            } }));
    }
    const selectedChannel = notificationChannels.find((channel) => channel.id === editedAutomation.notificationChannel);
    const isInPlatformChannel = selectedChannel?.destinationType === "inPlatform";
    return (_jsxs(_Fragment, { children: [
            _jsx(Overlay, { className: "gd-notifications-channels-dialog-overlay", isModal: true, positionType: "fixed", ensureVisibility: true, children: _jsx(OverlayControllerProvider, { overlayController: overlayController, children: _jsx(ValidationContextStore, { value: validationContextValue, children: _jsxs(ConfirmDialogBase, { className: cx("gd-notifications-channels-dialog s-gd-notifications-channels-dialog", {
                                "gd-dialog--wide gd-notifications-channels-dialog--wide": enableAutomationManagement,
                            }), isPositive: true, cancelButtonText: intl.formatMessage({ id: "cancel" }), submitButtonText: scheduledExportToEdit
                                ? intl.formatMessage({ id: `dialogs.schedule.email.save` })
                                : intl.formatMessage({ id: `dialogs.schedule.email.create` }), accessibilityConfig: {
                                closeButton: {
                                    ariaLabel: intl.formatMessage({
                                        id: "dialogs.schedule.email.closeLabel",
                                    }),
                                },
                                titleElementId,
                                dialogId: SCHEDULED_EMAIL_DIALOG_ID,
                            }, showProgressIndicator: isSavingScheduledEmail, returnFocusTo: returnFocusTo, returnFocusAfterClose: !enableAutomationManagement, footerLeftRenderer: () => (_jsx(ScheduledEmailDialogFooter, { isWhiteLabeled: isWhiteLabeled, helpTextId: helpTextId, scheduledExportToEdit: scheduledExportToEdit, isSavingScheduledEmail: isSavingScheduledEmail, onDeleteClick: () => setScheduledEmailToDelete(editedAutomation) })), isSubmitDisabled: submitDisabled, submitButtonTooltipText: isExecutionTimestampMode
                                ? intl.formatMessage({
                                    id: "dialogs.schedule.email.save.executionTimestampMode",
                                })
                                : undefined, initialFocus: dialogTitleRef, submitOnEnterKey: false, onCancel: onCancel, onSubmit: handleSaveScheduledEmail, headline: undefined, headerLeftButtonRenderer: () => (_jsx(ScheduledEmailDialogHeader, { title: editedAutomation.title ?? "", onChange: onTitleChange, onBack: onBack, placeholder: intl.formatMessage({
                                    id: "dialogs.schedule.email.title.placeholder",
                                }), ref: dialogTitleRef, onKeyDownSubmit: handleSubmitForm, secondaryTitle: secondaryTitle, secondaryTitleIcon: secondaryTitleIcon, isSecondaryTitleVisible: isSecondaryTitleVisible ? isParentValid : undefined })), children: [
                                _jsx("h2", { className: "sr-only", id: titleElementId, children: intl.formatMessage({ id: "dialogs.schedule.email.accessibilityTitle" }) }), tabs.length > 1 ? (_jsx(UiTabs, { tabs: tabs, selectedTabId: selectedTabId, onTabSelect: handleTabSelect, size: "medium", accessibilityConfig: {
                                        role: "tablist",
                                        tabRole: "tab",
                                        ariaLabel: intl.formatMessage({
                                            id: "dialogs.schedule.email.accessibilityTitle",
                                        }),
                                    }, disableBottomBorder: true })) : null, _jsxs(ScrollablePanel, { className: cx("gd-notifications-channel-dialog-content-wrapper", {
                                        "gd-notification-channel-dialog-with-automation-filters": true,
                                        "gd-notification-channel-dialog-with-tabs": tabs.length > 1,
                                    }), children: [
                                        _jsx("div", { className: "gd-divider-with-margin" }), selectedTabId === "filters" ? (_jsx("div", { ref: filtersTabContentRef, className: "gd-schedule-dialog-tab-content", style: tabContentHeight
                                                ? { minHeight: `${tabContentHeight}px` }
                                                : undefined, children: _jsx(AutomationFiltersSelect, { availableFilters: availableFilters, selectedFilters: editedAutomationFilters, onFiltersChange: onFiltersChange, storeFilters: storeFilters, onStoreFiltersChange: handleStoreFiltersChange, isDashboardAutomation: !widget, overlayPositionType: OVERLAY_POSITION_TYPE, hideTitle: true, showAllFilters: true, filtersByTab: filtersByTab, editedFiltersByTab: editedAutomationFiltersByTab, onFiltersByTabChange: onFiltersByTabChange, parameters: flatTabId ? visibleParametersByTab[flatTabId] : undefined, availableParameters: flatTabId ? availableParametersByTab[flatTabId] : undefined, onParameterChange: onParameterChange, onParameterDelete: onParameterDelete, onParameterAdd: onParameterAdd, parametersByTab: visibleParametersByTab, availableParametersByTab: availableParametersByTab, onParameterChangeByTab: onParameterChangeByTab, onParameterDeleteByTab: onParameterDeleteByTab, onParameterAddByTab: onParameterAddByTab, parametersEnabled: parametersEnabled }) })) : (_jsxs("div", { ref: generalTabContentRef, className: "gd-schedule-dialog-tab-content", children: [!widget && hasMultipleTabs ? (_jsx(Message, { type: "progress", className: "gd-schedule-dialog-tab-content-info", children: intl.formatMessage({
                                                        id: "dialogs.schedule.email.tabs.info",
                                                    }) })) : null, _jsx(RecurrenceForm, { startDate: startDate, cronExpression: editedAutomation.schedule?.cron ??
                                                        getDefaultCronExpression(startDate), cronDescription: editedAutomation.schedule?.cronDescription, timezone: editedAutomation.schedule?.timezone ??
                                                        TIMEZONE_DEFAULT.identifier, dateFormat: dateFormat ?? "MM/dd/yyyy", locale: locale, weekStart: weekStart, onChange: onRecurrenceChange, allowHourlyRecurrence: allowHourlyRecurrence, isWhiteLabeled: isWhiteLabeled, closeDropdownsOnParentScroll: CLOSE_ON_PARENT_SCROLL, onKeyDownSubmit: handleSubmitForm }), _jsx(ContentDivider, { className: "gd-divider-with-margin" }), _jsx(DestinationSelect, { notificationChannels: notificationChannels, selectedItemId: editedAutomation.notificationChannel, onChange: onDestinationChange, closeOnParentScroll: CLOSE_ON_PARENT_SCROLL, overlayPositionType: OVERLAY_POSITION_TYPE }), _jsx(ContentDivider, { className: "gd-divider-with-margin" }), _jsx(RecipientsSelect, { id: "schedule.email.recipients", loggedUser: defaultUser, users: users, usersError: usersError, value: editedAutomation.recipients ?? [], originalValue: originalAutomation.recipients || [], onChange: onRecipientsChange, allowEmptySelection: true, allowOnlyLoggedUserRecipients: allowOnlyLoggedUserRecipients, allowExternalRecipients: allowExternalRecipients, maxRecipients: maxAutomationsRecipients, notificationChannels: notificationChannels, notificationChannelId: editedAutomation.notificationChannel, onKeyDownSubmit: handleSubmitForm, externalRecipientOverride: externalRecipientOverride }), isInPlatformChannel ? null : (_jsxs(_Fragment, { children: [
                                                        _jsx(SubjectForm, { dashboardTitle: dashboardTitle, editedAutomation: editedAutomation, onChange: onSubjectChange, onKeyDownSubmit: handleSaveScheduledEmail, isSubmitDisabled: isSubmitDisabled }), _jsx(MessageForm, { onChange: onMessageChange, value: editedAutomation.details?.message ?? "" })
                                                    ] })), widget ? (_jsx(WidgetAttachments, { selectedAttachments: selectedAttachments, onWidgetAttachmentsChange: onWidgetAttachmentsChange, xlsxSettings: xlsxSettings, pdfSettings: pdfSettings, onXlsxSettingsChange: onXlsxSettingsChange, onPdfSettingsChange: onPdfSettingsChange, csvSettings: csvSettings, onCsvSettingsChange: onCsvSettingsChange, csvRawSettings: csvRawSettings, onCsvRawSettingsChange: onCsvRawSettingsChange, isCsvSettingsEnabled: enableCustomizableCsvDelimiter, defaultPdfPageSize: defaultPdfPageSize, exportTemplates: exportTemplates, slidesTemplateIds: slidesTemplateIds, onSlidesTemplateIdChange: onSlidesTemplateIdChange })) : (_jsx(DashboardAttachments, { selectedAttachments: selectedAttachments, dashboardFilters: dashboardFilters, isCrossFiltering: isCrossFiltering, onDashboardAttachmentsChange: onDashboardAttachmentsChange, xlsxSettings: xlsxSettings, onXlsxSettingsChange: onXlsxSettingsChange, defaultPdfPageSize: defaultPdfPageSize, exportTemplates: exportTemplates, slidesTemplateIds: slidesTemplateIds, onSlidesTemplateIdChange: onSlidesTemplateIdChange })), enableAutomationEvaluationMode ? (_jsx(EvaluationModeCheckbox, { isShared: editedAutomation.evaluationMode === "SHARED", onChange: onEvaluationModeChange })) : null, errorMessage ? (_jsx(Message, { type: "error", className: cx("gd-notifications-channels-dialog-error", {
                                                        "gd-notifications-channels-dialog-error-scrollable": true,
                                                    }), children: errorMessage })) : null, getInvalidDatapoints()
                                                    .filter((invalidDatapoint) => invalidDatapoint.severity === "error")
                                                    .map((invalidDatapoint) => (_jsx(Message, { id: invalidDatapoint.id, type: "error", className: cx("gd-notifications-channels-dialog-error", {
                                                        "gd-notifications-channels-dialog-error-scrollable": true,
                                                    }), children: invalidDatapoint.message }, invalidDatapoint.id)))] }))] })
                            ] }) }) }) }), scheduledEmailToDelete ? (_jsx(DeleteScheduleConfirmDialog, { scheduledEmail: scheduledEmailToDelete, onCancel: () => setScheduledEmailToDelete(null), onSuccess: handleScheduleDeleteSuccess, onError: onDeleteError })) : null] }));
}
/**
 * @alpha
 */
export function DefaultScheduledEmailDialog(props) {
    const { isLoading, onCancel, scheduledExportToEdit } = props;
    if (isLoading) {
        return (_jsx(DefaultLoadingScheduledEmailDialog, { onCancel: onCancel, scheduledExportToEdit: scheduledExportToEdit }));
    }
    return _jsx(DefaultScheduledEmailDialogBody, { ...props });
}
function DefaultScheduledEmailDialogBody(props) {
    const locale = useDashboardSelector(selectLocale);
    const automationsContext = useBuildAutomationsContext();
    return (_jsx(AutomationsContextProvider, { value: automationsContext, children: _jsx(IntlWrapper, { locale: locale, children: _jsx(ScheduledMailDialogRenderer, { ...props }) }) }));
}
function useDefaultScheduledEmailDialogData() {
    const locale = useDashboardSelector(selectLocale);
    const dashboardTitle = useDashboardSelector(selectDashboardTitle);
    const dateFormat = useDashboardSelector(selectDateFormat);
    const settings = useDashboardSelector(selectSettings);
    const formatLocale = settings?.formatLocale;
    const weekStart = useDashboardSelector(selectWeekStart);
    const maxAutomationsRecipients = useDashboardSelector(selectMaxAutomationRecipients);
    const minimumRecurrenceMinutesEntitlement = useDashboardSelector(selectEntitlementMinimumRecurrenceMinutes);
    const allowHourlyRecurrence = parseInt(minimumRecurrenceMinutesEntitlement?.value ?? DEFAULT_MIN_RECURRENCE_MINUTES, 10) === 60;
    const isCrossFiltering = useDashboardSelector(selectIsCrossFiltering);
    const isExecutionTimestampMode = !!useDashboardSelector(selectExecutionTimestamp);
    const enableNewScheduledExport = useDashboardSelector(selectEnableNewScheduledExport);
    const enableCustomizableCsvDelimiter = useDashboardSelector(selectEnableCustomizableCsvDelimiter);
    const defaultPdfPageSize = getDefaultPdfPageSize(formatLocale);
    return {
        locale,
        dashboardTitle,
        dateFormat,
        weekStart,
        maxAutomationsRecipients,
        allowHourlyRecurrence,
        isCrossFiltering,
        isExecutionTimestampMode,
        enableNewScheduledExport,
        enableCustomizableCsvDelimiter,
        defaultPdfPageSize,
    };
}
