@uvalib/web-components 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +133 -12
  3. package/dist/base/states.d.ts +12 -0
  4. package/dist/base/states.js +33 -0
  5. package/dist/base/states.js.map +1 -0
  6. package/dist/base.css +15 -5
  7. package/dist/components/bento-box/BentoBox.js +1 -0
  8. package/dist/components/bento-box/BentoBox.js.map +1 -1
  9. package/dist/components/events-section/EventsSection.js +1 -0
  10. package/dist/components/events-section/EventsSection.js.map +1 -1
  11. package/dist/components/library-hours/hours-data.js +1 -1
  12. package/dist/components/library-hours/hours-data.js.map +1 -1
  13. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js +1 -0
  14. package/dist/components/library-weekly-hours/LibraryWeeklyHours.js.map +1 -1
  15. package/dist/components/uvalib-card/UvalibCard.js +6 -0
  16. package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
  17. package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +27 -0
  18. package/dist/components/uvalib-combobox/UvalibCombobox.js +85 -1
  19. package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -1
  20. package/dist/components/uvalib-contents/UvalibContents.js +5 -0
  21. package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
  22. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +6 -0
  23. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +10 -0
  24. package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -1
  25. package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +1 -0
  26. package/dist/components/uvalib-image-regions/UvalibImageRegions.js +4 -1
  27. package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -1
  28. package/dist/components/uvalib-image-regions/regions.d.ts +6 -2
  29. package/dist/components/uvalib-image-regions/regions.js +6 -3
  30. package/dist/components/uvalib-image-regions/regions.js.map +1 -1
  31. package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +100 -7
  32. package/dist/components/uvalib-lightbox/UvalibLightbox.js +310 -83
  33. package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
  34. package/dist/components/uvalib-lightbox/compare.d.ts +48 -8
  35. package/dist/components/uvalib-lightbox/compare.js +226 -22
  36. package/dist/components/uvalib-lightbox/compare.js.map +1 -1
  37. package/dist/components/uvalib-map/UvalibMap.js +2 -2
  38. package/dist/components/uvalib-map/UvalibMap.js.map +1 -1
  39. package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -0
  40. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  41. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +3 -1
  42. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  43. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +3 -3
  44. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +16 -8
  45. package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
  46. package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +4 -1
  47. package/dist/components/uvalib-tag-list/UvalibTagList.js +9 -2
  48. package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -1
  49. package/dist/custom-elements.json +596 -19
  50. package/dist/styles/message.js +4 -0
  51. package/dist/styles/message.js.map +1 -1
  52. package/dist/styles/result-list.js +25 -4
  53. package/dist/styles/result-list.js.map +1 -1
  54. package/dist/styles/results.js +17 -2
  55. package/dist/styles/results.js.map +1 -1
  56. package/dist-cdn/base.css +15 -5
  57. package/dist-cdn/bento-box.js +1 -0
  58. package/dist-cdn/bento-box.js.map +1 -1
  59. package/dist-cdn/chunks/{compare-D4VdaIJN.js → compare-C0nhByn7.js} +185 -56
  60. package/dist-cdn/chunks/compare-C0nhByn7.js.map +1 -0
  61. package/dist-cdn/chunks/{hours-data-Bw6vkIw7.js → hours-data-gMu5uT7H.js} +2 -2
  62. package/dist-cdn/chunks/hours-data-gMu5uT7H.js.map +1 -0
  63. package/dist-cdn/chunks/{library-weekly-hours-CrV3TlP5.js → library-weekly-hours-BJgxAyah.js} +3 -2
  64. package/dist-cdn/chunks/library-weekly-hours-BJgxAyah.js.map +1 -0
  65. package/dist-cdn/chunks/{regions-B8ExwUGP.js → regions-B-rOwa-v.js} +15 -15
  66. package/dist-cdn/chunks/regions-B-rOwa-v.js.map +1 -0
  67. package/dist-cdn/chunks/states-DGXGzcte.js +17 -0
  68. package/dist-cdn/chunks/states-DGXGzcte.js.map +1 -0
  69. package/dist-cdn/custom-elements.json +596 -19
  70. package/dist-cdn/events-section.js +1 -0
  71. package/dist-cdn/events-section.js.map +1 -1
  72. package/dist-cdn/library-hours-setup.js +1 -1
  73. package/dist-cdn/library-weekly-hours.js +1 -1
  74. package/dist-cdn/manifest.json +1 -1
  75. package/dist-cdn/site-hours-section.js +1 -1
  76. package/dist-cdn/skills/uvalib-web-components/SKILL.md +8 -6
  77. package/dist-cdn/skills/uvalib-web-components/reference/components.md +37 -6
  78. package/dist-cdn/uvalib-card.js +6 -0
  79. package/dist-cdn/uvalib-card.js.map +1 -1
  80. package/dist-cdn/uvalib-combobox.js +107 -68
  81. package/dist-cdn/uvalib-combobox.js.map +1 -1
  82. package/dist-cdn/uvalib-contents.js +5 -0
  83. package/dist-cdn/uvalib-contents.js.map +1 -1
  84. package/dist-cdn/uvalib-filter-drawer.js +27 -25
  85. package/dist-cdn/uvalib-filter-drawer.js.map +1 -1
  86. package/dist-cdn/uvalib-image-regions.js +4 -2
  87. package/dist-cdn/uvalib-image-regions.js.map +1 -1
  88. package/dist-cdn/uvalib-lightbox.js +230 -129
  89. package/dist-cdn/uvalib-lightbox.js.map +1 -1
  90. package/dist-cdn/uvalib-map.js +2 -2
  91. package/dist-cdn/uvalib-map.js.map +1 -1
  92. package/dist-cdn/uvalib-metadata.js +3 -0
  93. package/dist-cdn/uvalib-metadata.js.map +1 -1
  94. package/dist-cdn/uvalib-pagefind-search.js +2 -1
  95. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  96. package/dist-cdn/uvalib-photo-grid.js +4 -5
  97. package/dist-cdn/uvalib-photo-grid.js.map +1 -1
  98. package/dist-cdn/uvalib-tag-list.js +21 -16
  99. package/dist-cdn/uvalib-tag-list.js.map +1 -1
  100. package/package.json +1 -1
  101. package/skills/uvalib-web-components/SKILL.md +8 -6
  102. package/skills/uvalib-web-components/reference/components.md +37 -6
  103. package/dist-cdn/chunks/compare-D4VdaIJN.js.map +0 -1
  104. package/dist-cdn/chunks/hours-data-Bw6vkIw7.js.map +0 -1
  105. package/dist-cdn/chunks/library-weekly-hours-CrV3TlP5.js.map +0 -1
  106. package/dist-cdn/chunks/regions-B8ExwUGP.js.map +0 -1
@@ -1,15 +1,42 @@
1
1
  import { l as e, o as t, p as n, r } from "./UvalibElement-pGONDAwB.js";
2
2
  import { a as i } from "./analytics-DTTihuBD.js";
3
+ import { n as a } from "./regions-B-rOwa-v.js";
3
4
  // src/components/uvalib-lightbox/compare.ts
