@justanarthur/modo-ui-notch 0.2.0 → 0.3.0

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.
Files changed (148) hide show
  1. package/README.md +11 -11
  2. package/blocks/activities/agenda/examples.mdx +21 -5
  3. package/blocks/activities/agenda/index.tsx +291 -182
  4. package/blocks/activities/clock/examples.mdx +73 -0
  5. package/blocks/activities/clock/index.tsx +619 -0
  6. package/blocks/activities/now-playing/examples.mdx +32 -13
  7. package/blocks/activities/now-playing/index.tsx +319 -126
  8. package/blocks/activities/weather/examples.mdx +115 -0
  9. package/blocks/activities/weather/index.tsx +634 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +19 -3
  12. package/blocks/app/settings-window/examples.mdx +6 -2
  13. package/blocks/app/settings-window/index.tsx +25 -7
  14. package/blocks/system/clipboard/examples.mdx +83 -0
  15. package/blocks/system/clipboard/index.tsx +563 -0
  16. package/blocks/system/recent-files/examples.mdx +66 -0
  17. package/blocks/system/recent-files/index.tsx +542 -0
  18. package/blocks/system/system-stats/examples.mdx +38 -9
  19. package/blocks/system/system-stats/index.tsx +241 -107
  20. package/components/indicators/media-scrubber/examples.mdx +8 -0
  21. package/components/indicators/media-scrubber/index.tsx +37 -13
  22. package/components/island/island/examples.mdx +4 -4
  23. package/components/island/island/index.tsx +2 -2
  24. package/components/island/island-flash/examples.mdx +15 -18
  25. package/components/island/island-flash/index.tsx +4 -4
  26. package/components/island/island-tabs/examples.mdx +5 -5
  27. package/components/island/widget/examples.mdx +76 -0
  28. package/components/island/widget/index.tsx +431 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +1 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +2 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +3 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +2 -0
  36. package/dist/blocks/activities/weather/index.js +21 -0
  37. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  38. package/dist/blocks/app/expanded-island/index.js +4 -3
  39. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  40. package/dist/blocks/app/settings-window/index.js +1 -1
  41. package/dist/blocks/system/clipboard/index.d.ts +2 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +2 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +2 -2
  46. package/dist/blocks/system/system-stats/index.js +4 -1
  47. package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
  48. package/dist/components/indicators/media-scrubber/index.js +1 -1
  49. package/dist/components/island/island/index.d.ts +1 -1
  50. package/dist/components/island/island/index.js +2 -2
  51. package/dist/components/island/island-flash/index.d.ts +1 -1
  52. package/dist/components/island/island-flash/index.js +1 -1
  53. package/dist/components/island/island-tabs/index.js +2 -2
  54. package/dist/components/island/widget/index.d.ts +2 -0
  55. package/dist/components/island/widget/index.js +30 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +102 -58
  58. package/dist/lib/artwork.d.ts +2 -0
  59. package/dist/lib/artwork.js +8 -0
  60. package/dist/lib/geometry.js +1 -1
  61. package/dist/shared/chunk-2818esrq.d.ts +140 -0
  62. package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-2m5dz8nf.d.ts} +4 -4
  63. package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
  64. package/dist/shared/chunk-416tsgbc.d.ts +175 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-9c7ewvkk.js +381 -0
  69. package/dist/shared/{chunk-mp1nx0ez.js → chunk-9m0xbg5v.js} +14 -3
  70. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  71. package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
  72. package/dist/shared/{chunk-s33y1pcq.js → chunk-cc9nwbtf.js} +20 -10
  73. package/dist/shared/chunk-da177e8r.d.ts +114 -0
  74. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  77. package/dist/shared/chunk-j77cx8dp.js +498 -0
  78. package/dist/shared/chunk-mt0k6v8x.js +474 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-pfhy5e4q.d.ts} +7 -1
  81. package/dist/shared/chunk-qdzemt2v.js +477 -0
  82. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  83. package/dist/shared/chunk-s2jeqqan.js +243 -0
  84. package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
  87. package/dist/shared/chunk-x7f3g82r.js +285 -0
  88. package/dist/shared/chunk-xq5hc5gv.js +333 -0
  89. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  90. package/dist/shared/chunk-ym0xbses.js +518 -0
  91. package/dist/styles.css +97 -55
  92. package/index.ts +7 -6
  93. package/lib/artwork.ts +112 -0
  94. package/lib/geometry.ts +1 -1
  95. package/mock/activities.tsx +9 -32
  96. package/mock/artwork.tsx +13 -1
  97. package/mock/clipboard.tsx +79 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +30 -44
  100. package/mock/files.tsx +70 -0
  101. package/mock/island-content.tsx +43 -118
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +46 -0
  105. package/mock/weather.tsx +105 -0
  106. package/package.json +7 -2
  107. package/blocks/activities/shelf/examples.mdx +0 -33
  108. package/blocks/activities/shelf/index.tsx +0 -289
  109. package/blocks/activities/timer/examples.mdx +0 -52
  110. package/blocks/activities/timer/index.tsx +0 -292
  111. package/blocks/system/controls/examples.mdx +0 -34
  112. package/blocks/system/controls/index.tsx +0 -167
  113. package/blocks/system/devices/examples.mdx +0 -25
  114. package/blocks/system/devices/index.tsx +0 -172
  115. package/blocks/system/power-alert/examples.mdx +0 -32
  116. package/blocks/system/power-alert/index.tsx +0 -89
  117. package/components/indicators/battery-glyph/examples.mdx +0 -22
  118. package/components/indicators/battery-glyph/index.tsx +0 -91
  119. package/dist/blocks/activities/shelf/index.d.ts +0 -2
  120. package/dist/blocks/activities/shelf/index.js +0 -14
  121. package/dist/blocks/activities/timer/index.d.ts +0 -2
  122. package/dist/blocks/activities/timer/index.js +0 -19
  123. package/dist/blocks/system/controls/index.d.ts +0 -2
  124. package/dist/blocks/system/controls/index.js +0 -10
  125. package/dist/blocks/system/devices/index.d.ts +0 -2
  126. package/dist/blocks/system/devices/index.js +0 -12
  127. package/dist/blocks/system/power-alert/index.d.ts +0 -2
  128. package/dist/blocks/system/power-alert/index.js +0 -9
  129. package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
  130. package/dist/components/indicators/battery-glyph/index.js +0 -9
  131. package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
  132. package/dist/shared/chunk-45gytfr1.d.ts +0 -84
  133. package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
  134. package/dist/shared/chunk-5w0yck07.d.ts +0 -32
  135. package/dist/shared/chunk-7hr53mby.js +0 -116
  136. package/dist/shared/chunk-b8jb1w72.js +0 -145
  137. package/dist/shared/chunk-cpewy6yg.js +0 -178
  138. package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
  139. package/dist/shared/chunk-enm6td0p.js +0 -280
  140. package/dist/shared/chunk-fvedaas2.d.ts +0 -33
  141. package/dist/shared/chunk-gex38j8x.d.ts +0 -82
  142. package/dist/shared/chunk-hwtxpzg0.js +0 -69
  143. package/dist/shared/chunk-phb53x1f.js +0 -252
  144. package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
  145. package/dist/shared/chunk-rcp1g9ca.js +0 -70
  146. package/dist/shared/chunk-rx9sphz2.js +0 -266
  147. package/dist/shared/chunk-xdeek16r.d.ts +0 -58
  148. package/dist/shared/chunk-xkzjk1tq.js +0 -206
