import { defineComponent as O, watch as D, createElementBlock as m, openBlock as a, createCommentVNode as u, normalizeStyle as c, unref as e, toDisplayString as p, createTextVNode as R, ref as v, onMounted as W, onBeforeUnmount as B } from "vue";
import C from "axios";
import "../text-text-basic/index.mjs";
import "../text-table-basic/index.mjs";
import "../chart-other-gauge/index.mjs";
import "../chart-other-gauge-stage/index.mjs";
import "../chart-other-gauge-grade/index.mjs";
import "../chart-other-word-cloud/index.mjs";
import "../chart-other-liquidfill/index.mjs";
import "../chart-other-funnel/index.mjs";
import "../chart-other-force/index.mjs";
import "../chart-other-radar/index.mjs";
import "../chart-other-funnel-split/index.mjs";
import "../chart-other-funnel-contrast/index.mjs";
import "../chart-other-candlestick-basic/index.mjs";
import "../chart-other-candlestick-shanghai/index.mjs";
import "../chart-other-candlestick-demo/index.mjs";
import "../chart-other-heatmap/index.mjs";
import "../chart-other-force2/index.mjs";
import "../chart-other-graph-basic/index.mjs";
import "../chart-other-graph-basic2/index.mjs";
import "../chart-other-graph-calendar/index.mjs";
import "../chart-other-tree-line/index.mjs";
import "../chart-other-treemap-basic/index.mjs";
import "../chart-other-sunburst-basic/index.mjs";
import "../chart-other-sunburst-basic2/index.mjs";
import "../chart-other-sunburst-basic3/index.mjs";
import "../chart-other-sunburst-basic4/index.mjs";
import "../chart-other-sunburst-book/index.mjs";
import "../chart-other-sunburst-radius/index.mjs";
import "../chart-other-sunburst-flavors/index.mjs";
import "../chart-other-parallel-basic/index.mjs";
import "../chart-other-parallel-mul/index.mjs";
import "../chart-other-circular-graph/index.mjs";
import "../map-earth-basic/index.mjs";
import "../map-earth-cool-tech/index.mjs";
import "../map-earth-particle/index.mjs";
import "../map-earth-hacker/index.mjs";
import "../map-earth-fly-line/index.mjs";
import "../chart-other-grid-percentage/index.mjs";
import "../chart-other-radar-stack/index.mjs";
import "../chart-other-funnel2/index.mjs";
import "../chart-other-label-gauge/index.mjs";
import "../chart-other-theme-river/index.mjs";
import "../chart-other-tree/index.mjs";
import "../chart-other-treemap/index.mjs";
import "../commons-product-model/index.mjs";
import "../commons-vr-photo/index.mjs";
import "../commons-vr-video/index.mjs";
import "../commons-three-loader/index.mjs";
import "../commons-three-loader3/index.mjs";
import "../commons-loop-iterator/index.mjs";
import "../commons-gaussian-splatting-view/index.mjs";
import "../commons-babylon/index.mjs";
import "../commons-svg/index.mjs";
import "../commons-weather/index.mjs";
import "./index.mjs";
import "../media-wavesurfer/index.mjs";
import "../interaction-tabs/index.mjs";
import "../interaction-tabs2/index.mjs";
import "../interaction-button/index.mjs";
import "../interaction-button-image/index.mjs";
import "../interaction-select/index.mjs";
import "../interaction-input/index.mjs";
import "../interaction-radio/index.mjs";
import "../interaction-slider/index.mjs";
import "../interaction-switch/index.mjs";
import "../interaction-data-picker/index.mjs";
import "../interaction-button-refresh/index.mjs";
import "../media-image/index.mjs";
import "../text-title/index.mjs";
import "../commons-qrcode/index.mjs";
import "../media-video/index.mjs";
import "../media-audio/index.mjs";
import "../text-real-time/index.mjs";
import "../media-carousel/index.mjs";
import "../media-carousel-slides/index.mjs";
import "../media-iframe-carousel/index.mjs";
import "../media-iframe/index.mjs";
import "../media-m3u8/index.mjs";
import "../media-m3u8-dynamic/index.mjs";
import "../media-audio-dynamic/index.mjs";
import "../media-video-dynamic/index.mjs";
import "../media-image-dynamic/index.mjs";
import "../media-iframe-dynamic/index.mjs";
import "../media-flv/index.mjs";
import "../commons-echarts/index.mjs";
import "../text-over-number/index.mjs";
import "../text-table-scroll/index.mjs";
import "../text-carousel/index.mjs";
import "../text-row-scroll/index.mjs";
import "../text-text-dynamic/index.mjs";
import "../text-count-down/index.mjs";
import "../graphical-circle/index.mjs";
import "../graphical-diamond/index.mjs";
import "../graphical-hexagon/index.mjs";
import "../graphical-isosceles-triangle/index.mjs";
import "../graphical-pentagon/index.mjs";
import "../graphical-rect/index.mjs";
import "../graphical-right-triangle/index.mjs";
import "../scene-map3d/index.mjs";
import "../scene-amap2d/index.mjs";
import "../scene-amap3d/index.mjs";
import "../scene-vr/index.mjs";
import "../scene-unity-iframe/index.mjs";
import "../scene-unity-webgl/index.mjs";
import "../scene-ue-iframe/index.mjs";
import "../scene-ue-shj/index.mjs";
import "../scene-default/index.mjs";
import "../interaction/tabs/index.mjs";
import "../interaction/tabs-icon/index.mjs";
import "../interaction/button/index.mjs";
import "../interaction/date-picker/src/date-picker/index.mjs";
import "../interaction/date-picker/src/date-picker-range/index.mjs";
import "../text/list/index.mjs";
import "../chart/src/bar/basic/index.mjs";
import "../chart/src/bar/animation/index.mjs";
import "../chart/src/bar/contrast/index.mjs";
import "../chart/src/bar/contrast2/index.mjs";
import "../chart/src/bar/contrast3/index.mjs";
import "../chart/src/bar/gradient-column-chart/index.mjs";
import "../chart/src/bar/horizontal/index.mjs";
import "../chart/src/bar/horizontal-stack/index.mjs";
import "../chart/src/bar/line-bar/index.mjs";
import "../chart/src/bar/line-bar2/index.mjs";
import "../chart/src/bar/loop/index.mjs";
import "../chart/src/bar/mini/index.mjs";
import "../chart/src/bar/polar/index.mjs";
import "../chart/src/bar/polar-stack/index.mjs";
import "../chart/src/bar/polar2/index.mjs";
import "../chart/src/bar/radius-circle/index.mjs";
import "../chart/src/bar/rank/index.mjs";
import "../chart/src/bar/segmented-progress/index.mjs";
import "../chart/src/bar/spire/index.mjs";
import "../chart/src/bar/stack/index.mjs";
import "../chart/src/bar/stack-line/index.mjs";
import "../chart/src/bar/stack2/index.mjs";
import "../chart/src/bar/stack3/index.mjs";
import "../chart/src/bar/staggered/index.mjs";
import "../chart/src/bar/three/index.mjs";
import "../chart/src/bar/waterfall/index.mjs";
import "../chart/src/bar/zebra/index.mjs";
import "../chart/src/line/area-gradient/index.mjs";
import "../chart/src/line/area-highlight/index.mjs";
import "../chart/src/line/area-highlight2/index.mjs";
import "../chart/src/line/basic/index.mjs";
import "../chart/src/line/bump/index.mjs";
import "../chart/src/line/dashed/index.mjs";
import "../chart/src/line/ladder/index.mjs";
import "../chart/src/line/logarithm/index.mjs";
import "../chart/src/line/multix/index.mjs";
import "../chart/src/line/polar-double/index.mjs";
import "../chart/src/line/rain-flow/index.mjs";
import "../chart/src/line/scale/index.mjs";
import "../chart/src/line/smooth/index.mjs";
import "../chart/src/line/smooth-area/index.mjs";
import "../chart/src/line/stack/index.mjs";
import "../chart/src/line/stack-area/index.mjs";
import "../chart/src/line/temp/index.mjs";
import "../chart/src/line/vertical/index.mjs";
import "../chart/src/map/basic/index.mjs";
import "../chart/src/map/bmap-basic/index.mjs";
import "../chart/src/map/bmap-heatmap/index.mjs";
import "../chart/src/map/bmap-rich/index.mjs";
import "../chart/src/map/customize/index.mjs";
import "../chart/src/map/lines/index.mjs";
import "../chart/src/map/scatter/index.mjs";
import "../chart/src/pie/3d/index.mjs";
import "../chart/src/pie/basic/index.mjs";
import "../chart/src/pie/basic2/index.mjs";
import "../chart/src/pie/customized/index.mjs";
import "../chart/src/pie/index/index.mjs";
import "../chart/src/pie/interval/index.mjs";
import "../chart/src/pie/legend-scroll/index.mjs";
import "../chart/src/pie/radius/index.mjs";
import "../chart/src/pie/rose/index.mjs";
import "../chart/src/pie/round/index.mjs";
import "../chart/src/pie/sunburst/index.mjs";
import "../chart/src/scatter/basic/index.mjs";
import "../chart/src/scatter/basic2/index.mjs";
import "../chart/src/scatter/bubble/index.mjs";
import "../chart/src/scatter/ripples/index.mjs";
/* empty css                        */
/* empty css                               */
import { SHJDatasourceV2 as H } from "../../plugins/datasource/index.mjs";
import { SHJParseEvent as b } from "../../plugins/event/index.mjs";
import "lodash";
import { autoInstallFont as A, jsonToCssStyle as F } from "../../commons/utils/json2css.mjs";
const M = {
  key: 0,
  class: "weather-temperature__suffix"
}, V = O({ name: "zv-commons-weather-dynamic" }), de = /* @__PURE__ */ O({
  ...V,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "on-success",
    "on-error"
  ],
  setup(k, { emit: S }) {
    const i = k, w = S, $ = () => {
      const t = v(), s = v({
        city: "",
        date: "",
        week: "",
        dayweather: "",
        nightweather: "",
        daytemp: "",
        nighttemp: "",
        daywind: "",
        nightwind: "",
        daypower: "",
        nightpower: "",
        daytemp_float: "",
        nighttemp_float: ""
      }), l = v(null), d = (r) => {
        H.parse({
          tId: i.uuid,
          sources: i.sources,
          callback: ({ data: y }) => {
            const f = y[0].data[0];
            C.get(`https://restapi.amap.com/v3/weather/weatherInfo?city=${f.adcode}&key=${f.key}&extensions=all`).then((o) => {
              o.status === 200 && o.data.status === "1" && o.data.forecasts.length > 0 ? (w("on-success", o), b.parseEvents(i.useEvents, "on-success", o), s.value = o.data.forecasts[0].casts[0], s.value.city = o.data.forecasts[0].city) : (w("on-error", o), b.parseEvents(i.useEvents, "on-error", o));
            }).catch(() => {
              w("on-error", null), b.parseEvents(i.useEvents, "on-error", null);
            });
          }
        });
      }, T = (r) => (r.fontFamily && A(r.fontFamily), {
        ...F(r),
        lineHeight: `${r.lineHeight}px`,
        transform: `translate(${r.transform.x}px, ${r.transform.y}px)`
      }), U = (r, y) => {
        if (y.find((o) => o.name === s.value.dayweather)) {
          const o = y.find((z) => z.name === s.value.dayweather).url || "";
          return {
            mask: `url(${o}) 0px 0px / 100% 100%`,
            width: `${r.size}px`,
            height: `${r.size}px`,
            background: `url(${o}) 0px 0px / 100% 100%, ${r.color}`,
            backgroundBlendMode: "overlay",
            marginRight: `${r.margin.right}px`
          };
        }
        return {};
      }, g = (r) => {
        l.value && clearInterval(l.value), r.autoUpdate !== 0 ? l.value = setInterval(() => d(), r.autoUpdate * 1e3) : (clearInterval(l.value), d());
      };
      return W(() => {
        d(i.basicOption), g(i.basicOption);
      }), B(() => {
        l.value && clearInterval(l.value);
      }), {
        initWeatherMessage: d,
        rendererDomStyle: T,
        handleAutoUpdate: g,
        rendererWeatherTypeStyle: U,
        weatherRef: t,
        weather: s
      };
    }, { handleAutoUpdate: x, rendererDomStyle: h, rendererWeatherTypeStyle: E, weatherRef: I, weather: n } = $();
    return D(() => i.basicOption, () => x(i.basicOption), { deep: !0 }), (t, s) => (a(), m("div", {
      ref_key: "weatherRef",
      ref: I,
      class: "zerov-widgets"
    }, [
      t.basicOption.icon.show ? (a(), m("p", {
        key: 0,
        class: "weather-icon",
        style: c(e(E)(t.basicOption.icon, t.basicOption.icons))
      }, null, 4)) : u("", !0),
      t.basicOption.weather.city.show ? (a(), m("p", {
        key: 1,
        class: "weather-city",
        style: c(e(h)(t.basicOption.weather.city.textStyle))
      }, p(e(n).city), 5)) : u("", !0),
      t.basicOption.weather.type.show ? (a(), m("p", {
        key: 2,
        class: "weather-type",
        style: c(e(h)(t.basicOption.weather.type.textStyle))
      }, p(e(n).dayweather), 5)) : u("", !0),
      t.basicOption.weather.wind.show ? (a(), m("p", {
        key: 3,
        class: "weather-wind",
        style: c(e(h)(t.basicOption.weather.wind.textStyle))
      }, p(e(n).daywind) + "风" + p(e(n).daypower) + "级 ", 5)) : u("", !0),
      t.basicOption.weather.temperature.show ? (a(), m("p", {
        key: 4,
        class: "weather-temperature",
        style: c(e(h)(t.basicOption.weather.temperature.textStyle))
      }, [
        R(p(e(n).nighttemp) + " " + p(t.basicOption.weather.temperature.connectors) + " " + p(e(n).daytemp) + " ", 1),
        t.basicOption.weather.temperature.suffix.show ? (a(), m("span", M, p(t.basicOption.weather.temperature.suffix.suffix), 1)) : u("", !0)
      ], 4)) : u("", !0)
    ], 512));
  }
});
export {
  de as default
};
