function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import React, { Fragment, useContext } from 'react';
import Context from '../Context/instance.js';
import MapView from './../MapView';
import MapChoose from './../MapChoose'; // 地图组件

var Map = function Map(_ref) {
  var readOnly = _ref.readOnly,
      type = _ref.type,
      onChange = _ref.onChange,
      ak = _ref.ak,
      show = _ref.show,
      viewMapData = _ref.viewMapData,
      portal = _ref.portal,
      onHide = _ref.onHide,
      mapPageProps = _ref.mapPageProps;
  // 国际化
  var context = useContext(Context) || {};
  return /*#__PURE__*/React.createElement(Fragment, null, readOnly && /*#__PURE__*/React.createElement(MapView, _extends({
    ak: ak,
    show: show,
    header: viewMapData && viewMapData.address ? /*#__PURE__*/React.createElement("div", {
      className: "map-bar border-b"
    }, viewMapData.address) : null,
    points: viewMapData && viewMapData.point ? [viewMapData.point] : null,
    portal: context.portal || document.getElementById('root') || document.body,
    onHide: onHide
  }, mapPageProps || {})), !readOnly && type === 'choose' && /*#__PURE__*/React.createElement(MapChoose, _extends({
    ak: ak,
    show: show,
    autoLocation: true,
    point: viewMapData && viewMapData.point ? viewMapData.point : null,
    address: viewMapData && viewMapData.address ? viewMapData.address : null,
    portal: context.portal || document.getElementById('root') || document.body,
    onHide: onHide,
    onChange: onChange
  }, mapPageProps || {})));
};

export default Map;