@wodira/browser 1.1.0 → 1.2.1
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/CHANGELOG.md +24 -1
- package/README.md +106 -1
- package/dist/index.cjs +36 -0
- package/dist/index.d.ts +90 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/boxes/cdn.js +15 -15
- package/dist/ui/components.d.ts +18 -1
- package/dist/ui/components.d.ts.map +1 -1
- package/dist/ui/events.d.ts +1 -1
- package/dist/ui/events.d.ts.map +1 -1
- package/dist/ui/i18n.d.ts +1 -1
- package/dist/ui/i18n.d.ts.map +1 -1
- package/dist/ui/{index-tfej862z.js → index-1zshfsk6.js} +45 -1563
- package/dist/ui/index-3qe91gk8.js +1625 -0
- package/dist/ui/index-bjb0t7yn.js +1624 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +290 -125
- package/dist/ui/map-view-rn3jgtqn.js +28737 -0
- package/dist/ui/maplibre-gl-worker.mjs +10 -0
- package/dist/ui/route-3d/cdn.d.ts +2 -0
- package/dist/ui/route-3d/cdn.d.ts.map +1 -0
- package/dist/ui/route-3d/cdn.js +1527 -0
- package/dist/ui/route-3d/gpx.d.ts +14 -0
- package/dist/ui/route-3d/gpx.d.ts.map +1 -0
- package/dist/ui/route-3d/index.d.ts +12 -0
- package/dist/ui/route-3d/index.d.ts.map +1 -0
- package/dist/ui/route-3d/index.js +16 -0
- package/dist/ui/route-3d/map-view.d.ts +73 -0
- package/dist/ui/route-3d/map-view.d.ts.map +1 -0
- package/dist/ui/route-3d/maplibre-gl-worker.mjs +10 -0
- package/dist/ui/route-3d/route-3d.d.ts +168 -0
- package/dist/ui/route-3d/route-3d.d.ts.map +1 -0
- package/dist/ui/route-3d/route-geo.d.ts +77 -0
- package/dist/ui/route-3d/route-geo.d.ts.map +1 -0
- package/dist/ui/shirt-sponsors/cdn.js +29 -27
- package/dist/ui/shirt-sponsors/index.js +5 -3
- package/dist/ui/shirt-sponsors/shirt-auction.d.ts +19 -0
- package/dist/ui/shirt-sponsors/shirt-auction.d.ts.map +1 -1
- package/package.json +15 -6
|
@@ -0,0 +1,1624 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__preload,
|
|
3
|
+
__chunks,
|
|
4
|
+
css,
|
|
5
|
+
html,
|
|
6
|
+
nothing,
|
|
7
|
+
_$LH,
|
|
8
|
+
LitElement,
|
|
9
|
+
directive,
|
|
10
|
+
Directive,
|
|
11
|
+
createWodiraBrowserClient
|
|
12
|
+
} from "./index-1zshfsk6.js";
|
|
13
|
+
|
|
14
|
+
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/development/directive-helpers.js
|
|
15
|
+
var { _ChildPart: ChildPart } = _$LH;
|
|
16
|
+
var ENABLE_SHADYDOM_NOPATCH = true;
|
|
17
|
+
var wrap = ENABLE_SHADYDOM_NOPATCH && window.ShadyDOM?.inUse && window.ShadyDOM?.noPatch === true ? window.ShadyDOM.wrap : (node) => node;
|
|
18
|
+
var RESET_VALUE = {};
|
|
19
|
+
var setCommittedValue = (part, value = RESET_VALUE) => part._$committedValue = value;
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/development/directives/keyed.js
|
|
22
|
+
class Keyed extends Directive {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.key = nothing;
|
|
26
|
+
}
|
|
27
|
+
render(k, v) {
|
|
28
|
+
this.key = k;
|
|
29
|
+
return v;
|
|
30
|
+
}
|
|
31
|
+
update(part, [k, v]) {
|
|
32
|
+
if (k !== this.key) {
|
|
33
|
+
setCommittedValue(part);
|
|
34
|
+
this.key = k;
|
|
35
|
+
}
|
|
36
|
+
return v;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
var keyed = directive(Keyed);
|
|
40
|
+
// src/ui/styles.ts
|
|
41
|
+
var wodiraUiStyles = css`
|
|
42
|
+
:host {
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
color: var(--wodira-color-text, #17132e);
|
|
45
|
+
display: block;
|
|
46
|
+
font-family: var(--wodira-font-family, inherit);
|
|
47
|
+
font-size: var(--wodira-font-size, 1rem);
|
|
48
|
+
line-height: 1.5;
|
|
49
|
+
container-type: inline-size;
|
|
50
|
+
min-width: 0;
|
|
51
|
+
overflow-wrap: anywhere;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
*,
|
|
55
|
+
*::before,
|
|
56
|
+
*::after {
|
|
57
|
+
box-sizing: inherit;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[hidden] {
|
|
61
|
+
display: none !important;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[part~='stack'] {
|
|
65
|
+
display: grid;
|
|
66
|
+
gap: var(--wodira-space, 1rem);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
[part~='grid'] {
|
|
70
|
+
display: grid;
|
|
71
|
+
gap: var(--wodira-space, 1rem);
|
|
72
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--wodira-grid-min, 15rem)), 1fr));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
[part~='card'] {
|
|
76
|
+
background: var(--wodira-color-surface, #fff);
|
|
77
|
+
border: 1px solid var(--wodira-color-border, #dcd9e3);
|
|
78
|
+
border-radius: var(--wodira-radius, 1rem);
|
|
79
|
+
box-shadow: var(--wodira-shadow, 0 4px 18px rgb(23 19 46 / 0.04));
|
|
80
|
+
padding: var(--wodira-card-padding, clamp(1rem, 3cqi, 1.75rem));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[part~='button'] {
|
|
84
|
+
align-items: center;
|
|
85
|
+
background: var(--wodira-color-primary, #17132e);
|
|
86
|
+
border: 0;
|
|
87
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
88
|
+
color: var(--wodira-color-primary-contrast, #fff);
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
font: inherit;
|
|
92
|
+
font-weight: 700;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
min-height: var(--wodira-control-height, 2.75rem);
|
|
95
|
+
padding: 0.75rem 1rem;
|
|
96
|
+
transition:
|
|
97
|
+
opacity 0.2s ease,
|
|
98
|
+
transform 0.2s ease;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[part~='button']:hover:not(:disabled) {
|
|
102
|
+
transform: translateY(-1px);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[part~='button']:focus-visible,
|
|
106
|
+
[part~='input']:focus-visible,
|
|
107
|
+
[part~='select']:focus-visible,
|
|
108
|
+
[part~='textarea']:focus-visible,
|
|
109
|
+
[part~='checkbox']:focus-visible {
|
|
110
|
+
outline: 3px solid color-mix(in srgb, var(--wodira-color-accent, #c40072) 35%, transparent);
|
|
111
|
+
outline-offset: 2px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
[part~='button']:disabled {
|
|
115
|
+
cursor: not-allowed;
|
|
116
|
+
opacity: 0.6;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
[part~='button'][part~='secondary'] {
|
|
120
|
+
background: var(--wodira-color-muted, #f6f5f8);
|
|
121
|
+
color: var(--wodira-color-text, #17132e);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[part~='text-button'] {
|
|
125
|
+
justify-self: start;
|
|
126
|
+
min-height: auto;
|
|
127
|
+
padding: 0.45rem 0.7rem;
|
|
128
|
+
width: auto;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[part~='input'],
|
|
132
|
+
[part~='select'],
|
|
133
|
+
[part~='textarea'] {
|
|
134
|
+
background: var(--wodira-color-surface, #fff);
|
|
135
|
+
border: 1px solid var(--wodira-color-border, #dcd9e3);
|
|
136
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
137
|
+
color: var(--wodira-color-text, #17132e);
|
|
138
|
+
font: inherit;
|
|
139
|
+
min-height: var(--wodira-control-height, 2.75rem);
|
|
140
|
+
padding: 0.7rem 0.8rem;
|
|
141
|
+
width: 100%;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
[part~='input'][aria-invalid='true'],
|
|
145
|
+
[part~='select'][aria-invalid='true'],
|
|
146
|
+
[part~='textarea'][aria-invalid='true'] {
|
|
147
|
+
border-color: var(--wodira-color-danger, #b42318);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
[part~='textarea'] {
|
|
151
|
+
min-height: 5.5rem;
|
|
152
|
+
resize: vertical;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[part~='label'] {
|
|
156
|
+
display: grid;
|
|
157
|
+
gap: 0.35rem;
|
|
158
|
+
font-size: 0.92rem;
|
|
159
|
+
font-weight: 700;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
[part~='checkbox'] {
|
|
163
|
+
margin-inline-end: 0.5rem;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[part~='email-field'] {
|
|
167
|
+
min-width: 0;
|
|
168
|
+
}
|
|
169
|
+
[part~='email-suggestion'] {
|
|
170
|
+
display: flex;
|
|
171
|
+
flex-wrap: wrap;
|
|
172
|
+
align-items: center;
|
|
173
|
+
gap: 0.25rem;
|
|
174
|
+
margin-top: 0.5rem;
|
|
175
|
+
}
|
|
176
|
+
[part~='email-correction'] {
|
|
177
|
+
background: transparent;
|
|
178
|
+
color: var(--wodira-color-accent, #c40072);
|
|
179
|
+
min-height: 2.75rem;
|
|
180
|
+
max-width: 100%;
|
|
181
|
+
padding: 0.25rem 0.5rem;
|
|
182
|
+
overflow-wrap: anywhere;
|
|
183
|
+
}
|
|
184
|
+
[part~='email-delivery'] {
|
|
185
|
+
overflow-wrap: anywhere;
|
|
186
|
+
margin-top: 0.5rem;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
[part~='hint'],
|
|
190
|
+
[part~='meta'],
|
|
191
|
+
[part~='field-error'] {
|
|
192
|
+
color: var(--wodira-color-text-muted, #625e70);
|
|
193
|
+
font-size: 0.875rem;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[part~='description'] {
|
|
197
|
+
color: var(--wodira-color-text-muted, #625e70);
|
|
198
|
+
display: grid;
|
|
199
|
+
font-size: 0.95rem;
|
|
200
|
+
gap: 0.55rem;
|
|
201
|
+
line-height: 1.65;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
[part~='description'] p {
|
|
205
|
+
margin: 0;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
[part~='description-heading'] {
|
|
209
|
+
color: var(--wodira-color-text, #17132e);
|
|
210
|
+
font-weight: 800;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
[part~='description-list'] {
|
|
214
|
+
display: grid;
|
|
215
|
+
gap: 0.3rem;
|
|
216
|
+
margin: 0;
|
|
217
|
+
padding-inline-start: 1.15rem;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
[part~='event-card-description'] {
|
|
221
|
+
display: -webkit-box;
|
|
222
|
+
margin: 0;
|
|
223
|
+
max-width: 65ch;
|
|
224
|
+
overflow: hidden;
|
|
225
|
+
-webkit-box-orient: vertical;
|
|
226
|
+
-webkit-line-clamp: var(--wodira-event-card-description-lines, 4);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
[part~='event-card-description-full'] {
|
|
230
|
+
margin: 0;
|
|
231
|
+
max-width: 65ch;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
[part~='inline-code'] {
|
|
235
|
+
background: var(--wodira-color-muted, #f6f5f8);
|
|
236
|
+
border-radius: 0.35rem;
|
|
237
|
+
color: var(--wodira-color-text, #17132e);
|
|
238
|
+
font-family:
|
|
239
|
+
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
|
|
240
|
+
font-size: 0.9em;
|
|
241
|
+
padding: 0.08rem 0.28rem;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
[part~='field-error'] {
|
|
245
|
+
color: var(--wodira-color-danger, #b42318);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
[part~='eligibility-summary'] {
|
|
249
|
+
background: color-mix(
|
|
250
|
+
in srgb,
|
|
251
|
+
var(--wodira-color-accent, #c40072) 7%,
|
|
252
|
+
var(--wodira-color-surface, #fff)
|
|
253
|
+
);
|
|
254
|
+
border: 1px solid color-mix(in srgb, var(--wodira-color-accent, #c40072) 24%, transparent);
|
|
255
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
256
|
+
display: grid;
|
|
257
|
+
gap: 0.45rem;
|
|
258
|
+
padding: 0.8rem 0.9rem;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
[part~='eligibility-summary'] ul {
|
|
262
|
+
color: var(--wodira-color-text-muted, #625e70);
|
|
263
|
+
display: grid;
|
|
264
|
+
font-size: 0.875rem;
|
|
265
|
+
gap: 0.25rem;
|
|
266
|
+
margin: 0;
|
|
267
|
+
padding-inline-start: 1.2rem;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
[part~='gender-composition'] {
|
|
271
|
+
border: 0;
|
|
272
|
+
display: grid;
|
|
273
|
+
gap: 0.6rem;
|
|
274
|
+
margin: 0;
|
|
275
|
+
padding: 0;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
[part~='gender-composition'] legend {
|
|
279
|
+
font-weight: 800;
|
|
280
|
+
padding: 0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
[part~='gender-composition'] [part~='hint'] {
|
|
284
|
+
margin: 0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
[part~='composition-options'] {
|
|
288
|
+
display: grid;
|
|
289
|
+
gap: 0.6rem;
|
|
290
|
+
grid-template-columns: repeat(auto-fit, minmax(min(100%, 11.25rem), 1fr));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
[part~='composition-option'] {
|
|
294
|
+
align-items: center;
|
|
295
|
+
background: var(--wodira-color-surface, #fff);
|
|
296
|
+
border: 1px solid var(--wodira-color-border, #dcd9e3);
|
|
297
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
298
|
+
cursor: pointer;
|
|
299
|
+
display: flex;
|
|
300
|
+
font-weight: 700;
|
|
301
|
+
gap: 0.55rem;
|
|
302
|
+
min-height: var(--wodira-control-height, 2.75rem);
|
|
303
|
+
padding: 0.7rem 0.8rem;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
[part~='composition-option'][part~='selected'] {
|
|
307
|
+
background: color-mix(
|
|
308
|
+
in srgb,
|
|
309
|
+
var(--wodira-color-accent, #c40072) 10%,
|
|
310
|
+
var(--wodira-color-surface, #fff)
|
|
311
|
+
);
|
|
312
|
+
border-color: var(--wodira-color-accent, #c40072);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
[part~='composition-option']:focus-within {
|
|
316
|
+
outline: 3px solid color-mix(in srgb, var(--wodira-color-accent, #c40072) 35%, transparent);
|
|
317
|
+
outline-offset: 2px;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
[part~='participant-mode'] {
|
|
321
|
+
background: var(--wodira-color-muted, #f6f5f8);
|
|
322
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
323
|
+
display: grid;
|
|
324
|
+
gap: 0.25rem;
|
|
325
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
326
|
+
margin-block: 0.8rem;
|
|
327
|
+
padding: 0.25rem;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
[part~='participant-mode-button'] {
|
|
331
|
+
background: transparent;
|
|
332
|
+
border: 1px solid transparent;
|
|
333
|
+
border-radius: calc(var(--wodira-radius-sm, 0.625rem) * 0.75);
|
|
334
|
+
color: var(--wodira-color-text-muted, #625e70);
|
|
335
|
+
cursor: pointer;
|
|
336
|
+
font: inherit;
|
|
337
|
+
font-size: 0.875rem;
|
|
338
|
+
font-weight: 750;
|
|
339
|
+
min-height: 2.4rem;
|
|
340
|
+
padding: 0.55rem 0.75rem;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
[part~='participant-mode-button'][part~='active'] {
|
|
344
|
+
background: var(--wodira-color-surface, #fff);
|
|
345
|
+
border-color: var(--wodira-color-border, #dcd9e3);
|
|
346
|
+
box-shadow: 0 2px 8px rgb(15 23 42 / 0.08);
|
|
347
|
+
color: var(--wodira-color-text, #17132e);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
[part~='participant-mode-button']:focus-visible {
|
|
351
|
+
outline: 3px solid color-mix(in srgb, var(--wodira-color-accent, #c40072) 35%, transparent);
|
|
352
|
+
outline-offset: 2px;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
[part~='deferred-participant-hint'] {
|
|
356
|
+
background: var(--wodira-color-muted, #f6f5f8);
|
|
357
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
358
|
+
color: var(--wodira-color-text-muted, #625e70);
|
|
359
|
+
line-height: 1.5;
|
|
360
|
+
margin: 0.8rem 0 0;
|
|
361
|
+
padding: 0.8rem 0.9rem;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
[part~='error'] {
|
|
365
|
+
background: color-mix(in srgb, var(--wodira-color-danger, #b42318) 10%, transparent);
|
|
366
|
+
border: 1px solid color-mix(in srgb, var(--wodira-color-danger, #b42318) 35%, transparent);
|
|
367
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
368
|
+
color: var(--wodira-color-danger, #b42318);
|
|
369
|
+
padding: 0.75rem 0.9rem;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
[part~='success'] {
|
|
373
|
+
background: color-mix(in srgb, var(--wodira-color-success, #16703c) 12%, transparent);
|
|
374
|
+
border: 1px solid color-mix(in srgb, var(--wodira-color-success, #16703c) 35%, transparent);
|
|
375
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
376
|
+
color: var(--wodira-color-success, #16703c);
|
|
377
|
+
padding: 0.75rem 0.9rem;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
[part~='loader'],
|
|
381
|
+
[part~='empty'] {
|
|
382
|
+
color: var(--wodira-color-text-muted, #625e70);
|
|
383
|
+
padding: var(--wodira-space, 1rem);
|
|
384
|
+
text-align: center;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
[part~='title'] {
|
|
388
|
+
font-size: clamp(1.15rem, 2vw, 1.5rem);
|
|
389
|
+
font-weight: 800;
|
|
390
|
+
line-height: 1.15;
|
|
391
|
+
margin: 0;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
[part~='price'] {
|
|
395
|
+
color: var(--wodira-color-accent, #c40072);
|
|
396
|
+
font-size: 1.35rem;
|
|
397
|
+
font-weight: 850;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
[part~='tier-list'] {
|
|
401
|
+
display: grid;
|
|
402
|
+
gap: 0.55rem;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
[part~='tier-row'] {
|
|
406
|
+
align-items: center;
|
|
407
|
+
background: var(--wodira-color-muted, #f6f5f8);
|
|
408
|
+
border: 1px solid transparent;
|
|
409
|
+
border-radius: var(--wodira-radius-sm, 0.625rem);
|
|
410
|
+
display: grid;
|
|
411
|
+
gap: 0.35rem;
|
|
412
|
+
padding: 0.7rem 0.8rem;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
[part~='tier-row'][part~='current'] {
|
|
416
|
+
background: color-mix(
|
|
417
|
+
in srgb,
|
|
418
|
+
var(--wodira-color-accent, #c40072) 10%,
|
|
419
|
+
var(--wodira-color-surface, #fff)
|
|
420
|
+
);
|
|
421
|
+
border-color: color-mix(in srgb, var(--wodira-color-accent, #c40072) 45%, transparent);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
[part~='tier-heading'] {
|
|
425
|
+
align-items: center;
|
|
426
|
+
display: flex;
|
|
427
|
+
gap: 0.5rem;
|
|
428
|
+
justify-content: space-between;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
[part~='tier-name'] {
|
|
432
|
+
font-weight: 800;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
[part~='tier-price'] {
|
|
436
|
+
color: var(--wodira-color-accent, #c40072);
|
|
437
|
+
font-weight: 850;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
[part~='badge'] {
|
|
441
|
+
background: var(--wodira-color-accent, #c40072);
|
|
442
|
+
border-radius: 999px;
|
|
443
|
+
color: var(--wodira-color-accent-contrast, #fff);
|
|
444
|
+
display: inline-flex;
|
|
445
|
+
font-size: 0.72rem;
|
|
446
|
+
font-weight: 800;
|
|
447
|
+
letter-spacing: 0.02em;
|
|
448
|
+
padding: 0.2rem 0.5rem;
|
|
449
|
+
text-transform: uppercase;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
[part~='image'] {
|
|
453
|
+
aspect-ratio: 16 / 9;
|
|
454
|
+
border-radius: calc(var(--wodira-radius, 1rem) * 0.75);
|
|
455
|
+
display: block;
|
|
456
|
+
margin-block-end: var(--wodira-space, 1rem);
|
|
457
|
+
object-fit: cover;
|
|
458
|
+
width: 100%;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
[part~='summary-row'] {
|
|
462
|
+
display: flex;
|
|
463
|
+
justify-content: space-between;
|
|
464
|
+
gap: var(--wodira-space, 1rem);
|
|
465
|
+
}
|
|
466
|
+
`;
|
|
467
|
+
|
|
468
|
+
// src/ui/shirt-sponsors/shirt-auction.ts
|
|
469
|
+
var copy = {
|
|
470
|
+
es: {
|
|
471
|
+
label: "Patrocina la camiseta del evento",
|
|
472
|
+
loading: "Cargando camiseta y pujas…",
|
|
473
|
+
error: "No se ha podido cargar la campaña.",
|
|
474
|
+
invalid: "Configura una campaña y una clave publicable válidas.",
|
|
475
|
+
retry: "Reintentar",
|
|
476
|
+
shirtAria: "Camiseta 3D. Arrástrala para girarla y toca un espacio para elegirlo.",
|
|
477
|
+
hint: "Arrastra para girar · Toca un espacio para pujar",
|
|
478
|
+
noModel: "La vista 3D no está disponible en este dispositivo. Elige un espacio en la lista.",
|
|
479
|
+
zoomIn: "Acercar camiseta",
|
|
480
|
+
zoomOut: "Alejar camiseta",
|
|
481
|
+
views: "Vista de la camiseta",
|
|
482
|
+
slots: "Espacios",
|
|
483
|
+
closes: "Cierre de pujas",
|
|
484
|
+
shirts: "camisetas",
|
|
485
|
+
from: "Desde",
|
|
486
|
+
current: "Puja actual",
|
|
487
|
+
reserved: "Reservado por la organización",
|
|
488
|
+
minimum: "Puja mínima",
|
|
489
|
+
increments: "Incrementos de",
|
|
490
|
+
amount: "Tu puja (€)",
|
|
491
|
+
bid: "Pujar",
|
|
492
|
+
outbid: "Superar la puja",
|
|
493
|
+
closed: "Las pujas de esta camiseta están cerradas.",
|
|
494
|
+
pick: "Elige un espacio en la camiseta o en la lista.",
|
|
495
|
+
belowMinimum: "La puja debe ser de al menos",
|
|
496
|
+
step: "Usa múltiplos del incremento a partir de la puja mínima.",
|
|
497
|
+
guestNote: "Verifica tu email y continúa al pago seguro, sin contraseña.",
|
|
498
|
+
note: "Terminarás en WODira: inicio de sesión, logotipo en SVG y pago seguro con Stripe.",
|
|
499
|
+
popupBlocked: "Tu navegador ha bloqueado la ventana de WODira.",
|
|
500
|
+
openBid: "Abrir la puja en WODira",
|
|
501
|
+
waiting: "Completa la puja en la ventana de WODira. Esta camiseta se actualizará sola.",
|
|
502
|
+
paid: "Puja confirmada. Tu marca ya aparece en la camiseta.",
|
|
503
|
+
leads: "lidera",
|
|
504
|
+
sides: {
|
|
505
|
+
front: "Delantera",
|
|
506
|
+
back: "Trasera",
|
|
507
|
+
"left-sleeve": "Manga izquierda",
|
|
508
|
+
"right-sleeve": "Manga derecha"
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
en: {
|
|
512
|
+
label: "Sponsor the event shirt",
|
|
513
|
+
loading: "Loading shirt and bids…",
|
|
514
|
+
error: "The campaign could not be loaded.",
|
|
515
|
+
invalid: "Set a valid campaign and publishable key.",
|
|
516
|
+
retry: "Retry",
|
|
517
|
+
shirtAria: "3D shirt. Drag it to turn it and tap a space to choose it.",
|
|
518
|
+
hint: "Drag to turn · Tap a space to bid",
|
|
519
|
+
noModel: "The 3D view is not available on this device. Choose a space from the list.",
|
|
520
|
+
zoomIn: "Zoom in",
|
|
521
|
+
zoomOut: "Zoom out",
|
|
522
|
+
views: "Shirt view",
|
|
523
|
+
slots: "Spaces",
|
|
524
|
+
closes: "Bidding closes",
|
|
525
|
+
shirts: "shirts",
|
|
526
|
+
from: "From",
|
|
527
|
+
current: "Current bid",
|
|
528
|
+
reserved: "Reserved by the organizer",
|
|
529
|
+
minimum: "Minimum bid",
|
|
530
|
+
increments: "Increments of",
|
|
531
|
+
amount: "Your bid (€)",
|
|
532
|
+
bid: "Bid",
|
|
533
|
+
outbid: "Outbid",
|
|
534
|
+
closed: "Bidding for this shirt is closed.",
|
|
535
|
+
pick: "Choose a space on the shirt or in the list.",
|
|
536
|
+
belowMinimum: "The bid must be at least",
|
|
537
|
+
step: "Use multiples of the increment above the minimum bid.",
|
|
538
|
+
guestNote: "Verify your email and continue to secure payment, without a password.",
|
|
539
|
+
note: "You will finish on WODira: sign-in, SVG logo and secure Stripe payment.",
|
|
540
|
+
popupBlocked: "Your browser blocked the WODira window.",
|
|
541
|
+
openBid: "Open the bid on WODira",
|
|
542
|
+
waiting: "Complete the bid in the WODira window. This shirt will update by itself.",
|
|
543
|
+
paid: "Bid confirmed. Your brand is now on the shirt.",
|
|
544
|
+
leads: "leads",
|
|
545
|
+
sides: {
|
|
546
|
+
front: "Front",
|
|
547
|
+
back: "Back",
|
|
548
|
+
"left-sleeve": "Left sleeve",
|
|
549
|
+
"right-sleeve": "Right sleeve"
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
pt: {
|
|
553
|
+
label: "Patrocina a camisola do evento",
|
|
554
|
+
loading: "A carregar camisola e licitações…",
|
|
555
|
+
error: "Não foi possível carregar a campanha.",
|
|
556
|
+
invalid: "Configura uma campanha e uma chave publicável válidas.",
|
|
557
|
+
retry: "Tentar novamente",
|
|
558
|
+
shirtAria: "Camisola 3D. Arrasta-a para a rodar e toca num espaço para o escolher.",
|
|
559
|
+
hint: "Arrasta para rodar · Toca num espaço para licitar",
|
|
560
|
+
noModel: "A vista 3D não está disponível neste dispositivo. Escolhe um espaço na lista.",
|
|
561
|
+
zoomIn: "Aproximar camisola",
|
|
562
|
+
zoomOut: "Afastar camisola",
|
|
563
|
+
views: "Vista da camisola",
|
|
564
|
+
slots: "Espaços",
|
|
565
|
+
closes: "Fim das licitações",
|
|
566
|
+
shirts: "camisolas",
|
|
567
|
+
from: "Desde",
|
|
568
|
+
current: "Licitação atual",
|
|
569
|
+
reserved: "Reservado pela organização",
|
|
570
|
+
minimum: "Licitação mínima",
|
|
571
|
+
increments: "Incrementos de",
|
|
572
|
+
amount: "A tua licitação (€)",
|
|
573
|
+
bid: "Licitar",
|
|
574
|
+
outbid: "Superar a licitação",
|
|
575
|
+
closed: "As licitações desta camisola estão fechadas.",
|
|
576
|
+
pick: "Escolhe um espaço na camisola ou na lista.",
|
|
577
|
+
belowMinimum: "A licitação deve ser de pelo menos",
|
|
578
|
+
step: "Usa múltiplos do incremento a partir da licitação mínima.",
|
|
579
|
+
guestNote: "Verifica o teu email e continua para o pagamento seguro, sem palavra-passe.",
|
|
580
|
+
note: "Vais terminar na WODira: início de sessão, logótipo em SVG e pagamento seguro com Stripe.",
|
|
581
|
+
popupBlocked: "O teu navegador bloqueou a janela da WODira.",
|
|
582
|
+
openBid: "Abrir a licitação na WODira",
|
|
583
|
+
waiting: "Conclui a licitação na janela da WODira. Esta camisola atualiza-se sozinha.",
|
|
584
|
+
paid: "Licitação confirmada. A tua marca já aparece na camisola.",
|
|
585
|
+
leads: "lidera",
|
|
586
|
+
sides: {
|
|
587
|
+
front: "Frente",
|
|
588
|
+
back: "Costas",
|
|
589
|
+
"left-sleeve": "Manga esquerda",
|
|
590
|
+
"right-sleeve": "Manga direita"
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
var SIDE_ORDER = ["front", "back", "left-sleeve", "right-sleeve"];
|
|
595
|
+
var DEFAULT_APP_URL = "https://wodira.app";
|
|
596
|
+
var SHIRT_MODEL_PATH = "/images/sponsor-studio/white-shirt-realistic-v1.glb?v=7";
|
|
597
|
+
var CLICK_TOLERANCE_PX = 6;
|
|
598
|
+
var PALETTE_TOKENS = {
|
|
599
|
+
slot: ["--wodira-color-accent", "#c40072"],
|
|
600
|
+
slotPreview: ["--wodira-color-accent", "#c40072"],
|
|
601
|
+
slotText: ["--wodira-color-accent-contrast", "#ffffff"],
|
|
602
|
+
priceLeading: ["--wodira-color-accent", "#c40072"],
|
|
603
|
+
price: ["--wodira-color-primary", "#17132e"],
|
|
604
|
+
reserved: ["--wodira-color-border", "#dcd9e3"],
|
|
605
|
+
selected: ["--wodira-color-primary", "#17132e"]
|
|
606
|
+
};
|
|
607
|
+
function placement(side) {
|
|
608
|
+
return side === "left-sleeve" || side === "right-sleeve" ? { side: "front", surface: side } : { side };
|
|
609
|
+
}
|
|
610
|
+
function toSponsorSlot(slot) {
|
|
611
|
+
const result = {
|
|
612
|
+
id: slot.id,
|
|
613
|
+
name: slot.name,
|
|
614
|
+
...placement(slot.side),
|
|
615
|
+
x: slot.x,
|
|
616
|
+
y: slot.y,
|
|
617
|
+
width: slot.width,
|
|
618
|
+
height: slot.height,
|
|
619
|
+
printWidth: slot.printWidthCm,
|
|
620
|
+
printHeight: slot.printHeightCm,
|
|
621
|
+
startingPrice: slot.startingPriceCents / 100,
|
|
622
|
+
bidPrice: slot.minimumBidCents / 100,
|
|
623
|
+
increment: slot.incrementCents / 100,
|
|
624
|
+
isReserved: !!slot.isReserved,
|
|
625
|
+
bids: slot.leadingArtworkUrl ? [
|
|
626
|
+
{
|
|
627
|
+
id: slot.id,
|
|
628
|
+
buyer: slot.leadingBrandName ?? "",
|
|
629
|
+
amount: (slot.leadingAmountCents ?? 0) / 100,
|
|
630
|
+
paidAt: 0,
|
|
631
|
+
status: "leading",
|
|
632
|
+
logo: slot.leadingArtworkUrl,
|
|
633
|
+
views: 0,
|
|
634
|
+
opens: 0,
|
|
635
|
+
clicks: 0
|
|
636
|
+
}
|
|
637
|
+
] : []
|
|
638
|
+
};
|
|
639
|
+
if (slot.reservedArtworkUrl)
|
|
640
|
+
result.reservedLogo = slot.reservedArtworkUrl;
|
|
641
|
+
return result;
|
|
642
|
+
}
|
|
643
|
+
function safeHttpUrl(value) {
|
|
644
|
+
try {
|
|
645
|
+
const url = new URL(value);
|
|
646
|
+
const local = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
|
|
647
|
+
if (url.username || url.password)
|
|
648
|
+
return null;
|
|
649
|
+
return url.protocol === "https:" || local && url.protocol === "http:" ? url : null;
|
|
650
|
+
} catch {
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
class WodiraShirtAuction2 extends LitElement {
|
|
656
|
+
static properties = {
|
|
657
|
+
campaignId: { type: String, attribute: "campaign-id" },
|
|
658
|
+
modelUrl: { type: String, attribute: "model-url" },
|
|
659
|
+
bidMode: { type: String, attribute: "bid-mode" },
|
|
660
|
+
campaignData: { attribute: false },
|
|
661
|
+
publishableKey: { type: String, attribute: "publishable-key" },
|
|
662
|
+
baseUrl: { type: String, attribute: "base-url" },
|
|
663
|
+
appUrl: { type: String, attribute: "app-url" },
|
|
664
|
+
locale: { type: String },
|
|
665
|
+
campaign: { state: true },
|
|
666
|
+
loading: { state: true },
|
|
667
|
+
failed: { state: true },
|
|
668
|
+
selectedSlotId: { state: true },
|
|
669
|
+
side: { state: true },
|
|
670
|
+
amountEuros: { state: true },
|
|
671
|
+
modelUnavailable: { state: true },
|
|
672
|
+
modelLoading: { state: true },
|
|
673
|
+
status: { state: true }
|
|
674
|
+
};
|
|
675
|
+
static styles = [
|
|
676
|
+
wodiraUiStyles,
|
|
677
|
+
css`
|
|
678
|
+
:host {
|
|
679
|
+
/* Earlier releases used these shorter names; they still apply as fallbacks. */
|
|
680
|
+
--_accent: var(--wodira-color-accent, var(--wodira-primary, #c40072));
|
|
681
|
+
--_accent-contrast: var(--wodira-color-accent-contrast, #fff);
|
|
682
|
+
--_surface: var(--wodira-color-surface, var(--wodira-background, #fff));
|
|
683
|
+
--_muted: var(--wodira-color-muted, #f6f5f8);
|
|
684
|
+
--_border: var(--wodira-color-border, var(--wodira-border, #dcd9e3));
|
|
685
|
+
--_text: var(--wodira-color-text, var(--wodira-text, #17132e));
|
|
686
|
+
--_text-muted: var(--wodira-color-text-muted, #625e70);
|
|
687
|
+
--_radius: var(--wodira-radius, 1rem);
|
|
688
|
+
--_radius-sm: var(--wodira-radius-sm, 0.625rem);
|
|
689
|
+
--_space: var(--wodira-space, 1rem);
|
|
690
|
+
color: var(--_text);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
[part~='container'] {
|
|
694
|
+
background: var(--_surface);
|
|
695
|
+
border: 1px solid var(--_border);
|
|
696
|
+
border-radius: var(--_radius);
|
|
697
|
+
box-shadow: var(--wodira-shadow, none);
|
|
698
|
+
display: grid;
|
|
699
|
+
gap: var(--_space);
|
|
700
|
+
padding: var(--wodira-card-padding, clamp(1rem, 3cqi, 1.75rem));
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
[part~='header'] {
|
|
704
|
+
display: grid;
|
|
705
|
+
gap: 0.35rem;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
[part~='title'] {
|
|
709
|
+
font-size: clamp(1.25rem, 4cqi, 1.75rem);
|
|
710
|
+
line-height: 1.15;
|
|
711
|
+
margin: 0;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
[part~='meta'] {
|
|
715
|
+
color: var(--_text-muted);
|
|
716
|
+
display: flex;
|
|
717
|
+
flex-wrap: wrap;
|
|
718
|
+
font-size: 0.875rem;
|
|
719
|
+
gap: 0.25rem 1rem;
|
|
720
|
+
margin: 0;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
[part~='layout'] {
|
|
724
|
+
display: grid;
|
|
725
|
+
gap: var(--_space);
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
@container (min-width: 46rem) {
|
|
729
|
+
[part~='layout'] {
|
|
730
|
+
align-items: start;
|
|
731
|
+
grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
[part~='stage'] {
|
|
736
|
+
aspect-ratio: 1 / 1;
|
|
737
|
+
background: var(--wodira-shirt-stage-background, var(--_muted));
|
|
738
|
+
border-radius: var(--_radius);
|
|
739
|
+
max-height: min(36rem, 75vh);
|
|
740
|
+
overflow: hidden;
|
|
741
|
+
position: relative;
|
|
742
|
+
width: 100%;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
[part~='shirt'] {
|
|
746
|
+
cursor: grab;
|
|
747
|
+
display: block;
|
|
748
|
+
height: 100%;
|
|
749
|
+
/* Vertical swipes keep scrolling the page; horizontal drags turn the shirt. */
|
|
750
|
+
touch-action: pan-y;
|
|
751
|
+
width: 100%;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
[part~='shirt']:active {
|
|
755
|
+
cursor: grabbing;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
[part~='shirt']:focus-visible {
|
|
759
|
+
outline: 3px solid var(--_accent);
|
|
760
|
+
outline-offset: -3px;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
[part~='stage-hint'] {
|
|
764
|
+
background: color-mix(in srgb, var(--_surface) 88%, transparent);
|
|
765
|
+
border-radius: 999px;
|
|
766
|
+
bottom: 0.75rem;
|
|
767
|
+
color: var(--_text-muted);
|
|
768
|
+
font-size: 0.8125rem;
|
|
769
|
+
left: 0.75rem;
|
|
770
|
+
margin: 0;
|
|
771
|
+
padding: 0.35rem 0.75rem;
|
|
772
|
+
pointer-events: none;
|
|
773
|
+
position: absolute;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
[part~='stage-controls'] {
|
|
777
|
+
display: flex;
|
|
778
|
+
gap: 0.5rem;
|
|
779
|
+
position: absolute;
|
|
780
|
+
right: 0.75rem;
|
|
781
|
+
top: 0.75rem;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
[part~='zoom-button'],
|
|
785
|
+
[part~='side-button'] {
|
|
786
|
+
align-items: center;
|
|
787
|
+
background: var(--_surface);
|
|
788
|
+
border: 1px solid var(--_border);
|
|
789
|
+
border-radius: var(--_radius-sm);
|
|
790
|
+
color: var(--_text);
|
|
791
|
+
cursor: pointer;
|
|
792
|
+
display: inline-flex;
|
|
793
|
+
font: inherit;
|
|
794
|
+
justify-content: center;
|
|
795
|
+
min-height: 2.75rem;
|
|
796
|
+
min-width: 2.75rem;
|
|
797
|
+
padding: 0 0.75rem;
|
|
798
|
+
transition:
|
|
799
|
+
background-color 0.15s ease,
|
|
800
|
+
border-color 0.15s ease;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
[part~='side-button'][aria-pressed='true'] {
|
|
804
|
+
background: var(--_accent);
|
|
805
|
+
border-color: var(--_accent);
|
|
806
|
+
color: var(--_accent-contrast);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
[part~='side-switch'] {
|
|
810
|
+
display: flex;
|
|
811
|
+
flex-wrap: wrap;
|
|
812
|
+
gap: 0.5rem;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
[part~='stage-fallback'] {
|
|
816
|
+
align-items: center;
|
|
817
|
+
color: var(--_text-muted);
|
|
818
|
+
display: flex;
|
|
819
|
+
height: 100%;
|
|
820
|
+
justify-content: center;
|
|
821
|
+
margin: 0;
|
|
822
|
+
padding: 1.5rem;
|
|
823
|
+
text-align: center;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
[part~='slot-list'] {
|
|
827
|
+
display: grid;
|
|
828
|
+
gap: 0.5rem;
|
|
829
|
+
list-style: none;
|
|
830
|
+
margin: 0;
|
|
831
|
+
padding: 0;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
[part~='slot'] {
|
|
835
|
+
align-items: center;
|
|
836
|
+
background: var(--_surface);
|
|
837
|
+
border: 1px solid var(--_border);
|
|
838
|
+
border-radius: var(--_radius-sm);
|
|
839
|
+
color: inherit;
|
|
840
|
+
cursor: pointer;
|
|
841
|
+
display: grid;
|
|
842
|
+
font: inherit;
|
|
843
|
+
gap: 0.15rem 1rem;
|
|
844
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
845
|
+
min-height: 3.25rem;
|
|
846
|
+
padding: 0.75rem 1rem;
|
|
847
|
+
text-align: start;
|
|
848
|
+
transition:
|
|
849
|
+
background-color 0.15s ease,
|
|
850
|
+
border-color 0.15s ease;
|
|
851
|
+
width: 100%;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
[part~='slot-selected'] {
|
|
855
|
+
background: color-mix(in srgb, var(--_accent) 8%, var(--_surface));
|
|
856
|
+
border-color: var(--_accent);
|
|
857
|
+
box-shadow: inset 4px 0 0 var(--_accent);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
[part~='slot']:disabled {
|
|
861
|
+
cursor: default;
|
|
862
|
+
opacity: 0.7;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
[part~='slot']:focus-visible,
|
|
866
|
+
[part~='zoom-button']:focus-visible,
|
|
867
|
+
[part~='side-button']:focus-visible {
|
|
868
|
+
outline: 3px solid var(--_accent);
|
|
869
|
+
outline-offset: 2px;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
@media (hover: hover) {
|
|
873
|
+
[part~='slot']:not(:disabled):hover,
|
|
874
|
+
[part~='zoom-button']:hover,
|
|
875
|
+
[part~='side-button']:hover {
|
|
876
|
+
border-color: var(--_accent);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
[part~='slot-name'] {
|
|
881
|
+
font-weight: 700;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
[part~='slot-detail'] {
|
|
885
|
+
color: var(--_text-muted);
|
|
886
|
+
font-size: 0.8125rem;
|
|
887
|
+
grid-column: 1;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
[part~='slot-price'] {
|
|
891
|
+
font-variant-numeric: tabular-nums;
|
|
892
|
+
font-weight: 700;
|
|
893
|
+
grid-column: 2;
|
|
894
|
+
grid-row: 1 / span 2;
|
|
895
|
+
text-align: end;
|
|
896
|
+
white-space: nowrap;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
[part~='slot-price'] small {
|
|
900
|
+
color: var(--_text-muted);
|
|
901
|
+
display: block;
|
|
902
|
+
font-size: 0.75rem;
|
|
903
|
+
font-weight: 500;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
[part~='section-title'] {
|
|
907
|
+
font-size: 0.8125rem;
|
|
908
|
+
letter-spacing: 0.08em;
|
|
909
|
+
margin: 0;
|
|
910
|
+
text-transform: uppercase;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
[part~='bid-panel'] {
|
|
914
|
+
background: var(--_muted);
|
|
915
|
+
border-radius: var(--_radius);
|
|
916
|
+
display: grid;
|
|
917
|
+
gap: 0.75rem;
|
|
918
|
+
padding: var(--_space);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
[part~='bid-title'] {
|
|
922
|
+
font-size: 1.125rem;
|
|
923
|
+
margin: 0;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
[part~='leader'] {
|
|
927
|
+
align-items: center;
|
|
928
|
+
display: flex;
|
|
929
|
+
gap: 0.75rem;
|
|
930
|
+
margin: 0;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
[part~='leader-logo'] {
|
|
934
|
+
background: #fff;
|
|
935
|
+
border-radius: 0.5rem;
|
|
936
|
+
height: 2.5rem;
|
|
937
|
+
object-fit: contain;
|
|
938
|
+
outline: 1px solid rgb(0 0 0 / 0.1);
|
|
939
|
+
outline-offset: -1px;
|
|
940
|
+
padding: 0.25rem;
|
|
941
|
+
width: 4.5rem;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
[part~='bid-form'] {
|
|
945
|
+
display: grid;
|
|
946
|
+
gap: 0.75rem;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
[part~='bid-form'] [part~='label'] {
|
|
950
|
+
display: grid;
|
|
951
|
+
gap: 0.35rem;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
[part~='status'] {
|
|
955
|
+
margin: 0;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
@media (prefers-reduced-motion: reduce) {
|
|
959
|
+
[part~='slot'],
|
|
960
|
+
[part~='zoom-button'],
|
|
961
|
+
[part~='side-button'] {
|
|
962
|
+
transition: none;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
`
|
|
966
|
+
];
|
|
967
|
+
client = null;
|
|
968
|
+
abort = null;
|
|
969
|
+
renderer = null;
|
|
970
|
+
rendererCanvas = null;
|
|
971
|
+
rendererGeneration = 0;
|
|
972
|
+
canvasRevision = 0;
|
|
973
|
+
drag = null;
|
|
974
|
+
bidWindow = null;
|
|
975
|
+
bidWindowTimer;
|
|
976
|
+
blockedUrl = "";
|
|
977
|
+
channel = globalThis.crypto.randomUUID();
|
|
978
|
+
themeObserver = null;
|
|
979
|
+
colorScheme = null;
|
|
980
|
+
constructor() {
|
|
981
|
+
super();
|
|
982
|
+
this.campaignId = "";
|
|
983
|
+
this.modelUrl = "";
|
|
984
|
+
this.bidMode = "wodira";
|
|
985
|
+
this.publishableKey = "";
|
|
986
|
+
this.baseUrl = "";
|
|
987
|
+
this.appUrl = DEFAULT_APP_URL;
|
|
988
|
+
this.locale = "auto";
|
|
989
|
+
this.campaign = null;
|
|
990
|
+
this.loading = false;
|
|
991
|
+
this.failed = false;
|
|
992
|
+
this.selectedSlotId = null;
|
|
993
|
+
this.side = "front";
|
|
994
|
+
this.amountEuros = null;
|
|
995
|
+
this.modelUnavailable = false;
|
|
996
|
+
this.modelLoading = true;
|
|
997
|
+
this.status = "idle";
|
|
998
|
+
}
|
|
999
|
+
refreshTheme() {
|
|
1000
|
+
this.renderer?.setAppearance({ palette: this.palette(), locale: this.numberLocale });
|
|
1001
|
+
}
|
|
1002
|
+
connectedCallback() {
|
|
1003
|
+
super.connectedCallback();
|
|
1004
|
+
window.addEventListener("message", this.onMessage);
|
|
1005
|
+
window.addEventListener("focus", this.onWindowFocus);
|
|
1006
|
+
this.themeObserver = new MutationObserver(() => this.refreshTheme());
|
|
1007
|
+
for (const target of [this, this.ownerDocument.documentElement, this.ownerDocument.body])
|
|
1008
|
+
if (target)
|
|
1009
|
+
this.themeObserver.observe(target, {
|
|
1010
|
+
attributes: true,
|
|
1011
|
+
attributeFilter: ["class", "style", "data-theme"]
|
|
1012
|
+
});
|
|
1013
|
+
this.colorScheme = matchMedia("(prefers-color-scheme: dark)");
|
|
1014
|
+
this.colorScheme.addEventListener("change", this.onColorScheme);
|
|
1015
|
+
if (this.hasUpdated) {
|
|
1016
|
+
this.modelUnavailable = false;
|
|
1017
|
+
this.requestUpdate();
|
|
1018
|
+
this.load(true);
|
|
1019
|
+
this.watchBidWindow();
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
disconnectedCallback() {
|
|
1023
|
+
window.removeEventListener("message", this.onMessage);
|
|
1024
|
+
window.removeEventListener("focus", this.onWindowFocus);
|
|
1025
|
+
this.themeObserver?.disconnect();
|
|
1026
|
+
this.colorScheme?.removeEventListener("change", this.onColorScheme);
|
|
1027
|
+
clearInterval(this.bidWindowTimer);
|
|
1028
|
+
this.abort?.abort();
|
|
1029
|
+
this.disposeRenderer();
|
|
1030
|
+
this.canvasRevision++;
|
|
1031
|
+
super.disconnectedCallback();
|
|
1032
|
+
}
|
|
1033
|
+
willUpdate(changes) {
|
|
1034
|
+
if (changes.has("modelUrl")) {
|
|
1035
|
+
this.modelUnavailable = false;
|
|
1036
|
+
this.canvasRevision++;
|
|
1037
|
+
this.disposeRenderer();
|
|
1038
|
+
}
|
|
1039
|
+
if (changes.has("campaignId") || changes.has("bidMode") || changes.has("publishableKey") || changes.has("baseUrl") || changes.has("appUrl")) {
|
|
1040
|
+
this.client = this.createClient();
|
|
1041
|
+
clearInterval(this.bidWindowTimer);
|
|
1042
|
+
this.bidWindow = null;
|
|
1043
|
+
this.blockedUrl = "";
|
|
1044
|
+
this.canvasRevision++;
|
|
1045
|
+
this.selectedSlotId = null;
|
|
1046
|
+
this.status = "idle";
|
|
1047
|
+
this.modelUnavailable = false;
|
|
1048
|
+
this.disposeRenderer();
|
|
1049
|
+
this.load();
|
|
1050
|
+
} else if (changes.has("campaignData") && this.bidMode === "host") {
|
|
1051
|
+
this.load(true);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
updated(changes) {
|
|
1055
|
+
const canvas = this.renderRoot.querySelector("canvas");
|
|
1056
|
+
if (canvas !== this.rendererCanvas) {
|
|
1057
|
+
this.disposeRenderer();
|
|
1058
|
+
if (canvas)
|
|
1059
|
+
this.startRenderer(canvas);
|
|
1060
|
+
} else if (changes.has("campaign") || changes.has("side") || changes.has("selectedSlotId"))
|
|
1061
|
+
this.paintShirt();
|
|
1062
|
+
if (changes.has("locale"))
|
|
1063
|
+
this.refreshTheme();
|
|
1064
|
+
}
|
|
1065
|
+
get language() {
|
|
1066
|
+
const locale = this.locale && this.locale !== "auto" ? this.locale : this.ownerDocument.documentElement.lang || navigator.language || "es";
|
|
1067
|
+
const language = locale.toLowerCase().split("-")[0];
|
|
1068
|
+
return language === "en" || language === "pt" ? language : "es";
|
|
1069
|
+
}
|
|
1070
|
+
get numberLocale() {
|
|
1071
|
+
return this.locale && this.locale !== "auto" ? this.locale : this.ownerDocument.documentElement.lang || navigator.language || "es-ES";
|
|
1072
|
+
}
|
|
1073
|
+
get text() {
|
|
1074
|
+
return copy[this.language];
|
|
1075
|
+
}
|
|
1076
|
+
get appOrigin() {
|
|
1077
|
+
return safeHttpUrl(this.appUrl || DEFAULT_APP_URL);
|
|
1078
|
+
}
|
|
1079
|
+
createClient() {
|
|
1080
|
+
if (!/^[a-zA-Z0-9_-]{1,160}$/.test(this.campaignId))
|
|
1081
|
+
return null;
|
|
1082
|
+
if (!this.publishableKey?.startsWith("wpk_live_"))
|
|
1083
|
+
return null;
|
|
1084
|
+
if (!this.appOrigin)
|
|
1085
|
+
return null;
|
|
1086
|
+
const options = { publishableKey: this.publishableKey };
|
|
1087
|
+
if (this.baseUrl) {
|
|
1088
|
+
if (!safeHttpUrl(this.baseUrl))
|
|
1089
|
+
return null;
|
|
1090
|
+
options.baseUrl = this.baseUrl;
|
|
1091
|
+
}
|
|
1092
|
+
try {
|
|
1093
|
+
return createWodiraBrowserClient(options);
|
|
1094
|
+
} catch {
|
|
1095
|
+
return null;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
async load(silent = false) {
|
|
1099
|
+
this.abort?.abort();
|
|
1100
|
+
if (this.bidMode === "host" && this.campaignData) {
|
|
1101
|
+
this.loading = false;
|
|
1102
|
+
this.failed = false;
|
|
1103
|
+
this.applyCampaign(this.campaignData);
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
if (!this.client) {
|
|
1107
|
+
this.campaign = null;
|
|
1108
|
+
this.loading = false;
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
const abort = new AbortController;
|
|
1112
|
+
this.abort = abort;
|
|
1113
|
+
if (!silent)
|
|
1114
|
+
this.loading = true;
|
|
1115
|
+
this.failed = false;
|
|
1116
|
+
try {
|
|
1117
|
+
const campaign = await this.client.getShirtSponsorCampaign(this.campaignId, abort.signal);
|
|
1118
|
+
if (abort.signal.aborted)
|
|
1119
|
+
return;
|
|
1120
|
+
this.applyCampaign(campaign);
|
|
1121
|
+
} catch {
|
|
1122
|
+
if (abort.signal.aborted)
|
|
1123
|
+
return;
|
|
1124
|
+
if (!silent)
|
|
1125
|
+
this.failed = true;
|
|
1126
|
+
} finally {
|
|
1127
|
+
if (!abort.signal.aborted)
|
|
1128
|
+
this.loading = false;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
applyCampaign(campaign) {
|
|
1132
|
+
this.campaign = campaign;
|
|
1133
|
+
const next = campaign.slots.find((slot) => slot.id === this.selectedSlotId) ?? campaign.slots.find((slot) => !slot.isReserved && slot.side === "front") ?? campaign.slots.find((slot) => !slot.isReserved) ?? campaign.slots[0];
|
|
1134
|
+
if (next)
|
|
1135
|
+
this.select(next, false);
|
|
1136
|
+
}
|
|
1137
|
+
get biddingOpen() {
|
|
1138
|
+
const campaign = this.campaign;
|
|
1139
|
+
return !!campaign && campaign.status === "PUBLISHED" && new Date(campaign.closesAt) > new Date;
|
|
1140
|
+
}
|
|
1141
|
+
get selectedSlot() {
|
|
1142
|
+
return this.campaign?.slots.find((slot) => slot.id === this.selectedSlotId) ?? null;
|
|
1143
|
+
}
|
|
1144
|
+
get orderedSlots() {
|
|
1145
|
+
return [...this.campaign?.slots ?? []].sort((a, b) => SIDE_ORDER.indexOf(a.side) - SIDE_ORDER.indexOf(b.side));
|
|
1146
|
+
}
|
|
1147
|
+
get sides() {
|
|
1148
|
+
const used = new Set(this.campaign?.slots.map((slot) => slot.side));
|
|
1149
|
+
return SIDE_ORDER.filter((side) => side === "front" || side === "back" || used.has(side));
|
|
1150
|
+
}
|
|
1151
|
+
select(slot, announce = true) {
|
|
1152
|
+
const changed = slot.id !== this.selectedSlotId;
|
|
1153
|
+
this.selectedSlotId = slot.id;
|
|
1154
|
+
if (changed)
|
|
1155
|
+
this.side = slot.side;
|
|
1156
|
+
if (changed || this.amountEuros === null || this.amountEuros * 100 < slot.minimumBidCents)
|
|
1157
|
+
this.amountEuros = slot.minimumBidCents / 100;
|
|
1158
|
+
if (announce && changed)
|
|
1159
|
+
this.dispatchEvent(new CustomEvent("wodira:shirt:slot-selected", {
|
|
1160
|
+
bubbles: true,
|
|
1161
|
+
composed: true,
|
|
1162
|
+
detail: { campaignId: this.campaignId, slotId: slot.id }
|
|
1163
|
+
}));
|
|
1164
|
+
}
|
|
1165
|
+
formatMoney(cents) {
|
|
1166
|
+
const digits = cents % 100 ? 2 : 0;
|
|
1167
|
+
try {
|
|
1168
|
+
return new Intl.NumberFormat(this.numberLocale, {
|
|
1169
|
+
style: "currency",
|
|
1170
|
+
currency: "EUR",
|
|
1171
|
+
minimumFractionDigits: digits,
|
|
1172
|
+
maximumFractionDigits: digits
|
|
1173
|
+
}).format(cents / 100);
|
|
1174
|
+
} catch {
|
|
1175
|
+
return `${(cents / 100).toFixed(digits)} €`;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
formatDate(value) {
|
|
1179
|
+
try {
|
|
1180
|
+
return new Intl.DateTimeFormat(this.numberLocale, {
|
|
1181
|
+
dateStyle: "medium",
|
|
1182
|
+
timeStyle: "short"
|
|
1183
|
+
}).format(new Date(value));
|
|
1184
|
+
} catch {
|
|
1185
|
+
return value;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
palette() {
|
|
1189
|
+
const style = getComputedStyle(this);
|
|
1190
|
+
const palette = {};
|
|
1191
|
+
for (const [key, [token, fallback]] of Object.entries(PALETTE_TOKENS))
|
|
1192
|
+
palette[key] = style.getPropertyValue(token).trim() || fallback;
|
|
1193
|
+
return palette;
|
|
1194
|
+
}
|
|
1195
|
+
get modelSource() {
|
|
1196
|
+
if (this.modelUrl) {
|
|
1197
|
+
try {
|
|
1198
|
+
const url = safeHttpUrl(new URL(this.modelUrl, this.ownerDocument.baseURI).href);
|
|
1199
|
+
if (url)
|
|
1200
|
+
return url.href;
|
|
1201
|
+
} catch {}
|
|
1202
|
+
}
|
|
1203
|
+
return new URL(SHIRT_MODEL_PATH, this.appOrigin ?? DEFAULT_APP_URL).href;
|
|
1204
|
+
}
|
|
1205
|
+
async startRenderer(canvas) {
|
|
1206
|
+
const generation = ++this.rendererGeneration;
|
|
1207
|
+
this.rendererCanvas = canvas;
|
|
1208
|
+
this.modelLoading = true;
|
|
1209
|
+
try {
|
|
1210
|
+
const { Shirt3dRenderer } = await (__preload("jyks1h8f"), import("./shirt-3d-renderer-jyks1h8f.js"));
|
|
1211
|
+
if (generation !== this.rendererGeneration)
|
|
1212
|
+
return;
|
|
1213
|
+
const renderer = new Shirt3dRenderer(canvas, () => {
|
|
1214
|
+
if (generation === this.rendererGeneration)
|
|
1215
|
+
this.modelUnavailable = true;
|
|
1216
|
+
}, (loading) => {
|
|
1217
|
+
if (generation === this.rendererGeneration)
|
|
1218
|
+
this.modelLoading = loading;
|
|
1219
|
+
}, {
|
|
1220
|
+
modelUrl: this.modelSource,
|
|
1221
|
+
locale: this.numberLocale,
|
|
1222
|
+
palette: this.palette()
|
|
1223
|
+
});
|
|
1224
|
+
this.renderer = renderer;
|
|
1225
|
+
this.paintShirt();
|
|
1226
|
+
await renderer.load();
|
|
1227
|
+
if (generation === this.rendererGeneration)
|
|
1228
|
+
this.modelLoading = false;
|
|
1229
|
+
} catch {
|
|
1230
|
+
if (generation === this.rendererGeneration) {
|
|
1231
|
+
this.disposeRenderer();
|
|
1232
|
+
this.modelUnavailable = true;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
disposeRenderer() {
|
|
1237
|
+
this.rendererGeneration++;
|
|
1238
|
+
this.renderer?.dispose();
|
|
1239
|
+
this.renderer = null;
|
|
1240
|
+
this.rendererCanvas = null;
|
|
1241
|
+
this.drag = null;
|
|
1242
|
+
}
|
|
1243
|
+
paintShirt() {
|
|
1244
|
+
const campaign = this.campaign;
|
|
1245
|
+
if (!this.renderer || !campaign)
|
|
1246
|
+
return;
|
|
1247
|
+
const view = placement(this.side);
|
|
1248
|
+
const design = campaign.shirtDesign;
|
|
1249
|
+
const artwork = design ? {
|
|
1250
|
+
...design.front ? { front: design.front } : {},
|
|
1251
|
+
...design.back ? { back: design.back } : {}
|
|
1252
|
+
} : null;
|
|
1253
|
+
this.renderer.setSelectedSlot(this.selectedSlotId);
|
|
1254
|
+
this.renderer.update(campaign.slots.map(toSponsorSlot), view.side, true, campaign.shirtColor || "#ffffff", false, artwork, view.surface);
|
|
1255
|
+
}
|
|
1256
|
+
onPointerDown(event) {
|
|
1257
|
+
if (event.button !== 0)
|
|
1258
|
+
return;
|
|
1259
|
+
this.drag = {
|
|
1260
|
+
id: event.pointerId,
|
|
1261
|
+
x: event.clientX,
|
|
1262
|
+
y: event.clientY,
|
|
1263
|
+
originX: event.clientX,
|
|
1264
|
+
originY: event.clientY
|
|
1265
|
+
};
|
|
1266
|
+
if (event.pointerType !== "touch")
|
|
1267
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1268
|
+
}
|
|
1269
|
+
onPointerMove(event) {
|
|
1270
|
+
const drag = this.drag;
|
|
1271
|
+
if (!drag || drag.id !== event.pointerId)
|
|
1272
|
+
return;
|
|
1273
|
+
const distance = Math.hypot(event.clientX - drag.originX, event.clientY - drag.originY);
|
|
1274
|
+
if (distance <= CLICK_TOLERANCE_PX)
|
|
1275
|
+
return;
|
|
1276
|
+
this.renderer?.rotate(event.clientX - drag.x, event.clientY - drag.y);
|
|
1277
|
+
drag.x = event.clientX;
|
|
1278
|
+
drag.y = event.clientY;
|
|
1279
|
+
}
|
|
1280
|
+
onPointerUp(event) {
|
|
1281
|
+
const drag = this.drag;
|
|
1282
|
+
this.drag = null;
|
|
1283
|
+
if (!drag || drag.id !== event.pointerId)
|
|
1284
|
+
return;
|
|
1285
|
+
const distance = Math.hypot(event.clientX - drag.originX, event.clientY - drag.originY);
|
|
1286
|
+
if (distance > CLICK_TOLERANCE_PX)
|
|
1287
|
+
return;
|
|
1288
|
+
const picked = this.renderer?.pick(event.clientX, event.clientY);
|
|
1289
|
+
const slot = picked && this.campaign?.slots.find((item) => item.id === picked.id);
|
|
1290
|
+
if (slot && !slot.isReserved)
|
|
1291
|
+
this.select(slot);
|
|
1292
|
+
}
|
|
1293
|
+
onPointerCancel() {
|
|
1294
|
+
this.drag = null;
|
|
1295
|
+
}
|
|
1296
|
+
onShirtKey(event) {
|
|
1297
|
+
if (!this.renderer)
|
|
1298
|
+
return;
|
|
1299
|
+
const turns = {
|
|
1300
|
+
ArrowLeft: [-10, 0],
|
|
1301
|
+
ArrowRight: [10, 0],
|
|
1302
|
+
ArrowUp: [0, -10],
|
|
1303
|
+
ArrowDown: [0, 10]
|
|
1304
|
+
};
|
|
1305
|
+
const turn = turns[event.key];
|
|
1306
|
+
if (turn) {
|
|
1307
|
+
event.preventDefault();
|
|
1308
|
+
this.renderer.rotate(turn[0], turn[1]);
|
|
1309
|
+
} else if (event.key === "+" || event.key === "=") {
|
|
1310
|
+
event.preventDefault();
|
|
1311
|
+
this.renderer.zoomBy(0.1);
|
|
1312
|
+
} else if (event.key === "-") {
|
|
1313
|
+
event.preventDefault();
|
|
1314
|
+
this.renderer.zoomBy(-0.1);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
showSide(side) {
|
|
1318
|
+
this.side = side;
|
|
1319
|
+
this.renderer?.resetView();
|
|
1320
|
+
this.paintShirt();
|
|
1321
|
+
}
|
|
1322
|
+
bidUrl(slot, amountCents) {
|
|
1323
|
+
const app = this.appOrigin;
|
|
1324
|
+
if (!app)
|
|
1325
|
+
return null;
|
|
1326
|
+
const local = ["localhost", "127.0.0.1", "[::1]"].includes(app.hostname);
|
|
1327
|
+
const path = `${local ? "" : `/${this.language}`}/patrocinios/camisetas/${encodeURIComponent(this.campaignId)}`;
|
|
1328
|
+
const url = new URL(path, app.origin);
|
|
1329
|
+
url.searchParams.set("slot", slot.id);
|
|
1330
|
+
url.searchParams.set("amount", String(amountCents));
|
|
1331
|
+
url.searchParams.set("channel", this.channel);
|
|
1332
|
+
url.searchParams.set("parentOrigin", location.origin);
|
|
1333
|
+
return url.href;
|
|
1334
|
+
}
|
|
1335
|
+
amountProblem(slot) {
|
|
1336
|
+
const cents = Math.round((this.amountEuros ?? 0) * 100);
|
|
1337
|
+
if (!Number.isFinite(cents) || cents < slot.minimumBidCents)
|
|
1338
|
+
return `${this.text.belowMinimum} ${this.formatMoney(slot.minimumBidCents)}.`;
|
|
1339
|
+
if (slot.incrementCents > 0 && (cents - slot.minimumBidCents) % slot.incrementCents !== 0)
|
|
1340
|
+
return this.text.step;
|
|
1341
|
+
return null;
|
|
1342
|
+
}
|
|
1343
|
+
submitBid(event) {
|
|
1344
|
+
event.preventDefault();
|
|
1345
|
+
const slot = this.selectedSlot;
|
|
1346
|
+
if (!slot || slot.isReserved || !this.biddingOpen || this.amountProblem(slot))
|
|
1347
|
+
return;
|
|
1348
|
+
const amountCents = Math.round((this.amountEuros ?? 0) * 100);
|
|
1349
|
+
if (this.bidMode === "host") {
|
|
1350
|
+
this.dispatchEvent(new CustomEvent("wodira:shirt:bid-requested", {
|
|
1351
|
+
bubbles: true,
|
|
1352
|
+
composed: true,
|
|
1353
|
+
detail: {
|
|
1354
|
+
campaignId: this.campaignId,
|
|
1355
|
+
slotId: slot.id,
|
|
1356
|
+
slotName: slot.name,
|
|
1357
|
+
amountCents
|
|
1358
|
+
}
|
|
1359
|
+
}));
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
const url = this.bidUrl(slot, amountCents);
|
|
1363
|
+
if (!url)
|
|
1364
|
+
return;
|
|
1365
|
+
this.dispatchEvent(new CustomEvent("wodira:shirt:bid-started", {
|
|
1366
|
+
bubbles: true,
|
|
1367
|
+
composed: true,
|
|
1368
|
+
detail: { campaignId: this.campaignId, slotId: slot.id, amountCents }
|
|
1369
|
+
}));
|
|
1370
|
+
const width = Math.min(1100, screen.availWidth);
|
|
1371
|
+
const height = Math.min(900, screen.availHeight);
|
|
1372
|
+
const left = Math.max(0, Math.round((screen.availWidth - width) / 2));
|
|
1373
|
+
const top = Math.max(0, Math.round((screen.availHeight - height) / 2));
|
|
1374
|
+
const popup = window.open(url, `wodira-shirt-${this.channel}`, `popup,width=${width},height=${height},left=${left},top=${top}`);
|
|
1375
|
+
if (!popup) {
|
|
1376
|
+
this.blockedUrl = url;
|
|
1377
|
+
this.status = "blocked";
|
|
1378
|
+
return;
|
|
1379
|
+
}
|
|
1380
|
+
this.bidWindow = popup;
|
|
1381
|
+
this.status = "waiting";
|
|
1382
|
+
this.watchBidWindow();
|
|
1383
|
+
}
|
|
1384
|
+
watchBidWindow() {
|
|
1385
|
+
clearInterval(this.bidWindowTimer);
|
|
1386
|
+
if (!this.bidWindow)
|
|
1387
|
+
return;
|
|
1388
|
+
this.bidWindowTimer = setInterval(() => {
|
|
1389
|
+
if (!this.bidWindow?.closed)
|
|
1390
|
+
return;
|
|
1391
|
+
clearInterval(this.bidWindowTimer);
|
|
1392
|
+
this.bidWindow = null;
|
|
1393
|
+
if (this.status === "waiting")
|
|
1394
|
+
this.status = "idle";
|
|
1395
|
+
this.load(true);
|
|
1396
|
+
}, 1000);
|
|
1397
|
+
}
|
|
1398
|
+
onMessage = (event) => {
|
|
1399
|
+
const app = this.appOrigin;
|
|
1400
|
+
if (!app || event.origin !== app.origin)
|
|
1401
|
+
return;
|
|
1402
|
+
if (!this.bidWindow || event.source !== this.bidWindow)
|
|
1403
|
+
return;
|
|
1404
|
+
const data = event.data;
|
|
1405
|
+
if (!data || typeof data !== "object" || !("type" in data) || data.type !== "wodira:shirt:paid" || !("channel" in data) || data.channel !== this.channel || !("campaignId" in data) || data.campaignId !== this.campaignId)
|
|
1406
|
+
return;
|
|
1407
|
+
this.status = "paid";
|
|
1408
|
+
this.load(true);
|
|
1409
|
+
this.dispatchEvent(new CustomEvent("wodira:shirt:paid", {
|
|
1410
|
+
bubbles: true,
|
|
1411
|
+
composed: true,
|
|
1412
|
+
detail: { campaignId: this.campaignId }
|
|
1413
|
+
}));
|
|
1414
|
+
};
|
|
1415
|
+
onWindowFocus = () => {
|
|
1416
|
+
if (this.status === "blocked")
|
|
1417
|
+
this.load(true);
|
|
1418
|
+
};
|
|
1419
|
+
onColorScheme = () => this.refreshTheme();
|
|
1420
|
+
render() {
|
|
1421
|
+
const text = this.text;
|
|
1422
|
+
if (!this.client && !this.campaign)
|
|
1423
|
+
return html`<section part="container" aria-label=${text.label}>
|
|
1424
|
+
<p part="error" role="alert">${text.invalid}</p>
|
|
1425
|
+
</section>`;
|
|
1426
|
+
if (this.loading && !this.campaign)
|
|
1427
|
+
return html`<section part="container" aria-label=${text.label} aria-busy="true">
|
|
1428
|
+
<p part="loader" role="status">${text.loading}</p>
|
|
1429
|
+
</section>`;
|
|
1430
|
+
if (this.failed || !this.campaign)
|
|
1431
|
+
return html`<section part="container" aria-label=${text.label}>
|
|
1432
|
+
<p part="error" role="alert">${text.error}</p>
|
|
1433
|
+
<button part="button secondary" type="button" @click=${() => this.load()}>
|
|
1434
|
+
${text.retry}
|
|
1435
|
+
</button>
|
|
1436
|
+
</section>`;
|
|
1437
|
+
const campaign = this.campaign;
|
|
1438
|
+
return html`<section part="container" aria-label=${text.label}>
|
|
1439
|
+
<header part="header">
|
|
1440
|
+
<h2 part="title">${campaign.eventName}</h2>
|
|
1441
|
+
<p part="meta">
|
|
1442
|
+
<span>${[campaign.city, campaign.province].filter(Boolean).join(", ")}</span>
|
|
1443
|
+
<span>${campaign.shirtCount.toLocaleString(this.numberLocale)} ${text.shirts}</span>
|
|
1444
|
+
<span>${text.closes}: ${this.formatDate(campaign.closesAt)}</span>
|
|
1445
|
+
</p>
|
|
1446
|
+
</header>
|
|
1447
|
+
<div part="layout">
|
|
1448
|
+
<div part="stack">${this.renderStage()} ${this.renderSides()}</div>
|
|
1449
|
+
<div part="stack">${this.renderSlots()} ${this.renderBidPanel()}</div>
|
|
1450
|
+
</div>
|
|
1451
|
+
</section>`;
|
|
1452
|
+
}
|
|
1453
|
+
renderStage() {
|
|
1454
|
+
const text = this.text;
|
|
1455
|
+
if (this.modelUnavailable)
|
|
1456
|
+
return html`<div part="stage"><p part="stage-fallback">${text.noModel}</p></div>`;
|
|
1457
|
+
return html`<div part="stage">
|
|
1458
|
+
${keyed(this.canvasRevision, html`<canvas
|
|
1459
|
+
part="shirt"
|
|
1460
|
+
tabindex="0"
|
|
1461
|
+
role="img"
|
|
1462
|
+
aria-label=${text.shirtAria}
|
|
1463
|
+
@pointerdown=${this.onPointerDown}
|
|
1464
|
+
@pointermove=${this.onPointerMove}
|
|
1465
|
+
@pointerup=${this.onPointerUp}
|
|
1466
|
+
@pointercancel=${this.onPointerCancel}
|
|
1467
|
+
@lostpointercapture=${this.onPointerCancel}
|
|
1468
|
+
@keydown=${this.onShirtKey}
|
|
1469
|
+
></canvas>`)}
|
|
1470
|
+
${this.modelLoading ? html`<p part="stage-hint loader" role="status">${text.loading}</p>` : html`<p part="stage-hint">${text.hint}</p>`}
|
|
1471
|
+
<div part="stage-controls">
|
|
1472
|
+
<button
|
|
1473
|
+
part="zoom-button"
|
|
1474
|
+
type="button"
|
|
1475
|
+
aria-label=${text.zoomOut}
|
|
1476
|
+
@click=${() => this.renderer?.zoomBy(-0.1)}
|
|
1477
|
+
>
|
|
1478
|
+
−
|
|
1479
|
+
</button>
|
|
1480
|
+
<button
|
|
1481
|
+
part="zoom-button"
|
|
1482
|
+
type="button"
|
|
1483
|
+
aria-label=${text.zoomIn}
|
|
1484
|
+
@click=${() => this.renderer?.zoomBy(0.1)}
|
|
1485
|
+
>
|
|
1486
|
+
+
|
|
1487
|
+
</button>
|
|
1488
|
+
</div>
|
|
1489
|
+
</div>`;
|
|
1490
|
+
}
|
|
1491
|
+
renderSides() {
|
|
1492
|
+
return html`<div part="side-switch" role="group" aria-label=${this.text.views}>
|
|
1493
|
+
${this.sides.map((side) => html`<button
|
|
1494
|
+
part=${`side-button${this.side === side ? " side-button-active" : ""}`}
|
|
1495
|
+
type="button"
|
|
1496
|
+
aria-pressed=${String(this.side === side)}
|
|
1497
|
+
@click=${() => this.showSide(side)}
|
|
1498
|
+
>
|
|
1499
|
+
${this.text.sides[side]}
|
|
1500
|
+
</button>`)}
|
|
1501
|
+
</div>`;
|
|
1502
|
+
}
|
|
1503
|
+
renderSlots() {
|
|
1504
|
+
const text = this.text;
|
|
1505
|
+
return html`<div part="stack">
|
|
1506
|
+
<h3 part="section-title">${text.slots}</h3>
|
|
1507
|
+
<ul part="slot-list">
|
|
1508
|
+
${this.orderedSlots.map((slot) => {
|
|
1509
|
+
const selected = slot.id === this.selectedSlotId;
|
|
1510
|
+
const leading = slot.leadingAmountCents !== null && !!slot.leadingBrandName;
|
|
1511
|
+
const parts = ["slot", selected && "slot-selected", slot.isReserved && "slot-reserved"].filter(Boolean).join(" ");
|
|
1512
|
+
return html`<li>
|
|
1513
|
+
<button
|
|
1514
|
+
part=${parts}
|
|
1515
|
+
type="button"
|
|
1516
|
+
aria-pressed=${String(selected)}
|
|
1517
|
+
?disabled=${!!slot.isReserved}
|
|
1518
|
+
@click=${() => this.select(slot)}
|
|
1519
|
+
>
|
|
1520
|
+
<span part="slot-name">${slot.name}</span>
|
|
1521
|
+
<span part="slot-detail"
|
|
1522
|
+
>${text.sides[slot.side]} · ${slot.printWidthCm} × ${slot.printHeightCm} cm</span
|
|
1523
|
+
>
|
|
1524
|
+
<span part="slot-price price">
|
|
1525
|
+
${slot.isReserved ? html`<small>${text.reserved}</small>` : leading ? html`<small>${slot.leadingBrandName} ${text.leads}</small
|
|
1526
|
+
>${this.formatMoney(slot.leadingAmountCents ?? 0)}` : html`<small>${text.from}</small>${this.formatMoney(slot.minimumBidCents)}`}
|
|
1527
|
+
</span>
|
|
1528
|
+
</button>
|
|
1529
|
+
</li>`;
|
|
1530
|
+
})}
|
|
1531
|
+
</ul>
|
|
1532
|
+
</div>`;
|
|
1533
|
+
}
|
|
1534
|
+
renderBidPanel() {
|
|
1535
|
+
const text = this.text;
|
|
1536
|
+
const slot = this.selectedSlot;
|
|
1537
|
+
if (!slot)
|
|
1538
|
+
return html`<p part="hint">${text.pick}</p>`;
|
|
1539
|
+
if (slot.isReserved)
|
|
1540
|
+
return html`<div part="bid-panel">
|
|
1541
|
+
<h3 part="bid-title">${slot.name}</h3>
|
|
1542
|
+
<p part="hint">${text.reserved}</p>
|
|
1543
|
+
</div>`;
|
|
1544
|
+
const leading = slot.leadingAmountCents !== null && !!slot.leadingBrandName;
|
|
1545
|
+
const problem = this.amountProblem(slot);
|
|
1546
|
+
const amountCents = Math.round((this.amountEuros ?? 0) * 100);
|
|
1547
|
+
return html`<div part="bid-panel">
|
|
1548
|
+
<h3 part="bid-title">${slot.name}</h3>
|
|
1549
|
+
${leading ? html`<p part="leader">
|
|
1550
|
+
${slot.leadingArtworkUrl ? html`<img
|
|
1551
|
+
part="leader-logo"
|
|
1552
|
+
src=${slot.leadingArtworkUrl}
|
|
1553
|
+
alt=${slot.leadingBrandName ?? ""}
|
|
1554
|
+
loading="lazy"
|
|
1555
|
+
/>` : nothing}
|
|
1556
|
+
<span
|
|
1557
|
+
>${text.current}:
|
|
1558
|
+
<strong part="price">${this.formatMoney(slot.leadingAmountCents ?? 0)}</strong> ·
|
|
1559
|
+
${slot.leadingBrandName}</span
|
|
1560
|
+
>
|
|
1561
|
+
</p>` : nothing}
|
|
1562
|
+
<p part="hint">
|
|
1563
|
+
${text.minimum}: <strong>${this.formatMoney(slot.minimumBidCents)}</strong>.
|
|
1564
|
+
${text.increments} ${this.formatMoney(slot.incrementCents)}.
|
|
1565
|
+
</p>
|
|
1566
|
+
${this.biddingOpen ? html`<form part="bid-form" novalidate @submit=${this.submitBid}>
|
|
1567
|
+
<label part="label">
|
|
1568
|
+
${text.amount}
|
|
1569
|
+
<input
|
|
1570
|
+
part="input"
|
|
1571
|
+
type="number"
|
|
1572
|
+
inputmode="decimal"
|
|
1573
|
+
name="amount"
|
|
1574
|
+
.value=${this.amountEuros === null ? "" : String(this.amountEuros)}
|
|
1575
|
+
min=${slot.minimumBidCents / 100}
|
|
1576
|
+
step=${Math.max(1, slot.incrementCents) / 100}
|
|
1577
|
+
aria-invalid=${problem ? "true" : "false"}
|
|
1578
|
+
aria-describedby="bid-problem"
|
|
1579
|
+
@input=${(event) => {
|
|
1580
|
+
const value = event.target.valueAsNumber;
|
|
1581
|
+
this.amountEuros = Number.isFinite(value) ? value : null;
|
|
1582
|
+
}}
|
|
1583
|
+
/>
|
|
1584
|
+
</label>
|
|
1585
|
+
<p id="bid-problem" part="field-error" role="alert" ?hidden=${!problem}>
|
|
1586
|
+
${problem ?? ""}
|
|
1587
|
+
</p>
|
|
1588
|
+
<button part="button submit" type="submit" ?disabled=${!!problem}>
|
|
1589
|
+
${leading ? text.outbid : text.bid}${problem ? "" : ` · ${this.formatMoney(amountCents)}`}
|
|
1590
|
+
</button>
|
|
1591
|
+
<p part="hint">
|
|
1592
|
+
<slot name="bid-note">${this.bidMode === "host" ? text.guestNote : text.note}</slot>
|
|
1593
|
+
</p>
|
|
1594
|
+
</form>` : html`<p part="hint">${text.closed}</p>`}
|
|
1595
|
+
${this.renderStatus()}
|
|
1596
|
+
</div>`;
|
|
1597
|
+
}
|
|
1598
|
+
renderStatus() {
|
|
1599
|
+
const text = this.text;
|
|
1600
|
+
switch (this.status) {
|
|
1601
|
+
case "waiting":
|
|
1602
|
+
return html`<p part="status hint" role="status">${text.waiting}</p>`;
|
|
1603
|
+
case "paid":
|
|
1604
|
+
return html`<p part="status success" role="status">${text.paid}</p>`;
|
|
1605
|
+
case "blocked":
|
|
1606
|
+
return html`<p part="status error" role="alert">
|
|
1607
|
+
${text.popupBlocked}
|
|
1608
|
+
<a href=${this.blockedUrl} target="_blank" rel="opener">${text.openBid}</a>
|
|
1609
|
+
</p>`;
|
|
1610
|
+
default:
|
|
1611
|
+
return nothing;
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
// src/ui/shirt-sponsors/index.ts
|
|
1617
|
+
function defineWodiraShirtElements2() {
|
|
1618
|
+
if (!globalThis.customElements)
|
|
1619
|
+
throw new Error("WODira shirt elements require a browser.");
|
|
1620
|
+
if (!customElements.get("wodira-shirt-auction"))
|
|
1621
|
+
customElements.define("wodira-shirt-auction", WodiraShirtAuction2);
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
export { wodiraUiStyles, WodiraShirtAuction2, defineWodiraShirtElements2 };
|