import { defineComponent as d, onMounted as J, computed as a, shallowRef as b, ref as u, watch as j, createElementBlock as E, openBlock as c, createElementVNode as H, createBlock as V, createCommentVNode as O, unref as P } from "vue";
import { useVueImportMap as x, Sandbox as N, useStore as k } from "@vue/repl";
import { useWatch as D } from "./hooks/useWatch.mjs";
/* 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 "./index.mjs";
import "../Graphical/index.mjs";
import "../Svg/index.mjs";
import "../ModelViewer/index.mjs";
import "../VrVideo/index.mjs";
import "../VrPhoto/index.mjs";
import "../Babylon/index.mjs";
import "../Echarts/index.mjs";
import "../GSViewer/index.mjs";
import "../../../Scene/components/Amap2d/index.mjs";
import "../../../Scene/components/Amap3d/index.mjs";
import "../../../Scene/components/Default/index.mjs";
import "../../../Scene/components/Map2d/index.mjs";
import "../../../Scene/components/Map3d/index.mjs";
import "../../../Scene/components/UeIframe/index.mjs";
import "../../../Scene/components/UeShj/index.mjs";
import "../../../Scene/components/UnityIframe/index.mjs";
import "../../../Scene/components/UnityWebgl/index.mjs";
import "../../../Scene/components/Vr/index.mjs";
import "../../../Scene/components/Earth/index.mjs";
import { SHJDatasourceV2 as M } from "../../../../commons/plugins/datasource/index.mjs";
import { SHJParseEvent as T } from "../../../../commons/plugins/event/index.mjs";
import "lodash";
import { upgradeCustomComponentRender as _ } from "./version.mjs";
const B = { class: "custom-component-render" }, R = { class: "preview-content" }, $ = d({ name: "ShjCustomComponentRender" }), Ir = /* @__PURE__ */ d({
  ...$,
  props: {
    option: {},
    sources: {},
    useEvents: {}
  },
  setup(i, { expose: f }) {
    J(() => {
      window.SHJDatasourceV2 = M, window.SHJParseEvent = T;
    });
    const e = a(() => _(i.option)), { productionMode: p, vueVersion: v, importMap: h } = x(), w = a(() => ({
      script: {
        inlineTemplate: p.value,
        isProd: p.value,
        propsDestructure: !0
      },
      style: {
        isProd: p.value
      },
      template: {
        isProd: p.value
      }
    })), o = b(null), t = u(!0), l = u(""), S = () => {
      const s = e.value.base.hash;
      if (!(l.value === s && o.value)) {
        l.value = s, t.value = !0;
        try {
          const r = k(
            { builtinImportMap: h, vueVersion: v, sfcOptions: w },
            s
          );
          r.files["src/source.json"] && (r.files["src/source.json"].code = JSON.stringify(i.sources, null, 2)), r.files["src/option.json"] && (r.files["src/option.json"].code = JSON.stringify(
            e.value.base.option,
            null,
            2
          )), o.value = r, t.value = !1;
        } catch {
          t.value = !1;
        }
      }
    };
    j(
      () => e.value.base.hash,
      () => {
        S();
      },
      { immediate: !0 }
    );
    const m = () => {
      o.value && (t.value = !0, o.value.files["src/source.json"] && (o.value.files["src/source.json"].code = JSON.stringify(
        i.sources,
        null,
        2
      )), setTimeout(() => {
        t.value = !1;
      }, 10));
    }, n = () => {
      o.value && (t.value = !0, o.value.files["src/option.json"] && (o.value.files["src/option.json"].code = JSON.stringify(
        e.value.base.option,
        null,
        2
      )), setTimeout(() => {
        t.value = !1;
      }, 10));
    };
    D(
      {
        option: e,
        sources: i.sources
      },
      m,
      n
    ), f({
      refresh: () => {
        n(), m();
      },
      refreshView: () => {
        n(), m();
      },
      refreshData: () => {
        m();
      }
    });
    const g = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-plus/dist/index.css" />', y = '<link rel="stylesheet" href="https://lganv-1304359499.cos.ap-beijing.myqcloud.com/lg_cos_static/TEST/CesiumUnminified/Widgets/widgets.css" />', C = a(() => ({
      customCode: {
        useCode: `
      /** 导入山河鉴必须的变量 **/
      window.useEvents = ${JSON.stringify(i.useEvents)};
      window.SHJDatasourceV2 = window.parent.SHJDatasourceV2;
      window.SHJParseEvent = window.parent.SHJParseEvent;
    `
      },
      headHTML: `
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      html,
      body,
      #app {
        height: 100%;
        overflow: hidden;
      }
    </style>
    ${g}
    ${y}
  `
    }));
    return (s, r) => (c(), E("div", B, [
      H("div", R, [
        !t.value && o.value ? (c(), V(P(N), {
          key: 0,
          store: o.value,
          "clear-console": !1,
          "preview-options": C.value
        }, null, 8, ["store", "preview-options"])) : O("", !0)
      ])
    ]));
  }
});
export {
  Ir as default
};
