import * as React from 'react';
import classNames from 'classnames';
import { s as IconButton, an as GeoTypeIcon, am as Tooltip, a1 as Input } from './MapEditView-f6381866.js';
import { useToggle } from 'react-use';

const prefixCls = 'dm-map-package-wrapper';
const PackageWrapper = React.memo((props) => {
    const { text, alias, isCurrent, type, deleteTitle, onDelete, onClick, onChangeText, provided, onEdit, } = props;
    const [inEdit, toggle] = useToggle(false);
    const enter = (e) => {
        var _a;
        const value = (_a = e.target) === null || _a === void 0 ? void 0 : _a.value;
        onChangeText && onChangeText(value);
        toggle(false);
    };
    return (React.createElement("div", { style: { marginBottom: 4 }, className: classNames(prefixCls, {
            [`${prefixCls}-current`]: isCurrent,
        }) },
        React.createElement("div", { className: `${prefixCls}-main`, onClick: onClick },
            provided && (React.createElement(IconButton, Object.assign({ className: `${prefixCls}-drag-handle`, icon: "drag-handle", type: "only-icon" }, provided === null || provided === void 0 ? void 0 : provided.dragHandleProps))),
            React.createElement(GeoTypeIcon, { type: type, size: 12, className: `${prefixCls}-type-icon` }),
            !inEdit && (React.createElement(Tooltip, { title: text, placement: "right", mouseEnterDelay: 0, mouseLeaveDelay: 0 },
                React.createElement("div", { className: `${prefixCls}-text`, onDoubleClick: () => {
                        onChangeText && toggle(true);
                    } }, alias ? alias : text))),
            inEdit && onChangeText && (React.createElement(Input, { className: `${prefixCls}-text-input`, autoFocus: true, allowClear: false, defaultValue: alias ? alias : text, onBlur: enter, onPressEnter: enter }))),
        onEdit && React.createElement(IconButton, { icon: "edit", type: "only-icon", onClick: onEdit }),
        deleteTitle ? (React.createElement(Tooltip, { title: deleteTitle, placement: "right", mouseEnterDelay: 0, mouseLeaveDelay: 0 },
            React.createElement(IconButton, { icon: "close", type: "only-icon", onClick: onDelete }))) : (React.createElement(IconButton, { icon: "close", type: "only-icon", onClick: onDelete }))));
});
PackageWrapper.whyDidYouRender = true;
PackageWrapper.displayName = 'PackageWrapper';

export { PackageWrapper as P };