4
- var a = [
5
+ var o = [
5
6
  "switch",
6
7
  "wipe",
7
8
  "fade"
8
- ], o = {
9
+ ], s = {
9
10
  switch: "Switch",
10
11
  wipe: "Reveal",
11
12
  fade: "Fade"
12
- }, s = { settle: 400 }, c = (e) => typeof e == "string" ? e.replace(/\s+/g, " ").trim() : "", l = (e) => Math.min(100, Math.max(0, Math.round(e))), u = (e) => `
13
+ }, c = { settle: 400 }, l = 4096;
14
+ function u(e) {
15
+ if (!e.some((e) => e.frame)) return null;
16
+ let t = e.map(({ frame: e }) => e ? {
17
+ x: -e.x / e.w,
18
+ y: -e.y / e.h,
19
+ w: 100 / e.w,
20
+ h: 100 / e.h
21
+ } : {
22
+ x: 0,
23
+ y: 0,
24
+ w: 1,
25
+ h: 1
26
+ }), n = Math.min(...t.map((e) => e.x)), r = Math.min(...t.map((e) => e.y)), i = Math.max(...t.map((e) => e.x + e.w)) - n, a = Math.max(...t.map((e) => e.y + e.h)) - r;
27
+ return {
28
+ uw: i,
29
+ uh: a,
30
+ boxes: t.map((e) => ({
31
+ x: (e.x - n) / i * 100,
32
+ y: (e.y - r) / a * 100,
33
+ w: e.w / i * 100,
34
+ h: e.h / a * 100
35
+ })),
36
+ covers: e.map(({ frame: e }) => !e || e.x >= -.001 && e.y >= -.001 && e.x + e.w <= 100.001 && e.y + e.h <= 100.001)
37
+ };
38
+ }
39
+ var d = (e) => Math.round(e * 1e4) / 1e4, f = (e) => `--uvalib-frame-x: ${d(e.x)}; --uvalib-frame-y: ${d(e.y)}; --uvalib-frame-w: ${d(e.w)}; --uvalib-frame-h: ${d(e.h)}`, p = (e) => typeof e == "string" ? e.replace(/\s+/g, " ").trim() : "", m = (e) => Math.min(100, Math.max(0, Math.round(e))), h = (e) => `
13
40
  ${e} .stack { isolation: isolate; }
14
41
  ${e} .stack > img.top {
15
42
  position: absolute; inset: 0; width: 100%; height: 100%;
@@ -21,6 +48,32 @@ var a = [
21
48
  ${e} .compare-wipe:dir(rtl) > img.top.on { clip-path: inset(0 0 0 calc(100% - var(--uvalib-compare, 50%))); }
22
49
  ${e} .compare-wipe { touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: col-resize; }
23
50
  ${e} .compare-wipe img { -webkit-user-drag: none; }
51
+ ${e} .stack.framed > img {
52
+ position: absolute; inset: auto;
53
+ left: calc(var(--uvalib-frame-x) * 1%); top: calc(var(--uvalib-frame-y) * 1%);
54
+ width: calc(var(--uvalib-frame-w) * 1%); height: calc(var(--uvalib-frame-h) * 1%);
55
+ max-width: none; max-height: none; margin: 0;
56
+ }
57
+ ${e} .stack.framed > canvas.frame-box {
58
+ display: block; width: auto; height: auto; max-width: 100%; max-height: 70dvh; margin: auto;
59
+ }
60
+ ${e} .stack.framed.hide-base > img:not(.top) { opacity: 0; }
61
+ ${e} .stack.framed.compare-fade > img.top.on { opacity: 1; }
62
+ ${e} .stack.framed.compare-fade.top-on > img:not(.top) {
63
+ z-index: 1; opacity: calc(1 - var(--uvalib-compare-opacity, 1));
64
+ }
65
+ ${e} .stack.framed.compare-wipe > img.top.on {
66
+ clip-path: inset(0 max(0%, calc((var(--uvalib-frame-x) + var(--uvalib-frame-w) - var(--uvalib-compare-n, 50)) / var(--uvalib-frame-w) * 100%)) 0 0);
67
+ }
68
+ ${e} .stack.framed.compare-wipe:dir(rtl) > img.top.on {
69
+ clip-path: inset(0 0 0 max(0%, calc((100 - var(--uvalib-compare-n, 50) - var(--uvalib-frame-x)) / var(--uvalib-frame-w) * 100%)));
70
+ }
71
+ ${e} .stack.framed.compare-wipe.top-part > img:not(.top) {
72
+ clip-path: inset(0 0 0 max(0%, calc((var(--uvalib-compare-n, 50) - var(--uvalib-frame-x)) / var(--uvalib-frame-w) * 100%)));
73
+ }
74
+ ${e} .stack.framed.compare-wipe.top-part:dir(rtl) > img:not(.top) {
75
+ clip-path: inset(0 max(0%, calc((var(--uvalib-compare-n, 50) + var(--uvalib-frame-x) + var(--uvalib-frame-w) - 100) / var(--uvalib-frame-w) * 100%)) 0 0);
76
+ }
24
77
  ${e} .divider {
25
78
  position: absolute; inset-block: 0; inset-inline-start: var(--uvalib-compare, 50%);
26
79
  width: 0; pointer-events: none; forced-color-adjust: none;
@@ -66,18 +119,18 @@ var a = [
66
119
  ${e} .handle::after { border-left-color: CanvasText; }
67
120
  ${e} .side { background: CanvasText; color: Canvas; outline-color: Canvas; }
68
121
  }
69
- `, d = "var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))", f = "var(--uva-color-link, var(--uva-brand-blue, #232d4b))", p = (e) => `
122
+ `, g = "var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))", _ = "var(--uva-color-link, var(--uva-brand-blue, #232d4b))", v = (e) => `
70
123
  ${e} .compare button.seg, ${e} .compare button.jump, ${e} .compare button.hold {
71
124
  display: inline-flex; align-items: center; justify-content: center;
72
125
  border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));
73
126
  background: var(--uva-color-surface-raised, var(--uva-color-surface, #fff));
74
- color: ${f}; font-size: 0.9375rem; font-weight: 600; line-height: 1.3;
127
+ color: ${_}; font-size: 0.9375rem; font-weight: 600; line-height: 1.3;
75
128
  }
76
129
  ${e} .seg-group > button + button { margin-inline-start: -1px; }
77
130
  ${e} .seg-group > button:first-child { border-start-start-radius: 0.3rem; border-end-start-radius: 0.3rem; }
78
131
  ${e} .seg-group > button:last-child { border-start-end-radius: 0.3rem; border-end-end-radius: 0.3rem; }
79
132
  ${e} .compare button.seg[aria-pressed='true'] {
80
- position: relative; border-color: ${d}; background: ${d};
133
+ position: relative; border-color: ${g}; background: ${g};
81
134
  color: var(--uva-color-on-accent, #fff);
82
135
  }
83
136
  ${e} .compare button.seg[aria-pressed='true']::before {
@@ -85,42 +138,45 @@ var a = [
85
138
  margin-inline-end: 0.5rem; border: solid currentColor; border-width: 0 2px 2px 0;
86
139
  transform: translateY(-0.0625rem) rotate(45deg);
87
140
  }
88
- ${e} .compare button:hover { border-color: ${f}; }
89
- ${e} .compare button.seg[aria-pressed='true']:hover { border-color: ${d}; }
141
+ ${e} .compare button:hover { border-color: ${_}; }
142
+ ${e} .compare button.seg[aria-pressed='true']:hover { border-color: ${g}; }
90
143
  ${e} .compare button.hold[data-held] { background: var(--uva-color-surface-hover, #f1f1f1); }
91
144
  ${e} .slider label { font-weight: 600; }
92
- ${e} .slider input { accent-color: ${d}; }
145
+ ${e} .slider input { accent-color: ${g}; }
93
146
  ${e} .slider input:focus-visible {
94
147
  outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
95
148
  outline-offset: 2px;
96
149
  }
97
150
  ${e} .note { font-size: 0.9375rem; line-height: 1.5; }
151
+ ${e} .stack.framed:not(.starting) {
152
+ background: repeating-linear-gradient(135deg, transparent 0 7px, rgb(128 128 128 / 0.2) 7px 9px);
153
+ }
98
154
  @media (prefers-reduced-motion: no-preference) {
99
- ${e} .compare-switch > img.top { transition: opacity 0.2s ease; }
155
+ ${e} .compare-switch > img.top, ${e} .compare-switch.framed > img { transition: opacity 0.2s ease; }
100
156
  }
101
157
  @media (forced-colors: active) {
102
158
  ${e} .compare button.seg, ${e} .compare button.jump, ${e} .compare button.hold { border-color: ButtonText; }
103
159
  ${e} .compare button.seg[aria-pressed='true'] { background: Highlight; color: HighlightText; border-color: Highlight; }
104
160
  }
105
- `, m = /* @__PURE__ */ new WeakSet();
106
- function h(e) {
161
+ `, y = /* @__PURE__ */ new WeakSet();
162
+ function b(e) {
107
163
  let t = e.root;
108
164
  if (e.light) {
109
165
  let i = {
110
166
  root: t,
111
167
  scope: !1
112
168
  };
113
- r("uvalib-lightbox::compare-structure", n(u("uvalib-lightbox")), i), e.noStyle || r("uvalib-lightbox::compare", n(p("uvalib-lightbox")), i);
169
+ r("uvalib-lightbox::compare-structure", n(h("uvalib-lightbox")), i), e.noStyle || r("uvalib-lightbox::compare", n(v("uvalib-lightbox")), i);
114
170
  return;
115
171
  }
116
- if (!(t instanceof ShadowRoot) || m.has(t)) return;
117
- m.add(t);
118
- let i = u(":host") + (e.noStyle ? "" : p(":host")), a = n(i).styleSheet;
172
+ if (!(t instanceof ShadowRoot) || y.has(t)) return;
173
+ y.add(t);
174
+ let i = h(":host") + (e.noStyle ? "" : v(":host")), a = n(i).styleSheet;
119
175
  a && (t.adoptedStyleSheets = [...t.adoptedStyleSheets, a]);
120
176
  }
121
- var g = 0, _ = class {
177
+ var x = 0, S = class {
122
178
  constructor(e) {
123
- this.host = e, this.list = [], this.slideKey = "", this.id = "", this.warned = !1, this.chosen = null, this.mode = "switch", this.other = 1, this.value = 50, this.shown = 0, this.holding = !1, this.requested = /* @__PURE__ */ new Set(), this.ready = /* @__PURE__ */ new Set(), this.failed = /* @__PURE__ */ new Set(), this.message = "", this.flip = !1, this.pendingAnnounce = !1, this.announceNext = !1, this.settleTimer = 0, this.settled = "", this.dragging = !1, this.dragEnd = 0, this.uid = `uvalib-compare-${++g}`, this.onInput = (e) => {
179
+ this.host = e, this.list = [], this.slideKey = "", this.id = "", this.warned = !1, this.warnedFrame = !1, this.warnedStart = !1, this.startPending = !1, this.geo = null, this.baseHref = "", this.chosen = null, this.mode = "switch", this.other = 1, this.value = 50, this.shown = 0, this.holding = !1, this.requested = /* @__PURE__ */ new Set(), this.ready = /* @__PURE__ */ new Set(), this.failed = /* @__PURE__ */ new Set(), this.message = "", this.flip = !1, this.pendingAnnounce = !1, this.announceNext = !1, this.settleTimer = 0, this.settled = "", this.dragging = !1, this.dragEnd = 0, this.uid = `uvalib-compare-${++x}`, this.onInput = (e) => {
124
180
  this.set(Number(e.target.value), !1);
125
181
  }, this.onSliderKey = (e) => {
126
182
  let t = getComputedStyle(e.target).direction === "rtl", n = e.key, r = 0;
@@ -132,17 +188,22 @@ var g = 0, _ = class {
132
188
  if (n !== " " && n !== "Enter") return;
133
189
  this.hold(t === "keydown");
134
190
  } else this.hold(t === "pointerdown");
135
- }, h(e);
191
+ }, b(e);
136
192
  }
137
193
  get active() {
138
194
  return this.list.length > 1;
139
195
  }
140
196
  sync(e, t, n) {
141
197
  let r = `${t}\n${e.href}\n${JSON.stringify(e.versions)}`;
142
- r !== this.slideKey && (this.reset(), this.slideKey = r, this.id = e.id, this.list = this.parse(e), this.mode = this.chosen ?? (a.includes(this.host.mode()) ? this.host.mode() : "switch"), this.value = this.mode === "wipe" ? 50 : 0, this.need(), this.settled = this.encode()), n != null && this.active && this.restore(n);
198
+ if (r !== this.slideKey) {
199
+ this.reset(), this.slideKey = r, this.id = e.id, this.list = this.parse(e), this.geo = u(this.list), this.baseHref = e.href, this.mode = this.chosen ?? (o.includes(this.host.mode()) ? this.host.mode() : "switch"), this.value = this.mode === "wipe" ? 50 : 0, this.need(), this.settled = this.encode();
200
+ let t = n != null && this.active && this.parseState(n, !1);
201
+ e.start && this.active && !t && this.begin(e.start);
202
+ }
203
+ n != null && this.active && this.restore(n);
143
204
  }
144
205
  reset() {
145
- this.settleTimer && this.settle(!1), this.slideKey = "", this.list = [], this.other = 1, this.shown = 0, this.holding = !1, this.dragging = !1, this.requested = /* @__PURE__ */ new Set(), this.ready = /* @__PURE__ */ new Set(), this.failed = /* @__PURE__ */ new Set(), this.message = "", this.pendingAnnounce = !1;
206
+ this.settleTimer && this.settle(!1), this.slideKey = "", this.list = [], this.geo = null, this.other = 1, this.shown = 0, this.holding = !1, this.dragging = !1, this.requested = /* @__PURE__ */ new Set(), this.ready = /* @__PURE__ */ new Set(), this.failed = /* @__PURE__ */ new Set(), this.message = "", this.pendingAnnounce = !1, this.startPending = !1;
146
207
  }
147
208
  parse(e) {
148
209
  let t = e.versions, n = !1;
@@ -153,26 +214,76 @@ var g = 0, _ = class {
153
214
  }
154
215
  let r = [];
155
216
  return Array.isArray(t) ? t.forEach((t, i) => {
156
- let a = t && typeof t == "object" ? t : {}, o = c(a.label) || (i === 0 ? "Original" : ""), s = i === 0 ? e.href : c(a.href);
217
+ let a = t && typeof t == "object" ? t : {}, o = p(a.label) || (i === 0 ? "Original" : ""), s = i === 0 ? e.href : p(a.href);
157
218
  o && s && this.host.size(s) ? r.push({
158
219
  label: o,
159
220
  href: s,
160
- note: c(a.note)
221
+ note: p(a.note),
222
+ frame: this.frame(a, i)
161
223
  }) : i === 0 ? r.length = 0 : n = !0;
162
224
  }) : n = !0, n && !this.warned && (this.warned = !0, console.warn("uvalib-lightbox: data-versions (or the versions callback) has entries without a label or a usable href; they are left out.")), r.length > 1 ? r : [];
163
225
  }
226
+ frame(e, t) {
227
+ if (e.frame == null || e.frame === "") return null;
228
+ let n = t > 0 && typeof e.frame == "string" ? a(e.frame, { signed: !0 }) : null, r = (e) => typeof e == "number" || typeof e == "string" ? Number(e) : 0, i = r(e.width), o = r(e.height);
229
+ return n?.unit === "percent" ? {
230
+ x: n.x,
231
+ y: n.y,
232
+ w: n.w,
233
+ h: n.h
234
+ } : n && i > 0 && o > 0 ? {
235
+ x: n.x / i * 100,
236
+ y: n.y / o * 100,
237
+ w: n.w / i * 100,
238
+ h: n.h / o * 100
239
+ } : (this.warnedFrame || (this.warnedFrame = !0, console.warn("uvalib-lightbox: a version has a frame that is not usable (on the first version, not percent:x,y,w,h, or pixels without the version's width and height); it is shown with the original's framing.")), null);
240
+ }
241
+ natural() {
242
+ if (!this.geo) return null;
243
+ let e = this.baseImg();
244
+ return !e?.complete || !e.naturalWidth || !e.naturalHeight ? null : {
245
+ w: e.naturalWidth,
246
+ h: e.naturalHeight
247
+ };
248
+ }
249
+ parseState(e, t) {
250
+ let n = /^(?:(switch|wipe|fade):)?(\d{1,3})(?::(\d{1,3}))?$/.exec(e.trim().toLowerCase());
251
+ if (!n) return null;
252
+ let r = n[1] ?? "switch", i = Number(n[2]);
253
+ if (r === "switch") return i < this.list.length && !n[3] ? {
254
+ mode: r,
255
+ shown: i,
256
+ other: this.other,
257
+ value: this.value
258
+ } : null;
259
+ let a = n[3] ? Number(n[3]) : 1, o = a >= 1 && a < this.list.length;
260
+ return t && (!o || i > 100) ? null : {
261
+ mode: r,
262
+ shown: this.shown,
263
+ other: o ? a : 1,
264
+ value: m(i)
265
+ };
266
+ }
267
+ apply(e) {
268
+ this.mode = e.mode, this.shown = e.shown, this.other = e.other, this.value = e.value, this.need(), this.settled = this.encode();
269
+ }
164
270
  restore(e) {
165
- let t = /^(?:(switch|wipe|fade):)?(\d{1,3})(?::(\d{1,3}))?$/.exec(e.trim().toLowerCase());
166
- if (!t) return;
167
- let n = t[1] ?? "switch", r = Number(t[2]);
168
- if (n === "switch") {
169
- if (r >= this.list.length) return;
170
- this.shown = r;
171
- } else {
172
- let e = t[3] ? Number(t[3]) : 1;
173
- this.other = e >= 1 && e < this.list.length ? e : 1, this.value = l(r);
174
- }
175
- this.mode = this.chosen = n, this.need(), this.settled = this.encode();
271
+ let t = this.parseState(e, !1);
272
+ t && (this.apply(t), this.chosen = t.mode);
273
+ }
274
+ begin(e) {
275
+ let t = this.parseState(e, !0);
276
+ t ? (this.apply(t), this.startPending = this.amount > 0) : this.warnedStart || (this.warnedStart = !0, console.warn(`uvalib-lightbox: data-version "${e.slice(0, 40)}" is not a version of its image (1, wipe:50, fade:50, wipe:40:2); it opens on the original.`));
277
+ }
278
+ baseImg() {
279
+ let e = (this.host.light ? this.host.el : this.host.root).querySelector("dialog .stack > img:not(.top)");
280
+ return e && e.getAttribute("src") === this.host.size(this.baseHref) ? e : null;
281
+ }
282
+ get starting() {
283
+ return !this.startPending || this.failed.has(this.top) ? !1 : !(this.ready.has(this.top) && this.baseImg()?.complete);
284
+ }
285
+ get named() {
286
+ return this.startPending && !this.failed.has(this.top) ? this.amount : this.seen;
176
287
  }
177
288
  encode() {
178
289
  return this.mode === "switch" ? String(this.shown) : `${this.mode}:${this.value}${this.other === 1 ? "" : `:${this.other}`}`;
@@ -193,11 +304,11 @@ var g = 0, _ = class {
193
304
  this.amount > 0 && this.top > 0 && this.requested.add(this.top);
194
305
  }
195
306
  set(e, t) {
196
- let n = l(e);
197
- n !== this.value && (this.value = n, this.need(), this.host.update(), this.announceNext ||= t, window.clearTimeout(this.settleTimer), this.settleTimer = window.setTimeout(() => this.settle(), s.settle));
307
+ let n = m(e);
308
+ n !== this.value && (this.startPending = !1, this.value = n, this.need(), this.host.update(), this.announceNext ||= t, window.clearTimeout(this.settleTimer), this.settleTimer = window.setTimeout(() => this.settle(), c.settle));
198
309
  }
199
310
  change(e) {
200
- e(), this.need(), this.host.update(), this.announceNext = !0, this.settle();
311
+ this.startPending = !1, e(), this.need(), this.host.update(), this.announceNext = !0, this.settle();
201
312
  }
202
313
  settle(e = !0) {
203
314
  window.clearTimeout(this.settleTimer), this.settleTimer = 0;
@@ -269,36 +380,54 @@ var g = 0, _ = class {
269
380
  return this.dragging || performance.now() - this.dragEnd < 100;
270
381
  }
271
382
  alt(e) {
272
- let t = this.seen, n = this.label(0), r = this.label(this.top);
383
+ let t = this.named, n = this.label(0), r = this.label(this.top);
273
384
  return `${e} (${t <= 0 ? n : t >= 100 ? r : `${n} and ${r}, ${this.mode === "wipe" ? "compared side by side" : "blended"}`})`;
274
385
  }
275
386
  get stackClass() {
276
- return `compare-${this.mode}`;
387
+ let e = this.starting ? " starting" : "", t = this.natural() ? this.geo : null;
388
+ if (!t) return `compare-${this.mode}${e}`;
389
+ let n = this.seen > 0, r = n && !t.covers[this.top], i = this.mode === "switch" && r && this.seen >= 100;
390
+ return `compare-${this.mode} framed${n ? " top-on" : ""}${i ? " hide-base" : ""}${r && this.mode === "wipe" ? " top-part" : ""}${e}`;
277
391
  }
278
392
  get stackStyle() {
279
- let e = this.mode === "switch" ? 100 : this.value;
280
- return `--uvalib-compare: ${e}%; --uvalib-compare-opacity: ${e / 100}`;
393
+ let e = this.mode === "switch" ? 100 : this.value, t = `--uvalib-compare: ${e}%; --uvalib-compare-opacity: ${e / 100}`, n = this.natural() ? this.geo : null;
394
+ return n ? `${t}; --uvalib-compare-n: ${e}; ${f(n.boxes[0])}` : t;
395
+ }
396
+ get regionsStyle() {
397
+ let e = this.natural() ? this.geo : null;
398
+ if (!e) return "";
399
+ let t = e.boxes[0];
400
+ return `--uvalib-image-regions-inset: ${d(t.y)}% ${d(100 - t.x - t.w)}% ${d(100 - t.y - t.h)}% ${d(t.x)}%`;
281
401
  }
282
402
  layers() {
283
- let n = this.top, r = this.seen > 0, i = this.list.map((i, a) => a === 0 ? t : e`<img
284
- class="top ${a === n && r ? "on" : ""}"
285
- data-version=${a}
403
+ let n = this.top, r = this.seen > 0, i = this.natural(), a = i ? this.geo : null, o = a && i ? (() => {
404
+ let t = i.w * a.uw, n = i.h * a.uh, r = Math.min(1, l / Math.max(t, n));
405
+ return e`<canvas
406
+ class="frame-box"
407
+ aria-hidden="true"
408
+ width=${Math.max(1, Math.round(t * r))}
409
+ height=${Math.max(1, Math.round(n * r))}
410
+ ></canvas>`;
411
+ })() : t, s = this.list.map((i, o) => o === 0 ? t : e`<img
412
+ class="top ${o === n && r ? "on" : ""}"
413
+ style=${a && i.frame ? f(a.boxes[o]) : t}
414
+ data-version=${o}
286
415
  alt=""
287
416
  decoding="async"
288
417
  draggable="false"
289
- src=${this.requested.has(a) ? this.host.size(i.href) : t}
290
- @load=${() => this.loaded(a)}
291
- @error=${() => this.errored(a)}
418
+ src=${this.requested.has(o) ? this.host.size(i.href) : t}
419
+ @load=${() => this.loaded(o)}
420
+ @error=${() => this.errored(o)}
292
421
  />`);
293
- if (this.mode !== "wipe") return i;
294
- let a = this.seen;
295
- return e`${i}
422
+ if (this.mode !== "wipe") return e`${o}${s}`;
423
+ let c = this.seen;
424
+ return e`${o}${s}
296
425
  <div class="divider" aria-hidden="true"><span class="handle"></span></div>
297
- <span class="side side-start" aria-hidden="true" ?hidden=${a <= 0}>${this.label(n)}</span>
298
- <span class="side side-end" aria-hidden="true" ?hidden=${a >= 100}>${this.label(0)}</span>`;
426
+ <span class="side side-start" aria-hidden="true" ?hidden=${c <= 0}>${this.label(n)}</span>
427
+ <span class="side side-end" aria-hidden="true" ?hidden=${c >= 100}>${this.label(0)}</span>`;
299
428
  }
300
429
  controls(n) {
301
- let r = this.seen, i = this.top, s = (e) => e === 0 ? r < 100 : e === i && r > 0, c = this.list.map((n, r) => n.note ? e`<p class="note" ?data-off=${!s(r)}><strong>${n.label}:</strong> ${n.note}</p>` : t), l = this.failed.has(i) && this.amount > 0 ? e`<p class="note">${this.label(i)} could not be loaded.</p>` : t, u = (t, n, r) => e`<button
430
+ let r = this.named, i = this.top, a = (e) => e === 0 ? r < 100 : e === i && r > 0, c = this.list.map((n, r) => n.note ? e`<p class="note" ?data-off=${!a(r)}><strong>${n.label}:</strong> ${n.note}</p>` : t), l = this.failed.has(i) && this.amount > 0 ? e`<p class="note">${this.label(i)} could not be loaded.</p>` : t, u = (t, n, r) => e`<button
302
431
  type="button"
303
432
  class="seg"
304
433
  aria-pressed=${t ? "true" : "false"}
@@ -357,7 +486,7 @@ var g = 0, _ = class {
357
486
  ${c}${l}
358
487
  <div class="compare-bar">
359
488
  <div class="seg-group" role="group" aria-label="Compare versions">
360
- ${a.map((e) => u(this.mode === e, o[e], () => this.setMode(e)))}
489
+ ${o.map((e) => u(this.mode === e, s[e], () => this.setMode(e)))}
361
490
  </div>
362
491
  <div class="mode-panels">${m(p, h)}${m(!p, g)}</div>
363
492
  </div>
@@ -371,6 +500,6 @@ var g = 0, _ = class {
371
500
  }));
372
501
  }
373
502
  };
374
- export { _ as Compare, s as compareTiming };
503
+ export { S as Compare, c as compareTiming };
375
504
 
376
- //# sourceMappingURL=compare-D4VdaIJN.js.map
505
+ //# sourceMappingURL=compare-C0nhByn7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare-C0nhByn7.js","names":["unsafeCSS","nothing","b","A","r","trackEvent","parseXywh","MODES","MODE_NAMES","compareTiming","MAX_SIDE","framing","list","v","ext","f","x0","y0","uw","uh","r4","n","place","norm","s","clamp","structure","h","ACCENT","LINK","look","styled","install","root","host","opts","installLightDomStyles","text","sheet","nextId","Compare","rtl","k","d","key","index","slide","fromUrl","restore","raw","bad","out","o","label","href","box","i","size","w","img","m","param","mode","other","ok","strict","st","start","next","announce","fn","state","el","write","a","on","stack","l0","lk","base","starting","geo","part","hide","top","sizer","layers","visible","notes","failed","seg","pressed","onClick","switching","panel","body","switchPanel","sliding","slot"],"sources":["../../src/components/uvalib-lightbox/compare.ts"],"sourcesContent":["/**\n * Versions of an image compared over the photo: Switch, Reveal (a wipe) and Fade. Loaded by\n * `<uvalib-lightbox>` the first time an open image has versions, so pages without them never\n * load it.\n */\nimport { html, nothing, unsafeCSS } from 'lit';\nimport { trackEvent } from '../../base/analytics.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { parseXywh } from '../uvalib-image-regions/regions.js';\n\nexport type CompareMode = 'switch' | 'wipe' | 'fade';\n\nconst MODES: CompareMode[] = ['switch', 'wipe', 'fade'];\nconst MODE_NAMES: Record<CompareMode, string> = {\n switch: 'Switch',\n wipe: 'Reveal',\n fade: 'Fade',\n};\n\n/** How long (ms) after the last slider or drag change it counts as settled. Tests shorten it. */\nexport const compareTiming = { settle: 400 };\n\n/** A box in percent: of a version (its `frame`), or of the box that holds every version. */\ninterface Box {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\ninterface Version {\n label: string;\n href: string;\n note: string;\n /** Where the original sits in this version, in percent of the version; null: the same framing. */\n frame: Box | null;\n}\n\n/**\n * Versions with a different framing: every version's box (and the original's, first) in\n * percent of the box that holds them all, at the original's scale; `uw` × `uh` is that box in\n * original widths and heights; `covers` says whether a version covers the whole original.\n */\ninterface Framing {\n boxes: Box[];\n uw: number;\n uh: number;\n covers: boolean[];\n}\n\n/** The largest side of the sizer (a canvas never drawn on, so nothing is allocated). */\nconst MAX_SIDE = 4096;\n\nfunction framing(list: Version[]): Framing | null {\n if (!list.some((v) => v.frame)) return null;\n // Each version's extent in original units: the original is 0..1 across and down.\n const ext = list.map(({ frame: f }) =>\n f ? { x: -f.x / f.w, y: -f.y / f.h, w: 100 / f.w, h: 100 / f.h } : { x: 0, y: 0, w: 1, h: 1 },\n );\n const x0 = Math.min(...ext.map((e) => e.x));\n const y0 = Math.min(...ext.map((e) => e.y));\n const uw = Math.max(...ext.map((e) => e.x + e.w)) - x0;\n const uh = Math.max(...ext.map((e) => e.y + e.h)) - y0;\n return {\n uw,\n uh,\n boxes: ext.map((e) => ({\n x: ((e.x - x0) / uw) * 100,\n y: ((e.y - y0) / uh) * 100,\n w: (e.w / uw) * 100,\n h: (e.h / uh) * 100,\n })),\n // A version covers the original when the original's box lies inside it.\n covers: list.map(\n ({ frame: f }) =>\n !f || (f.x >= -0.001 && f.y >= -0.001 && f.x + f.w <= 100.001 && f.y + f.h <= 100.001),\n ),\n };\n}\n\nconst r4 = (n: number) => Math.round(n * 1e4) / 1e4;\n/** Custom properties placing a layer (numbers, percent of the stack). */\nconst place = (b: Box) =>\n `--uvalib-frame-x: ${r4(b.x)}; --uvalib-frame-y: ${r4(b.y)}; --uvalib-frame-w: ${r4(b.w)}; --uvalib-frame-h: ${r4(b.h)}`;\n\n/** What the lightbox lends the comparison. */\nexport interface CompareHost {\n el: HTMLElement;\n light: boolean;\n root: Node;\n noStyle: boolean;\n /** The `compare` attribute: the first mode. */\n mode(): string;\n /** The URL the viewer would load for `href` ('' when it may not be shown). */\n size(href: string): string;\n /** Write the comparison to `version-param` (replaceState). */\n write(value: string | null): void;\n update(): void;\n}\n\n/** The parts of a lightbox slide the comparison reads. */\nexport interface CompareSlide {\n id: string;\n href: string;\n versions: string | unknown[] | null;\n /** `data-version`: the comparison the image opens on (the `version-param` format). */\n start?: string | null;\n}\n\n/** A comparison state: `version-param`'s value, parsed. */\ninterface State {\n mode: CompareMode;\n /** The version shown (Switch). */\n shown: number;\n /** The version compared (Reveal, Fade), and the percentage of it shown. */\n other: number;\n value: number;\n}\n\nconst norm = (s: unknown) => (typeof s === 'string' ? s.replace(/\\s+/g, ' ').trim() : '');\nconst clamp = (n: number) => Math.min(100, Math.max(0, Math.round(n)));\n\n/**\n * Kept with `no-style`: the stacked layers, the clip and fade, the divider and its handle\n * (white inside black, so it shows on any photo), the side labels and the control layout.\n * `h` is `:host` (shadow) or the tag (light DOM).\n */\nconst structure = (h: string) => `\n ${h} .stack { isolation: isolate; }\n ${h} .stack > img.top {\n position: absolute; inset: 0; width: 100%; height: 100%;\n max-width: none; max-height: none; margin: 0; opacity: 0; pointer-events: none;\n }\n ${h} .stack > img.top.on { opacity: 1; }\n ${h} .compare-fade > img.top.on { opacity: var(--uvalib-compare-opacity, 1); }\n ${h} .compare-wipe > img.top.on { clip-path: inset(0 calc(100% - var(--uvalib-compare, 50%)) 0 0); }\n ${h} .compare-wipe:dir(rtl) > img.top.on { clip-path: inset(0 0 0 calc(100% - var(--uvalib-compare, 50%))); }\n ${h} .compare-wipe { touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: col-resize; }\n ${h} .compare-wipe img { -webkit-user-drag: none; }\n ${h} .stack.framed > img {\n position: absolute; inset: auto;\n left: calc(var(--uvalib-frame-x) * 1%); top: calc(var(--uvalib-frame-y) * 1%);\n width: calc(var(--uvalib-frame-w) * 1%); height: calc(var(--uvalib-frame-h) * 1%);\n max-width: none; max-height: none; margin: 0;\n }\n ${h} .stack.framed > canvas.frame-box {\n display: block; width: auto; height: auto; max-width: 100%; max-height: 70dvh; margin: auto;\n }\n ${h} .stack.framed.hide-base > img:not(.top) { opacity: 0; }\n ${h} .stack.framed.compare-fade > img.top.on { opacity: 1; }\n ${h} .stack.framed.compare-fade.top-on > img:not(.top) {\n z-index: 1; opacity: calc(1 - var(--uvalib-compare-opacity, 1));\n }\n ${h} .stack.framed.compare-wipe > img.top.on {\n clip-path: inset(0 max(0%, calc((var(--uvalib-frame-x) + var(--uvalib-frame-w) - var(--uvalib-compare-n, 50)) / var(--uvalib-frame-w) * 100%)) 0 0);\n }\n ${h} .stack.framed.compare-wipe:dir(rtl) > img.top.on {\n clip-path: inset(0 0 0 max(0%, calc((100 - var(--uvalib-compare-n, 50) - var(--uvalib-frame-x)) / var(--uvalib-frame-w) * 100%)));\n }\n ${h} .stack.framed.compare-wipe.top-part > img:not(.top) {\n clip-path: inset(0 0 0 max(0%, calc((var(--uvalib-compare-n, 50) - var(--uvalib-frame-x)) / var(--uvalib-frame-w) * 100%)));\n }\n ${h} .stack.framed.compare-wipe.top-part:dir(rtl) > img:not(.top) {\n clip-path: inset(0 max(0%, calc((var(--uvalib-compare-n, 50) + var(--uvalib-frame-x) + var(--uvalib-frame-w) - 100) / var(--uvalib-frame-w) * 100%)) 0 0);\n }\n ${h} .divider {\n position: absolute; inset-block: 0; inset-inline-start: var(--uvalib-compare, 50%);\n width: 0; pointer-events: none; forced-color-adjust: none;\n }\n ${h} .divider::before {\n content: ''; position: absolute; inset-block: 0; inset-inline-start: -2px; width: 4px;\n background: #fff; outline: 1px solid #000;\n }\n ${h} .handle {\n position: absolute; top: 50%; inset-inline-start: -22px; box-sizing: border-box;\n width: 44px; height: 44px; margin-top: -22px; border: 3px solid #000; border-radius: 50%;\n background: #fff; outline: 2px solid #fff;\n }\n ${h} .handle::before, ${h} .handle::after {\n content: ''; position: absolute; top: 50%; margin-top: -6px;\n border-block: 6px solid transparent;\n }\n ${h} .handle::before { left: 7px; border-right: 8px solid #000; }\n ${h} .handle::after { right: 7px; border-left: 8px solid #000; }\n ${h} .side {\n position: absolute; inset-block-end: 0.5rem; max-width: 40%; overflow: hidden;\n padding: 0.125rem 0.5rem; background: #000; color: #fff; outline: 1px solid #fff;\n font-size: 0.875rem; font-weight: 700; line-height: 1.3; white-space: nowrap;\n text-overflow: ellipsis; pointer-events: none; forced-color-adjust: none;\n }\n ${h} .side-start { inset-inline-start: 0.5rem; }\n ${h} .side-end { inset-inline-end: 0.5rem; }\n ${h} .compare { display: flex; flex-direction: column; gap: 0.5rem; margin-block-start: 0.75rem; }\n ${h} .compare-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }\n ${h} .mode-panels { display: grid; flex: 1 1 auto; min-width: 0; }\n ${h} .mode-panel { grid-area: 1 / 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }\n ${h} .mode-panel[data-off] { visibility: hidden; }\n ${h} .seg-group { display: flex; flex-wrap: wrap; }\n ${h} .slider { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; flex: 1 1 14rem; min-width: 0; }\n ${h} .slider input { flex: 1 1 8rem; min-width: 0; min-height: 44px; margin: 0; }\n ${h} .note { margin: 0; overflow-wrap: anywhere; }\n ${h} .note[data-off] { visibility: hidden; }\n ${h} .compare button.hold { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; touch-action: none; }\n @media (forced-colors: active) {\n ${h} .divider::before { background: CanvasText; outline-color: Canvas; }\n ${h} .handle { background: Canvas; border-color: Highlight; outline-color: Canvas; }\n ${h} .handle::before { border-right-color: CanvasText; }\n ${h} .handle::after { border-left-color: CanvasText; }\n ${h} .side { background: CanvasText; color: Canvas; outline-color: Canvas; }\n }\n`;\n\nconst ACCENT = 'var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))';\nconst LINK = 'var(--uva-color-link, var(--uva-brand-blue, #232d4b))';\n\n/** The look: segmented buttons like `<uvalib-chip-group segmented>`, the slider's accent. */\nconst look = (h: string) => `\n ${h} .compare button.seg, ${h} .compare button.jump, ${h} .compare button.hold {\n display: inline-flex; align-items: center; justify-content: center;\n border: 1px solid var(--uva-color-control-border, var(--uva-grey, #808080));\n background: var(--uva-color-surface-raised, var(--uva-color-surface, #fff));\n color: ${LINK}; font-size: 0.9375rem; font-weight: 600; line-height: 1.3;\n }\n ${h} .seg-group > button + button { margin-inline-start: -1px; }\n ${h} .seg-group > button:first-child { border-start-start-radius: 0.3rem; border-end-start-radius: 0.3rem; }\n ${h} .seg-group > button:last-child { border-start-end-radius: 0.3rem; border-end-end-radius: 0.3rem; }\n ${h} .compare button.seg[aria-pressed='true'] {\n position: relative; border-color: ${ACCENT}; background: ${ACCENT};\n color: var(--uva-color-on-accent, #fff);\n }\n ${h} .compare button.seg[aria-pressed='true']::before {\n content: ''; box-sizing: border-box; width: 0.375rem; height: 0.75rem;\n margin-inline-end: 0.5rem; border: solid currentColor; border-width: 0 2px 2px 0;\n transform: translateY(-0.0625rem) rotate(45deg);\n }\n ${h} .compare button:hover { border-color: ${LINK}; }\n ${h} .compare button.seg[aria-pressed='true']:hover { border-color: ${ACCENT}; }\n ${h} .compare button.hold[data-held] { background: var(--uva-color-surface-hover, #f1f1f1); }\n ${h} .slider label { font-weight: 600; }\n ${h} .slider input { accent-color: ${ACCENT}; }\n ${h} .slider input:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${h} .note { font-size: 0.9375rem; line-height: 1.5; }\n ${h} .stack.framed:not(.starting) {\n background: repeating-linear-gradient(135deg, transparent 0 7px, rgb(128 128 128 / 0.2) 7px 9px);\n }\n @media (prefers-reduced-motion: no-preference) {\n ${h} .compare-switch > img.top, ${h} .compare-switch.framed > img { transition: opacity 0.2s ease; }\n }\n @media (forced-colors: active) {\n ${h} .compare button.seg, ${h} .compare button.jump, ${h} .compare button.hold { border-color: ButtonText; }\n ${h} .compare button.seg[aria-pressed='true'] { background: Highlight; color: HighlightText; border-color: Highlight; }\n }\n`;\n\n/** Shadow roots that already have the comparison's sheets. */\nconst styled = new WeakSet<Node>();\n\nfunction install(host: CompareHost): void {\n const root = host.root;\n if (host.light) {\n const opts = { root: root as Document | ShadowRoot, scope: false };\n installLightDomStyles(\n 'uvalib-lightbox::compare-structure',\n unsafeCSS(structure('uvalib-lightbox')),\n opts,\n );\n if (!host.noStyle)\n installLightDomStyles('uvalib-lightbox::compare', unsafeCSS(look('uvalib-lightbox')), opts);\n return;\n }\n if (!(root instanceof ShadowRoot) || styled.has(root)) return;\n styled.add(root);\n const text = structure(':host') + (host.noStyle ? '' : look(':host'));\n const sheet = unsafeCSS(text).styleSheet;\n if (sheet) root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n}\n\nlet nextId = 0;\n\n/**\n * The comparison for one lightbox. State: the mode, the version shown (Switch) or compared\n * with the original (Reveal, Fade), and the percentage of it shown. Another version's image\n * is requested the first time it is needed, and drawn (and announced) once it has loaded.\n */\nexport class Compare {\n private list: Version[] = [];\n private slideKey = '';\n private id = '';\n private warned = false;\n private warnedFrame = false;\n private warnedStart = false;\n /** The image opened on another version (`data-version`): hidden until that version is drawn. */\n private startPending = false;\n private geo: Framing | null = null;\n private baseHref = '';\n /** The mode the visitor (or the address) chose; else the lightbox's `compare`. */\n private chosen: CompareMode | null = null;\n mode: CompareMode = 'switch';\n /** The version compared with the original (Reveal, Fade), from 1. */\n private other = 1;\n /** The percentage of `other` shown (Reveal, Fade). */\n private value = 50;\n /** The version shown (Switch), from 0. */\n private shown = 0;\n private holding = false;\n private requested = new Set<number>();\n private ready = new Set<number>();\n private failed = new Set<number>();\n private message = '';\n private flip = false;\n private pendingAnnounce = false;\n private announceNext = false;\n private settleTimer = 0;\n private settled = '';\n private dragging = false;\n private dragEnd = 0;\n private readonly uid = `uvalib-compare-${++nextId}`;\n\n constructor(private readonly host: CompareHost) {\n install(host);\n }\n\n /** At least two usable versions. */\n get active(): boolean {\n return this.list.length > 1;\n }\n\n /** Follow the open image: a new one starts again (in the current mode); `restore` is the address's value. */\n sync(slide: CompareSlide, index: number, restore: string | null): void {\n const key = `${index}\\n${slide.href}\\n${JSON.stringify(slide.versions)}`;\n if (key !== this.slideKey) {\n this.reset();\n this.slideKey = key;\n this.id = slide.id;\n this.list = this.parse(slide);\n this.geo = framing(this.list);\n this.baseHref = slide.href;\n this.mode =\n this.chosen ??\n (MODES.includes(this.host.mode() as CompareMode)\n ? (this.host.mode() as CompareMode)\n : 'switch');\n this.value = this.mode === 'wipe' ? 50 : 0;\n this.need();\n this.settled = this.encode();\n // The link's own start, unless the address says otherwise.\n const fromUrl = restore != null && this.active && this.parseState(restore, false);\n if (slide.start && this.active && !fromUrl) this.begin(slide.start);\n }\n if (restore != null && this.active) this.restore(restore);\n }\n\n /** Forget the open image (the viewer closed): report a change still settling first. */\n reset(): void {\n // Its event and analytics, but not the address: that is the next image's now.\n if (this.settleTimer) this.settle(false);\n this.slideKey = '';\n this.list = [];\n this.geo = null;\n this.other = 1;\n this.shown = 0;\n this.holding = false;\n this.dragging = false;\n this.requested = new Set();\n this.ready = new Set();\n this.failed = new Set();\n this.message = '';\n this.pendingAnnounce = false;\n this.startPending = false;\n }\n\n private parse(slide: CompareSlide): Version[] {\n let raw: unknown = slide.versions;\n let bad = false;\n if (typeof raw === 'string') {\n try {\n raw = JSON.parse(raw);\n } catch {\n raw = null;\n bad = true;\n }\n }\n const out: Version[] = [];\n if (Array.isArray(raw)) {\n raw.forEach((v: unknown, i) => {\n const o = v && typeof v === 'object' ? (v as Record<string, unknown>) : {};\n const label = norm(o.label) || (i === 0 ? 'Original' : '');\n const href = i === 0 ? slide.href : norm(o.href);\n if (label && href && this.host.size(href))\n out.push({ label, href, note: norm(o.note), frame: this.frame(o, i) });\n else if (i === 0) out.length = 0;\n else bad = true;\n });\n } else bad = true;\n if (bad && !this.warned) {\n this.warned = true;\n console.warn(\n 'uvalib-lightbox: data-versions (or the versions callback) has entries without a label or a usable href; they are left out.',\n );\n }\n return out.length > 1 ? out : [];\n }\n\n /**\n * A version's `frame`: the original's box in it, `percent:x,y,w,h`, or pixels\n * (`x,y,w,h` / `pixel:`) of the version's `width` × `height`. `x` and `y` may be negative\n * and `w` and `h` over the version (a crop: the original reaches past it); `w` and `h` must\n * be positive. Anything else is ignored (the same framing), with one warning.\n */\n private frame(o: Record<string, unknown>, i: number): Box | null {\n if (o.frame == null || o.frame === '') return null;\n const box = i > 0 && typeof o.frame === 'string' ? parseXywh(o.frame, { signed: true }) : null;\n const size = (v: unknown) => (typeof v === 'number' || typeof v === 'string' ? Number(v) : 0);\n const w = size(o.width);\n const h = size(o.height);\n if (box?.unit === 'percent') return { x: box.x, y: box.y, w: box.w, h: box.h };\n if (box && w > 0 && h > 0)\n return {\n x: (box.x / w) * 100,\n y: (box.y / h) * 100,\n w: (box.w / w) * 100,\n h: (box.h / h) * 100,\n };\n if (!this.warnedFrame) {\n this.warnedFrame = true;\n console.warn(\n \"uvalib-lightbox: a version has a frame that is not usable (on the first version, not percent:x,y,w,h, or pixels without the version's width and height); it is shown with the original's framing.\",\n );\n }\n return null;\n }\n\n /**\n * The original's natural size, once its image (the one rendered now) has loaded: the framed\n * layout needs it, and is used only from then on (before, the original sizes the stack).\n */\n private natural(): { w: number; h: number } | null {\n if (!this.geo) return null;\n const img = this.baseImg();\n if (!img?.complete || !img.naturalWidth || !img.naturalHeight) return null;\n return { w: img.naturalWidth, h: img.naturalHeight };\n }\n\n /**\n * `2`, `switch:2`, `wipe:40`, `fade:60`, `wipe:40:2` (the version compared, from 1), or\n * null. `strict` (`data-version`) refuses what the address forgives: a percentage over 100\n * or a version compared that does not exist.\n */\n private parseState(param: string, strict: boolean): State | null {\n const m = /^(?:(switch|wipe|fade):)?(\\d{1,3})(?::(\\d{1,3}))?$/.exec(param.trim().toLowerCase());\n if (!m) return null;\n const mode = (m[1] ?? 'switch') as CompareMode;\n const n = Number(m[2]);\n if (mode === 'switch')\n return n < this.list.length && !m[3]\n ? { mode, shown: n, other: this.other, value: this.value }\n : null;\n const other = m[3] ? Number(m[3]) : 1;\n const ok = other >= 1 && other < this.list.length;\n if (strict && (!ok || n > 100)) return null;\n return { mode, shown: this.shown, other: ok ? other : 1, value: clamp(n) };\n }\n\n private apply(st: State): void {\n this.mode = st.mode;\n this.shown = st.shown;\n this.other = st.other;\n this.value = st.value;\n this.need();\n this.settled = this.encode();\n }\n\n /** The comparison from the address: the visitor's mode from now on. */\n private restore(param: string): void {\n const st = this.parseState(param, false);\n if (!st) return;\n this.apply(st);\n this.chosen = st.mode;\n }\n\n /**\n * The link's starting version (`data-version`): not the visitor's change, so no event, no\n * analytics, nothing written to the address, and the mode chosen stays for other images.\n */\n private begin(start: string): void {\n const st = this.parseState(start, true);\n if (!st) {\n if (!this.warnedStart) {\n this.warnedStart = true;\n console.warn(\n `uvalib-lightbox: data-version \"${start.slice(0, 40)}\" is not a version of its image (1, wipe:50, fade:50, wipe:40:2); it opens on the original.`,\n );\n }\n return;\n }\n this.apply(st);\n this.startPending = this.amount > 0;\n }\n\n /** The open image's own image element (the original). */\n private baseImg(): HTMLImageElement | null {\n const scope = (this.host.light ? this.host.el : this.host.root) as ParentNode;\n const img = scope.querySelector<HTMLImageElement>('dialog .stack > img:not(.top)');\n return img && img.getAttribute('src') === this.host.size(this.baseHref) ? img : null;\n }\n\n /**\n * Opening on another version: the photo stays hidden until that version (and the\n * original, which sizes a framed stack) has loaded, so the original never flashes first.\n */\n private get starting(): boolean {\n if (!this.startPending || this.failed.has(this.top)) return false;\n return !(this.ready.has(this.top) && this.baseImg()?.complete);\n }\n\n /** The percentage of the top version named and noted: the start's at once, else what is drawn. */\n private get named(): number {\n return this.startPending && !this.failed.has(this.top) ? this.amount : this.seen;\n }\n\n private encode(): string {\n if (this.mode === 'switch') return String(this.shown);\n return `${this.mode}:${this.value}${this.other !== 1 ? `:${this.other}` : ''}`;\n }\n\n /** The version over the original: shown (Switch) or compared (Reveal, Fade). */\n private get top(): number {\n return this.mode === 'switch' ? this.shown : this.other;\n }\n\n /** The percentage of the top version asked for. */\n private get amount(): number {\n if (this.holding) return 0;\n if (this.mode === 'switch') return this.shown > 0 ? 100 : 0;\n return this.value;\n }\n\n /** The percentage of it on screen: none until its image has loaded. */\n private get seen(): number {\n return this.top > 0 && this.ready.has(this.top) ? this.amount : 0;\n }\n\n private label(i: number): string {\n return this.list[i]?.label ?? '';\n }\n\n /** Request the top version's image the first time it is needed. */\n private need(): void {\n if (this.amount > 0 && this.top > 0) this.requested.add(this.top);\n }\n\n // ------------------------------------------------------------ changes\n\n private set(v: number, announce: boolean): void {\n const next = clamp(v);\n if (next === this.value) return;\n this.startPending = false;\n this.value = next;\n this.need();\n this.host.update();\n this.announceNext ||= announce;\n window.clearTimeout(this.settleTimer);\n this.settleTimer = window.setTimeout(() => this.settle(), compareTiming.settle);\n }\n\n private change(fn: () => void): void {\n this.startPending = false;\n fn();\n this.need();\n this.host.update();\n this.announceNext = true;\n this.settle();\n }\n\n /** A visitor's change has settled: the event, analytics, the address and the announcement. */\n private settle(write = true): void {\n window.clearTimeout(this.settleTimer);\n this.settleTimer = 0;\n const state = this.encode();\n const announce = this.announceNext;\n this.announceNext = false;\n if (state === this.settled || !this.active) return;\n this.settled = state;\n const index = this.top;\n const el = this.host.el;\n el.dispatchEvent(\n new CustomEvent('uvalib-lightbox-version', {\n detail: {\n id: this.id,\n mode: this.mode,\n index,\n value: this.mode === 'switch' ? null : this.value,\n },\n bubbles: true,\n composed: true,\n }),\n );\n trackEvent(el, ['uvalib-lightbox', 'compare', this.mode, index + 1]);\n if (!write) return;\n this.host.write(state);\n if (!announce) return;\n if (this.amount > 0 && !this.ready.has(this.top)) this.pendingAnnounce = true;\n else this.say(this.stateText());\n }\n\n private say(text: string): void {\n this.pendingAnnounce = false;\n // A repeated message is still a change, so it is read again.\n this.flip = !this.flip;\n this.message = text + (this.flip ? ' ' : '');\n this.host.update();\n }\n\n private stateText(): string {\n const a = this.amount;\n if (a <= 0) return `${this.label(0)} shown`;\n if (a >= 100) return `${this.label(this.top)} shown`;\n return `${a}% ${this.label(this.top)}`;\n }\n\n private setMode(mode: CompareMode): void {\n if (mode === this.mode) return;\n this.change(() => {\n if (mode === 'switch') this.shown = this.value >= 50 ? this.other : 0;\n else if (this.mode === 'switch') {\n if (this.shown > 0) this.other = this.shown;\n this.value = mode === 'wipe' ? 50 : this.shown > 0 ? 100 : 0;\n }\n this.mode = this.chosen = mode;\n });\n }\n\n private hold(on: boolean): void {\n if (on === this.holding) return;\n this.holding = on;\n this.host.update();\n }\n\n private loaded(i: number): void {\n this.ready.add(i);\n this.host.update();\n if (this.pendingAnnounce && i === this.top) this.say(this.stateText());\n }\n\n private errored(i: number): void {\n this.failed.add(i);\n this.pendingAnnounce = false;\n this.say(`${this.label(i)} could not be loaded.`);\n }\n\n // ------------------------------------------------------------ input\n\n /** The `o` key held anywhere in the dialog shows the original. True when handled. */\n key(e: KeyboardEvent): boolean {\n if (!this.active || (e.key !== 'o' && e.key !== 'O') || e.altKey || e.ctrlKey || e.metaKey)\n return false;\n this.hold(e.type === 'keydown');\n return true;\n }\n\n /** A press on the photo in Reveal moves the divider there; a drag keeps moving it. */\n pointer(e: PointerEvent): void {\n if (!this.active || this.mode !== 'wipe') return;\n const stack = e.currentTarget as HTMLElement;\n if (e.type === 'pointerdown') {\n if (e.button !== 0 || !e.isPrimary) return;\n this.dragging = true;\n try {\n stack.setPointerCapture(e.pointerId);\n } catch {\n // A synthetic pointer cannot be captured; the press still moves the divider.\n }\n e.preventDefault();\n } else if (e.type !== 'pointermove') {\n if (this.dragging) this.dragEnd = performance.now();\n this.dragging = false;\n return;\n }\n if (!this.dragging) return;\n const r = stack.getBoundingClientRect();\n if (!r.width) return;\n const rtl = getComputedStyle(stack).direction === 'rtl';\n this.set(((rtl ? r.right - e.clientX : e.clientX - r.left) / r.width) * 100, true);\n }\n\n /** A drag that ended outside the photo must not count as a click on the backdrop. */\n dragged(): boolean {\n return this.dragging || performance.now() - this.dragEnd < 100;\n }\n\n private readonly onInput = (e: Event): void => {\n this.set(Number((e.target as HTMLInputElement).value), false);\n };\n\n /** Shift with an arrow, and Page Up / Page Down, move 10%. */\n private readonly onSliderKey = (e: KeyboardEvent): void => {\n const rtl = getComputedStyle(e.target as Element).direction === 'rtl';\n const k = e.key;\n let d = 0;\n if (k === 'PageUp') d = 10;\n else if (k === 'PageDown') d = -10;\n else if (e.shiftKey && (k === 'ArrowUp' || k === 'ArrowDown')) d = k === 'ArrowUp' ? 10 : -10;\n else if (e.shiftKey && (k === 'ArrowLeft' || k === 'ArrowRight'))\n d = (k === 'ArrowRight') !== rtl ? 10 : -10;\n if (!d) return;\n e.preventDefault();\n this.set(this.value + d, false);\n };\n\n private readonly onHold = (e: Event): void => {\n const t = e.type;\n if (t === 'keydown' || t === 'keyup') {\n const k = (e as KeyboardEvent).key;\n if (k !== ' ' && k !== 'Enter') return;\n this.hold(t === 'keydown');\n } else this.hold(t === 'pointerdown');\n };\n\n // ------------------------------------------------------------ render\n\n /** The image's accessible name ends with what is on screen. */\n alt(base: string): string {\n const a = this.named;\n const l0 = this.label(0);\n const lk = this.label(this.top);\n const what =\n a <= 0\n ? l0\n : a >= 100\n ? lk\n : `${l0} and ${lk}, ${this.mode === 'wipe' ? 'compared side by side' : 'blended'}`;\n return `${base} (${what})`;\n }\n\n get stackClass(): string {\n const starting = this.starting ? ' starting' : '';\n const geo = this.natural() ? this.geo : null;\n if (!geo) return `compare-${this.mode}${starting}`;\n const on = this.seen > 0;\n // A version that does not cover the whole original (a crop): Switch hides the original;\n // Reveal shows only the version on its side of the divider, the pattern around it.\n const part = on && !geo.covers[this.top];\n const hide = this.mode === 'switch' && part && this.seen >= 100;\n return `compare-${this.mode} framed${on ? ' top-on' : ''}${hide ? ' hide-base' : ''}${part && this.mode === 'wipe' ? ' top-part' : ''}${starting}`;\n }\n\n get stackStyle(): string {\n const a = this.mode === 'switch' ? 100 : this.value;\n const base = `--uvalib-compare: ${a}%; --uvalib-compare-opacity: ${a / 100}`;\n const geo = this.natural() ? this.geo : null;\n return geo ? `${base}; --uvalib-compare-n: ${a}; ${place(geo.boxes[0]!)}` : base;\n }\n\n /**\n * With a different framing, where the outlines of regions go: the original's box in the\n * stack, as `<uvalib-image-regions>`'s overlay inset. Empty otherwise.\n */\n get regionsStyle(): string {\n const geo = this.natural() ? this.geo : null;\n if (!geo) return '';\n const b = geo.boxes[0]!;\n return `--uvalib-image-regions-inset: ${r4(b.y)}% ${r4(100 - b.x - b.w)}% ${r4(100 - b.y - b.h)}% ${r4(b.x)}%`;\n }\n\n /** The other versions' images (each requested on first use), the divider and the side labels. */\n layers() {\n const top = this.top;\n const on = this.seen > 0;\n const size = this.natural();\n const geo = size ? this.geo : null;\n // The stack's size, reserved from the frames and the original: a canvas of the whole box\n // at the original's scale (never drawn on), sized like the image it stands for.\n const sizer =\n geo && size\n ? (() => {\n const w = size.w * geo.uw;\n const h = size.h * geo.uh;\n const k = Math.min(1, MAX_SIDE / Math.max(w, h));\n return html`<canvas\n class=\"frame-box\"\n aria-hidden=\"true\"\n width=${Math.max(1, Math.round(w * k))}\n height=${Math.max(1, Math.round(h * k))}\n ></canvas>`;\n })()\n : nothing;\n const layers = this.list.map((v, i) =>\n i === 0\n ? nothing\n : html`<img\n class=\"top ${i === top && on ? 'on' : ''}\"\n style=${geo && v.frame ? place(geo.boxes[i]!) : nothing}\n data-version=${i}\n alt=\"\"\n decoding=\"async\"\n draggable=\"false\"\n src=${this.requested.has(i) ? this.host.size(v.href) : nothing}\n @load=${() => this.loaded(i)}\n @error=${() => this.errored(i)}\n />`,\n );\n if (this.mode !== 'wipe') return html`${sizer}${layers}`;\n const a = this.seen;\n return html`${sizer}${layers}\n <div class=\"divider\" aria-hidden=\"true\"><span class=\"handle\"></span></div>\n <span class=\"side side-start\" aria-hidden=\"true\" ?hidden=${a <= 0}>${this.label(top)}</span>\n <span class=\"side side-end\" aria-hidden=\"true\" ?hidden=${a >= 100}>${this.label(0)}</span>`;\n }\n\n /** Notes of the versions on screen, then the controls. `slot` puts them under regions' image. */\n controls(slot: string) {\n const a = this.named;\n const top = this.top;\n // Every note keeps its line (hidden while its version is not on screen), so showing\n // another version never moves the photo or the controls.\n const visible = (i: number) => (i === 0 ? a < 100 : i === top && a > 0);\n const notes = this.list.map((v, i) =>\n v.note\n ? html`<p class=\"note\" ?data-off=${!visible(i)}><strong>${v.label}:</strong> ${v.note}</p>`\n : nothing,\n );\n const failed =\n this.failed.has(top) && this.amount > 0\n ? html`<p class=\"note\">${this.label(top)} could not be loaded.</p>`\n : nothing;\n const seg = (pressed: boolean, text: string, onClick: () => void) =>\n html`<button\n type=\"button\"\n class=\"seg\"\n aria-pressed=${pressed ? 'true' : 'false'}\n @click=${onClick}\n >\n ${text}\n </button>`;\n const l0 = this.label(0);\n const lk = this.label(this.other);\n // Both panels are always drawn, in one grid cell: the row is as tall as the taller one,\n // so changing mode never moves the photo (the dialog re-centres on any height change).\n // The other panel is inert and hidden, out of the tab order and the accessibility tree.\n const switching = this.mode === 'switch';\n const panel = (on: boolean, body: unknown) =>\n html`<div class=\"mode-panel\" ?inert=${!on} ?data-off=${!on}>${body}</div>`;\n const switchPanel = html`<div class=\"seg-group\" role=\"group\" aria-label=\"Version shown\">\n ${this.list.map((v, i) =>\n seg(this.shown === i, v.label, () => this.change(() => (this.shown = i))),\n )}\n </div>`;\n const sliding = html`${\n this.list.length > 2\n ? html`<div class=\"seg-group\" role=\"group\" aria-label=\"Compare ${l0} with\">\n ${this.list.map((v, i) =>\n i\n ? seg(this.other === i, v.label, () => this.change(() => (this.other = i)))\n : nothing,\n )}\n </div>`\n : nothing\n }\n <div class=\"slider\">\n <label for=${this.uid}>${this.mode === 'fade' ? 'Fade to' : 'Reveal'} ${lk}</label>\n <input\n id=${this.uid}\n type=\"range\"\n min=\"0\"\n max=\"100\"\n step=\"1\"\n .value=${String(this.value)}\n aria-valuetext=\"${this.value}% ${lk}\"\n @input=${this.onInput}\n @keydown=${this.onSliderKey}\n />\n </div>\n <div class=\"seg-group\" role=\"group\" aria-label=\"Jump to\">\n ${[\n [0, l0],\n [50, '50/50'],\n [100, lk],\n ].map(\n ([v, text]) =>\n html`<button\n type=\"button\"\n class=\"jump\"\n @click=${() => this.change(() => (this.value = v as number))}\n >\n ${text}\n </button>`,\n )}\n </div>\n <button\n type=\"button\"\n class=\"hold\"\n aria-keyshortcuts=\"O\"\n ?data-held=${this.holding}\n @pointerdown=${this.onHold}\n @pointerup=${this.onHold}\n @pointerleave=${this.onHold}\n @pointercancel=${this.onHold}\n @keydown=${this.onHold}\n @keyup=${this.onHold}\n @blur=${() => this.hold(false)}\n @contextmenu=${(e: Event) => e.preventDefault()}\n >\n Hold for ${l0}\n </button>`;\n return html`<div class=\"compare\" part=\"compare\" slot=${slot || nothing}>\n ${notes}${failed}\n <div class=\"compare-bar\">\n <div class=\"seg-group\" role=\"group\" aria-label=\"Compare versions\">\n ${MODES.map((m) => seg(this.mode === m, MODE_NAMES[m], () => this.setMode(m)))}\n </div>\n <div class=\"mode-panels\">${panel(switching, switchPanel)}${panel(!switching, sliding)}</div>\n </div>\n <p class=\"visually-hidden\" role=\"status\">${this.message}</p>\n </div>`;\n }\n\n /**\n * Full size, in every mode: the original and the version shown (Switch) or compared (Reveal,\n * Fade), each named. The same two links in every mode keep the toolbar's height, so changing\n * mode never moves the photo; and a visitor can always open the original at full size.\n */\n full(): { href: string; label: string }[] {\n const k = this.mode === 'switch' ? this.shown || this.other : this.other;\n return [0, k].map((i) => ({ href: this.list[i]!.href, label: this.label(i) }));\n }\n}\n"],"mappings":";;;;AAYA,IAAMO,IAAuB;CAAC;CAAU;CAAQ;AAAM,GAChDC,IAA0C;CAC9C,QAAQ;CACR,MAAM;CACN,MAAM;AACR,GAGaC,IAAgB,EAAE,QAAQ,IAAI,GA+BrCC,IAAW;AAEjB,SAASC,EAAQ,GA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K,SAAS,SAAS,YAAY,SAAS,GAAG6E,EAAG;;eAEpE,KAAK,IAAI;;;;;mBAKL,OAAO,KAAK,KAAK,EAAE;4BACV,KAAK,MAAM,IAAIA,EAAG;mBAC3B,KAAK,QAAQ;qBACX,KAAK,YAAY;;;;UAI5B;GACA,CAAC,GAAGD,CAAE;GACN,CAAC,IAAI,OAAO;GACZ,CAAC,KAAKC,CAAE;EACV,CAAC,CAAC,KACC,CAACjE,GAAGwB,OACH,CAAI;;;6BAGa,KAAK,aAAc,KAAK,QAAQxB,CAAY,EAAE;;gBAE3DwB,EAAK;sBAEb,EAAE;;;;;;qBAMW,KAAK,QAAQ;uBACX,KAAK,OAAO;qBACd,KAAK,OAAO;wBACT,KAAK,OAAO;yBACX,KAAK,OAAO;mBAClB,KAAK,OAAO;iBACd,KAAK,OAAO;sBACP,KAAK,KAAK,EAAK,EAAE;wBACf,MAAa,EAAE,eAAe,EAAE;;mBAErCwC,EAAG;;EAElB,OAAO,CAAI,4CAA4CqB,KAAQjG,EAAQ;QACnEuF,IAAQC,EAAO;;;YAGXlF,EAAM,KAAK,MAAMmF,EAAI,KAAK,SAAS9B,GAAGpD,EAAWoD,UAAU,KAAK,QAAQA,CAAC,CAAC,CAAC,EAAE;;mCAEtDkC,EAAMD,GAAWG,CAAW,IAAIF,EAAM,CAACD,GAAWI,CAAO,EAAE;;iDAE7C,KAAK,QAAQ;;CAE5D;CAOA,OAA0C;EAExC,OAAO,CAAC,GADE,KAAK,SAAS,YAAW,KAAK,SAAS,KAAK,KAC1C,CAAC,CAAC,KAAK,OAAO;GAAE,MAAM,KAAK,KAAKzC,EAAE,CAAE;GAAM,OAAO,KAAK,MAAMA,CAAC;EAAE,EAAE;CAC/E;AACF"}
@@ -79,7 +79,7 @@ function h(e, t, n, r = Infinity) {
79
79
  }
80
80
  function g(e) {
81
81
  let t = (e) => e.priorityPlacement || Infinity;
82
- return [...e].sort((e, n) => t(e) - t(n) || e.title.localeCompare(n.title));
82
+ return e.toSorted((e, n) => t(e) - t(n) || e.title.localeCompare(n.title));
83
83
  }
84
84
  var _ = (e) => {
85
85
  let [t, n, r] = e.split("-").map(Number);
@@ -178,4 +178,4 @@ function F(e, t = document) {
178
178
  }
179
179
  export { r as a, S as c, C as d, w as f, b as h, n as i, F as l, D as m, k as n, h as o, g as p, T as r, f as s, y as t, i as u };
180
180
 
181
- //# sourceMappingURL=hours-data-Bw6vkIw7.js.map
181
+ //# sourceMappingURL=hours-data-gMu5uT7H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hours-data-gMu5uT7H.js","names":["fetchJsonWith","fetchJson$1","formatter","hoursEndpoints","hoursTiming","setHoursEndpoints","key","value","from","globalApplied","endpoints","fetchJson","url","orUndefined","v","parseLibraries","data","json","n","a","calId","uri","siteLink","node","librariesCache","loadLibraries","p","promise","hoursCache","HOURS_CACHE_MAX","loadHours","sorted","ids","b","to","hit","maxAge","out","c","lid","entry","sortLibraries","rank","l","libs","utc","y","m","d","iso","date","addDays","days","weekStart","fmt","options","longDate","shortDate","shortWeekday","fullDate","headingDate","weekHeadingDate","formatTime","time","ampm","formatDay","day","h","ALLOWED","DROPPED","SAFE_PROTOCOLS","safeHref","href","base","copyAllowed","doc","name","el","sanitizeHoursHtml","parsed","html"],"sources":["../../src/components/library-hours/hours-data.ts"],"sourcesContent":["// Shared data and formatting for the library-hours components. Internal: not exported from\n// the package entry (only the LibraryInfo and DayHours types are). No side effects on import.\n\nimport { fetchJson as fetchJsonWith } from '../../data/fetch-json.js';\nimport { TIME_ZONE, formatter, todayInNewYork } from '../../data/new-york.js';\n\n/** One day's hours from LibCal: a status and, when open, one or more ranges. */\nexport interface DayHours {\n /** `open`, `closed`, `24hours`, or another LibCal status, shown as is. */\n status: string;\n /** Opening ranges, LibCal's own text (`9:00am` to `12:00am`); `to` may be past midnight. */\n hours?: { from: string; to: string }[];\n}\n\n/** A library (or a space inside one) from the Drupal JSON:API, reduced to the fields used. */\nexport interface LibraryInfo {\n /** Drupal node UUID. */\n id: string;\n title: string;\n shortTitle?: string;\n slug?: string;\n /** LibCal calendar id. */\n calId?: number;\n /** `Library`, `space` or `other-professional`. */\n placeType?: string;\n priorityPlacement?: number;\n /** Site link, with Drupal's `internal:` prefix removed (other schemes are kept as is). */\n siteLink?: string;\n /** Drupal's processed `field_hours_information` HTML. Sanitise before display. */\n hoursInformation?: string;\n /** Parent library's node UUID. */\n parent?: string;\n}\n\n/** Hours per LibCal calendar id, each a map of `YYYY-MM-DD` to that day's hours. */\nexport type HoursByCalendar = Map<number, Record<string, DayHours>>;\n\n/** The two data URLs. */\nexport interface HoursEndpoints {\n /** The Drupal JSON:API library list (relative by default: same origin, no CORS). */\n libraries: string;\n /** LibCal hours, with `{ids}` for the comma-separated calendar ids; `from` / `to` are appended. */\n hours: string;\n}\n\n/**\n * Where the data comes from, shared by every hours element (and exposed to pages as the\n * elements' static `endpoints`). The LibCal key is LibCal's public client widget key\n * (already public in the live bundles). A page can also set `window.uvalibHoursEndpoints`\n * (`{ libraries?, hours? }`) before the elements' script runs; it is merged in at the\n * first fetch. Requests are cached by URL, so a change applies to the next load.\n */\nexport const hoursEndpoints: HoursEndpoints = {\n libraries: '/jsonapi/index/default_index?filter[type]=library&page[limit]=100',\n hours:\n 'https://cal.lib.virginia.edu/api/1.0/hours/{ids}?iid=863&key=e4b27d40b7099e8e392113da2f8bf30a',\n};\n\n/**\n * Fetch attempts, the delay between them (ms), each attempt's timeout (ms), and how often\n * elements check the date (ms).\n */\nexport const hoursTiming = { retries: 3, retryDelay: 1000, timeout: 10_000, tick: 60_000 };\n\ndeclare global {\n interface Window {\n /** Optional endpoint overrides for the library-hours elements, read at their first fetch. */\n uvalibHoursEndpoints?: Partial<HoursEndpoints>;\n }\n}\n\n/** Copy the known endpoint keys (strings only) from `from` into the shared endpoints. */\nexport function setHoursEndpoints(from: Partial<HoursEndpoints> | null | undefined): void {\n for (const key of ['libraries', 'hours'] as const) {\n const value = from?.[key];\n if (typeof value === 'string' && value) hoursEndpoints[key] = value;\n }\n}\n\nlet globalApplied = false;\n/** The endpoints to use now: the page's `window.uvalibHoursEndpoints` is merged in once. */\nfunction endpoints(): HoursEndpoints {\n if (!globalApplied) {\n globalApplied = true;\n setHoursEndpoints(globalThis.window?.uvalibHoursEndpoints);\n }\n return hoursEndpoints;\n}\n\nexport { TIME_ZONE, todayInNewYork };\n\n// --- fetching -------------------------------------------------------------------------\n\nconst fetchJson = (url: string) => fetchJsonWith(url, hoursTiming);\n\ninterface RawLibrary {\n id: string;\n attributes: {\n title: string;\n field_short_title?: string | null;\n field_slug?: string | null;\n field_libcal_id?: string | number | null;\n field_type_basic?: string | null;\n field_priority_placement?: number | null;\n field_library_site_link?: { uri?: string } | null;\n field_hours_information?: { processed?: string } | null;\n };\n relationships?: { field_parent?: { data?: { id?: string } | null } };\n}\n\nconst orUndefined = <T>(v: T | null | undefined): T | undefined => v ?? undefined;\n\n/** Reduce a JSON:API response to LibraryInfo, in response order. */\nexport function parseLibraries(json: unknown): LibraryInfo[] {\n const data = (json as { data?: RawLibrary[] } | null)?.data;\n if (!Array.isArray(data)) return [];\n return data\n .filter((n) => n?.id && n.attributes?.title)\n .map((n) => {\n const a = n.attributes;\n const calId = parseInt(String(a.field_libcal_id ?? ''), 10);\n const uri = a.field_library_site_link?.uri;\n return {\n id: n.id,\n title: a.title,\n shortTitle: orUndefined(a.field_short_title),\n slug: orUndefined(a.field_slug),\n calId: Number.isNaN(calId) ? undefined : calId,\n placeType: orUndefined(a.field_type_basic),\n priorityPlacement: orUndefined(a.field_priority_placement),\n siteLink: siteLink(uri),\n hoursInformation: orUndefined(a.field_hours_information?.processed),\n parent: orUndefined(n.relationships?.field_parent?.data?.id),\n };\n });\n}\n\n/**\n * A Drupal link field as an href: `internal:/rmc/` becomes `/rmc/` and `entity:node/807`\n * becomes `/node/807` (Drupal redirects it to the page's alias). Other `entity:` links have\n * no URL outside Drupal, so they are dropped.\n */\nfunction siteLink(uri: string | undefined): string | undefined {\n if (!uri) return undefined;\n if (uri.startsWith('internal:')) return uri.slice('internal:'.length) || undefined;\n const node = /^entity:node\\/(\\d+)$/.exec(uri);\n if (node) return `/node/${node[1]}`;\n return uri.startsWith('entity:') ? undefined : uri;\n}\n\nconst librariesCache = new Map<string, Promise<LibraryInfo[]>>();\n\n/** The library list, fetched once per page (per URL) and shared. A failure is not cached. */\nexport function loadLibraries(): Promise<LibraryInfo[]> {\n const url = endpoints().libraries;\n let p = librariesCache.get(url);\n if (!p) {\n const promise = fetchJson(url).then(parseLibraries);\n librariesCache.set(url, (p = promise));\n promise.catch(() => {\n if (librariesCache.get(url) === promise) librariesCache.delete(url);\n });\n }\n return p;\n}\n\ninterface CacheEntry {\n at: number;\n promise: Promise<HoursByCalendar>;\n}\nconst hoursCache = new Map<string, CacheEntry>();\nconst HOURS_CACHE_MAX = 50;\n\n/**\n * Hours for LibCal calendars `ids` from `from` to `to` (inclusive, `YYYY-MM-DD`, at most\n * 100 days). Identical requests share one fetch; a cached result older than `maxAge` ms is\n * fetched again. A failure is not cached.\n */\nexport function loadHours(\n ids: number[],\n from: string,\n to: string,\n maxAge = Infinity,\n): Promise<HoursByCalendar> {\n const sorted = [...new Set(ids)].sort((a, b) => a - b);\n if (!sorted.length) return Promise.resolve(new Map());\n const url =\n endpoints().hours.replace('{ids}', sorted.join(',')) +\n `&from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}`;\n const key = url;\n const hit = hoursCache.get(key);\n if (hit && performance.now() - hit.at <= maxAge) return hit.promise;\n const promise = fetchJson(url).then((json) => {\n const out: HoursByCalendar = new Map();\n if (Array.isArray(json)) {\n for (const c of json as { lid?: unknown; dates?: unknown }[]) {\n const lid = Number(c?.lid);\n if (Number.isFinite(lid) && c.dates && typeof c.dates === 'object')\n out.set(lid, c.dates as Record<string, DayHours>);\n }\n }\n return out;\n });\n const entry = { at: performance.now(), promise };\n hoursCache.delete(key);\n hoursCache.set(key, entry);\n if (hoursCache.size > HOURS_CACHE_MAX) hoursCache.delete(hoursCache.keys().next().value!);\n promise.catch(() => {\n if (hoursCache.get(key) === entry) hoursCache.delete(key);\n });\n return promise;\n}\n\n/** Forget the cached library list and hours (for tests). */\nexport function resetHoursCache(): void {\n librariesCache.clear();\n hoursCache.clear();\n globalApplied = false;\n}\n\n/** Libraries by priority placement (missing last), then title. Returns a new array. */\nexport function sortLibraries(libs: readonly LibraryInfo[]): LibraryInfo[] {\n const rank = (l: LibraryInfo) => l.priorityPlacement || Infinity;\n return libs.toSorted((a, b) => rank(a) - rank(b) || a.title.localeCompare(b.title));\n}\n\n// --- dates: all arithmetic on YYYY-MM-DD strings, in UTC -------------------------------\n\nconst utc = (iso: string): Date => {\n const [y, m, d] = iso.split('-').map(Number) as [number, number, number];\n return new Date(Date.UTC(y, m - 1, d));\n};\nconst iso = (date: Date): string => date.toISOString().slice(0, 10);\n\nexport function addDays(date: string, days: number): string {\n const d = utc(date);\n d.setUTCDate(d.getUTCDate() + days);\n return iso(d);\n}\n\n/** The Sunday on or before `date`. */\nexport function weekStart(date: string): string {\n return addDays(date, -utc(date).getUTCDay());\n}\n\nconst fmt = (key: string, options: Intl.DateTimeFormatOptions) => (date: string) =>\n formatter(key, { ...options, timeZone: 'UTC' }).format(utc(date));\n\n/** \"Monday, November 9\" */\nexport const longDate = fmt('long', { weekday: 'long', month: 'long', day: 'numeric' });\n/** \"Nov 9\" */\nexport const shortDate = fmt('short', { month: 'short', day: 'numeric' });\n/** \"Mon\" */\nexport const shortWeekday = fmt('weekday', { weekday: 'short' });\n/** \"Saturday, November 14, 2026\" */\nexport const fullDate = fmt('full', {\n weekday: 'long',\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n});\nconst headingDate = fmt('heading', { year: 'numeric', month: 'short', day: '2-digit' });\n/** \"Nov 08. 2026\": the live week heading's format, kept because Drupal's /hours shows it. */\nexport const weekHeadingDate = (date: string): string => headingDate(date).replace(',', '.');\n\n// --- hours text ----------------------------------------------------------------------\n\n/** `9:00am` → `9am`, `5:30pm` → `5:30pm`; anything else unchanged. */\nexport function formatTime(time: string): string {\n const m = /^(\\d+):(\\d+)\\s*(am|pm)$/i.exec(time.trim());\n if (!m) return time;\n const ampm = m[3]!.toLowerCase();\n return m[2] === '00' ? `${m[1]}${ampm}` : `${m[1]}:${m[2]}${ampm}`;\n}\n\n/** A day's hours as text: `9am - 6pm` (ranges joined by commas), `24 Hours`, `closed`, or ''. */\nexport function formatDay(day: DayHours | undefined): string {\n if (!day) return '';\n if (Array.isArray(day.hours) && day.hours.length)\n return day.hours.map((h) => `${formatTime(h.from)} - ${formatTime(h.to)}`).join(', ');\n return (day.status ?? '').replace('24hours', '24 Hours').replace('ByApp', 'By Appt').trim();\n}\n\n// --- HTML from Drupal ----------------------------------------------------------------\n\nconst ALLOWED = new Set(['a', 'p', 'br', 'strong', 'em']);\n/** Dropped with their content; any other element is unwrapped (its content kept). */\nconst DROPPED = new Set([\n 'script',\n 'style',\n 'template',\n 'iframe',\n 'object',\n 'embed',\n 'noscript',\n 'svg',\n 'math',\n 'title',\n 'textarea',\n 'select',\n 'img',\n 'video',\n 'audio',\n 'head',\n]);\nconst SAFE_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'tel:']);\n\nfunction safeHref(href: string, base: string): boolean {\n try {\n return SAFE_PROTOCOLS.has(new URL(href, base).protocol);\n } catch {\n return false;\n }\n}\n\nfunction copyAllowed(from: Node, to: Node, doc: Document): void {\n for (const node of from.childNodes) {\n if (node.nodeType === Node.TEXT_NODE) {\n to.appendChild(doc.createTextNode((node as Text).data));\n } else if (node.nodeType === Node.ELEMENT_NODE) {\n const name = (node as Element).localName;\n if (ALLOWED.has(name)) {\n const el = doc.createElement(name);\n const href = (node as Element).getAttribute('href');\n if (name === 'a' && href && safeHref(href, doc.baseURI)) el.setAttribute('href', href);\n copyAllowed(node, el, doc);\n to.appendChild(el);\n } else if (!DROPPED.has(name)) {\n copyAllowed(node, to, doc);\n }\n }\n }\n}\n\n/**\n * Drupal's hours HTML reduced to an allowlist (`a[href]` with an http(s), mailto, tel or\n * relative URL, `p`, `br`, `strong`, `em`), as new nodes owned by `doc`. It is parsed in an\n * inert document, so nothing in it runs or loads. The same walk is used in every browser\n * (rather than `setHTML` where available) so the output never differs between browsers.\n */\nexport function sanitizeHoursHtml(html: string, doc: Document = document): DocumentFragment {\n const out = doc.createDocumentFragment();\n let parsed: Document;\n try {\n parsed = new DOMParser().parseFromString(html, 'text/html');\n } catch {\n // For example a page enforcing Trusted Types: fall back to the text alone.\n out.append(doc.createTextNode(html.replace(/<[^>]*>/g, '')));\n return out;\n }\n copyAllowed(parsed.body, out, doc);\n return out;\n}\n"],"mappings":";;;AAoDA,IAAaG,IAAiC;CAC5C,WAAW;CACX,OACE;AACJ,GAMaC,IAAc;CAAE,SAAS;CAAG,YAAY;CAAM,SAAS;CAAQ,MAAM;AAAO;AAUzF,SAAgBC,EAAkB,GAAwD;CACxF,KAAK,IAAMC,KAAO,CAAC,aAAa,OAAO,GAAY;EACjD,IAAMC,IAAQC,IAAOF;EACrB,AAAI,OAAOC,KAAU,YAAYA,MAAO,EAAeD,KAAOC;CAChE;AACF;AAEA,IAAIE,IAAgB;AAEpB,SAASC,IAA4B;CAKnC,OAJKD,MACH,IAAgB,IAChBJ,EAAkB,WAAW,QAAQ,oBAAoB,IAEpDF;AACT;AAMA,IAAMQ,KAAa,MAAgBX,EAAcY,GAAKR,CAAW,GAiB3DS,KAAkB,MAA2CC,KAAK,KAAA;AAGxE,SAAgBC,EAAe,GAA8B;CAC3D,IAAMC,IAAQC,GAAyC;CAEvD,OADK,MAAM,QAAQD,CAAI,IAChBA,EACJ,QAAQ,MAAME,GAAG,MAAMA,EAAE,YAAY,KAAK,CAAC,CAC3C,KAAK,MAAM;EACV,IAAMC,IAAID,EAAE,YACNE,IAAQ,SAAS,OAAOD,EAAE,mBAAmB,EAAE,GAAG,EAAE,GACpDE,IAAMF,EAAE,yBAAyB;EACvC,OAAO;GACL,IAAID,EAAE;GACN,OAAOC,EAAE;GACT,YAAYN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E;EACnB,OAAO,AAAKR,EAAQ,IAAIO,CAAI,KAC1BF,EAAYnD,GAAMW,GAAIyC,CAAG;CAE7B;AAEJ;AAQA,SAAgBG,EAAkB,GAAc,IAAgB,UAA4B;CAC1F,IAAMzC,IAAMsC,EAAI,uBAAuB,GACnCI;CACJ,IAAI;EACF,IAAS,IAAI,UAAU,CAAC,CAAC,gBAAgBC,GAAM,WAAW;CAC5D,QAAQ;EAGN,OADA3C,EAAI,OAAOsC,EAAI,eAAeK,EAAK,QAAQ,YAAY,EAAE,CAAC,CAAC,GACpD3C;CACT;CAEA,OADAqC,EAAYK,EAAO,MAAM1C,GAAKsC,CAAG,GAC1BtC;AACT"}
@@ -3,7 +3,7 @@ import { a as u, i as d } from "./analytics-DTTihuBD.js";
3
3
  import { t as f } from "./heading-level-DIuNS44-.js";
4
4
  import { t as p } from "./accessible-DJv7YOtS.js";
5
5
  import { r as m } from "./new-york-DkcnqvJ4.js";
6
- import { a as h, c as g, d as _, f as v, h as y, i as b, m as x, n as S, o as C, r as w, s as T, t as E, u as D } from "./hours-data-Bw6vkIw7.js";
6
+ import { a as h, c as g, d as _, f as v, h as y, i as b, m as x, n as S, o as C, r as w, s as T, t as E, u as D } from "./hours-data-gMu5uT7H.js";
7
7
  // src/components/library-weekly-hours/LibraryWeeklyHours.ts
8
8
  var O = 0, k = (e) => `
9
9
  ${e} { display: block; }
@@ -86,6 +86,7 @@ var O = 0, k = (e) => `
86
86
  font-size: 1.25rem;
87
87
  font-weight: bold;
88
88
  color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));
89
+ text-wrap: balance;
89
90
  }
90
91
  `
91
92
  ];
@@ -352,4 +353,4 @@ a([e({
352
353
  attribute: "headinglevelstart"
353
354
  })], j.prototype, "headingLevelStart", void 0), a([n()], j.prototype, "inferredLevel", void 0), a([n()], j.prototype, "_state", void 0), a([n()], j.prototype, "today", void 0), a([n()], j.prototype, "view", void 0), a([n()], j.prototype, "pending", void 0), a([n()], j.prototype, "announcement", void 0), i("library-weekly-hours", j);
354
355
 
355
- //# sourceMappingURL=library-weekly-hours-CrV3TlP5.js.map
356
+ //# sourceMappingURL=library-weekly-hours-BJgxAyah.js.map