import * as React from 'react';
import { p as i18n$1, ai as DraggableWrap, I as Icon, ak as LinkButton, b1 as InputNumber, aj as LabelSelect, al as Button, b2 as mapboxs } from './MapEditView-f6381866.js';
import { L as LabelCheckbox } from './LabelCheckbox-687644d2.js';
import 'maptalks';
import 'lodash';
import 'uuid';
import 'mobx';
import 'lz-string';
import 'dayjs';
import 'react-dom';
import 'classnames';
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 'mobx-react';
import 'decamelize';
import 'rbush';
import 'qs';
import 'maptalks.snap';
import 'react-use';
import 'react-rnd';
import 'react-beautiful-dnd';

const i18n = i18n$1.mapEdit.exportImageSettings;
const prefixCls = 'dm-map-export-img-setting';
const { useState } = React;
const clarityGroup = [
    {
        key: '',
        label: i18n.HD,
        value: i18n.HD,
    },
    {
        key: '',
        label: i18n.ultraHD,
        value: i18n.ultraHD,
    },
    {
        key: '',
        label: i18n.ultraHDLossless,
        value: i18n.ultraHDLossless,
    },
];
const zoomGroup = [];
for (let i = 3; i <= 20; i++) {
    zoomGroup.push({
        key: i,
        label: i,
        value: i,
    });
}
const MapExportImgSetting = React.memo((props) => {
    var _a, _b;
    const { renew, currentZoom = 8, onCancel, legendId, exportHighResolution, mapStyle, changeSize, } = props;
    const inMapboxBase = mapboxs.includes(mapStyle);
    const [width, setWidth] = useState((_a = props === null || props === void 0 ? void 0 : props.width) !== null && _a !== void 0 ? _a : 40);
    const [height, setHeight] = useState((_b = props === null || props === void 0 ? void 0 : props.height) !== null && _b !== void 0 ? _b : 30);
    const [exportLayer, setExportLayer] = useState(false);
    const [clarity, setClarity] = useState(i18n.HD); // 分辨率
    const [zoom, setZoom] = useState(Math.round(currentZoom)); // zoom
    const _onChangeSize = () => {
        changeSize && changeSize(width, height);
    };
    const _onOk = () => {
        _onChangeSize();
        let hiresType = 'hd_ll'; // hd_ll | hd | fhd
        if (clarity === i18n.ultraHD) {
            hiresType = 'hd';
        }
        else if (clarity === i18n.ultraHDLossless) {
            hiresType = 'fhd';
        }
        const exportOptions = {
            exportLayer,
            zoom,
            hiresType,
        };
        exportHighResolution === null || exportHighResolution === void 0 ? void 0 : exportHighResolution(exportOptions);
    };
    const _onCancel = () => {
        onCancel && onCancel();
    };
    const resetSize = (width, height, zoom) => {
        width && setWidth(width);
        height && setHeight(height);
        zoom && setZoom(zoom);
    };
    const _renew = () => {
        renew(resetSize);
    };
    return (React.createElement(DraggableWrap, { bounds: false },
        React.createElement("div", { className: prefixCls },
            React.createElement("div", { id: legendId }),
            React.createElement("div", { className: `${prefixCls}-item mb20` },
                React.createElement("div", { className: `${prefixCls}-title` }, i18n.plotOptions),
                React.createElement("div", { className: `${prefixCls}-renew`, onClick: _renew },
                    React.createElement(Icon, { icon: "renew", size: 14, className: `${prefixCls}-renew-icon` }),
                    i18n.reselection)),
            React.createElement("div", { className: `${prefixCls}-item-size` },
                React.createElement("div", { className: `${prefixCls}-fs14` }, i18n.selectionSize),
                React.createElement("div", { className: `${prefixCls}-help ml8` }, i18n.selectionUnit)),
            React.createElement("div", { className: `${prefixCls}-item-refresh-size mb10` },
                i18n.selectionHelp1,
                React.createElement(LinkButton, { className: `${prefixCls}-fs12 ml4 mr4`, onClick: _onChangeSize }, i18n.selectionHelp2),
                i18n.selectionHelp3),
            React.createElement("div", { className: `${prefixCls}-item ${prefixCls}-item-input mb10` },
                i18n.width,
                React.createElement(InputNumber, { visibilityHandler: true, size: "compact", type: "assist-bg", className: `${prefixCls}-item-input-number mr8 ml8`, value: width, onChange: (value) => setWidth(Number(value)), onPressEnter: () => {
                        _onChangeSize();
                    } }),
                i18n.height,
                React.createElement(InputNumber, { visibilityHandler: true, size: "compact", type: "assist-bg", className: `${prefixCls}-item-input-number ml8`, value: height, onChange: (value) => setHeight(Number(value)), onPressEnter: () => {
                        _onChangeSize();
                    } })),
            React.createElement("div", { className: `${prefixCls}-gap mb10` }),
            React.createElement(LabelSelect, { options: zoomGroup, value: zoom, onChange: (value) => {
                    console.log(value, 'value');
                    setZoom(Number(value));
                }, text: i18n.zoomLevel, help: React.createElement(React.Fragment, null,
                    i18n.zoomLevelHelp1,
                    React.createElement("br", null),
                    i18n.zoomLevelHelp2,
                    React.createElement("br", null),
                    i18n.zoomLevelHelp3), className: `mb10` }),
            React.createElement(LabelSelect, { options: clarityGroup, value: clarity, onChange: (value) => {
                    console.log(value, 'value');
                    setClarity(value);
                }, text: i18n.clarity, help: i18n.clarityHelp1, className: `mb10` }),
            React.createElement(LabelCheckbox, { text: i18n.plotOptions1, help: React.createElement(React.Fragment, null,
                    i18n.plotOptions1Help1,
                    React.createElement("br", null),
                    i18n.plotOptions1Help2), title: i18n.splitDataLayer, className: `mb20`, onChange: setExportLayer, checked: exportLayer }),
            !inMapboxBase && (React.createElement("div", { className: `${prefixCls}-warning-help mb20` },
                React.createElement(Icon, { icon: "alert", size: 14, className: `${prefixCls}-warning-icon mr8` }),
                i18n.warningHelp)),
            React.createElement("div", { className: `${prefixCls}-button` },
                React.createElement(Button, { onClick: _onCancel }, i18n$1.mapEdit.cancelText),
                React.createElement(Button, { type: "primary", onClick: _onOk }, i18n$1.mapEdit.okText)))));
});
var MapExportImgSetting$1 = MapExportImgSetting;

export { MapExportImgSetting$1 as default };
