import React__default from 'react';
import { observer } from 'mobx-react';
import { B as BottomWrapper } from './BottomWrapper-bce78582.js';
import { br as NUMBER_VISUAL, bq as TYPE_VISUAL, bD as HEAT_VISUAL, bE as GRID_HEAT_VISUAL, bF as HEXAGON_HEAT_VISUAL, w as appContext, i as __read, n as iconsUtil, ba as getIcon } from './MapEditView-67426f04.js';
import { find, map, get, forEach } from 'lodash';
import classNames from 'classnames';
import { useSetState, useCreation } from 'ahooks';
import { N as NumberColorSegmentation, T as TextColorSegmentation } from './TextColorSegmentation-f0bab752.js';
import { a as getCurrentVisualConfig, g as getCardIconInfo } from './getCardIconInfo-8a064b41.js';
import 'maptalks';
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 '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 './MapColorPicker-37a8d2be.js';
import './useDataValue-bfcabd04.js';

var VisualDescription = function (props) {
    return React__default.createElement("div", { className: "dm-map-mobile-visual-description" }, props.children);
};

var _a;
var visualTypeMap = (_a = {},
    _a["".concat(NUMBER_VISUAL)] = '数值可视化',
    _a["".concat(TYPE_VISUAL)] = '类型可视化',
    _a["".concat(HEAT_VISUAL)] = '热力可视化',
    _a["".concat(GRID_HEAT_VISUAL)] = '热力可视化',
    _a["".concat(HEXAGON_HEAT_VISUAL)] = '热力可视化',
    _a);
