import { defineComponent as P, computed as F, ref as f, onMounted as Q, onBeforeUnmount as X, watch as S, createElementBlock as u, openBlock as d, createElementVNode as B, normalizeClass as A, createCommentVNode as L, normalizeStyle as h, Fragment as O, renderList as z, toDisplayString as j, unref as Y } from "vue";
import { cloneDeep as v, isEqual as E } from "lodash";
import $ from "gsap";
import { useFps as Z } from "@vueuse/core";
import { World as _ } from "./utils/map.mjs";
import { initWatch as ee } from "./watch.mjs";
import "three";
import "d3-geo";
import "three/examples/jsm/controls/OrbitControls";
import "three/examples/jsm/loaders/GLTFLoader";
import "three/examples/jsm/loaders/DRACOLoader.js";
import { createHistory as te } from "./utils/mini3d/utils/CreateHistory.mjs";
import "three/examples/jsm/libs/lil-gui.module.min";
import "three/examples/jsm/utils/BufferGeometryUtils";
import "three/examples/jsm/renderers/CSS3DRenderer";
/* empty css                                     */
/* empty css                                     */
import "../../../Interaction/components/Tabs/index.mjs";
import "../../../Interaction/components/Tabs-icon/index.mjs";
import "../../../Interaction/components/Button/index.mjs";
import "../../../Interaction/components/DatePicker/index.mjs";
import "../../../Interaction/components/DatePickerRange/index.mjs";
import "../../../Interaction/components/Switch/index.mjs";
import "../../../Interaction/components/Input/index.mjs";
import "../../../Interaction/components/Select/index.mjs";
import "../../../Interaction/components/Slider/index.mjs";
import "../../../Text/components/List/index.mjs";
import "../../../Text/components/Text/index.mjs";
import "../../../Text/components/TextDynamic/index.mjs";
import "../../../Text/components/TableBasic/index.mjs";
import "../../../Text/components/TableScroll/index.mjs";
import "../../../Text/components/RowScroll/index.mjs";
import "../../../Text/components/RealTime/index.mjs";
import "../../../Text/components/OverNumber/index.mjs";
import "../../../Text/components/CountDown/index.mjs";
import "../../../Text/components/TextCarousel/index.mjs";
import "../../../Media/components/Audio/index.mjs";
import "../../../Media/components/Video/index.mjs";
import "../../../Media/components/Carousel/index.mjs";
import "../../../Media/components/Flv/index.mjs";
import "../../../Media/components/Iframe/index.mjs";
import "../../../Media/components/IframeCarousel/index.mjs";
import "../../../Media/components/Image/index.mjs";
import "../../../Media/components/ImageDynamic/index.mjs";
import "../../../Media/components/M3u8/index.mjs";
import "../../../Media/components/Wavesurfer/index.mjs";
import "../../../Media/components/Weather/index.mjs";
import "../../../Media/components/Qrcode/index.mjs";
import "../../../Chart/components/bar/basic/index.mjs";
import "../../../Chart/components/bar/animation/index.mjs";
import "../../../Chart/components/bar/contrast/index.mjs";
import "../../../Chart/components/bar/contrast2/index.mjs";
import "../../../Chart/components/bar/contrast3/index.mjs";
import "../../../Chart/components/bar/gradient-column-chart/index.mjs";
import "../../../Chart/components/bar/horizontal/index.mjs";
import "../../../Chart/components/bar/horizontal-stack/index.mjs";
import "../../../Chart/components/bar/line-bar/index.mjs";
import "../../../Chart/components/bar/line-bar2/index.mjs";
import "../../../Chart/components/bar/loop/index.mjs";
import "../../../Chart/components/bar/mini/index.mjs";
import "../../../Chart/components/bar/polar/index.mjs";
import "../../../Chart/components/bar/polar-stack/index.mjs";
import "../../../Chart/components/bar/polar2/index.mjs";
import "../../../Chart/components/bar/radius-circle/index.mjs";
import "../../../Chart/components/bar/rank/index.mjs";
import "../../../Chart/components/bar/segmented-progress/index.mjs";
import "../../../Chart/components/bar/spire/index.mjs";
import "../../../Chart/components/bar/stack/index.mjs";
import "../../../Chart/components/bar/stack-line/index.mjs";
import "../../../Chart/components/bar/stack2/index.mjs";
import "../../../Chart/components/bar/stack3/index.mjs";
import "../../../Chart/components/bar/staggered/index.mjs";
import "../../../Chart/components/bar/three/index.mjs";
import "../../../Chart/components/bar/waterfall/index.mjs";
import "../../../Chart/components/bar/zebra/index.mjs";
import "../../../Chart/components/line/area-gradient/index.mjs";
import "../../../Chart/components/line/area-highlight/index.mjs";
import "../../../Chart/components/line/area-highlight2/index.mjs";
import "../../../Chart/components/line/basic/index.mjs";
import "../../../Chart/components/line/bump/index.mjs";
import "../../../Chart/components/line/dashed/index.mjs";
import "../../../Chart/components/line/ladder/index.mjs";
import "../../../Chart/components/line/logarithm/index.mjs";
import "../../../Chart/components/line/multix/index.mjs";
import "../../../Chart/components/line/polar-double/index.mjs";
import "../../../Chart/components/line/rain-flow/index.mjs";
import "../../../Chart/components/line/scale/index.mjs";
import "../../../Chart/components/line/smooth/index.mjs";
import "../../../Chart/components/line/smooth-area/index.mjs";
import "../../../Chart/components/line/stack/index.mjs";
import "../../../Chart/components/line/stack-area/index.mjs";
import "../../../Chart/components/line/temp/index.mjs";
import "../../../Chart/components/line/vertical/index.mjs";
import "../../../Chart/components/map/basic/index.mjs";
import "../../../Chart/components/map/bmap-basic/index.mjs";
import "../../../Chart/components/map/bmap-heatmap/index.mjs";
import "../../../Chart/components/map/bmap-rich/index.mjs";
import "../../../Chart/components/map/customize/index.mjs";
import "../../../Chart/components/map/lines/index.mjs";
import "../../../Chart/components/map/scatter/index.mjs";
import "../../../Chart/components/pie/3d/index.mjs";
import "../../../Chart/components/pie/basic/index.mjs";
import "../../../Chart/components/pie/basic2/index.mjs";
import "../../../Chart/components/pie/customized/index.mjs";
import "../../../Chart/components/pie/index/index.mjs";
import "../../../Chart/components/pie/interval/index.mjs";
import "../../../Chart/components/pie/legend-scroll/index.mjs";
import "../../../Chart/components/pie/radius/index.mjs";
import "../../../Chart/components/pie/rose/index.mjs";
import "../../../Chart/components/pie/round/index.mjs";
import "../../../Chart/components/pie/sunburst/index.mjs";
import "../../../Chart/components/scatter/basic/index.mjs";
import "../../../Chart/components/scatter/basic2/index.mjs";
import "../../../Chart/components/scatter/bubble/index.mjs";
import "../../../Chart/components/scatter/ripples/index.mjs";
import "../../../Chart/components/other/candlestick-basic/index.mjs";
import "../../../Chart/components/other/sunburst-basic/index.mjs";
import "../../../Chart/components/other/sunburst-basic2/index.mjs";
import "../../../Chart/components/other/sunburst-basic3/index.mjs";
import "../../../Chart/components/other/sunburst-basic4/index.mjs";
import "../../../Chart/components/other/sunburst-book/index.mjs";
import "../../../Chart/components/other/sunburst-flavors/index.mjs";
import "../../../Chart/components/other/sunburst-radius/index.mjs";
import "../../../Chart/components/other/funnel/index.mjs";
import "../../../Chart/components/other/funnel-contrast/index.mjs";
import "../../../Chart/components/other/funnel-split/index.mjs";
import "../../../Chart/components/other/funnel2/index.mjs";
import "../../../Chart/components/other/force/index.mjs";
import "../../../Chart/components/other/force2/index.mjs";
import "../../../Chart/components/other/gauge/index.mjs";
import "../../../Chart/components/other/gauge-grade/index.mjs";
import "../../../Chart/components/other/gauge-stage/index.mjs";
import "../../../Chart/components/other/graph-basic/index.mjs";
import "../../../Chart/components/other/graph-basic2/index.mjs";
import "../../../Chart/components/other/graph-calendar/index.mjs";
import "../../../Chart/components/other/circular-graph/index.mjs";
import "../../../Chart/components/other/heatmap/index.mjs";
import "../../../Chart/components/other/liquidfill/index.mjs";
import "../../../Chart/components/other/parallel-basic/index.mjs";
import "../../../Chart/components/other/parallel-mul/index.mjs";
import "../../../Chart/components/other/radar-stack/index.mjs";
import "../../../Chart/components/other/tree/index.mjs";
import "../../../Chart/components/other/tree-line/index.mjs";
import "../../../Chart/components/other/word-cloud/index.mjs";
import "../../../Chart/components/other/treemap/index.mjs";
import "../../../Chart/components/other/treemap-basic/index.mjs";
import "../../../Chart/components/other/label-gauge/index.mjs";
import "../../../Chart/components/other/grid-percentage/index.mjs";
import "../../../Chart/components/other/radar/index.mjs";
import "../../../Commons/components/CustomComponentRender/index.mjs";
import "../../../Commons/components/Graphical/index.mjs";
import "../../../Commons/components/Svg/index.mjs";
import "../../../Commons/components/ModelViewer/index.mjs";
import "../../../Commons/components/VrVideo/index.mjs";
import "../../../Commons/components/VrPhoto/index.mjs";
import "../../../Commons/components/Babylon/index.mjs";
import "../../../Commons/components/Echarts/index.mjs";
import "../../../Commons/components/GSViewer/index.mjs";
import "../Amap2d/index.mjs";
import "../Amap3d/index.mjs";
import "../Default/index.mjs";
import "../Map2d/index.mjs";
import "./index.mjs";
import "../UeIframe/index.mjs";
import "../UeShj/index.mjs";
import "../UnityIframe/index.mjs";
import "../UnityWebgl/index.mjs";
import "../Vr/index.mjs";
import "../Earth/index.mjs";
import { SHJDatasourceV2 as oe } from "../../../../commons/plugins/datasource/index.mjs";
import { SHJParseEvent as s } from "../../../../commons/plugins/event/index.mjs";
import { upgradeMap3d as re } from "./version.mjs";
import { Utils as b } from "../../../../commons/utils/utils.mjs";
const ae = { style: { width: "100%", height: "100%" } }, le = { class: "value" }, ie = ["onClick"], ne = {
  key: 3,
  class: "fps"
}, ce = P({ name: "ShjMap3d" }), Sr = /* @__PURE__ */ P({
  ...ce,
  props: {
    option: {},
    sources: {},
    useEvents: {}
  },
  emits: [
    "on-loaded",
    "on-animated",
    "on-drill-down",
    "on-area-mouseover",
    "on-area-mouseout",
    "on-area-click",
    "on-bar-click",
    "on-scatter-click",
    "on-flyline-click",
    "on-return",
    "on-data-change"
  ],
  setup(l, { expose: T, emit: V }) {
    const a = F(() => re(l.option)), p = V, r = f(), x = f(!1), H = f(!1), w = "zerov-map3d-scene", C = f(), i = new te(), g = f(!1), k = (e = !0) => {
      r.value.cleanAllBar(), r.value.cleanAllScatter(), r.value.cleanAllFlyLine(), r.value.createAllRegionalLevel(), l.sources && l.sources.length > 0 && a.value.widgets.forEach((o, t) => {
        oe.parse({
          sources: [l.sources[t]],
          callback: (n) => {
            try {
              o && o.type === "bar" && r.value.createBar(o, n.data[0].data, !0, e), o && o.type === "scatter" && r.value.createScatter(
                o,
                n.data[0].data,
                !0,
                e
              ), o && o.type === "flyline" && r.value.createFlyLine(
                o,
                n.data[0].data,
                !0,
                e
              ), o && o.type === "regionalLevel" && r.value.createRegionalLevel(
                o,
                n.data[0].data,
                !0,
                e
              ), e && (r.value.createBarTimeLine(), r.value.createScatterTimeLine(), r.value.createFlyLineTimeLine(), r.value.createRegionalLevelTimeLine()), p("on-data-change", n), s.parseEvents(l.useEvents, "on-data-change", n);
            } catch {
              p("on-data-change", null), s.parseEvents(l.useEvents, "on-data-change", null);
            }
          }
        });
      });
    }, N = () => {
      try {
        C.value && document.getElementById(w) && C.value.removeChild(document.getElementById(w));
        const e = document.createElement("canvas");
        e.id = w, e.className = "zerov-map-3d", e.style.width = "100%", e.style.height = "100%", C.value.appendChild(e);
      } catch {
      }
    }, y = (e) => (x.value = !1, H.value = !1, r.value && (r.value.destroy(), r.value = null), N(), new _(
      document.getElementById(w),
      { geoProjectionCenter: [108.55, 36.32] },
      e,
      {
        onAreaMouseover: (t) => {
          p("on-area-mouseover", t), s.parseEvents(l.useEvents, "on-area-mouseover", t);
        },
        onAreaMouseout: (t) => {
          p("on-area-mouseout", t), s.parseEvents(l.useEvents, "on-area-mouseout", t);
        },
        onLoadChild: (t) => {
          if (p("on-area-click", t), s.parseEvents(l.useEvents, "on-area-click", t), t.adcode !== i.present && e.scene.isDrilling && e.scene.defaultMapAdcode !== 1) {
            p("on-drill-down", t), s.parseEvents(l.useEvents, "on-drill-down", t);
            const n = v(e);
            n.scene.defaultMapAdcode = t.adcode, r.value = y(n), i.push(t.adcode), i.past.length <= 0 ? g.value = !1 : g.value = !0;
          }
        },
        onMapSuccess: () => {
          x.value = !0, p("on-loaded"), s.parseEvents(l.useEvents, "on-loaded", null);
        },
        onMapAnimationSuccess: () => {
          k(), H.value = !0, p("on-animated"), s.parseEvents(l.useEvents, "on-animated", null);
        },
        onClickBar: (t) => {
          p("on-bar-click", t), s.parseEvents(l.useEvents, "on-bar-click", t);
        },
        onClickScatter: (t) => {
          p("on-scatter-click", t), s.parseEvents(l.useEvents, "on-scatter-click", t);
        },
        onClickFlyline: (t) => {
          p("on-flyline-click", t), s.parseEvents(l.useEvents, "on-flyline-click", t);
        }
      }
    ));
    Q(() => {
      r.value = y(a.value), i.push(a.value.scene.defaultMapAdcode), ee(
        { option: a.value, sources: l.sources, useEvents: l.useEvents },
        r,
        y,
        k,
        U
      ), window.addEventListener("resize", () => {
        r.value = y(a.value);
      });
    }), X(() => {
      r.value && r.value.destroy();
    });
    const I = () => {
      p("on-return", {
        parentAdcode: i.past[i.past.length - 1],
        adcode: i.present
      }), s.parseEvents(l.useEvents, "on-return", {
        parentAdcode: i.past[i.past.length - 1],
        adcode: i.present
      }), i.undo();
      const e = v(a.value);
      e.scene.defaultMapAdcode = i.present, r.value = y(e), i.past.length <= 0 ? g.value = !1 : g.value = !0;
    }, U = () => {
      i.empty(), i.push(a.value.scene.defaultMapAdcode), r.value = y(a.value), i.past.length <= 0 ? g.value = !1 : g.value = !0;
    }, D = (e, o, t) => {
      $.timeline().add(
        $.to(r.value.camera.instance.position, {
          duration: 2,
          delay: 0,
          x: e,
          y: o,
          z: t,
          ease: "circ.out"
        })
      );
    };
    T({
      refresh: () => k(),
      refreshView: () => k(),
      refreshData: () => k(),
      // 返回上一级
      goBack: () => I(),
      // 更新相机位置
      setCameraPosition: (e, o, t) => D(e, o, t)
    });
    const J = Z(), M = f(), q = (e) => {
      if (M.value && e) {
        const o = `url(${e.backgroundImage})`;
        return {
          ...b.json2cssObject(e.background),
          ...b.json2cssObject(e.border),
          ...b.json2cssObject(e.text),
          left: a.value.backButton.left + "%",
          bottom: a.value.backButton.bottom + "%",
          "background-image": o
        };
      }
      return {};
    }, m = f(v(a.value.widgets)), c = F(() => {
      try {
        const e = m.value.filter(
          (o) => o.type === "regionalLevel"
        );
        return e.length > 0 ? e[0].isHide ? null : e[0] : null;
      } catch {
        return null;
      }
    });
    S(
      () => v(a.value.widgets),
      (e, o) => {
        try {
          !E(e, o) && r.value && (m.value = v(a.value.widgets));
        } catch {
        }
      },
      {
        deep: !0
      }
    ), S(
      () => v(m.value.filter((e) => e.type === "bar")),
      (e, o) => {
        try {
          !E(e, o) && r.value && e.length === o.length && e.forEach((t) => {
            r.value.createBar(t, void 0, !1);
          });
        } catch {
        }
      },
      {
        deep: !0
      }
    ), S(
      () => v(m.value.filter((e) => e.type === "scatter")),
      (e, o) => {
        try {
          !E(e, o) && r.value && e.length === o.length && e.forEach((t) => {
            r.value.createScatter(t, void 0, !1);
          });
        } catch {
        }
      },
      {
        deep: !0
      }
    ), S(
      () => v(m.value.filter((e) => e.type === "flyline")),
      (e, o) => {
        try {
          !E(e, o) && r.value && e.length === o.length && e.forEach((t) => {
            r.value.createFlyLine(t, void 0, !1);
          });
        } catch {
        }
      },
      {
        deep: !0
      }
    ), S(
      () => v(m.value.filter((e) => e.type === "regionalLevel")),
      (e, o) => {
        try {
          !E(e, o) && r.value && e.length === o.length && e.forEach((t) => {
            r.value.createRegionalLevel(t, void 0, !1);
          });
        } catch {
        }
      },
      {
        deep: !0
      }
    );
    const G = (e) => {
      try {
        e.isHide === void 0 ? e.isHide = !0 : e.isHide = !e.isHide;
      } catch {
      }
    }, K = () => {
      try {
        const e = m.value.every((o) => !o.isHide);
        m.value.forEach((o) => o.isHide = e);
      } catch {
      }
    }, W = (e) => {
      const o = `url(${e.backgroundImage})`, t = `url(${R(e.hover.backgroundImage)})`, n = `url(${R(e.active.backgroundImage)})`;
      return {
        ...b.json2cssObject(e),
        ...b.json2cssObject(e.hover, "hover"),
        ...b.json2cssObject(e.active, "active"),
        "background-image": o,
        "--hover-background-image": t,
        "--active-background-image": n
      };
    }, R = (e) => !e.startsWith("http") && !e.startsWith("//") ? "../" + e : e;
    return (e, o) => (d(), u("div", ae, [
      B("div", {
        ref_key: "map3dWrapRef",
        ref: C,
        class: A(["map-3d-wrap", { show: x.value }])
      }, [
        H.value && g.value && a.value.backButton.show ? (d(), u("div", {
          key: 0,
          ref_key: "buttonRef",
          ref: M,
          class: "return-btn",
          style: h(q(a.value.backButton)),
          onClick: I
        }, " 返回上一级 ", 4)) : L("", !0),
        c.value ? (d(), u("div", {
          key: 1,
          class: "regional-level",
          style: h({
            left: c.value.labelStyle.left + "%",
            top: c.value.labelStyle.top + "%",
            flexDirection: c.value.labelStyle.direction,
            gap: c.value.labelStyle.gap + "px",
            fontSize: c.value.labelStyle.fontSize + "px",
            fontFamily: c.value.labelStyle.fontFamily,
            fontStyle: c.value.labelStyle.fontStyle,
            color: c.value.labelStyle.color,
            "--color-width": c.value.labelStyle.colorStyle.width + "px",
            "--color-height": c.value.labelStyle.colorStyle.height + "px",
            "--color-borderRadius": c.value.labelStyle.colorStyle.borderRadius + "px"
          })
        }, [
          (d(!0), u(O, null, z(c.value.rules, (t, n) => (d(), u("div", {
            key: n,
            class: "item"
          }, [
            B("div", {
              class: "color",
              style: h({ backgroundColor: t.color })
            }, null, 4),
            B("span", le, j(t.label), 1)
          ]))), 128))
        ], 4)) : L("", !0),
        a.value.widgets.length > 0 && a.value.widgetControlStyle && a.value.widgetControlStyle.show ? (d(), u("div", {
          key: 2,
          class: "widget-control",
          style: h({
            left: a.value.widgetControlStyle.left + "%",
            top: a.value.widgetControlStyle.top + "%",
            flexDirection: a.value.widgetControlStyle.direction,
            gap: a.value.widgetControlStyle.gap + "px",
            "--widget-width": a.value.widgetControlStyle.width + "px",
            "--widget-height": a.value.widgetControlStyle.height + "px"
          })
        }, [
          B("div", {
            class: A(["control-button", {
              active: m.value.every((t) => !t.isHide)
            }]),
            style: h(W(a.value.widgetControlStyle)),
            onClick: K
          }, j(m.value.every((t) => !t.isHide) ? "隐藏" : "显示") + "/全部 ", 7),
          (d(!0), u(O, null, z(m.value, (t) => (d(), u("div", {
            key: t.id,
            class: A(["control-button", {
              active: !t.isHide
            }]),
            style: h(W(a.value.widgetControlStyle)),
            onClick: (n) => G(t)
          }, j(t.name || "-"), 15, ie))), 128))
        ], 4)) : L("", !0),
        a.value.debugger ? (d(), u("div", ne, "fps:" + j(Y(J)), 1)) : L("", !0)
      ], 2)
    ]));
  }
});
export {
  Sr as default
};
