@wral/active-alerts 0.1.4

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.
@@ -0,0 +1,9 @@
1
+ import { W as t } from "./wral-active-alerts-CSZAUUIB.js";
2
+ function i() {
3
+ const e = globalThis?.customElements;
4
+ e && (e.get("wral-active-alerts") || e.define("wral-active-alerts", t));
5
+ }
6
+ typeof window < "u" && globalThis.customElements && i();
7
+ export {
8
+ i as defineAll
9
+ };
@@ -0,0 +1,857 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ const H = globalThis, L = H.ShadowRoot && (H.ShadyCSS === void 0 || H.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, j = Symbol(), V = /* @__PURE__ */ new WeakMap();
7
+ let tt = class {
8
+ constructor(t, e, s) {
9
+ if (this._$cssResult$ = !0, s !== j) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
10
+ this.cssText = t, this.t = e;
11
+ }
12
+ get styleSheet() {
13
+ let t = this.o;
14
+ const e = this.t;
15
+ if (L && t === void 0) {
16
+ const s = e !== void 0 && e.length === 1;
17
+ s && (t = V.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && V.set(e, t));
18
+ }
19
+ return t;
20
+ }
21
+ toString() {
22
+ return this.cssText;
23
+ }
24
+ };
25
+ const at = (i) => new tt(typeof i == "string" ? i : i + "", void 0, j), lt = (i, ...t) => {
26
+ const e = i.length === 1 ? i[0] : t.reduce(((s, r, n) => s + ((o) => {
27
+ if (o._$cssResult$ === !0) return o.cssText;
28
+ if (typeof o == "number") return o;
29
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + o + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
30
+ })(r) + i[n + 1]), i[0]);
31
+ return new tt(e, i, j);
32
+ }, ht = (i, t) => {
33
+ if (L) i.adoptedStyleSheets = t.map(((e) => e instanceof CSSStyleSheet ? e : e.styleSheet));
34
+ else for (const e of t) {
35
+ const s = document.createElement("style"), r = H.litNonce;
36
+ r !== void 0 && s.setAttribute("nonce", r), s.textContent = e.cssText, i.appendChild(s);
37
+ }
38
+ }, q = L ? (i) => i : (i) => i instanceof CSSStyleSheet ? ((t) => {
39
+ let e = "";
40
+ for (const s of t.cssRules) e += s.cssText;
41
+ return at(e);
42
+ })(i) : i;
43
+ /**
44
+ * @license
45
+ * Copyright 2017 Google LLC
46
+ * SPDX-License-Identifier: BSD-3-Clause
47
+ */
48
+ const { is: ct, defineProperty: dt, getOwnPropertyDescriptor: pt, getOwnPropertyNames: ut, getOwnPropertySymbols: ft, getPrototypeOf: $t } = Object, M = globalThis, F = M.trustedTypes, mt = F ? F.emptyScript : "", gt = M.reactiveElementPolyfillSupport, x = (i, t) => i, z = { toAttribute(i, t) {
49
+ switch (t) {
50
+ case Boolean:
51
+ i = i ? mt : null;
52
+ break;
53
+ case Object:
54
+ case Array:
55
+ i = i == null ? i : JSON.stringify(i);
56
+ }
57
+ return i;
58
+ }, fromAttribute(i, t) {
59
+ let e = i;
60
+ switch (t) {
61
+ case Boolean:
62
+ e = i !== null;
63
+ break;
64
+ case Number:
65
+ e = i === null ? null : Number(i);
66
+ break;
67
+ case Object:
68
+ case Array:
69
+ try {
70
+ e = JSON.parse(i);
71
+ } catch {
72
+ e = null;
73
+ }
74
+ }
75
+ return e;
76
+ } }, et = (i, t) => !ct(i, t), K = { attribute: !0, type: String, converter: z, reflect: !1, useDefault: !1, hasChanged: et };
77
+ Symbol.metadata ??= Symbol("metadata"), M.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
78
+ let b = class extends HTMLElement {
79
+ static addInitializer(t) {
80
+ this._$Ei(), (this.l ??= []).push(t);
81
+ }
82
+ static get observedAttributes() {
83
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
84
+ }
85
+ static createProperty(t, e = K) {
86
+ if (e.state && (e.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(t) && ((e = Object.create(e)).wrapped = !0), this.elementProperties.set(t, e), !e.noAccessor) {
87
+ const s = Symbol(), r = this.getPropertyDescriptor(t, s, e);
88
+ r !== void 0 && dt(this.prototype, t, r);
89
+ }
90
+ }
91
+ static getPropertyDescriptor(t, e, s) {
92
+ const { get: r, set: n } = pt(this.prototype, t) ?? { get() {
93
+ return this[e];
94
+ }, set(o) {
95
+ this[e] = o;
96
+ } };
97
+ return { get: r, set(o) {
98
+ const c = r?.call(this);
99
+ n?.call(this, o), this.requestUpdate(t, c, s);
100
+ }, configurable: !0, enumerable: !0 };
101
+ }
102
+ static getPropertyOptions(t) {
103
+ return this.elementProperties.get(t) ?? K;
104
+ }
105
+ static _$Ei() {
106
+ if (this.hasOwnProperty(x("elementProperties"))) return;
107
+ const t = $t(this);
108
+ t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
109
+ }
110
+ static finalize() {
111
+ if (this.hasOwnProperty(x("finalized"))) return;
112
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(x("properties"))) {
113
+ const e = this.properties, s = [...ut(e), ...ft(e)];
114
+ for (const r of s) this.createProperty(r, e[r]);
115
+ }
116
+ const t = this[Symbol.metadata];
117
+ if (t !== null) {
118
+ const e = litPropertyMetadata.get(t);
119
+ if (e !== void 0) for (const [s, r] of e) this.elementProperties.set(s, r);
120
+ }
121
+ this._$Eh = /* @__PURE__ */ new Map();
122
+ for (const [e, s] of this.elementProperties) {
123
+ const r = this._$Eu(e, s);
124
+ r !== void 0 && this._$Eh.set(r, e);
125
+ }
126
+ this.elementStyles = this.finalizeStyles(this.styles);
127
+ }
128
+ static finalizeStyles(t) {
129
+ const e = [];
130
+ if (Array.isArray(t)) {
131
+ const s = new Set(t.flat(1 / 0).reverse());
132
+ for (const r of s) e.unshift(q(r));
133
+ } else t !== void 0 && e.push(q(t));
134
+ return e;
135
+ }
136
+ static _$Eu(t, e) {
137
+ const s = e.attribute;
138
+ return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
139
+ }
140
+ constructor() {
141
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
142
+ }
143
+ _$Ev() {
144
+ this._$ES = new Promise(((t) => this.enableUpdating = t)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t) => t(this)));
145
+ }
146
+ addController(t) {
147
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(t), this.renderRoot !== void 0 && this.isConnected && t.hostConnected?.();
148
+ }
149
+ removeController(t) {
150
+ this._$EO?.delete(t);
151
+ }
152
+ _$E_() {
153
+ const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
154
+ for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
155
+ t.size > 0 && (this._$Ep = t);
156
+ }
157
+ createRenderRoot() {
158
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
159
+ return ht(t, this.constructor.elementStyles), t;
160
+ }
161
+ connectedCallback() {
162
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach(((t) => t.hostConnected?.()));
163
+ }
164
+ enableUpdating(t) {
165
+ }
166
+ disconnectedCallback() {
167
+ this._$EO?.forEach(((t) => t.hostDisconnected?.()));
168
+ }
169
+ attributeChangedCallback(t, e, s) {
170
+ this._$AK(t, s);
171
+ }
172
+ _$ET(t, e) {
173
+ const s = this.constructor.elementProperties.get(t), r = this.constructor._$Eu(t, s);
174
+ if (r !== void 0 && s.reflect === !0) {
175
+ const n = (s.converter?.toAttribute !== void 0 ? s.converter : z).toAttribute(e, s.type);
176
+ this._$Em = t, n == null ? this.removeAttribute(r) : this.setAttribute(r, n), this._$Em = null;
177
+ }
178
+ }
179
+ _$AK(t, e) {
180
+ const s = this.constructor, r = s._$Eh.get(t);
181
+ if (r !== void 0 && this._$Em !== r) {
182
+ const n = s.getPropertyOptions(r), o = typeof n.converter == "function" ? { fromAttribute: n.converter } : n.converter?.fromAttribute !== void 0 ? n.converter : z;
183
+ this._$Em = r;
184
+ const c = o.fromAttribute(e, n.type);
185
+ this[r] = c ?? this._$Ej?.get(r) ?? c, this._$Em = null;
186
+ }
187
+ }
188
+ requestUpdate(t, e, s) {
189
+ if (t !== void 0) {
190
+ const r = this.constructor, n = this[t];
191
+ if (s ??= r.getPropertyOptions(t), !((s.hasChanged ?? et)(n, e) || s.useDefault && s.reflect && n === this._$Ej?.get(t) && !this.hasAttribute(r._$Eu(t, s)))) return;
192
+ this.C(t, e, s);
193
+ }
194
+ this.isUpdatePending === !1 && (this._$ES = this._$EP());
195
+ }
196
+ C(t, e, { useDefault: s, reflect: r, wrapped: n }, o) {
197
+ s && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t) && (this._$Ej.set(t, o ?? e ?? this[t]), n !== !0 || o !== void 0) || (this._$AL.has(t) || (this.hasUpdated || s || (e = void 0), this._$AL.set(t, e)), r === !0 && this._$Em !== t && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t));
198
+ }
199
+ async _$EP() {
200
+ this.isUpdatePending = !0;
201
+ try {
202
+ await this._$ES;
203
+ } catch (e) {
204
+ Promise.reject(e);
205
+ }
206
+ const t = this.scheduleUpdate();
207
+ return t != null && await t, !this.isUpdatePending;
208
+ }
209
+ scheduleUpdate() {
210
+ return this.performUpdate();
211
+ }
212
+ performUpdate() {
213
+ if (!this.isUpdatePending) return;
214
+ if (!this.hasUpdated) {
215
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
216
+ for (const [r, n] of this._$Ep) this[r] = n;
217
+ this._$Ep = void 0;
218
+ }
219
+ const s = this.constructor.elementProperties;
220
+ if (s.size > 0) for (const [r, n] of s) {
221
+ const { wrapped: o } = n, c = this[r];
222
+ o !== !0 || this._$AL.has(r) || c === void 0 || this.C(r, void 0, n, c);
223
+ }
224
+ }
225
+ let t = !1;
226
+ const e = this._$AL;
227
+ try {
228
+ t = this.shouldUpdate(e), t ? (this.willUpdate(e), this._$EO?.forEach(((s) => s.hostUpdate?.())), this.update(e)) : this._$EM();
229
+ } catch (s) {
230
+ throw t = !1, this._$EM(), s;
231
+ }
232
+ t && this._$AE(e);
233
+ }
234
+ willUpdate(t) {
235
+ }
236
+ _$AE(t) {
237
+ this._$EO?.forEach(((e) => e.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
238
+ }
239
+ _$EM() {
240
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
241
+ }
242
+ get updateComplete() {
243
+ return this.getUpdateComplete();
244
+ }
245
+ getUpdateComplete() {
246
+ return this._$ES;
247
+ }
248
+ shouldUpdate(t) {
249
+ return !0;
250
+ }
251
+ update(t) {
252
+ this._$Eq &&= this._$Eq.forEach(((e) => this._$ET(e, this[e]))), this._$EM();
253
+ }
254
+ updated(t) {
255
+ }
256
+ firstUpdated(t) {
257
+ }
258
+ };
259
+ b.elementStyles = [], b.shadowRootOptions = { mode: "open" }, b[x("elementProperties")] = /* @__PURE__ */ new Map(), b[x("finalized")] = /* @__PURE__ */ new Map(), gt?.({ ReactiveElement: b }), (M.reactiveElementVersions ??= []).push("2.1.1");
260
+ /**
261
+ * @license
262
+ * Copyright 2017 Google LLC
263
+ * SPDX-License-Identifier: BSD-3-Clause
264
+ */
265
+ const D = globalThis, I = D.trustedTypes, J = I ? I.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, st = "$lit$", m = `lit$${Math.random().toFixed(9).slice(2)}$`, it = "?" + m, _t = `<${it}>`, y = document, P = () => y.createComment(""), U = (i) => i === null || typeof i != "object" && typeof i != "function", B = Array.isArray, At = (i) => B(i) || typeof i?.[Symbol.iterator] == "function", R = `[
266
+ \f\r]`, w = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Z = /-->/g, G = />/g, g = RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^
267
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), Q = /'/g, X = /"/g, rt = /^(?:script|style|textarea|title)$/i, yt = (i) => (t, ...e) => ({ _$litType$: i, strings: t, values: e }), $ = yt(1), E = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), Y = /* @__PURE__ */ new WeakMap(), A = y.createTreeWalker(y, 129);
268
+ function nt(i, t) {
269
+ if (!B(i) || !i.hasOwnProperty("raw")) throw Error("invalid template strings array");
270
+ return J !== void 0 ? J.createHTML(t) : t;
271
+ }
272
+ const vt = (i, t) => {
273
+ const e = i.length - 1, s = [];
274
+ let r, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = w;
275
+ for (let c = 0; c < e; c++) {
276
+ const a = i[c];
277
+ let d, l, h = -1, u = 0;
278
+ for (; u < a.length && (o.lastIndex = u, l = o.exec(a), l !== null); ) u = o.lastIndex, o === w ? l[1] === "!--" ? o = Z : l[1] !== void 0 ? o = G : l[2] !== void 0 ? (rt.test(l[2]) && (r = RegExp("</" + l[2], "g")), o = g) : l[3] !== void 0 && (o = g) : o === g ? l[0] === ">" ? (o = r ?? w, h = -1) : l[1] === void 0 ? h = -2 : (h = o.lastIndex - l[2].length, d = l[1], o = l[3] === void 0 ? g : l[3] === '"' ? X : Q) : o === X || o === Q ? o = g : o === Z || o === G ? o = w : (o = g, r = void 0);
279
+ const f = o === g && i[c + 1].startsWith("/>") ? " " : "";
280
+ n += o === w ? a + _t : h >= 0 ? (s.push(d), a.slice(0, h) + st + a.slice(h) + m + f) : a + m + (h === -2 ? c : f);
281
+ }
282
+ return [nt(i, n + (i[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
283
+ };
284
+ class T {
285
+ constructor({ strings: t, _$litType$: e }, s) {
286
+ let r;
287
+ this.parts = [];
288
+ let n = 0, o = 0;
289
+ const c = t.length - 1, a = this.parts, [d, l] = vt(t, e);
290
+ if (this.el = T.createElement(d, s), A.currentNode = this.el.content, e === 2 || e === 3) {
291
+ const h = this.el.content.firstChild;
292
+ h.replaceWith(...h.childNodes);
293
+ }
294
+ for (; (r = A.nextNode()) !== null && a.length < c; ) {
295
+ if (r.nodeType === 1) {
296
+ if (r.hasAttributes()) for (const h of r.getAttributeNames()) if (h.endsWith(st)) {
297
+ const u = l[o++], f = r.getAttribute(h).split(m), N = /([.?@])?(.*)/.exec(u);
298
+ a.push({ type: 1, index: n, name: N[2], strings: f, ctor: N[1] === "." ? Et : N[1] === "?" ? St : N[1] === "@" ? wt : k }), r.removeAttribute(h);
299
+ } else h.startsWith(m) && (a.push({ type: 6, index: n }), r.removeAttribute(h));
300
+ if (rt.test(r.tagName)) {
301
+ const h = r.textContent.split(m), u = h.length - 1;
302
+ if (u > 0) {
303
+ r.textContent = I ? I.emptyScript : "";
304
+ for (let f = 0; f < u; f++) r.append(h[f], P()), A.nextNode(), a.push({ type: 2, index: ++n });
305
+ r.append(h[u], P());
306
+ }
307
+ }
308
+ } else if (r.nodeType === 8) if (r.data === it) a.push({ type: 2, index: n });
309
+ else {
310
+ let h = -1;
311
+ for (; (h = r.data.indexOf(m, h + 1)) !== -1; ) a.push({ type: 7, index: n }), h += m.length - 1;
312
+ }
313
+ n++;
314
+ }
315
+ }
316
+ static createElement(t, e) {
317
+ const s = y.createElement("template");
318
+ return s.innerHTML = t, s;
319
+ }
320
+ }
321
+ function S(i, t, e = i, s) {
322
+ if (t === E) return t;
323
+ let r = s !== void 0 ? e._$Co?.[s] : e._$Cl;
324
+ const n = U(t) ? void 0 : t._$litDirective$;
325
+ return r?.constructor !== n && (r?._$AO?.(!1), n === void 0 ? r = void 0 : (r = new n(i), r._$AT(i, e, s)), s !== void 0 ? (e._$Co ??= [])[s] = r : e._$Cl = r), r !== void 0 && (t = S(i, r._$AS(i, t.values), r, s)), t;
326
+ }
327
+ class bt {
328
+ constructor(t, e) {
329
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
330
+ }
331
+ get parentNode() {
332
+ return this._$AM.parentNode;
333
+ }
334
+ get _$AU() {
335
+ return this._$AM._$AU;
336
+ }
337
+ u(t) {
338
+ const { el: { content: e }, parts: s } = this._$AD, r = (t?.creationScope ?? y).importNode(e, !0);
339
+ A.currentNode = r;
340
+ let n = A.nextNode(), o = 0, c = 0, a = s[0];
341
+ for (; a !== void 0; ) {
342
+ if (o === a.index) {
343
+ let d;
344
+ a.type === 2 ? d = new O(n, n.nextSibling, this, t) : a.type === 1 ? d = new a.ctor(n, a.name, a.strings, this, t) : a.type === 6 && (d = new xt(n, this, t)), this._$AV.push(d), a = s[++c];
345
+ }
346
+ o !== a?.index && (n = A.nextNode(), o++);
347
+ }
348
+ return A.currentNode = y, r;
349
+ }
350
+ p(t) {
351
+ let e = 0;
352
+ for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
353
+ }
354
+ }
355
+ class O {
356
+ get _$AU() {
357
+ return this._$AM?._$AU ?? this._$Cv;
358
+ }
359
+ constructor(t, e, s, r) {
360
+ this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = r, this._$Cv = r?.isConnected ?? !0;
361
+ }
362
+ get parentNode() {
363
+ let t = this._$AA.parentNode;
364
+ const e = this._$AM;
365
+ return e !== void 0 && t?.nodeType === 11 && (t = e.parentNode), t;
366
+ }
367
+ get startNode() {
368
+ return this._$AA;
369
+ }
370
+ get endNode() {
371
+ return this._$AB;
372
+ }
373
+ _$AI(t, e = this) {
374
+ t = S(this, t, e), U(t) ? t === p || t == null || t === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : t !== this._$AH && t !== E && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : At(t) ? this.k(t) : this._(t);
375
+ }
376
+ O(t) {
377
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
378
+ }
379
+ T(t) {
380
+ this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
381
+ }
382
+ _(t) {
383
+ this._$AH !== p && U(this._$AH) ? this._$AA.nextSibling.data = t : this.T(y.createTextNode(t)), this._$AH = t;
384
+ }
385
+ $(t) {
386
+ const { values: e, _$litType$: s } = t, r = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = T.createElement(nt(s.h, s.h[0]), this.options)), s);
387
+ if (this._$AH?._$AD === r) this._$AH.p(e);
388
+ else {
389
+ const n = new bt(r, this), o = n.u(this.options);
390
+ n.p(e), this.T(o), this._$AH = n;
391
+ }
392
+ }
393
+ _$AC(t) {
394
+ let e = Y.get(t.strings);
395
+ return e === void 0 && Y.set(t.strings, e = new T(t)), e;
396
+ }
397
+ k(t) {
398
+ B(this._$AH) || (this._$AH = [], this._$AR());
399
+ const e = this._$AH;
400
+ let s, r = 0;
401
+ for (const n of t) r === e.length ? e.push(s = new O(this.O(P()), this.O(P()), this, this.options)) : s = e[r], s._$AI(n), r++;
402
+ r < e.length && (this._$AR(s && s._$AB.nextSibling, r), e.length = r);
403
+ }
404
+ _$AR(t = this._$AA.nextSibling, e) {
405
+ for (this._$AP?.(!1, !0, e); t !== this._$AB; ) {
406
+ const s = t.nextSibling;
407
+ t.remove(), t = s;
408
+ }
409
+ }
410
+ setConnected(t) {
411
+ this._$AM === void 0 && (this._$Cv = t, this._$AP?.(t));
412
+ }
413
+ }
414
+ class k {
415
+ get tagName() {
416
+ return this.element.tagName;
417
+ }
418
+ get _$AU() {
419
+ return this._$AM._$AU;
420
+ }
421
+ constructor(t, e, s, r, n) {
422
+ this.type = 1, this._$AH = p, this._$AN = void 0, this.element = t, this.name = e, this._$AM = r, this.options = n, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = p;
423
+ }
424
+ _$AI(t, e = this, s, r) {
425
+ const n = this.strings;
426
+ let o = !1;
427
+ if (n === void 0) t = S(this, t, e, 0), o = !U(t) || t !== this._$AH && t !== E, o && (this._$AH = t);
428
+ else {
429
+ const c = t;
430
+ let a, d;
431
+ for (t = n[0], a = 0; a < n.length - 1; a++) d = S(this, c[s + a], e, a), d === E && (d = this._$AH[a]), o ||= !U(d) || d !== this._$AH[a], d === p ? t = p : t !== p && (t += (d ?? "") + n[a + 1]), this._$AH[a] = d;
432
+ }
433
+ o && !r && this.j(t);
434
+ }
435
+ j(t) {
436
+ t === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
437
+ }
438
+ }
439
+ class Et extends k {
440
+ constructor() {
441
+ super(...arguments), this.type = 3;
442
+ }
443
+ j(t) {
444
+ this.element[this.name] = t === p ? void 0 : t;
445
+ }
446
+ }
447
+ class St extends k {
448
+ constructor() {
449
+ super(...arguments), this.type = 4;
450
+ }
451
+ j(t) {
452
+ this.element.toggleAttribute(this.name, !!t && t !== p);
453
+ }
454
+ }
455
+ class wt extends k {
456
+ constructor(t, e, s, r, n) {
457
+ super(t, e, s, r, n), this.type = 5;
458
+ }
459
+ _$AI(t, e = this) {
460
+ if ((t = S(this, t, e, 0) ?? p) === E) return;
461
+ const s = this._$AH, r = t === p && s !== p || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, n = t !== p && (s === p || r);
462
+ r && this.element.removeEventListener(this.name, this, s), n && this.element.addEventListener(this.name, this, t), this._$AH = t;
463
+ }
464
+ handleEvent(t) {
465
+ typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, t) : this._$AH.handleEvent(t);
466
+ }
467
+ }
468
+ class xt {
469
+ constructor(t, e, s) {
470
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
471
+ }
472
+ get _$AU() {
473
+ return this._$AM._$AU;
474
+ }
475
+ _$AI(t) {
476
+ S(this, t);
477
+ }
478
+ }
479
+ const Ct = D.litHtmlPolyfillSupport;
480
+ Ct?.(T, O), (D.litHtmlVersions ??= []).push("3.3.1");
481
+ const Pt = (i, t, e) => {
482
+ const s = e?.renderBefore ?? t;
483
+ let r = s._$litPart$;
484
+ if (r === void 0) {
485
+ const n = e?.renderBefore ?? null;
486
+ s._$litPart$ = r = new O(t.insertBefore(P(), n), n, void 0, e ?? {});
487
+ }
488
+ return r._$AI(i), r;
489
+ };
490
+ /**
491
+ * @license
492
+ * Copyright 2017 Google LLC
493
+ * SPDX-License-Identifier: BSD-3-Clause
494
+ */
495
+ const W = globalThis;
496
+ class C extends b {
497
+ constructor() {
498
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
499
+ }
500
+ createRenderRoot() {
501
+ const t = super.createRenderRoot();
502
+ return this.renderOptions.renderBefore ??= t.firstChild, t;
503
+ }
504
+ update(t) {
505
+ const e = this.render();
506
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Pt(e, this.renderRoot, this.renderOptions);
507
+ }
508
+ connectedCallback() {
509
+ super.connectedCallback(), this._$Do?.setConnected(!0);
510
+ }
511
+ disconnectedCallback() {
512
+ super.disconnectedCallback(), this._$Do?.setConnected(!1);
513
+ }
514
+ render() {
515
+ return E;
516
+ }
517
+ }
518
+ C._$litElement$ = !0, C.finalized = !0, W.litElementHydrateSupport?.({ LitElement: C });
519
+ const Ut = W.litElementPolyfillSupport;
520
+ Ut?.({ LitElement: C });
521
+ (W.litElementVersions ??= []).push("4.2.1");
522
+ const _ = (i, ...t) => (...e) => i(...t, ...e);
523
+ function Tt(i) {
524
+ return {
525
+ // Underlying mechanism to use the REST URLs directly.
526
+ api: _(v, i),
527
+ listActiveAlerts: _(Ot, i),
528
+ getActiveAlert: _(Nt, i),
529
+ listAlerts: _(Ht, i),
530
+ getAlert: _(It, i),
531
+ sendAlert: _(Mt, i),
532
+ cancelAlert: _(kt, i)
533
+ };
534
+ }
535
+ function Ot(i) {
536
+ const t = Object.assign({}, i, { apiKey: void 0 });
537
+ return v(t, "/v1/active/alerts");
538
+ }
539
+ function Nt(i, t) {
540
+ const e = Object.assign({}, i, { apiKey: void 0 });
541
+ return v(e, `/v1/active/alerts/${t}`);
542
+ }
543
+ function Ht(i) {
544
+ return v(i, "/v1/alerts");
545
+ }
546
+ function It(i, t) {
547
+ return v(i, `/v1/alerts/${t}`);
548
+ }
549
+ function Mt(i, t) {
550
+ return v(i, "/v1/alerts", {
551
+ method: "POST",
552
+ body: t
553
+ });
554
+ }
555
+ function kt(i, t) {
556
+ return v(i, `/v1/alerts/${t}`, {
557
+ method: "DELETE"
558
+ });
559
+ }
560
+ async function v(i, t, e) {
561
+ const s = i.baseUrl.endsWith("/") ? i.baseUrl : `${i.baseUrl}/`, r = t.startsWith("/") ? t.substring(1) : t, n = new URL(r, s), o = {
562
+ "Content-Type": "application/json"
563
+ };
564
+ i.apiKey && (o.Authorization = `Bearer ${i.apiKey}`);
565
+ const c = Object.assign({}, e, {
566
+ headers: Object.assign({}, o, e?.headers),
567
+ body: e?.body ? JSON.stringify(e.body) : void 0
568
+ }), a = await fetch(n.toString(), c);
569
+ if (!a.ok) {
570
+ const l = new Error("API request failed.", { cause: a });
571
+ if (l.status = a.status, l.statusText = a.statusText, l.url = n.toString(), l.headers = a.headers, l.bodyUsed = a.bodyUsed, a.headers.get("Content-Type")?.includes("application/json"))
572
+ try {
573
+ l.body = await a.json();
574
+ } catch {
575
+ l.body = "Failed to parse response body.";
576
+ }
577
+ throw l;
578
+ }
579
+ if (a.status === 204)
580
+ return;
581
+ const d = await a.json();
582
+ return d.caption && console.warn("Alert API provided a value with a caption field. The caption field is deprecated and will be removed."), (d?.items || []).some((l) => l.caption) && console.warn("Alert API provided an item with a caption field. The caption field is deprecated and will be removed."), d;
583
+ }
584
+ const Rt = "https://api.wral.com/alerts/v1/active/alerts", zt = "https://assets.wral.com/a1cc0e86-adab-48e9-bd80-703cd2c56aff?w=1200&h=630", Lt = (i) => String(i || "Alert").replace(/[^\p{L}\p{N}]/gu, " ").replace(/\s+/g, " ").trim() || "Alert", jt = (i) => {
585
+ if (!i) return null;
586
+ const t = i.url || i.href || "", e = i.title || i.headline || "";
587
+ if (!t || !e) return null;
588
+ const s = i.topic || "", r = i.caption || s || "Alert", n = i.image || i.imageUrl || i.image_url || zt;
589
+ return {
590
+ url: t,
591
+ title: e,
592
+ topic: s,
593
+ caption: r,
594
+ image: n,
595
+ body: i.body || i.summary || "",
596
+ effectiveFrom: i.effectiveFrom || i.effective_from || ""
597
+ };
598
+ }, Dt = (i) => {
599
+ if (!i) return "";
600
+ try {
601
+ const t = new Date(i);
602
+ return Number.isNaN(t.getTime()) ? "" : t.toLocaleString(void 0, {
603
+ month: "short",
604
+ day: "numeric",
605
+ hour: "numeric",
606
+ minute: "2-digit"
607
+ });
608
+ } catch {
609
+ return "";
610
+ }
611
+ };
612
+ class ot extends C {
613
+ static properties = {
614
+ api: { type: String },
615
+ items: { state: !0 },
616
+ loading: { state: !0 },
617
+ error: { state: !0 },
618
+ refreshInterval: { type: Number, attribute: "refresh-interval" }
619
+ };
620
+ constructor() {
621
+ super(), this.api = Rt, this.items = [], this.loading = !1, this.error = "", this.refreshInterval = 0, this._refreshId = null;
622
+ }
623
+ static styles = lt`
624
+ :host {
625
+ display: block;
626
+ background: #f7f5f4;
627
+ color: #000b27;
628
+ }
629
+ .wrapper {
630
+ max-width: 1040px;
631
+ margin: 0 auto;
632
+ padding: 1rem 1.25rem 1.5rem;
633
+ }
634
+ .heading {
635
+ display: flex;
636
+ align-items: center;
637
+ gap: .5rem;
638
+ font-family: var(--heading-font-family, sans-serif);
639
+ font-size: 1rem;
640
+ font-weight: 700;
641
+ letter-spacing: .02em;
642
+ text-transform: uppercase;
643
+ margin: 0 0 .75rem;
644
+ }
645
+ .pill {
646
+ display: inline-flex;
647
+ align-items: center;
648
+ gap: .35rem;
649
+ background: #fff;
650
+ border: 1px solid #e0e0e0;
651
+ border-radius: 999px;
652
+ padding: .2rem .65rem;
653
+ color: #444;
654
+ font-size: .8125rem;
655
+ }
656
+ .list {
657
+ list-style: none;
658
+ margin: 0;
659
+ padding: 0;
660
+ display: flex;
661
+ flex-direction: column;
662
+ gap: .75rem;
663
+ }
664
+ .alert {
665
+ background: #fff;
666
+ border: 1px solid #e5e5e5;
667
+ padding: .9rem 1rem;
668
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
669
+ display: grid;
670
+ grid-template-columns: 112px 1fr;
671
+ gap: .9rem;
672
+ }
673
+ .thumb {
674
+ overflow: hidden;
675
+ background: #f3f3f3;
676
+ border: 1px solid #ececec;
677
+ aspect-ratio: 4 / 3;
678
+ }
679
+ .thumb img {
680
+ display: block;
681
+ width: 100%;
682
+ height: 100%;
683
+ object-fit: cover;
684
+ }
685
+ .alert-body {
686
+ display: flex;
687
+ flex-direction: column;
688
+ gap: .35rem;
689
+ }
690
+ .alert-header {
691
+ display: flex;
692
+ align-items: center;
693
+ justify-content: space-between;
694
+ gap: .5rem;
695
+ }
696
+ .label {
697
+ display: inline-flex;
698
+ align-items: center;
699
+ width: fit-content;
700
+ color: #fff;
701
+ font-size: .75rem;
702
+ font-weight: 700;
703
+ padding: 0.125rem 0.35rem;
704
+ border-radius: 6px;
705
+ text-transform: uppercase;
706
+ background-color: #c15800;
707
+ letter-spacing: .03em;
708
+ }
709
+ .label.recommended-story {
710
+ background-color: #2594e3;
711
+ }
712
+ a.title {
713
+ color: inherit;
714
+ font-size: 1.0625rem;
715
+ line-height: 1.35;
716
+ font-family: var(--heading-font-family, sans-serif);
717
+ font-weight: 700;
718
+ text-decoration: none;
719
+ }
720
+ a.title:hover,
721
+ a.title:focus-visible {
722
+ text-decoration: underline;
723
+ }
724
+ .body {
725
+ margin: 0;
726
+ color: #323232;
727
+ font-size: .95rem;
728
+ line-height: 1.45;
729
+ }
730
+ .date {
731
+ color: #5a5a5a;
732
+ font-size: .8125rem;
733
+ white-space: nowrap;
734
+ }
735
+ .status {
736
+ margin: .35rem 0 0;
737
+ color: #4a4a4a;
738
+ font-size: .9375rem;
739
+ }
740
+ .status.error {
741
+ color: #9b1c1c;
742
+ }
743
+ .empty {
744
+ color: #666;
745
+ font-family: var(--heading-font-family, sans-serif);
746
+ font-size: .95rem;
747
+ margin: .5rem 0 0;
748
+ }
749
+ @media (max-width: 720px) {
750
+ .wrapper { padding: .75rem .75rem 1.25rem; }
751
+ .alert {
752
+ grid-template-columns: 1fr;
753
+ padding: .85rem .9rem;
754
+ }
755
+ .alert-header {
756
+ align-items: flex-start;
757
+ flex-direction: column;
758
+ }
759
+ }
760
+ `;
761
+ async firstUpdated() {
762
+ await this.load();
763
+ }
764
+ connectedCallback() {
765
+ super.connectedCallback(), this._setupInterval();
766
+ }
767
+ disconnectedCallback() {
768
+ super.disconnectedCallback(), this._clearInterval();
769
+ }
770
+ updated(t) {
771
+ t.has("api") && t.get("api") !== this.api && this.load(), t.has("refreshInterval") && this._setupInterval();
772
+ }
773
+ async fetchActiveAlerts() {
774
+ return Tt({
775
+ baseUrl: this.api.replace(/v1\/.*$/, "")
776
+ }).listActiveAlerts();
777
+ }
778
+ async load() {
779
+ if (this.api) {
780
+ this.loading = !0, this.error = "";
781
+ try {
782
+ const t = await this.fetchActiveAlerts();
783
+ this.items = (t?.items || []).map(jt).filter(Boolean);
784
+ } catch (t) {
785
+ console.error("[wral-active-alerts]", t), this.items = [], this.error = "Unable to load active alerts.";
786
+ } finally {
787
+ this.loading = !1;
788
+ }
789
+ }
790
+ }
791
+ _setupInterval() {
792
+ this._clearInterval();
793
+ const t = Number(this.refreshInterval) || 0;
794
+ t > 0 && (this._refreshId = globalThis.setInterval(() => this.load(), t));
795
+ }
796
+ _clearInterval() {
797
+ this._refreshId && (globalThis.clearInterval(this._refreshId), this._refreshId = null);
798
+ }
799
+ render() {
800
+ const { items: t, loading: e, error: s } = this, r = (n, o) => {
801
+ const c = Dt(n.effectiveFrom);
802
+ return $`
803
+ <li class="alert" data-index=${o} aria-label="Site Alert">
804
+ <div class="thumb">
805
+ <img
806
+ src=${n.image}
807
+ alt=${n.title}
808
+ loading="lazy"
809
+ >
810
+ </div>
811
+ <div class="alert-body">
812
+ <div class="alert-header">
813
+ <div class="label ${n.topic}">
814
+ ${Lt(n.caption)}
815
+ </div>
816
+ ${c ? $`
817
+ <span class="date">
818
+ ${c}
819
+ </span>
820
+ ` : ""}
821
+ </div>
822
+ <a class="title" href=${n.url}>${n.title}</a>
823
+ ${n.body ? $`<p class="body">${n.body}</p>` : ""}
824
+ </div>
825
+ </li>
826
+ `;
827
+ };
828
+ return $`
829
+ <div class="wrapper" role="region" aria-live="polite">
830
+ <div class="heading">
831
+ <span>Active Alerts</span>
832
+ ${e ? $`<span class="pill">Loading…</span>` : ""}
833
+ </div>
834
+
835
+ ${s ? $`<div class="status error">${s}</div>` : ""}
836
+ ${!s && !e && !t.length ? $`
837
+ <div class="empty">No active alerts right now.</div>
838
+ ` : ""}
839
+
840
+ ${t.length ? $`
841
+ <ul class="list">
842
+ ${t.map(r)}
843
+ </ul>
844
+ ` : ""}
845
+ </div>
846
+ `;
847
+ }
848
+ }
849
+ globalThis?.customElements && !globalThis.customElements.get("wral-active-alerts") && globalThis.customElements.define("wral-active-alerts", ot);
850
+ function Bt() {
851
+ const i = globalThis?.customElements;
852
+ i && (i.get("wral-active-alerts") || i.define("wral-active-alerts", ot));
853
+ }
854
+ typeof window < "u" && globalThis.customElements && Bt();
855
+ export {
856
+ Bt as defineAll
857
+ };
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import { W as r, n as s, s as l } from "./wral-active-alerts-CSZAUUIB.js";
2
+ export {
3
+ r as WralActiveAlerts,
4
+ s as normalizeAlert,
5
+ l as sanitizeLabel
6
+ };
@@ -0,0 +1,273 @@
1
+ import { LitElement as c, css as d, html as i } from "lit";
2
+ import { createClient as m } from "@wral/sdk-alerts/v1";
3
+ const f = "https://api.wral.com/alerts/v1/active/alerts", p = "https://assets.wral.com/a1cc0e86-adab-48e9-bd80-703cd2c56aff?w=1200&h=630", h = (t) => String(t || "Alert").replace(/[^\p{L}\p{N}]/gu, " ").replace(/\s+/g, " ").trim() || "Alert", g = (t) => {
4
+ if (!t) return null;
5
+ const e = t.url || t.href || "", s = t.title || t.headline || "";
6
+ if (!e || !s) return null;
7
+ const a = t.topic || "", l = t.caption || a || "Alert", r = t.image || t.imageUrl || t.image_url || p;
8
+ return {
9
+ url: e,
10
+ title: s,
11
+ topic: a,
12
+ caption: l,
13
+ image: r,
14
+ body: t.body || t.summary || "",
15
+ effectiveFrom: t.effectiveFrom || t.effective_from || ""
16
+ };
17
+ }, u = (t) => {
18
+ if (!t) return "";
19
+ try {
20
+ const e = new Date(t);
21
+ return Number.isNaN(e.getTime()) ? "" : e.toLocaleString(void 0, {
22
+ month: "short",
23
+ day: "numeric",
24
+ hour: "numeric",
25
+ minute: "2-digit"
26
+ });
27
+ } catch {
28
+ return "";
29
+ }
30
+ };
31
+ class b extends c {
32
+ static properties = {
33
+ api: { type: String },
34
+ items: { state: !0 },
35
+ loading: { state: !0 },
36
+ error: { state: !0 },
37
+ refreshInterval: { type: Number, attribute: "refresh-interval" }
38
+ };
39
+ constructor() {
40
+ super(), this.api = f, this.items = [], this.loading = !1, this.error = "", this.refreshInterval = 0, this._refreshId = null;
41
+ }
42
+ static styles = d`
43
+ :host {
44
+ display: block;
45
+ background: #f7f5f4;
46
+ color: #000b27;
47
+ }
48
+ .wrapper {
49
+ max-width: 1040px;
50
+ margin: 0 auto;
51
+ padding: 1rem 1.25rem 1.5rem;
52
+ }
53
+ .heading {
54
+ display: flex;
55
+ align-items: center;
56
+ gap: .5rem;
57
+ font-family: var(--heading-font-family, sans-serif);
58
+ font-size: 1rem;
59
+ font-weight: 700;
60
+ letter-spacing: .02em;
61
+ text-transform: uppercase;
62
+ margin: 0 0 .75rem;
63
+ }
64
+ .pill {
65
+ display: inline-flex;
66
+ align-items: center;
67
+ gap: .35rem;
68
+ background: #fff;
69
+ border: 1px solid #e0e0e0;
70
+ border-radius: 999px;
71
+ padding: .2rem .65rem;
72
+ color: #444;
73
+ font-size: .8125rem;
74
+ }
75
+ .list {
76
+ list-style: none;
77
+ margin: 0;
78
+ padding: 0;
79
+ display: flex;
80
+ flex-direction: column;
81
+ gap: .75rem;
82
+ }
83
+ .alert {
84
+ background: #fff;
85
+ border: 1px solid #e5e5e5;
86
+ padding: .9rem 1rem;
87
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
88
+ display: grid;
89
+ grid-template-columns: 112px 1fr;
90
+ gap: .9rem;
91
+ }
92
+ .thumb {
93
+ overflow: hidden;
94
+ background: #f3f3f3;
95
+ border: 1px solid #ececec;
96
+ aspect-ratio: 4 / 3;
97
+ }
98
+ .thumb img {
99
+ display: block;
100
+ width: 100%;
101
+ height: 100%;
102
+ object-fit: cover;
103
+ }
104
+ .alert-body {
105
+ display: flex;
106
+ flex-direction: column;
107
+ gap: .35rem;
108
+ }
109
+ .alert-header {
110
+ display: flex;
111
+ align-items: center;
112
+ justify-content: space-between;
113
+ gap: .5rem;
114
+ }
115
+ .label {
116
+ display: inline-flex;
117
+ align-items: center;
118
+ width: fit-content;
119
+ color: #fff;
120
+ font-size: .75rem;
121
+ font-weight: 700;
122
+ padding: 0.125rem 0.35rem;
123
+ border-radius: 6px;
124
+ text-transform: uppercase;
125
+ background-color: #c15800;
126
+ letter-spacing: .03em;
127
+ }
128
+ .label.recommended-story {
129
+ background-color: #2594e3;
130
+ }
131
+ a.title {
132
+ color: inherit;
133
+ font-size: 1.0625rem;
134
+ line-height: 1.35;
135
+ font-family: var(--heading-font-family, sans-serif);
136
+ font-weight: 700;
137
+ text-decoration: none;
138
+ }
139
+ a.title:hover,
140
+ a.title:focus-visible {
141
+ text-decoration: underline;
142
+ }
143
+ .body {
144
+ margin: 0;
145
+ color: #323232;
146
+ font-size: .95rem;
147
+ line-height: 1.45;
148
+ }
149
+ .date {
150
+ color: #5a5a5a;
151
+ font-size: .8125rem;
152
+ white-space: nowrap;
153
+ }
154
+ .status {
155
+ margin: .35rem 0 0;
156
+ color: #4a4a4a;
157
+ font-size: .9375rem;
158
+ }
159
+ .status.error {
160
+ color: #9b1c1c;
161
+ }
162
+ .empty {
163
+ color: #666;
164
+ font-family: var(--heading-font-family, sans-serif);
165
+ font-size: .95rem;
166
+ margin: .5rem 0 0;
167
+ }
168
+ @media (max-width: 720px) {
169
+ .wrapper { padding: .75rem .75rem 1.25rem; }
170
+ .alert {
171
+ grid-template-columns: 1fr;
172
+ padding: .85rem .9rem;
173
+ }
174
+ .alert-header {
175
+ align-items: flex-start;
176
+ flex-direction: column;
177
+ }
178
+ }
179
+ `;
180
+ async firstUpdated() {
181
+ await this.load();
182
+ }
183
+ connectedCallback() {
184
+ super.connectedCallback(), this._setupInterval();
185
+ }
186
+ disconnectedCallback() {
187
+ super.disconnectedCallback(), this._clearInterval();
188
+ }
189
+ updated(e) {
190
+ e.has("api") && e.get("api") !== this.api && this.load(), e.has("refreshInterval") && this._setupInterval();
191
+ }
192
+ async fetchActiveAlerts() {
193
+ return m({
194
+ baseUrl: this.api.replace(/v1\/.*$/, "")
195
+ }).listActiveAlerts();
196
+ }
197
+ async load() {
198
+ if (this.api) {
199
+ this.loading = !0, this.error = "";
200
+ try {
201
+ const e = await this.fetchActiveAlerts();
202
+ this.items = (e?.items || []).map(g).filter(Boolean);
203
+ } catch (e) {
204
+ console.error("[wral-active-alerts]", e), this.items = [], this.error = "Unable to load active alerts.";
205
+ } finally {
206
+ this.loading = !1;
207
+ }
208
+ }
209
+ }
210
+ _setupInterval() {
211
+ this._clearInterval();
212
+ const e = Number(this.refreshInterval) || 0;
213
+ e > 0 && (this._refreshId = globalThis.setInterval(() => this.load(), e));
214
+ }
215
+ _clearInterval() {
216
+ this._refreshId && (globalThis.clearInterval(this._refreshId), this._refreshId = null);
217
+ }
218
+ render() {
219
+ const { items: e, loading: s, error: a } = this, l = (r, o) => {
220
+ const n = u(r.effectiveFrom);
221
+ return i`
222
+ <li class="alert" data-index=${o} aria-label="Site Alert">
223
+ <div class="thumb">
224
+ <img
225
+ src=${r.image}
226
+ alt=${r.title}
227
+ loading="lazy"
228
+ >
229
+ </div>
230
+ <div class="alert-body">
231
+ <div class="alert-header">
232
+ <div class="label ${r.topic}">
233
+ ${h(r.caption)}
234
+ </div>
235
+ ${n ? i`
236
+ <span class="date">
237
+ ${n}
238
+ </span>
239
+ ` : ""}
240
+ </div>
241
+ <a class="title" href=${r.url}>${r.title}</a>
242
+ ${r.body ? i`<p class="body">${r.body}</p>` : ""}
243
+ </div>
244
+ </li>
245
+ `;
246
+ };
247
+ return i`
248
+ <div class="wrapper" role="region" aria-live="polite">
249
+ <div class="heading">
250
+ <span>Active Alerts</span>
251
+ ${s ? i`<span class="pill">Loading…</span>` : ""}
252
+ </div>
253
+
254
+ ${a ? i`<div class="status error">${a}</div>` : ""}
255
+ ${!a && !s && !e.length ? i`
256
+ <div class="empty">No active alerts right now.</div>
257
+ ` : ""}
258
+
259
+ ${e.length ? i`
260
+ <ul class="list">
261
+ ${e.map(l)}
262
+ </ul>
263
+ ` : ""}
264
+ </div>
265
+ `;
266
+ }
267
+ }
268
+ globalThis?.customElements && !globalThis.customElements.get("wral-active-alerts") && globalThis.customElements.define("wral-active-alerts", b);
269
+ export {
270
+ b as W,
271
+ g as n,
272
+ h as s
273
+ };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@wral/active-alerts",
3
+ "version": "0.1.4",
4
+ "type": "module",
5
+ "description": "Lit web component for rendering the current set of active WRAL alerts.",
6
+ "author": "Dominick Jones <djones@wral.com>",
7
+ "license": "UNLICENSED",
8
+ "peerDependencies": {
9
+ "lit": "^3.0.0"
10
+ },
11
+ "scripts": {
12
+ "dev": "vite",
13
+ "lint": "eslint",
14
+ "prepublishOnly": "npm run build",
15
+ "build": "vite build && vite build --config vite.standalone.config.mjs"
16
+ },
17
+ "exports": {
18
+ ".": "./dist/index.mjs",
19
+ "./define": "./dist/define.mjs",
20
+ "./package.json": "./package.json"
21
+ },
22
+ "main": "./dist/index.mjs",
23
+ "module": "./dist/index.mjs",
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "dependencies": {
31
+ "@wral/sdk-alerts": "^0.0.1"
32
+ },
33
+ "devDependencies": {
34
+ "eslint": "^9.36.0",
35
+ "vite": "^7.1.7",
36
+ "lit": "^3.3.1"
37
+ }
38
+ }