import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2022-2026 GoodData Corporation
import cx from "classnames";
import { insightCreated, insightIsLocked, insightSummary, insightTitle, insightUpdated, insightVisualizationType, } from "@gooddata/sdk-model";
import { InsightListItem } from "@gooddata/sdk-ui-kit";
import { useDashboardSelector } from "../../../../model/react/DashboardStoreProvider.js";
import { useDashboardUserInteraction } from "../../../../model/react/useDashboardUserInteraction.js";
import { selectEnableRichTextDescriptions, selectEnableRichTextDynamicReferences, selectSettings, } from "../../../../model/store/config/configSelectors.js";
import { useDashboardComponentsContext } from "../../../dashboardContexts/DashboardComponentsContext.js";
import { InsightList } from "../../../insightList/InsightList.js";
import { DraggableInsightListItemWrapper } from "./DraggableInsightListItemWrapper.js";
export function DraggableInsightListCore({ enableDescriptions, WrapInsightListItemWithDragComponent, ...remainingProps }) {
    const userInteraction = useDashboardUserInteraction();
    const settings = useDashboardSelector(selectSettings);
    const useRichText = useDashboardSelector(selectEnableRichTextDescriptions);
    const useReferences = useDashboardSelector(selectEnableRichTextDynamicReferences);
    const { LoadingComponent } = useDashboardComponentsContext();
    return (_jsx(InsightList, { ...remainingProps, renderItem: ({ item: insight, width, isFirst, isLast }) => {
            if (!insight) {
                return _jsx(InsightListItem, { isLoading: true });
            }
            const visualizationType = insightVisualizationType(insight);
            const classNames = cx("gd-visualizations-list-item-wrap", {
                "is-first": isFirst,
                "is-last": isLast,
            });
            const description = insightSummary(insight)?.trim();
            const eventPayload = {
                from: "insight",
                type: "inherit",
                description,
            };
            return (_jsx(DraggableInsightListItemWrapper, { WrapInsightListItemWithDragComponent: WrapInsightListItemWithDragComponent, title: insightTitle(insight), description: description, showDescriptionPanel: enableDescriptions, type: visualizationType, width: width, className: classNames, updated: insightUpdated(insight) ?? insightCreated(insight), isLocked: insightIsLocked(insight), insight: insight, onDescriptionPanelOpen: () => {
                    userInteraction.descriptionTooltipOpened(eventPayload);
                }, metadataTimeZone: settings?.metadataTimeZone, useRichText: useRichText, useReferences: useReferences, LoadingComponent: LoadingComponent }));
        } }));
}
//# sourceMappingURL=DraggableInsightListCore.js.map