@vtex/ads-stories 0.4.0 → 0.4.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.
@@ -26,6 +26,1320 @@ __export(index_exports, {
26
26
  });
27
27
  module.exports = __toCommonJS(index_exports);
28
28
 
29
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/lib/element-internals.js
30
+ var ElementInternalsShim = class ElementInternals {
31
+ get shadowRoot() {
32
+ return this.__host.__shadowRoot;
33
+ }
34
+ constructor(_host) {
35
+ this.ariaActiveDescendantElement = null;
36
+ this.ariaAtomic = "";
37
+ this.ariaAutoComplete = "";
38
+ this.ariaBrailleLabel = "";
39
+ this.ariaBrailleRoleDescription = "";
40
+ this.ariaBusy = "";
41
+ this.ariaChecked = "";
42
+ this.ariaColCount = "";
43
+ this.ariaColIndex = "";
44
+ this.ariaColIndexText = "";
45
+ this.ariaColSpan = "";
46
+ this.ariaControlsElements = null;
47
+ this.ariaCurrent = "";
48
+ this.ariaDescribedByElements = null;
49
+ this.ariaDescription = "";
50
+ this.ariaDetailsElements = null;
51
+ this.ariaDisabled = "";
52
+ this.ariaErrorMessageElements = null;
53
+ this.ariaExpanded = "";
54
+ this.ariaFlowToElements = null;
55
+ this.ariaHasPopup = "";
56
+ this.ariaHidden = "";
57
+ this.ariaInvalid = "";
58
+ this.ariaKeyShortcuts = "";
59
+ this.ariaLabel = "";
60
+ this.ariaLabelledByElements = null;
61
+ this.ariaLevel = "";
62
+ this.ariaLive = "";
63
+ this.ariaModal = "";
64
+ this.ariaMultiLine = "";
65
+ this.ariaMultiSelectable = "";
66
+ this.ariaOrientation = "";
67
+ this.ariaOwnsElements = null;
68
+ this.ariaPlaceholder = "";
69
+ this.ariaPosInSet = "";
70
+ this.ariaPressed = "";
71
+ this.ariaReadOnly = "";
72
+ this.ariaRelevant = "";
73
+ this.ariaRequired = "";
74
+ this.ariaRoleDescription = "";
75
+ this.ariaRowCount = "";
76
+ this.ariaRowIndex = "";
77
+ this.ariaRowIndexText = "";
78
+ this.ariaRowSpan = "";
79
+ this.ariaSelected = "";
80
+ this.ariaSetSize = "";
81
+ this.ariaSort = "";
82
+ this.ariaValueMax = "";
83
+ this.ariaValueMin = "";
84
+ this.ariaValueNow = "";
85
+ this.ariaValueText = "";
86
+ this.role = "";
87
+ this.form = null;
88
+ this.labels = [];
89
+ this.states = /* @__PURE__ */ new Set();
90
+ this.validationMessage = "";
91
+ this.validity = {};
92
+ this.willValidate = true;
93
+ this.__host = _host;
94
+ }
95
+ checkValidity() {
96
+ console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true.");
97
+ return true;
98
+ }
99
+ reportValidity() {
100
+ return true;
101
+ }
102
+ setFormValue() {
103
+ }
104
+ setValidity() {
105
+ }
106
+ };
107
+
108
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/lib/events.js
109
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f4) {
110
+ if (kind === "m") throw new TypeError("Private method is not writable");
111
+ if (kind === "a" && !f4) throw new TypeError("Private accessor was defined without a setter");
112
+ if (typeof state === "function" ? receiver !== state || !f4 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
113
+ return kind === "a" ? f4.call(receiver, value) : f4 ? f4.value = value : state.set(receiver, value), value;
114
+ };
115
+ var __classPrivateFieldGet = function(receiver, state, kind, f4) {
116
+ if (kind === "a" && !f4) throw new TypeError("Private accessor was defined without a getter");
117
+ if (typeof state === "function" ? receiver !== state || !f4 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
118
+ return kind === "m" ? f4 : kind === "a" ? f4.call(receiver) : f4 ? f4.value : state.get(receiver);
119
+ };
120
+ var _Event_cancelable;
121
+ var _Event_bubbles;
122
+ var _Event_composed;
123
+ var _Event_defaultPrevented;
124
+ var _Event_timestamp;
125
+ var _Event_propagationStopped;
126
+ var _Event_type;
127
+ var _Event_target;
128
+ var _Event_isBeingDispatched;
129
+ var _a;
130
+ var _CustomEvent_detail;
131
+ var _b;
132
+ var NONE = 0;
133
+ var CAPTURING_PHASE = 1;
134
+ var AT_TARGET = 2;
135
+ var BUBBLING_PHASE = 3;
136
+ var enumerableProperty = { __proto__: null };
137
+ enumerableProperty.enumerable = true;
138
+ Object.freeze(enumerableProperty);
139
+ var EventShim = (_a = class Event {
140
+ constructor(type, options = {}) {
141
+ _Event_cancelable.set(this, false);
142
+ _Event_bubbles.set(this, false);
143
+ _Event_composed.set(this, false);
144
+ _Event_defaultPrevented.set(this, false);
145
+ _Event_timestamp.set(this, Date.now());
146
+ _Event_propagationStopped.set(this, false);
147
+ _Event_type.set(this, void 0);
148
+ _Event_target.set(this, void 0);
149
+ _Event_isBeingDispatched.set(this, void 0);
150
+ this.NONE = NONE;
151
+ this.CAPTURING_PHASE = CAPTURING_PHASE;
152
+ this.AT_TARGET = AT_TARGET;
153
+ this.BUBBLING_PHASE = BUBBLING_PHASE;
154
+ if (arguments.length === 0)
155
+ throw new Error(`The type argument must be specified`);
156
+ if (typeof options !== "object" || !options) {
157
+ throw new Error(`The "options" argument must be an object`);
158
+ }
159
+ const { bubbles, cancelable, composed } = options;
160
+ __classPrivateFieldSet(this, _Event_cancelable, !!cancelable, "f");
161
+ __classPrivateFieldSet(this, _Event_bubbles, !!bubbles, "f");
162
+ __classPrivateFieldSet(this, _Event_composed, !!composed, "f");
163
+ __classPrivateFieldSet(this, _Event_type, `${type}`, "f");
164
+ __classPrivateFieldSet(this, _Event_target, null, "f");
165
+ __classPrivateFieldSet(this, _Event_isBeingDispatched, false, "f");
166
+ }
167
+ initEvent(_type, _bubbles, _cancelable) {
168
+ throw new Error("Method not implemented.");
169
+ }
170
+ stopImmediatePropagation() {
171
+ this.stopPropagation();
172
+ }
173
+ preventDefault() {
174
+ __classPrivateFieldSet(this, _Event_defaultPrevented, true, "f");
175
+ }
176
+ get target() {
177
+ return __classPrivateFieldGet(this, _Event_target, "f");
178
+ }
179
+ get currentTarget() {
180
+ return __classPrivateFieldGet(this, _Event_target, "f");
181
+ }
182
+ get srcElement() {
183
+ return __classPrivateFieldGet(this, _Event_target, "f");
184
+ }
185
+ get type() {
186
+ return __classPrivateFieldGet(this, _Event_type, "f");
187
+ }
188
+ get cancelable() {
189
+ return __classPrivateFieldGet(this, _Event_cancelable, "f");
190
+ }
191
+ get defaultPrevented() {
192
+ return __classPrivateFieldGet(this, _Event_cancelable, "f") && __classPrivateFieldGet(this, _Event_defaultPrevented, "f");
193
+ }
194
+ get timeStamp() {
195
+ return __classPrivateFieldGet(this, _Event_timestamp, "f");
196
+ }
197
+ composedPath() {
198
+ return __classPrivateFieldGet(this, _Event_isBeingDispatched, "f") ? [__classPrivateFieldGet(this, _Event_target, "f")] : [];
199
+ }
200
+ get returnValue() {
201
+ return !__classPrivateFieldGet(this, _Event_cancelable, "f") || !__classPrivateFieldGet(this, _Event_defaultPrevented, "f");
202
+ }
203
+ get bubbles() {
204
+ return __classPrivateFieldGet(this, _Event_bubbles, "f");
205
+ }
206
+ get composed() {
207
+ return __classPrivateFieldGet(this, _Event_composed, "f");
208
+ }
209
+ get eventPhase() {
210
+ return __classPrivateFieldGet(this, _Event_isBeingDispatched, "f") ? _a.AT_TARGET : _a.NONE;
211
+ }
212
+ get cancelBubble() {
213
+ return __classPrivateFieldGet(this, _Event_propagationStopped, "f");
214
+ }
215
+ set cancelBubble(value) {
216
+ if (value) {
217
+ __classPrivateFieldSet(this, _Event_propagationStopped, true, "f");
218
+ }
219
+ }
220
+ stopPropagation() {
221
+ __classPrivateFieldSet(this, _Event_propagationStopped, true, "f");
222
+ }
223
+ get isTrusted() {
224
+ return false;
225
+ }
226
+ }, _Event_cancelable = /* @__PURE__ */ new WeakMap(), _Event_bubbles = /* @__PURE__ */ new WeakMap(), _Event_composed = /* @__PURE__ */ new WeakMap(), _Event_defaultPrevented = /* @__PURE__ */ new WeakMap(), _Event_timestamp = /* @__PURE__ */ new WeakMap(), _Event_propagationStopped = /* @__PURE__ */ new WeakMap(), _Event_type = /* @__PURE__ */ new WeakMap(), _Event_target = /* @__PURE__ */ new WeakMap(), _Event_isBeingDispatched = /* @__PURE__ */ new WeakMap(), _a.NONE = NONE, _a.CAPTURING_PHASE = CAPTURING_PHASE, _a.AT_TARGET = AT_TARGET, _a.BUBBLING_PHASE = BUBBLING_PHASE, _a);
227
+ Object.defineProperties(EventShim.prototype, {
228
+ initEvent: enumerableProperty,
229
+ stopImmediatePropagation: enumerableProperty,
230
+ preventDefault: enumerableProperty,
231
+ target: enumerableProperty,
232
+ currentTarget: enumerableProperty,
233
+ srcElement: enumerableProperty,
234
+ type: enumerableProperty,
235
+ cancelable: enumerableProperty,
236
+ defaultPrevented: enumerableProperty,
237
+ timeStamp: enumerableProperty,
238
+ composedPath: enumerableProperty,
239
+ returnValue: enumerableProperty,
240
+ bubbles: enumerableProperty,
241
+ composed: enumerableProperty,
242
+ eventPhase: enumerableProperty,
243
+ cancelBubble: enumerableProperty,
244
+ stopPropagation: enumerableProperty,
245
+ isTrusted: enumerableProperty
246
+ });
247
+ var CustomEventShim = (_b = class CustomEvent extends EventShim {
248
+ constructor(type, options = {}) {
249
+ var _a13;
250
+ super(type, options);
251
+ _CustomEvent_detail.set(this, void 0);
252
+ __classPrivateFieldSet(this, _CustomEvent_detail, (_a13 = options == null ? void 0 : options.detail) != null ? _a13 : null, "f");
253
+ }
254
+ initCustomEvent(_type, _bubbles, _cancelable, _detail) {
255
+ throw new Error("Method not implemented.");
256
+ }
257
+ get detail() {
258
+ return __classPrivateFieldGet(this, _CustomEvent_detail, "f");
259
+ }
260
+ }, _CustomEvent_detail = /* @__PURE__ */ new WeakMap(), _b);
261
+ Object.defineProperties(CustomEventShim.prototype, {
262
+ detail: enumerableProperty
263
+ });
264
+ var EventShimWithRealType = EventShim;
265
+ var CustomEventShimWithRealType = CustomEventShim;
266
+
267
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/lib/css.js
268
+ var _a2;
269
+ var CSSRuleShim = (_a2 = class CSSRule {
270
+ constructor() {
271
+ this.STYLE_RULE = 1;
272
+ this.CHARSET_RULE = 2;
273
+ this.IMPORT_RULE = 3;
274
+ this.MEDIA_RULE = 4;
275
+ this.FONT_FACE_RULE = 5;
276
+ this.PAGE_RULE = 6;
277
+ this.NAMESPACE_RULE = 10;
278
+ this.KEYFRAMES_RULE = 7;
279
+ this.KEYFRAME_RULE = 8;
280
+ this.SUPPORTS_RULE = 12;
281
+ this.COUNTER_STYLE_RULE = 11;
282
+ this.FONT_FEATURE_VALUES_RULE = 14;
283
+ this.MARGIN_RULE = 9;
284
+ this.__parentStyleSheet = null;
285
+ this.cssText = "";
286
+ }
287
+ get parentRule() {
288
+ return null;
289
+ }
290
+ get parentStyleSheet() {
291
+ return this.__parentStyleSheet;
292
+ }
293
+ get type() {
294
+ return 0;
295
+ }
296
+ }, _a2.STYLE_RULE = 1, _a2.CHARSET_RULE = 2, _a2.IMPORT_RULE = 3, _a2.MEDIA_RULE = 4, _a2.FONT_FACE_RULE = 5, _a2.PAGE_RULE = 6, _a2.NAMESPACE_RULE = 10, _a2.KEYFRAMES_RULE = 7, _a2.KEYFRAME_RULE = 8, _a2.SUPPORTS_RULE = 12, _a2.COUNTER_STYLE_RULE = 11, _a2.FONT_FEATURE_VALUES_RULE = 14, _a2.MARGIN_RULE = 9, _a2);
297
+
298
+ // ../../node_modules/.pnpm/@lit-labs+ssr-dom-shim@1.6.0/node_modules/@lit-labs/ssr-dom-shim/index.js
299
+ var _a3;
300
+ (_a3 = globalThis.Event) != null ? _a3 : globalThis.Event = EventShimWithRealType;
301
+ var _a4;
302
+ (_a4 = globalThis.CustomEvent) != null ? _a4 : globalThis.CustomEvent = CustomEventShimWithRealType;
303
+ var constructionToken = Symbol();
304
+ var isCaptureEventListener = (options) => {
305
+ var _a13;
306
+ return typeof options === "boolean" ? options : (_a13 = options == null ? void 0 : options.capture) != null ? _a13 : false;
307
+ };
308
+ var enumerableProperty2 = { __proto__: null };
309
+ enumerableProperty2.enumerable = true;
310
+ Object.freeze(enumerableProperty2);
311
+ var EventTarget = class {
312
+ constructor() {
313
+ this.__eventListeners = /* @__PURE__ */ new Map();
314
+ this.__captureEventListeners = /* @__PURE__ */ new Map();
315
+ }
316
+ addEventListener(type, callback, options) {
317
+ var _a13;
318
+ if (callback === void 0 || callback === null) {
319
+ return;
320
+ }
321
+ const eventListenersMap = isCaptureEventListener(options) ? this.__captureEventListeners : this.__eventListeners;
322
+ let eventListeners = eventListenersMap.get(type);
323
+ if (eventListeners === void 0) {
324
+ eventListeners = /* @__PURE__ */ new Map();
325
+ eventListenersMap.set(type, eventListeners);
326
+ } else if (eventListeners.has(callback)) {
327
+ return;
328
+ }
329
+ const normalizedOptions = typeof options === "object" && options ? options : {};
330
+ (_a13 = normalizedOptions.signal) == null ? void 0 : _a13.addEventListener("abort", () => this.removeEventListener(type, callback, options));
331
+ eventListeners.set(callback, normalizedOptions != null ? normalizedOptions : {});
332
+ }
333
+ removeEventListener(type, callback, options) {
334
+ if (callback === void 0 || callback === null) {
335
+ return;
336
+ }
337
+ const eventListenersMap = isCaptureEventListener(options) ? this.__captureEventListeners : this.__eventListeners;
338
+ const eventListeners = eventListenersMap.get(type);
339
+ if (eventListeners !== void 0) {
340
+ eventListeners.delete(callback);
341
+ if (!eventListeners.size) {
342
+ eventListenersMap.delete(type);
343
+ }
344
+ }
345
+ }
346
+ dispatchEvent(event) {
347
+ let composedPath = this.__resolveFullEventPath();
348
+ if (!event.composed && this.__host) {
349
+ composedPath = composedPath.slice(0, composedPath.indexOf(this.__host));
350
+ }
351
+ let stopPropagation = false;
352
+ let stopImmediatePropagation = false;
353
+ let eventPhase = EventShimWithRealType.NONE;
354
+ let target = null;
355
+ let tmpTarget = null;
356
+ let currentTarget = null;
357
+ const originalStopPropagation = event.stopPropagation;
358
+ const originalStopImmediatePropagation = event.stopImmediatePropagation;
359
+ Object.defineProperties(event, {
360
+ target: {
361
+ get() {
362
+ return target != null ? target : tmpTarget;
363
+ },
364
+ ...enumerableProperty2
365
+ },
366
+ srcElement: {
367
+ get() {
368
+ return event.target;
369
+ },
370
+ ...enumerableProperty2
371
+ },
372
+ currentTarget: {
373
+ get() {
374
+ return currentTarget;
375
+ },
376
+ ...enumerableProperty2
377
+ },
378
+ eventPhase: {
379
+ get() {
380
+ return eventPhase;
381
+ },
382
+ ...enumerableProperty2
383
+ },
384
+ composedPath: {
385
+ value: () => composedPath,
386
+ ...enumerableProperty2
387
+ },
388
+ stopPropagation: {
389
+ value: () => {
390
+ stopPropagation = true;
391
+ originalStopPropagation.call(event);
392
+ },
393
+ ...enumerableProperty2
394
+ },
395
+ stopImmediatePropagation: {
396
+ value: () => {
397
+ stopImmediatePropagation = true;
398
+ originalStopImmediatePropagation.call(event);
399
+ },
400
+ ...enumerableProperty2
401
+ }
402
+ });
403
+ const invokeEventListener = (listener, options, eventListenerMap) => {
404
+ if (typeof listener === "function") {
405
+ listener(event);
406
+ } else if (typeof (listener == null ? void 0 : listener.handleEvent) === "function") {
407
+ listener.handleEvent(event);
408
+ }
409
+ if (options.once) {
410
+ eventListenerMap.delete(listener);
411
+ }
412
+ };
413
+ const finishDispatch = () => {
414
+ currentTarget = null;
415
+ eventPhase = EventShimWithRealType.NONE;
416
+ return !event.defaultPrevented;
417
+ };
418
+ const captureEventPath = composedPath.slice().reverse();
419
+ target = !this.__host || !event.composed ? this : null;
420
+ const retarget = (eventTargets) => {
421
+ tmpTarget = this;
422
+ while (tmpTarget.__host && eventTargets.includes(tmpTarget.__host)) {
423
+ tmpTarget = tmpTarget.__host;
424
+ }
425
+ };
426
+ for (const eventTarget of captureEventPath) {
427
+ if (!target && (!tmpTarget || tmpTarget === eventTarget.__host)) {
428
+ retarget(captureEventPath.slice(captureEventPath.indexOf(eventTarget)));
429
+ }
430
+ currentTarget = eventTarget;
431
+ eventPhase = eventTarget === event.target ? EventShimWithRealType.AT_TARGET : EventShimWithRealType.CAPTURING_PHASE;
432
+ const captureEventListeners = eventTarget.__captureEventListeners.get(event.type);
433
+ if (captureEventListeners) {
434
+ for (const [listener, options] of captureEventListeners) {
435
+ invokeEventListener(listener, options, captureEventListeners);
436
+ if (stopImmediatePropagation) {
437
+ return finishDispatch();
438
+ }
439
+ }
440
+ }
441
+ if (stopPropagation) {
442
+ return finishDispatch();
443
+ }
444
+ }
445
+ const bubbleEventPath = event.bubbles ? composedPath : [this];
446
+ tmpTarget = null;
447
+ for (const eventTarget of bubbleEventPath) {
448
+ if (!target && (!tmpTarget || eventTarget === tmpTarget.__host)) {
449
+ retarget(bubbleEventPath.slice(0, bubbleEventPath.indexOf(eventTarget) + 1));
450
+ }
451
+ currentTarget = eventTarget;
452
+ eventPhase = eventTarget === event.target ? EventShimWithRealType.AT_TARGET : EventShimWithRealType.BUBBLING_PHASE;
453
+ const eventListeners = eventTarget.__eventListeners.get(event.type);
454
+ if (eventListeners) {
455
+ for (const [listener, options] of eventListeners) {
456
+ invokeEventListener(listener, options, eventListeners);
457
+ if (stopImmediatePropagation) {
458
+ return finishDispatch();
459
+ }
460
+ }
461
+ }
462
+ if (stopPropagation) {
463
+ return finishDispatch();
464
+ }
465
+ }
466
+ return finishDispatch();
467
+ }
468
+ __resolveFullEventPath() {
469
+ if (this.__eventPathCache) {
470
+ return this.__eventPathCache;
471
+ } else if (!this.__eventTargetParent) {
472
+ return this.__eventPathCache = [this, documentShim, windowShim];
473
+ } else {
474
+ return this.__eventPathCache = [
475
+ this,
476
+ ...this.__eventTargetParent.__resolveFullEventPath()
477
+ ];
478
+ }
479
+ }
480
+ };
481
+ var attributes = /* @__PURE__ */ new WeakMap();
482
+ var attributesForElement = (element) => {
483
+ let attrs = attributes.get(element);
484
+ if (attrs === void 0) {
485
+ attributes.set(element, attrs = /* @__PURE__ */ new Map());
486
+ }
487
+ return attrs;
488
+ };
489
+ var NodeShim = class Node extends EventTarget {
490
+ getRootNode(options) {
491
+ var _a13;
492
+ if (options == null ? void 0 : options.composed) {
493
+ return document2;
494
+ }
495
+ const host = this.__host;
496
+ return (_a13 = host == null ? void 0 : host.__shadowRoot) != null ? _a13 : document2;
497
+ }
498
+ };
499
+ var DocumentShim = class Document2 extends NodeShim {
500
+ get adoptedStyleSheets() {
501
+ return [];
502
+ }
503
+ createTreeWalker() {
504
+ return {};
505
+ }
506
+ createTextNode() {
507
+ return {};
508
+ }
509
+ createElement() {
510
+ return {};
511
+ }
512
+ };
513
+ var documentShim = new DocumentShim();
514
+ var document2 = documentShim;
515
+ var WindowShim = class Window extends NodeShim {
516
+ constructor(token) {
517
+ super();
518
+ if (token !== constructionToken) {
519
+ throw new TypeError("Illegal constructor");
520
+ }
521
+ Object.assign(this, globalThis, {
522
+ CustomElementRegistry,
523
+ customElements: customElements2,
524
+ document: document2,
525
+ Document: DocumentShim,
526
+ Element: ElementShim,
527
+ EventTarget,
528
+ HTMLElement: HTMLElementShim,
529
+ Node: NodeShim,
530
+ ShadowRoot: ShadowRootShim,
531
+ window: this,
532
+ Window: WindowShim
533
+ });
534
+ }
535
+ };
536
+ var ElementShim = class Element extends NodeShim {
537
+ constructor() {
538
+ super(...arguments);
539
+ this.__shadowRootMode = null;
540
+ this.__shadowRoot = null;
541
+ this.__internals = null;
542
+ }
543
+ get attributes() {
544
+ return Array.from(attributesForElement(this)).map(([name, value]) => ({
545
+ name,
546
+ value
547
+ }));
548
+ }
549
+ get shadowRoot() {
550
+ if (this.__shadowRootMode === "closed") {
551
+ return null;
552
+ }
553
+ return this.__shadowRoot;
554
+ }
555
+ get localName() {
556
+ return this.constructor.__localName;
557
+ }
558
+ get tagName() {
559
+ var _a13;
560
+ return (_a13 = this.localName) == null ? void 0 : _a13.toUpperCase();
561
+ }
562
+ setAttribute(name, value) {
563
+ attributesForElement(this).set(name, String(value));
564
+ }
565
+ removeAttribute(name) {
566
+ attributesForElement(this).delete(name);
567
+ }
568
+ toggleAttribute(name, force) {
569
+ if (this.hasAttribute(name)) {
570
+ if (force === void 0 || !force) {
571
+ this.removeAttribute(name);
572
+ return false;
573
+ }
574
+ } else {
575
+ if (force === void 0 || force) {
576
+ this.setAttribute(name, "");
577
+ return true;
578
+ } else {
579
+ return false;
580
+ }
581
+ }
582
+ return true;
583
+ }
584
+ hasAttribute(name) {
585
+ return attributesForElement(this).has(name);
586
+ }
587
+ attachShadow(init) {
588
+ this.__shadowRootMode = init.mode;
589
+ const shadowRoot = new ShadowRootShim(constructionToken, init);
590
+ shadowRoot.__eventTargetParent = this;
591
+ shadowRoot.__host = this;
592
+ return this.__shadowRoot = shadowRoot;
593
+ }
594
+ attachInternals() {
595
+ if (this.__internals !== null) {
596
+ throw new Error(`Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`);
597
+ }
598
+ const internals = new ElementInternalsShim(this);
599
+ this.__internals = internals;
600
+ return internals;
601
+ }
602
+ getAttribute(name) {
603
+ const value = attributesForElement(this).get(name);
604
+ return value != null ? value : null;
605
+ }
606
+ };
607
+ var HTMLElementShim = class HTMLElement extends ElementShim {
608
+ };
609
+ var HTMLElementShimWithRealType = HTMLElementShim;
610
+ var ShadowRootShim = class ShadowRoot extends NodeShim {
611
+ get host() {
612
+ return this.__host;
613
+ }
614
+ constructor(constructionToken2, init) {
615
+ super();
616
+ if (constructionToken2 !== constructionToken2) {
617
+ throw new TypeError("Illegal constructor");
618
+ }
619
+ this.mode = init.mode;
620
+ }
621
+ };
622
+ var _a5;
623
+ (_a5 = globalThis.litServerRoot) != null ? _a5 : globalThis.litServerRoot = Object.defineProperty(new HTMLElementShimWithRealType(), "localName", {
624
+ // Patch localName (and tagName) to return a unique name.
625
+ get() {
626
+ return "lit-server-root";
627
+ }
628
+ });
629
+ function promiseWithResolvers() {
630
+ let resolve;
631
+ let reject;
632
+ const promise = new Promise((res, rej) => {
633
+ resolve = res;
634
+ reject = rej;
635
+ });
636
+ return { promise, resolve, reject };
637
+ }
638
+ var CustomElementRegistry = class {
639
+ constructor() {
640
+ this.__definitions = /* @__PURE__ */ new Map();
641
+ this.__reverseDefinitions = /* @__PURE__ */ new Map();
642
+ this.__pendingWhenDefineds = /* @__PURE__ */ new Map();
643
+ }
644
+ define(name, ctor) {
645
+ var _a13, _b3;
646
+ if (this.__definitions.has(name)) {
647
+ if (process.env.NODE_ENV === "development") {
648
+ console.warn(`'CustomElementRegistry' already has "${name}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
649
+ Make sure to test your application with a production build as repeat registrations will throw in production.`);
650
+ } else {
651
+ throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${name}" has already been used with this registry`);
652
+ }
653
+ }
654
+ if (this.__reverseDefinitions.has(ctor)) {
655
+ throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(ctor)}`);
656
+ }
657
+ ctor.__localName = name;
658
+ this.__definitions.set(name, {
659
+ ctor,
660
+ // Note it's important we read `observedAttributes` in case it is a getter
661
+ // with side-effects, as is the case in Lit, where it triggers class
662
+ // finalization.
663
+ //
664
+ // TODO(aomarks) To be spec compliant, we should also capture the
665
+ // registration-time lifecycle methods like `connectedCallback`. For them
666
+ // to be actually accessible to e.g. the Lit SSR element renderer, though,
667
+ // we'd need to introduce a new API for accessing them (since `get` only
668
+ // returns the constructor).
669
+ observedAttributes: (_a13 = ctor.observedAttributes) != null ? _a13 : []
670
+ });
671
+ this.__reverseDefinitions.set(ctor, name);
672
+ (_b3 = this.__pendingWhenDefineds.get(name)) == null ? void 0 : _b3.resolve(ctor);
673
+ this.__pendingWhenDefineds.delete(name);
674
+ }
675
+ get(name) {
676
+ const definition = this.__definitions.get(name);
677
+ return definition == null ? void 0 : definition.ctor;
678
+ }
679
+ getName(ctor) {
680
+ var _a13;
681
+ return (_a13 = this.__reverseDefinitions.get(ctor)) != null ? _a13 : null;
682
+ }
683
+ initialize(_root) {
684
+ throw new Error(`customElements.initialize is not currently supported in SSR. Please file a bug if you need it.`);
685
+ }
686
+ upgrade(_element) {
687
+ throw new Error(`customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.`);
688
+ }
689
+ async whenDefined(name) {
690
+ const definition = this.__definitions.get(name);
691
+ if (definition) {
692
+ return definition.ctor;
693
+ }
694
+ let withResolvers = this.__pendingWhenDefineds.get(name);
695
+ if (!withResolvers) {
696
+ withResolvers = promiseWithResolvers();
697
+ this.__pendingWhenDefineds.set(name, withResolvers);
698
+ }
699
+ return withResolvers.promise;
700
+ }
701
+ };
702
+ var CustomElementRegistryShimWithRealType = CustomElementRegistry;
703
+ var customElements2 = new CustomElementRegistryShimWithRealType();
704
+ var windowShim = new WindowShim(constructionToken);
705
+
706
+ // ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/node/css-tag.js
707
+ var t = globalThis;
708
+ var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
709
+ var s = Symbol();
710
+ var o = /* @__PURE__ */ new WeakMap();
711
+ var n = class {
712
+ constructor(t5, e6, o8) {
713
+ if (this._$cssResult$ = true, o8 !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
714
+ this.cssText = t5, this.t = e6;
715
+ }
716
+ get styleSheet() {
717
+ let t5 = this.o;
718
+ const s5 = this.t;
719
+ if (e && void 0 === t5) {
720
+ const e6 = void 0 !== s5 && 1 === s5.length;
721
+ e6 && (t5 = o.get(s5)), void 0 === t5 && ((this.o = t5 = new CSSStyleSheet()).replaceSync(this.cssText), e6 && o.set(s5, t5));
722
+ }
723
+ return t5;
724
+ }
725
+ toString() {
726
+ return this.cssText;
727
+ }
728
+ };
729
+ var r = (t5) => new n("string" == typeof t5 ? t5 : t5 + "", void 0, s);
730
+ var i = (t5, ...e6) => {
731
+ const o8 = 1 === t5.length ? t5[0] : e6.reduce((e7, s5, o9) => e7 + ((t6) => {
732
+ if (true === t6._$cssResult$) return t6.cssText;
733
+ if ("number" == typeof t6) return t6;
734
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + t6 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
735
+ })(s5) + t5[o9 + 1], t5[0]);
736
+ return new n(o8, t5, s);
737
+ };
738
+ var S = (s5, o8) => {
739
+ if (e) s5.adoptedStyleSheets = o8.map((t5) => t5 instanceof CSSStyleSheet ? t5 : t5.styleSheet);
740
+ else for (const e6 of o8) {
741
+ const o9 = document.createElement("style"), n6 = t.litNonce;
742
+ void 0 !== n6 && o9.setAttribute("nonce", n6), o9.textContent = e6.cssText, s5.appendChild(o9);
743
+ }
744
+ };
745
+ var c = e || void 0 === t.CSSStyleSheet ? (t5) => t5 : (t5) => t5 instanceof CSSStyleSheet ? ((t6) => {
746
+ let e6 = "";
747
+ for (const s5 of t6.cssRules) e6 += s5.cssText;
748
+ return r(e6);
749
+ })(t5) : t5;
750
+
751
+ // ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/node/reactive-element.js
752
+ var { is: h, defineProperty: r2, getOwnPropertyDescriptor: o2, getOwnPropertyNames: n2, getOwnPropertySymbols: a, getPrototypeOf: c2 } = Object;
753
+ var l = globalThis;
754
+ var _a6;
755
+ (_a6 = l.customElements) != null ? _a6 : l.customElements = customElements2;
756
+ var p = l.trustedTypes;
757
+ var d = p ? p.emptyScript : "";
758
+ var u = l.reactiveElementPolyfillSupport;
759
+ var f = (t5, s5) => t5;
760
+ var b = { toAttribute(t5, s5) {
761
+ switch (s5) {
762
+ case Boolean:
763
+ t5 = t5 ? d : null;
764
+ break;
765
+ case Object:
766
+ case Array:
767
+ t5 = null == t5 ? t5 : JSON.stringify(t5);
768
+ }
769
+ return t5;
770
+ }, fromAttribute(t5, s5) {
771
+ let i5 = t5;
772
+ switch (s5) {
773
+ case Boolean:
774
+ i5 = null !== t5;
775
+ break;
776
+ case Number:
777
+ i5 = null === t5 ? null : Number(t5);
778
+ break;
779
+ case Object:
780
+ case Array:
781
+ try {
782
+ i5 = JSON.parse(t5);
783
+ } catch (t6) {
784
+ i5 = null;
785
+ }
786
+ }
787
+ return i5;
788
+ } };
789
+ var m = (t5, s5) => !h(t5, s5);
790
+ var y = { attribute: true, type: String, converter: b, reflect: false, useDefault: false, hasChanged: m };
791
+ var _a7, _b2;
792
+ (_a7 = Symbol.metadata) != null ? _a7 : Symbol.metadata = Symbol("metadata"), (_b2 = l.litPropertyMetadata) != null ? _b2 : l.litPropertyMetadata = /* @__PURE__ */ new WeakMap();
793
+ var _a8;
794
+ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElementShimWithRealType) {
795
+ static addInitializer(t5) {
796
+ var _a13;
797
+ this._$Ei(), ((_a13 = this.l) != null ? _a13 : this.l = []).push(t5);
798
+ }
799
+ static get observedAttributes() {
800
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
801
+ }
802
+ static createProperty(t5, s5 = y) {
803
+ if (s5.state && (s5.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t5) && ((s5 = Object.create(s5)).wrapped = true), this.elementProperties.set(t5, s5), !s5.noAccessor) {
804
+ const i5 = Symbol(), e6 = this.getPropertyDescriptor(t5, i5, s5);
805
+ void 0 !== e6 && r2(this.prototype, t5, e6);
806
+ }
807
+ }
808
+ static getPropertyDescriptor(t5, s5, i5) {
809
+ var _a13;
810
+ const { get: e6, set: h5 } = (_a13 = o2(this.prototype, t5)) != null ? _a13 : { get() {
811
+ return this[s5];
812
+ }, set(t6) {
813
+ this[s5] = t6;
814
+ } };
815
+ return { get: e6, set(s6) {
816
+ const r6 = e6 == null ? void 0 : e6.call(this);
817
+ h5 == null ? void 0 : h5.call(this, s6), this.requestUpdate(t5, r6, i5);
818
+ }, configurable: true, enumerable: true };
819
+ }
820
+ static getPropertyOptions(t5) {
821
+ var _a13;
822
+ return (_a13 = this.elementProperties.get(t5)) != null ? _a13 : y;
823
+ }
824
+ static _$Ei() {
825
+ if (this.hasOwnProperty(f("elementProperties"))) return;
826
+ const t5 = c2(this);
827
+ t5.finalize(), void 0 !== t5.l && (this.l = [...t5.l]), this.elementProperties = new Map(t5.elementProperties);
828
+ }
829
+ static finalize() {
830
+ if (this.hasOwnProperty(f("finalized"))) return;
831
+ if (this.finalized = true, this._$Ei(), this.hasOwnProperty(f("properties"))) {
832
+ const t6 = this.properties, s5 = [...n2(t6), ...a(t6)];
833
+ for (const i5 of s5) this.createProperty(i5, t6[i5]);
834
+ }
835
+ const t5 = this[Symbol.metadata];
836
+ if (null !== t5) {
837
+ const s5 = litPropertyMetadata.get(t5);
838
+ if (void 0 !== s5) for (const [t6, i5] of s5) this.elementProperties.set(t6, i5);
839
+ }
840
+ this._$Eh = /* @__PURE__ */ new Map();
841
+ for (const [t6, s5] of this.elementProperties) {
842
+ const i5 = this._$Eu(t6, s5);
843
+ void 0 !== i5 && this._$Eh.set(i5, t6);
844
+ }
845
+ this.elementStyles = this.finalizeStyles(this.styles);
846
+ }
847
+ static finalizeStyles(t5) {
848
+ const s5 = [];
849
+ if (Array.isArray(t5)) {
850
+ const e6 = new Set(t5.flat(1 / 0).reverse());
851
+ for (const t6 of e6) s5.unshift(c(t6));
852
+ } else void 0 !== t5 && s5.push(c(t5));
853
+ return s5;
854
+ }
855
+ static _$Eu(t5, s5) {
856
+ const i5 = s5.attribute;
857
+ return false === i5 ? void 0 : "string" == typeof i5 ? i5 : "string" == typeof t5 ? t5.toLowerCase() : void 0;
858
+ }
859
+ constructor() {
860
+ super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
861
+ }
862
+ _$Ev() {
863
+ var _a13;
864
+ this._$ES = new Promise((t5) => this.enableUpdating = t5), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (_a13 = this.constructor.l) == null ? void 0 : _a13.forEach((t5) => t5(this));
865
+ }
866
+ addController(t5) {
867
+ var _a13, _b3;
868
+ ((_a13 = this._$EO) != null ? _a13 : this._$EO = /* @__PURE__ */ new Set()).add(t5), void 0 !== this.renderRoot && this.isConnected && ((_b3 = t5.hostConnected) == null ? void 0 : _b3.call(t5));
869
+ }
870
+ removeController(t5) {
871
+ var _a13;
872
+ (_a13 = this._$EO) == null ? void 0 : _a13.delete(t5);
873
+ }
874
+ _$E_() {
875
+ const t5 = /* @__PURE__ */ new Map(), s5 = this.constructor.elementProperties;
876
+ for (const i5 of s5.keys()) this.hasOwnProperty(i5) && (t5.set(i5, this[i5]), delete this[i5]);
877
+ t5.size > 0 && (this._$Ep = t5);
878
+ }
879
+ createRenderRoot() {
880
+ var _a13;
881
+ const t5 = (_a13 = this.shadowRoot) != null ? _a13 : this.attachShadow(this.constructor.shadowRootOptions);
882
+ return S(t5, this.constructor.elementStyles), t5;
883
+ }
884
+ connectedCallback() {
885
+ var _a13, _b3;
886
+ (_a13 = this.renderRoot) != null ? _a13 : this.renderRoot = this.createRenderRoot(), this.enableUpdating(true), (_b3 = this._$EO) == null ? void 0 : _b3.forEach((t5) => {
887
+ var _a14;
888
+ return (_a14 = t5.hostConnected) == null ? void 0 : _a14.call(t5);
889
+ });
890
+ }
891
+ enableUpdating(t5) {
892
+ }
893
+ disconnectedCallback() {
894
+ var _a13;
895
+ (_a13 = this._$EO) == null ? void 0 : _a13.forEach((t5) => {
896
+ var _a14;
897
+ return (_a14 = t5.hostDisconnected) == null ? void 0 : _a14.call(t5);
898
+ });
899
+ }
900
+ attributeChangedCallback(t5, s5, i5) {
901
+ this._$AK(t5, i5);
902
+ }
903
+ _$ET(t5, s5) {
904
+ var _a13;
905
+ const i5 = this.constructor.elementProperties.get(t5), e6 = this.constructor._$Eu(t5, i5);
906
+ if (void 0 !== e6 && true === i5.reflect) {
907
+ const h5 = (void 0 !== ((_a13 = i5.converter) == null ? void 0 : _a13.toAttribute) ? i5.converter : b).toAttribute(s5, i5.type);
908
+ this._$Em = t5, null == h5 ? this.removeAttribute(e6) : this.setAttribute(e6, h5), this._$Em = null;
909
+ }
910
+ }
911
+ _$AK(t5, s5) {
912
+ var _a13, _b3, _c;
913
+ const i5 = this.constructor, e6 = i5._$Eh.get(t5);
914
+ if (void 0 !== e6 && this._$Em !== e6) {
915
+ const t6 = i5.getPropertyOptions(e6), h5 = "function" == typeof t6.converter ? { fromAttribute: t6.converter } : void 0 !== ((_a13 = t6.converter) == null ? void 0 : _a13.fromAttribute) ? t6.converter : b;
916
+ this._$Em = e6;
917
+ const r6 = h5.fromAttribute(s5, t6.type);
918
+ this[e6] = (_c = r6 != null ? r6 : (_b3 = this._$Ej) == null ? void 0 : _b3.get(e6)) != null ? _c : r6, this._$Em = null;
919
+ }
920
+ }
921
+ requestUpdate(t5, s5, i5, e6 = false, h5) {
922
+ var _a13, _b3;
923
+ if (void 0 !== t5) {
924
+ const r6 = this.constructor;
925
+ if (false === e6 && (h5 = this[t5]), i5 != null ? i5 : i5 = r6.getPropertyOptions(t5), !(((_a13 = i5.hasChanged) != null ? _a13 : m)(h5, s5) || i5.useDefault && i5.reflect && h5 === ((_b3 = this._$Ej) == null ? void 0 : _b3.get(t5)) && !this.hasAttribute(r6._$Eu(t5, i5)))) return;
926
+ this.C(t5, s5, i5);
927
+ }
928
+ false === this.isUpdatePending && (this._$ES = this._$EP());
929
+ }
930
+ C(t5, s5, { useDefault: i5, reflect: e6, wrapped: h5 }, r6) {
931
+ var _a13, _b3, _c;
932
+ i5 && !((_a13 = this._$Ej) != null ? _a13 : this._$Ej = /* @__PURE__ */ new Map()).has(t5) && (this._$Ej.set(t5, (_b3 = r6 != null ? r6 : s5) != null ? _b3 : this[t5]), true !== h5 || void 0 !== r6) || (this._$AL.has(t5) || (this.hasUpdated || i5 || (s5 = void 0), this._$AL.set(t5, s5)), true === e6 && this._$Em !== t5 && ((_c = this._$Eq) != null ? _c : this._$Eq = /* @__PURE__ */ new Set()).add(t5));
933
+ }
934
+ async _$EP() {
935
+ this.isUpdatePending = true;
936
+ try {
937
+ await this._$ES;
938
+ } catch (t6) {
939
+ Promise.reject(t6);
940
+ }
941
+ const t5 = this.scheduleUpdate();
942
+ return null != t5 && await t5, !this.isUpdatePending;
943
+ }
944
+ scheduleUpdate() {
945
+ return this.performUpdate();
946
+ }
947
+ performUpdate() {
948
+ var _a13, _b3;
949
+ if (!this.isUpdatePending) return;
950
+ if (!this.hasUpdated) {
951
+ if ((_a13 = this.renderRoot) != null ? _a13 : this.renderRoot = this.createRenderRoot(), this._$Ep) {
952
+ for (const [t7, s6] of this._$Ep) this[t7] = s6;
953
+ this._$Ep = void 0;
954
+ }
955
+ const t6 = this.constructor.elementProperties;
956
+ if (t6.size > 0) for (const [s6, i5] of t6) {
957
+ const { wrapped: t7 } = i5, e6 = this[s6];
958
+ true !== t7 || this._$AL.has(s6) || void 0 === e6 || this.C(s6, void 0, i5, e6);
959
+ }
960
+ }
961
+ let t5 = false;
962
+ const s5 = this._$AL;
963
+ try {
964
+ t5 = this.shouldUpdate(s5), t5 ? (this.willUpdate(s5), (_b3 = this._$EO) == null ? void 0 : _b3.forEach((t6) => {
965
+ var _a14;
966
+ return (_a14 = t6.hostUpdate) == null ? void 0 : _a14.call(t6);
967
+ }), this.update(s5)) : this._$EM();
968
+ } catch (s6) {
969
+ throw t5 = false, this._$EM(), s6;
970
+ }
971
+ t5 && this._$AE(s5);
972
+ }
973
+ willUpdate(t5) {
974
+ }
975
+ _$AE(t5) {
976
+ var _a13;
977
+ (_a13 = this._$EO) == null ? void 0 : _a13.forEach((t6) => {
978
+ var _a14;
979
+ return (_a14 = t6.hostUpdated) == null ? void 0 : _a14.call(t6);
980
+ }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t5)), this.updated(t5);
981
+ }
982
+ _$EM() {
983
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
984
+ }
985
+ get updateComplete() {
986
+ return this.getUpdateComplete();
987
+ }
988
+ getUpdateComplete() {
989
+ return this._$ES;
990
+ }
991
+ shouldUpdate(t5) {
992
+ return true;
993
+ }
994
+ update(t5) {
995
+ this._$Eq && (this._$Eq = this._$Eq.forEach((t6) => this._$ET(t6, this[t6]))), this._$EM();
996
+ }
997
+ updated(t5) {
998
+ }
999
+ firstUpdated(t5) {
1000
+ }
1001
+ };
1002
+ var _a9;
1003
+ g.elementStyles = [], g.shadowRootOptions = { mode: "open" }, g[f("elementProperties")] = /* @__PURE__ */ new Map(), g[f("finalized")] = /* @__PURE__ */ new Map(), u == null ? void 0 : u({ ReactiveElement: g }), ((_a9 = l.reactiveElementVersions) != null ? _a9 : l.reactiveElementVersions = []).push("2.1.2");
1004
+
1005
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/lit-html.js
1006
+ var t2 = globalThis;
1007
+ var i2 = (t5) => t5;
1008
+ var s2 = t2.trustedTypes;
1009
+ var e2 = s2 ? s2.createPolicy("lit-html", { createHTML: (t5) => t5 }) : void 0;
1010
+ var h2 = "$lit$";
1011
+ var o3 = `lit$${Math.random().toFixed(9).slice(2)}$`;
1012
+ var n3 = "?" + o3;
1013
+ var r3 = `<${n3}>`;
1014
+ var l2 = void 0 === t2.document ? { createTreeWalker: () => ({}) } : document;
1015
+ var c3 = () => l2.createComment("");
1016
+ var a2 = (t5) => null === t5 || "object" != typeof t5 && "function" != typeof t5;
1017
+ var u2 = Array.isArray;
1018
+ var d2 = (t5) => u2(t5) || "function" == typeof (t5 == null ? void 0 : t5[Symbol.iterator]);
1019
+ var f2 = "[ \n\f\r]";
1020
+ var v = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
1021
+ var _ = /-->/g;
1022
+ var m2 = />/g;
1023
+ var p2 = RegExp(`>|${f2}(?:([^\\s"'>=/]+)(${f2}*=${f2}*(?:[^
1024
+ \f\r"'\`<>=]|("|')|))|$)`, "g");
1025
+ var g2 = /'/g;
1026
+ var $ = /"/g;
1027
+ var y2 = /^(?:script|style|textarea|title)$/i;
1028
+ var x = (t5) => (i5, ...s5) => ({ _$litType$: t5, strings: i5, values: s5 });
1029
+ var T = x(1);
1030
+ var b2 = x(2);
1031
+ var w = x(3);
1032
+ var E = Symbol.for("lit-noChange");
1033
+ var A = Symbol.for("lit-nothing");
1034
+ var C = /* @__PURE__ */ new WeakMap();
1035
+ var P = l2.createTreeWalker(l2, 129);
1036
+ function V(t5, i5) {
1037
+ if (!u2(t5) || !t5.hasOwnProperty("raw")) throw Error("invalid template strings array");
1038
+ return void 0 !== e2 ? e2.createHTML(i5) : i5;
1039
+ }
1040
+ var N = (t5, i5) => {
1041
+ const s5 = t5.length - 1, e6 = [];
1042
+ let n6, l3 = 2 === i5 ? "<svg>" : 3 === i5 ? "<math>" : "", c5 = v;
1043
+ for (let i6 = 0; i6 < s5; i6++) {
1044
+ const s6 = t5[i6];
1045
+ let a3, u3, d3 = -1, f4 = 0;
1046
+ for (; f4 < s6.length && (c5.lastIndex = f4, u3 = c5.exec(s6), null !== u3); ) f4 = c5.lastIndex, c5 === v ? "!--" === u3[1] ? c5 = _ : void 0 !== u3[1] ? c5 = m2 : void 0 !== u3[2] ? (y2.test(u3[2]) && (n6 = RegExp("</" + u3[2], "g")), c5 = p2) : void 0 !== u3[3] && (c5 = p2) : c5 === p2 ? ">" === u3[0] ? (c5 = n6 != null ? n6 : v, d3 = -1) : void 0 === u3[1] ? d3 = -2 : (d3 = c5.lastIndex - u3[2].length, a3 = u3[1], c5 = void 0 === u3[3] ? p2 : '"' === u3[3] ? $ : g2) : c5 === $ || c5 === g2 ? c5 = p2 : c5 === _ || c5 === m2 ? c5 = v : (c5 = p2, n6 = void 0);
1047
+ const x2 = c5 === p2 && t5[i6 + 1].startsWith("/>") ? " " : "";
1048
+ l3 += c5 === v ? s6 + r3 : d3 >= 0 ? (e6.push(a3), s6.slice(0, d3) + h2 + s6.slice(d3) + o3 + x2) : s6 + o3 + (-2 === d3 ? i6 : x2);
1049
+ }
1050
+ return [V(t5, l3 + (t5[s5] || "<?>") + (2 === i5 ? "</svg>" : 3 === i5 ? "</math>" : "")), e6];
1051
+ };
1052
+ var S2 = class _S {
1053
+ constructor({ strings: t5, _$litType$: i5 }, e6) {
1054
+ let r6;
1055
+ this.parts = [];
1056
+ let l3 = 0, a3 = 0;
1057
+ const u3 = t5.length - 1, d3 = this.parts, [f4, v2] = N(t5, i5);
1058
+ if (this.el = _S.createElement(f4, e6), P.currentNode = this.el.content, 2 === i5 || 3 === i5) {
1059
+ const t6 = this.el.content.firstChild;
1060
+ t6.replaceWith(...t6.childNodes);
1061
+ }
1062
+ for (; null !== (r6 = P.nextNode()) && d3.length < u3; ) {
1063
+ if (1 === r6.nodeType) {
1064
+ if (r6.hasAttributes()) for (const t6 of r6.getAttributeNames()) if (t6.endsWith(h2)) {
1065
+ const i6 = v2[a3++], s5 = r6.getAttribute(t6).split(o3), e7 = /([.?@])?(.*)/.exec(i6);
1066
+ d3.push({ type: 1, index: l3, name: e7[2], strings: s5, ctor: "." === e7[1] ? I : "?" === e7[1] ? L : "@" === e7[1] ? z : H }), r6.removeAttribute(t6);
1067
+ } else t6.startsWith(o3) && (d3.push({ type: 6, index: l3 }), r6.removeAttribute(t6));
1068
+ if (y2.test(r6.tagName)) {
1069
+ const t6 = r6.textContent.split(o3), i6 = t6.length - 1;
1070
+ if (i6 > 0) {
1071
+ r6.textContent = s2 ? s2.emptyScript : "";
1072
+ for (let s5 = 0; s5 < i6; s5++) r6.append(t6[s5], c3()), P.nextNode(), d3.push({ type: 2, index: ++l3 });
1073
+ r6.append(t6[i6], c3());
1074
+ }
1075
+ }
1076
+ } else if (8 === r6.nodeType) if (r6.data === n3) d3.push({ type: 2, index: l3 });
1077
+ else {
1078
+ let t6 = -1;
1079
+ for (; -1 !== (t6 = r6.data.indexOf(o3, t6 + 1)); ) d3.push({ type: 7, index: l3 }), t6 += o3.length - 1;
1080
+ }
1081
+ l3++;
1082
+ }
1083
+ }
1084
+ static createElement(t5, i5) {
1085
+ const s5 = l2.createElement("template");
1086
+ return s5.innerHTML = t5, s5;
1087
+ }
1088
+ };
1089
+ function M(t5, i5, s5 = t5, e6) {
1090
+ var _a13, _b3, _c;
1091
+ if (i5 === E) return i5;
1092
+ let h5 = void 0 !== e6 ? (_a13 = s5._$Co) == null ? void 0 : _a13[e6] : s5._$Cl;
1093
+ const o8 = a2(i5) ? void 0 : i5._$litDirective$;
1094
+ return (h5 == null ? void 0 : h5.constructor) !== o8 && ((_b3 = h5 == null ? void 0 : h5._$AO) == null ? void 0 : _b3.call(h5, false), void 0 === o8 ? h5 = void 0 : (h5 = new o8(t5), h5._$AT(t5, s5, e6)), void 0 !== e6 ? ((_c = s5._$Co) != null ? _c : s5._$Co = [])[e6] = h5 : s5._$Cl = h5), void 0 !== h5 && (i5 = M(t5, h5._$AS(t5, i5.values), h5, e6)), i5;
1095
+ }
1096
+ var k = class {
1097
+ constructor(t5, i5) {
1098
+ this._$AV = [], this._$AN = void 0, this._$AD = t5, this._$AM = i5;
1099
+ }
1100
+ get parentNode() {
1101
+ return this._$AM.parentNode;
1102
+ }
1103
+ get _$AU() {
1104
+ return this._$AM._$AU;
1105
+ }
1106
+ u(t5) {
1107
+ var _a13;
1108
+ const { el: { content: i5 }, parts: s5 } = this._$AD, e6 = ((_a13 = t5 == null ? void 0 : t5.creationScope) != null ? _a13 : l2).importNode(i5, true);
1109
+ P.currentNode = e6;
1110
+ let h5 = P.nextNode(), o8 = 0, n6 = 0, r6 = s5[0];
1111
+ for (; void 0 !== r6; ) {
1112
+ if (o8 === r6.index) {
1113
+ let i6;
1114
+ 2 === r6.type ? i6 = new R(h5, h5.nextSibling, this, t5) : 1 === r6.type ? i6 = new r6.ctor(h5, r6.name, r6.strings, this, t5) : 6 === r6.type && (i6 = new W(h5, this, t5)), this._$AV.push(i6), r6 = s5[++n6];
1115
+ }
1116
+ o8 !== (r6 == null ? void 0 : r6.index) && (h5 = P.nextNode(), o8++);
1117
+ }
1118
+ return P.currentNode = l2, e6;
1119
+ }
1120
+ p(t5) {
1121
+ let i5 = 0;
1122
+ for (const s5 of this._$AV) void 0 !== s5 && (void 0 !== s5.strings ? (s5._$AI(t5, s5, i5), i5 += s5.strings.length - 2) : s5._$AI(t5[i5])), i5++;
1123
+ }
1124
+ };
1125
+ var R = class _R {
1126
+ get _$AU() {
1127
+ var _a13, _b3;
1128
+ return (_b3 = (_a13 = this._$AM) == null ? void 0 : _a13._$AU) != null ? _b3 : this._$Cv;
1129
+ }
1130
+ constructor(t5, i5, s5, e6) {
1131
+ var _a13;
1132
+ this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t5, this._$AB = i5, this._$AM = s5, this.options = e6, this._$Cv = (_a13 = e6 == null ? void 0 : e6.isConnected) != null ? _a13 : true;
1133
+ }
1134
+ get parentNode() {
1135
+ let t5 = this._$AA.parentNode;
1136
+ const i5 = this._$AM;
1137
+ return void 0 !== i5 && 11 === (t5 == null ? void 0 : t5.nodeType) && (t5 = i5.parentNode), t5;
1138
+ }
1139
+ get startNode() {
1140
+ return this._$AA;
1141
+ }
1142
+ get endNode() {
1143
+ return this._$AB;
1144
+ }
1145
+ _$AI(t5, i5 = this) {
1146
+ t5 = M(this, t5, i5), a2(t5) ? t5 === A || null == t5 || "" === t5 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t5 !== this._$AH && t5 !== E && this._(t5) : void 0 !== t5._$litType$ ? this.$(t5) : void 0 !== t5.nodeType ? this.T(t5) : d2(t5) ? this.k(t5) : this._(t5);
1147
+ }
1148
+ O(t5) {
1149
+ return this._$AA.parentNode.insertBefore(t5, this._$AB);
1150
+ }
1151
+ T(t5) {
1152
+ this._$AH !== t5 && (this._$AR(), this._$AH = this.O(t5));
1153
+ }
1154
+ _(t5) {
1155
+ this._$AH !== A && a2(this._$AH) ? this._$AA.nextSibling.data = t5 : this.T(l2.createTextNode(t5)), this._$AH = t5;
1156
+ }
1157
+ $(t5) {
1158
+ var _a13;
1159
+ const { values: i5, _$litType$: s5 } = t5, e6 = "number" == typeof s5 ? this._$AC(t5) : (void 0 === s5.el && (s5.el = S2.createElement(V(s5.h, s5.h[0]), this.options)), s5);
1160
+ if (((_a13 = this._$AH) == null ? void 0 : _a13._$AD) === e6) this._$AH.p(i5);
1161
+ else {
1162
+ const t6 = new k(e6, this), s6 = t6.u(this.options);
1163
+ t6.p(i5), this.T(s6), this._$AH = t6;
1164
+ }
1165
+ }
1166
+ _$AC(t5) {
1167
+ let i5 = C.get(t5.strings);
1168
+ return void 0 === i5 && C.set(t5.strings, i5 = new S2(t5)), i5;
1169
+ }
1170
+ k(t5) {
1171
+ u2(this._$AH) || (this._$AH = [], this._$AR());
1172
+ const i5 = this._$AH;
1173
+ let s5, e6 = 0;
1174
+ for (const h5 of t5) e6 === i5.length ? i5.push(s5 = new _R(this.O(c3()), this.O(c3()), this, this.options)) : s5 = i5[e6], s5._$AI(h5), e6++;
1175
+ e6 < i5.length && (this._$AR(s5 && s5._$AB.nextSibling, e6), i5.length = e6);
1176
+ }
1177
+ _$AR(t5 = this._$AA.nextSibling, s5) {
1178
+ var _a13;
1179
+ for ((_a13 = this._$AP) == null ? void 0 : _a13.call(this, false, true, s5); t5 !== this._$AB; ) {
1180
+ const s6 = i2(t5).nextSibling;
1181
+ i2(t5).remove(), t5 = s6;
1182
+ }
1183
+ }
1184
+ setConnected(t5) {
1185
+ var _a13;
1186
+ void 0 === this._$AM && (this._$Cv = t5, (_a13 = this._$AP) == null ? void 0 : _a13.call(this, t5));
1187
+ }
1188
+ };
1189
+ var H = class {
1190
+ get tagName() {
1191
+ return this.element.tagName;
1192
+ }
1193
+ get _$AU() {
1194
+ return this._$AM._$AU;
1195
+ }
1196
+ constructor(t5, i5, s5, e6, h5) {
1197
+ this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t5, this.name = i5, this._$AM = e6, this.options = h5, s5.length > 2 || "" !== s5[0] || "" !== s5[1] ? (this._$AH = Array(s5.length - 1).fill(new String()), this.strings = s5) : this._$AH = A;
1198
+ }
1199
+ _$AI(t5, i5 = this, s5, e6) {
1200
+ const h5 = this.strings;
1201
+ let o8 = false;
1202
+ if (void 0 === h5) t5 = M(this, t5, i5, 0), o8 = !a2(t5) || t5 !== this._$AH && t5 !== E, o8 && (this._$AH = t5);
1203
+ else {
1204
+ const e7 = t5;
1205
+ let n6, r6;
1206
+ for (t5 = h5[0], n6 = 0; n6 < h5.length - 1; n6++) r6 = M(this, e7[s5 + n6], i5, n6), r6 === E && (r6 = this._$AH[n6]), o8 || (o8 = !a2(r6) || r6 !== this._$AH[n6]), r6 === A ? t5 = A : t5 !== A && (t5 += (r6 != null ? r6 : "") + h5[n6 + 1]), this._$AH[n6] = r6;
1207
+ }
1208
+ o8 && !e6 && this.j(t5);
1209
+ }
1210
+ j(t5) {
1211
+ t5 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t5 != null ? t5 : "");
1212
+ }
1213
+ };
1214
+ var I = class extends H {
1215
+ constructor() {
1216
+ super(...arguments), this.type = 3;
1217
+ }
1218
+ j(t5) {
1219
+ this.element[this.name] = t5 === A ? void 0 : t5;
1220
+ }
1221
+ };
1222
+ var L = class extends H {
1223
+ constructor() {
1224
+ super(...arguments), this.type = 4;
1225
+ }
1226
+ j(t5) {
1227
+ this.element.toggleAttribute(this.name, !!t5 && t5 !== A);
1228
+ }
1229
+ };
1230
+ var z = class extends H {
1231
+ constructor(t5, i5, s5, e6, h5) {
1232
+ super(t5, i5, s5, e6, h5), this.type = 5;
1233
+ }
1234
+ _$AI(t5, i5 = this) {
1235
+ var _a13;
1236
+ if ((t5 = (_a13 = M(this, t5, i5, 0)) != null ? _a13 : A) === E) return;
1237
+ const s5 = this._$AH, e6 = t5 === A && s5 !== A || t5.capture !== s5.capture || t5.once !== s5.once || t5.passive !== s5.passive, h5 = t5 !== A && (s5 === A || e6);
1238
+ e6 && this.element.removeEventListener(this.name, this, s5), h5 && this.element.addEventListener(this.name, this, t5), this._$AH = t5;
1239
+ }
1240
+ handleEvent(t5) {
1241
+ var _a13, _b3;
1242
+ "function" == typeof this._$AH ? this._$AH.call((_b3 = (_a13 = this.options) == null ? void 0 : _a13.host) != null ? _b3 : this.element, t5) : this._$AH.handleEvent(t5);
1243
+ }
1244
+ };
1245
+ var W = class {
1246
+ constructor(t5, i5, s5) {
1247
+ this.element = t5, this.type = 6, this._$AN = void 0, this._$AM = i5, this.options = s5;
1248
+ }
1249
+ get _$AU() {
1250
+ return this._$AM._$AU;
1251
+ }
1252
+ _$AI(t5) {
1253
+ M(this, t5);
1254
+ }
1255
+ };
1256
+ var Z = { M: h2, P: o3, A: n3, C: 1, L: N, R: k, D: d2, V: M, I: R, H, N: L, U: z, B: I, F: W };
1257
+ var j = t2.litHtmlPolyfillSupport;
1258
+ var _a10;
1259
+ j == null ? void 0 : j(S2, R), ((_a10 = t2.litHtmlVersions) != null ? _a10 : t2.litHtmlVersions = []).push("3.3.3");
1260
+ var B = (t5, i5, s5) => {
1261
+ var _a13, _b3;
1262
+ const e6 = (_a13 = s5 == null ? void 0 : s5.renderBefore) != null ? _a13 : i5;
1263
+ let h5 = e6._$litPart$;
1264
+ if (void 0 === h5) {
1265
+ const t6 = (_b3 = s5 == null ? void 0 : s5.renderBefore) != null ? _b3 : null;
1266
+ e6._$litPart$ = h5 = new R(i5.insertBefore(c3(), t6), t6, void 0, s5 != null ? s5 : {});
1267
+ }
1268
+ return h5._$AI(t5), h5;
1269
+ };
1270
+
1271
+ // ../../node_modules/.pnpm/lit-element@4.2.2/node_modules/lit-element/lit-element.js
1272
+ var s3 = globalThis;
1273
+ var i3 = class extends g {
1274
+ constructor() {
1275
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
1276
+ }
1277
+ createRenderRoot() {
1278
+ var _a13, _b3;
1279
+ const t5 = super.createRenderRoot();
1280
+ return (_b3 = (_a13 = this.renderOptions).renderBefore) != null ? _b3 : _a13.renderBefore = t5.firstChild, t5;
1281
+ }
1282
+ update(t5) {
1283
+ const r6 = this.render();
1284
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t5), this._$Do = B(r6, this.renderRoot, this.renderOptions);
1285
+ }
1286
+ connectedCallback() {
1287
+ var _a13;
1288
+ super.connectedCallback(), (_a13 = this._$Do) == null ? void 0 : _a13.setConnected(true);
1289
+ }
1290
+ disconnectedCallback() {
1291
+ var _a13;
1292
+ super.disconnectedCallback(), (_a13 = this._$Do) == null ? void 0 : _a13.setConnected(false);
1293
+ }
1294
+ render() {
1295
+ return E;
1296
+ }
1297
+ };
1298
+ var _a11;
1299
+ i3._$litElement$ = true, i3["finalized"] = true, (_a11 = s3.litElementHydrateSupport) == null ? void 0 : _a11.call(s3, { LitElement: i3 });
1300
+ var o4 = s3.litElementPolyfillSupport;
1301
+ o4 == null ? void 0 : o4({ LitElement: i3 });
1302
+ var _a12;
1303
+ ((_a12 = s3.litElementVersions) != null ? _a12 : s3.litElementVersions = []).push("4.2.2");
1304
+
1305
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive.js
1306
+ var t3 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 };
1307
+ var e3 = (t5) => (...e6) => ({ _$litDirective$: t5, values: e6 });
1308
+ var i4 = class {
1309
+ constructor(t5) {
1310
+ }
1311
+ get _$AU() {
1312
+ return this._$AM._$AU;
1313
+ }
1314
+ _$AT(t5, e6, i5) {
1315
+ this._$Ct = t5, this._$AM = e6, this._$Ci = i5;
1316
+ }
1317
+ _$AS(t5, e6) {
1318
+ return this.update(t5, e6);
1319
+ }
1320
+ update(t5, e6) {
1321
+ return this.render(...e6);
1322
+ }
1323
+ };
1324
+
1325
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/unsafe-html.js
1326
+ var e4 = class extends i4 {
1327
+ constructor(i5) {
1328
+ if (super(i5), this.it = A, i5.type !== t3.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
1329
+ }
1330
+ render(r6) {
1331
+ if (r6 === A || null == r6) return this._t = void 0, this.it = r6;
1332
+ if (r6 === E) return r6;
1333
+ if ("string" != typeof r6) throw Error(this.constructor.directiveName + "() called with a non-string value");
1334
+ if (r6 === this.it) return this._t;
1335
+ this.it = r6;
1336
+ const s5 = [r6];
1337
+ return s5.raw = s5, this._t = { _$litType$: this.constructor.resultType, strings: s5, values: [] };
1338
+ }
1339
+ };
1340
+ e4.directiveName = "unsafeHTML", e4.resultType = 1;
1341
+ var o5 = e3(e4);
1342
+
29
1343
  // raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg
30
1344
  var close_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"/></svg>\n';
31
1345
 
@@ -57,18 +1371,222 @@ var icons = {
57
1371
  soundOff: speaker_x_fill_default,
58
1372
  soundOn: speaker_high_fill_default
59
1373
  };
60
- function createIcon(name) {
61
- const template = document.createElement("template");
62
- template.innerHTML = icons[name];
63
- const svg = template.content.firstElementChild;
64
- svg.classList.add("icon");
65
- svg.setAttribute("aria-hidden", "true");
66
- svg.setAttribute("focusable", "false");
67
- return svg;
1374
+ var markup = Object.fromEntries(
1375
+ Object.entries(icons).map(([name, svg]) => [
1376
+ name,
1377
+ svg.replace(
1378
+ "<svg",
1379
+ '<svg class="icon" aria-hidden="true" focusable="false"'
1380
+ )
1381
+ ])
1382
+ );
1383
+ function icon(name) {
1384
+ return o5(markup[name]);
1385
+ }
1386
+
1387
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive-helpers.js
1388
+ var { I: t4 } = Z;
1389
+ var r4 = (o8) => void 0 === o8.strings;
1390
+
1391
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/async-directive.js
1392
+ var s4 = (i5, t5) => {
1393
+ var _a13;
1394
+ const e6 = i5._$AN;
1395
+ if (void 0 === e6) return false;
1396
+ for (const i6 of e6) (_a13 = i6._$AO) == null ? void 0 : _a13.call(i6, t5, false), s4(i6, t5);
1397
+ return true;
1398
+ };
1399
+ var o6 = (i5) => {
1400
+ let t5, e6;
1401
+ do {
1402
+ if (void 0 === (t5 = i5._$AM)) break;
1403
+ e6 = t5._$AN, e6.delete(i5), i5 = t5;
1404
+ } while (0 === (e6 == null ? void 0 : e6.size));
1405
+ };
1406
+ var r5 = (i5) => {
1407
+ for (let t5; t5 = i5._$AM; i5 = t5) {
1408
+ let e6 = t5._$AN;
1409
+ if (void 0 === e6) t5._$AN = e6 = /* @__PURE__ */ new Set();
1410
+ else if (e6.has(i5)) break;
1411
+ e6.add(i5), c4(t5);
1412
+ }
1413
+ };
1414
+ function h3(i5) {
1415
+ void 0 !== this._$AN ? (o6(this), this._$AM = i5, r5(this)) : this._$AM = i5;
1416
+ }
1417
+ function n4(i5, t5 = false, e6 = 0) {
1418
+ const r6 = this._$AH, h5 = this._$AN;
1419
+ if (void 0 !== h5 && 0 !== h5.size) if (t5) if (Array.isArray(r6)) for (let i6 = e6; i6 < r6.length; i6++) s4(r6[i6], false), o6(r6[i6]);
1420
+ else null != r6 && (s4(r6, false), o6(r6));
1421
+ else s4(this, i5);
1422
+ }
1423
+ var c4 = (i5) => {
1424
+ var _a13, _b3;
1425
+ i5.type == t3.CHILD && ((_a13 = i5._$AP) != null ? _a13 : i5._$AP = n4, (_b3 = i5._$AQ) != null ? _b3 : i5._$AQ = h3);
1426
+ };
1427
+ var f3 = class extends i4 {
1428
+ constructor() {
1429
+ super(...arguments), this._$AN = void 0;
1430
+ }
1431
+ _$AT(i5, t5, e6) {
1432
+ super._$AT(i5, t5, e6), r5(this), this.isConnected = i5._$AU;
1433
+ }
1434
+ _$AO(i5, t5 = true) {
1435
+ var _a13, _b3;
1436
+ i5 !== this.isConnected && (this.isConnected = i5, i5 ? (_a13 = this.reconnected) == null ? void 0 : _a13.call(this) : (_b3 = this.disconnected) == null ? void 0 : _b3.call(this)), t5 && (s4(this, i5), o6(this));
1437
+ }
1438
+ setValue(t5) {
1439
+ if (r4(this._$Ct)) this._$Ct._$AI(t5, this);
1440
+ else {
1441
+ const i5 = [...this._$Ct._$AH];
1442
+ i5[this._$Ci] = t5, this._$Ct._$AI(i5, this, 0);
1443
+ }
1444
+ }
1445
+ disconnected() {
1446
+ }
1447
+ reconnected() {
1448
+ }
1449
+ };
1450
+
1451
+ // ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/ref.js
1452
+ var e5 = () => new h4();
1453
+ var h4 = class {
1454
+ };
1455
+ var o7 = /* @__PURE__ */ new WeakMap();
1456
+ var n5 = e3(class extends f3 {
1457
+ render(i5) {
1458
+ return A;
1459
+ }
1460
+ update(i5, [s5]) {
1461
+ var _a13;
1462
+ const e6 = s5 !== this.G;
1463
+ return e6 && this.rt(void 0), (e6 || this.lt !== this.ct) && (this.G = s5, this.ht = (_a13 = i5.options) == null ? void 0 : _a13.host, this.rt(this.ct = i5.element)), A;
1464
+ }
1465
+ rt(t5) {
1466
+ var _a13;
1467
+ if (void 0 !== this.G) if (this.isConnected || (t5 = void 0), "function" == typeof this.G) {
1468
+ const i5 = (_a13 = this.ht) != null ? _a13 : globalThis;
1469
+ let s5 = o7.get(i5);
1470
+ void 0 === s5 && (s5 = /* @__PURE__ */ new WeakMap(), o7.set(i5, s5)), void 0 !== s5.get(this.G) && this.G.call(this.ht, void 0), s5.set(this.G, t5), void 0 !== t5 && this.G.call(this.ht, t5);
1471
+ } else this.G.value = t5;
1472
+ }
1473
+ get lt() {
1474
+ var _a13, _b3, _c;
1475
+ return "function" == typeof this.G ? (_b3 = o7.get((_a13 = this.ht) != null ? _a13 : globalThis)) == null ? void 0 : _b3.get(this.G) : (_c = this.G) == null ? void 0 : _c.value;
1476
+ }
1477
+ disconnected() {
1478
+ this.lt === this.ct && this.rt(void 0);
1479
+ }
1480
+ reconnected() {
1481
+ this.rt(this.ct);
1482
+ }
1483
+ });
1484
+
1485
+ // src/components/media/media.ts
1486
+ function httpUrl(value) {
1487
+ if (!value) return null;
1488
+ try {
1489
+ const { protocol } = new URL(value);
1490
+ return protocol === "https:" || protocol === "http:" ? value : null;
1491
+ } catch (e6) {
1492
+ return null;
1493
+ }
1494
+ }
1495
+ function prefersReducedMotion() {
1496
+ var _a13, _b3;
1497
+ return (_b3 = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, "(prefers-reduced-motion: reduce)").matches) != null ? _b3 : false;
1498
+ }
1499
+ function hasVideo(story, video) {
1500
+ return !video.failed && httpUrl(story.media_url) !== null;
1501
+ }
1502
+ function renderMedia(story, video) {
1503
+ const posterUrl = httpUrl(story.poster_url);
1504
+ const mediaUrl = httpUrl(story.media_url);
1505
+ return T`
1506
+ ${posterUrl ? T`<img class="poster" alt="" src=${posterUrl} />` : A}
1507
+ ${mediaUrl && !video.failed ? T`
1508
+ <video
1509
+ class="video"
1510
+ muted
1511
+ playsinline
1512
+ loop
1513
+ preload="metadata"
1514
+ .muted=${true}
1515
+ ?autoplay=${!prefersReducedMotion()}
1516
+ poster=${posterUrl != null ? posterUrl : A}
1517
+ src=${mediaUrl}
1518
+ ${n5(video.ref)}
1519
+ @play=${video.sync}
1520
+ @pause=${video.sync}
1521
+ @volumechange=${video.sync}
1522
+ @error=${video.fail}
1523
+ ></video>
1524
+ ` : A}
1525
+ `;
68
1526
  }
69
1527
 
1528
+ // src/components/media/video-controller.ts
1529
+ function playVideo(video) {
1530
+ var _a13;
1531
+ (_a13 = video.play()) == null ? void 0 : _a13.catch(() => void 0);
1532
+ }
1533
+ var VideoController = class {
1534
+ constructor(host) {
1535
+ this.host = host;
1536
+ /** Bound to the <video> by renderMedia. */
1537
+ this.ref = e5();
1538
+ this.paused = true;
1539
+ // The video always starts muted: that is what browsers allow to autoplay.
1540
+ this.muted = true;
1541
+ /** The video could not load: only the cover is shown. */
1542
+ this.failed = false;
1543
+ /** Listener for the video's play, pause and volumechange events. */
1544
+ this.sync = () => {
1545
+ const video = this.ref.value;
1546
+ if (!video) return;
1547
+ this.paused = video.paused;
1548
+ this.muted = video.muted;
1549
+ this.host.requestUpdate();
1550
+ };
1551
+ /** Listener for the video's error event. */
1552
+ this.fail = () => {
1553
+ this.failed = true;
1554
+ this.host.requestUpdate();
1555
+ };
1556
+ }
1557
+ /** For a new <video>, such as each time the player opens. */
1558
+ reset() {
1559
+ this.paused = true;
1560
+ this.muted = true;
1561
+ this.failed = false;
1562
+ }
1563
+ play() {
1564
+ const video = this.ref.value;
1565
+ if (video) playVideo(video);
1566
+ }
1567
+ pause() {
1568
+ var _a13;
1569
+ (_a13 = this.ref.value) == null ? void 0 : _a13.pause();
1570
+ }
1571
+ /** Plays again if the video plays on its own (see renderMedia). */
1572
+ resume() {
1573
+ const video = this.ref.value;
1574
+ if (video == null ? void 0 : video.autoplay) playVideo(video);
1575
+ }
1576
+ togglePlayback() {
1577
+ const video = this.ref.value;
1578
+ if (!video) return;
1579
+ if (video.paused) playVideo(video);
1580
+ else video.pause();
1581
+ }
1582
+ toggleMuted() {
1583
+ const video = this.ref.value;
1584
+ if (video) video.muted = !video.muted;
1585
+ }
1586
+ };
1587
+
70
1588
  // src/components/card/card.ts
71
- var cardStyles = `
1589
+ var cardStyles = i`
72
1590
  .card {
73
1591
  position: relative;
74
1592
  box-sizing: border-box;
@@ -175,89 +1693,37 @@ var cardStyles = `
175
1693
  }
176
1694
  }
177
1695
  `;
178
- function httpUrl(value) {
179
- if (!value) return null;
180
- try {
181
- const { protocol } = new URL(value);
182
- return protocol === "https:" || protocol === "http:" ? value : null;
183
- } catch (e) {
184
- return null;
185
- }
1696
+ function renderSoundButton(video, options) {
1697
+ return T`
1698
+ <button
1699
+ type="button"
1700
+ class="card-sound"
1701
+ aria-label=${video.muted ? options.soundOnLabel : options.soundOffLabel}
1702
+ @click=${() => video.toggleMuted()}
1703
+ >
1704
+ ${icon(video.muted ? "soundOff" : "soundOn")}
1705
+ </button>
1706
+ `;
186
1707
  }
187
- function prefersReducedMotion() {
188
- var _a2, _b;
189
- return (_b = (_a2 = globalThis.matchMedia) == null ? void 0 : _a2.call(globalThis, "(prefers-reduced-motion: reduce)").matches) != null ? _b : false;
190
- }
191
- function playVideo(video) {
192
- var _a2;
193
- (_a2 = video.play()) == null ? void 0 : _a2.catch(() => void 0);
194
- }
195
- function createVideo(src, poster) {
196
- const video = document.createElement("video");
197
- video.className = "video";
198
- video.muted = true;
199
- video.setAttribute("muted", "");
200
- video.setAttribute("playsinline", "");
201
- video.loop = true;
202
- video.preload = "metadata";
203
- video.autoplay = !prefersReducedMotion();
204
- if (poster) video.poster = poster;
205
- video.src = src;
206
- video.addEventListener("error", () => video.remove());
207
- return video;
208
- }
209
- function createSoundButton(video, options) {
210
- const button = document.createElement("button");
211
- button.type = "button";
212
- button.className = "card-sound";
213
- function sync() {
214
- button.setAttribute(
215
- "aria-label",
216
- video.muted ? options.soundOnLabel : options.soundOffLabel
217
- );
218
- button.replaceChildren(createIcon(video.muted ? "soundOff" : "soundOn"));
219
- }
220
- video.addEventListener("volumechange", sync);
221
- video.addEventListener("error", () => button.remove());
222
- button.addEventListener("click", () => {
223
- video.muted = !video.muted;
224
- });
225
- sync();
226
- return button;
227
- }
228
- function createCard(story, options) {
229
- const card = document.createElement("div");
230
- card.className = "card";
231
- const posterUrl = httpUrl(story.poster_url);
232
- if (posterUrl) {
233
- const poster = document.createElement("img");
234
- poster.className = "poster";
235
- poster.alt = "";
236
- poster.src = posterUrl;
237
- card.append(poster);
238
- }
239
- const mediaUrl = httpUrl(story.media_url);
240
- const video = mediaUrl ? createVideo(mediaUrl, posterUrl) : null;
241
- if (video) card.append(video);
242
- if (options) {
243
- const open = document.createElement("button");
244
- open.type = "button";
245
- open.className = "card-open";
246
- open.setAttribute("aria-label", options.label);
247
- const play = document.createElement("span");
248
- play.className = "play";
249
- play.setAttribute("aria-hidden", "true");
250
- play.append(createIcon("play"));
251
- open.append(play);
252
- open.addEventListener("click", options.onSelect);
253
- card.append(open);
254
- if (video) card.append(createSoundButton(video, options));
255
- }
256
- return card;
1708
+ function renderCard(story, video, options) {
1709
+ return T`
1710
+ <div class="card">
1711
+ ${renderMedia(story, video)}
1712
+ <button
1713
+ type="button"
1714
+ class="card-open"
1715
+ aria-label=${options.label}
1716
+ @click=${options.onSelect}
1717
+ >
1718
+ <span class="play" aria-hidden="true">${icon("play")}</span>
1719
+ </button>
1720
+ ${hasVideo(story, video) && !video.paused ? renderSoundButton(video, options) : A}
1721
+ </div>
1722
+ `;
257
1723
  }
258
1724
 
259
1725
  // src/components/player/player.ts
260
- var playerStyles = `
1726
+ var playerStyles = i`
261
1727
  .player {
262
1728
  position: fixed;
263
1729
  inset: auto 16px 16px auto;
@@ -449,132 +1915,189 @@ var playerStyles = `
449
1915
  }
450
1916
  }
451
1917
  `;
452
- function createButton(className, label, icon) {
453
- const button = document.createElement("button");
454
- button.type = "button";
455
- button.className = `player-button ${className}`;
456
- button.setAttribute("aria-label", label);
457
- button.append(createIcon(icon));
458
- return button;
459
- }
460
- function supportsPopover(player) {
461
- return typeof player.showPopover === "function";
462
- }
463
- function showPlayer(player) {
464
- if (supportsPopover(player)) player.showPopover();
465
- else player.show();
466
- }
467
- function playPlayer(player) {
468
- const video = player.querySelector("video");
469
- if (video) playVideo(video);
1918
+ function supportsPopover(dialog) {
1919
+ return typeof dialog.showPopover === "function";
470
1920
  }
471
- function addVideoControls(player, card, video, options) {
472
- const toggle = document.createElement("button");
473
- toggle.type = "button";
474
- toggle.className = "play player-toggle";
475
- const sound = createButton("player-sound", "", "soundOff");
476
- function syncPlayback() {
477
- player.toggleAttribute("data-paused", video.paused);
478
- toggle.setAttribute(
479
- "aria-label",
480
- video.paused ? options.playLabel : options.pauseLabel
481
- );
482
- toggle.replaceChildren(createIcon(video.paused ? "play" : "pause"));
483
- }
484
- function syncSound() {
485
- sound.setAttribute(
486
- "aria-label",
487
- video.muted ? options.soundOnLabel : options.soundOffLabel
488
- );
489
- sound.replaceChildren(createIcon(video.muted ? "soundOff" : "soundOn"));
490
- }
491
- function togglePlayback() {
492
- if (video.paused) playVideo(video);
493
- else video.pause();
1921
+ var PlayerController = class {
1922
+ constructor(host, options) {
1923
+ this.host = host;
1924
+ this.options = options;
1925
+ /** Rendered and, once the host has updated, shown. */
1926
+ this.isOpen = false;
1927
+ this.expanded = false;
1928
+ /** Switched modes at least once: only the first opening fades in. */
1929
+ this.switched = false;
1930
+ /** The dialog is showing, in the mode `expanded` says. */
1931
+ this.shown = false;
1932
+ this.dialog = e5();
1933
+ this.expandButton = e5();
1934
+ this.closeButton = e5();
1935
+ this.toggleExpanded = async () => {
1936
+ var _a13;
1937
+ const dialog = this.dialog.value;
1938
+ if (!dialog) return;
1939
+ this.hide(dialog);
1940
+ this.expanded = !this.expanded;
1941
+ this.switched = true;
1942
+ this.host.requestUpdate();
1943
+ await this.host.updateComplete;
1944
+ if (!this.isOpen) return;
1945
+ this.show(dialog);
1946
+ (_a13 = this.expandButton.value) == null ? void 0 : _a13.focus();
1947
+ };
1948
+ // Escape anywhere on the page, also in the mini player, which is not modal.
1949
+ this.onKeyDown = (event) => {
1950
+ if (event.key === "Escape") this.options.onClose();
1951
+ };
1952
+ // Clicks on the backdrop of the expanded view reach the dialog itself.
1953
+ this.onDialogClick = (event) => {
1954
+ if (this.expanded && event.target === event.currentTarget) {
1955
+ this.options.onClose();
1956
+ }
1957
+ };
1958
+ // Escape on a modal dialog would only hide it: close the player instead.
1959
+ this.onCancel = (event) => {
1960
+ event.preventDefault();
1961
+ this.options.onClose();
1962
+ };
1963
+ host.addController(this);
1964
+ this.video = new VideoController(host);
494
1965
  }
495
- video.addEventListener("play", syncPlayback);
496
- video.addEventListener("pause", syncPlayback);
497
- video.addEventListener("volumechange", syncSound);
498
- video.addEventListener("error", () => {
499
- toggle.remove();
500
- sound.remove();
501
- delete player.dataset.paused;
502
- });
503
- toggle.addEventListener("click", (event) => {
504
- event.stopPropagation();
505
- togglePlayback();
506
- });
507
- sound.addEventListener("click", (event) => {
508
- event.stopPropagation();
509
- video.muted = !video.muted;
510
- });
511
- card.addEventListener("click", () => {
512
- if (video.isConnected) togglePlayback();
513
- });
514
- syncPlayback();
515
- syncSound();
516
- card.append(toggle, sound);
517
- }
518
- function createPlayer(story, options) {
519
- const player = document.createElement("dialog");
520
- player.className = "player";
521
- player.setAttribute("popover", "manual");
522
- player.setAttribute("aria-label", options.label);
523
- const frame = document.createElement("div");
524
- frame.className = "player-frame";
525
- const controls = document.createElement("div");
526
- controls.className = "player-controls";
527
- const expand = createButton("player-expand", options.expandLabel, "expand");
528
- const close = createButton("player-close", options.closeLabel, "close");
529
- controls.append(expand, close);
530
- let expanded = false;
531
- function hide() {
532
- if (!expanded && supportsPopover(player)) player.hidePopover();
533
- else player.close();
534
- }
535
- expand.addEventListener("click", () => {
536
- hide();
537
- expanded = !expanded;
538
- player.toggleAttribute("data-expanded", expanded);
539
- player.dataset.switched = "";
540
- expand.setAttribute(
541
- "aria-label",
542
- expanded ? options.collapseLabel : options.expandLabel
543
- );
544
- expand.replaceChildren(createIcon(expanded ? "collapse" : "expand"));
545
- if (expanded) player.showModal();
546
- else showPlayer(player);
547
- expand.focus();
548
- });
549
- close.addEventListener("click", options.onClose);
550
- player.addEventListener("click", (event) => {
551
- if (expanded && event.target === player) options.onClose();
552
- });
553
- player.addEventListener("cancel", (event) => {
554
- event.preventDefault();
555
- options.onClose();
556
- });
557
- const card = createCard(story);
558
- const video = card.querySelector("video");
559
- if (video) addVideoControls(player, card, video, options);
560
- frame.append(controls, card);
561
- player.append(frame);
562
- return player;
563
- }
1966
+ hostDisconnected() {
1967
+ this.close();
1968
+ }
1969
+ /** Opens the mini player, plays the video and focuses the close button. */
1970
+ async open() {
1971
+ var _a13;
1972
+ if (this.isOpen) return;
1973
+ document.addEventListener("keydown", this.onKeyDown);
1974
+ this.isOpen = true;
1975
+ this.expanded = false;
1976
+ this.switched = false;
1977
+ this.video.reset();
1978
+ this.host.requestUpdate();
1979
+ await this.host.updateComplete;
1980
+ const dialog = this.dialog.value;
1981
+ if (!this.isOpen || !dialog) return;
1982
+ this.show(dialog);
1983
+ this.video.play();
1984
+ (_a13 = this.closeButton.value) == null ? void 0 : _a13.focus();
1985
+ }
1986
+ /** Hides the player now; the host removes it on its next update. */
1987
+ close() {
1988
+ if (!this.isOpen) return;
1989
+ document.removeEventListener("keydown", this.onKeyDown);
1990
+ const dialog = this.dialog.value;
1991
+ if (dialog) this.hide(dialog);
1992
+ this.isOpen = false;
1993
+ this.host.requestUpdate();
1994
+ }
1995
+ // Mini: a manual popover, or a non-modal dialog without popover support.
1996
+ // Expanded: a modal dialog.
1997
+ // Already showing: a second expand click in the same task resumes after the
1998
+ // first one has shown the dialog, and showing it again would throw.
1999
+ show(dialog) {
2000
+ if (this.shown) return;
2001
+ if (this.expanded) dialog.showModal();
2002
+ else if (supportsPopover(dialog)) dialog.showPopover();
2003
+ else dialog.show();
2004
+ this.shown = true;
2005
+ }
2006
+ // A dialog can't be shown as a popover and as a modal at the same time, so
2007
+ // switching modes hides it first, the same way it was shown.
2008
+ hide(dialog) {
2009
+ if (!this.shown) return;
2010
+ if (!this.expanded && supportsPopover(dialog)) dialog.hidePopover();
2011
+ else dialog.close();
2012
+ this.shown = false;
2013
+ }
2014
+ /**
2015
+ * Play/pause in the middle of the video and sound on/off at its top right.
2016
+ * They follow the video's own events, so a blocked autoplay shows as
2017
+ * paused.
2018
+ */
2019
+ renderVideoControls() {
2020
+ const { video, options } = this;
2021
+ const onToggle = (event) => {
2022
+ event.stopPropagation();
2023
+ video.togglePlayback();
2024
+ };
2025
+ const onSound = (event) => {
2026
+ event.stopPropagation();
2027
+ video.toggleMuted();
2028
+ };
2029
+ return T`
2030
+ <button
2031
+ type="button"
2032
+ class="play player-toggle"
2033
+ aria-label=${video.paused ? options.playLabel : options.pauseLabel}
2034
+ @click=${onToggle}
2035
+ >
2036
+ ${icon(video.paused ? "play" : "pause")}
2037
+ </button>
2038
+ <button
2039
+ type="button"
2040
+ class="player-button player-sound"
2041
+ aria-label=${video.muted ? options.soundOnLabel : options.soundOffLabel}
2042
+ @click=${onSound}
2043
+ >
2044
+ ${icon(video.muted ? "soundOff" : "soundOn")}
2045
+ </button>
2046
+ `;
2047
+ }
2048
+ /**
2049
+ * The player <dialog> while it is open. Clicking the video also plays or
2050
+ * pauses it.
2051
+ */
2052
+ render(story) {
2053
+ if (!this.isOpen) return A;
2054
+ const { video, options, expanded } = this;
2055
+ const withVideo = hasVideo(story, video);
2056
+ return T`
2057
+ <dialog
2058
+ class="player"
2059
+ popover="manual"
2060
+ aria-label=${options.label}
2061
+ ?data-expanded=${expanded}
2062
+ ?data-switched=${this.switched}
2063
+ ?data-paused=${withVideo && video.paused}
2064
+ ${n5(this.dialog)}
2065
+ @click=${this.onDialogClick}
2066
+ @cancel=${this.onCancel}
2067
+ >
2068
+ <div class="player-frame">
2069
+ <div class="player-controls">
2070
+ <button
2071
+ type="button"
2072
+ class="player-button player-expand"
2073
+ aria-label=${expanded ? options.collapseLabel : options.expandLabel}
2074
+ ${n5(this.expandButton)}
2075
+ @click=${this.toggleExpanded}
2076
+ >
2077
+ ${icon(expanded ? "collapse" : "expand")}
2078
+ </button>
2079
+ <button
2080
+ type="button"
2081
+ class="player-button player-close"
2082
+ aria-label=${options.closeLabel}
2083
+ ${n5(this.closeButton)}
2084
+ @click=${options.onClose}
2085
+ >
2086
+ ${icon("close")}
2087
+ </button>
2088
+ </div>
2089
+ <div class="card" @click=${() => video.togglePlayback()}>
2090
+ ${renderMedia(story, video)}
2091
+ ${withVideo ? this.renderVideoControls() : A}
2092
+ </div>
2093
+ </div>
2094
+ </dialog>
2095
+ `;
2096
+ }
2097
+ };
564
2098
 
565
2099
  // src/story/story.ts
566
2100
  var TAG_NAME = "vtex-ads-story";
567
- var _a;
568
- var BaseElement = (_a = globalThis.HTMLElement) != null ? _a : Object;
569
- var styles = `
570
- :host {
571
- display: block;
572
- font-family: var(--vtex-ads-story-font-family, inherit);
573
- color: var(--vtex-ads-story-color-text, inherit);
574
- }
575
- ${cardStyles}
576
- ${playerStyles}
577
- `;
578
2101
  var PLACEHOLDER_STORY = {
579
2102
  poster_url: "https://dummyimage.com/1080x1920/e31c57/fff",
580
2103
  media_url: "https://samplelib.com/mp4/sample-10s-vp9.mp4"
@@ -590,37 +2113,11 @@ var LABELS = {
590
2113
  soundOn: "Ativar som",
591
2114
  soundOff: "Desativar som"
592
2115
  };
593
- var VtexAdsStoryElement = class extends BaseElement {
2116
+ var VtexAdsStoryElement = class extends i3 {
594
2117
  constructor() {
595
2118
  super(...arguments);
596
- this.player = null;
597
- this.onKeyDown = (event) => {
598
- if (event.key === "Escape") this.closePlayer();
599
- };
600
- }
601
- render() {
602
- var _a2;
603
- const container = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(".root");
604
- if (!container) return;
605
- container.replaceChildren(
606
- createCard(PLACEHOLDER_STORY, {
607
- label: LABELS.watch,
608
- soundOnLabel: LABELS.soundOn,
609
- soundOffLabel: LABELS.soundOff,
610
- onSelect: () => this.openPlayer()
611
- })
612
- );
613
- }
614
- cardVideo() {
615
- var _a2;
616
- return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(
617
- ".root .card video"
618
- );
619
- }
620
- openPlayer() {
621
- var _a2, _b;
622
- if (this.player || !this.shadowRoot) return;
623
- this.player = createPlayer(PLACEHOLDER_STORY, {
2119
+ this.cardVideo = new VideoController(this);
2120
+ this.player = new PlayerController(this, {
624
2121
  label: LABELS.player,
625
2122
  expandLabel: LABELS.expand,
626
2123
  collapseLabel: LABELS.collapse,
@@ -631,37 +2128,57 @@ var VtexAdsStoryElement = class extends BaseElement {
631
2128
  soundOffLabel: LABELS.soundOff,
632
2129
  onClose: () => this.closePlayer()
633
2130
  });
634
- this.shadowRoot.append(this.player);
635
- showPlayer(this.player);
636
- (_a2 = this.cardVideo()) == null ? void 0 : _a2.pause();
637
- playPlayer(this.player);
638
- document.addEventListener("keydown", this.onKeyDown);
639
- (_b = this.player.querySelector(".player-close")) == null ? void 0 : _b.focus();
640
- }
641
- // `removed`: the element is leaving the page, so there is no card to give
642
- // focus back to or to resume playing (it would play out of sight).
643
- closePlayer({ removed = false } = {}) {
644
- var _a2, _b;
645
- if (!this.player) return;
646
- document.removeEventListener("keydown", this.onKeyDown);
647
- this.player.remove();
648
- this.player = null;
649
- if (removed) return;
650
- const video = this.cardVideo();
651
- if (video == null ? void 0 : video.autoplay) playVideo(video);
652
- (_b = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(".root .card-open")) == null ? void 0 : _b.focus();
653
2131
  }
2132
+ // Lit keeps the card's DOM when the element is moved (removed and appended
2133
+ // again), but the browser pauses a removed video and doesn't autoplay it
2134
+ // again. resume() only plays a video that autoplays (not with reduced
2135
+ // motion), and does nothing on the first connection, before the render.
2136
+ // Not in VideoController.hostConnected: there, the player's video is still
2137
+ // in the DOM until the next update and would play for a moment.
654
2138
  connectedCallback() {
655
- if (!this.shadowRoot) {
656
- const root = this.attachShadow({ mode: "open" });
657
- root.innerHTML = `<style>${styles}</style><div class="root"></div>`;
658
- }
659
- this.render();
2139
+ super.connectedCallback();
2140
+ this.cardVideo.resume();
660
2141
  }
661
- disconnectedCallback() {
662
- this.closePlayer({ removed: true });
2142
+ openPlayer() {
2143
+ if (this.player.isOpen) return;
2144
+ this.cardVideo.pause();
2145
+ void this.player.open();
2146
+ }
2147
+ // The player also closes on its own when the element leaves the page,
2148
+ // without this: there is no card to give focus back to or to resume playing
2149
+ // (it would play out of sight).
2150
+ closePlayer() {
2151
+ var _a13;
2152
+ if (!this.player.isOpen) return;
2153
+ this.player.close();
2154
+ this.cardVideo.resume();
2155
+ (_a13 = this.renderRoot.querySelector(".root .card-open")) == null ? void 0 : _a13.focus();
2156
+ }
2157
+ render() {
2158
+ return T`
2159
+ <div class="root">
2160
+ ${renderCard(PLACEHOLDER_STORY, this.cardVideo, {
2161
+ label: LABELS.watch,
2162
+ soundOnLabel: LABELS.soundOn,
2163
+ soundOffLabel: LABELS.soundOff,
2164
+ onSelect: () => this.openPlayer()
2165
+ })}
2166
+ </div>
2167
+ ${this.player.render(PLACEHOLDER_STORY)}
2168
+ `;
663
2169
  }
664
2170
  };
2171
+ VtexAdsStoryElement.styles = [
2172
+ i`
2173
+ :host {
2174
+ display: block;
2175
+ font-family: var(--vtex-ads-story-font-family, inherit);
2176
+ color: var(--vtex-ads-story-color-text, inherit);
2177
+ }
2178
+ `,
2179
+ cardStyles,
2180
+ playerStyles
2181
+ ];
665
2182
  function defineVtexAdsStories() {
666
2183
  if (typeof customElements === "undefined") return;
667
2184
  if (customElements.get(TAG_NAME)) return;
@@ -674,4 +2191,56 @@ function defineVtexAdsStories() {
674
2191
  defineVtexAdsStories
675
2192
  });
676
2193
  /*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */
2194
+ /*! Bundled license information:
2195
+
2196
+ @lit-labs/ssr-dom-shim/lib/element-internals.js:
2197
+ @lit-labs/ssr-dom-shim/lib/events.js:
2198
+ (**
2199
+ * @license
2200
+ * Copyright 2023 Google LLC
2201
+ * SPDX-License-Identifier: BSD-3-Clause
2202
+ *)
2203
+
2204
+ @lit-labs/ssr-dom-shim/lib/css.js:
2205
+ @lit-labs/ssr-dom-shim/lib/observers.js:
2206
+ (**
2207
+ * @license
2208
+ * Copyright 2024 Google LLC
2209
+ * SPDX-License-Identifier: BSD-3-Clause
2210
+ *)
2211
+
2212
+ @lit-labs/ssr-dom-shim/index.js:
2213
+ @lit/reactive-element/node/css-tag.js:
2214
+ (**
2215
+ * @license
2216
+ * Copyright 2019 Google LLC
2217
+ * SPDX-License-Identifier: BSD-3-Clause
2218
+ *)
2219
+
2220
+ lit-html/node/lit-html.js:
2221
+ lit-element/lit-element.js:
2222
+ lit-html/node/directive.js:
2223
+ lit-html/node/directives/unsafe-html.js:
2224
+ lit-html/node/async-directive.js:
2225
+ (**
2226
+ * @license
2227
+ * Copyright 2017 Google LLC
2228
+ * SPDX-License-Identifier: BSD-3-Clause
2229
+ *)
2230
+
2231
+ lit-html/node/is-server.js:
2232
+ (**
2233
+ * @license
2234
+ * Copyright 2022 Google LLC
2235
+ * SPDX-License-Identifier: BSD-3-Clause
2236
+ *)
2237
+
2238
+ lit-html/node/directive-helpers.js:
2239
+ lit-html/node/directives/ref.js:
2240
+ (**
2241
+ * @license
2242
+ * Copyright 2020 Google LLC
2243
+ * SPDX-License-Identifier: BSD-3-Clause
2244
+ *)
2245
+ */
677
2246
  //# sourceMappingURL=index.cjs.map