import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { DragOverlay } from '@dnd-kit/core';
import { getEventCoordinates } from '@dnd-kit/utilities';
import { FolderFileCard } from '../FolderFileCard/index.js';
import './index.scss';
const baseClass = 'drag-overlay-selection';
export function DragOverlaySelection({ item, selectedCount }) {
    return /*#__PURE__*/ _jsxDEV(DragOverlay, {
        dropAnimation: null,
        modifiers: [
            snapTopLeftToCursor
        ],
        style: {
            height: 'unset',
            maxWidth: '220px'
        },
        children: /*#__PURE__*/ _jsxDEV("div", {
            className: `${baseClass}__cards`,
            children: [
                Array.from({
                    length: selectedCount > 1 ? 2 : 1
                }).map((_, index)=>/*#__PURE__*/ _jsxDEV("div", {
                        className: `${baseClass}__card`,
                        style: {
                            right: `${index * 3}px`,
                            top: `-${index * 3}px`
                        },
                        children: /*#__PURE__*/ _jsxDEV(FolderFileCard, {
                            id: null,
                            isSelected: true,
                            itemKey: "overlay-card",
                            title: item.value._folderOrDocumentTitle,
                            type: "folder"
                        }, void 0, false, {
                            fileName: "src/elements/FolderView/DragOverlaySelection/index.tsx",
                            lineNumber: 36,
                            columnNumber: 13
                        }, this)
                    }, index, false, {
                        fileName: "src/elements/FolderView/DragOverlaySelection/index.tsx",
                        lineNumber: 28,
                        columnNumber: 11
                    }, this)),
                selectedCount > 1 ? /*#__PURE__*/ _jsxDEV("span", {
                    className: `${baseClass}__card-count`,
                    children: selectedCount
                }, void 0, false, {
                    fileName: "src/elements/FolderView/DragOverlaySelection/index.tsx",
                    lineNumber: 46,
                    columnNumber: 11
                }, this) : null
            ]
        }, void 0, true, {
            fileName: "src/elements/FolderView/DragOverlaySelection/index.tsx",
            lineNumber: 26,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/elements/FolderView/DragOverlaySelection/index.tsx",
        lineNumber: 18,
        columnNumber: 5
    }, this);
}
export const snapTopLeftToCursor = ({ activatorEvent, draggingNodeRect, transform })=>{
    if (draggingNodeRect && activatorEvent) {
        const activatorCoordinates = getEventCoordinates(activatorEvent);
        if (!activatorCoordinates) {
            return transform;
        }
        const offsetX = activatorCoordinates.x - draggingNodeRect.left;
        const offsetY = activatorCoordinates.y - draggingNodeRect.top;
        return {
            ...transform,
            x: transform.x + offsetX + 5,
            y: transform.y + offsetY + 5
        };
    }
    return transform;
};

//# sourceMappingURL=index.js.map