import { x as Popconfirm, aC as Select, a6 as Input, at as Icon, kF as ActionKeys, kD as SelectPosEnum, s as __assign } from './MapEditView-24782753.js';
import React__default from 'react';
import { observer } from 'mobx-react';
import classNames from 'classnames';
import { i as i18n, M as MyDataTableContext, p as prefixCls } from './index-3505e026.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 'perf-request';
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-6f8b3541.js';
import './useDataValue-8bdb351c.js';
import 'react-dnd-html5-backend';
import 'ali-react-table-fork';
import './Transfer-f55a5877.js';
import 'ismobilejs';

var 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 },
];
var TablePopconfirm = observer(function (_a) {
    var children = _a.children, onVisibleChange = _a.onVisibleChange, visible = _a.visible, className = _a.className;
    var store = React__default.useContext(MyDataTableContext).store;
    var _b = store.cTableStore, addCol = _b.addCol, changeAddCol = _b.changeAddCol, updateCol = _b.updateCol, isExistSameNameCol = _b.isExistSameNameCol;
    return (React__default.createElement(Popconfirm, { placement: "bottomRight", cancelText: i18n.dataTable.cancel, overlayClassName: "".concat(prefixCls, "-item-label-popconfirm"), okText: i18n.dataTable.add, message: i18n.dataTable.addColPh, description: React__default.createElement("div", { className: "".concat(prefixCls, "-col ").concat(prefixCls, "-add-col") },
            React__default.createElement("div", { className: "".concat(prefixCls, "-col-label") }, i18n.dataTable.addColTitle),
            React__default.createElement("div", { className: "".concat(prefixCls, "-col-content") },
                React__default.createElement(Select, { options: dataTypeOptions, value: addCol.type, onSelect: function (value) { return changeAddCol('type', value); }, size: "compact", type: "menu-bg", 
                    // dropdownStyle={adjustZIndexStyle}
                    dropdownMatchSelectWidth: 120 }),
                React__default.createElement("div", { className: "".concat(prefixCls, "-col-input-container") },
                    React__default.createElement(Input, { value: addCol.name, onChange: function (e) { return 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: function () { return updateCol({ key: "".concat(ActionKeys.AddCol, "-") }); }, 
        // overlayStyle={adjustZIndexStyle}
        className: className },
        React__default.createElement(React__default.Fragment, null, children)));
});
TablePopconfirm.displayName = 'TablePopconfirm';
var PopconfirmTitle = observer(function (_a) {
    var _b;
    var index = _a.index, p = _a.p;
    var key = p.column.key;
    var store = React__default.useContext(MyDataTableContext).store;
    var ref = React__default.useRef(null);
    var _c = store.cTableStore, visibleIndex = _c.visibleIndex, changeVisibleIndex = _c.changeVisibleIndex, selectedPos = _c.selectedPos, changeSelectedPos = _c.changeSelectedPos, addCol = _c.addCol, changeAddCol = _c.changeAddCol, currentAction = _c.currentAction, changeColIndex = _c.changeColIndex, updateCol = _c.updateCol, columnHeaderKeys = _c.columnHeaderKeys, isExistSameNameCol = _c.isExistSameNameCol;
    var options = {
        okText: '',
        message: '',
        description: '',
        // eslint-disable-next-line @typescript-eslint/no-empty-function
        onConfirm: function () { },
    };
    if (currentAction === ActionKeys.AddCol) {
        options = {
            okText: i18n.dataTable.add,
            message: i18n.dataTable.addColPh,
            onConfirm: function () { return updateCol({ key: "".concat(ActionKeys.AddCol, "-") }); },
            description: (React__default.createElement("div", { className: "".concat(prefixCls, "-col ").concat(prefixCls, "-add-col"), ref: ref },
                React__default.createElement("div", { className: "".concat(prefixCls, "-col-label") }, i18n.dataTable.addColTitle),
                React__default.createElement("div", { className: "".concat(prefixCls, "-col-content") },
                    React__default.createElement(Select, { options: dataTypeOptions, value: addCol.type, onSelect: function (value) { return changeAddCol('type', value); }, size: "compact", type: "menu-bg" }),
                    React__default.createElement("div", { className: "".concat(prefixCls, "-col-input-container") },
                        React__default.createElement(Input, { value: addCol.name, onChange: function (e) { return 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: function () { return updateCol({ key: "".concat(ActionKeys.CopyCol, "-") }); },
            description: (React__default.createElement("div", { className: "".concat(prefixCls, "-col") },
                React__default.createElement("div", { className: "".concat(prefixCls, "-col-label") }, i18n.dataTable.addColPh),
                React__default.createElement("div", { className: "".concat(prefixCls, "-col-content") },
                    React__default.createElement(Input, { value: addCol.name, onChange: function (e) { return changeAddCol('name', e.target.value); }, size: "compact", block: true, type: "menu-bg" })))),
        };
    }
    var headerCellCls = classNames("".concat(prefixCls, "-table-header-cell"), (_b = {},
        _b["".concat(prefixCls, "-table-header-cell-active")] = index === selectedPos.colIndex && selectedPos.status === SelectPosEnum.ColActive,
        _b));
    return (React__default.createElement(Popconfirm, __assign({ placement: "bottomRight", cancelText: i18n.dataTable.cancel, overlayClassName: "".concat(prefixCls, "-item-label-popconfirm"), visible: visibleIndex === index, onVisibleChange: function () {
            changeVisibleIndex(-1);
        } }, options, { emotion: 'info', okButtonProps: { disabled: !addCol.name || isExistSameNameCol } }),
        React__default.createElement("div", { className: headerCellCls, onContextMenu: function (e) {
                e.stopPropagation();
                e.preventDefault();
                changeColIndex(index);
                changeSelectedPos({
                    value: '',
                    rowIndex: -1,
                    colIndex: index,
                    status: SelectPosEnum.ColActive,
                });
            } }, columnHeaderKeys[key])));
});

export { TablePopconfirm, dataTypeOptions, PopconfirmTitle as default };