var LegendItem = observer(function (props) {
    var Context = appContext.getContext();
    var value = React__default.useContext(Context);
    var routeStore = value.routeStore; value.prefixCls;
    var defaultIcon = routeStore.defaultIcon, customIconPrefInfo = routeStore.customIconPrefInfo, getSuppPackage = routeStore.SuppFiltersStore.getSuppPackage;
    var card = props.card;
    var _a = __read(useSetState({
        openModal: false,
    }), 2), state = _a[0], setState = _a[1];
    var defaultStyle = card.defaultStyle, uuid = card.uuid;
    var visualList = card.visualList;
    var currentVisual = find(visualList, { isCurrent: true });
    var suppPackage = useCreation(function () {
        return getSuppPackage(card.uuid);
    }, [card.uuid]);
    var getCol = suppPackage.getCol, geometryType = suppPackage.geometryType, getColumnValueById = suppPackage.getColumnValueById;
    var iconCache = iconsUtil.iconCache, getIconUrl = iconsUtil.getIconUrl, getIconColorPref = iconsUtil.getIconColorPref;
    var _b = __read(getCurrentVisualConfig({
        currentVisual: currentVisual,
        card: card,
        packageInfo: suppPackage,
    }), 5), currentVisualDetail = _b[0]; _b[1]; var currentVisualField = _b[2]; _b[3]; var currentVisualOpinion = _b[4];
    currentVisualOpinion.isHeat; currentVisualOpinion.isCurrentHeatVisual; currentVisualOpinion.isCurrentGridHeatVisual; currentVisualOpinion.isCurrentHexagonHeatVisual; var isCurrentTypeVisual = currentVisualOpinion.isCurrentTypeVisual; currentVisualOpinion.isCurrentNumberVisual; var isFlow = currentVisualOpinion.isFlow, isPolygon3DVisual = currentVisualOpinion.isPolygon3DVisual; currentVisualOpinion.isLine3DVisual; currentVisualOpinion.isPoint3DVisual; var isPointToPoint = currentVisualOpinion.isPointToPoint, isPoint = currentVisualOpinion.isPoint;
    var _getCurrentBreaks = function () {
        var currentBreaks = [];
        if (isCurrentTypeVisual) {
            forEach(currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.breaks, function (b) {
                var data = getColumnValueById({ uuid: uuid, col: currentVisualField, id: b });
                currentBreaks.push(data === null || data === void 0 ? void 0 : data.value);
            });
        }
        if (isFlow || isPolygon3DVisual) {
            var field_1 = getCol({ uuid: uuid, fieldId: currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.colorFieldId });
            forEach(currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.breaks, function (b) {
                var data = getColumnValueById({ uuid: uuid, col: field_1, id: b });
                currentBreaks.push(data === null || data === void 0 ? void 0 : data.value);
            });
        }
        return currentBreaks;
    };
    var iconInfo = useCreation(function () {
        return getCardIconInfo({
            getIconColorPref: getIconColorPref,
            getIconUrl: getIconUrl,
            iconCache: iconCache,
            customIconPrefInfo: customIconPrefInfo,
            defaultIcon: defaultIcon,
        });
    }, [
        getIconColorPref,
        getIconUrl,
        defaultIcon,
        customIconPrefInfo,
        iconCache.customIconList,
        iconCache.defaultIconList,
    ]);
    return (React__default.createElement(React__default.Fragment, null,
        React__default.createElement("div", { className: classNames('dm-map-mobile-legend-item', {
                show: props.show,
            }), onClick: function () {
                if (props.show) {
                    setState({
                        openModal: true,
                    });
                }
                else {
                    card.changeCardHidden(false);
                }
            } },
            !card.hidden && (React__default.createElement("div", { className: "dm-map-mobile-legend-item-show-icon" },
                React__default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
                    React__default.createElement("path", { d: "M0 0H20V20H6C2.68629 20 0 17.3137 0 14V0Z", fill: "var(--primary-primary-border-1, #5578f4)" }),
                    React__default.createElement("path", { d: "M14.7349 5.15935C15.2107 5.46171 15.3513 6.09258 15.049 6.56842L9.85981 14.735C9.69233 14.9985 9.41343 15.171 9.1028 15.203C8.79216 15.2349 8.48397 15.123 8.26629 14.8991L5.2889 11.8366C4.8959 11.4324 4.905 10.7861 5.30923 10.3931C5.71346 10.0001 6.35974 10.0092 6.75274 10.4135L8.82952 12.5496L13.3258 5.47348C13.6281 4.99763 14.259 4.85699 14.7349 5.15935Z", fill: "white" })))),
            React__default.createElement("div", null,
                React__default.createElement("div", { className: "dm-map-mobile-legend-item-name" }, card.name),
                card.hidden && (React__default.createElement("div", { className: "dm-map-mobile-legend-item-visual-list" }, map(visualList, function (item, index) {
                    return (React__default.createElement(VisualDescription, { key: index },
                        "\u6309\"",
                        getCol({ fieldId: item.fieldId }),
                        "\"",
                        get(visualTypeMap, item.id)));
                }))),
                !card.hidden && (currentVisual === null || currentVisual === void 0 ? void 0 : currentVisual.id) === 'numberVisual' && (React__default.createElement("div", null,
                    React__default.createElement(NumberColorSegmentation, { icons: isPoint || isPointToPoint ? currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.icons : [], breaks: currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.breaks, colors: currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.colors, ignore: currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.ignore, iconInfo: iconInfo }))),
                !card.hidden && (currentVisual === null || currentVisual === void 0 ? void 0 : currentVisual.id) === 'typeVisual' && (React__default.createElement("div", null,
                    React__default.createElement(TextColorSegmentation, { icons: isPoint || isPointToPoint
                            ? currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.icons
                            : [getIcon(geometryType, defaultStyle)], breaks: _getCurrentBreaks(), colors: currentVisualDetail === null || currentVisualDetail === void 0 ? void 0 : currentVisualDetail.colors }))))),
        state.openModal && (React__default.createElement("div", null,
            React__default.createElement("div", { className: "dm-map-mobile-legend-item-mask", onClick: function () {
                    setState({
                        openModal: false,
                    });
                } }),
            React__default.createElement("div", { className: "dm-map-mobile-legend-item-modal" },
                React__default.createElement("div", { className: "dm-map-mobile-legend-item-modal-content" }, map(visualList, function (item, index) {
                    return (React__default.createElement("div", { key: index, className: "dm-map-mobile-legend-item-modal-content-item", onClick: function () {
                            card.changeCurrentVisual({
                                id: item.id,
                                fieldId: item.fieldId,
                            });
                            setState({
                                openModal: false,
                            });
                        } },
                        "\u6309\"",
                        getCol({ fieldId: item.fieldId }),
                        "\"",
                        get(visualTypeMap, item.id)));
                })),
                React__default.createElement("div", { className: "dm-map-mobile-legend-item-modal-hidden", onClick: function () {
                        card.changeCardHidden(true);
                        setState({
                            openModal: false,
                        });
                    } }, "\u9690\u85CF\u56FE\u5C42"))))));
});

var LegendAll = observer(function () {
    var Context = appContext.getContext();
    var value = React__default.useContext(Context);
    var routeStore = value.routeStore; value.prefixCls;
    var cards = routeStore.CardsStore.cards, setLegend = routeStore.MobileUIStore.setLegend;
    return (React__default.createElement(BottomWrapper, { title: "\u56FE\u4F8B", iconClick: function () {
            setLegend(false);
        } },
        React__default.createElement("div", { className: "dm-map-mobile-legend-all" }, map(cards, function (card) {
            return React__default.createElement(LegendItem, { key: card.uuid, show: !card.hidden, card: card });
        }))));
});

export { LegendAll as default };