@@ -0,0 +1,518 @@
1
+ "use client";
2
+
3
+ import {
4
+ IslandFlash2
5
+ } from "./chunk-ndf79pv5.js";
6
+ import {
7
+ widget_default
8
+ } from "./chunk-x7f3g82r.js";
9
+ import {
10
+ MINUTE2,
11
+ useEdgeClock2
12
+ } from "./chunk-gb56m10p.js";
13
+
14
+ // blocks/activities/weather/index.tsx
15
+ import Button from "@justanarthur/modo-ui/components/actions/button";
16
+ import { useSize } from "@justanarthur/modo-ui/lib/size-context";
17
+ import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
18
+ import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
19
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
20
+ import Skeleton from "@justanarthur/modo-ui/primitives/content/skeleton";
21
+ import {
22
+ ArrowDown,
23
+ ArrowUp,
24
+ Cloud,
25
+ CloudDrizzle,
26
+ CloudFog,
27
+ CloudHail,
28
+ CloudLightning,
29
+ CloudMoon,
30
+ CloudOff,
31
+ CloudRain,
32
+ CloudRainWind,
33
+ CloudSnow,
34
+ CloudSun,
35
+ Droplets,
36
+ LocateOff,
37
+ MapPin,
38
+ Moon,
39
+ RotateCw,
40
+ Sun,
41
+ Umbrella,
42
+ WifiOff,
43
+ Wind
44
+ } from "lucide-react";
45
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
46
+ /*!
47
+ * Local addition: a notch app's weather, the temperature now, the next
48
+ * hours and tomorrow, with the location and loading states around it and a
49
+ * flash before rain. Presentational: the forecast comes in as props, shaped
50
+ * so a host can fill it from Open-Meteo (`conditionFromCode` reads its WMO
51
+ * weather codes).
52
+ */
53
+ var LABEL = {
54
+ clear: "Clear",
55
+ "partly-cloudy": "Partly cloudy",
56
+ cloudy: "Cloudy",
57
+ fog: "Fog",
58
+ drizzle: "Drizzle",
59
+ rain: "Rain",
60
+ "heavy-rain": "Heavy rain",
61
+ sleet: "Sleet",
62
+ snow: "Snow",
63
+ thunderstorm: "Thunderstorm"
64
+ };
65
+ var GLYPH = {
66
+ clear: Sun,
67
+ "partly-cloudy": CloudSun,
68
+ cloudy: Cloud,
69
+ fog: CloudFog,
70
+ drizzle: CloudDrizzle,
71
+ rain: CloudRain,
72
+ "heavy-rain": CloudRainWind,
73
+ sleet: CloudHail,
74
+ snow: CloudSnow,
75
+ thunderstorm: CloudLightning
76
+ };
77
+ var HUE = {
78
+ clear: "text-status-warning",
79
+ "partly-cloudy": "text-status-warning",
80
+ cloudy: "text-foreground",
81
+ fog: "text-foreground",
82
+ drizzle: "text-status-info",
83
+ rain: "text-status-info",
84
+ "heavy-rain": "text-status-info",
85
+ sleet: "text-status-info",
86
+ snow: "text-foreground",
87
+ thunderstorm: "text-status-info"
88
+ };
89
+ var HERO_GLYPH = { default: 30, compact: 24 };
90
+ var STRIP_GLYPH = { default: 16, compact: 14 };
91
+ var WET = 30;
92
+ var HOURS = 6;
93
+ function conditionFromCode2(code) {
94
+ if (code === 0)
95
+ return "clear";
96
+ if (code <= 2)
97
+ return "partly-cloudy";
98
+ if (code === 3)
99
+ return "cloudy";
100
+ if (code === 45 || code === 48)
101
+ return "fog";
102
+ if (code >= 51 && code <= 55)
103
+ return "drizzle";
104
+ if (code === 56 || code === 57 || code === 66 || code === 67)
105
+ return "sleet";
106
+ if (code === 65 || code === 82)
107
+ return "heavy-rain";
108
+ if (code >= 61 && code <= 63 || code === 80 || code === 81)
109
+ return "rain";
110
+ if (code >= 71 && code <= 77 || code === 85 || code === 86)
111
+ return "snow";
112
+ if (code >= 95)
113
+ return "thunderstorm";
114
+ return "cloudy";
115
+ }
116
+ function glyphFor(condition, isDay = true) {
117
+ if (!isDay && condition === "clear")
118
+ return Moon;
119
+ if (!isDay && condition === "partly-cloudy")
120
+ return CloudMoon;
121
+ return GLYPH[condition];
122
+ }
123
+ function hueFor(condition, isDay = true) {
124
+ if (!isDay && (condition === "clear" || condition === "partly-cloudy"))
125
+ return "text-foreground";
126
+ return HUE[condition];
127
+ }
128
+ var degrees = (celsius, unit) => Math.round(unit === "fahrenheit" ? celsius * 9 / 5 + 32 : celsius);
129
+ var temp = (celsius, unit) => `${degrees(celsius, unit)}°`;
130
+ var speed = (kmh, unit) => unit === "fahrenheit" ? `${Math.round(kmh / 1.609)} mph` : `${Math.round(kmh)} km/h`;
131
+ var hourOf = (ms, locale) => new Date(ms).toLocaleTimeString(locale, { hour: "numeric" });
132
+ function ago(ms) {
133
+ const minutes = Math.floor(ms / MINUTE2);
134
+ if (minutes < 1)
135
+ return "Just now";
136
+ if (minutes < 60)
137
+ return `${minutes} min ago`;
138
+ return `${Math.floor(minutes / 60)} h ago`;
139
+ }
140
+ function rainAhead(current, hours) {
141
+ if (HUE[current.condition] === "text-status-info")
142
+ return;
143
+ return hours.find((hour) => (hour.precipitation ?? 0) >= 50);
144
+ }
145
+ function Glyph({ condition, isDay, size, className }) {
146
+ const Icon = glyphFor(condition, isDay);
147
+ return /* @__PURE__ */ jsx(Icon, {
148
+ "aria-hidden": true,
149
+ size,
150
+ strokeWidth: 1.5,
151
+ className: cn("shrink-0", className)
152
+ });
153
+ }
154
+ function Hours({ hours, unit, locale }) {
155
+ const size = useSize();
156
+ const wet = hours.some((hour) => (hour.precipitation ?? 0) >= WET);
157
+ return /* @__PURE__ */ jsx("div", {
158
+ className: "flex min-w-0 justify-between",
159
+ children: hours.map((hour, i) => /* @__PURE__ */ jsxs("div", {
160
+ className: "flex min-w-0 flex-1 flex-col items-center gap-1 tabular-nums",
161
+ children: [
162
+ /* @__PURE__ */ jsx("span", {
163
+ className: "whitespace-nowrap text-caption text-muted-foreground",
164
+ children: i === 0 ? "Now" : hourOf(hour.time, locale)
165
+ }),
166
+ /* @__PURE__ */ jsx(Glyph, {
167
+ condition: hour.condition,
168
+ isDay: hour.isDay,
169
+ size: STRIP_GLYPH[size.variant],
170
+ className: "text-foreground"
171
+ }),
172
+ /* @__PURE__ */ jsx("span", {
173
+ className: "text-body text-foreground",
174
+ children: temp(hour.temperature, unit)
175
+ }),
176
+ wet && /* @__PURE__ */ jsx("span", {
177
+ className: "h-4 text-caption text-status-info",
178
+ children: (hour.precipitation ?? 0) >= WET && `${hour.precipitation}%`
179
+ })
180
+ ]
181
+ }, hour.time))
182
+ });
183
+ }
184
+ function Tomorrow({ day, unit }) {
185
+ return /* @__PURE__ */ jsx(widget_default.Row, {
186
+ leading: "Tomorrow",
187
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
188
+ children: [
189
+ (day.precipitation ?? 0) >= WET && /* @__PURE__ */ jsxs("span", {
190
+ className: "text-status-info",
191
+ children: [
192
+ day.precipitation,
193
+ "%"
194
+ ]
195
+ }),
196
+ /* @__PURE__ */ jsx("span", {
197
+ className: "text-foreground",
198
+ children: temp(day.high, unit)
199
+ }),
200
+ /* @__PURE__ */ jsx("span", {
201
+ children: temp(day.low, unit)
202
+ })
203
+ ]
204
+ }),
205
+ children: /* @__PURE__ */ jsxs("span", {
206
+ className: "flex min-w-0 items-center gap-2",
207
+ children: [
208
+ /* @__PURE__ */ jsx(Glyph, {
209
+ condition: day.condition,
210
+ size: 14,
211
+ className: "text-muted-foreground"
212
+ }),
213
+ /* @__PURE__ */ jsx("span", {
214
+ className: "truncate",
215
+ children: LABEL[day.condition]
216
+ })
217
+ ]
218
+ })
219
+ });
220
+ }
221
+ function Loading({ location, className }) {
222
+ return /* @__PURE__ */ jsx(widget_default, {
223
+ className,
224
+ aside: /* @__PURE__ */ jsxs("div", {
225
+ "aria-hidden": true,
226
+ className: "flex flex-col gap-3",
227
+ children: [
228
+ /* @__PURE__ */ jsx(Skeleton, {
229
+ className: "h-3 w-20"
230
+ }),
231
+ /* @__PURE__ */ jsx("div", {
232
+ className: "flex justify-between",
233
+ children: Array.from({ length: HOURS }, (_, i) => /* @__PURE__ */ jsx(Skeleton, {
234
+ className: "h-14 w-7"
235
+ }, i))
236
+ }),
237
+ /* @__PURE__ */ jsx(Skeleton, {
238
+ className: "h-3 w-full"
239
+ })
240
+ ]
241
+ }),
242
+ children: /* @__PURE__ */ jsxs("div", {
243
+ "aria-busy": true,
244
+ className: "flex min-w-0 flex-col gap-2",
245
+ children: [
246
+ /* @__PURE__ */ jsx(widget_default.Header, {
247
+ icon: MapPin,
248
+ children: location ?? "Finding you…"
249
+ }),
250
+ /* @__PURE__ */ jsx(Skeleton, {
251
+ className: "h-8 w-28"
252
+ }),
253
+ /* @__PURE__ */ jsx(Skeleton, {
254
+ className: "h-4 w-40"
255
+ }),
256
+ /* @__PURE__ */ jsx(Skeleton, {
257
+ className: "h-3 w-56"
258
+ })
259
+ ]
260
+ })
261
+ });
262
+ }
263
+ function WeatherLeading2({ current }) {
264
+ return /* @__PURE__ */ jsx(Glyph, {
265
+ condition: current.condition,
266
+ isDay: current.isDay,
267
+ size: 16,
268
+ className: hueFor(current.condition, current.isDay)
269
+ });
270
+ }
271
+ function WeatherTrailing2({ current, unit = "celsius" }) {
272
+ return /* @__PURE__ */ jsx("span", {
273
+ className: "text-caption weight-semibold text-foreground tabular-nums",
274
+ children: temp(current.temperature, unit)
275
+ });
276
+ }
277
+ function WeatherMinimal2({ current }) {
278
+ const level = useLift(1);
279
+ return /* @__PURE__ */ jsx("span", {
280
+ role: "img",
281
+ "aria-label": LABEL[current.condition],
282
+ className: cn("flex size-6 items-center justify-center rounded-full", SURFACE_BG[level], hueFor(current.condition, current.isDay)),
283
+ children: /* @__PURE__ */ jsx(Glyph, {
284
+ condition: current.condition,
285
+ isDay: current.isDay,
286
+ size: 14
287
+ })
288
+ });
289
+ }
290
+ var ALERT_TILE = {
291
+ notice: "bg-status-info/16 text-status-info",
292
+ warning: "bg-status-warning/16 text-status-warning",
293
+ severe: "bg-status-error/16 text-status-error"
294
+ };
295
+ function WeatherAlert2({
296
+ condition,
297
+ startsAt,
298
+ title,
299
+ caption,
300
+ severity = "notice",
301
+ actionLabel = "Details",
302
+ onAction
303
+ }) {
304
+ const now = useEdgeClock2(startsAt ?? 0, startsAt !== undefined && title === undefined, MINUTE2);
305
+ const left = startsAt === undefined ? 0 : Math.ceil((startsAt - now) / MINUTE2);
306
+ const heading = title ?? (left > 0 ? `${LABEL[condition]} in ${left} min` : `${LABEL[condition]} now`);
307
+ return /* @__PURE__ */ jsx(IslandFlash2, {
308
+ icon: /* @__PURE__ */ jsx("span", {
309
+ className: cn("flex size-9 items-center justify-center rounded-lg", ALERT_TILE[severity]),
310
+ children: /* @__PURE__ */ jsx(Glyph, {
311
+ condition,
312
+ size: 16
313
+ })
314
+ }),
315
+ title: heading,
316
+ caption,
317
+ action: onAction && /* @__PURE__ */ jsx(Button, {
318
+ variant: "secondary",
319
+ size: "compact",
320
+ onClick: onAction,
321
+ children: actionLabel
322
+ })
323
+ });
324
+ }
325
+ var Weather2 = Object.assign(function Weather({
326
+ location,
327
+ current,
328
+ hours = [],
329
+ days = [],
330
+ unit = "celsius",
331
+ access = "granted",
332
+ status = "ready",
333
+ now: nowProp,
334
+ locale,
335
+ onRefresh,
336
+ onRequestAccess,
337
+ onOpenSettings,
338
+ className
339
+ }) {
340
+ const size = useSize();
341
+ const ticking = useEdgeClock2(current?.time ?? 0, nowProp === undefined, MINUTE2);
342
+ const now = nowProp ?? ticking;
343
+ if (access === "undetermined")
344
+ return /* @__PURE__ */ jsx(widget_default.Message, {
345
+ icon: MapPin,
346
+ title: "Weather where you are",
347
+ description: "The temperature now, the next hours and tomorrow, for your location.",
348
+ actions: /* @__PURE__ */ jsx(Button, {
349
+ variant: "primary",
350
+ size: "compact",
351
+ onClick: onRequestAccess,
352
+ children: "Allow location"
353
+ }),
354
+ className
355
+ });
356
+ if (access === "denied")
357
+ return /* @__PURE__ */ jsx(widget_default.Message, {
358
+ icon: LocateOff,
359
+ title: "Location access is off",
360
+ description: "Turn it on in System Settings › Privacy & Security › Location Services.",
361
+ actions: /* @__PURE__ */ jsx(Button, {
362
+ variant: "secondary",
363
+ size: "compact",
364
+ onClick: onOpenSettings,
365
+ children: "Open System Settings"
366
+ }),
367
+ className
368
+ });
369
+ if (!current && status === "error")
370
+ return /* @__PURE__ */ jsx(widget_default.Message, {
371
+ icon: CloudOff,
372
+ title: "Couldn't load the weather",
373
+ description: "The forecast service didn't answer. It tries again on its own in a few minutes.",
374
+ actions: onRefresh && /* @__PURE__ */ jsx(Button, {
375
+ variant: "secondary",
376
+ size: "compact",
377
+ onClick: onRefresh,
378
+ children: "Try again"
379
+ }),
380
+ className
381
+ });
382
+ if (!current && status === "offline")
383
+ return /* @__PURE__ */ jsx(widget_default.Message, {
384
+ icon: WifiOff,
385
+ title: "You're offline",
386
+ description: "The forecast loads as soon as you're back online.",
387
+ className
388
+ });
389
+ if (!current)
390
+ return /* @__PURE__ */ jsx(Loading, {
391
+ location,
392
+ className
393
+ });
394
+ const hourStart = new Date(now).setMinutes(0, 0, 0);
395
+ const ahead = hours.filter((hour) => hour.time >= hourStart).sort((a, b) => a.time - b.time);
396
+ const [today, tomorrow] = days;
397
+ const rain = rainAhead(current, ahead);
398
+ const fresh = ago(Math.max(0, now - current.time));
399
+ const freshness = status === "offline" ? `Offline · ${fresh}` : status === "error" ? `Not updated · ${fresh}` : fresh;
400
+ const feels = current.apparent !== undefined && `Feels like ${temp(current.apparent, unit)}`;
401
+ const soon = rain && `${LABEL[rain.condition]} around ${hourOf(rain.time, locale)}`;
402
+ return /* @__PURE__ */ jsxs(widget_default, {
403
+ className,
404
+ aside: ahead.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
405
+ children: [
406
+ /* @__PURE__ */ jsx(widget_default.Section, {
407
+ label: "Next hours",
408
+ children: /* @__PURE__ */ jsx(Hours, {
409
+ hours: ahead.slice(0, HOURS),
410
+ unit,
411
+ locale
412
+ })
413
+ }),
414
+ tomorrow && /* @__PURE__ */ jsx("div", {
415
+ className: "mt-1.5",
416
+ children: /* @__PURE__ */ jsx(Tomorrow, {
417
+ day: tomorrow,
418
+ unit
419
+ })
420
+ })
421
+ ]
422
+ }),
423
+ children: [
424
+ /* @__PURE__ */ jsx(widget_default.Header, {
425
+ icon: MapPin,
426
+ trailing: /* @__PURE__ */ jsxs(Fragment, {
427
+ children: [
428
+ /* @__PURE__ */ jsx("span", {
429
+ className: "whitespace-nowrap pr-1 text-caption",
430
+ children: freshness
431
+ }),
432
+ onRefresh && /* @__PURE__ */ jsx(widget_default.Action, {
433
+ icon: RotateCw,
434
+ label: "Refresh",
435
+ onClick: onRefresh
436
+ })
437
+ ]
438
+ }),
439
+ children: location ?? "Current location"
440
+ }),
441
+ /* @__PURE__ */ jsxs("div", {
442
+ className: "flex min-w-0 items-center gap-2.5",
443
+ children: [
444
+ /* @__PURE__ */ jsx(Glyph, {
445
+ condition: current.condition,
446
+ isDay: current.isDay,
447
+ size: HERO_GLYPH[size.variant],
448
+ className: hueFor(current.condition, current.isDay)
449
+ }),
450
+ /* @__PURE__ */ jsx(widget_default.Figure, {
451
+ value: degrees(current.temperature, unit),
452
+ unit: unit === "fahrenheit" ? "°F" : "°C"
453
+ })
454
+ ]
455
+ }),
456
+ /* @__PURE__ */ jsxs("div", {
457
+ className: "flex min-w-0 flex-col gap-0.5",
458
+ children: [
459
+ /* @__PURE__ */ jsx(widget_default.Title, {
460
+ children: LABEL[current.condition]
461
+ }),
462
+ (feels || soon) && /* @__PURE__ */ jsx(widget_default.Subtitle, {
463
+ children: [feels, soon].filter(Boolean).join(" · ")
464
+ })
465
+ ]
466
+ }),
467
+ /* @__PURE__ */ jsxs(widget_default.Meta, {
468
+ className: "mt-1",
469
+ children: [
470
+ today && /* @__PURE__ */ jsxs(Fragment, {
471
+ children: [
472
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
473
+ icon: ArrowUp,
474
+ children: temp(today.high, unit)
475
+ }),
476
+ /* @__PURE__ */ jsx(widget_default.MetaItem, {
477
+ icon: ArrowDown,
478
+ children: temp(today.low, unit)
479
+ })
480
+ ]
481
+ }),
482
+ today?.precipitation !== undefined && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
483
+ icon: Umbrella,
484
+ children: [
485
+ today.precipitation,
486
+ "%"
487
+ ]
488
+ }),
489
+ current.wind !== undefined && /* @__PURE__ */ jsx(widget_default.MetaItem, {
490
+ icon: Wind,
491
+ children: speed(current.wind, unit)
492
+ }),
493
+ current.humidity !== undefined && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
494
+ icon: Droplets,
495
+ children: [
496
+ Math.round(current.humidity),
497
+ "%"
498
+ ]
499
+ }),
500
+ current.uv !== undefined && /* @__PURE__ */ jsxs(widget_default.MetaItem, {
501
+ icon: Sun,
502
+ children: [
503
+ "UV ",
504
+ Math.round(current.uv)
505
+ ]
506
+ })
507
+ ]
508
+ })
509
+ ]
510
+ });
511
+ }, {
512
+ Leading: WeatherLeading2,
513
+ Trailing: WeatherTrailing2,
514
+ Minimal: WeatherMinimal2,
515
+ Alert: WeatherAlert2
516
+ });
517
+ var weather_default = Weather2;
518
+ export { conditionFromCode2, WeatherLeading2, WeatherTrailing2, WeatherMinimal2, WeatherAlert2, Weather2, weather_default };