import React__default from 'react';
import { observer } from 'mobx-react';
import { r as Popconfirm, aw as Select, a1 as Input, ao as Icon, kF as ActionKeys, kD as SelectPosEnum } from './MapEditView-f6381866.js';
import classNames from 'classnames';
import { i as i18n, M as MyDataTableContext, p as prefixCls } from './index-0b8bebb4.js';
import 'maptalks';
import 'lodash';
import 'uuid';
import 'mobx';
import 'lz-string';
import 'dayjs';
import 'react-dom';
import 'react-is';
import '@loadable/component';
import 'js-beautify';
import 'axios';
import 'superstruct';
import '@tanem/react-nprogress';
import 'jquery';
import 'chroma-js';
import 'js-cookie';
import 'is-email';
import 'is-uuid';
import 'is-url';
import 'anymatch';
import '@syncpoint/wkx';
import 'buffer';
import '@turf/turf';
import '@mapbox/polylabel';
import 'turf-multipolygon';
import 'turf-polygon';
import 'gcoord';
import 'eventemitter2';
import 'geobuf';
import 'localforage';
import 'rc-menu';
import 'perfect-scrollbar';
import 'ahooks';
import 'jszip';
import 'file-saver';
import 'screenfull';
import 'sql-formatter-fork';
import 'array-move';
import 'turf-multilinestring';
import 'copy-to-clipboard';
import 'maptalks.three';
import 'ajv';
import 'spark-md5';
import 'react-draggable';
import 'react-virtualized';
import 'turf-point';
import 'decamelize';
import 'rbush';
import 'qs';
import 'maptalks.snap';
import 'react-use';
import 'react-rnd';
import 'react-beautiful-dnd';
import 'react-contextmenu';
import 'coordtransform';
import './compact-f89fbdd0.js';
import './useDataValue-6bd3790f.js';
import 'react-dnd-html5-backend';
import 'ali-react-table-fork';
import './Transfer-b219601e.js';
import 'ismobilejs';

