'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var elementPlus = require('element-plus');
var index = require('../../svg-icon/index.js');
var index$2 = require('../../button/index.js');
var index$1 = require('../../dialog/index.js');
require('./map.vue.js');
var map_vue_vue_type_script_setup_true_lang = require('./map.vue2.js');

"use strict";
const _hoisted_1 = { class: "me-input-gps" };
const _hoisted_2 = {
  key: 0,
  style: { "color": "#999" }
};
const __default__ = vue.defineComponent({
  name: "me-input-gps"
});
var script = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: {
    latitude: { type: Number, required: true },
    longitude: { type: Number, required: true },
    address: { type: String, required: true },
    mapKey: { type: String, required: true }
  },
  emits: ["confirmEvent"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const coord = vue.ref({});
    const visible = vue.ref(false);
    const inputValue = vue.computed(() => {
      if (!coord.value.latitude) return "";
      return `\u7ECF\u5EA6\uFF1A${coord.value.longitude}\uFF0C\u7EAC\u5EA6\uFF1A${coord.value.latitude}`;
    });
    const handleOpenMap = () => {
      visible.value = true;
    };
    const confirm = () => {
      const data = {
        latitude: coord.value.latitude,
        longitude: coord.value.longitude,
        address: coord.value.address
      };
      emit("confirmEvent", data);
      visible.value = false;
    };
    vue.onMounted(() => {
      coord.value.latitude = props.latitude;
      coord.value.longitude = props.longitude;
    });
    const isFullscreen = vue.ref(false);
    const handleFullscreenChange = (val) => {
      isFullscreen.value = val;
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(elementPlus.ElInput), {
          style: { "cursor": "pointer" },
          value: inputValue.value,
          "read-only": ""
        }, {
          suffix: vue.withCtx(() => [
            vue.createElementVNode("div", {
              style: { "cursor": "pointer", "height": "100%" },
              onClick: handleOpenMap
            }, [
              vue.createVNode(vue.unref(index.MeSvgIcon), { name: "ri-map-pin-line" })
            ])
          ]),
          _: 1
          /* STABLE */
        }, 8, ["value"]),
        coord.value?.address ? (vue.openBlock(), vue.createElementBlock(
          "div",
          _hoisted_2,
          "\u4F4D\u7F6E\uFF1A" + vue.toDisplayString(coord.value.address),
          1
          /* TEXT */
        )) : vue.createCommentVNode("v-if", true),
        vue.createVNode(vue.unref(index$1.MeDialog), {
          modelValue: visible.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => visible.value = $event),
          title: "\u9009\u62E9\u4F4D\u7F6E"
        }, {
          "me-dialog-footer-right": vue.withCtx(() => [
            vue.createVNode(vue.unref(index$2.MeButton), { onClick: confirm }, {
              default: vue.withCtx(() => [..._cache[2] || (_cache[2] = [
                vue.createTextVNode(
                  "\u786E\u5B9A",
                  -1
                  /* CACHED */
                )
              ])]),
              _: 1
              /* STABLE */
            })
          ]),
          default: vue.withCtx(() => [
            __props.mapKey ? (vue.openBlock(), vue.createBlock(map_vue_vue_type_script_setup_true_lang.default, {
              key: 0,
              isFullscreen: isFullscreen.value,
              modelValue: coord.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => coord.value = $event),
              "map-key": __props.mapKey
            }, null, 8, ["isFullscreen", "modelValue", "map-key"])) : vue.createCommentVNode("v-if", true)
          ]),
          _: 1
          /* STABLE */
        }, 8, ["modelValue"])
      ]);
    };
  }
});

exports.default = script;
//# sourceMappingURL=input-gps.vue2.js.map
