import { reactive as I, toRefs as B, defineComponent as w, resolveComponent as n, openBlock as f, createElementBlock as V, normalizeClass as _, unref as a, createVNode as v, withCtx as l, createBlock as T, createCommentVNode as g, createTextVNode as W, renderSlot as h } from "vue";
import { u as $, t as E, b as k } from "./layer-select-Ba4IEiWY.js";
import { b, _ as S } from "./utils-B4smQbM-.js";
import "./vendor-D4icwOYu.js";
import "ant-design-vue";
import "@mapgis/webclient-common";
const D = {
  /**
   * @description 服务根地址，形如：http(s)://<server>:<port>/igs/rest/services
   */
  serviceRootUrl: {
    type: String
  },
  /**
   * @description 服务根令牌
   */
  serviceRootToken: {
    type: String
  },
  /**
   * @description 服务类型，来自于@mapgis/webclient-common中LayerType的常量值
   */
  serviceType: {
    type: String
  },
  /**
   * @description 服务类型显示模式，可取值2D、3D、all
   */
  showMode: {
    type: String,
    default: "all",
    validator: (s) => ["2D", "3D", "all"].includes(s)
  },
  /**
   * @description 是否支持第三方服务，第三方服务无法从服务器选择，只能输入，默认为true
   */
  supportThirdPartyServices: {
    type: Boolean,
    default: !0
  },
  /**
   * @description 服务选择下拉框宽度，单位像素
   */
  dropdownWidth: {
    type: Number
  }
}, U = {
  add: ({ layerOptions: s, layer: r }) => b(s) && b(r)
}, K = {
  ...D,
  /**
   * @description 默认激活的标签页key
   */
  defaultActiveKey: {
    type: String,
    default: "url"
  }
}, L = {
  ...U
}, O = {
  ...D
}, z = {
  ...U
}, x = (s, r) => ({}), j = (s, r) => {
  const { zondy: c, map: i, viewState: e } = $(), t = I({ enabledAddData: !1, serviceInfo: null, showMode: s.showMode });
  e.viewMode === "2D" && (t.showMode = "2D");
  function d(o) {
    t.serviceInfo = { ...o }, t.enabledAddData = o.isServiceUrlValid && o.serviceUrl && o.serviceType;
  }
  async function p() {
    t.enabledAddData = !1;
    const o = {
      title: t.serviceInfo.suggestServiceName,
      type: t.serviceInfo.serviceType,
      url: t.serviceInfo.serviceUrl,
      tokenKey: t.serviceInfo.tokenKey,
      tokenValue: t.serviceInfo.tokenValue,
      tokenAttachType: t.serviceInfo.tokenAttachType
    }, y = await E(c, e.view, i, o);
    r("add", { layerOptions: o, layer: y });
  }
  return { ...B(t), handleServiceChange: d, handleAddData: p };
}, q = /* @__PURE__ */ w({
  name: "MapgisAddDataUrl",
  __name: "add-data-url",
  props: O,
  emits: z,
  setup(s, { emit: r }) {
    const c = s, i = r, e = k("add-data-url"), { enabledAddData: t, serviceInfo: d, showMode: p, handleServiceChange: o, handleAddData: y } = j(c, i);
    return (u, m) => {
      const A = n("a-input"), R = n("a-form-item"), M = n("mapgis-service-select"), C = n("a-button"), P = n("mapgis-ui-setting-footer");
      return f(), V("div", {
        class: _([a(e).b()])
      }, [
        v(M, {
          serviceRootUrl: u.serviceRootUrl,
          serviceRootToken: u.serviceRootToken,
          serviceType: u.serviceType,
          showMode: a(p),
          supportThirdPartyServices: u.supportThirdPartyServices,
          dropdownWidth: u.dropdownWidth,
          onServiceChange: a(o)
        }, {
          default: l(() => [
            a(d) ? (f(), T(R, {
              key: 0,
              label: "服务名称"
            }, {
              default: l(() => [
                v(A, {
                  value: a(d).suggestServiceName,
                  "onUpdate:value": m[0] || (m[0] = (N) => a(d).suggestServiceName = N),
                  title: a(d).suggestServiceName
                }, null, 8, ["value", "title"])
              ]),
              _: 1
            })) : g("", !0)
          ]),
          _: 1
        }, 8, ["serviceRootUrl", "serviceRootToken", "serviceType", "showMode", "supportThirdPartyServices", "dropdownWidth", "onServiceChange"]),
        v(P, { divider: !1 }, {
          default: l(() => [
            v(C, {
              type: "primary",
              disabled: !a(t),
              onClick: a(y)
            }, {
              default: l(() => [...m[1] || (m[1] = [
                W("添加", -1)
              ])]),
              _: 1
            }, 8, ["disabled", "onClick"])
          ]),
          _: 1
        })
      ], 2);
    };
  }
}), F = /* @__PURE__ */ S(q, [["__scopeId", "data-v-814536d4"]]), G = /* @__PURE__ */ w({
  name: "MapgisAddData",
  __name: "add-data",
  props: K,
  emits: L,
  setup(s, { emit: r }) {
    const c = r, i = k("add-data");
    return (e, t) => {
      const d = n("a-tab-pane"), p = n("a-tabs");
      return f(), T(p, {
        animated: !1,
        class: _([a(i).b()]),
        "default-active-key": e.defaultActiveKey
      }, {
        default: l(() => [
          h(e.$slots, "beforeUrlTabs", {}, void 0, !0),
          e.$slots.default ? g("", !0) : (f(), T(d, {
            key: "url",
            tab: "通过URL添加",
            class: _(a(i).e("url"))
          }, {
            default: l(() => [
              v(F, {
                serviceRootUrl: e.serviceRootUrl,
                serviceRootToken: e.serviceRootToken,
                serviceType: e.serviceType,
                showMode: e.showMode,
                supportThirdPartyServices: e.supportThirdPartyServices,
                dropdownWidth: e.dropdownWidth,
                onAdd: t[0] || (t[0] = (o) => c("add", o))
              }, null, 8, ["serviceRootUrl", "serviceRootToken", "serviceType", "showMode", "supportThirdPartyServices", "dropdownWidth"])
            ]),
            _: 1
          }, 8, ["class"])),
          e.$slots.default ? h(e.$slots, "default", { key: 1 }, void 0, !0) : g("", !0),
          h(e.$slots, "afterUrlTabs", {}, void 0, !0)
        ]),
        _: 3
      }, 8, ["class", "default-active-key"]);
    };
  }
}), ee = /* @__PURE__ */ S(G, [["__scopeId", "data-v-93bd7f3f"]]);
export {
  F as A,
  ee as a,
  U as b,
  D as c,
  L as d,
  K as e,
  z as f,
  O as g,
  j as h,
  x as u
};