const dataTypeOptions = [
    { label: i18n.dataTable.str, value: 'text' },
    { label: i18n.dataTable.num, value: 'number' },
    { label: i18n.dataTable.time, value: 'dateTime' },
    // { label: 'lng', value: 'lng', disabled: true },
    // { label: 'lat', value: 'lat', disabled: true },
    // { label: i18n.dataTable.img, value: 'image', disabled: true },
];
const TablePopconfirm = observer(({ children, onVisibleChange, visible, className }) => {
    const { store } = React__default.useContext(MyDataTableContext);
    const { addCol, changeAddCol, updateCol, isExistSameNameCol } = store.cTableStore;
    return (React__default.createElement(Popconfirm, { placement: "bottomRight", cancelText: i18n.dataTable.cancel, overlayClassName: `${prefixCls}-item-label-popconfirm`, okText: i18n.dataTable.add, message: i18n.dataTable.addColPh, description: React__default.createElement("div", { className: `${prefixCls}-col ${prefixCls}-add-col` },
            React__default.createElement("div", { className: `${prefixCls}-col-label` }, i18n.dataTable.addColTitle),
            React__default.createElement("div", { className: `${prefixCls}-col-content` },
                React__default.createElement(Select, { options: dataTypeOptions, value: addCol.type, onSelect: (value) => changeAddCol('type', value), size: "compact", type: "menu-bg", 
                    // dropdownStyle={adjustZIndexStyle}
                    dropdownMatchSelectWidth: 120 }),
                React__default.createElement("div", { className: `${prefixCls}-col-input-container` },
                    React__default.createElement(Input, { value: addCol.name, onChange: (e) => changeAddCol('name', e.target.value), size: "compact", block: true, type: "menu-bg" }),
                    isExistSameNameCol && (React__default.createElement("div", { className: "dmc-form-item-message dmc-form-item-message-error" },
                        React__default.createElement(Icon, { icon: "alert", className: "dmc-icon dmc-form-item-icon" }),
                        React__default.createElement("span", null, "\u5DF2\u6709\u540C\u540D\u5217\uFF0C\u8BF7\u4FEE\u6539")))))), emotion: 'info', okButtonProps: { disabled: !addCol.name || isExistSameNameCol }, trigger: "click", visible: visible, onVisibleChange: onVisibleChange, onConfirm: () => updateCol({ key: `${ActionKeys.AddCol}-` }), 
        // overlayStyle={adjustZIndexStyle}
        className: className },
        React__default.createElement(React__default.Fragment, null, children)));
});
TablePopconfirm.displayName = 'TablePopconfirm';
const PopconfirmTitle = observer(({ index, p }) => {
    const key = p.column.key;
    const { store } = React__default.useContext(MyDataTableContext);
    const ref = React__default.useRef(null);
    const { visibleIndex, changeVisibleIndex, selectedPos, changeSelectedPos, addCol, changeAddCol, currentAction, changeColIndex, updateCol, columnHeaderKeys, isExistSameNameCol, } = store.cTableStore;
    let options = {
        okText: '',
        message: '',
        description: '',
        // eslint-disable-next-line @typescript-eslint/no-empty-function
        onConfirm: () => { },
    };
    if (currentAction === ActionKeys.AddCol) {
        options = {
            okText: i18n.dataTable.add,
            message: i18n.dataTable.addColPh,
            onConfirm: () => updateCol({ key: `${ActionKeys.AddCol}-` }),
            description: (React__default.createElement("div", { className: `${prefixCls}-col ${prefixCls}-add-col`, ref: ref },
                React__default.createElement("div", { className: `${prefixCls}-col-label` }, i18n.dataTable.addColTitle),
                React__default.createElement("div", { className: `${prefixCls}-col-content` },
                    React__default.createElement(Select, { options: dataTypeOptions, value: addCol.type, onSelect: (value) => changeAddCol('type', value), size: "compact", type: "menu-bg" }),
                    React__default.createElement("div", { className: `${prefixCls}-col-input-container` },
                        React__default.createElement(Input, { value: addCol.name, onChange: (e) => changeAddCol('name', e.target.value), size: "compact", block: true, type: "menu-bg" }),
                        isExistSameNameCol && (React__default.createElement("div", { className: "dmc-form-item-message dmc-form-item-message-error" },
                            React__default.createElement(Icon, { icon: "alert", className: "dmc-icon dmc-form-item-icon" }),
                            React__default.createElement("span", null, "\u5DF2\u6709\u540C\u540D\u5217\uFF0C\u8BF7\u4FEE\u6539"))))))),
        };
    }
    else if (currentAction === ActionKeys.CopyCol) {
        options = {
            okText: i18n.dataTable.rename,
            message: i18n.dataTable.copyDataCol,
            onConfirm: () => updateCol({ key: `${ActionKeys.CopyCol}-` }),
            description: (React__default.createElement("div", { className: `${prefixCls}-col` },
                React__default.createElement("div", { className: `${prefixCls}-col-label` }, i18n.dataTable.addColPh),
                React__default.createElement("div", { className: `${prefixCls}-col-content` },
                    React__default.createElement(Input, { value: addCol.name, onChange: (e) => changeAddCol('name', e.target.value), size: "compact", block: true, type: "menu-bg" })))),
        };
    }
    const headerCellCls = classNames(`${prefixCls}-table-header-cell`, {
        [`${prefixCls}-table-header-cell-active`]: index === selectedPos.colIndex && selectedPos.status === SelectPosEnum.ColActive,
    });
    return (React__default.createElement(Popconfirm, Object.assign({ placement: "bottomRight", cancelText: i18n.dataTable.cancel, overlayClassName: `${prefixCls}-item-label-popconfirm`, visible: visibleIndex === index, onVisibleChange: () => {
            changeVisibleIndex(-1);
        } }, options, { emotion: 'info', okButtonProps: { disabled: !addCol.name || isExistSameNameCol } }),
        React__default.createElement("div", { className: headerCellCls, onContextMenu: (e) => {
                e.stopPropagation();
                e.preventDefault();
                changeColIndex(index);
                changeSelectedPos({
                    value: '',
                    rowIndex: -1,
                    colIndex: index,
                    status: SelectPosEnum.ColActive,
                });
            } }, columnHeaderKeys[key])));
});

export { TablePopconfirm, dataTypeOptions, PopconfirmTitle as default };
