@startside/swa 1.0.2 → 1.0.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.
- package/LICENSE +7 -6
- package/README.md +19 -5
- package/bin/swa.mjs +10 -18
- package/package.json +2 -2
- package/swa/1.0/agents.md +89 -2
- package/swa/1.0/frame.css +245 -0
- package/swa/1.0/frame.js +4 -0
- package/swa/1.0/host.js +27 -0
- package/swa/1.0/host.md +152 -0
- package/swa/1.0/quickstart.md +2 -0
- package/swa/1.0/runtime.js +3 -3
- package/swa/1.0/spec.md +195 -37
- package/swa/1.0/swa.d.ts +81 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startside/swa",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "The Startside Widget API (SWA): the runtime a widget file loads, its TypeScript types, its specification in Markdown, and a command to check a widget file and inline its runtime.",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"description": "The Startside Widget API (SWA): the runtime a widget file loads, its TypeScript types, its specification in Markdown, and a command to check a widget file and inline its runtime, and what another host needs to run a widget in a frame.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"swa",
|
|
7
7
|
"startside",
|
package/swa/1.0/agents.md
CHANGED
|
@@ -133,8 +133,10 @@ What it shows, in order:
|
|
|
133
133
|
| SHOULD | Follow its width with a `ResizeObserver` on its own element when its layout depends on it | 7.3.2 |
|
|
134
134
|
| SHOULD | Meet WCAG 2.2 AA: keyboard alone, names on controls, 4.5:1 text, `prefers-reduced-motion` | 14 |
|
|
135
135
|
| MUST | Show only pictures it may show (public domain, or a licence or permission that allows it), their required credits kept; a picture opened large carries its own: `widget.openPhoto({ src, alt, credit })` | 7.12 |
|
|
136
|
+
| MAY | Read an API that wants the person's own key: `<input type="password" name="key" data-key-for="https://api.example">` in the settings, then `widget.fetch` to that origin. The host keeps the key and adds `Authorization: Bearer`; the widget never sees it (`widget.settings.get('key')` is `''`), and a 401 or 403 means no key yet: say to add one in the settings | 5.3, 8.2 |
|
|
136
137
|
| MAY | Declare actions of its own for its options menu, in the file: `<menu id="actions" hidden>` with one `<button type="button" name="reset">Reset</button>` each, five at most (`disabled` or `hidden` as it starts, `data-confirm="…?"` for a question the host asks first). Answer the `action` event (`event.detail.id`), and change their state as the widget's does with `widget.setActionStates({ reset: { disabled: false } })` | 7.13 |
|
|
137
138
|
| MAY | Hand the person a file it makes, from one of those actions only: `data-save=".cook"` on its button, then `widget.saveFile({ name, type, data }, { action: event })` in its `action` listener | 7.13 |
|
|
139
|
+
| MAY | Take a file dragged from the computer onto it: `<meta name="acceptFiles" content=".gpx">` (the extensions it takes), then its own `dragover` (`preventDefault()`) and `drop` listeners; a file it doesn't take, left uncancelled, is refused, never opened. A file input (`<input type="file" accept=".gpx">`) beside it, for the keyboard and a phone | 4.5, 10.1 |
|
|
138
140
|
| MAY | Carry its icon in the file: `<link rel="icon" href="data:image/svg+xml,…">`, kept when the file is shared by itself (best: an SVG drawn for 16 pixels, or a 64 × 64 PNG) | 4.6 |
|
|
139
141
|
|
|
140
142
|
## Checklist
|
|
@@ -184,6 +186,11 @@ licence (CC BY 4.0).*
|
|
|
184
186
|
(`https://cdn.jsdelivr.net/npm/@startside/swa@1/swa/1.0/agents.md`). Served by jsDelivr and unpkg (4.3), installed
|
|
185
187
|
with `npm install @startside/swa`. Since 1.0.1 too, a command, for Node 20 or later, with nothing else to install:
|
|
186
188
|
`validate` and `inline`, below.
|
|
189
|
+
- **Running widgets in another page.** Since 1.0.3, `@startside/swa` also carries the runtime a host writes into a
|
|
190
|
+
widget's frame (`swa/1.0/frame.js`, SWA files only), its base styles (`frame.css`), and `host.md`: how a host runs a
|
|
191
|
+
frame (10.1), the configuration that runtime reads and the messages a host answers. Since 1.0.4, `host.js` too: a
|
|
192
|
+
widget file read (6.2), its settings' values, the frame's document written and a message checked, by the code
|
|
193
|
+
Startside's dashboard runs, as a module for the browser.
|
|
187
194
|
- **Checking a file.** `npx @startside/swa validate my-widget.swa.html` reads a widget file without running it, with no
|
|
188
195
|
network: the file's name and document, its runtime tag, metadata and settings form, and its scripts against this
|
|
189
196
|
API, UWA's members and globals named with what replaces them. Each finding is `file:line:col: error|warning:
|
|
@@ -253,12 +260,16 @@ declare global {
|
|
|
253
260
|
settingschange: WidgetEvent<{ names: string[] }>;
|
|
254
261
|
/** One of the widget's own actions (declared in `<menu id="actions">`, 7.13) chosen in its options menu. */
|
|
255
262
|
action: WidgetEvent<{ id: string }>;
|
|
263
|
+
/** A picture opened with `openPhoto({ deletable: true, id })`, deleted by the person in the host's window. */
|
|
264
|
+
photodelete: WidgetEvent<{ id: string }>;
|
|
265
|
+
/** Its pictures (`storage.files`) changed: Sync, another copy of the page, or its own call. List them again. */
|
|
266
|
+
fileschange: WidgetEvent<null>;
|
|
256
267
|
}
|
|
257
268
|
|
|
258
269
|
interface Widget extends EventTarget {
|
|
259
270
|
// 7.2 Identity and environment
|
|
260
271
|
readonly id: string;
|
|
261
|
-
/** The title shown: the
|
|
272
|
+
/** The title shown: the widget's own, its file's `<title>` until it sets another (7.3). */
|
|
262
273
|
readonly title: string;
|
|
263
274
|
/** The widget file's address. */
|
|
264
275
|
readonly uwaUrl: string;
|
|
@@ -328,6 +339,11 @@ declare global {
|
|
|
328
339
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
329
340
|
/** RSS, Atom or JSON Feed as a JSON Feed 1.1, kept by the host: a kept copy answers at once. */
|
|
330
341
|
fetchFeed(url: string, options?: FetchFeedOptions): Promise<ContentFeed>;
|
|
342
|
+
/**
|
|
343
|
+
* A picture fetched by the host as itself (with its Referer; 8.6): an address to show in an `img`, the same for the
|
|
344
|
+
* same picture. https, a raster picture of 2 MB at most; rejects with a TypeError otherwise.
|
|
345
|
+
*/
|
|
346
|
+
fetchImage(url: string, options?: { signal?: AbortSignal | null }): Promise<string>;
|
|
331
347
|
|
|
332
348
|
// 7.10 Read state and counts
|
|
333
349
|
readItems(box: Element, itemSelector: string, options?: { key?: (item: Element) => string }): void;
|
|
@@ -356,6 +372,8 @@ declare global {
|
|
|
356
372
|
// 7.13 The page
|
|
357
373
|
shareUrl(): string | null;
|
|
358
374
|
share(data?: { text?: string; url?: string }): unknown;
|
|
375
|
+
/** Startside's extension: the page's Send to… for this widget; nothing where environment.people is null. */
|
|
376
|
+
sendTo(): void;
|
|
359
377
|
/** Absent where no widget can be added (a preview, a widget on its own page): `if (widget.addWidget)`. */
|
|
360
378
|
addWidget?(spec: AddWidgetSpec): unknown;
|
|
361
379
|
/** `spec`, or a function giving it as the drag starts, given the drag's event; nothing given, the drag doesn't start. */
|
|
@@ -413,6 +431,31 @@ declare global {
|
|
|
413
431
|
readonly memory: WidgetStorageArea;
|
|
414
432
|
/** Across reloads, shared by every widget of the same file: scores. */
|
|
415
433
|
readonly local: WidgetStorageArea;
|
|
434
|
+
/** Its own pictures, kept for good and the same on the person's other devices (synced): photos it took. */
|
|
435
|
+
readonly files: WidgetFiles;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/** A widget's pictures (7.8): JPEG, PNG, WebP or GIF, 10 MB each at most. */
|
|
439
|
+
interface WidgetFiles {
|
|
440
|
+
/** Every one, oldest first, from this device at once. */
|
|
441
|
+
list(): Promise<WidgetFile[]>;
|
|
442
|
+
/** Its bytes, from this device or the server; rejects `NotFoundError`, or `NetworkError` offline without them. */
|
|
443
|
+
get(id: string): Promise<Blob>;
|
|
444
|
+
/** Kept here at once, sent when the host can; its id. Rejects `TypeError` (not a picture, a meta not JSON or over 1,024 bytes), `RangeError` (over 10 MB). */
|
|
445
|
+
add(file: Blob, meta?: unknown): Promise<string>;
|
|
446
|
+
/** Deleted here and on the person's other devices. */
|
|
447
|
+
delete(id: string): Promise<void>;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
interface WidgetFile {
|
|
451
|
+
readonly id: string;
|
|
452
|
+
/** `image/jpeg`, `image/png`, `image/webp` or `image/gif`, told by its bytes. */
|
|
453
|
+
readonly type: string;
|
|
454
|
+
readonly size: number;
|
|
455
|
+
/** When it was added, in milliseconds. */
|
|
456
|
+
readonly at: number;
|
|
457
|
+
/** What the widget gave `add`. */
|
|
458
|
+
readonly meta: unknown;
|
|
416
459
|
}
|
|
417
460
|
|
|
418
461
|
interface WidgetStorageArea {
|
|
@@ -428,6 +471,11 @@ declare global {
|
|
|
428
471
|
readonly inline: boolean;
|
|
429
472
|
/** The page's style, or "" standalone. */
|
|
430
473
|
readonly style: string;
|
|
474
|
+
/**
|
|
475
|
+
* Startside's extension: who plays, in the beta's conversations (this person's name, and who sent this copy,
|
|
476
|
+
* null on their own page); null elsewhere.
|
|
477
|
+
*/
|
|
478
|
+
readonly people: Readonly<{ me: string; from: string | null; to: string | null }> | null;
|
|
431
479
|
}
|
|
432
480
|
|
|
433
481
|
/** A setting as the file declares it: frozen, as `preferences` and `getPreference` give it. */
|
|
@@ -530,6 +578,20 @@ declare global {
|
|
|
530
578
|
/** Played without a Referer, through the host's relay. */
|
|
531
579
|
relay?: boolean;
|
|
532
580
|
live?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* For a file (`live: false`): the files the host plays after it, each as the one before ends, with no further click,
|
|
583
|
+
* until a pause (7.12). `audioState.url` says which plays. 100 at most.
|
|
584
|
+
*/
|
|
585
|
+
next?: NextAudio[];
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
interface NextAudio {
|
|
589
|
+
/** https */
|
|
590
|
+
url: string;
|
|
591
|
+
relay?: boolean;
|
|
592
|
+
/** What the host says plays as it starts (`audioInfo`'s title and artist). */
|
|
593
|
+
title?: string;
|
|
594
|
+
artist?: string;
|
|
533
595
|
}
|
|
534
596
|
|
|
535
597
|
interface AudioState {
|
|
@@ -540,6 +602,21 @@ declare global {
|
|
|
540
602
|
/** Seconds, for a file. */
|
|
541
603
|
time?: number | null;
|
|
542
604
|
duration?: number | null;
|
|
605
|
+
/**
|
|
606
|
+
* A file (`live: false`) another widget of the page plays, playing or loading, else null. While this widget plays
|
|
607
|
+
* nothing itself, `pauseAudio` and `seekAudio` act on it; `playAudio` of a file another widget holds goes on there.
|
|
608
|
+
*/
|
|
609
|
+
elsewhere?: ElsewhereAudio | null;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
interface ElsewhereAudio {
|
|
613
|
+
url: string;
|
|
614
|
+
playing: boolean;
|
|
615
|
+
loading: boolean;
|
|
616
|
+
time: number | null;
|
|
617
|
+
duration: number | null;
|
|
618
|
+
/** Its `audioInfo`'s source. */
|
|
619
|
+
source: string | null;
|
|
543
620
|
}
|
|
544
621
|
|
|
545
622
|
interface AudioControls {
|
|
@@ -577,7 +654,12 @@ declare global {
|
|
|
577
654
|
}
|
|
578
655
|
|
|
579
656
|
interface PhotoSpec {
|
|
580
|
-
|
|
657
|
+
/** An `https` picture or one of the host's; `file` instead for one of the widget's own files. */
|
|
658
|
+
src?: string;
|
|
659
|
+
/** One of its own pictures (`storage.files`), by id: the host reads it, `src` aside. */
|
|
660
|
+
file?: string;
|
|
661
|
+
/** Its own pictures to step through from `file` (their ids, in order, 5,000 at most): ‹ › and the arrow keys. */
|
|
662
|
+
files?: string[];
|
|
581
663
|
alt?: string;
|
|
582
664
|
title?: string;
|
|
583
665
|
preview?: string;
|
|
@@ -587,6 +669,10 @@ declare global {
|
|
|
587
669
|
height?: number;
|
|
588
670
|
/** What the picture's licence asks to go with it. A plain string is its credit text. */
|
|
589
671
|
credit?: PhotoCredit | string;
|
|
672
|
+
/** The window offers Delete, which asks the person first; the widget hears it as `photodelete`. */
|
|
673
|
+
deletable?: boolean;
|
|
674
|
+
/** Given back in `photodelete`'s detail: which picture (100 characters at most). With `file`, the file's id instead. */
|
|
675
|
+
id?: string;
|
|
590
676
|
}
|
|
591
677
|
|
|
592
678
|
/**
|
|
@@ -688,6 +774,7 @@ The full text: https://startside.app/swa/1.0/ (Markdown: https://startside.app/s
|
|
|
688
774
|
- [8.3 `widget.fetchFeed`](https://startside.app/swa/1.0/#83-widgetfetchfeed)
|
|
689
775
|
- [8.4 Freshness](https://startside.app/swa/1.0/#84-freshness)
|
|
690
776
|
- [8.5 Content feeds](https://startside.app/swa/1.0/#85-content-feeds)
|
|
777
|
+
- [8.6 `widget.fetchImage`](https://startside.app/swa/1.0/#86-widgetfetchimage)
|
|
691
778
|
- [9. Built-in objects](https://startside.app/swa/1.0/#9-built-in-objects)
|
|
692
779
|
- [10. Execution environments](https://startside.app/swa/1.0/#10-execution-environments)
|
|
693
780
|
- [10.1 Framed](https://startside.app/swa/1.0/#101-framed)
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/* Base styles for every widget, UWA, SWA and RWA, in its frame, inline and on its own page (the shared runtime, XWA:
|
|
2
|
+
docs/plans/xwa-rename.md), in the spirit of Netvibes' uwa-iframe.css,
|
|
3
|
+
using the dashboard skin's colors (the --variables are injected per frame). */
|
|
4
|
+
html,
|
|
5
|
+
body {
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 0;
|
|
8
|
+
background: transparent;
|
|
9
|
+
}
|
|
10
|
+
body {
|
|
11
|
+
color: var(--text, #333);
|
|
12
|
+
font: 11px/1.45 var(--font-body, Verdana, Tahoma, Geneva, sans-serif);
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
.moduleContent {
|
|
16
|
+
padding: 6px 8px;
|
|
17
|
+
}
|
|
18
|
+
/* A widget with viewport-fit=cover in its viewport meta draws to its edges (srcdoc.ts, runtime.js: uwa-cover; SWA 7.3.2). */
|
|
19
|
+
:root.uwa-cover .moduleContent {
|
|
20
|
+
padding: 0;
|
|
21
|
+
}
|
|
22
|
+
a {
|
|
23
|
+
color: var(--link, #1e5bb8);
|
|
24
|
+
text-decoration: none;
|
|
25
|
+
}
|
|
26
|
+
a:hover {
|
|
27
|
+
text-decoration: underline;
|
|
28
|
+
}
|
|
29
|
+
p {
|
|
30
|
+
margin: 0 0 6px;
|
|
31
|
+
}
|
|
32
|
+
ul {
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding: 0;
|
|
35
|
+
list-style: none;
|
|
36
|
+
}
|
|
37
|
+
li {
|
|
38
|
+
padding: 2px 0 2px 12px;
|
|
39
|
+
position: relative;
|
|
40
|
+
}
|
|
41
|
+
li::before {
|
|
42
|
+
content: '';
|
|
43
|
+
position: absolute;
|
|
44
|
+
left: 2px;
|
|
45
|
+
top: 7px;
|
|
46
|
+
width: 4px;
|
|
47
|
+
height: 4px;
|
|
48
|
+
background: var(--link, #1e5bb8);
|
|
49
|
+
}
|
|
50
|
+
input,
|
|
51
|
+
select,
|
|
52
|
+
textarea,
|
|
53
|
+
button {
|
|
54
|
+
font: inherit;
|
|
55
|
+
}
|
|
56
|
+
table {
|
|
57
|
+
border-collapse: collapse;
|
|
58
|
+
font: inherit;
|
|
59
|
+
}
|
|
60
|
+
.buttonClean,
|
|
61
|
+
button {
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
padding: 2px 10px;
|
|
64
|
+
border: 1px solid #8e99a6;
|
|
65
|
+
border-radius: 3px;
|
|
66
|
+
color: #222;
|
|
67
|
+
background: linear-gradient(#ffffff, #e8ecf1 50%, #d6dde5 51%, #e9edf2);
|
|
68
|
+
}
|
|
69
|
+
/* On a dark page the same glossy button, dark: unstyled buttons stayed pale grey with dark text there (found by an
|
|
70
|
+
agent's screenshot, November 2026). data-color-scheme is set on a frame's and the standalone page's root. It weighs
|
|
71
|
+
more than a widget's `.x`, which still wins: this file sits under the widget's rules everywhere, in a cascade layer
|
|
72
|
+
in a frame (srcdoc.ts) and on the widget's own page (server/widgetRuntime.ts), the widget's rules scoped by a doubled
|
|
73
|
+
id inline (inline.ts; issue #87). */
|
|
74
|
+
:root[data-color-scheme='dark'] .buttonClean,
|
|
75
|
+
:root[data-color-scheme='dark'] button {
|
|
76
|
+
border-color: #5c6672;
|
|
77
|
+
color: #e6e9ed;
|
|
78
|
+
background: linear-gradient(#3e4650, #313841 50%, #2a3038 51%, #323941);
|
|
79
|
+
}
|
|
80
|
+
.uwa-error {
|
|
81
|
+
margin: 0 0 6px;
|
|
82
|
+
padding: 4px 8px;
|
|
83
|
+
color: #b3261e;
|
|
84
|
+
background: #fdecea;
|
|
85
|
+
border-bottom: 1px solid #f3c1bc;
|
|
86
|
+
}
|
|
87
|
+
.nv-pager {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: baseline;
|
|
90
|
+
gap: 10px;
|
|
91
|
+
margin-top: 6px;
|
|
92
|
+
padding-top: 5px;
|
|
93
|
+
border-top: 1px dotted var(--border, #ccc);
|
|
94
|
+
}
|
|
95
|
+
.nv-pager .status {
|
|
96
|
+
color: var(--muted, #888);
|
|
97
|
+
font-size: 10px;
|
|
98
|
+
}
|
|
99
|
+
.nv-pager .next {
|
|
100
|
+
margin-left: auto;
|
|
101
|
+
}
|
|
102
|
+
/* Keep images in proportion when a widget sets only their width. */
|
|
103
|
+
img {
|
|
104
|
+
max-width: 100%;
|
|
105
|
+
height: auto;
|
|
106
|
+
}
|
|
107
|
+
/* The dashboard's loading indicator (src/widgetBox/Loading.tsx and base.css), so a widget
|
|
108
|
+
can show the same one:
|
|
109
|
+
<div class="loading"><span class="spinner"><i/><i/><i/><i/><i/><i/><i/><i/></span>Loading…</div> */
|
|
110
|
+
.loading {
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 6px;
|
|
114
|
+
padding: 10px 8px;
|
|
115
|
+
color: var(--muted, #888);
|
|
116
|
+
}
|
|
117
|
+
.spinner {
|
|
118
|
+
position: relative;
|
|
119
|
+
width: 16px;
|
|
120
|
+
height: 16px;
|
|
121
|
+
}
|
|
122
|
+
.spinner i {
|
|
123
|
+
position: absolute;
|
|
124
|
+
left: 7px;
|
|
125
|
+
top: 0;
|
|
126
|
+
width: 2px;
|
|
127
|
+
height: 5px;
|
|
128
|
+
border-radius: 1px;
|
|
129
|
+
background: var(--muted, #888);
|
|
130
|
+
transform-origin: 1px 8px;
|
|
131
|
+
animation: spin-fade 0.8s steps(1) infinite;
|
|
132
|
+
}
|
|
133
|
+
.spinner i:nth-child(1) {
|
|
134
|
+
transform: rotate(0deg);
|
|
135
|
+
animation-delay: -0.8s;
|
|
136
|
+
}
|
|
137
|
+
.spinner i:nth-child(2) {
|
|
138
|
+
transform: rotate(45deg);
|
|
139
|
+
animation-delay: -0.7s;
|
|
140
|
+
}
|
|
141
|
+
.spinner i:nth-child(3) {
|
|
142
|
+
transform: rotate(90deg);
|
|
143
|
+
animation-delay: -0.6s;
|
|
144
|
+
}
|
|
145
|
+
.spinner i:nth-child(4) {
|
|
146
|
+
transform: rotate(135deg);
|
|
147
|
+
animation-delay: -0.5s;
|
|
148
|
+
}
|
|
149
|
+
.spinner i:nth-child(5) {
|
|
150
|
+
transform: rotate(180deg);
|
|
151
|
+
animation-delay: -0.4s;
|
|
152
|
+
}
|
|
153
|
+
.spinner i:nth-child(6) {
|
|
154
|
+
transform: rotate(225deg);
|
|
155
|
+
animation-delay: -0.3s;
|
|
156
|
+
}
|
|
157
|
+
.spinner i:nth-child(7) {
|
|
158
|
+
transform: rotate(270deg);
|
|
159
|
+
animation-delay: -0.2s;
|
|
160
|
+
}
|
|
161
|
+
.spinner i:nth-child(8) {
|
|
162
|
+
transform: rotate(315deg);
|
|
163
|
+
animation-delay: -0.1s;
|
|
164
|
+
}
|
|
165
|
+
@keyframes spin-fade {
|
|
166
|
+
0% {
|
|
167
|
+
opacity: 1;
|
|
168
|
+
}
|
|
169
|
+
12.5% {
|
|
170
|
+
opacity: 0.8;
|
|
171
|
+
}
|
|
172
|
+
25% {
|
|
173
|
+
opacity: 0.6;
|
|
174
|
+
}
|
|
175
|
+
37.5% {
|
|
176
|
+
opacity: 0.45;
|
|
177
|
+
}
|
|
178
|
+
50% {
|
|
179
|
+
opacity: 0.3;
|
|
180
|
+
}
|
|
181
|
+
62.5%,
|
|
182
|
+
100% {
|
|
183
|
+
opacity: 0.15;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* A link that leaves the dashboard (a new tab on another site, not the reader): a small "open
|
|
188
|
+
in new" icon after its text, in its own color, faded. Widgets put it on their headlines. */
|
|
189
|
+
/* The icon takes no room of its own (margin-right cancels it) and the link's end padding holds
|
|
190
|
+
its place: the padding sticks to the last word, so the icon never wraps onto a line alone. */
|
|
191
|
+
.ext-link {
|
|
192
|
+
padding-right: 1.02em;
|
|
193
|
+
}
|
|
194
|
+
.ext-link::after {
|
|
195
|
+
content: '';
|
|
196
|
+
display: inline-block;
|
|
197
|
+
flex: none;
|
|
198
|
+
width: 0.72em;
|
|
199
|
+
height: 0.72em;
|
|
200
|
+
margin: 0 -1.02em 0 0.3em;
|
|
201
|
+
vertical-align: 0;
|
|
202
|
+
background: currentColor;
|
|
203
|
+
opacity: 0.45;
|
|
204
|
+
-webkit-mask: var(--ext-icon) no-repeat center / contain;
|
|
205
|
+
mask: var(--ext-icon) no-repeat center / contain;
|
|
206
|
+
--ext-icon: url('data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27%3E%3Cpath d=%27M14 3h7v7h-2V6.41l-9.29 9.3-1.42-1.42L17.59 5H14V3zM5 5h6v2H5v12h12v-6h2v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z%27/%3E%3C/svg%3E');
|
|
207
|
+
}
|
|
208
|
+
.ext-link:hover::after {
|
|
209
|
+
opacity: 0.8;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* The corner grip of list widgets (widget.countGrip): drag it down for more items, up for fewer. */
|
|
213
|
+
.count-grip {
|
|
214
|
+
position: absolute;
|
|
215
|
+
right: 0;
|
|
216
|
+
bottom: 0;
|
|
217
|
+
width: 20px;
|
|
218
|
+
height: 20px;
|
|
219
|
+
display: grid;
|
|
220
|
+
place-items: center;
|
|
221
|
+
cursor: ns-resize;
|
|
222
|
+
touch-action: none;
|
|
223
|
+
color: currentColor;
|
|
224
|
+
opacity: 0.35;
|
|
225
|
+
}
|
|
226
|
+
.count-grip:hover,
|
|
227
|
+
.count-grip-dragging .count-grip {
|
|
228
|
+
opacity: 0.9;
|
|
229
|
+
}
|
|
230
|
+
/* Focused from the keyboard (↑ ↓, Home, End): the grip at full strength in a ring of the text's colour. */
|
|
231
|
+
.count-grip:focus-visible {
|
|
232
|
+
opacity: 1;
|
|
233
|
+
outline: 2px solid currentColor;
|
|
234
|
+
outline-offset: -2px;
|
|
235
|
+
border-radius: 3px;
|
|
236
|
+
}
|
|
237
|
+
.count-grip svg {
|
|
238
|
+
width: 10px;
|
|
239
|
+
height: 10px;
|
|
240
|
+
}
|
|
241
|
+
.count-grip-dragging,
|
|
242
|
+
.count-grip-dragging * {
|
|
243
|
+
cursor: ns-resize !important;
|
|
244
|
+
user-select: none;
|
|
245
|
+
}
|
package/swa/1.0/frame.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/* SWA 1.0, the runtime a host runs in a widget's frame (host.md) */
|
|
2
|
+
(function(){(function(){"use strict";(function(){var e=window.__UWA_CONFIG__,t;function n(e){t=e}function r(e,t){for(var n in t)e[n]=t[n];return e}var i=typeof WeakMap==`function`?/* @__PURE__ */ new WeakMap:null,a={reset:`↺`,refresh:`↻`,undo:`↶`,redo:`↷`,copy:`⧉`,download:`⇩`,upload:`⇧`,share:`↗`,add:`+`,remove:`×`,clear:`⌫`,edit:`✎`,search:`⌕`,print:`⎙`,play:`▶`,pause:`⏸`,stop:`■`,check:`✓`,star:`★`,info:`ⓘ`,settings:`⚙`},o={".cook":[`text/plain`],".txt":[`text/plain`],".md":[`text/markdown`,`text/plain`],".csv":[`text/csv`,`text/plain`],".json":[`application/json`,`text/plain`],".ics":[`text/calendar`,`text/plain`],".opml":[`text/x-opml`,`application/xml`,`text/xml`,`text/plain`],".gpx":[`application/gpx+xml`,`application/xml`,`text/xml`,`text/plain`]},s=8388608,c=function(e){return Object.prototype.hasOwnProperty.call(o,e)};function l(e){var t=[];return typeof e==`string`&&e.trim().split(/\s+/).forEach(function(e){var n=e.toLowerCase();/^\.[a-z0-9]{1,10}$/.test(n)&&c(n)&&t.indexOf(n)===-1&&t.push(n)}),t}function u(e,t){if(typeof e!=`string`||e.length>1024)return null;var n=e.split(/[/\\]/).pop().replace(/[\u0000-\u001f\u007f-\u009f\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/g,``).replace(/[:*?"<>|]/g,`-`).replace(/\s+/g,` `).replace(/[. ]+$/,``),r=/^(.*)(\.[A-Za-z0-9]{1,10})$/.exec(n);if(!r)return null;var i=r[2].toLowerCase();if(t.indexOf(i)===-1||!c(i))return null;var a=r[1].replace(/^[. ]+/,``).replace(/[. ]+$/,``).replace(/\.([A-Za-z0-9]{1,10})$/,`-$1`);return a=Array.from(a).slice(0,120).join(``).replace(/[. ]+$/,``),/^(con|prn|aux|nul|(com|lpt)[1-9\u00b9\u00b2\u00b3])(\.|$)/i.test(a)&&(a=`_`+a),{name:(a||`download`)+i,ext:i}}function d(e,t){if(!c(e)||typeof t!=`string`||t.length>255)return null;var n=t.split(`;`)[0].trim().toLowerCase(),r=n?o[e].indexOf(n)===-1?null:n:o[e][0];return r&&r+`;charset=utf-8`}function f(e,t,n){return{setActionStates:function(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`setActionStates takes an object: { id: { disabled, hidden, label } }`);var t=this.__declaredActions();if(!t)this.__earlyStates.push(e);else{var n=Object.create(null);Object.keys(e).forEach(function(r){if(!t.some(function(e){return e.id===r}))throw TypeError(`setActionStates: the file declares no action "`+r+`" (<menu id="actions">)`);var i=e[r];if(!i||typeof i!=`object`)throw TypeError(`setActionStates: "`+r+`" takes { disabled, hidden, label }`);var a={};if(i.disabled!==void 0&&(a.disabled=i.disabled===null?null:i.disabled===!0),i.hidden!==void 0&&(a.hidden=i.hidden===null?null:i.hidden===!0),i.label===null)a.label=null;else if(i.label!==void 0){var o=String(i.label).replace(/\s+/g,` `).trim();if(!o||o.length>40)throw TypeError(`setActionStates: a label is 1 to 40 characters ("`+r+`")`);a.label=o}n[r]=a});var r=this.__actionStates;Object.keys(n).forEach(function(e){var t={};for(var i in r[e]||{})t[i]=r[e][i];for(var a in n[e])n[e][a]===null?delete t[a]:t[a]=n[e][a];r[e]=t}),this.__tellActions()}},saveFile:function(e,t){var r=function(e,t){return Promise.reject(typeof DOMException==`function`?new DOMException(t,e):Error(t))};if(!e||typeof e!=`object`||typeof e.name!=`string`||typeof e.type!=`string`)return Promise.reject(/* @__PURE__ */ TypeError(`saveFile takes { name, type, data }`));var a=e.data,o=typeof Blob==`function`&&a instanceof Blob,s=a instanceof ArrayBuffer;if(typeof a!=`string`&&!o&&!s)return Promise.reject(/* @__PURE__ */ TypeError(`saveFile: data is a string, a Blob or an ArrayBuffer`));var c=t&&t.action,l=c&&i?i.get(c):null;if(!l)return r(`NotAllowedError`,`saveFile answers a choice of an action that declares data-save: saveFile(file, { action: event })`);if(i.delete(c),(o?a.size:s?a.byteLength:a.length>8388608?a.length:new Blob([a]).size)>8388608)return r(`QuotaExceededError`,`a saved file is 8 MiB at most`);if(!n.saveFile)return r(`NotSupportedError`,`this host saves no file`);var u=function(t){return n.saveFile({token:l,name:e.name,type:e.type,data:t})};return o?a.arrayBuffer().then(u):u(s?a.slice(0):a)},__save:{extensions:l,name:u,type:d,max:s},__actionStates:Object.create(null),__actionsReady:!1,__actionsTold:``,__earlyStates:[],__declaredActions:function(){return!Array.isArray(t.actions)&&typeof t.readActions==`function`&&t.readActions(),Array.isArray(t.actions)?t.actions:typeof t.readActions==`function`?null:[]},__lateActions:function(){for(var e=this.__earlyStates.splice(0),t=0;t<e.length;t++)try{this.setActionStates(e[t])}catch(e){window.console&&console.error(e)}},__tellActions:function(){var e=JSON.stringify(this.__actionStates);this.__actionsReady&&e===this.__actionsTold||(this.__actionsReady=!0,this.__actionsTold=e,n.setActionStates&&n.setActionStates(JSON.parse(e)))},__askActions:function(){this.__actionsReady&&(this.__actionsTold=``,this.__actionsReady=!1,this.__tellActions())},__shownActions:function(){var e=this.__actionStates,t=this.__actionsReady;return(this.__declaredActions()||[]).filter(function(t){var n=e[t.id]||{};return t.album!==!0&&!(`hidden`in n?n.hidden:t.hidden===!0)}).map(function(n){var r=e[n.id]||{};return{id:n.id,label:r.label||n.label,icon:n.icon,confirm:n.confirm,save:n.save||[],disabled:!t||(`disabled`in r?r.disabled:n.disabled===!0)}})},__actionGlyph:function(e){var t=String(e||``).trim();if(!t||t.length>16)return``;if(Object.prototype.hasOwnProperty.call(a,t.toLowerCase()))return a[t.toLowerCase()];var n=!1;try{n=RegExp(`\\p{Extended_Pictographic}`,`u`).test(t)}catch{}return n&&(typeof Intl==`object`&&Intl.Segmenter?Array.from(new Intl.Segmenter().segment(t)).length===1:Array.from(t).length<=2)?t:``},__runAction:function(e,t){var n=this.__shownActions().filter(function(t){return t.id===e})[0];if(this.__actionsReady&&n&&!n.disabled){this.__actionToken=typeof t==`string`&&t?t:null;try{this.__fire(`__action`,{id:n.id})}finally{this.__actionToken=null}}}}}var p=[`version`,`title`,`home_page_url`,`feed_url`,`description`,`user_comment`,`next_url`,`icon`,`favicon`,`authors`,`language`,`expired`,`items`],m=[`id`,`url`,`external_url`,`title`,`content_html`,`content_text`,`summary`,`image`,`banner_image`,`date_published`,`date_modified`,`authors`,`tags`,`language`,`attachments`],h={VERSION:`https://jsonfeed.org/version/1.1`,feed:function(e){e||={};var t=g(e,p);return t.version=h.VERSION,t.items=(Array.isArray(e.items)?e.items:[]).map(h.item).filter(Boolean),t},item:function(e){if(!e||typeof e!=`object`)return null;var t=g(e,m);return(t.id==null||t.id===``)&&(t.id=t.url),t.id==null||t.id===``?null:(t.id=String(t.id),[`date_published`,`date_modified`].forEach(function(e){if(t[e]!=null){var n=new Date(t[e]);isNaN(n.getTime())?delete t[e]:t[e]=n.toISOString()}}),typeof t.authors==`string`&&(t.authors=[{name:t.authors}]),t)},author:function(e){var t=e&&e.authors&&e.authors[0];return t&&t.name||``},ext:function(e){return e&&e._myvibes||{}}};function g(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==void 0&&(t.indexOf(r)>=0||/^_[a-zA-Z]/.test(r))&&(n[r]=e[r]);return n}function _(e){if(!/<a\b/i.test(e))return null;for(var t=new DOMParser().parseFromString(`<body>`+e+`</body>`,`text/html`).body,n=[],r=t.firstChild;r&&n.length<8;r=r.nextSibling){var i=(r.textContent||``).slice(0,100);if(i){var a=r.nodeType===1&&r.tagName===`A`&&r.getAttribute(`href`)||``;n.push(/^https?:\/\//i.test(a)?{text:i,href:a}:{text:i})}}return n.some(function(e){return e.href})?n:null}function v(e,t,n){function r(t,n){return e.request(t,String(n))}var i=null;function a(e){return e.reason===void 0?new DOMException(`The operation was aborted.`,`AbortError`):e.reason}function o(e,n,i){return new Promise(function(o,s){if(i&&i.aborted)return s(a(i));var c=function(){s(a(i))};i&&i.addEventListener(`abort`,c,{once:!0}),r(e,n).then(function(e){if(i&&i.removeEventListener(`abort`,c),t.__destroyed)return s(new DOMException(`The widget is gone.`,`AbortError`));o(e)},function(e){i&&i.removeEventListener(`abort`,c),s(e)})})}function s(e,t){if(!e)return``;if(typeof e.get==`function`)return e.get(t)||``;for(var n=Array.isArray(e)?e:Object.keys(e).map(function(t){return[t,e[t]]}),r=0;r<n.length;r++)if(String(n[r][0]).toLowerCase()===t)return String(n[r][1]);return``}t.fetch=function(e,t){t||={};var n=e&&typeof e==`object`&&`url`in e?e.url:e,r=String(t.method||e&&e.method||`GET`).toUpperCase();if(r!==`GET`)return Promise.reject(/* @__PURE__ */ TypeError(`widget.fetch sends GET requests only (`+r+`)`));var i=s(t.headers||e&&e.headers,`accept`),a=t.signal||e&&typeof e==`object`&&e.signal||null;return o(/json/i.test(i)?`json`:`text`,String(n),a).then(function(e){return new Response(e,{status:200})},function(e){if(a&&a.aborted)throw a.reason===void 0?e:a.reason;if(e&&e.name===`AbortError`)throw e;var t=/HTTP (\d{3})/.exec(String(e&&e.message)),n=t?Number(t[1]):0;if(n>=400&&n<=599)return new Response(null,{status:n,statusText:String(e.message).slice(0,200)});throw TypeError(String(e&&e.message||`Failed to fetch`))})};var c={};function l(e,n,r){return o(`jsonfeed`,e,n).then(function(n){if(!n)throw Error(`Could not read the feed `+e);return t.__keepContent(e,h.feed(n))},function(e){throw r||e&&e.name===`AbortError`||t.__keepsContent()||t.__retryLoad(),e instanceof Error?e:Error(String(e))})}t.fetchFeed=function(e,n){n||={},e=String(e);var r=n.signal||null;if(r&&r.aborted)return Promise.reject(a(r));var i=n.fresh?null:t.__keptContent(e);return i?(!(Date.now()-i._myvibes.fetched<3e5)&&!c[e]&&(c[e]=!0,setTimeout(function(){l(e,null,!0).then(function(){delete c[e],t.__destroyed||t.__fire(t.__listens(`onRefresh`)?`onRefresh`:`onLoad`)},function(){delete c[e]})})),Promise.resolve(i)):l(e,r,!1)};var u=/* @__PURE__ */ new Map,d=400;return t.fetchImage=function(t,n){n||={};var r=n.signal||null;if(r&&r.aborted)return Promise.reject(a(r));var i=String(t),o=u.get(i);if(!o&&(o=e.request(`image`,i).then(function(e){return!e||typeof e!=`object`||!e.bytes?typeof e==`string`?e:i:URL.createObjectURL(new Blob([e.bytes],{type:String(e.type||``)}))},function(e){throw u.delete(i),TypeError(String(e&&e.message||`The picture could not be fetched`))}),u.set(i,o),u.size>d)){var s=u.keys().next().value,c=u.get(s);u.delete(s),c.then(function(e){/^blob:/.test(e)&&URL.revokeObjectURL(e)},function(){})}return r?new Promise(function(e,t){var n=function(){t(a(r))};r.addEventListener(`abort`,n,{once:!0}),o.then(function(t){r.removeEventListener(`abort`,n),e(t)},function(e){r.removeEventListener(`abort`,n),t(e)})}):o},i}function y(e,t){return{setTitle:function(e){this.__title=String(e);var n=_(this.__title);t.setTitle(n?n.map(function(e){return e.text}).join(``):this.__title.replace(/<[^>]*>/g,``)),t.setTitleLinks&&t.setTitleLinks(n)},getTitle:function(){return String(this.title).replace(/<[^>]*>/g,``)},setBody:function(e){this.__destroyed||(q.setContent.call(this.body,e),t.bodyChanged&&t.bodyChanged(),t.loading&&t.loading(!1),this.__fire(`onUpdateBody`))},addBody:function(e){this.__destroyed||(q.addContent.call(this.body,e),t.bodyChanged&&t.bodyChanged(),t.loading&&t.loading(!1),this.__fire(`onUpdateBody`))},createElement:function(e,t){return X(e,t)},setIcon:function(e){t.setIcon&&t.setIcon(e==null?null:String(e))},setStyle:function(e){if(t.addStyle)return t.addStyle(String(e));var n=document.createElement(`style`),r=String(e).replace(/#moduleContent|#container/g,``);n.textContent=document.documentElement.hasAttribute(`data-css-layers`)?`@layer widget{`+r+`
|
|
3
|
+
}`:r,document.head.appendChild(n)},log:function(){this.__debug&&console.log.apply(console,[`[UWA]`].concat([].slice.call(arguments)))}}}function b(e,t){return{__fullSize:!1,canFullSize:!!t.openFull,openFull:function(){t.openFull&&t.openFull()},closeFull:function(){t.closeFull&&t.closeFull()},setFullScreen:function(e){t.setScreen&&t.setScreen(!!e)},__fullScreen:!1,__setFullScreen:function(e,t){if(this.environment&&this.environment.inline||document.documentElement.classList.toggle(`uwa-full-window`,!!t),this.__fullScreen!==!!e){this.__fullScreen=!!e;var n=this;requestAnimationFrame(function(){n.__listens(`onFullScreen`)&&n.__fire(`onFullScreen`,n.fullScreen)})}},__grows:[],__held:{},__fullFits:[],__setRoom:function(e,t){if(e=Number(e),t=Number(t),this.fullSize&&isFinite(e)){this.__grows.forEach(function(n){n(e,t>0?t:void 0)});var n=!1;this.__fullFits.forEach(function(r){r.box.isConnected&&r(e,t>0?t:void 0)&&(n=!0)}),n||this.__fitDone()}},__fitDone:function(){!this.__fitted&&this.fullSize&&(this.__fitted=!0,requestAnimationFrame(function(){requestAnimationFrame(function(){t.fitted&&t.fitted()})}))},__setFullSize:function(e){if(this.__fullSize!==!!e){this.__fullSize=!!e;var t=this;if(this.environment&&this.environment.inline||document.documentElement.classList.toggle(`uwa-full-size`,this.fullSize),e){this.__fitted=!1;var n=function(e){return e.box?e.box.isConnected:e.scroller.isConnected};!this.__fullFits.some(n)&&!this.__grows.some(n)?this.__fitDone():setTimeout(function(){t.__fitDone()},1200)}if(e&&!this.__fullEsc?(this.__fullEsc=function(e){e.key===`Escape`&&t.fullSize&&!e.defaultPrevented&&t.closeFull()},document.addEventListener(`keydown`,this.__fullEsc)):!e&&this.__fullEsc&&(document.removeEventListener(`keydown`,this.__fullEsc),this.__fullEsc=null),!e){this.__grows.forEach(function(e){e(null)});var r=!1;this.__fullFits.forEach(function(e){e.box.isConnected&&!e.restore()&&(r=!0)});var i=this.__held;this.__held={};for(var a=Object.keys(i),o=0;o<a.length;o++)this.__data[a[o]]=i[a[o]];r&&this.__fire(`onLoad`)}requestAnimationFrame(function(){t.__listens(`onFullSize`)&&t.__fire(`onFullSize`,t.fullSize)})}}}}function x(e,t,n){var r=`http://www.w3.org/2000/svg`,i=document.createElement(`div`);i.className=`count-grip`,i.setAttribute(`role`,`separator`),i.setAttribute(`aria-orientation`,`horizontal`),i.setAttribute(`aria-label`,t),i.title=n,i.tabIndex=0;var a=i.appendChild(document.createElementNS(r,`svg`));a.setAttribute(`viewBox`,`0 0 10 10`),a.setAttribute(`aria-hidden`,`true`);var o=a.appendChild(document.createElementNS(r,`path`));o.setAttribute(`d`,`M9 3L3 9M9 6L6 9`),o.setAttribute(`stroke`,`currentColor`),o.setAttribute(`stroke-width`,`1.2`),o.setAttribute(`stroke-linecap`,`round`);var s=getComputedStyle(e).position;return s&&s!==`static`||(e.style.position=`relative`),e.appendChild(i),i}function S(e,t,n,r,i){e.setAttribute(`aria-valuemin`,String(n)),e.setAttribute(`aria-valuemax`,String(Math.max(n,r,t))),e.setAttribute(`aria-valuenow`,String(t)),e.setAttribute(`aria-valuetext`,i)}function C(e){return e.altKey||e.ctrlKey||e.metaKey||e.shiftKey?null:{ArrowDown:1,ArrowUp:-1,Home:`least`,End:`most`}[e.key]||null}function w(){return!!(window.matchMedia&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)}function T(e,t){return{__gripTemp:!1,__fitted:!0,__fitCache:{},__gripFollower:function(e,t,n){var r=function(){return e.getBoundingClientRect().top},i=t-r(),a=1,o={h:n,g:r()};return{want:function(e){return o.h+(e-i-r())/a},took:function(e){var t=r();if(Math.abs(e-o.h)>=2){var n=(t-o.g)/(e-o.h);n>.3&&n<1.3&&(a=n)}o={h:e,g:t}}}},__relayGrip:function(e){this.__grip=e,t.gripDrag&&t.gripDrag(!!e)},countGrip:function(e,n,r){r||={};var i=r.min||1,a=null,o=160,s=x(e,`Items shown`,`Drag to show more or fewer items`),c=function(){return Array.prototype.slice.call(e.querySelectorAll(n))},l=this,u=0,d=function(){var e=c().length;u=Math.max(u,e),S(s,e,i,u,u>e?e+` of `+u+` items`:e+(e===1?` item`:` items`))};d(),s.addEventListener(`focus`,d);var f=function(e,t){l.__gripTemp=t;try{r.onDone(e)}finally{l.__gripTemp=!1}},p=function(n,a){if(!r.onDone||!e.isConnected||(p.px=n,p.from=a,p.ran))return!1;p.ran=!0;var o=l.environment&&l.environment.inline?l.body:document.documentElement,s=(a||o.getBoundingClientRect().height)+n,u=Math.round(o.getBoundingClientRect().width);p.before===void 0&&(p.before=c().length);var d=function(e){var t=0;return e.forEach(function(e){t=Math.max(t,e.getBoundingClientRect().bottom)}),t-o.getBoundingClientRect().top},m=0,h=function(){var t=o.getBoundingClientRect().top,n=c();m=n.length?Math.max(0,e.getBoundingClientRect().bottom-t-d(n)):0;var r=n.filter(function(e){return e.getBoundingClientRect().bottom-t+m<=s}).length;return{n:Math.max(i,r),all:n.length}},g=c().length;if(r.onStart){l.__gripTemp=!0;try{r.onStart()}finally{l.__gripTemp=!1}}var _=c().length===g&&(!t.inFlight||t.inFlight()>0),v=parseInt(l.__getValue(`__maxCount`),10);if(v>0)return f(v,!0),!1;var y=Math.round(s)+`x`+u,b=l.__fitCache[y],x=h();if(b&&x.all>=b)return f(b,!0),!1;var S=function(e,t){if(f(e,!0),c().length===e)for(;e<t;){f(e+1,!0);var n=c();if(n.length!==e+1||d(n)+m>s){f(e,!0);break}e++}l.__fitCache[y]=e};if(x.n<x.all||!_)return S(x.n,x.all),!1;var C=new MutationObserver(function(){var e=h();e.n<e.all&&(C.disconnect(),clearTimeout(w),S(e.n,e.all),l.__fitDone())});C.observe(e,{childList:!0,subtree:!0});var w=setTimeout(function(){C.disconnect();var e=h();S(e.n,e.all),l.__fitDone()},1e3);return!0};p.restore=function(){var t=p.before;if(p.before=void 0,p.ran=!1,t===void 0||!e.isConnected)return!0;if(c().length<t)return!1;if(r.onStart){l.__gripTemp=!0;try{r.onStart()}finally{l.__gripTemp=!1}}return f(t,!0),!0},p.box=e,this.__fullFits=this.__fullFits.filter(function(e){return e.box.isConnected}).concat(p);var m=0,h=function(){clearTimeout(m),m=0},g=function(t){if(h(),e.style.height=``,w())e.style.overflow=``,e.style.boxSizing=``;else{var n=e.getBoundingClientRect().height;e.style.height=t+`px`,e.offsetHeight,e.style.transition=`height `+o+`ms ease-out`,e.style.height=n+`px`,m=setTimeout(function(){m=0,e.style.transition=``,e.style.height=``,e.style.overflow=``,e.style.boxSizing=``},o+30)}};s.addEventListener(`dblclick`,function(){if(l.fullSize)l.__deleteValue(`__maxCount`),p.ran=!1,setTimeout(function(){p.px!==void 0&&l.fullSize&&p(p.px,p.from)},o+60);else{var t=r.setting||(l.getPreference(`count`)?`count`:l.getPreference(`limit`)?`limit`:null),n=t?l.getPreference(t):null,a=n?parseInt(n.defaultValue,10):NaN;if(!(a>0)||!r.onDone)return;var s=e.getBoundingClientRect().height;r.onStart&&r.onStart(),f(Math.max(i,a),!1),g(s),d()}});var _=function(){var t=a;if(a=null,document.body.classList.remove(`count-grip-dragging`),l.__relayGrip(null),t){var n=e.getBoundingClientRect().bottom-t.below,o=Math.max(i,c().filter(function(e){var t=e.getBoundingClientRect();return t.top+t.height/2<n}).length),s=e.getBoundingClientRect().height;r.onDone&&(u=Math.max(u,c().length),f(o,l.fullSize),l.fullSize&&l.__setValue(`__maxCount`,String(o))),g(s),d()}},v=null,y=null,b=function(n){v&&v();var o=c().length;if(!a&&o&&r.onDone&&!((n===-1||n===`least`)&&o<=i)){h();var p=e.getBoundingClientRect().height;e.style.boxSizing=`border-box`,e.style.height=p+`px`,e.style.overflow=`hidden`,e.style.transition=``,r.onStart&&r.onStart();var m=c().length;u=Math.max(u,m);var _=n===`least`?i:n===`most`?m:o+n,b=null,x=0,S=0,C=!1,w=function(){C=!0,v=null,y=null,b&&b.disconnect(),clearTimeout(x),clearTimeout(S)},T=function(){if(!C&&(w(),s.isConnected)){var e=c().length;u=Math.max(u,e);var t=Math.max(i,Math.min(_,e)),n=document.activeElement===s;if(f(t,l.fullSize),l.fullSize&&l.__setValue(`__maxCount`,String(t)),g(p),d(),n&&!s.isConnected){var r=l.body&&l.body.querySelector(`.count-grip`);r&&r.focus()}}};if(_<=m)return T();v=T,y=w,S=setTimeout(function(){if(!C){if(c().length>=_||t.inFlight&&t.inFlight()===0)return T();b=new MutationObserver(function(){c().length>=_&&T()}),b.observe(e,{childList:!0,subtree:!0}),x=setTimeout(T,2e3)}},0)}};s.addEventListener(`keydown`,function(e){var t=C(e);t&&(e.preventDefault(),b(t))}),s.addEventListener(`pointerdown`,function(t){v&&t.button===0&&v();var n=c(),i=n[n.length-1];if(i&&t.button===0){h(),t.preventDefault();try{s.setPointerCapture(t.pointerId)}catch{}var o=e.getBoundingClientRect();a={startY:t.clientY,startHeight:o.height,below:o.bottom-i.getBoundingClientRect().bottom,follow:l.__gripFollower(s,t.clientY,o.height)},l.fullSize&&p.before===void 0&&(p.before=n.length),e.style.boxSizing=`border-box`,e.style.height=o.height+`px`,e.style.overflow=`hidden`,e.style.transition=``,document.body.classList.add(`count-grip-dragging`),l.__relayGrip({move:T,end:_}),r.onStart&&r.onStart()}});var T=function(t){if(a){var n=c()[0],r=(n?n.getBoundingClientRect().bottom-e.getBoundingClientRect().top:0)+a.below;e.style.height=Math.max(r,a.follow.want(t))+`px`,a.follow.took(e.getBoundingClientRect().height)}};return s.addEventListener(`pointermove`,function(e){T(e.clientY)}),s.addEventListener(`pointerup`,_),s.addEventListener(`pointercancel`,_),s.release=function(){y&&y(),h(),a&&_(),s.remove()},s},heightGrip:function(e,n,r){r||={};var i=this,a=r.min||80,o=null,s=null,c=null;n.style.overflowY=`auto`;var l=function(e,t){if(e===null){if(c===null)return;n.style.height=c,c=null,s&&(s.style.display=``)}else if(n.isConnected&&(c===null&&(c=n.style.height),s&&(s.style.display=`none`),t>0&&(e=t+e-document.documentElement.getBoundingClientRect().height),!(Math.abs(e)<2))){var r=n.getBoundingClientRect().height+e,i=n.lastElementChild,o=i?Math.ceil(i.getBoundingClientRect().bottom-n.getBoundingClientRect().top+n.scrollTop):0;n.style.height=Math.max(a,Math.min(Math.max(n.scrollHeight,o),r))+`px`}};this.__grows=this.__grows.filter(function(e){return e.scroller.isConnected}).concat(l),l.scroller=n,this.fullSize&&t.askRoom&&setTimeout(function(){t.askRoom()},0);var u=160,d=function(){if(!r.items)return[];var e=n.getBoundingClientRect().top-n.scrollTop;return Array.prototype.slice.call(n.querySelectorAll(r.items)).map(function(t){var n=t.getBoundingClientRect();return{top:n.top-e,bottom:n.bottom-e,heading:/^H[1-6]$/.test(t.tagName)}})},f=function(e,t){var n=d(),r=-1;if(t||=0,!n.length)return Math.max(a,e);for(var i=0;i<n.length;i++)n[i].bottom>t&&(r<0||(n[i].top+n[i].bottom)/2<t+e)&&(r=i);if(r<0)return Math.max(a,e);for(;r>0&&n[r].heading&&n[r-1].bottom>t;)r--;return Math.max(a,Math.round(n[r].bottom-t))};r.height>0&&(n.style.height=f(Math.max(a,r.height))+`px`),s=x(e,`List height`,`Drag to make the list taller or shorter`);var p=function(){var e=Math.round(n.getBoundingClientRect().height),t=Math.max(a,n.scrollHeight),r=d(),i=n.scrollTop,o=r.filter(function(t){return!t.heading&&t.bottom>i&&(t.top+t.bottom)/2<i+e}).length,c=r.filter(function(e){return!e.heading}).length;S(s,e,a,t,c?o+` of `+c+` items`:e+` pixels`)};p(),s.addEventListener(`focus`,p),s.addEventListener(`keydown`,function(e){var t=C(e);if(t&&(e.preventDefault(),!o)){var i=n.getBoundingClientRect().height,s=n.scrollTop,c=Math.max(a,n.scrollHeight),l=i;if(t===`least`)l=f(a,s);else if(t===`most`)l=c;else{for(var d=r.items?8:20;d<=400&&(l-i)*t<1;d+=8)l=f(Math.min(c,Math.max(a,i+t*d)),s);if((l-i)*t<1)return}if(l=Math.min(c,Math.max(a,l)),!(Math.abs(l-i)<1)){var m=!w();n.style.transition=m?`height `+u+`ms ease-out`:``,n.style.height=l+`px`,setTimeout(function(){n.style.transition=``,p(),r.onDone&&r.onDone(l)},m?u+30:0)}}});var m=function(){i.__relayGrip(null);var e=o;if(o=null,document.body.classList.remove(`count-grip-dragging`),e){var t=d(),a=t.length?t[0].top:0,s=0;t.forEach(function(e){Math.abs(e.top-a-n.scrollTop)<Math.abs(s-n.scrollTop)&&(s=e.top-a)}),n.scrollTop=s;var c=f(n.getBoundingClientRect().height,n.scrollTop),l=!w();n.style.transition=l?`height `+u+`ms ease-out`:``,n.style.height=c+`px`,setTimeout(function(){n.style.transition=``,p(),r.onDone&&r.onDone(c)},l?u+30:0)}};s.addEventListener(`pointerdown`,function(e){if(e.button===0){e.preventDefault();try{s.setPointerCapture(e.pointerId)}catch{}var t=n.getBoundingClientRect().height;o={startY:e.clientY,startHeight:t,follow:i.__gripFollower(s,e.clientY,t)},document.body.classList.add(`count-grip-dragging`),i.__relayGrip({move:h,end:m})}});var h=function(e){if(o){var t=Math.max(a,n.scrollHeight);n.style.height=Math.min(t,Math.max(a,o.follow.want(e)))+`px`,o.follow.took(n.getBoundingClientRect().height)}};return s.addEventListener(`pointermove`,function(e){h(e.clientY)}),s.addEventListener(`pointerup`,m),s.addEventListener(`pointercancel`,m),s}}}function E(e){if(e.__standaloneAudio)return e.__standaloneAudio;var t=new Audio;t.preload=`none`;var n=function(t){var n=e.audioState;e.__setAudioState({url:`url`in t?t.url:n.url,playing:`playing`in t?t.playing:n.playing,loading:`loading`in t?t.loading:n.loading,error:`error`in t?t.error:n.error})};t.addEventListener(`playing`,function(){n({playing:!0,loading:!1,error:null})}),t.addEventListener(`waiting`,function(){n({loading:!0})});var r=[];return t.addEventListener(`pause`,function(){var i=t.ended?r.shift():void 0;i?e.__standaloneAudio.play({url:i.url,live:!1,next:r}):(r=[],n({playing:!1,loading:!1}))}),t.addEventListener(`error`,function(){t.getAttribute(`src`)&&n({playing:!1,loading:!1,error:`failed`})}),e.__standaloneAudio={play:function(e){return/^https:\/\//.test(e.url)?(r=e.live===!1&&Array.isArray(e.next)?e.next.filter(function(e){return/^https:\/\//.test(e.url)}).slice(0,100):[],n({url:e.url,loading:!0,error:null}),t.src=e.url,t.play().catch(function(e){e.name!==`AbortError`&&n({playing:!1,loading:!1,error:e.name===`NotAllowedError`?`blocked`:`failed`})}),!0):!1},pause:function(){t.pause(),t.removeAttribute(`src`),t.load()}},e.__standaloneAudio}function D(e,t){return{audioStarted:function(e,n){if(typeof e!=`function`)throw Error(`widget.audioStarted needs a function that stops the sound`);t.audioStarted&&t.audioStarted(e,n||{})},audioStopped:function(){t.audioStopped&&t.audioStopped()},__audioState:{url:null,playing:!1,loading:!1,error:null,away:!1},playAudio:function(e){var n=e||{},r={url:String(n.url||``),relay:!!n.relay,live:n.live!==!1};return!r.live&&Array.isArray(n.next)&&(r.next=n.next.map(function(e){var t=e||{};return{url:String(t.url||``),relay:!!t.relay,title:t.title?String(t.title):void 0,artist:t.artist?String(t.artist):void 0}})),t.playAudio?t.playAudio(r):E(this).play(r)},pauseAudio:function(){return t.pauseAudio?t.pauseAudio():E(this).pause()},seekAudio:function(e){if(t.seekAudio)return t.seekAudio(Number(e));var n=E(this);n.seek&&n.seek(Number(e))},__setAudioState:function(e){var t=e||{};this.__audioState={url:t.url||null,playing:!!t.playing,loading:!!t.loading,error:t.error||null,away:!!t.away,time:typeof t.time==`number`?t.time:null,duration:typeof t.duration==`number`?t.duration:null,elsewhere:t.elsewhere&&t.elsewhere.url?{url:String(t.elsewhere.url),playing:!!t.elsewhere.playing,loading:!!t.elsewhere.loading,time:typeof t.elsewhere.time==`number`?t.elsewhere.time:null,duration:typeof t.elsewhere.duration==`number`?t.elsewhere.duration:null,source:t.elsewhere.source?String(t.elsewhere.source):null}:null},this.__listens(`onAudioState`)&&this.__fire(`onAudioState`,this.audioState)},__videoState:null,__setVideoState:function(e){var t=e&&typeof e==`object`?e:null;this.__videoState=t?{provider:String(t.provider||``),id:String(t.id||``),list:t.list?String(t.list):void 0,playing:!!t.playing}:null,this.__listens(`onVideoState`)&&this.__fire(`onVideoState`,this.videoState)},audioInfo:function(e){t.audioInfo&&e&&t.audioInfo({source:e.source?String(e.source):void 0,title:e.title?String(e.title):void 0,artist:e.artist?String(e.artist):void 0,artwork:e.artwork?String(e.artwork):void 0,artworkType:e.artworkType?String(e.artworkType):void 0,artworkSizes:e.artworkSizes?String(e.artworkSizes):void 0})},playVideo:function(e){if(t.playVideo)return t.playVideo(e);var n=e||{};n.provider===`youtube`&&/^[A-Za-z0-9_-]{11}$/.test(n.id)?window.open(`https://www.youtube.com/watch?v=`+n.id+(/^[A-Za-z0-9_-]{10,64}$/.test(n.list||``)?`&list=`+n.list:``),`_blank`,`noopener`):n.provider===`vimeo`&&/^\d{1,12}$/.test(n.id)?window.open(`https://vimeo.com/`+n.id,`_blank`,`noopener`):n.provider===`arte`&&/^(\d{6}-\d{3}-[A-Z]|RC-\d{6})$/.test(n.id)&&window.open(`https://www.arte.tv/`+(/^(fr|de|en|es|pl|it)$/.test(n.lang||``)?n.lang:`fr`)+`/videos/`+n.id+`/`,`_blank`,`noopener`)},__resumeAudio:function(){this.__resumeQueued=!this.__launched,this.__launched&&this.__fire(`onAudioResume`)}}}function O(e,t,n){return{recall:function(e){return this.__memory[String(e)]},remember:function(e,n){e=String(e),n===void 0?delete this.__memory[e]:this.__memory[e]=n,t.remember&&t.remember(e,n)},getStored:function(e){if(e=String(e),t.getStored)return t.getStored(e);var n=this.__stored[e];return n===void 0?void 0:JSON.parse(JSON.stringify(n))},setStored:function(e,n){e=String(e),n===void 0?delete this.__stored[e]:this.__stored[e]=JSON.parse(JSON.stringify(n)),t.setStored&&t.setStored(e,n)},keptContent:function(e){var t=this.__recall(`content`),n=t&&t[String(e)],r=n&&n._myvibes&&n._myvibes.fetched;return n&&Array.isArray(n.items)&&typeof r==`number`?n:null},keepContent:function(e,t,n){e=String(e);var i=Date.now(),a=this.__recall(`content`)||{},o={},s={};for(var c in t)s[c]=t[c];var l=t._myvibes&&t._myvibes.fetched;s._myvibes=r(r({},t._myvibes||{}),{source:e,fetched:n&&typeof l==`number`?l:i});var u=Object.keys(a).filter(function(t){var n=a[t];return t!==e&&n&&n._myvibes&&i-n._myvibes.fetched<2592e6});return u.sort(function(e,t){return a[t]._myvibes.fetched-a[e]._myvibes.fetched}),u.slice(0,5).forEach(function(e){o[e]=a[e]}),o[e]=s,this.__remember(`content`,o),s},__keepsContent:function(){return this.__refreshAfterError||!(Date.now()<(this.__refreshUntil||0))||!this.body?!1:this.body.children.length>0&&!this.body.querySelector(`.loading`)}}}function k(e,t,n){return{__prepareGoogle:function(){n.prepareGoogle&&n.prepareGoogle()},__connectGoogle:function(e){return n.connectGoogle?n.connectGoogle(e):Promise.reject(/* @__PURE__ */ Error(`Connecting a Google account works from your page, not from this widget alone.`))},setChromeColor:function(e,t){var r=t||{};n.setChromeColor&&n.setChromeColor(e||null,r.background||null)},openPhoto:function(e){if(n.openPhoto)return n.openPhoto(e);e&&e.src&&window.open(String(e.src),`_blank`,`noopener`)},addWidget:function(e){return n.addWidget?n.addWidget(e):!1},dragWidget:function(e,t){return!n.dragWidget||!e?!1:(e.setAttribute(`draggable`,`true`),e.addEventListener(`dragstart`,function(e){var r=typeof t==`function`?t(e):t;r&&n.dragWidget(e,r)||e.preventDefault()}),!0)},openURL:function(e){n.openURL?n.openURL(String(e)):window.open(e,`_blank`,`noopener`)},openPreferences:function(){n.openPreferences&&n.openPreferences()},withPreferencesLink:function(e){var t=this,n=document.createElement(`span`);return String(e).split(/(\[\[[^\]]*\]\])/).forEach(function(e){var r=/^\[\[([^\]]*)\]\]$/.exec(e);if(!r)e&&n.appendChild(document.createTextNode(e));else{var i=document.createElement(`a`);i.href=`#`,i.className=`uwa-prefs-link`,i.textContent=r[1],i.addEventListener(`click`,function(e){e.preventDefault(),t.openPreferences()}),n.appendChild(i)}}),n},shareUrl:function(){var e=t.dashboard||(t.inline?location.origin:``),n=/^(https?:\/\/[^/]+)\/xwa\/([a-z0-9-]+(?:\.[rsu]wa)?)\.x?html$/.exec(String(t.url||``).split(/[?#]/)[0]);return n&&e&&n[1]===e?e+`/add/`+n[2]:null},share:function(e){var t={text:String(e&&e.text||``).slice(0,2e3),url:e&&e.url?String(e.url):``};if(n.share)return n.share(t);var r=t.url?t.text+`
|
|
4
|
+
`+t.url:t.text;if(navigator.share)return navigator.share(t.url?{text:t.text,url:t.url}:{text:t.text}).catch(function(){});navigator.clipboard&&navigator.clipboard.writeText(r)},sendTo:function(){n.sendTo&&this.environment&&this.environment.people&&n.sendTo()},openItems:function(e,t,r){if(n.openItems)return n.openItems(e,t,r||{});var i=e&&e[t];i&&i.url&&window.open(i.url,`_blank`,`noopener`)}}}function A(e,t){return{setSearchResultCount:function(e){this.__searchResultCount=Number(e)||0},isRead:function(e){return Object.prototype.hasOwnProperty.call(this.__read,String(e))},setRead:function(e,n){for(var r=(Array.isArray(e)?e:[e]).map(String).filter(function(e){return e&&e.length<=2e3}).slice(0,500),i=n!==!1,a=0;a<r.length;a++)i?this.__read[r[a]]=!0:delete this.__read[r[a]];r.length&&t.setRead&&t.setRead(r,i)},__setReadKeys:function(e){var t={};(Array.isArray(e)?e:[]).forEach(function(e){typeof e==`string`&&(t[e]=!0)}),this.__read=t,this.__paintRead&&this.__paintRead()},setUnreadCount:function(e){this.__unreadCount=Math.max(0,Math.floor(Number(e))||0),t.setUnreadCount&&t.setUnreadCount(this.__unreadCount)},setMaxValue:function(e,n){var r=Math.floor(Number(n));t.setMaxValue&&e&&r>=0&&t.setMaxValue(String(e),r)},readItems:function(e,t,n){n||={};var r=this,i=function(e){if(n.key)return String(n.key(e)||``);var t=e.querySelector(`a.ext-link[href]`)||e.querySelector(`a[href]`);return t?t.href:``},a=function(){return Array.prototype.slice.call(e.querySelectorAll(t))},o=function(){var e=0;a().forEach(function(t){var n=i(t),a=!!n&&r.isRead(n);t.classList.toggle(`uwa-read`,a),n&&!a&&e++}),document.body.classList.contains(`count-grip-dragging`)||r.setUnreadCount(e)},s=function(n){if(n.type!==`auxclick`||n.button===1){var a=n.target.closest&&n.target.closest(`a[href]`),s=a&&a.closest(t);if(s&&e.contains(s)){var c=i(s);c&&!r.isRead(c)&&(r.setRead(c),o())}}};e.addEventListener(`click`,s,!0),e.addEventListener(`auxclick`,s,!0);var c=null,l=new MutationObserver(function(){clearTimeout(c),c=setTimeout(o,50)});l.observe(e,{childList:!0,subtree:!0}),this.__paintRead=o,this.onReadAll||(this.__readAllItems=function(){var e=a().map(i).filter(Boolean);e.length&&r.setRead(e),o()}),o();var u=this.__readAllItems;return{paint:o,stop:function(){e.removeEventListener(`click`,s,!0),e.removeEventListener(`auxclick`,s,!0),l.disconnect(),clearTimeout(c),r.__paintRead===o&&(r.__paintRead=null),r.__readAllItems===u&&(r.__readAllItems=null)}}},__readAll:function(e){if(e===!1){var t=Object.keys(this.__read);t.length&&this.setRead(t,!1),this.__paintRead&&this.__paintRead()}else{var n=this.__uwaApi&&(typeof this.onReadAll==`function`||typeof this.callbacks.onReadAll==`function`);this.__fire(`onReadAll`)&&!n&&this.__readAllItems&&this.__readAllItems()}}}}function j(){var e=!0,t=/* @__PURE__ */ new Set,n;return{__setShown:function(r){if(r=r!==!1,r!==e){var i=!e||document.hidden;if(e=r,i!==(!e||document.hidden)){var a=new Event(`visibilitychange`);Array.from(t).forEach(function(e){try{typeof e==`function`?e.call(n,a):e&&typeof e.handleEvent==`function`&&e.handleEvent(a)}catch(e){console.error(`[UWA]`,e)}})}}},__document:function(){return n||(n=new Proxy(document,{get:function(n,r){if(r===`hidden`)return!e||n.hidden;if(r===`visibilityState`)return e?n.visibilityState:`hidden`;if(r===`addEventListener`||r===`removeEventListener`)return function(e,i,a){return e===`visibilitychange`&&(r===`addEventListener`?t.add(i):t.delete(i)),n[r](e,i,a)};var i=Reflect.get(n,r,n);return typeof i==`function`?i.bind(n):i},set:function(e,t,n){return Reflect.set(e,t,n,e)}}),n)}}}function M(e,t){return{setPeriodical:function(e,t,n,r){this.clearPeriodical(e);var i=this;this.__periodicals[e]=setInterval(function(){t.call(i)},n),r&&t.call(this)},clearPeriodical:function(e){this.__periodicals[e]&&clearInterval(this.__periodicals[e]),delete this.__periodicals[e]},setAutoRefresh:function(e){if(e=Number(e)||0,this.__listens(`onRefresh`)||(e=0),t.autoRefresh)return t.autoRefresh(e);if(e<=0)return this.clearPeriodical(`autoRefresh`);this.setPeriodical(`autoRefresh`,function(){this.__fire(`onRefresh`)},e*6e4+Math.floor(Math.random()*1e4))}}}function N(e,t,n){return{getPreference:function(e){for(var t=0;t<this.preferences.length;t++)if(this.preferences[t].name===e)return this.preferences[t];return null},__initPreferences:function(){for(var e=0;e<this.preferences.length;e++){var t=this.preferences[e];t.name&&this.__getValue(t.name)==null&&t.defaultValue&&(this.__data[t.name]=String(t.defaultValue))}},getValue:function(e){if(this.__data[e]!==void 0)return this.__data[e];var n=Object.prototype.hasOwnProperty.call(t.values,e)?t.values[e]:void 0;return n===`null`&&(n=null),n!==void 0&&(this.__data[e]=n),n},getInt:function(e){var t=this.__getValue(e);return t===`true`||t===!0?1:(t=parseInt(t,10),isNaN(t)?0:t)},getBool:function(e){return!!this.__getInt(e)},setValue:function(e,t){return this.__data[e]===t||(this.__gripTemp&&!Object.prototype.hasOwnProperty.call(this.__held,e)&&(this.__held[e]=this.__getValue(e)),this.__data[e]=t,this.__gripTemp)||n.setValue(String(e),t==null?``:String(t)),t},deleteValue:function(e){e=String(e),delete this.__data[e],t.values&&delete t.values[e];var r=this.getPreference(e);r&&r.defaultValue!==void 0&&(this.__data[e]=r.defaultValue),n.deleteValue?n.deleteValue(e):n.setValue(e,``)}}}var P={onLoad:`load`,onLoadComplete:`loadcomplete`,onRefresh:`refresh`,onResize:`resize`,onUpdateBody:`updatebody`,onUpdatePreferences:`updatepreferences`,onHideEdit:`hideedit`,onReadAll:`readall`,onAudioState:`audiostate`,onAudioResume:`audioresume`,onVideoState:`videostate`,onFullSize:`fullsize`,onFullScreen:`fullscreen`,__settingsChange:`settingschange`,__action:`action`,__photoDelete:`photodelete`,__filesChange:`fileschange`},F={readall:!0,settingschange:!0},I=typeof Event==`function`?(function(){function e(t,n){var r=Reflect.construct(Event,[t,n||{}],new.target||e);return Object.defineProperty(r,"__detail",{value:n&&`detail`in n?n.detail:null}),Object.defineProperty(r,"__promises",{value:null,writable:!0}),Object.defineProperty(r,"__signal",{value:n&&n.signal?n.signal:null}),r}return e.prototype=Object.create(Event.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.setPrototypeOf(e,Event),Object.defineProperty(e.prototype,"detail",{get:function(){return this.__detail},configurable:!0}),Object.defineProperty(e.prototype,"signal",{get:function(){return this.__signal},configurable:!0}),e.prototype.waitUntil=function(e){if(!this.__promises)throw new DOMException(`waitUntil is only for a load being dispatched (load, refresh)`,`InvalidStateError`);this.__promises.push(Promise.resolve(e))},e})():null;function L(e,t,n,r){try{var i={detail:Object.assign({widget:t},n||{})};typeof r==`number`&&(i.startTime=r),performance.mark(`xwa:`+e,i)}catch{}}function R(e,t){return e}function z(e){return e&&typeof e==`object`&&(Object.keys(e).forEach(function(t){z(e[t])}),Object.freeze(e)),e}function B(e,t,n){var r=e.__uwaApi,i=function(t,n,i){Object.defineProperty(e,t,{get:n,set:r?i:void 0,enumerable:!0,configurable:!0})},a=function(t){Object.defineProperty(e,t,{value:e[t],writable:!!r,enumerable:!0,configurable:!0})};i(`title`,function(){return e.__title},function(t){e.__title=t}),i(`body`,function(){return e.__body},function(t){e.__body=t}),i(`fullSize`,function(){return e.__fullSize},function(t){e.__fullSize=t}),i(`fullScreen`,function(){return e.__fullScreen},function(t){e.__fullScreen=t}),i(`audioState`,function(){return r?e.__audioState:Object.freeze(e.__audioState)},function(t){e.__audioState=t}),i(`videoState`,function(){return r||!e.__videoState?e.__videoState:Object.freeze(e.__videoState)},function(t){e.__videoState=t});var o=null,s=null;i(`preferences`,function(){return r?e.__preferences:(o!==e.__preferences&&(o=e.__preferences,s=z(JSON.parse(JSON.stringify(o||[])))),s)},function(t){e.__preferences=t}),r?(e.data=e.__data,e.periodicals=e.__periodicals,e.launch=e.__launch,e.endEdit=e.__endEdit,e.initPreferences=e.__initPreferences,i(`debugMode`,function(){return e.__debug},function(t){e.__debug=t}),i(`unreadCount`,function(){return e.__unreadCount},function(t){e.__unreadCount=t}),i(`searchResultCount`,function(){return e.__searchResultCount},function(t){e.__searchResultCount=t})):(i(`metas`,n),e.environment=Object.freeze(e.environment),[`id`,`uwaUrl`,`lang`,`locale`,`environment`,`canFullSize`,`settings`,`storage`].forEach(a))}function V(e,t,n){t=R(t,e.instance);var a=e.metas||{},o=a.debugMode===`true`,s=null,c={id:e.instance,__title:e.title,__body:null,__data:{},callbacks:{},__preferences:e.preferences||[],metas:a,__debug:o,elements:{},__periodicals:{},apiVersion:`1.2`,lang:(e.lang||`en-US`).replace(`-`,`_`),locale:(e.lang||`en-US`).split(`-`)[1]?(e.lang||`en-US`).split(`-`)[1].toLowerCase():`us`,dir:`ltr`,readOnly:!1,isNew:!1,uwaUrl:e.url,__searchResultCount:0,__unreadCount:0,__memory:e.memory||{},__stored:e.stored||{},__read:(e.read||[]).reduce(function(e,t){return typeof t==`string`&&(e[t]=!0),e},{}),environment:{name:`myvibes`,standalone:!!e.standalone,inline:!!e.inline,style:e.theme?String(e.theme):``,people:e.people&&typeof e.people.me==`string`?Object.freeze({me:e.people.me,from:e.people.from||null,to:e.people.to||null}):null},__fire:function(e,n,r){var a=e===`onLoad`||e===`onRefresh`;(e===`onLoad`||e===`onRefresh`)&&t.loading&&t.loading(!0),(e===`onRefresh`||e===`onLoad`&&this.__retrying)&&(this.__afterEdit||(this.__refreshUntil=Date.now()+3e4),this.__refreshAfterError=this.__errorBoxes().length>0,this.__refreshAfterError||(this.__retries=0),this.__errorBoxes().forEach(function(e){e.remove()}));for(var o=[],s=this.__uwaApi?[this[e],this.callbacks[e]]:[],c=0;c<s.length;c++)if(typeof s[c]==`function`)try{var u=s[c].call(r||this,n);a&&u&&typeof u.then==`function`&&o.push(u)}catch(e){l(e)}var d=!0,f=P[e];if(f&&this.__dispatch){var p=null;a&&typeof AbortController==`function`&&(this.__loadAbort&&this.__loadAbort.abort(),this.__loadAbort=new AbortController,p=this.__loadAbort.signal);var m=new I(f,{detail:n===void 0?null:n,cancelable:!!F[f],signal:p});a&&(m.__promises=[]),e===`__action`&&this.__actionToken&&i&&i.set(m,this.__actionToken),d=this.__dispatch(m),a&&(m.__promises.forEach(function(e){o.push(e.catch(l))}),m.__promises=null)}return o.length&&t.loading?Promise.allSettled(o).then(function(){t.loading(!1),t.bodyChanged&&t.bodyChanged()}):a&&!this.__uwaApi&&(t.loading&&t.loading(!1),t.bodyChanged&&t.bodyChanged()),e===`onLoad`&&!this.__actionsReady&&(this.__declaredActions()||[]).length&&this.__tellActions(),d},__listens:function(e){return this.__uwaApi&&(typeof this[e]==`function`||typeof this.callbacks[e]==`function`)||(this.__listening?this.__listening(P[e]):!1)},__attach:function(e){this.__body=e,this.elements&&(this.elements.body=e)},__launch:function(){if(e.preferences&&(this.__preferences=e.preferences),r(a,e.metas||{}),s=null,this.__debug=a.debugMode===`true`,this.environment&&this.environment.inline||document.documentElement.classList.toggle(`uwa-cover`,/(^|[,;\s])viewport-fit\s*=\s*cover\b/i.test(a.viewport||``)),e.title&&(this.__title=e.title),this.__initPreferences(),a.autoRefresh&&this.setAutoRefresh(a.autoRefresh),this.__starting=!0,L(`load`,e.instance),this.__fire(`onLoad`),this.__starting=!1,t&&t.__marksLaunched&&t.__marksLaunched(),this.__staleFeeds){var n=this;setTimeout(function(){n.__staleFeeds=!1,n.__listens(`onRefresh`)?n.__fire(`onRefresh`):n.__fire(`onLoad`)},0)}this.__fire(`onLoadComplete`),this.__launched=!0,this.__resumeQueued&&this.__resumeAudio()},__endEdit:function(e){var t=Array.isArray(e)?e.slice():[];if(!t.length||this.__fire(`__settingsChange`,{names:t})){this.__afterEdit=!0,this.__refreshUntil=0;try{this.__listens(`onRefresh`)?this.__fire(`onRefresh`):this.__fire(`onLoad`)}finally{this.__afterEdit=!1}}this.__fire(`onHideEdit`)},__applySettings:function(e){var t=[];for(var n in e)String(this.__getValue(n))!==String(e[n])&&t.push(n),this.__data[n]=e[n];this.__endEdit(t)},__errorBoxes:function(){var e=this.body&&this.body.parentNode;return Array.prototype.slice.call(e?e.querySelectorAll(`:scope > .uwa-error`):document.querySelectorAll(`.uwa-error`))},__retryLoad:function(){if(!(this.__retryTimer||this.__destroyed)){var e=this,t=[15,30,60,120,300],n=t[Math.min(this.__retries||0,t.length-1)]*1e3;this.__retries=(this.__retries||0)+1,this.__retryTimer=setTimeout(function(){if(e.__retryTimer=null,e.__destroyed||!e.__errorBoxes().length)e.__errorBoxes().length||(e.__retries=0);else{e.log(`trying again after a failed load`),e.__retrying=!0;try{e.__fire(e.__listens(`onRefresh`)?`onRefresh`:`onLoad`)}finally{e.__retrying=!1}}},n)}},__destroy:function(){for(var e in this.__loadAbort&&this.__loadAbort.abort(),this.__destroyed=!0,this.__unwatchAudio&&this.__unwatchAudio(),this.__unwatchVideo&&this.__unwatchVideo(),this.__unwatchFiles&&this.__unwatchFiles(),this.__unwatchFull&&this.__unwatchFull(),this.__unwatchScreen&&this.__unwatchScreen(),this.__unwatchRoom&&this.__unwatchRoom(),clearTimeout(this.__retryTimer),this.__periodicals)this.clearPeriodical(e)}};Object.assign(c,y(c,t),N(c,e,t),D(c,t),b(c,t),M(c,t),f(c,e,t),O(c,t,n),A(c,t),k(c,e,t),T(c,t),j());function l(e){t.loading&&t.loading(!1),console.error(`[UWA]`,e);var n=document.createElement(`div`);n.className=`uwa-error`,n.textContent=typeof e==`string`?e:`Widget error: `+(e&&e.message?e.message:String(e));var r=c.body;r&&r.parentNode?r.parentNode.insertBefore(n,r):document.body.insertBefore(n,document.body.firstChild)}c.__showError=l,c.__uwaApi=J(e),c.__keptContent=c.keptContent,c.__keepContent=c.keepContent,c.__recall=c.recall,c.__remember=c.remember,c.__getStored=c.getStored,c.__setStored=c.setStored,c.__getValue=c.getValue,c.__getInt=c.getInt,c.__getBool=c.getBool,c.__setValue=c.setValue,c.__deleteValue=c.deleteValue;var u=function(e,t){var n=c.getPreference(String(e));if(!n&&t)throw TypeError(`widget.settings.`+t+`: no setting "`+e+`" in the widget's form`);return n},d=function(e){return String(e)===`title`&&!c.getPreference(`title`)};c.settings=Object.freeze({get:function(e){if(d(e))return c.getTitle();var t=u(e);if(t){var n=c.__getValue(t.name);if(n??=t.defaultValue,t.type===`boolean`)return n===!0||n===`true`;if(t.type===`range`||t.type===`number`){var r=n===``||n==null?NaN:Number(n);return isFinite(r)?r:null}return n==null?``:String(n)}},set:function(e,t){var n=u(e,`set`);if(n.type===`boolean`){if(typeof t!=`boolean`)throw TypeError(`widget.settings.set: "`+n.name+`" is a checkbox: true or false`);t=t?`true`:`false`}else if(n.type===`range`||n.type===`number`){if(typeof t!=`number`||!isFinite(t))throw TypeError(`widget.settings.set: "`+n.name+`" is a number`);t=String(t)}else t=t==null?``:String(t);c.__setValue(n.name,t)},reset:function(e){c.__deleteValue(u(e,`reset`).name)}}),c.refresh=function(){c.__destroyed||(c.__listens(`onRefresh`)?c.__fire(`onRefresh`):c.__fire(`onLoad`))};var p={content:!0,"uwa-feeds":!0},m=function(e,t,n){var r=function(e){if(e=String(e),n&&Object.prototype.hasOwnProperty.call(p,e))throw TypeError(`"`+e+`" is the runtime's own key`);return e},i=function(e){var t=JSON.stringify(e);if(t===void 0)throw TypeError(`A stored value must be JSON (not undefined or a function)`);return JSON.parse(t)};return Object.freeze({get:function(t){return new Promise(function(n){var a=e(r(t));n(a===void 0?void 0:i(a))})},set:function(e,n){return new Promise(function(a){t(r(e),i(n)),a()})},delete:function(e){return new Promise(function(n){t(r(e),void 0),n()})}})},g=function(e,n,r,i){return t.files?t.files(e,n,r,i):Promise.reject(new DOMException(`widget.storage.files: not here`,`NotSupportedError`))};if(c.storage=Object.freeze({memory:m(function(e){return c.__recall(e)},function(e,t){c.__remember(e,t)},!0),local:m(function(e){return c.__getStored(e)},function(e,t){c.__setStored(e,t)},!1),files:Object.freeze({list:function(){return g(`list`)},get:function(e){return g(`get`,String(e))},add:function(e,t){return typeof Blob==`function`&&e instanceof Blob?g(`add`,void 0,e,t):Promise.reject(/* @__PURE__ */ TypeError(`widget.storage.files.add: a Blob is needed`))},delete:function(e){return g(`delete`,String(e)).then(function(){})}})}),c.__uwaApi||(delete c.callback,delete c.setCallback,delete c.callbacks,delete c.loadContent,delete c.keptContent,delete c.keepContent,delete c.getValue,delete c.getInt,delete c.getBool,delete c.setValue,delete c.deleteValue,delete c.remember,delete c.recall,delete c.getStored,delete c.setStored,[`addPreference`,`apiVersion`,`data`,`debugMode`,`dir`,`elements`,`endEdit`,`initPreferences`,`isNew`,`launch`,`periodicals`,`readOnly`,`saveValues`,`searchResultCount`,`setCSS`,`setDebugMode`,`setMetas`,`setPreferences`,`unreadCount`].forEach(function(e){delete c[e]})),B(c,e,function(){return s||=z(JSON.parse(JSON.stringify(a)))}),I&&typeof EventTarget==`function`){var _=new EventTarget;Object.setPrototypeOf(c,EventTarget.prototype);var x={},S=function(e,t,n){for(var r=x[e]||[],i=0;i<r.length;i++)if(r[i].fn===t&&r[i].capture===n)return r[i];return null},C=function(e,t){var n=x[e]||[],r=n.indexOf(t);r>=0&&n.splice(r,1),_.removeEventListener(e,t.wrapped,t.capture)};c.addEventListener=function(e,t,n){if(!(!t||typeof t!=`function`&&typeof t.handleEvent!=`function`)){e=String(e);var r=typeof n==`boolean`?n:!!(n&&n.capture),i=n&&typeof n==`object`?n.signal:null,a=!!(n&&typeof n==`object`&&n.once),o=!!(n&&typeof n==`object`&&n.passive);if(!(i&&i.aborted||S(e,t,r))){var s={fn:t,capture:r};s.wrapped=function(n){a&&C(e,s);try{typeof t==`function`?t.call(c,n):t.handleEvent(n)}catch(e){l(e)}},(x[e]||(x[e]=[])).push(s),_.addEventListener(e,s.wrapped,{capture:r,passive:o}),i&&i.addEventListener(`abort`,function(){C(e,s)},{once:!0})}}},c.removeEventListener=function(e,t,n){var r=typeof n==`boolean`?n:!!(n&&n.capture),i=S(String(e),t,r);i&&C(String(e),i)},c.dispatchEvent=function(e){return _.dispatchEvent(e)},c.__dispatch=function(e){return _.dispatchEvent(e)},c.__listening=function(e){return!!(e&&x[e]&&x[e].length)}}return t.watchAudio&&(c.__unwatchAudio=t.watchAudio(function(e){c.__setAudioState(e)})),t.watchFiles&&(c.__unwatchFiles=t.watchFiles(function(){c.__fire(`__filesChange`)})),t.watchVideo&&(c.__unwatchVideo=t.watchVideo(function(e){c.__setVideoState(e)})),t.watchFull&&(c.__unwatchFull=t.watchFull(function(e){c.__setFullSize(e)})),t.watchScreen&&(c.__unwatchScreen=t.watchScreen(function(e,t){c.__setFullScreen(e,t)})),t.watchRoom&&(c.__unwatchRoom=t.watchRoom(function(e,t){c.__setRoom(e,t)})),n.Feeds={},n.Data=v(t,c,n),n.Content=h,t.addWidget||delete c.addWidget,c}var H;function U(){H=window.UWA={}}function W(e){this.module=e.module||window.widget,this.limit=Math.max(1,Number(e.limit)||10),this.offset=Math.max(0,Number(e.offset)||0),this.total=e.dataArray?e.dataArray.length:Number(e.total)||0,this.onChange=e.onChange||null}W.prototype.go=function(e){this.offset=e,this.onChange&&this.onChange.call(this,e)},W.prototype.getContent=function(){var e=this,t=Math.floor(this.offset/this.limit),n=Math.max(1,Math.ceil(this.total/this.limit)),r=X(`div`,{class:`nv-pager`});function i(t,n,r){var i=X(`a`,{href:`#`,class:r});return q.setText.call(i,t),i.addEventListener(`click`,function(t){t.preventDefault(),e.go(n)}),i}t>0&&r.appendChild(i(`« Previous`,(t-1)*this.limit,`prev`));var a=X(`span`,{class:`status`});return q.setText.call(a,t+1+` / `+n),r.appendChild(a),t+1<n&&r.appendChild(i(`Next »`,(t+1)*this.limit,`next`)),r};function G(e,t){window.widget=e,K(e)}function K(e){window.addEventListener(`error`,function(t){if(!/ResizeObserver loop/.test(String(t.message||``))){if(!t.error&&!t.filename&&!t.lineno)return console.warn(`[UWA] an error from a script not the widget’s:`,t.message);e.__showError(t.error||t.message)}}),window.addEventListener(`unhandledrejection`,function(t){e.__showError(t.reason)})}var q={addContent:function(e){var t=e;if((typeof e==`string`||typeof e==`number`)&&(t=document.createElement(`div`),t.innerHTML=String(e)),Array.isArray(e)){for(var n=0;n<e.length;n++)q.addContent.call(this,e[n]);return this}return t&&this.appendChild(t),Y(t)},setContent:function(e){return typeof e==`string`||typeof e==`number`?this.innerHTML=String(e):(q.empty.call(this),e!=null&&q.addContent.call(this,e)),this},empty:function(){for(;this.firstChild;)this.removeChild(this.firstChild);return this}};function J(e){return!1}function Y(e){return typeof e==`string`&&(e=document.getElementById(e)),e||null}function X(e,t){var n=document.createElement(e);if(!t||typeof t!=`object`)return n;for(var r in t){var i=t[r];r===`styles`?q.setStyles.call(n,i):r===`attributes`?q.setAttributes.call(n,i):r===`id`?n.id=i:r===`class`||r===`className`?n.className=i:r===`events`?q.addEvents.call(n,i):n.setAttribute(r,i)}return n}function Z(e){var t=e.faces;if(t&&t.length){delete e.faces;for(var n=0;n<t.length;n++){var r=t[n];try{for(var i=atob(r.data),a=new Uint8Array(i.length),o=0;o<i.length;o++)a[o]=i.charCodeAt(o);var s=new FontFace(r.family,a.buffer,r.descriptors||{});document.fonts.add(s)}catch{}}}}function Q(){var n={},r={},i=0;function a(t){t.uwa=e.instance,parent.postMessage(t,`*`)}var o=!0,s=Object.getOwnPropertyDescriptor(Document.prototype,`hidden`),c=Object.getOwnPropertyDescriptor(Document.prototype,`visibilityState`);if(s&&s.get&&c&&c.get){var l=s.get,u=c.get;Object.defineProperty(document,"hidden",{configurable:!0,get:function(){return!o||l.call(document)}}),Object.defineProperty(document,"visibilityState",{configurable:!0,get:function(){return o?u.call(document):`hidden`}})}function d(e){e!==o&&(o=e,document.dispatchEvent(new Event(`visibilitychange`)))}var f=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable=""], [contenteditable="true"], audio[controls], video[controls]`;function p(e){if(!e.matches(f)||e.disabled||e.tabIndex<0||e.getAttribute(`type`)===`hidden`)return!1;var t=e.getBoundingClientRect();return t.width>0&&t.height>0&&getComputedStyle(e).visibility!==`hidden`}function m(){var e=function(e){for(var t=e.querySelectorAll(f),n=0;n<t.length;n++)if(p(t[n]))return t[n];return null},t=document.querySelector(`[data-autofocus], [autofocus]`);if(t){if(p(t))return t;var n=e(t);if(n)return n}return e(document.body)}var h=null;document.addEventListener(`focusin`,function(e){e.target&&e.target.nodeType===1&&e.target!==document.body&&(h=e.target)});var g=`input, textarea, select, [contenteditable=""], [contenteditable="true"], audio, video, [role="slider"], [role="spinbutton"], [role="listbox"], [role="combobox"], [role="menu"], [role="menubar"], [role="tablist"], [role="radiogroup"], [role="tree"], [role="grid"], [role="application"]`;function _(e,t){for(var n=t===`ArrowDown`,r=t===`ArrowUp`,i=t===`ArrowRight`,a=e;a&&a.nodeType===1;a=a.parentElement){var o=a===document.documentElement,s=getComputedStyle(a);if(r||n){if((o||/auto|scroll/.test(s.overflowY))&&a.scrollHeight-a.clientHeight>1&&(n?a.scrollTop+a.clientHeight<a.scrollHeight-1:a.scrollTop>0))return!0}else if((o||/auto|scroll/.test(s.overflowX))&&a.scrollWidth-a.clientWidth>1&&(i?a.scrollLeft+a.clientWidth<a.scrollWidth-1:a.scrollLeft>0))return!0}return!1}var v=!1,y=function(){v=!1};window.addEventListener(`pointerdown`,y,!0),window.addEventListener(`pointermove`,y,!0),window.addEventListener(`keydown`,function(e){if(!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.isComposing||t.__fullScreen)){var n=e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`ArrowLeft`||e.key===`ArrowRight`;if((n||e.key===`Escape`||e.key===`Tab`)&&(v||(v=!0,a({type:`keys`})),e.key!==`Tab`)){var r=e.target&&e.target.nodeType===1?e.target:document.body,i=n&&(r.closest(g)||_(r,e.key)),o=t.fullSize;setTimeout(function(){e.defaultPrevented||i||(n?a({type:`arrow`,key:e.key}):o||a({type:`escape`}))},0)}}});var b=function(e){return!!e.dataTransfer&&Array.prototype.indexOf.call(e.dataTransfer.types||[],`Files`)!==-1};window.addEventListener(`dragover`,function(e){!e.defaultPrevented&&b(e)&&(e.preventDefault(),e.dataTransfer.dropEffect=`none`)}),window.addEventListener(`drop`,function(e){!e.defaultPrevented&&b(e)&&e.preventDefault()}),window.addEventListener(`message`,function(i){if(i.source===parent){var o=i.data;if(o&&o.uwa===e.instance){if(o.type===`saveFileResult`){var s=r[o.reqId];if(!s)return;delete r[o.reqId],o.ok?s.resolve():s.reject(new DOMException(`saveFile: `+String(o.error),/^(NotAllowed|NotSupported|QuotaExceeded|Abort)Error$/.test(o.error)?o.error:`NotSupportedError`))}else if(o.type===`dashboardResponse`){var c=r[o.reqId];if(!c)return;delete r[o.reqId],o.ok?c.resolve(o.answer):c.reject(TypeError(o.error||`Failed to fetch`))}else if(o.type===`response`){var l=n[o.reqId];if(!l)return;delete n[o.reqId],o.ok?l.resolve(o.data):l.reject(Error(o.error))}else if(o.type===`key`){if(/^(Arrow(Up|Down|Left|Right)|Enter|Escape)$/.test(o.key)&&document.hasFocus()){var u=document.activeElement||document.body,f=u.dispatchEvent(new KeyboardEvent(o.down?`keydown`:`keyup`,{key:o.key,code:o.key,bubbles:!0,cancelable:!0,composed:!0}));o.down&&o.key===`Enter`&&f&&u.matches(`button, a[href], summary, [role="button"], input[type="button"], input[type="submit"]`)&&!u.disabled&&u.click()}}else if(o.type===`focusBack`){var g=document.activeElement;if(h&&document.hasFocus()&&(!g||g===document.body||g===document.documentElement)){var _=h.isConnected&&p(h)?h:m();_&&_.focus({focusVisible:!0})}}else if(o.type===`focus`){var v=m();v&&v.focus({focusVisible:!0})}else if(o.type===`tabShown`)d(o.shown!==!1);else if(o.type===`refresh`)t.__listens(`onRefresh`)?t.__fire(`onRefresh`):t.__fire(`onLoad`);else if(o.type===`valueRefused`)console.warn(`settings.set("`+o.name+`"): not saved by the host, `+o.why+`. The widget keeps it until it reloads.`);else if(o.type===`prefsSaved`)t.__applySettings(o.values||{});else if(o.type===`gripMove`)t.__grip&&typeof o.y==`number`&&t.__grip.move(o.y);else if(o.type===`gripEnd`)t.__grip&&t.__grip.end();else if(o.type===`resize`)t.__fire(`onResize`);else if(o.type===`audioResumeAfterLoad`)t.__resumeAudio();else if(o.type===`audioState`)t.__setAudioState(o.state);else if(o.type===`filesResult`){var y=r[o.reqId];if(!y)return;if(delete r[o.reqId],o.ok)y.resolve(o.value);else{var b=o.error||{},w=String(b.message||`widget.storage.files: refused`);y.reject(b.name===`TypeError`?TypeError(w):b.name===`RangeError`?RangeError(w):new DOMException(w,/^(NotFound|Network|NotSupported|QuotaExceeded)Error$/.test(b.name)?b.name:`UnknownError`))}}else if(o.type===`filesChanged`)t.__fire(`__filesChange`);else if(o.type===`videoState`)t.__setVideoState(o.state);else if(o.type===`fullSize`)t.__setFullSize(o.on);else if(o.type===`fullScreen`)t.__setFullScreen(o.on,o.whole);else if(o.type===`fullRoom`)t.__setRoom(o.px,o.from);else if(o.type===`measure`){var T=o.seq,E=!1,D=function(){E||(E=!0,a({type:`measured`,seq:T,height:document.documentElement.getBoundingClientRect().height,width:window.innerWidth}))};requestAnimationFrame(function(){requestAnimationFrame(D)}),setTimeout(D,100)}else if(o.type===`itemOpened`){if(typeof S==`function`)try{S(Number(o.index))}catch(e){t.__showError(e)}}else if(o.type===`readKeys`)t.__setReadKeys(o.keys);else if(o.type===`readAll`)t.__readAll(o.read!==!1);else if(o.type===`action`)t.__runAction(String(o.id),o.token);else if(o.type===`photoDelete`)t.__fire(`__photoDelete`,{id:String(o.id)});else if(o.type===`stored`&&typeof o.key==`string`)o.value===void 0?delete t.__stored[o.key]:t.__stored[o.key]=o.value,t.__dispatch(new CustomEvent(`storagechange`,{detail:{key:o.key}}));else if(o.type===`askActions`)t.__askActions();else if(o.type===`accent`)[`--accent`,`--accent-ink`,`--accent-glow`].forEach(function(e){var t=o.vars&&o.vars[e];typeof t==`string`&&/^#[\da-f]{3,8}$/i.test(t)&&document.documentElement.style.setProperty(e,t)});else if(o.type===`look`){var O=document.documentElement;O.classList.toggle(`uwa-neutral`,!!o.neutral),[`--module-color`,`--module-paper`,`--module-accent`].forEach(function(e){var t=o.vars&&o.vars[e];typeof t==`string`?O.style.setProperty(e,t):O.style.removeProperty(e)})}else if(/^audio(Stop|Resume|Volume|Next|Previous)$/.test(o.type)){var k={audioStop:x,audioResume:C.resume,audioVolume:C.setVolume,audioNext:C.next,audioPrevious:C.previous}[o.type];if(typeof k==`function`)try{k(Number(o.volume))}catch(e){t.__showError(e)}}}}});var x=null,S=null,C={},w=0;function T(){var e=Math.round(document.documentElement.getBoundingClientRect().height*100)/100;e!==w&&(w=e,a({type:`height`,height:e}))}var E=0;function D(){E||=setTimeout(function(){E=0,T()},250)}return window.addEventListener(`load`,T),window.addEventListener(`resize`,D),document.addEventListener(`load`,D,!0),document.addEventListener(`visibilitychange`,function(){document.hidden||T()}),document.fonts&&document.fonts.addEventListener&&document.fonts.addEventListener(`loadingdone`,D),document.addEventListener(`DOMContentLoaded`,function(){new ResizeObserver(T).observe(document.documentElement),new MutationObserver(D).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),typeof IntersectionObserver==`function`&&new IntersectionObserver(function(e){e.some(function(e){return e.isIntersecting})&&T()}).observe(document.documentElement),T()}),{bodyChanged:function(){setTimeout(T,0)},inFlight:function(){return Object.keys(n).length+Object.keys(r).length},request:function(e,t){return new Promise(function(r,o){var s=++i;n[s]={resolve:r,reject:o},a({type:`request`,reqId:s,kind:e,url:t})})},setTitle:function(e){a({type:`setTitle`,title:e})},setTitleLinks:function(e){a({type:`setTitleLinks`,parts:e})},setValue:function(e,t){a({type:`setValue`,name:e,value:t})},deleteValue:function(e){a({type:`deleteValue`,name:e})},addWidget:e.noAdd?void 0:function(e){var t=e||{};return a({type:`addWidget`,spec:{file:String(t.file||``),title:t.title==null?void 0:String(t.title),values:t.values&&typeof t.values==`object`?JSON.parse(JSON.stringify(t.values)):void 0}}),!0},playVideo:function(e){var t=e||{};a({type:`playVideo`,video:{provider:String(t.provider||``),id:String(t.id||``),title:t.title==null?void 0:String(t.title),list:t.list==null?void 0:String(t.list),lang:t.lang==null?void 0:String(t.lang)}})},openURL:function(e){a({type:`openURL`,url:e})},openPreferences:function(){a({type:`openPreferences`})},gripDrag:function(e){a({type:`gripDrag`,on:!!e})},sendTo:function(){a({type:`sendTo`})},share:function(e){a({type:`share`,text:String(e&&e.text||``).slice(0,2e3),url:e&&e.url?String(e.url):``})},openItems:function(e,t,n){n||={},S=typeof n.onOpen==`function`?n.onOpen:null;var r=(Array.isArray(e)?e:[]).map(function(e){return e||={},{url:String(e.url||``),link:typeof e.link==`string`?e.link:void 0,title:String(e.title||``),content:typeof e.content==`string`?e.content:void 0,prefer:typeof e.prefer==`string`?e.prefer:void 0,truncated:e.truncated===!0||void 0,date:typeof e.date==`string`?e.date:void 0,summary:typeof e.summary==`string`?e.summary:void 0,read:e.read===!0||void 0,author:typeof e.author==`string`?e.author:void 0,excerpt:e.excerpt===!0||void 0,image:typeof e.image==`string`?e.image:void 0}}),i=Array.isArray(n.frameable)?n.frameable.map(String):void 0;a({type:`openItems`,items:r,index:Number(t),options:{prefer:n.prefer?String(n.prefer):void 0,frameable:i,onOpen:!!S}})},audioStarted:function(e,t){x=e,C=t||{},a({type:`audioStarted`,resume:!!C.resume,volume:!!C.setVolume,next:!!C.next,previous:!!C.previous,elsewhere:!!C.elsewhere})},audioStopped:function(){a({type:`audioStopped`})},playAudio:function(e){return a({type:`playAudio`,spec:e}),!0},pauseAudio:function(){a({type:`pauseAudio`})},seekAudio:function(e){a({type:`seekAudio`,seconds:e})},setChromeColor:function(e,t){a({type:`setChromeColor`,color:e,background:t})},openPhoto:function(e){a({type:`openPhoto`,spec:e&&{src:e.src,alt:e.alt,title:e.title,preview:e.preview,zoom:e.zoom,width:e.width,height:e.height,credit:e.credit,deletable:e.deletable,id:e.id,file:e.file,files:Array.isArray(e.files)?e.files.slice(0,5e3):void 0}})},openFull:function(){a({type:`openFull`})},closeFull:function(){a({type:`closeFull`})},askRoom:function(){a({type:`askRoom`})},fitted:function(){a({type:`fitted`,height:document.documentElement.getBoundingClientRect().height})},setScreen:function(e){a({type:`setScreen`,on:e})},setIcon:function(e){a({type:`setIcon`,url:e})},audioInfo:function(e){a({type:`audioInfo`,info:e})},setRead:function(e,t){a({type:`setRead`,keys:e,read:t})},remember:function(e,t){a({type:`remember`,key:e,value:t})},setStored:function(e,t){a({type:`setStored`,key:e,value:t})},dashboardFetch:function(e){return new Promise(function(t,n){var o=++i;r[o]={resolve:t,reject:n},a({type:`dashboardFetch`,reqId:o,url:e.url,method:e.method,body:e.body,contentType:e.contentType})})},openPopup:function(e,t,n){a({type:`openPopup`,url:e,name:t,features:n})},prepareGoogle:function(){a({type:`prepareGoogle`})},connectGoogle:function(e){return new Promise(function(t,n){var o=++i;r[o]={resolve:t,reject:n},a({type:`connectGoogle`,reqId:o,scope:e&&e.scope,account:e&&e.account})})},autoRefresh:function(e){a({type:`autoRefresh`,minutes:e})},loading:function(e){a({type:`loading`,on:!!e})},setUnreadCount:function(e){a({type:`setUnreadCount`,count:e})},saveFile:function(e){return new Promise(function(t,n){var o=++i;r[o]={resolve:t,reject:n},a({type:`saveFile`,reqId:o,token:e.token,name:e.name,mime:e.type,data:e.data})})},setActionStates:function(e){a({type:`setActionStates`,states:e})},files:function(e,t,n,o){return new Promise(function(s,c){var l=++i;r[l]={resolve:s,reject:c};try{a({type:`files`,reqId:l,op:e,id:t,file:n,meta:o})}catch{delete r[l],c(/* @__PURE__ */ TypeError(`widget.storage.files.add: the meta must be a JSON value`))}})},setMaxValue:function(e,t){a({type:`setMaxValue`,name:e,max:t})}}}function $(t){var n=window.fetch?window.fetch.bind(window):null,r=window.open,i=e.dashboard;function a(e){if(!i)return null;try{var t=new URL(String(e),document.baseURI);return t.origin===i?t:null}catch{return null}}window.fetch=function(e,r){var i=a(e&&typeof e==`object`&&`url`in e?e.url:e);if(!i)return n(e,r);r||={};var o=new Headers(r.headers||e&&e.headers||{}),s=r.body;s!=null&&typeof s!=`string`&&(s=s instanceof URLSearchParams?s.toString():String(s));var c=o.get(`Content-Type`)||(r.body instanceof URLSearchParams?`application/x-www-form-urlencoded`:s==null?``:`text/plain`);return t.dashboardFetch({url:i.href,method:r.method||`GET`,body:s,contentType:c}).then(function(e){var t=Number(e.status)||500;return new Response(t===204||t===205||t===304?null:e.body,{status:t<200||t>599?500:t,headers:{"Content-Type":e.contentType||`text/plain`}})})},window.open=function(e,n,i){var o=a(e);return o?(t.openPopup(o.href,n?String(n):``,i?String(i):``),{closed:!1,close:function(){},focus:function(){}}):r.apply(window,arguments)}}window.__startside||window.UWA&&window.UWA.__createInline||ee();function ee(){if(I&&!window.WidgetEvent&&(window.WidgetEvent=I),U(),e){if(Z(e),!window.__UWA_HOST__)var r=R(Q(),e.instance);r&&$(r),n(V(e,window.__UWA_HOST__||r,H)),Object.defineProperty(window,"__startside",{value:Object.freeze({attachBody:function(){t.__attach(document.getElementById(`moduleContent`))},start:function(){t.__launch()}})}),delete window.UWA,G(t,!1)}}})()})()})();
|
package/swa/1.0/host.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* SWA 1.0, the host's side of a widget file (host.md) */
|
|
2
|
+
const e=e=>e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`),t=e=>`<script>${e.replace(/<\/(script)/gi,`<\\/$1`)}<\/script>`;function n(e){let t=[],n=e.replace(/@charset\s+[^;]+;/gi,``).replace(/@import\s+([^;]+?)\s*;/gi,(e,n)=>(t.push(`@import ${n} layer(widget);`),``));return`${t.join(`
|
|
3
|
+
`)}\n@layer widget{${n}\n}`}const r=e=>/(^|[,;\s])viewport-fit\s*=\s*cover\b/i.test(e.viewport??``);function i(e){return{title:e.title,preferences:e.preferences.map(e=>e.type===`password`?{...e,defaultValue:``}:e),actions:e.actions,metas:e.metas,url:e.url,format:e.format??`uwa`}}function a(i,a,o){let s=[...o.classes??[],o.mode===`dark`?`uwa-dark`:``,r(i.metas)?`uwa-cover`:``].filter(Boolean);return`<!doctype html>
|
|
4
|
+
<html lang="${e(o.lang)}" data-css-layers data-color-scheme="${o.mode===`dark`?`dark`:`light`}"${s.length?` class="${s.join(` `)}"`:``}>
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<meta http-equiv="Content-Security-Policy" content="connect-src https:">
|
|
8
|
+
<base href="${e(i.url)}" target="_blank">
|
|
9
|
+
<style>@layer host, widget;\n@layer host{${o.hostCss}}</style>
|
|
10
|
+
${i.stylesheets.map(t=>`<style>@import url("${e(t)}") layer(widget);</style>`).join(`
|
|
11
|
+
`)}
|
|
12
|
+
${i.styles.map(e=>`<style>${n(e).replace(/<\/(style)/gi,`<\\/$1`)}</style>`).join(`
|
|
13
|
+
`)}
|
|
14
|
+
<style>html{-webkit-text-size-adjust:100%;text-size-adjust:100%}</style>
|
|
15
|
+
${o.look??``}
|
|
16
|
+
${t(`window.__UWA_CONFIG__ = ${JSON.stringify(a).replace(/</g,`\\u003c`)};`)}
|
|
17
|
+
${o.runtime}
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="moduleContent" class="moduleContent">${i.body}</div>
|
|
21
|
+
${t(`__startside.attachBody();`)}
|
|
22
|
+
${[...i.scripts.filter(e=>`src`in e),...i.scripts.filter(e=>!(`src`in e))].map(e=>`src`in e?o.script(e.src):t(e.code)).join(`
|
|
23
|
+
`)}
|
|
24
|
+
${t(`__startside.start();`)}
|
|
25
|
+
</body>
|
|
26
|
+
</html>`}const o={".cook":[`text/plain`],".txt":[`text/plain`],".md":[`text/markdown`,`text/plain`],".csv":[`text/csv`,`text/plain`],".json":[`application/json`,`text/plain`],".ics":[`text/calendar`,`text/plain`],".opml":[`text/x-opml`,`application/xml`,`text/xml`,`text/plain`],".gpx":[`application/gpx+xml`,`application/xml`,`text/xml`,`text/plain`]};function s(e){if(typeof e!=`string`)return[];let t=[];for(let n of e.trim().split(/\s+/)){let e=n.toLowerCase();/^\.[a-z0-9]{1,10}$/.test(e)&&Object.hasOwn(o,e)&&!t.includes(e)&&t.push(e)}return t}const c=/^[A-Za-z0-9_.-]{1,40}$/,l={reset:`↺`,refresh:`↻`,undo:`↶`,redo:`↷`,copy:`⧉`,download:`⇩`,upload:`⇧`,share:`↗`,add:`+`,remove:`×`,clear:`⌫`,edit:`✎`,search:`⌕`,print:`⎙`,play:`▶`,pause:`⏸`,stop:`■`,check:`✓`,star:`★`,info:`ⓘ`,settings:`⚙`};function u(e){let t=Intl.Segmenter;return t?[...new t().segment(e)].length===1:[...e].length<=2}const d=/\p{Extended_Pictographic}/u;function f(e){if(typeof e!=`string`)return``;let t=e.trim();return!t||t.length>16?``:Object.hasOwn(l,t.toLowerCase())?l[t.toLowerCase()]:d.test(t)&&u(t)?t:``}const p=e=>typeof e==`string`?e.replace(/\s+/g,` `).trim():``,m=e=>{let t=p(e);return t&&t.length<=40?t:null};function h(e){let t=[];for(let n of Array.isArray(e)?e:[]){if(t.length>=5)break;if(!n||typeof n!=`object`)continue;let{id:e,label:r,disabled:i,hidden:a,icon:o,confirm:l,save:u,album:d}=n,h=m(r),g=p(l);typeof e!=`string`||!c.test(e)||!h||g.length>200||t.some(t=>t.id===e)||t.push({id:e,label:h,disabled:i===!0,hidden:a===!0,icon:f(o),confirm:g,save:s(u),album:d===!0})}return t}const g=e=>(e??``).toLowerCase().split(/[\s,]+/).filter(e=>/^\.[a-z0-9]{1,16}$/.test(e)),_=/\/(js\/UWA\/|js\/c\/UWA_|themes\/uwa\/|api\/0\.[23]\/style\.css|swa\/\d+\.\d+\/runtime\.js|uwa\/\d+\.\d+\/runtime\.js(\?|$))/i,v=/^(?:[a-z]+:\/\/[^/]+)?(?:\/[^?#]*)?\/rwa\/(\d+(?:\.\d+)?)\/(runtime\.js|style\.css)$/i,y=(e,t)=>typeof location<`u`?new URL(`/rwa/${e}/${t}`,location.origin).href:null,b=(e,t)=>{let n=v.exec(e);if(n)return t(n[1]===`1`?`1.0`:n[1],n[2]===`runtime.js`?`frame.js`:n[2])},x=(e,t)=>Array.from(e.getElementsByTagName(`*`)).filter(e=>e.localName.toLowerCase().replace(/^widget:/,``)===t);function S(e,t){let n=new DOMParser;if(/\.html?([?#]|$)/i.test(t))return n.parseFromString(e,`text/html`);let r=n.parseFromString(e,`application/xhtml+xml`);return r.getElementsByTagName(`parsererror`).length?n.parseFromString(e,`text/html`):r}function C(e,t,n=y){let r=S(e,t),i=e=>{try{return new URL(e,t).href}catch{return e}},a={};for(let e of Array.from(r.getElementsByTagName(`meta`))){let t=e.getAttribute(`name`);t&&(a[t]=e.getAttribute(`content`)??``)}let o=Array.from(r.getElementsByTagName(`link`)),s=o.find(e=>/(^|\s)icon(\s|$)/i.test(e.getAttribute(`rel`)??``)),c=o.filter(e=>/stylesheet/i.test(e.getAttribute(`rel`)??``)&&e.getAttribute(`href`)).flatMap(e=>{let t=b(e.getAttribute(`href`),n);return t===void 0?[i(e.getAttribute(`href`))]:t?[t]:[]}).filter(e=>!_.test(e)),l=x(r,`preference`).map(e=>{let t=t=>e.getAttribute(t)==null?void 0:Number(e.getAttribute(t));return{name:e.getAttribute(`name`)??``,type:(e.getAttribute(`type`)??`text`).toLowerCase(),label:e.getAttribute(`label`)??e.getAttribute(`name`)??``,defaultValue:e.getAttribute(`defaultValue`)??e.getAttribute(`defaultvalue`)??``,options:O(e,`option`).map(e=>{let t=(e.getAttribute(`feed`)??e.getAttribute(`data-feed`))?.trim();return{value:e.getAttribute(`value`)??``,label:e.getAttribute(`label`)??e.getAttribute(`value`)??``,...t?{feed:t}:{}}}),min:t(`min`),max:t(`max`),step:t(`step`),...e.getAttribute(`shareable`)===`true`?{shareable:!0}:{},...e.getAttribute(`send`)===`true`?{sendable:!0}:{},...e.getAttribute(`hint`)?.trim()?{hint:e.getAttribute(`hint`).trim()}:{},...e.getAttribute(`commit`)===`ok`?{commit:`ok`}:{},...e.getAttribute(`when`)?.trim()?{when:e.getAttribute(`when`).trim()}:{}}}).concat(E(r)).filter(e=>e.name&&e.name!==`xwaFiles`),u=Array.from(r.getElementsByTagName(`script`)).map(e=>e.getAttribute(`src`)??``),d=e=>!e.getAttribute(`src`)&&/^swa\/\d+\.\d+$/.test(e.getAttribute(`data-runtime`)??``),f=Array.from(r.getElementsByTagName(`script`)).some(d),p=t.split(/[?#]/)[0],m=u.some(e=>v.test(e))||/\.rwa\.(x?html)$/i.test(p)?`rwa`:u.some(e=>/\/swa\/\d+\.\d+\/runtime\.js(\?|$)/i.test(e))||f||/\.swa\.html$/i.test(p)?`swa`:`uwa`,h=[],g=e=>/^(|text\/javascript|application\/javascript|module)$/i.test((e.getAttribute(`type`)??``).trim());for(let e of Array.from(r.getElementsByTagName(`script`)).filter(g)){let t=e.getAttribute(`src`);if(t){let e=b(t,n);(e===void 0?!_.test(t):e)&&h.push({src:e??i(t)})}else e.textContent?.trim()&&!d(e)&&h.push({code:e.textContent})}let C=t.split(/[?#]/)[0].split(`/`).pop()??``,D=0;for(let t of Array.from(r.getElementsByTagName(`script`)).filter(e=>!g(e))){t.setAttribute(`data-file`,C);let n=t.textContent??``,r=n?e.indexOf(n,D):-1;r<0||(t.setAttribute(`data-line`,String(e.slice(0,r).split(`
|
|
27
|
+
`).length)),D=r+n.length)}let k=Array.from(r.getElementsByTagName(`style`)).map(e=>e.textContent??``),A=T(r),j=w(r),M=r.getElementsByTagName(`body`)[0];if(M?.querySelectorAll(`script`).forEach(e=>g(e)&&e.remove()),M){for(let e of Array.from(M.querySelectorAll(`style, link, meta, title`)))e.remove();for(let e of O(M,`preferences`))e.remove();M.querySelector(`form#preferences`)?.remove(),M.querySelector(`menu#actions`)?.remove();for(let e of M.querySelectorAll(`[autofocus]`))e.removeAttribute(`autofocus`),e.setAttribute(`data-autofocus`,``)}return{url:t,format:m,title:r.getElementsByTagName(`title`)[0]?.textContent?.trim()||`UWA widget`,icon:s?.getAttribute(`href`)?i(s.getAttribute(`href`)):null,metas:a,preferences:l,actions:j,styles:k,stylesheets:c,scripts:h,body:M?.innerHTML??``,...A?{formOk:A}:{}}}function w(e){let t=e.getElementById(`actions`);return!t||t.localName!==`menu`?[]:h(Array.from(t.children).filter(e=>e.localName===`button`).map(e=>({id:e.getAttribute(`name`)??``,label:e.textContent??``,icon:e.getAttribute(`data-icon`)??``,confirm:e.getAttribute(`data-confirm`)??``,disabled:e.hasAttribute(`disabled`),hidden:e.hasAttribute(`hidden`),save:e.getAttribute(`data-save`)??``,album:e.hasAttribute(`data-album`)})))}function T(e){let t=e.getElementById(`preferences`);if(!t||t.localName!==`form`)return null;let n=t.querySelector(`button:not([type]), button[type="submit"], input[type="submit"]`);return n?((n.localName===`input`?n.getAttribute(`value`):n.textContent)??``).replace(/\s+/g,` `).trim()||`OK`:null}function E(e){let t=e.getElementById(`preferences`);if(!t||t.localName!==`form`)return[];let n=e=>{if(!e)return``;let t=e.cloneNode(!0);return t.querySelectorAll(`select, input, textarea`).forEach(e=>e.remove()),(t.textContent??``).replace(/\s+/g,` `).trim().replace(/\s*[::]$/,``)},r=e=>n(e.closest(`label`))||(e.id?n(t.querySelector(`label[for="${CSS.escape(e.id)}"]`)):``)||e.getAttribute(`aria-label`)||e.getAttribute(`name`)||``,i=(e,t)=>e.getAttribute(t)==null?void 0:Number(e.getAttribute(t)),a=[];for(let e of Array.from(t.querySelectorAll(`select[name], input[name]:not([type=submit i], [type=button i], [type=reset i], [type=image i]), textarea[name]`))){let t=e.getAttribute(`name`)??``,n=e.getAttribute(`data-hint`)?.trim(),o={name:t,label:r(e),options:[],...n?{hint:n}:{},...e.getAttribute(`data-commit`)===`ok`?{commit:`ok`}:{},...e.getAttribute(`data-when`)?.trim()?{when:e.getAttribute(`data-when`).trim()}:{}};if(e.localName===`select`){let t=Array.from(e.querySelectorAll(`option`)).map(e=>({value:e.getAttribute(`value`)??e.textContent?.trim()??``,label:(e.textContent??``).trim(),...e.getAttribute(`data-feed`)?.trim()?{feed:e.getAttribute(`data-feed`).trim()}:{}})),n=e.querySelector(`option[selected]`),r=t[0]?.value??``;a.push({...o,type:`list`,options:t,defaultValue:n?n.getAttribute(`value`)??n.textContent?.trim()??``:r})}else if(e.localName===`textarea`)a.push({...o,type:`text`,defaultValue:e.textContent??``});else{let t=(e.getAttribute(`type`)??`text`).toLowerCase();if(t===`url`)a.push({...o,type:`url`,defaultValue:e.getAttribute(`value`)??``});else if(t===`number`)a.push({...o,type:`number`,defaultValue:e.getAttribute(`value`)??``,min:i(e,`min`),max:i(e,`max`),step:i(e,`step`)});else if(t===`checkbox`)a.push({...o,type:`boolean`,defaultValue:e.hasAttribute(`checked`)?`true`:`false`});else if(t===`range`)a.push({...o,type:`range`,defaultValue:e.getAttribute(`value`)??``,min:i(e,`min`),max:i(e,`max`),step:i(e,`step`)});else if(t===`hidden`)a.push({...o,type:`hidden`,defaultValue:e.getAttribute(`value`)??``,...e.hasAttribute(`data-share`)?{shareable:!0}:{},...e.hasAttribute(`data-send`)?{sendable:!0}:{},...e.hasAttribute(`data-share`)&&e.getAttribute(`data-load`)?.trim()?{load:e.getAttribute(`data-load`).trim().slice(0,40)}:{},...e.hasAttribute(`data-share`)&&Number(e.getAttribute(`maxlength`))>0?{maxLength:Math.min(Math.floor(Number(e.getAttribute(`maxlength`))),16e3)}:{},...g(e.getAttribute(`data-file`)).length?{file:g(e.getAttribute(`data-file`))}:{}});else{let n=t===`password`&&e.hasAttribute(`data-key-for`),r=n?D(e.getAttribute(`data-key-for`)):null;a.push({...o,type:n&&!r?`hidden`:t===`password`?`password`:`text`,defaultValue:n?``:e.getAttribute(`value`)??``,...r?{keyFor:r}:{}})}}}return a}function D(e){let t=typeof e==`string`?e.trim():``;if(!/^https:\/\/[^\s/?#@\\]+\/?$/i.test(t))return null;try{let e=new URL(t);return e.protocol===`https:`&&!e.username&&!e.password&&!e.search&&!e.hash&&e.pathname===`/`?e.origin:null}catch{return null}}function O(e,t){return Array.from(e.getElementsByTagName(`*`)).filter(e=>e.localName.toLowerCase().replace(/^widget:/,``)===t)}function k(e,t){let n={};for(let r of e.preferences)n[r.name]=r.name in t?String(t[r.name]):r.defaultValue;for(let[e,r]of Object.entries(t))e in n||(n[e]=String(r));return n}function A(e,t){if(!e.when)return!0;let n=/^\s*([\w-]+)\s*(!?=)\s*(.*?)\s*$/.exec(e.when);if(!n)return!0;let r=n[3].split(`|`).map(e=>e.trim()).includes(t[n[1]]??``);return n[2]===`=`?r:!r}function j(e,t,n){let r=C(e,t,()=>null);if(!n.includes(r.format??`uwa`))throw Error(`Not ${n.map(e=>`an ${e.toUpperCase()}`).join(` or `)} widget file`);return r}const M=(t,n)=>`<script src="${e(t)}"${n?` crossorigin`:``}><\/script>`,N=e=>{try{return new URL(e).origin}catch{return null}};function P(e,n,r){let o=r.mode===`dark`?`dark`:`light`,s=Object.entries(r.vars??{}).map(([e,t])=>`${e}:${t}`).join(`;`);return a(e,{...n,...i(e)},{lang:n.lang??`en`,mode:o,hostCss:`:root{${s?`${s};`:``}color-scheme:${o}}\n${r.css??``}`,runtime:`src`in r.runtime?M(r.runtime.src,!0):t(r.runtime.code),script:e=>M(e,!!r.origin&&N(e)===r.origin)})}const F=(e,t,n)=>e.source===t&&e.data!=null&&typeof e.data==`object`&&e.data.uwa===n,I=(e,t)=>j(e,t,[`swa`]);export{F as accepts,P as buildSrcdoc,I as parseWidget,A as prefShown,k as prefValues};
|