import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import classNames from "classnames";
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
import { selectIsApplyFiltersAllAtOnceEnabledAndSet } from "../../../model/store/config/configSelectors.js";
import { selectIsInEditMode } from "../../../model/store/renderMode/renderModeSelectors.js";
import { selectCanAddMoreFilters } from "../../../model/store/tabs/filterContext/filterContextSelectors.js";
import { DraggableFilterDropZoneHint } from "../draggableFilterDropZone/DraggableFilterDropZoneHint.js";
import { useDashboardDrag } from "../useDashboardDrag.js";
export function DraggableDateFilter({ FilterComponent, filter, workingFilter, filterIndex, autoOpen, readonly, onDateFilterChanged, onDateFilterAdded, config, }) {
    const isInEditMode = useDashboardSelector(selectIsInEditMode);
    const [{ isDragging }, dragRef] = useDashboardDrag({
        dragItem: {
            type: "dateFilter",
            filter,
            filterIndex,
        },
        canDrag: isInEditMode,
    }, [filter, filterIndex, isInEditMode]);
    const canAddMoreDateFilters = useDashboardSelector(selectCanAddMoreFilters);
    const showDropZones = isInEditMode && !isDragging;
    const isApplyAllAtOnceEnabledAndSet = useDashboardSelector(selectIsApplyFiltersAllAtOnceEnabledAndSet);
    return (_jsxs("div", { className: "draggable-attribute-filter", children: [showDropZones ? (_jsx(DraggableFilterDropZoneHint, { hintPosition: "prev", targetIndex: filterIndex, onAddAttributePlaceholder: onDateFilterAdded, acceptPlaceholder: canAddMoreDateFilters })) : null, _jsx("div", { className: classNames("dash-filters-date", "dash-filters-nodate", {
                    "dash-filter-is-edit-mode": isInEditMode,
                    "is-dragging": isDragging,
                }), ref: dragRef, children: _jsx(FilterComponent, { filter: filter, workingFilter: isApplyAllAtOnceEnabledAndSet ? workingFilter : undefined, config: config, onFilterChanged: onDateFilterChanged, isDraggable: isInEditMode, readonly: readonly, autoOpen: autoOpen }) }), showDropZones ? (_jsx(DraggableFilterDropZoneHint, { hintPosition: "next", targetIndex: filterIndex, onAddAttributePlaceholder: onDateFilterAdded, acceptPlaceholder: canAddMoreDateFilters })) : null] }));
}
