import { n as e, r as t } from "./component-AqiMonitor-BUy1MSaP.mjs";
import { A as n, C as r, D as i, E as ee, M as a, N as o, O as s, P as c, S as l, T as u, _ as d, a as f, b as p, c as m, d as te, f as ne, g as re, h as ie, i as ae, j as oe, k as se, l as ce, m as le, n as ue, o as h, p as g, r as _, s as de, u as fe, v as pe, w as me, x as he, y as ge } from "./component-HighwayWeatherForecast-BplmvdB0.mjs";
import { n as v } from "./component-LithiumBatteryMiningArea-uQetbL3w.mjs";
import { ElLoadingDirective as y, ElOption as b, ElSelect as x } from "element-plus/es";
import { Fragment as S, createElementBlock as C, createElementVNode as w, createVNode as T, defineComponent as E, getCurrentInstance as D, nextTick as O, normalizeStyle as k, onBeforeUnmount as A, onMounted as j, openBlock as M, ref as N, renderList as P, toDisplayString as F, watch as I, withCtx as L, withDirectives as _e } from "vue";
import * as ve from "echarts";
import "element-plus/es/components/select/style/css";
import "element-plus/es/components/option/style/css";
//#region src/components/TimeBasedForecast/TimeBasedForecast.vue?vue&type=script&setup=true&lang.ts
var ye = {
	class: "TimeBasedForecast",
	"element-loading-background": "rgba(0, 0, 0, 0.4)"
}, be = { class: "TimeBasedForecast__meta" }, xe = { class: "TimeBasedForecast__control" }, R = { class: "TimeBasedForecast__time" }, Se = { class: "TimeBasedForecast__content" }, Ce = { class: "TimeBasedForecast__scroll" }, we = { class: "TimeBasedForecast__dates" }, Te = { class: "TimeBasedForecast__date" }, Ee = { class: "TimeBasedForecast__hour" }, De = { class: "TimeBasedForecast__chart" }, Oe = { class: "TimeBasedForecast__table" }, ke = { class: "TimeBasedForecast__row TimeBasedForecast__row--icon" }, Ae = ["src", "alt"], je = { class: "TimeBasedForecast__row" }, Me = { class: "TimeBasedForecast__row" }, Ne = { class: "TimeBasedForecast__row" }, Pe = 78, z = 112, B = /* @__PURE__ */ e(/* @__PURE__ */ E({
	__name: "TimeBasedForecast",
	props: {
		appKey: {
			type: String,
			default: ""
		},
		appSalt: {
			type: String,
			default: ""
		},
		baseHttp: {
			type: String,
			default: ""
		},
		ids: {
			type: Object,
			default: () => ({})
		}
	},
	emits: ["close"],
	setup(e, { emit: E }) {
		let B = D()?.appContext.config.globalProperties.$bus, V = e, Fe = E, H = N(null), U = null, Ie = [
			"24小时预报",
			"48小时预报",
			"72小时预报",
			"96小时预报",
			"120小时预报",
			"144小时预报",
			"168小时预报"
		], W = N("24小时预报"), G = N(""), K = N([]), q = N([]), J = N(0), Y = N(!1), X = N({});
		j(() => {
			B?.on("toComponent", (e) => {
				e.componentName === "TimeBasedForecast" && (X.value = e.data, Le());
			});
		}), A(() => {
			U?.dispose(), U = null;
		}), I(W, async () => {
			Q(), await $();
		});
		let Le = async () => {
			await Z(), Q(), await $();
		}, Re = () => {
			Fe("close", "TimeBasedForecast");
		}, Z = async () => {
			Y.value = !0;
			let e = {
				lon: X.value.longitude,
				lat: X.value.latitude,
				hours: Number(W.value.replace("小时预报", "")),
				unit_id: "3"
			}, y = await t({
				appKey: V.appKey,
				appSalt: V.appSalt,
				id: V.ids.data.id,
				variables: { str: v.encode(JSON.stringify(e)) },
				baseHttp: V.baseHttp,
				reqType: V.ids.data.reqType,
				isFormData: V.ids.data.isFormData
			});
			Y.value = !1;
			let b = JSON.parse(y.data.result.output);
			if (b.ds[0].error) return;
			let x = String(b?.ds?.[0]?.observation_time || "");
			G.value = x ? `${x.slice(0, 4)}-${x.slice(4, 6)}-${x.slice(6, 8)} ${x.slice(8, 10)}时` : "", K.value = (Array.isArray(b?.ds) ? b.ds : []).map((e) => {
				let t = String(e.observation_time || ""), v = "--日", y = "--:--";
				if (/^\d{12,14}$/.test(t)) v = `${t.slice(6, 8)}日`, y = `${t.slice(8, 10)}:${t.slice(10, 12)}`;
				else {
					let [e = "", n = ""] = t.split(" "), r = e.includes("/") ? e.split("/") : e.split("-");
					v = r[2] ? `${r[2]}日` : "--日", y = n.slice(0, 5) || "--:--";
				}
				let b = Number(e.temper), x = e.weatherPhenomenon ?? e.weather_code ?? 0, S = e.wind_grade ?? e.windGrade ?? "-", C = Number(S), w = Number.isFinite(C) && C < 3 ? "<3" : String(S);
				return {
					...e,
					_date: v,
					_time: y,
					_temp: Number.isFinite(b) ? b : 0,
					_weatherIcon: new URL((/* @__PURE__ */ Object.assign({
						"../../assets/img/weatherIcon/0.gif": c,
						"../../assets/img/weatherIcon/1.gif": o,
						"../../assets/img/weatherIcon/10.gif": a,
						"../../assets/img/weatherIcon/11.gif": oe,
						"../../assets/img/weatherIcon/12.gif": n,
						"../../assets/img/weatherIcon/13.gif": se,
						"../../assets/img/weatherIcon/14.gif": s,
						"../../assets/img/weatherIcon/15.gif": i,
						"../../assets/img/weatherIcon/16.gif": ee,
						"../../assets/img/weatherIcon/17.gif": u,
						"../../assets/img/weatherIcon/18.gif": me,
						"../../assets/img/weatherIcon/19.gif": r,
						"../../assets/img/weatherIcon/2.gif": l,
						"../../assets/img/weatherIcon/20.gif": he,
						"../../assets/img/weatherIcon/21.gif": p,
						"../../assets/img/weatherIcon/22.gif": ge,
						"../../assets/img/weatherIcon/23.gif": pe,
						"../../assets/img/weatherIcon/24.gif": d,
						"../../assets/img/weatherIcon/25.gif": re,
						"../../assets/img/weatherIcon/26.gif": ie,
						"../../assets/img/weatherIcon/27.gif": le,
						"../../assets/img/weatherIcon/28.gif": g,
						"../../assets/img/weatherIcon/29.gif": ne,
						"../../assets/img/weatherIcon/3.gif": te,
						"../../assets/img/weatherIcon/30.gif": fe,
						"../../assets/img/weatherIcon/31.gif": ce,
						"../../assets/img/weatherIcon/4.gif": m,
						"../../assets/img/weatherIcon/5.gif": de,
						"../../assets/img/weatherIcon/53.gif": h,
						"../../assets/img/weatherIcon/6.gif": f,
						"../../assets/img/weatherIcon/7.gif": ae,
						"../../assets/img/weatherIcon/8.gif": _,
						"../../assets/img/weatherIcon/9.gif": ue
					}))[`../../assets/img/weatherIcon/${x}.gif`], import.meta.url).href,
					_windSpeed: `${w}级`
				};
			});
		}, Q = () => {
			q.value = K.value, J.value = Math.max(q.value.length * Pe, 320);
		}, $ = async () => {
			await O(), H.value && (U ? U.resize({
				width: J.value,
				height: z
			}) : U = ve.init(H.value), U.setOption({
				animation: !1,
				grid: {
					top: 30,
					right: 0,
					bottom: 8,
					left: 0
				},
				xAxis: {
					type: "category",
					data: q.value.map((e, t) => t),
					show: !1
				},
				yAxis: {
					type: "value",
					show: !1,
					scale: !0
				},
				series: [{
					type: "line",
					data: q.value.map((e) => e._temp),
					smooth: !0,
					symbol: "circle",
					symbolSize: 6,
					clip: !1,
					lineStyle: {
						color: "#4da8ff",
						width: 2
					},
					itemStyle: {
						color: "#4da8ff",
						borderColor: "#9ed0ff"
					},
					label: {
						show: !0,
						position: "top",
						distance: 8,
						color: "#d6ecff",
						fontSize: 12,
						formatter: ({ value: e }) => `${e}℃`
					}
				}]
			}));
		};
		return (e, t) => {
			let n = b, r = x, i = y;
			return _e((M(), C("div", ye, [
				w("div", { class: "TimeBasedForecast__head" }, [w("div", { class: "TimeBasedForecast__head-top" }, [t[1] ||= w("div", null, "分时段预报", -1), w("div", {
					class: "closeBtn",
					onClick: Re,
					title: "关闭"
				})]), t[2] ||= w("img", {
					class: "TimeBasedForecast__head-line",
					src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbsAAAASBAMAAAAwI22/AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAwUExURQAAAAem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/wem/5bu5GYAAAAPdFJOUwAFwAwc2M8ULQYDn/hGXGnV2UoAAAGZSURBVEjH7ZM/S8NAGId/JYGmmeLspptThurk0CHWRXGo0Nk/S50y6CYSHMRF7Efo4uQXEIpbwUnM6OhnEIeChXjv5ZLLXdLtLCX68vDCe0eGJ7/3AJN1VcL+UImB/SruVJwYTqSAW5V3LLyaPR1c+IIdH12OPZiLcyTAjccZEdccZ0Nn4bXpC3KpCuFu5tkdziX3FJxBSBZZdFk9HempCduMk4xSitJTpOgJSSIPrx10YAUB0tYOwrQ1g12k7ZyODIYXZmQpppLV26rtbDFOXVhua2Fn7WTWwUEyAe5Zc2hiLWTTC3jjk8Hw+jrSM9/Z8raKOAtZVmyr9jbpee4lU9hvSUStw6YvOpqwiXlK9d8IL0Oq5tuqvc3KLMs7q9uyCC0y22aKvDVp4u2SjnJ1c+Wecg7h9gV4CFV8NHpEaw7yF2wVGcIa6OBx/Ax3PI6pRWx6Am98alBbpSODNVTxgAbQUpF3KeVv0s80xMUow8N//YVaqWEV9BJDdby2PBUZ1/te0uU0YzeLa623jjrrvaLOep/+str9ACyAtv25BhHcAAAAAElFTkSuQmCC",
					alt: ""
				}, null, -1)]),
				w("div", be, [w("div", xe, [t[3] ||= w("span", { class: "TimeBasedForecast__label" }, "预报时效：", -1), T(r, {
					modelValue: W.value,
					"onUpdate:modelValue": t[0] ||= (e) => W.value = e,
					class: "dark-select",
					"popper-class": "dark-select-popper",
					onChange: Z
				}, {
					default: L(() => [(M(), C(S, null, P(Ie, (e) => T(n, {
						key: e,
						label: e,
						value: e
					}, null, 8, ["label", "value"])), 64))]),
					_: 1
				}, 8, ["modelValue"])]), w("div", R, F(G.value), 1)]),
				w("div", Se, [w("div", Ce, [w("div", {
					class: "TimeBasedForecast__board",
					style: k({ width: `${J.value}px` })
				}, [
					w("div", we, [(M(!0), C(S, null, P(q.value, (e) => (M(), C("div", {
						key: `${e._date}-${e._time}`,
						class: "TimeBasedForecast__dateItem"
					}, [w("div", Te, F(e._date), 1), w("div", Ee, F(e._time), 1)]))), 128))]),
					w("div", De, [w("div", {
						ref_key: "ref_ForecastChart",
						ref: H,
						class: "TimeBasedForecast__echarts",
						style: k({
							width: `${J.value}px`,
							height: `${z}px`
						})
					}, null, 4)]),
					w("div", Oe, [
						w("div", ke, [(M(!0), C(S, null, P(q.value, (e) => (M(), C("div", {
							key: `icon-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, [w("img", {
							class: "TimeBasedForecast__weatherIcon",
							src: e._weatherIcon,
							alt: e.weather
						}, null, 8, Ae)]))), 128))]),
						w("div", je, [(M(!0), C(S, null, P(q.value, (e) => (M(), C("div", {
							key: `weather-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, F(e.weather), 1))), 128))]),
						w("div", Me, [(M(!0), C(S, null, P(q.value, (e) => (M(), C("div", {
							key: `direction-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, F(e.wind_direction_txt), 1))), 128))]),
						w("div", Ne, [(M(!0), C(S, null, P(q.value, (e) => (M(), C("div", {
							key: `speed-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, F(e._windSpeed), 1))), 128))])
					])
				], 4)])])
			])), [[i, Y.value]]);
		};
	}
}), [["__scopeId", "data-v-cfbdee52"]]);
//#endregion
export { B as t };
