@sjvair/monitor-map 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/LoadScreen.js +73 -0
- package/dist/lib/actions.js +9 -0
- package/dist/lib/assets/icons/adjustment-horizontal.js +4 -0
- package/dist/lib/collocation-sites/CollocationTooltip.js +105 -0
- package/dist/lib/collocation-sites/collocations-icon-manager.svelte.js +21 -0
- package/dist/lib/collocation-sites/collocations-map-integration.svelte.js +84 -0
- package/dist/lib/collocation-sites/collocations.svelte.js +26 -0
- package/dist/lib/colors.js +25 -0
- package/dist/lib/components/DataBox.js +30 -0
- package/dist/lib/components/DisplayOption.js +10 -0
- package/dist/lib/components/MapLayersDisplayOptions.js +78 -0
- package/dist/lib/components/SegmentedControl.js +37 -0
- package/dist/lib/components/ToggleSwitch.js +17 -0
- package/dist/lib/components/ui/button/button.js +34 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-caption.js +79 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-cell.js +34 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-day.js +34 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-body.js +26 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-head.js +26 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-row.js +34 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid.js +34 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-head-cell.js +34 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-header.js +34 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-month-select.js +61 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-month.js +25 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-months.js +25 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-nav.js +25 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-next-button.js +57 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-prev-button.js +57 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-year-select.js +59 -0
- package/dist/lib/components/ui/range-calendar/range-calendar.js +272 -0
- package/dist/lib/data-chart/DataChart.js +142 -0
- package/dist/lib/data-chart/DateRange.js +15 -0
- package/dist/lib/data-chart/chart-utils.js +99 -0
- package/dist/lib/data-chart/data-chart.svelte.js +28 -0
- package/dist/lib/data-chart/requests.js +30 -0
- package/dist/lib/data-chart/tooltip.js +101 -0
- package/dist/lib/hms/hms-fire-icon-manager.js +39 -0
- package/dist/lib/hms/hms-fire-map-integration.svelte.js +97 -0
- package/dist/lib/hms/hms-smoke-map-integration.svelte.js +84 -0
- package/dist/lib/hms/hms.svelte.js +78 -0
- package/dist/lib/index.js +19 -0
- package/dist/lib/map/Map.js +14 -0
- package/dist/lib/map/MapStyleDisplayOptions.js +43 -0
- package/dist/lib/map/Menu.js +45 -0
- package/dist/lib/map/icons.js +31 -0
- package/dist/lib/map/integrations/base-layer-seperator.js +12 -0
- package/dist/lib/map/integrations/click-manager.js +33 -0
- package/dist/lib/map/integrations/integrations-manager.js +12 -0
- package/dist/lib/map/integrations/map-display-option.svelte.js +18 -0
- package/dist/lib/map/integrations/map-geojson-integration.svelte.js +17 -0
- package/dist/lib/map/integrations/map-icon-manager.js +43 -0
- package/dist/lib/map/integrations/map-integration.svelte.js +5 -0
- package/dist/lib/map/integrations/map-layer-integration.svelte.js +23 -0
- package/dist/lib/map/integrations/tooltip.svelte.js +81 -0
- package/dist/lib/map/map.svelte.js +51 -0
- package/dist/lib/map/utils.js +30 -0
- package/dist/lib/monitors/components/MonitorClusterTooltip.js +83 -0
- package/dist/lib/monitors/components/MonitorSubscriptionManager.js +104 -0
- package/dist/lib/monitors/components/MonitorTooltip.js +59 -0
- package/dist/lib/monitors/components/MonitorWidgetModal.js +40 -0
- package/dist/lib/monitors/components/MonitorsDisplayOptions.js +76 -0
- package/dist/lib/monitors/monitor-utils.js +26 -0
- package/dist/lib/monitors/monitors-cluster-renderer.js +212 -0
- package/dist/lib/monitors/monitors-icon-manager.svelte.js +71 -0
- package/dist/lib/monitors/monitors-map-integration.svelte.js +270 -0
- package/dist/lib/monitors/monitors.svelte.js +68 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/CalendarDate.js +122 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/DateFormatter.js +84 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js +91 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/conversion.js +104 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/manipulation.js +159 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/queries.js +32 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/string.js +37 -0
- package/dist/lib/node_modules/@internationalized/date/dist/private/utils.js +6 -0
- package/dist/lib/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/lib/node_modules/tailwind-merge/dist/bundle-mjs.js +1723 -0
- package/dist/lib/node_modules/tailwind-variants/dist/chunk-LQJYWU4O.js +70 -0
- package/dist/lib/node_modules/tailwind-variants/dist/chunk-RZF76H2U.js +166 -0
- package/dist/lib/node_modules/tailwind-variants/dist/index.js +19 -0
- package/dist/lib/node_modules/uplot/dist/uPlot.esm.js +2147 -0
- package/dist/lib/sjvair-air.avif +0 -0
- package/dist/lib/sjvair-air.png +0 -0
- package/dist/lib/sjvair-air.webp +0 -0
- package/dist/lib/sjvair-air2.avif +0 -0
- package/dist/lib/sjvair-air2.png +0 -0
- package/dist/lib/sjvair-air2.webp +0 -0
- package/dist/lib/sjvair-icon.avif +0 -0
- package/dist/lib/sjvair-icon.png +0 -0
- package/dist/lib/sjvair-icon.webp +0 -0
- package/dist/lib/sjvair-icon2.avif +0 -0
- package/dist/lib/sjvair-icon2.png +0 -0
- package/dist/lib/sjvair-icon2.webp +0 -0
- package/dist/lib/sjvair-sjv.avif +0 -0
- package/dist/lib/sjvair-sjv.png +0 -0
- package/dist/lib/sjvair-sjv.webp +0 -0
- package/dist/lib/sjvair-sjv2.avif +0 -0
- package/dist/lib/sjvair-sjv2.png +0 -0
- package/dist/lib/sjvair-sjv2.webp +0 -0
- package/dist/lib/src/MapView.js +7 -0
- package/dist/lib/src/MonitorDetailPanel.js +169 -0
- package/dist/lib/src/router.js +9 -0
- package/dist/lib/utils.js +8 -0
- package/dist/lib/weather.js +8 -0
- package/dist/lib/wind/wind.svelte.js +21 -0
- package/dist/monitor-map/MonitorDetailPanel.css +1 -0
- package/dist/monitor-map/assets/MonitorDetailPanel-BU_pXZjp.js +15 -0
- package/dist/monitor-map/assets/validate-routes-CgbRa8fT.js +1 -0
- package/dist/monitor-map/inter-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-cyrillic-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-greek-ext-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-greek-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-latin-wght-normal.woff2 +0 -0
- package/dist/monitor-map/inter-vietnamese-wght-normal.woff2 +0 -0
- package/dist/monitor-map/lungs.svg +99 -0
- package/dist/monitor-map/sjvair-air.avif +0 -0
- package/dist/monitor-map/sjvair-air.png +0 -0
- package/dist/monitor-map/sjvair-air.webp +0 -0
- package/dist/monitor-map/sjvair-air2.avif +0 -0
- package/dist/monitor-map/sjvair-air2.png +0 -0
- package/dist/monitor-map/sjvair-air2.webp +0 -0
- package/dist/monitor-map/sjvair-icon.avif +0 -0
- package/dist/monitor-map/sjvair-icon.png +0 -0
- package/dist/monitor-map/sjvair-icon.webp +0 -0
- package/dist/monitor-map/sjvair-icon2.avif +0 -0
- package/dist/monitor-map/sjvair-icon2.png +0 -0
- package/dist/monitor-map/sjvair-icon2.webp +0 -0
- package/dist/monitor-map/sjvair-sjv.avif +0 -0
- package/dist/monitor-map/sjvair-sjv.png +0 -0
- package/dist/monitor-map/sjvair-sjv.webp +0 -0
- package/dist/monitor-map/sjvair-sjv2.avif +0 -0
- package/dist/monitor-map/sjvair-sjv2.png +0 -0
- package/dist/monitor-map/sjvair-sjv2.webp +0 -0
- package/dist/monitor-map/sjvairMonitorMap.css +1 -0
- package/dist/monitor-map/sjvairMonitorMap.js +4042 -0
- package/package.json +1 -1
- package/src/lib/components/MapLayersDisplayOptions.svelte +23 -10
- package/src/lib/ev-stations/components/EvStationsDisplayOptions.svelte +14 -2
- package/src/lib/ev-stations/ev-stations-map-integration.svelte.ts +4 -4
- package/src/lib/map/integrations/map-display-option.svelte.ts +5 -1
- package/src/lib/map/integrations/map-icon-manager.ts +4 -3
- package/src/lib/monitors/components/MonitorsDisplayOptions.svelte +4 -1
- package/src/lib/monitors/monitors-icon-manager.svelte.ts +3 -1
- package/src/lib/monitors/monitors-map-integration.svelte.ts +9 -9
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { mapManager as e } from "../map.svelte.js";
|
|
2
|
+
import "svelte/internal/client";
|
|
3
|
+
import { XMap as t } from "@tstk/builtin-extensions";
|
|
4
|
+
//#region src/lib/map/integrations/tooltip.svelte.ts
|
|
5
|
+
function n() {
|
|
6
|
+
a.activeHandle?.clearTooltip();
|
|
7
|
+
}
|
|
8
|
+
function r() {
|
|
9
|
+
e.map.getCanvas().style.cursor = "pointer";
|
|
10
|
+
}
|
|
11
|
+
function i() {
|
|
12
|
+
e.map.getCanvas().style.cursor = "";
|
|
13
|
+
}
|
|
14
|
+
var a = class {
|
|
15
|
+
static activeHandle = null;
|
|
16
|
+
isEnabled = !1;
|
|
17
|
+
_tooltips = new t();
|
|
18
|
+
get tooltips() {
|
|
19
|
+
return this._tooltips.values();
|
|
20
|
+
}
|
|
21
|
+
enable(t) {
|
|
22
|
+
!e.map || this.isEnabled || (e.map.on("zoom", n), this.forEachHandle(t, (e) => e.enable()), this.isEnabled = !0);
|
|
23
|
+
}
|
|
24
|
+
disable(t) {
|
|
25
|
+
!e.map || !this.isEnabled || (e.map.off("zoom", n), this.forEachHandle(t, (e) => e.disable()), this.isEnabled = !1);
|
|
26
|
+
}
|
|
27
|
+
get(e) {
|
|
28
|
+
return this._tooltips.get(e);
|
|
29
|
+
}
|
|
30
|
+
has(e) {
|
|
31
|
+
return this._tooltips.has(e);
|
|
32
|
+
}
|
|
33
|
+
register(e, t, n = 0) {
|
|
34
|
+
let r = new o(e, t, n);
|
|
35
|
+
return this._tooltips.set(e, r), r;
|
|
36
|
+
}
|
|
37
|
+
with(e, t) {
|
|
38
|
+
let n = Array.isArray(e) ? e : [e];
|
|
39
|
+
for (let e of n) {
|
|
40
|
+
let n = this._tooltips.get(e);
|
|
41
|
+
n && t(n);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
forEachHandle(e, t) {
|
|
45
|
+
if (e !== void 0 && this._tooltips.has(e)) t(this._tooltips.get(e));
|
|
46
|
+
else for (let e of this.tooltips) t(e);
|
|
47
|
+
}
|
|
48
|
+
}, o = class {
|
|
49
|
+
layerId;
|
|
50
|
+
priority;
|
|
51
|
+
tooltip = null;
|
|
52
|
+
activeFeatureId = void 0;
|
|
53
|
+
isEnabled = !1;
|
|
54
|
+
clearTooltip = () => {
|
|
55
|
+
a.activeHandle === this && (this.tooltip?.remove(), this.tooltip = null, a.activeHandle = null, this.activeFeatureId = void 0);
|
|
56
|
+
};
|
|
57
|
+
setTooltip;
|
|
58
|
+
constructor(t, n, r = 0) {
|
|
59
|
+
this.layerId = t, this.priority = r, this.setTooltip = (t) => {
|
|
60
|
+
if (!e.map || !t.features) return;
|
|
61
|
+
let r = t.features[0]?.id, i = a.activeHandle === this, o = r === this.activeFeatureId;
|
|
62
|
+
if (i && this.tooltip && o) {
|
|
63
|
+
this.tooltip.setLngLat(t.lngLat);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
let s = a.activeHandle;
|
|
67
|
+
if (s !== null && s !== this && s.priority >= this.priority) return;
|
|
68
|
+
s?.clearTooltip(), this.activeFeatureId = void 0;
|
|
69
|
+
let c = n(t);
|
|
70
|
+
c && (this.tooltip = c, a.activeHandle = this, this.activeFeatureId = r, c.addTo(e.map));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
enable() {
|
|
74
|
+
!e.map || this.isEnabled || (e.map.on("mousemove", this.layerId, r), e.map.on("mouseleave", this.layerId, i), e.map.on("mousemove", this.layerId, this.setTooltip), e.map.on("mouseleave", this.layerId, this.clearTooltip), this.isEnabled = !0);
|
|
75
|
+
}
|
|
76
|
+
disable() {
|
|
77
|
+
!e.map || !this.isEnabled || (this.clearTooltip(), e.map.off("mousemove", this.layerId, r), e.map.off("mouseleave", this.layerId, i), e.map.off("mousemove", this.layerId, this.setTooltip), e.map.off("mouseleave", this.layerId, this.clearTooltip), this.isEnabled = !1);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { a as TooltipManager };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isGeoJSONSource as e } from "./utils.js";
|
|
2
|
+
import * as t from "svelte/internal/client";
|
|
3
|
+
import { Map as n, MapStyle as r, config as i } from "@maptiler/sdk";
|
|
4
|
+
//#region src/lib/map/map.svelte.ts
|
|
5
|
+
i.apiKey = "1ZwL7YJSSN42A678HHPn";
|
|
6
|
+
var a = r.STREETS_V4.DEFAULT, o = [
|
|
7
|
+
"Sport",
|
|
8
|
+
"Tourism",
|
|
9
|
+
"Culture",
|
|
10
|
+
"Shopping",
|
|
11
|
+
"Food",
|
|
12
|
+
"Transport"
|
|
13
|
+
], s = new class {
|
|
14
|
+
#e = t.state(null);
|
|
15
|
+
get map() {
|
|
16
|
+
return t.get(this.#e);
|
|
17
|
+
}
|
|
18
|
+
set map(e) {
|
|
19
|
+
t.set(this.#e, e, !0);
|
|
20
|
+
}
|
|
21
|
+
setDataSource(t, n) {
|
|
22
|
+
let r = s.map?.getSource(t);
|
|
23
|
+
e(r) && r.setData({
|
|
24
|
+
type: "FeatureCollection",
|
|
25
|
+
features: n
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
refreshMap() {
|
|
29
|
+
s.map && this.removeExcludedLayers();
|
|
30
|
+
}
|
|
31
|
+
removeExcludedLayers() {
|
|
32
|
+
for (let e of o) s.map?.getLayer(e) && s.map.removeLayer(e);
|
|
33
|
+
}
|
|
34
|
+
removeMap() {
|
|
35
|
+
return s.map?.remove();
|
|
36
|
+
}
|
|
37
|
+
}(), c = (e) => {
|
|
38
|
+
let t = new n({
|
|
39
|
+
container: e,
|
|
40
|
+
center: [-119.7987626619462, 36.76272050981146],
|
|
41
|
+
zoom: 7,
|
|
42
|
+
style: a,
|
|
43
|
+
projection: "globe",
|
|
44
|
+
space: { preset: "milkyway" }
|
|
45
|
+
});
|
|
46
|
+
return t.once("idle", () => {
|
|
47
|
+
s.map = t;
|
|
48
|
+
}), () => t.remove();
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { a as DefaultMapStyle, c as initializeMap, s as mapManager };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MapStyle as e, Popup as t } from "@maptiler/sdk";
|
|
2
|
+
import { mount as n, unmount as r } from "svelte";
|
|
3
|
+
//#region src/lib/map/utils.ts
|
|
4
|
+
var i = (() => {
|
|
5
|
+
let t = /* @__PURE__ */ new Map();
|
|
6
|
+
for (let n of Object.values(e)) {
|
|
7
|
+
let e = n.getId(), r = e.match(/^(.+?)_V(\d+)$/i), i = r ? r[1] : e, a = r ? parseInt(r[2], 10) : 0, o = t.get(i);
|
|
8
|
+
(!o || a > o.version) && t.set(i, {
|
|
9
|
+
version: a,
|
|
10
|
+
style: n
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return Array.from(t.values()).map((e) => e.style).sort((e, t) => e.getName().localeCompare(t.getName()));
|
|
14
|
+
})();
|
|
15
|
+
function a(e) {
|
|
16
|
+
return typeof e == "object" && !!e && "type" in e && e.type === "geojson";
|
|
17
|
+
}
|
|
18
|
+
function o(e, i, a, o = !1) {
|
|
19
|
+
let s = document.createElement("div"), c = n(e, {
|
|
20
|
+
target: s,
|
|
21
|
+
props: i
|
|
22
|
+
}), l = new t({
|
|
23
|
+
closeButton: o,
|
|
24
|
+
closeOnClick: !1,
|
|
25
|
+
maxWidth: "none"
|
|
26
|
+
}).setLngLat(a).setDOMContent(s);
|
|
27
|
+
return l.on("close", () => r(c)), l;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { i as MAP_STYLE_OPTIONS, a as isGeoJSONSource, o as mountPopup };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { monitorsManager as e } from "../monitors.svelte.js";
|
|
2
|
+
import { mapManager as t } from "../../map/map.svelte.js";
|
|
3
|
+
import { getCurrentLevel as n } from "../monitor-utils.js";
|
|
4
|
+
import r from "../../components/DataBox.js";
|
|
5
|
+
import * as i from "svelte/internal/client";
|
|
6
|
+
import "svelte/internal/disclose-version";
|
|
7
|
+
import "@maptiler/sdk";
|
|
8
|
+
import { area as a } from "@turf/area";
|
|
9
|
+
import { convertArea as o } from "@turf/helpers";
|
|
10
|
+
//#region src/lib/monitors/components/MonitorClusterTooltip.svelte
|
|
11
|
+
var s = i.from_html("<span> </span>"), c = i.from_html("<div class=\"flex gap-2\"><!> <div class=\"flex flex-col\"><h1 class=\"text-lg font-bold\"> </h1> <p> <!></p> <div class=\"mt-auto\"><p class=\"text-base\"> </p> <p class=\"text-base leading-none\"> </p></div></div></div>");
|
|
12
|
+
function l(l, u) {
|
|
13
|
+
i.push(u, !0);
|
|
14
|
+
let d = i.state(void 0);
|
|
15
|
+
i.user_effect(() => {
|
|
16
|
+
let r = t.map.getSource(u.feature.source), s = e.latest, c = e.meta;
|
|
17
|
+
r.getClusterLeaves(u.feature.properties.cluster_id, u.feature.properties.point_count, 0).then((e) => {
|
|
18
|
+
if (!e.length || !c || !s) return;
|
|
19
|
+
let t = e.map((e) => s?.get(e.properties.id)), r = t[0];
|
|
20
|
+
if (!r) return;
|
|
21
|
+
let a = c.entryType(r.latest.entry_type), o = c.monitorType(r.type), f = t.map((e) => e.position.coordinates), p = t.map((e) => parseFloat(e?.latest.value ?? "0")), m = Math.round(p.reduce((e, t) => e + t, 0) / t.length), h = n(m, a.asIter.levels);
|
|
22
|
+
i.set(d, {
|
|
23
|
+
color: h?.color || "#d3d3d3",
|
|
24
|
+
count: u.feature.properties.point_count,
|
|
25
|
+
coverage: l(f),
|
|
26
|
+
header: a.label,
|
|
27
|
+
clusterType: `${r.is_sjvair ? "SJVAir " : ""}${o.label} Monitors`,
|
|
28
|
+
subheading: "(cluster avg)",
|
|
29
|
+
max: p.reduce((e, t) => e > t ? e : t),
|
|
30
|
+
min: p.reduce((e, t) => e < t ? e : t),
|
|
31
|
+
value: m.toString()
|
|
32
|
+
}, !0);
|
|
33
|
+
});
|
|
34
|
+
function l(e) {
|
|
35
|
+
e.length === 3 && e.push(e[0]);
|
|
36
|
+
let t = a({
|
|
37
|
+
type: "Feature",
|
|
38
|
+
geometry: {
|
|
39
|
+
type: "Polygon",
|
|
40
|
+
coordinates: [e]
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return t > 0 ? o(t, "meters", "miles").toFixed(3) : void 0;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
var f = i.comment(), p = i.first_child(f), m = (e) => {
|
|
47
|
+
var t = c(), n = i.child(t);
|
|
48
|
+
r(n, {
|
|
49
|
+
get color() {
|
|
50
|
+
return i.get(d).color;
|
|
51
|
+
},
|
|
52
|
+
get header() {
|
|
53
|
+
return i.get(d).header;
|
|
54
|
+
},
|
|
55
|
+
get subheading() {
|
|
56
|
+
return i.get(d).subheading;
|
|
57
|
+
},
|
|
58
|
+
get value() {
|
|
59
|
+
return i.get(d).value;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var a = i.sibling(n, 2), o = i.child(a), l = i.child(o, !0);
|
|
63
|
+
i.reset(o);
|
|
64
|
+
var u = i.sibling(o, 2), f = i.child(u), p = i.sibling(f), m = (e) => {
|
|
65
|
+
var t = s(), n = i.child(t);
|
|
66
|
+
i.reset(t), i.template_effect(() => i.set_text(n, `covering ${i.get(d).coverage ?? ""}mi²`)), i.append(e, t);
|
|
67
|
+
};
|
|
68
|
+
i.if(p, (e) => {
|
|
69
|
+
i.get(d).coverage && e(m);
|
|
70
|
+
}), i.reset(u);
|
|
71
|
+
var h = i.sibling(u, 2), g = i.child(h), _ = i.child(g);
|
|
72
|
+
i.reset(g);
|
|
73
|
+
var v = i.sibling(g, 2), y = i.child(v);
|
|
74
|
+
i.reset(v), i.reset(h), i.reset(a), i.reset(t), i.template_effect(() => {
|
|
75
|
+
i.set_text(l, i.get(d).clusterType), i.set_text(f, `${i.get(d).count ?? ""} monitors `), i.set_text(_, `Max: ${i.get(d).max ?? ""}µg/m³`), i.set_text(y, `Min: ${i.get(d).min ?? ""}µg/m³`);
|
|
76
|
+
}), i.append(e, t);
|
|
77
|
+
};
|
|
78
|
+
i.if(p, (e) => {
|
|
79
|
+
i.get(d) && e(m);
|
|
80
|
+
}), i.append(l, f), i.pop();
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { l as default };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { monitorsManager as e } from "../monitors.svelte.js";
|
|
2
|
+
import * as t from "svelte/internal/client";
|
|
3
|
+
import "svelte/internal/disclose-version";
|
|
4
|
+
import { BellCheckIcon as n, BellOffIcon as r, ChevronDownIcon as i } from "@lucide/svelte";
|
|
5
|
+
import { getSubscriptions as a, subscribe as o, unsubscribe as s } from "@sjvair/sdk/account";
|
|
6
|
+
//#region src/lib/monitors/components/MonitorSubscriptionManager.svelte
|
|
7
|
+
var c = t.from_html("<button class=\"cursor-pointer px-4 py-2 text-sm rounded-t w-full flex items-center justify-between border border-black/30 hover:bg-[#F5F5F3]\">Unsubscribe <!></button>"), l = t.from_html("<button><span> </span> <!></button>"), u = t.from_html("<button aria-label=\"Close\" class=\"fixed inset-0 z-10\"></button> <div class=\"absolute top-full left-0 z-20 mt-1 w-full overflow-hidden rounded shadow-lg\"><!> <!></div>", 1), d = t.from_html("<div class=\"relative select-none\"><button> <!></button> <!></div>");
|
|
8
|
+
function f(f, p) {
|
|
9
|
+
t.push(p, !0);
|
|
10
|
+
let m = [
|
|
11
|
+
"unhealthy_sensitive",
|
|
12
|
+
"unhealthy",
|
|
13
|
+
"very_unhealthy",
|
|
14
|
+
"hazardous"
|
|
15
|
+
], h = t.state(!1), g = t.state(!1), _ = t.state(!1), v = t.state(null), y = t.derived(() => {
|
|
16
|
+
if (!e.meta) return [];
|
|
17
|
+
try {
|
|
18
|
+
return e.meta.entryType("pm25").asIter.levels.filter((e) => m.includes(e.name));
|
|
19
|
+
} catch {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
t.user_effect(() => {
|
|
24
|
+
p.monitorId, t.set(h, !1), t.set(v, null), b();
|
|
25
|
+
});
|
|
26
|
+
async function b() {
|
|
27
|
+
let e = p.monitorId;
|
|
28
|
+
t.set(g, !0);
|
|
29
|
+
try {
|
|
30
|
+
let n = await a("");
|
|
31
|
+
if (e !== p.monitorId) return;
|
|
32
|
+
let r = n.find((t) => t.monitor === e);
|
|
33
|
+
t.set(v, r?.level ?? null, !0);
|
|
34
|
+
} finally {
|
|
35
|
+
e === p.monitorId && t.set(g, !1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function x(e) {
|
|
39
|
+
if (t.get(_) || !e) return;
|
|
40
|
+
t.set(_, !0);
|
|
41
|
+
let n = t.get(v);
|
|
42
|
+
try {
|
|
43
|
+
e === t.get(v) ? (await s({
|
|
44
|
+
monitorId: p.monitorId,
|
|
45
|
+
apiToken: "",
|
|
46
|
+
level: e
|
|
47
|
+
}), t.set(v, null)) : (await o({
|
|
48
|
+
monitorId: p.monitorId,
|
|
49
|
+
apiToken: "",
|
|
50
|
+
level: e
|
|
51
|
+
}), t.set(v, e, !0));
|
|
52
|
+
} catch {
|
|
53
|
+
t.set(v, n, !0);
|
|
54
|
+
return;
|
|
55
|
+
} finally {
|
|
56
|
+
t.set(_, !1);
|
|
57
|
+
}
|
|
58
|
+
t.set(h, !1);
|
|
59
|
+
}
|
|
60
|
+
var S = d(), C = t.child(S), w = t.child(C), T = t.sibling(w);
|
|
61
|
+
{
|
|
62
|
+
let e = t.derived(() => ["transition-transform duration-300", t.get(h) ? "rotate-180" : ""]);
|
|
63
|
+
i(T, {
|
|
64
|
+
size: 16,
|
|
65
|
+
get class() {
|
|
66
|
+
return t.get(e);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
t.reset(C);
|
|
71
|
+
var E = t.sibling(C, 2), D = (e) => {
|
|
72
|
+
var i = u(), a = t.first_child(i), o = t.sibling(a, 2), s = t.child(o), d = (e) => {
|
|
73
|
+
var n = c();
|
|
74
|
+
r(t.sibling(t.child(n)), { size: 14 }), t.reset(n), t.delegated("click", n, () => x(t.get(v))), t.append(e, n);
|
|
75
|
+
};
|
|
76
|
+
t.if(s, (e) => {
|
|
77
|
+
t.get(v) && e(d);
|
|
78
|
+
});
|
|
79
|
+
var f = t.sibling(s, 2);
|
|
80
|
+
t.each(f, 17, () => t.get(y), (e) => e.name, (e, r) => {
|
|
81
|
+
let i = t.derived(() => t.get(r).name === t.get(v));
|
|
82
|
+
var a = l(), o = t.child(a), s = t.child(o, !0);
|
|
83
|
+
t.reset(o);
|
|
84
|
+
var c = t.sibling(o, 2), u = (e) => {
|
|
85
|
+
n(e, { size: 14 });
|
|
86
|
+
};
|
|
87
|
+
t.if(c, (e) => {
|
|
88
|
+
t.get(i) && e(u);
|
|
89
|
+
}), t.reset(a), t.template_effect(() => {
|
|
90
|
+
t.set_class(a, 1, t.clsx(["flex w-full items-center justify-between px-4 py-2 text-sm text-white last:rounded-b", t.get(i) ? "" : "first:rounded-t hover:brightness-90 cursor-pointer"])), t.set_style(a, `background-color: ${t.get(r).color ?? ""}`), a.disabled = t.get(_), t.set_text(s, t.get(r).label);
|
|
91
|
+
}), t.delegated("click", a, function(...e) {
|
|
92
|
+
(t.get(i) ? null : () => x(t.get(r).name))?.apply(this, e);
|
|
93
|
+
}), t.append(e, a);
|
|
94
|
+
}), t.reset(o), t.delegated("click", a, () => t.set(h, !1)), t.append(e, i);
|
|
95
|
+
};
|
|
96
|
+
t.if(E, (e) => {
|
|
97
|
+
t.get(h) && e(D);
|
|
98
|
+
}), t.reset(S), t.template_effect(() => {
|
|
99
|
+
t.set_class(C, 1, t.clsx(["flex w-full cursor-pointer items-center justify-center gap-2 rounded border px-3 py-1.5 text-sm font-semibold text-white", t.get(v) ? "border-green-700 bg-green-600 hover:bg-green-700" : "border-blue-600 bg-blue-500 hover:bg-blue-600"])), C.disabled = t.get(g), t.set_text(w, `${t.get(v) ? "Manage Subscription" : "Subscribe to Alerts"} `);
|
|
100
|
+
}), t.delegated("click", C, () => t.set(h, !t.get(h))), t.append(f, S), t.pop();
|
|
101
|
+
}
|
|
102
|
+
t.delegate(["click"]);
|
|
103
|
+
//#endregion
|
|
104
|
+
export { f as default };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { monitorsManager as e } from "../monitors.svelte.js";
|
|
2
|
+
import { getCurrentLevel as t } from "../monitor-utils.js";
|
|
3
|
+
import n from "../../components/DataBox.js";
|
|
4
|
+
import * as r from "svelte/internal/client";
|
|
5
|
+
import "svelte/internal/disclose-version";
|
|
6
|
+
import { format as i, formatDistanceToNow as a } from "date-fns";
|
|
7
|
+
//#region src/lib/monitors/components/MonitorTooltip.svelte
|
|
8
|
+
var o = r.from_html("<div class=\"flex gap-2\"><!> <div class=\"flex flex-col\"><p> </p> <h1 class=\"text-lg font-bold underline\"> </h1> <div class=\"mt-auto\"><p class=\"text-base leading-none\">Last updated</p> <p class=\"text-base leading-none\"> </p></div></div></div>");
|
|
9
|
+
function s(s, c) {
|
|
10
|
+
r.push(c, !0);
|
|
11
|
+
let l = r.derived(() => {
|
|
12
|
+
let n = e.latest?.get(c.feature.properties.id);
|
|
13
|
+
if (!n || !e.meta) return;
|
|
14
|
+
let r = e.meta.entryType(n.latest.entry_type), o = t(n.latest.value, r.asIter.levels), s = e.meta.monitorType(n.type).expected_interval;
|
|
15
|
+
return {
|
|
16
|
+
color: o?.color ?? "",
|
|
17
|
+
header: r.label,
|
|
18
|
+
date: {
|
|
19
|
+
formatted: i(n.latest.timestamp, "h:mm:aaa EEEE MMM dd, yyyy"),
|
|
20
|
+
diference: a(n.latest.timestamp, {
|
|
21
|
+
addSuffix: !0,
|
|
22
|
+
includeSeconds: !0
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
subheading: `(${s} avg)`,
|
|
26
|
+
value: Math.round(parseInt(n.latest.value, 10)).toString()
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
var u = r.comment(), d = r.first_child(u), f = (e) => {
|
|
30
|
+
var t = o(), i = r.child(t);
|
|
31
|
+
n(i, {
|
|
32
|
+
get color() {
|
|
33
|
+
return r.get(l).color;
|
|
34
|
+
},
|
|
35
|
+
get header() {
|
|
36
|
+
return r.get(l).header;
|
|
37
|
+
},
|
|
38
|
+
get subheading() {
|
|
39
|
+
return r.get(l).subheading;
|
|
40
|
+
},
|
|
41
|
+
get value() {
|
|
42
|
+
return r.get(l).value;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
var a = r.sibling(i, 2), s = r.child(a), u = r.child(s, !0);
|
|
46
|
+
r.reset(s);
|
|
47
|
+
var d = r.sibling(s, 2), f = r.child(d, !0);
|
|
48
|
+
r.reset(d);
|
|
49
|
+
var p = r.sibling(d, 2), m = r.sibling(r.child(p), 2), h = r.child(m, !0);
|
|
50
|
+
r.reset(m), r.reset(p), r.reset(a), r.reset(t), r.template_effect(() => {
|
|
51
|
+
r.set_text(u, r.get(l).date.formatted), r.set_text(f, c.feature.properties.name), r.set_text(h, r.get(l).date.diference);
|
|
52
|
+
}), r.append(e, t);
|
|
53
|
+
};
|
|
54
|
+
r.if(d, (e) => {
|
|
55
|
+
r.get(l) && e(f);
|
|
56
|
+
}), r.append(s, u), r.pop();
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { s as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { portal as e } from "../../actions.js";
|
|
2
|
+
import * as t from "svelte/internal/client";
|
|
3
|
+
import "svelte/internal/disclose-version";
|
|
4
|
+
import { SquareX as n } from "@lucide/svelte";
|
|
5
|
+
import { origin as r } from "@sjvair/sdk/http";
|
|
6
|
+
//#region src/lib/monitors/components/MonitorWidgetModal.svelte
|
|
7
|
+
var i = t.from_html("<div class=\"select-none\"><button class=\"cursor-pointer rounded border border-blue-400 bg-blue-500 px-3 py-1.5 text-sm font-semibold text-white hover:bg-blue-600\">Get the widget!</button> <div><div class=\"m-4 flex max-w-[min(450px,calc(100vw-2rem))] flex-col items-center justify-center rounded bg-white p-4 shadow-lg\"><button translate=\"no\" class=\"cursor-pointer self-end\"><!></button> <div translate=\"no\"></div> <p class=\"mb-4 text-center\">Copy the following code and paste it in your website</p> <div class=\"group relative flex w-full items-center overflow-hidden bg-neutral-800 hover:bg-neutral-600\"><code class=\"cursor-text overflow-x-scroll bg-inherit text-gray-300 select-text\"> </code> <div class=\"invisible absolute top-1/2 left-[calc(100%-3rem)] flex -translate-y-1/2 cursor-pointer items-center justify-center rounded-full bg-black/80 p-2 group-hover:visible\"><button aria-label=\"Copy\" translate=\"no\" class=\"svg-icon content-copy cursor-pointer bg-gray-300\"></button></div> <div>Copied to clipboard!</div></div></div></div></div>");
|
|
8
|
+
function a(a, o) {
|
|
9
|
+
let s = {
|
|
10
|
+
overflow: "hidden",
|
|
11
|
+
width: "290px",
|
|
12
|
+
height: "390px"
|
|
13
|
+
}, c = t.state(!1), l = t.state(!1), u = t.derived(() => `${r}/widget/#/${o.monitorId}`), d = t.derived(() => `<iframe src="${t.get(u)}" frameborder="0" allowtransparency="true" style="overflow: ${s.overflow}; width: ${s.width}; height: ${s.height};"></iframe>`);
|
|
14
|
+
function f() {
|
|
15
|
+
navigator.clipboard.writeText(t.get(d)), t.set(l, !0), setTimeout(() => {
|
|
16
|
+
t.set(l, !1);
|
|
17
|
+
}, 1e3 * 2);
|
|
18
|
+
}
|
|
19
|
+
function p() {
|
|
20
|
+
t.set(c, !0), document.body.style.overflow = "hidden";
|
|
21
|
+
}
|
|
22
|
+
function m() {
|
|
23
|
+
t.set(c, !1), document.body.style.overflow = "auto";
|
|
24
|
+
}
|
|
25
|
+
var h = i(), g = t.child(h), _ = t.sibling(g, 2), v = t.child(_), y = t.child(v);
|
|
26
|
+
n(t.child(y), {}), t.reset(y);
|
|
27
|
+
var b = t.sibling(y, 2);
|
|
28
|
+
t.html(b, () => t.get(d), !0), t.reset(b);
|
|
29
|
+
var x = t.sibling(b, 4), S = t.child(x), C = t.child(S, !0);
|
|
30
|
+
t.reset(S);
|
|
31
|
+
var w = t.sibling(S, 2), T = t.child(w);
|
|
32
|
+
t.reset(w);
|
|
33
|
+
var E = t.sibling(w, 2);
|
|
34
|
+
t.reset(x), t.reset(v), t.reset(_), t.action(_, (t) => e?.(t)), t.reset(h), t.template_effect(() => {
|
|
35
|
+
t.set_class(_, 1, t.clsx(["fixed inset-0 z-9999 flex items-center justify-center bg-black/50 backdrop-blur-sm transition-all duration-200", t.get(c) ? "visible" : "invisible"])), t.set_text(C, t.get(d)), t.set_class(E, 1, t.clsx(["absolute flex h-full w-full items-center justify-center bg-[#1fb9ef] text-white transition-all duration-200 [text-shadow:1px_2px_4px_#333]", t.get(l) ? "left-0" : "left-[120%]"]));
|
|
36
|
+
}), t.delegated("click", g, p), t.delegated("click", y, m), t.delegated("click", T, f), t.append(a, h);
|
|
37
|
+
}
|
|
38
|
+
t.delegate(["click"]);
|
|
39
|
+
//#endregion
|
|
40
|
+
export { a as default };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { monitorsManager as e } from "../monitors.svelte.js";
|
|
2
|
+
import { monitorsMapIntegration as t } from "../monitors-map-integration.svelte.js";
|
|
3
|
+
import n from "../../components/DisplayOption.js";
|
|
4
|
+
import r from "../../components/SegmentedControl.js";
|
|
5
|
+
import i from "../../components/ToggleSwitch.js";
|
|
6
|
+
import * as a from "svelte/internal/client";
|
|
7
|
+
import "svelte/internal/disclose-version";
|
|
8
|
+
//#region src/lib/monitors/components/MonitorsDisplayOptions.svelte
|
|
9
|
+
var o = a.from_html("<img class=\"w-3\"/>"), s = a.from_html("<label class=\"flex gap-1 cursor-pointer whitespace-nowrap select-none\"><input type=\"checkbox\"/> <!> </label>"), c = a.from_html("<p class=\"text-lg font-bold underline\">Air Monitors</p> <div class=\"mb-2 w-full text-xs\"><div class=\"w-fit\"><!></div> <!></div> <!>", 1);
|
|
10
|
+
function l(l, u) {
|
|
11
|
+
a.push(u, !0);
|
|
12
|
+
let d = [{
|
|
13
|
+
label: "PM 2.5",
|
|
14
|
+
value: "pm25"
|
|
15
|
+
}, {
|
|
16
|
+
label: "Ozone",
|
|
17
|
+
value: "o3"
|
|
18
|
+
}], f = a.derived(() => e.pollutant && e.pollutant === "pm25" ? Object.entries(t.displayOptions) : Object.entries(t.displayOptions).filter(([t, n]) => t === "inactive" || e.meta?.asIter.monitors.some((t) => t.label === n.label && e.pollutant && e.pollutant in t.entries)));
|
|
19
|
+
a.user_effect(() => {
|
|
20
|
+
e.list = [], e.latest = null, e.update();
|
|
21
|
+
}), n(l, {
|
|
22
|
+
children: (n, l) => {
|
|
23
|
+
var u = c(), p = a.sibling(a.first_child(u), 2), m = a.child(p);
|
|
24
|
+
i(a.child(m), {
|
|
25
|
+
id: "monitor-clusters",
|
|
26
|
+
label: "Marker Clusters",
|
|
27
|
+
get value() {
|
|
28
|
+
return t.clustered;
|
|
29
|
+
},
|
|
30
|
+
set value(e) {
|
|
31
|
+
t.clustered = e;
|
|
32
|
+
}
|
|
33
|
+
}), a.reset(m);
|
|
34
|
+
var h = a.sibling(m, 2), g = (t) => {
|
|
35
|
+
r(t, {
|
|
36
|
+
segmentLabel: "Pollutant:",
|
|
37
|
+
get options() {
|
|
38
|
+
return d;
|
|
39
|
+
},
|
|
40
|
+
get group() {
|
|
41
|
+
return e.pollutant;
|
|
42
|
+
},
|
|
43
|
+
set group(t) {
|
|
44
|
+
e.pollutant = t;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
a.if(h, (t) => {
|
|
49
|
+
e.pollutant && t(g);
|
|
50
|
+
}), a.reset(p);
|
|
51
|
+
var _ = a.sibling(p, 2);
|
|
52
|
+
a.each(_, 17, () => a.get(f), ([e, t]) => t.label, (e, t) => {
|
|
53
|
+
var n = a.derived(() => a.to_array(a.get(t), 2));
|
|
54
|
+
let r = () => a.get(n)[0], i = () => a.get(n)[1], c = a.derived(() => `${r()}-monitor-display-option`);
|
|
55
|
+
var l = s(), u = a.child(l);
|
|
56
|
+
a.remove_input_defaults(u);
|
|
57
|
+
var d = a.sibling(u, 2), f = (e) => {
|
|
58
|
+
var t = o();
|
|
59
|
+
a.template_effect(() => {
|
|
60
|
+
a.set_attribute(t, "src", i().icon.image.src), a.set_attribute(t, "alt", i().icon.image.alt);
|
|
61
|
+
}), a.append(e, t);
|
|
62
|
+
};
|
|
63
|
+
a.if(d, (e) => {
|
|
64
|
+
i().icon && e(f);
|
|
65
|
+
});
|
|
66
|
+
var p = a.sibling(d);
|
|
67
|
+
a.reset(l), a.template_effect(() => {
|
|
68
|
+
a.set_attribute(l, "for", a.get(c)), a.set_attribute(u, "id", a.get(c)), a.set_attribute(u, "name", i().label), a.set_text(p, ` ${i().label ?? ""}`);
|
|
69
|
+
}), a.bind_checked(u, () => i().value, (e) => i().value = e), a.append(e, l);
|
|
70
|
+
}), a.append(n, u);
|
|
71
|
+
},
|
|
72
|
+
$$slots: { default: !0 }
|
|
73
|
+
}), a.pop();
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { l as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/lib/monitors/monitor-utils.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
return e = typeof e == "string" ? parseInt(e, 10) : e, t.find((t) => e >= t.range[0] && e <= t.range[1]);
|
|
4
|
+
}
|
|
5
|
+
function t(e) {
|
|
6
|
+
switch (e.type) {
|
|
7
|
+
case "airgradient": return 5;
|
|
8
|
+
case "airnow": return 2;
|
|
9
|
+
case "aqview": return 3;
|
|
10
|
+
case "bam1022": return 6;
|
|
11
|
+
case "purpleair": return e.is_sjvair ? 4 : 1;
|
|
12
|
+
default: throw Error(`Map ordering for ${e.device} has not been set`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function n(e) {
|
|
16
|
+
switch (e) {
|
|
17
|
+
case "airgradient": return "circle";
|
|
18
|
+
case "airnow":
|
|
19
|
+
case "aqview":
|
|
20
|
+
case "bam1022": return "triangle";
|
|
21
|
+
case "purpleair": return "square";
|
|
22
|
+
default: return "circle";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { e as getCurrentLevel, t as getOrder, n as getTypeShape };
|