/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { __toESM } from "../../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../../node_modules/classnames/index.js";
import { pkg } from "../../../settings.js";
import React from "react";
import PropTypes from "prop-types";
import { Draggable, Locked } from "@carbon/react/icons";
import { CSS } from "@dnd-kit/utilities";
import { useSortable } from "@dnd-kit/sortable";

//#region src/components/Datagrid/Datagrid/DraggableElement.tsx
/**
* Copyright IBM Corp. 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${pkg.prefix}--datagrid`;
/**
* Single row in the DraggableItemsList used by CustomizeColumnsTearsheet.
*/
const DraggableElement = ({ id, elementId, children, classList, disabled, ariaLabel, isSticky, selected }) => {
	const { attributes, isDragging, listeners, setNodeRef, transform, transition } = useSortable({
		disabled,
		id
	});
	const { "aria-pressed": ariaPressed, "aria-describedby": ariaDescribedby } = attributes;
	const dragHandle = isSticky ? /* @__PURE__ */ React.createElement("div", { className: (0, import_classnames.default)({ disabled }, `${blockClass}__draggable-handleStyle`) }, /* @__PURE__ */ React.createElement(Locked, { size: 16 }), " ") : /* @__PURE__ */ React.createElement("button", {
		className: `${blockClass}__draggable-handleStyle`,
		type: "button",
		"aria-label": ariaLabel,
		"aria-describedby": ariaDescribedby,
		"aria-pressed": ariaPressed,
		...listeners
	}, /* @__PURE__ */ React.createElement(Draggable, { size: 16 }));
	const content = /* @__PURE__ */ React.createElement(React.Fragment, null, dragHandle, children);
	const style = {
		transform: !disabled ? CSS.Transform.toString(transform) : void 0,
		transition
	};
	return /* @__PURE__ */ React.createElement("li", {
		className: (0, import_classnames.default)(classList, `${blockClass}__draggable-handleHolder`, {
			[`${blockClass}__draggable-handleHolder--selected`]: selected,
			[`${blockClass}__draggable-handleHolder--sticky`]: isSticky,
			[`${blockClass}__draggable-handleHolder--dragging`]: isDragging
		}),
		id: elementId ? elementId : id,
		ref: setNodeRef,
		style
	}, /* @__PURE__ */ React.createElement("div", { className: (0, import_classnames.default)([`${blockClass}__draggable-handleHolder-droppable`]) }, content));
};
DraggableElement.propTypes = {
	ariaLabel: PropTypes.string.isRequired,
	children: PropTypes.element.isRequired,
	classList: PropTypes.string,
	disabled: PropTypes.bool,
	elementId: PropTypes.string,
	id: PropTypes.string.isRequired,
	isSticky: PropTypes.bool,
	selected: PropTypes.bool
};

//#endregion
export { DraggableElement as default };