"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DragAndDropItem = void 0;
const react_1 = __importDefault(require("react"));
const helpers_1 = require("../../../utils/helpers");
const hooks_1 = require("../../../utils/hooks");
const DragAndDropDragHandler_1 = require("../drag-handler/DragAndDropDragHandler");
const DragAndDrop_context_1 = require("../root/DragAndDrop.context");
/**
 * TODO
 *
 * @see 🏷️ {@link DragAndDropItemProps}
 * @example
 * ```tsx
 * <DragAndDrop.Item numOfSelectedRows={selectedRows.length} onClear={handleClear}>
 *   TODO
 * </DragAndDrop.Item>
 * ```
 */
const DragAndDropItem = react_1.default.forwardRef((_a, forwardedRef) => {
    var _b;
    var { children, id, index, className, isOverlay = false, itemLabel } = _a, rest = __rest(_a, ["children", "id", "index", "className", "isOverlay", "itemLabel"]);
    const ref = react_1.default.useRef(null);
    const mergedRef = (0, hooks_1.useMergeRefs)(forwardedRef, ref);
    const context = (0, DragAndDrop_context_1.useDragAndDropContext)();
    const item = { id, index };
    const isDropTarget = ((_b = context === null || context === void 0 ? void 0 : context.dropTarget) === null || _b === void 0 ? void 0 : _b.id) === id;
    return (react_1.default.createElement("li", Object.assign({ id: isOverlay ? undefined : id }, rest, { ref: mergedRef, "data-dnd-id": isOverlay ? undefined : id, "data-dnd-index": isOverlay ? undefined : index, className: (0, helpers_1.cl)("aksel-data-table__drag-and-drop-item", className), "data-drop-target": isOverlay ? undefined : isDropTarget, "data-overlay": isOverlay }),
        react_1.default.createElement(DragAndDropDragHandler_1.DragAndDropDragHandler, { item: item, itemRef: ref, isOverlay: isOverlay, itemLabel: itemLabel }),
        react_1.default.createElement("div", null, children)));
});
exports.DragAndDropItem = DragAndDropItem;
exports.default = DragAndDropItem;
//# sourceMappingURL=DragAndDropItem.js.map