import "./rolldown-runtime-Dd0fQ6-X.mjs";
import { A as e, S as t, j as n, m as r } from "./component-HighWayFreeze-C_Y5P0wN.mjs";
import { a as i, n as a, r as o } from "./component-AqiMonitor-DoGm_NCt.mjs";
import "./component-ImageGeneration-Ch_ajmOP.mjs";
import { n as s } from "./component-HighwayLiveAlarmNew-KR4OZB7F.mjs";
import { n as c } from "./component-HighWayEarlyWarningRed-D89gFa50.mjs";
import { Fragment as l, computed as u, createBlock as ee, createCommentVNode as te, createElementBlock as d, createElementVNode as f, createTextVNode as p, createVNode as m, defineComponent as h, nextTick as ne, normalizeClass as g, normalizeStyle as _, onBeforeUnmount as re, onMounted as ie, openBlock as v, ref as y, renderList as b, toDisplayString as x, unref as S, vShow as C, watch as w, withCtx as T, withDirectives as E } from "vue";
//#region src/components/RadarShortTerm/RadarShortTerm.vue?vue&type=script&setup=true&lang.ts
var ae = {
	class: "RadarShortTerm",
	"element-loading-background": "rgba(0, 0, 0, 0.4)"
}, oe = { class: "RadarShortTerm-setting-panel" }, se = { class: "display-setting" }, ce = { class: "setting-row setting-row-pile" }, le = { class: "setting-pile-options" }, ue = { class: "RadarShortTerm-table" }, de = { class: "table-body" }, fe = ["onClick"], pe = { class: "name" }, me = ["onClick"], he = {
	key: 0,
	style: { color: "red" }
}, ge = { class: "pile-panel" }, _e = {
	key: 0,
	class: "pile-body"
}, ve = ["onClick"], ye = {
	key: 1,
	class: "pile-empty"
}, be = { class: "RadarShortTerm-timeline" }, xe = ["title"], Se = { class: "timeline-slider-wrap" }, Ce = { class: "timeline-time-label" }, we = { class: "radarAxis-li" }, Te = ["onClick"], Ee = { class: "radarAxis-li-node-text" }, D = /* @__PURE__ */ a(/* @__PURE__ */ h({
	__name: "RadarShortTerm",
	props: {
		appKey: {
			type: String,
			default: ""
		},
		appSalt: {
			type: String,
			default: ""
		},
		baseHttp: {
			type: String,
			default: ""
		},
		ids: {
			type: Object,
			default: () => ({})
		}
	},
	emits: [
		"close",
		"addDataTitle",
		"removeDataTitle",
		"showRadarLegend",
		"toMapView",
		"addImageAniArr",
		"clearImgAniArr",
		"setImgAniShowByIndex",
		"changeLoading"
	],
	setup(a, { emit: h }) {
		let D = a, O = h, k = y(!0), A = y(!1), j = y(0), M = y(null), N = y([]), P = y({}), F = y({}), I = y({}), L = y(""), R = y(null), z = y(!0), B = y(null), V = y(!0), H = y(null), U = y({
			httpurl: "",
			lngStart: void 0,
			latStart: void 0,
			lngEnd: void 0,
			latEnd: void 0
		}), W = y({
			httpurl: "",
			lngStart: void 0,
			latStart: void 0,
			lngEnd: void 0,
			latEnd: void 0
		});
		ie(() => {
			G(), B.value = setInterval(() => {
				G();
			}, 1e3 * 60 * 10);
		}), re(() => {
			Q(), clearInterval(B.value), B.value = null;
		});
		let G = async () => {
			z.value = !0, await K(), N.value = (await De()).map((e) => {
				let t = Ae(e), n = je(e.zhflds || []);
				return {
					name: e.name,
					tags: Me(t),
					piles: n
				};
			}), ke(), z.value = !1;
		}, K = async () => {
			z.value = !0;
			let e = await o({
				appKey: D.appKey,
				appSalt: D.appSalt,
				id: D.ids.radar.id,
				variables: {},
				baseHttp: D.baseHttp,
				reqType: D.ids.radar.reqType,
				isFormData: D.ids.radar.isFormData
			});
			console.log("雷达", e.data.result);
			let t = await o({
				appKey: D.appKey,
				appSalt: D.appSalt,
				id: D.ids.historyRadar.id,
				variables: {},
				baseHttp: D.baseHttp,
				reqType: D.ids.historyRadar.reqType,
				isFormData: D.ids.historyRadar.isFormData
			});
			console.log("历史雷达", t.data.result), z.value = !1;
			let n = q(e.data.result), r = q(t.data.result);
			U.value = {
				httpurl: n.httpurl,
				...n.extent
			}, W.value = {
				httpurl: r.httpurl,
				...r.extent
			};
			let i = r.frames.slice(-3).map((e, t) => ({
				...e,
				focarcast_time: e.observation_time,
				_isHistory: !0,
				_label: t === 0 ? "-2" : t === 1 ? "-1" : "现在",
				_httpurl: (r.httpurl || "") + (e.observation_time || "").slice(0, 10).replaceAll("-", "") + "/"
			})), a = n.frames.map((e, t) => ({
				...e,
				_isHistory: !1,
				_label: `+${t + 1}`,
				_httpurl: n.httpurl || ""
			})), s = [...i, ...a];
			I.value = {
				ds: s,
				httpurl: n.httpurl,
				...r.extent
			}, j.value = 2, k.value && (O("clearImgAniArr"), s.forEach((e) => {
				let t = Fe(e);
				t && O("addImageAniArr", { data: { imgArr: [t] } });
			}), setTimeout(() => {
				O("setImgAniShowByIndex", { index: j.value });
				let e = s[j.value];
				Ie(e), O("showRadarLegend", !0);
			}, 1e3));
		}, De = async () => {
			let e = await o({
				appKey: D.appKey,
				appSalt: D.appSalt,
				id: D.ids.shortTerm.id,
				variables: {},
				baseHttp: D.baseHttp,
				reqType: D.ids.shortTerm.reqType,
				isFormData: D.ids.shortTerm.isFormData
			});
			return console.log("短时预报", e.data.result.ds), e.data.result.ds || [];
		}, Oe = (e) => {
			let t = String(e || "").split(",").map((e) => Number(e.trim()));
			return {
				latStart: t[0],
				latEnd: t[1],
				lngStart: t[2],
				lngEnd: t[3]
			};
		}, q = (e) => {
			let t = Array.isArray(e?.ds) ? e : e?.ds, n = Array.isArray(t?.ds) ? t.ds : [];
			n = [...n].reverse();
			let r = Oe(n[0]?.extendstr || ""), i = t?.httpUrl || t?.httpurl || "";
			return {
				frames: n,
				httpurl: i,
				extent: r
			};
		}, J = u(() => Ne(N.value, (e) => Z(e.tags))), Y = u(() => I.value?.ds || []), X = u(() => Y.value.map((e) => {
			let t = new Date(e.focarcast_time);
			return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`;
		})), ke = () => {
			let e = J.value.find((e) => Z(e.tags)), t = {}, n = {};
			e && (t[e.name] = !0, n[e.name] = !0), P.value = t, F.value = n;
		}, Ae = (e) => {
			let t = e.zhflds || [];
			return {
				iswarnpre1h: t.some((e) => e?.iswarnpre1h === 1) ? 1 : 0,
				iswarnpre2h: t.some((e) => e?.iswarnpre2h === 1) ? 1 : 0,
				iswarnpre3h: t.some((e) => e?.iswarnpre3h === 1) ? 1 : 0
			};
		}, je = (e) => Ne((e || []).map((e) => ({
			pileNo: `${e.type || ""}${e.Name || ""}`,
			isWarn: e?.iswarnpre1h === 1 || e?.iswarnpre2h === 1 || e?.iswarnpre3h === 1,
			rain1h: e?.rain_1h ?? "-",
			rain2h: e?.rain_2h ?? "-",
			rain3h: e?.rain_3h ?? "-",
			x: e.x,
			y: e.y
		})), (e) => e.isWarn), Me = (e) => [
			{
				label: "未来R1h",
				warn: e.iswarnpre1h === 1
			},
			{
				label: "未来R2h",
				warn: e.iswarnpre2h === 1
			},
			{
				label: "未来R3h",
				warn: e.iswarnpre3h === 1
			}
		], Z = (e) => e.some((e) => e.warn), Ne = (e, t) => [...e].sort((e, n) => Number(t(n)) - Number(t(e))), Pe = (e) => e.filter((e) => e.isWarn).length, Fe = (e) => {
			if (!e) return null;
			let t = e._isHistory ? W.value : U.value, n = String(e?._httpurl || t.httpurl || ""), r = String(e?.file_name || "");
			return {
				alt: "",
				imgUrl: r.startsWith("http") ? r : `${n}${r.replace(/^\/+/, "")}`,
				lngStart: t.lngStart,
				latStart: t.latStart,
				lngEnd: t.lngEnd,
				latEnd: t.latEnd,
				opacity: 1,
				zIndex: 1e3,
				otherData: { imgId: "radar_RadarShortTerm" }
			};
		}, Ie = (e) => {
			L.value && O("removeDataTitle", L.value), L.value = "雷达观测时间：" + c(e.focarcast_time).format("YYYY-MM-DD HH:mm "), O("addDataTitle", L.value);
		}, Le = (e) => {
			O("setImgAniShowByIndex", { index: e });
			let t = Y.value[e];
			Ie(t);
		}, Q = () => {
			M.value &&= (clearInterval(M.value), null);
		}, $ = () => {
			A.value = !1, Q();
		}, Re = () => {
			X.value.length <= 1 || (A.value = !0, Q(), V.value && (H.value = j.value, O("changeLoading", !0)), M.value = setInterval(() => {
				j.value = (j.value + 1) % X.value.length;
			}, 1e3));
		}, ze = () => {
			if (A.value) {
				$();
				return;
			}
			Re();
		};
		w(j, (e) => {
			Le(e), V.value && H.value !== null && e === H.value && (V.value = !1, H.value = null, O("changeLoading", !1));
		}), w(j, () => {
			ne(() => {
				let e = R.value;
				if (!e) return;
				let t = e.querySelectorAll(".radarAxis-li")[j.value];
				t && t.scrollIntoView({
					behavior: "smooth",
					inline: "center",
					block: "nearest"
				});
			});
		});
		let Be = () => {
			$();
		}, Ve = async () => {
			if (!k.value) {
				O("clearImgAniArr"), O("removeDataTitle", L.value), O("showRadarLegend", !1), $();
				return;
			}
			z.value = !0, await K(), z.value = !1;
		}, He = (e) => {
			let t = !!P.value[e];
			P.value[e] = !t, t || (F.value[e] = !0);
		}, Ue = (e) => {
			F.value[e] = !F.value[e];
		}, We = () => {
			O("close", "RadarShortTerm");
		}, Ge = (e) => {
			O("toMapView", {
				lng: Number(e.x),
				lat: Number(e.y),
				zoom: 11
			});
		};
		return (a, o) => {
			let c = s, u = r, h = i;
			return E((v(), d("div", ae, [
				f("div", { class: "RadarShortTerm-head" }, [f("div", { class: "RadarShortTerm-head-top" }, [o[1] ||= f("div", null, "雷达短临预报", -1), f("div", { class: "head-actions" }, [f("div", {
					class: "closeBtn",
					onClick: We,
					title: "关闭"
				})])]), o[2] ||= f("img", {
					class: "RadarShortTerm-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)]),
				f("div", oe, [f("div", se, [f("div", ce, [o[4] ||= f("span", { class: "setting-label" }, "雷达展示：", -1), f("div", le, [m(c, {
					modelValue: k.value,
					"onUpdate:modelValue": o[0] ||= (e) => k.value = e,
					class: "pile-checkbox",
					onChange: Ve
				}, {
					default: T(() => [...o[3] ||= [p(" 显示 ", -1)]]),
					_: 1
				}, 8, ["modelValue"])])])])]),
				f("div", ue, [o[7] ||= f("div", { class: "table-head" }, [
					f("span", null, "高速名称"),
					f("span", null, "状态要素"),
					f("span", { class: "head-arrow" })
				], -1), f("div", de, [(v(!0), d(l, null, b(J.value, (e) => (v(), d("div", {
					class: "table-row",
					key: e.name
				}, [
					f("div", {
						class: "table-row-main",
						onClick: (t) => He(e.name)
					}, [
						f("span", pe, x(e.name), 1),
						f("div", { class: g(["status-tags", { "has-warn": Z(e.tags) }]) }, [(v(!0), d(l, null, b(e.tags, (t) => (v(), d("span", {
							class: g(["status-tag", { warn: t.warn }]),
							key: `${e.name}-${t.label}`
						}, [f("span", null, x(t.label), 1)], 2))), 128))], 2),
						f("span", {
							class: g(["expand-arrow", { expanded: P.value[e.name] }]),
							"aria-hidden": "true"
						}, [m(u, null, {
							default: T(() => [m(S(t))]),
							_: 1
						})], 2)
					], 8, fe),
					E(f("div", {
						class: "pile-title",
						onClick: (t) => Ue(e.name)
					}, [f("span", null, [o[5] ||= p(" 桩号数据 ", -1), Pe(e.piles) > 0 ? (v(), d("span", he, " （报警数量：" + x(Pe(e.piles)) + "个）", 1)) : te("", !0)]), f("span", { class: g(["panel-arrow", { expanded: F.value[e.name] }]) }, [m(u, null, {
						default: T(() => [m(S(t))]),
						_: 1
					})], 2)], 8, me), [[C, P.value[e.name]]]),
					E(f("div", ge, [o[6] ||= f("div", { class: "pile-head" }, [
						f("span", null, "桩号"),
						f("span", null, "未来R1h"),
						f("span", null, "未来R2h"),
						f("span", null, "未来R3h")
					], -1), e.piles.length ? (v(), d("div", _e, [(v(!0), d(l, null, b(e.piles, (e) => (v(), d("div", {
						class: g(["pile-row", { "is-warn": e.isWarn }]),
						key: e.pileNo,
						onClick: (t) => Ge(e)
					}, [
						f("span", null, x(e.pileNo), 1),
						f("span", null, x(e.rain1h), 1),
						f("span", null, x(e.rain2h), 1),
						f("span", null, x(e.rain3h), 1)
					], 10, ve))), 128))])) : (v(), d("div", ye, "暂无数据"))], 512), [[C, P.value[e.name] && F.value[e.name]]])
				]))), 128))])]),
				E(f("div", be, [f("button", {
					type: "button",
					class: "timeline-play-btn",
					title: A.value ? "暂停" : "播放",
					onClick: ze
				}, [m(u, null, {
					default: T(() => [A.value ? (v(), ee(S(e), { key: 0 })) : (v(), ee(S(n), { key: 1 }))]),
					_: 1
				})], 8, xe), f("div", Se, [f("span", Ce, x(X.value[j.value] || ""), 1), f("div", {
					class: "radarAxis",
					ref_key: "ref_radarAxis",
					ref: R
				}, [(v(!0), d(l, null, b(Y.value, (e, t) => (v(), d("div", we, [f("div", {
					class: "radarAxis-li-node",
					onClick: (e) => (j.value = Number(t), Be())
				}, [
					f("i", { style: _({ backgroundColor: e._isHistory ? "" : "#ca9e64" }) }, null, 4),
					E(f("span", null, [...o[8] ||= [f("i", null, null, -1)]], 512), [[C, t === j.value]]),
					f("div", Ee, [f("b", null, x(e._label), 1)])
				], 8, Te), (v(), d(l, null, b(4, (n) => E(f("div", {
					class: "radarAxis-li-point",
					key: n,
					style: _({ backgroundColor: e._isHistory ? "" : "#ca9e64" })
				}, null, 4), [[C, t !== Y.value.length - 1]])), 64))]))), 256))], 512)])], 512), [[C, k.value]])
			])), [[h, z.value]]);
		};
	}
}), [["__scopeId", "data-v-1ee038a5"]]);
//#endregion
export { D as t };
