import "./rolldown-runtime-Dd0fQ6-X.mjs";
import { n as e, r as t } from "./component-HighWayFreeze-C_Y5P0wN.mjs";
import { a as n, n as r, r as i } from "./component-AqiMonitor-DoGm_NCt.mjs";
import { n as a } from "./component-HighwayLiveAlarm-DMdnrD3c.mjs";
import { A as o, C as s, D as c, E as l, M as u, N as d, O as f, P as ee, S as te, T as ne, _ as re, a as ie, b as ae, c as p, d as m, f as h, g, h as _, i as v, j as oe, k as se, l as ce, m as le, n as ue, o as de, p as fe, r as pe, s as me, u as he, v as ge, w as y, x as b, y as x } from "./component-HighwayWeatherForecast-Dn6tjaR-.mjs";
import { n as S } from "./component-LithiumBatteryMiningArea-Dj1DMKuU.mjs";
import { Fragment as C, createElementBlock as w, createElementVNode as T, createVNode as E, defineComponent as D, getCurrentInstance as O, nextTick as k, normalizeStyle as A, onBeforeUnmount as j, onMounted as M, openBlock as N, ref as P, renderList as F, toDisplayString as I, watch as L, withCtx as _e, withDirectives as ve } from "vue";
//#region src/components/TimeBasedForecast/TimeBasedForecast.vue?vue&type=script&setup=true&lang.ts
var R = {
	class: "TimeBasedForecast",
	"element-loading-background": "rgba(0, 0, 0, 0.4)"
}, ye = { class: "TimeBasedForecast__meta" }, be = { class: "TimeBasedForecast__control" }, xe = { 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__ */ r(/* @__PURE__ */ D({
	__name: "TimeBasedForecast",
	props: {
		appKey: {
			type: String,
			default: ""
		},
		appSalt: {
			type: String,
			default: ""
		},
		baseHttp: {
			type: String,
			default: ""
		},
		ids: {
			type: Object,
			default: () => ({})
		}
	},
	emits: ["close"],
	setup(r, { emit: D }) {
		let B = O()?.appContext.config.globalProperties.$bus, V = r, Fe = D, H = P(null), U = null, Ie = [
			"24小时预报",
			"48小时预报",
			"72小时预报",
			"96小时预报",
			"120小时预报",
			"144小时预报",
			"168小时预报"
		], W = P("24小时预报"), G = P(""), K = P([]), q = P([]), J = P(0), Y = P(!1), X = P({});
		M(() => {
			B?.on("toComponent", (e) => {
				e.componentName === "TimeBasedForecast" && (X.value = e.data, Le());
			});
		}), j(() => {
			U?.dispose(), U = null;
		}), L(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"
			}, t = await i({
				appKey: V.appKey,
				appSalt: V.appSalt,
				id: V.ids.data.id,
				variables: { str: S.encode(JSON.stringify(e)) },
				baseHttp: V.baseHttp,
				reqType: V.ids.data.reqType,
				isFormData: V.ids.data.isFormData
			});
			Y.value = !1;
			let n = JSON.parse(t.data.result.output);
			if (n.ds[0].error) return;
			let r = String(n?.ds?.[0]?.observation_time || "");
			G.value = r ? `${r.slice(0, 4)}-${r.slice(4, 6)}-${r.slice(6, 8)} ${r.slice(8, 10)}时` : "", K.value = (Array.isArray(n?.ds) ? n.ds : []).map((e) => {
				let t = String(e.observation_time || ""), n = "--日", r = "--:--";
				if (/^\d{12,14}$/.test(t)) n = `${t.slice(6, 8)}日`, r = `${t.slice(8, 10)}:${t.slice(10, 12)}`;
				else {
					let [e = "", i = ""] = t.split(" "), a = e.includes("/") ? e.split("/") : e.split("-");
					n = a[2] ? `${a[2]}日` : "--日", r = i.slice(0, 5) || "--:--";
				}
				let i = Number(e.temper), a = 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: n,
					_time: r,
					_temp: Number.isFinite(i) ? i : 0,
					_weatherIcon: new URL((/* @__PURE__ */ Object.assign({
						"../../assets/img/weatherIcon/0.gif": ee,
						"../../assets/img/weatherIcon/1.gif": d,
						"../../assets/img/weatherIcon/10.gif": u,
						"../../assets/img/weatherIcon/11.gif": oe,
						"../../assets/img/weatherIcon/12.gif": o,
						"../../assets/img/weatherIcon/13.gif": se,
						"../../assets/img/weatherIcon/14.gif": f,
						"../../assets/img/weatherIcon/15.gif": c,
						"../../assets/img/weatherIcon/16.gif": l,
						"../../assets/img/weatherIcon/17.gif": ne,
						"../../assets/img/weatherIcon/18.gif": y,
						"../../assets/img/weatherIcon/19.gif": s,
						"../../assets/img/weatherIcon/2.gif": te,
						"../../assets/img/weatherIcon/20.gif": b,
						"../../assets/img/weatherIcon/21.gif": ae,
						"../../assets/img/weatherIcon/22.gif": x,
						"../../assets/img/weatherIcon/23.gif": ge,
						"../../assets/img/weatherIcon/24.gif": re,
						"../../assets/img/weatherIcon/25.gif": g,
						"../../assets/img/weatherIcon/26.gif": _,
						"../../assets/img/weatherIcon/27.gif": le,
						"../../assets/img/weatherIcon/28.gif": fe,
						"../../assets/img/weatherIcon/29.gif": h,
						"../../assets/img/weatherIcon/3.gif": m,
						"../../assets/img/weatherIcon/30.gif": he,
						"../../assets/img/weatherIcon/31.gif": ce,
						"../../assets/img/weatherIcon/4.gif": p,
						"../../assets/img/weatherIcon/5.gif": me,
						"../../assets/img/weatherIcon/53.gif": de,
						"../../assets/img/weatherIcon/6.gif": ie,
						"../../assets/img/weatherIcon/7.gif": v,
						"../../assets/img/weatherIcon/8.gif": pe,
						"../../assets/img/weatherIcon/9.gif": ue
					}))[`../../assets/img/weatherIcon/${a}.gif`], import.meta.url).href,
					_windSpeed: `${w}级`
				};
			});
		}, Q = () => {
			q.value = K.value, J.value = Math.max(q.value.length * Pe, 320);
		}, $ = async () => {
			await k(), H.value && (U ? U.resize({
				width: J.value,
				height: z
			}) : U = a(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 (r, i) => {
			let a = e, o = t, s = n;
			return ve((N(), w("div", R, [
				T("div", { class: "TimeBasedForecast__head" }, [T("div", { class: "TimeBasedForecast__head-top" }, [i[1] ||= T("div", null, "分时段预报", -1), T("div", {
					class: "closeBtn",
					onClick: Re,
					title: "关闭"
				})]), i[2] ||= T("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)]),
				T("div", ye, [T("div", be, [i[3] ||= T("span", { class: "TimeBasedForecast__label" }, "预报时效：", -1), E(o, {
					modelValue: W.value,
					"onUpdate:modelValue": i[0] ||= (e) => W.value = e,
					class: "dark-select",
					"popper-class": "dark-select-popper",
					onChange: Z
				}, {
					default: _e(() => [(N(), w(C, null, F(Ie, (e) => E(a, {
						key: e,
						label: e,
						value: e
					}, null, 8, ["label", "value"])), 64))]),
					_: 1
				}, 8, ["modelValue"])]), T("div", xe, I(G.value), 1)]),
				T("div", Se, [T("div", Ce, [T("div", {
					class: "TimeBasedForecast__board",
					style: A({ width: `${J.value}px` })
				}, [
					T("div", we, [(N(!0), w(C, null, F(q.value, (e) => (N(), w("div", {
						key: `${e._date}-${e._time}`,
						class: "TimeBasedForecast__dateItem"
					}, [T("div", Te, I(e._date), 1), T("div", Ee, I(e._time), 1)]))), 128))]),
					T("div", De, [T("div", {
						ref_key: "ref_ForecastChart",
						ref: H,
						class: "TimeBasedForecast__echarts",
						style: A({
							width: `${J.value}px`,
							height: `${z}px`
						})
					}, null, 4)]),
					T("div", Oe, [
						T("div", ke, [(N(!0), w(C, null, F(q.value, (e) => (N(), w("div", {
							key: `icon-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, [T("img", {
							class: "TimeBasedForecast__weatherIcon",
							src: e._weatherIcon,
							alt: e.weather
						}, null, 8, Ae)]))), 128))]),
						T("div", je, [(N(!0), w(C, null, F(q.value, (e) => (N(), w("div", {
							key: `weather-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, I(e.weather), 1))), 128))]),
						T("div", Me, [(N(!0), w(C, null, F(q.value, (e) => (N(), w("div", {
							key: `direction-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, I(e.wind_direction_txt), 1))), 128))]),
						T("div", Ne, [(N(!0), w(C, null, F(q.value, (e) => (N(), w("div", {
							key: `speed-${e._date}-${e._time}`,
							class: "TimeBasedForecast__cell"
						}, I(e._windSpeed), 1))), 128))])
					])
				], 4)])])
			])), [[s, Y.value]]);
		};
	}
}), [["__scopeId", "data-v-cfbdee52"]]);
//#endregion
export { B as t };
