@vtex/ads-stories 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @vtex/ads-stories
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2c00914: `<vtex-ads-story>` now plays the Story's video. For now it renders one fixed test Story from public URLs, until the carousel passes in Stories from the ad API. The card loops the video muted over the cover (not for people who prefer reduced motion), with a sound on/off button at its top right, and pauses while the player is open. The player plays it muted, with play/pause in the middle (also by clicking the video) and a sound on/off button at the top right. If the video can't load, the cover stays and the video controls are hidden.
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  VTEX Ads Stories web component. Framework-agnostic: works on any HTML5 page,
4
4
  including VTEX IO, FastStore and non-VTEX storefronts.
5
5
 
6
- > Work in progress. Currently renders one placeholder 9:16 card that opens in a
7
- > player at the bottom right; video and Stories from the ad API come next.
6
+ > Work in progress. Currently renders one fixed test Story, which opens in a
7
+ > player at the bottom right. The carousel, fed by the ad API, comes next.
8
8
 
9
9
  ## npm
10
10
 
@@ -1,8 +1,11 @@
1
- "use strict";var VtexAdsStories=(()=>{var u=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var T=(r,t)=>{for(var e in t)u(r,e,{get:t[e],enumerable:!0})},N=(r,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of V(t))!P.call(r,o)&&o!==e&&u(r,o,{get:()=>t[o],enumerable:!(a=C(t,o))||a.enumerable});return r};var Z=r=>N(u({},"__esModule",{value:!0}),r);var K={};T(K,{TAG_NAME:()=>c,VtexAdsStoryElement:()=>l,defineVtexAdsStories:()=>h});var v=`<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>
2
- `;var w=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z"/></svg>
3
- `;var E=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"/></svg>
4
- `;var A=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z"/></svg>
5
- `;var I={close:v,collapse:w,expand:E,play:A};function i(r){let t=document.createElement("template");t.innerHTML=I[r];let e=t.content.firstElementChild;return e.classList.add("icon"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false"),e}var x=`
1
+ "use strict";var VtexAdsStories=(()=>{var x=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var _=(a,t)=>{for(var e in t)x(a,e,{get:t[e],enumerable:!0})},I=(a,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of D(t))!z.call(a,r)&&r!==e&&x(a,r,{get:()=>t[r],enumerable:!(o=R(t,r))||o.enumerable});return a};var q=a=>I(x({},"__esModule",{value:!0}),a);var oe={};_(oe,{TAG_NAME:()=>m,VtexAdsStoryElement:()=>u,defineVtexAdsStories:()=>y});var V=`<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>
2
+ `;var k=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z"/></svg>
3
+ `;var H=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"/></svg>
4
+ `;var O=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z"/></svg>
5
+ `;var S=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z"/></svg>
6
+ `;var C=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M245.66,146.34a8,8,0,0,1-11.32,11.32L216,139.31l-18.34,18.35a8,8,0,0,1-11.32-11.32L204.69,128l-18.35-18.34a8,8,0,0,1,11.32-11.32L216,116.69l18.34-18.35a8,8,0,0,1,11.32,11.32L227.31,128ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm97.15-54.15a8,8,0,0,0-10-.16l-65.57,51A4,4,0,0,0,80,79.84v96.32a4,4,0,0,0,1.55,3.15l65.57,51a8,8,0,0,0,9,.56,8.29,8.29,0,0,0,3.91-7.18V32.25A8.27,8.27,0,0,0,157.12,25.85Z"/></svg>
7
+ `;var P=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"/></svg>
8
+ `;var W={close:V,collapse:k,expand:H,pause:O,play:S,soundOff:C,soundOn:P};function d(a){let t=document.createElement("template");t.innerHTML=W[a];let e=t.content.firstElementChild;return e.classList.add("icon"),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false"),e}var v=`
6
9
  .card {
7
10
  position: relative;
8
11
  box-sizing: border-box;
@@ -13,11 +16,29 @@
13
16
  background: #000;
14
17
  }
15
18
 
16
- .card[role="button"] {
19
+ /* The card's button covers it. The focus ring goes on the card, since the
20
+ card's overflow would clip the button's own. */
21
+ .card-open {
22
+ position: absolute;
23
+ inset: 0;
24
+ width: 100%;
25
+ height: 100%;
26
+ padding: 0;
27
+ border: 0;
28
+ background: transparent;
17
29
  cursor: pointer;
18
30
  }
19
31
 
20
- .poster {
32
+ .card-open:focus-visible {
33
+ outline: none;
34
+ }
35
+
36
+ .card:has(> .card-open:focus-visible) {
37
+ outline: auto;
38
+ }
39
+
40
+ .poster,
41
+ .video {
21
42
  position: absolute;
22
43
  inset: 0;
23
44
  width: 100%;
@@ -53,6 +74,29 @@
53
74
  color: #fff;
54
75
  }
55
76
 
77
+ /* Sound on/off, at the top right of the card (as in the prototype). */
78
+ .card-sound {
79
+ position: absolute;
80
+ top: 22px;
81
+ right: 12px;
82
+ z-index: 1;
83
+ display: grid;
84
+ width: 28px;
85
+ height: 28px;
86
+ place-items: center;
87
+ padding: 0;
88
+ border: 0;
89
+ background: transparent;
90
+ color: #fff;
91
+ cursor: pointer;
92
+ filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
93
+ }
94
+
95
+ .card-sound .icon {
96
+ width: 20px;
97
+ height: 20px;
98
+ }
99
+
56
100
  /* With a mouse, the play button shows only on hover or keyboard focus.
57
101
  Touch screens have no hover, so it stays visible there. */
58
102
  @media (hover: hover) and (pointer: fine) {
@@ -62,12 +106,12 @@
62
106
  }
63
107
 
64
108
  .card:hover .play,
65
- .card:focus-visible .play {
109
+ .card-open:focus-visible .play {
66
110
  opacity: 1;
67
111
  transform: translate(-50%, -50%);
68
112
  }
69
113
  }
70
- `;function B(r){try{let{protocol:t}=new URL(r);return t==="https:"||t==="http:"}catch(t){return!1}}function p(r,t){let e=document.createElement("div");if(e.className="card",r.poster_url&&B(r.poster_url)){let a=document.createElement("img");a.className="poster",a.alt="",a.src=r.poster_url,e.append(a)}if(t){e.setAttribute("role","button"),e.setAttribute("aria-label",t.label),e.tabIndex=0;let a=document.createElement("span");a.className="play",a.setAttribute("aria-hidden","true"),a.append(i("play")),e.append(a),e.addEventListener("click",t.onSelect),e.addEventListener("keydown",o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),t.onSelect())})}return e}var f=`
114
+ `;function T(a){if(!a)return null;try{let{protocol:t}=new URL(a);return t==="https:"||t==="http:"?a:null}catch(t){return null}}function J(){var a,t;return(t=(a=globalThis.matchMedia)==null?void 0:a.call(globalThis,"(prefers-reduced-motion: reduce)").matches)!=null?t:!1}function c(a){var t;(t=a.play())==null||t.catch(()=>{})}function Q(a,t){let e=document.createElement("video");return e.className="video",e.muted=!0,e.setAttribute("muted",""),e.setAttribute("playsinline",""),e.loop=!0,e.preload="metadata",e.autoplay=!J(),t&&(e.poster=t),e.src=a,e.addEventListener("error",()=>e.remove()),e}function X(a,t){let e=document.createElement("button");e.type="button",e.className="card-sound";function o(){e.setAttribute("aria-label",a.muted?t.soundOnLabel:t.soundOffLabel),e.replaceChildren(d(a.muted?"soundOff":"soundOn"))}return a.addEventListener("volumechange",o),a.addEventListener("error",()=>e.remove()),e.addEventListener("click",()=>{a.muted=!a.muted}),o(),e}function h(a,t){let e=document.createElement("div");e.className="card";let o=T(a.poster_url);if(o){let s=document.createElement("img");s.className="poster",s.alt="",s.src=o,e.append(s)}let r=T(a.media_url),n=r?Q(r,o):null;if(n&&e.append(n),t){let s=document.createElement("button");s.type="button",s.className="card-open",s.setAttribute("aria-label",t.label);let l=document.createElement("span");l.className="play",l.setAttribute("aria-hidden","true"),l.append(d("play")),s.append(l),s.addEventListener("click",t.onSelect),e.append(s),n&&e.append(X(n,t))}return e}var L=`
71
115
  .player {
72
116
  position: fixed;
73
117
  inset: auto 16px 16px auto;
@@ -112,6 +156,46 @@
112
156
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
113
157
  }
114
158
 
159
+ .player .card:has(.video) {
160
+ cursor: pointer;
161
+ }
162
+
163
+ /* Play/pause reuses the card's glass .play button, as a real button. */
164
+ .player-toggle {
165
+ padding: 0;
166
+ border: 0;
167
+ color: #fff;
168
+ font: inherit;
169
+ cursor: pointer;
170
+ }
171
+
172
+ .player[data-paused] .player-toggle,
173
+ .player-toggle:focus-visible {
174
+ opacity: 1;
175
+ transform: translate(-50%, -50%);
176
+ }
177
+
178
+ /* On touch, tapping the video pauses it; the button shows while paused. */
179
+ @media (hover: none) {
180
+ .player:not([data-paused]) .player-toggle {
181
+ opacity: 0;
182
+ }
183
+ }
184
+
185
+ .player-sound {
186
+ position: absolute;
187
+ top: 12px;
188
+ right: 12px;
189
+ z-index: 1;
190
+ border-color: transparent;
191
+ background: rgba(0, 0, 0, 0.3);
192
+ }
193
+
194
+ .player-sound .icon {
195
+ width: 20px;
196
+ height: 20px;
197
+ }
198
+
115
199
  /* Above the card: on narrow screens the expanded card can cover them. */
116
200
  .player-controls {
117
201
  position: absolute;
@@ -196,8 +280,12 @@
196
280
  border-radius: 0;
197
281
  }
198
282
 
283
+ /* Below the sound button, at the top right of the video. Placed in the
284
+ video frame, not the screen: the frame is centered, so on screens
285
+ taller than 9:16 its top is below the screen's. */
199
286
  .player[data-expanded] .player-controls {
200
- top: 12px;
287
+ position: absolute;
288
+ top: 60px;
201
289
  right: 12px;
202
290
  }
203
291
  }
@@ -214,14 +302,14 @@
214
302
  animation: none;
215
303
  }
216
304
  }
217
- `;function L(r,t,e){let a=document.createElement("button");return a.type="button",a.className=`player-button ${r}`,a.setAttribute("aria-label",t),a.append(i(e)),a}function k(r){return typeof r.showPopover=="function"}function y(r){k(r)?r.showPopover():r.show()}function b(r,t){let e=document.createElement("dialog");e.className="player",e.setAttribute("popover","manual"),e.setAttribute("aria-label",t.label);let a=document.createElement("div");a.className="player-frame";let o=document.createElement("div");o.className="player-controls";let s=L("player-expand",t.expandLabel,"expand"),g=L("player-close",t.closeLabel,"close");o.append(s,g);let n=!1;function M(){!n&&k(e)?e.hidePopover():e.close()}return s.addEventListener("click",()=>{M(),n=!n,e.toggleAttribute("data-expanded",n),e.dataset.switched="",s.setAttribute("aria-label",n?t.collapseLabel:t.expandLabel),s.replaceChildren(i(n?"collapse":"expand")),n?e.showModal():y(e),s.focus()}),g.addEventListener("click",t.onClose),e.addEventListener("click",m=>{n&&m.target===e&&t.onClose()}),e.addEventListener("cancel",m=>{m.preventDefault(),t.onClose()}),a.append(o,p(r)),e.append(a),e}var c="vtex-ads-story",H,z=(H=globalThis.HTMLElement)!=null?H:Object,G=`
305
+ `;function w(a,t,e){let o=document.createElement("button");return o.type="button",o.className=`player-button ${a}`,o.setAttribute("aria-label",t),o.append(d(e)),o}function N(a){return typeof a.showPopover=="function"}function b(a){N(a)?a.showPopover():a.show()}function E(a){let t=a.querySelector("video");t&&c(t)}function ee(a,t,e,o){let r=document.createElement("button");r.type="button",r.className="play player-toggle";let n=w("player-sound","","soundOff");function s(){a.toggleAttribute("data-paused",e.paused),r.setAttribute("aria-label",e.paused?o.playLabel:o.pauseLabel),r.replaceChildren(d(e.paused?"play":"pause"))}function l(){n.setAttribute("aria-label",e.muted?o.soundOnLabel:o.soundOffLabel),n.replaceChildren(d(e.muted?"soundOff":"soundOn"))}function f(){e.paused?c(e):e.pause()}e.addEventListener("play",s),e.addEventListener("pause",s),e.addEventListener("volumechange",l),e.addEventListener("error",()=>{r.remove(),n.remove(),delete a.dataset.paused}),r.addEventListener("click",p=>{p.stopPropagation(),f()}),n.addEventListener("click",p=>{p.stopPropagation(),e.muted=!e.muted}),t.addEventListener("click",()=>{e.isConnected&&f()}),s(),l(),t.append(r,n)}function A(a,t){let e=document.createElement("dialog");e.className="player",e.setAttribute("popover","manual"),e.setAttribute("aria-label",t.label);let o=document.createElement("div");o.className="player-frame";let r=document.createElement("div");r.className="player-controls";let n=w("player-expand",t.expandLabel,"expand"),s=w("player-close",t.closeLabel,"close");r.append(n,s);let l=!1;function f(){!l&&N(e)?e.hidePopover():e.close()}n.addEventListener("click",()=>{f(),l=!l,e.toggleAttribute("data-expanded",l),e.dataset.switched="",n.setAttribute("aria-label",l?t.collapseLabel:t.expandLabel),n.replaceChildren(d(l?"collapse":"expand")),l?e.showModal():b(e),n.focus()}),s.addEventListener("click",t.onClose),e.addEventListener("click",g=>{l&&g.target===e&&t.onClose()}),e.addEventListener("cancel",g=>{g.preventDefault(),t.onClose()});let p=h(a),M=p.querySelector("video");return M&&ee(e,p,M,t),o.append(r,p),e.append(o),e}var m="vtex-ads-story",B,te=(B=globalThis.HTMLElement)!=null?B:Object,ae=`
218
306
  :host {
219
307
  display: block;
220
308
  font-family: var(--vtex-ads-story-font-family, inherit);
221
309
  color: var(--vtex-ads-story-color-text, inherit);
222
310
  }
223
- ${x}
224
- ${f}
225
- `,S={ad_id:"placeholder",poster_url:"https://dummyimage.com/1080x1920/e31c57/fff"},d={watch:"Assistir v\xEDdeo",player:"V\xEDdeo",expand:"Expandir v\xEDdeo",collapse:"Reduzir v\xEDdeo",close:"Fechar v\xEDdeo"},l=class extends z{constructor(){super(...arguments);this.player=null;this.onKeyDown=e=>{e.key==="Escape"&&this.closePlayer()}}render(){var a;let e=(a=this.shadowRoot)==null?void 0:a.querySelector(".root");e&&e.replaceChildren(p(S,{label:d.watch,onSelect:()=>this.openPlayer()}))}openPlayer(){var e;this.player||!this.shadowRoot||(this.player=b(S,{label:d.player,expandLabel:d.expand,collapseLabel:d.collapse,closeLabel:d.close,onClose:()=>this.closePlayer()}),this.shadowRoot.append(this.player),y(this.player),document.addEventListener("keydown",this.onKeyDown),(e=this.player.querySelector(".player-close"))==null||e.focus())}closePlayer({restoreFocus:e=!0}={}){var a,o;this.player&&(document.removeEventListener("keydown",this.onKeyDown),this.player.remove(),this.player=null,e&&((o=(a=this.shadowRoot)==null?void 0:a.querySelector(".root .card"))==null||o.focus()))}connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`<style>${G}</style><div class="root"></div>`}this.render()}disconnectedCallback(){this.closePlayer({restoreFocus:!1})}};function h(){typeof customElements!="undefined"&&(customElements.get(c)||customElements.define(c,l))}h();return Z(K);})();
311
+ ${v}
312
+ ${L}
313
+ `,Z={poster_url:"https://dummyimage.com/1080x1920/e31c57/fff",media_url:"https://samplelib.com/mp4/sample-10s-vp9.mp4"},i={watch:"Assistir v\xEDdeo",player:"V\xEDdeo",expand:"Expandir v\xEDdeo",collapse:"Reduzir v\xEDdeo",close:"Fechar v\xEDdeo",play:"Reproduzir v\xEDdeo",pause:"Pausar v\xEDdeo",soundOn:"Ativar som",soundOff:"Desativar som"},u=class extends te{constructor(){super(...arguments);this.player=null;this.onKeyDown=e=>{e.key==="Escape"&&this.closePlayer()}}render(){var o;let e=(o=this.shadowRoot)==null?void 0:o.querySelector(".root");e&&e.replaceChildren(h(Z,{label:i.watch,soundOnLabel:i.soundOn,soundOffLabel:i.soundOff,onSelect:()=>this.openPlayer()}))}cardVideo(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector(".root .card video")}openPlayer(){var e,o;this.player||!this.shadowRoot||(this.player=A(Z,{label:i.player,expandLabel:i.expand,collapseLabel:i.collapse,closeLabel:i.close,playLabel:i.play,pauseLabel:i.pause,soundOnLabel:i.soundOn,soundOffLabel:i.soundOff,onClose:()=>this.closePlayer()}),this.shadowRoot.append(this.player),b(this.player),(e=this.cardVideo())==null||e.pause(),E(this.player),document.addEventListener("keydown",this.onKeyDown),(o=this.player.querySelector(".player-close"))==null||o.focus())}closePlayer({removed:e=!1}={}){var r,n;if(!this.player||(document.removeEventListener("keydown",this.onKeyDown),this.player.remove(),this.player=null,e))return;let o=this.cardVideo();o!=null&&o.autoplay&&c(o),(n=(r=this.shadowRoot)==null?void 0:r.querySelector(".root .card-open"))==null||n.focus()}connectedCallback(){if(!this.shadowRoot){let e=this.attachShadow({mode:"open"});e.innerHTML=`<style>${ae}</style><div class="root"></div>`}this.render()}disconnectedCallback(){this.closePlayer({removed:!0})}};function y(){typeof customElements!="undefined"&&(customElements.get(m)||customElements.define(m,u))}y();return q(oe);})();
226
314
  /*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */
227
315
  //# sourceMappingURL=vtex-ads-stories.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/cdn.ts","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg","../../src/components/icons/index.ts","../../src/components/card/card.ts","../../src/components/player/player.ts","../../src/story/story.ts"],"sourcesContent":["import { defineVtexAdsStories } from \"./story\";\n\ndefineVtexAdsStories();\n\nexport { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from \"./story\";\n","<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","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z\"/></svg>\n","/*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */\n\n// SVG files as downloaded from Phosphor: regular weight, or the weight in the\n// file name. They are bundled as text: `?raw` is handled by Vite in dev and\n// tests, and by the raw plugin in tsup.config.ts.\nimport close from \"./assets/close.svg?raw\";\nimport collapse from \"./assets/collapse.svg?raw\";\nimport expand from \"./assets/expand.svg?raw\";\nimport play from \"./assets/play-fill.svg?raw\";\n\nexport const icons = { close, collapse, expand, play };\n\nexport type IconName = keyof typeof icons;\n\n/** Renders a bundled icon. It is decorative: name the control around it. */\nexport function createIcon(name: IconName) {\n const template = document.createElement(\"template\");\n template.innerHTML = icons[name];\n\n const svg = template.content.firstElementChild as SVGSVGElement;\n svg.classList.add(\"icon\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.setAttribute(\"focusable\", \"false\");\n return svg;\n}\n","import { createIcon } from \"../icons\";\nimport type { StoryAd } from \"../../types\";\n\nexport const cardStyles = `\n .card {\n position: relative;\n box-sizing: border-box;\n width: calc(500px * 9 / 16);\n height: 500px;\n overflow: hidden;\n border-radius: var(--vtex-ads-story-radius, 20px);\n background: #000;\n }\n\n .card[role=\"button\"] {\n cursor: pointer;\n }\n\n .poster {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .play {\n position: absolute;\n top: 50%;\n left: 50%;\n display: grid;\n width: 66px;\n height: 66px;\n place-items: center;\n border-radius: 50%;\n background:\n linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),\n rgba(255, 255, 255, 0.15);\n backdrop-filter: blur(2px);\n box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);\n transform: translate(-50%, -50%);\n transition:\n opacity 0.3s ease,\n transform 0.3s ease;\n }\n\n /* The icon's triangle is 18px tall and already sits slightly right of its\n box, so it looks centered in the circle. */\n .play .icon {\n width: 22px;\n height: 22px;\n color: #fff;\n }\n\n /* With a mouse, the play button shows only on hover or keyboard focus.\n Touch screens have no hover, so it stays visible there. */\n @media (hover: hover) and (pointer: fine) {\n .play {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.9);\n }\n\n .card:hover .play,\n .card:focus-visible .play {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n`;\n\nexport interface CardOptions {\n /** Accessible name of the card. */\n label: string;\n /** Called on click, Enter or Space. */\n onSelect: () => void;\n}\n\n// Only absolute http(s) URLs reach the DOM.\nfunction isHttpUrl(value: string) {\n try {\n const { protocol } = new URL(value);\n return protocol === \"https:\" || protocol === \"http:\";\n } catch {\n return false;\n }\n}\n\n/**\n * A 9:16 card with the Story cover. With options, the card is a button with\n * a play icon in the middle.\n */\nexport function createCard(story: StoryAd, options?: CardOptions) {\n const card = document.createElement(\"div\");\n card.className = \"card\";\n\n if (story.poster_url && isHttpUrl(story.poster_url)) {\n const poster = document.createElement(\"img\");\n poster.className = \"poster\";\n poster.alt = \"\";\n poster.src = story.poster_url;\n card.append(poster);\n }\n\n if (options) {\n card.setAttribute(\"role\", \"button\");\n card.setAttribute(\"aria-label\", options.label);\n card.tabIndex = 0;\n\n const play = document.createElement(\"span\");\n play.className = \"play\";\n play.setAttribute(\"aria-hidden\", \"true\");\n play.append(createIcon(\"play\"));\n card.append(play);\n\n card.addEventListener(\"click\", options.onSelect);\n card.addEventListener(\"keydown\", (event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n options.onSelect();\n });\n }\n\n return card;\n}\n","import { createCard } from \"../card\";\nimport { createIcon, type IconName } from \"../icons\";\nimport type { StoryAd } from \"../../types\";\n\n// The player is a <dialog> shown in the top layer, so no store z-index,\n// overflow or transform can hide or move it.\n//\n// Mini: a manual popover (non-modal, the page stays usable), with the card at\n// the bottom right and the controls above it. Without popover support it is a\n// non-modal dialog, fixed with a high z-index.\n// Expanded: a modal dialog (showModal), so the browser makes the page behind\n// it inert. The card is centered over a dark backdrop, with the controls at\n// the top right of the screen. On narrow screens it fills the screen.\nexport const playerStyles = `\n .player {\n position: fixed;\n inset: auto 16px 16px auto;\n z-index: 2147483000;\n box-sizing: border-box;\n width: calc(min(587px, 100vh - 80px) * 9 / 16);\n height: min(587px, 100vh - 80px);\n margin: 0;\n padding: 0;\n overflow: visible;\n border: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n animation: player-in 0.25s ease;\n }\n\n /* A <dialog> shown as a popover has no open attribute, which the browser\n hides by default. */\n .player:popover-open {\n display: block;\n }\n\n /* Switching modes shows the dialog again; only the first opening fades in. */\n .player[data-switched] {\n animation: none;\n }\n\n .player::backdrop {\n background: transparent;\n }\n\n .player-frame {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .player .card {\n width: 100%;\n height: 100%;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);\n }\n\n /* Above the card: on narrow screens the expanded card can cover them. */\n .player-controls {\n position: absolute;\n right: 0;\n bottom: calc(100% + 8px);\n z-index: 1;\n display: flex;\n gap: 8px;\n }\n\n .player-button {\n display: grid;\n width: 36px;\n height: 36px;\n place-items: center;\n padding: 0;\n border: 1px solid rgba(133, 133, 133, 0.3);\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.32);\n backdrop-filter: blur(5px);\n color: #fff;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n .player-button:hover {\n background: rgba(0, 0, 0, 0.55);\n }\n\n .player-button .icon {\n width: 18px;\n height: 18px;\n }\n\n .player[data-expanded] {\n inset: 0;\n display: grid;\n width: 100%;\n max-width: none;\n height: 100%;\n max-height: none;\n place-items: center;\n background: rgba(0, 0, 0, 0.85);\n animation: none;\n }\n\n .player[data-expanded] .player-frame {\n width: calc(min(78vh, 720px) * 9 / 16);\n height: min(78vh, 720px);\n }\n\n .player[data-expanded] .player-controls {\n position: fixed;\n top: 24px;\n right: 24px;\n bottom: auto;\n }\n\n .player[data-expanded] .player-button {\n width: 40px;\n height: 40px;\n }\n\n @media (max-width: 576px) {\n .player {\n right: 12px;\n width: 220px;\n height: 391px;\n }\n\n .player[data-expanded] {\n background: #000;\n }\n\n /* The video stays 9:16 and centered; the rest of the screen is black. */\n .player[data-expanded] .player-frame {\n width: min(100vw, 100vh * 9 / 16);\n height: min(100vh, 100vw * 16 / 9);\n }\n\n .player[data-expanded] .card {\n border-radius: 0;\n }\n\n .player[data-expanded] .player-controls {\n top: 12px;\n right: 12px;\n }\n }\n\n @keyframes player-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .player {\n animation: none;\n }\n }\n`;\n\nexport interface PlayerOptions {\n /** Accessible name of the player. */\n label: string;\n /** Accessible names of the buttons. */\n expandLabel: string;\n collapseLabel: string;\n closeLabel: string;\n onClose: () => void;\n}\n\nfunction createButton(className: string, label: string, icon: IconName) {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = `player-button ${className}`;\n button.setAttribute(\"aria-label\", label);\n button.append(createIcon(icon));\n return button;\n}\n\nfunction supportsPopover(player: HTMLDialogElement) {\n return typeof player.showPopover === \"function\";\n}\n\n/** Shows the player as the mini player. It must already be in the page. */\nexport function showPlayer(player: HTMLDialogElement) {\n if (supportsPopover(player)) player.showPopover();\n else player.show();\n}\n\n/**\n * The Story player. It opens as the mini player (see showPlayer); expand\n * switches to the expanded view, a modal dialog, and back. Clicking the\n * backdrop of the expanded view or pressing Escape in it closes the player.\n */\nexport function createPlayer(story: StoryAd, options: PlayerOptions) {\n const player = document.createElement(\"dialog\");\n player.className = \"player\";\n player.setAttribute(\"popover\", \"manual\");\n player.setAttribute(\"aria-label\", options.label);\n\n const frame = document.createElement(\"div\");\n frame.className = \"player-frame\";\n\n const controls = document.createElement(\"div\");\n controls.className = \"player-controls\";\n\n const expand = createButton(\"player-expand\", options.expandLabel, \"expand\");\n const close = createButton(\"player-close\", options.closeLabel, \"close\");\n controls.append(expand, close);\n\n let expanded = false;\n\n // A dialog can't be shown as a popover and as a modal at the same time, so\n // switching modes hides it first, the same way it was shown.\n function hide() {\n if (!expanded && supportsPopover(player)) player.hidePopover();\n else player.close();\n }\n\n expand.addEventListener(\"click\", () => {\n hide();\n expanded = !expanded;\n player.toggleAttribute(\"data-expanded\", expanded);\n player.dataset.switched = \"\";\n expand.setAttribute(\n \"aria-label\",\n expanded ? options.collapseLabel : options.expandLabel,\n );\n expand.replaceChildren(createIcon(expanded ? \"collapse\" : \"expand\"));\n\n if (expanded) player.showModal();\n else showPlayer(player);\n expand.focus();\n });\n\n close.addEventListener(\"click\", options.onClose);\n\n // Clicks on the backdrop of the expanded view reach the dialog itself.\n player.addEventListener(\"click\", (event) => {\n if (expanded && event.target === player) options.onClose();\n });\n\n // Escape on a modal dialog would only hide it: close the player instead.\n player.addEventListener(\"cancel\", (event) => {\n event.preventDefault();\n options.onClose();\n });\n\n frame.append(controls, createCard(story));\n player.append(frame);\n return player;\n}\n","import { cardStyles, createCard } from \"../components/card\";\nimport { createPlayer, playerStyles, showPlayer } from \"../components/player\";\nimport type { StoryAd } from \"../types\";\n\nexport const TAG_NAME = \"vtex-ads-story\";\n\n// Keeps the module importable where HTMLElement doesn't exist (SSR, Node).\nconst BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;\n\nconst styles = `\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n ${cardStyles}\n ${playerStyles}\n`;\n\n// Temporary: rendered until the element reads Stories from the ad API.\nconst PLACEHOLDER_STORY: StoryAd = {\n ad_id: \"placeholder\",\n poster_url: \"https://dummyimage.com/1080x1920/e31c57/fff\",\n};\n\n// Temporary: fixed texts until the store can set them by attribute.\nconst LABELS = {\n watch: \"Assistir vídeo\",\n player: \"Vídeo\",\n expand: \"Expandir vídeo\",\n collapse: \"Reduzir vídeo\",\n close: \"Fechar vídeo\",\n};\n\nexport class VtexAdsStoryElement extends BaseElement {\n private player: HTMLDialogElement | null = null;\n\n private readonly onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") this.closePlayer();\n };\n\n private render() {\n const container = this.shadowRoot?.querySelector(\".root\");\n if (!container) return;\n\n container.replaceChildren(\n createCard(PLACEHOLDER_STORY, {\n label: LABELS.watch,\n onSelect: () => this.openPlayer(),\n }),\n );\n }\n\n private openPlayer() {\n if (this.player || !this.shadowRoot) return;\n\n this.player = createPlayer(PLACEHOLDER_STORY, {\n label: LABELS.player,\n expandLabel: LABELS.expand,\n collapseLabel: LABELS.collapse,\n closeLabel: LABELS.close,\n onClose: () => this.closePlayer(),\n });\n this.shadowRoot.append(this.player);\n showPlayer(this.player);\n document.addEventListener(\"keydown\", this.onKeyDown);\n\n this.player.querySelector<HTMLElement>(\".player-close\")?.focus();\n }\n\n private closePlayer({ restoreFocus = true } = {}) {\n if (!this.player) return;\n\n document.removeEventListener(\"keydown\", this.onKeyDown);\n this.player.remove();\n this.player = null;\n\n if (restoreFocus) {\n this.shadowRoot?.querySelector<HTMLElement>(\".root .card\")?.focus();\n }\n }\n\n connectedCallback() {\n if (!this.shadowRoot) {\n const root = this.attachShadow({ mode: \"open\" });\n root.innerHTML = `<style>${styles}</style><div class=\"root\"></div>`;\n }\n\n this.render();\n }\n\n disconnectedCallback() {\n this.closePlayer({ restoreFocus: false });\n }\n}\n\n// Types `document.createElement(\"vtex-ads-story\")` and `querySelector` results\n// as VtexAdsStoryElement in any TypeScript project, no framework needed.\ndeclare global {\n interface HTMLElementTagNameMap {\n \"vtex-ads-story\": VtexAdsStoryElement;\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n"],"mappings":"kcAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,wBAAAC,EAAA,yBAAAC,ICAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECUO,IAAMC,EAAQ,CAAE,MAAAC,EAAO,SAAAC,EAAU,OAAAC,EAAQ,KAAAC,CAAK,EAK9C,SAAS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AM,EACtB,SAAS,iBAAiB,UAAW,KAAK,SAAS,GAEnDZ,EAAA,KAAK,OAAO,cAA2B,eAAe,IAAtD,MAAAA,EAAyD,QAC3D,CAEQ,YAAY,CAAE,aAAAa,EAAe,EAAK,EAAI,CAAC,EAAG,CAtEpD,IAAAb,EAAAc,EAuES,KAAK,SAEV,SAAS,oBAAoB,UAAW,KAAK,SAAS,EACtD,KAAK,OAAO,OAAO,EACnB,KAAK,OAAS,KAEVD,KACFC,GAAAd,EAAA,KAAK,aAAL,YAAAA,EAAiB,cAA2B,iBAA5C,MAAAc,EAA4D,SAEhE,CAEA,mBAAoB,CAClB,GAAI,CAAC,KAAK,WAAY,CACpB,IAAMC,EAAO,KAAK,aAAa,CAAE,KAAM,MAAO,CAAC,EAC/CA,EAAK,UAAY,UAAUb,CAAM,kCACnC,CAEA,KAAK,OAAO,CACd,CAEA,sBAAuB,CACrB,KAAK,YAAY,CAAE,aAAc,EAAM,CAAC,CAC1C,CACF,EAUO,SAASc,GAAuB,CACjC,OAAO,gBAAmB,cAC1B,eAAe,IAAIjB,CAAQ,GAE/B,eAAe,OAAOA,EAAUQ,CAAmB,EACrD,CR3GAU,EAAqB","names":["cdn_exports","__export","TAG_NAME","VtexAdsStoryElement","defineVtexAdsStories","close_default","collapse_default","expand_default","play_fill_default","icons","close_default","collapse_default","expand_default","play_fill_default","createIcon","name","template","svg","cardStyles","isHttpUrl","value","protocol","e","createCard","story","options","card","poster","play","createIcon","event","playerStyles","createButton","className","label","icon","button","createIcon","supportsPopover","player","showPlayer","createPlayer","story","options","frame","controls","expand","close","expanded","hide","event","createCard","TAG_NAME","_a","BaseElement","styles","cardStyles","playerStyles","PLACEHOLDER_STORY","LABELS","VtexAdsStoryElement","event","container","createCard","createPlayer","showPlayer","restoreFocus","_b","root","defineVtexAdsStories","defineVtexAdsStories"]}
1
+ {"version":3,"sources":["../../src/cdn.ts","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg","raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg","../../src/components/icons/index.ts","../../src/components/card/card.ts","../../src/components/player/player.ts","../../src/story/story.ts"],"sourcesContent":["import { defineVtexAdsStories } from \"./story\";\n\ndefineVtexAdsStories();\n\nexport { VtexAdsStoryElement, defineVtexAdsStories, TAG_NAME } from \"./story\";\n","<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","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M152,96V48a8,8,0,0,1,16,0V88h40a8,8,0,0,1,0,16H160A8,8,0,0,1,152,96ZM96,152H48a8,8,0,0,0,0,16H88v40a8,8,0,0,0,16,0V160A8,8,0,0,0,96,152Zm112,0H160a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V168h40a8,8,0,0,0,0-16ZM96,40a8,8,0,0,0-8,8V88H48a8,8,0,0,0,0,16H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M245.66,146.34a8,8,0,0,1-11.32,11.32L216,139.31l-18.34,18.35a8,8,0,0,1-11.32-11.32L204.69,128l-18.35-18.34a8,8,0,0,1,11.32-11.32L216,116.69l18.34-18.35a8,8,0,0,1,11.32,11.32L227.31,128ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm97.15-54.15a8,8,0,0,0-10-.16l-65.57,51A4,4,0,0,0,80,79.84v96.32a4,4,0,0,0,1.55,3.15l65.57,51a8,8,0,0,0,9,.56,8.29,8.29,0,0,0,3.91-7.18V32.25A8.27,8.27,0,0,0,157.12,25.85Z\"/></svg>\n","<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z\"/></svg>\n","/*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */\n\n// SVG files as downloaded from Phosphor: regular weight, or the weight in the\n// file name. They are bundled as text: `?raw` is handled by Vite in dev and\n// tests, and by the raw plugin in tsup.config.ts.\nimport close from \"./assets/close.svg?raw\";\nimport collapse from \"./assets/collapse.svg?raw\";\nimport expand from \"./assets/expand.svg?raw\";\nimport pause from \"./assets/pause-fill.svg?raw\";\nimport play from \"./assets/play-fill.svg?raw\";\nimport soundOff from \"./assets/speaker-x-fill.svg?raw\";\nimport soundOn from \"./assets/speaker-high-fill.svg?raw\";\n\nexport const icons = {\n close,\n collapse,\n expand,\n pause,\n play,\n soundOff,\n soundOn,\n};\n\nexport type IconName = keyof typeof icons;\n\n/** Renders a bundled icon. It is decorative: name the control around it. */\nexport function createIcon(name: IconName) {\n const template = document.createElement(\"template\");\n template.innerHTML = icons[name];\n\n const svg = template.content.firstElementChild as SVGSVGElement;\n svg.classList.add(\"icon\");\n svg.setAttribute(\"aria-hidden\", \"true\");\n svg.setAttribute(\"focusable\", \"false\");\n return svg;\n}\n","import { createIcon } from \"../icons\";\nimport type { StoryMedia } from \"../../types\";\n\nexport const cardStyles = `\n .card {\n position: relative;\n box-sizing: border-box;\n width: calc(500px * 9 / 16);\n height: 500px;\n overflow: hidden;\n border-radius: var(--vtex-ads-story-radius, 20px);\n background: #000;\n }\n\n /* The card's button covers it. The focus ring goes on the card, since the\n card's overflow would clip the button's own. */\n .card-open {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n padding: 0;\n border: 0;\n background: transparent;\n cursor: pointer;\n }\n\n .card-open:focus-visible {\n outline: none;\n }\n\n .card:has(> .card-open:focus-visible) {\n outline: auto;\n }\n\n .poster,\n .video {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n object-fit: cover;\n }\n\n .play {\n position: absolute;\n top: 50%;\n left: 50%;\n display: grid;\n width: 66px;\n height: 66px;\n place-items: center;\n border-radius: 50%;\n background:\n linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),\n rgba(255, 255, 255, 0.15);\n backdrop-filter: blur(2px);\n box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);\n transform: translate(-50%, -50%);\n transition:\n opacity 0.3s ease,\n transform 0.3s ease;\n }\n\n /* The icon's triangle is 18px tall and already sits slightly right of its\n box, so it looks centered in the circle. */\n .play .icon {\n width: 22px;\n height: 22px;\n color: #fff;\n }\n\n /* Sound on/off, at the top right of the card (as in the prototype). */\n .card-sound {\n position: absolute;\n top: 22px;\n right: 12px;\n z-index: 1;\n display: grid;\n width: 28px;\n height: 28px;\n place-items: center;\n padding: 0;\n border: 0;\n background: transparent;\n color: #fff;\n cursor: pointer;\n filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));\n }\n\n .card-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* With a mouse, the play button shows only on hover or keyboard focus.\n Touch screens have no hover, so it stays visible there. */\n @media (hover: hover) and (pointer: fine) {\n .play {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.9);\n }\n\n .card:hover .play,\n .card-open:focus-visible .play {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n }\n`;\n\nexport interface CardOptions {\n /** Accessible name of the card. */\n label: string;\n /** Called on click, Enter or Space. */\n onSelect: () => void;\n /** Accessible names of the sound button, shown when the card has a video. */\n soundOnLabel: string;\n soundOffLabel: string;\n}\n\n// Only absolute http(s) URLs reach the DOM. Relative and protocol-relative\n// ones (\"/a.jpg\", \"//host/a.jpg\") don't parse without a base, so they're out.\nfunction httpUrl(value: string | undefined) {\n if (!value) return null;\n try {\n const { protocol } = new URL(value);\n return protocol === \"https:\" || protocol === \"http:\" ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction prefersReducedMotion() {\n return (\n globalThis.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches ?? false\n );\n}\n\n/**\n * Plays a video. A blocked play is ignored: the cover or the paused state\n * stays.\n */\nexport function playVideo(video: HTMLVideoElement) {\n video.play()?.catch(() => undefined);\n}\n\nfunction createVideo(src: string, poster: string | null) {\n const video = document.createElement(\"video\");\n video.className = \"video\";\n // Muted and inline is what browsers, iOS included, allow to autoplay.\n video.muted = true;\n video.setAttribute(\"muted\", \"\");\n video.setAttribute(\"playsinline\", \"\");\n video.loop = true;\n video.preload = \"metadata\";\n // No autoplay for people who asked for reduced motion.\n video.autoplay = !prefersReducedMotion();\n if (poster) video.poster = poster;\n video.src = src;\n\n // If the video can't load, the cover underneath stays.\n video.addEventListener(\"error\", () => video.remove());\n return video;\n}\n\n/** Sound on/off for the card's video, which starts muted. */\nfunction createSoundButton(video: HTMLVideoElement, options: CardOptions) {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"card-sound\";\n\n function sync() {\n button.setAttribute(\n \"aria-label\",\n video.muted ? options.soundOnLabel : options.soundOffLabel,\n );\n button.replaceChildren(createIcon(video.muted ? \"soundOff\" : \"soundOn\"));\n }\n\n video.addEventListener(\"volumechange\", sync);\n // Without the video, the cover stays and there is no sound to control.\n video.addEventListener(\"error\", () => button.remove());\n button.addEventListener(\"click\", () => {\n video.muted = !video.muted;\n });\n\n sync();\n return button;\n}\n\n/**\n * A 9:16 card with the Story cover and, with a media_url, the video looping\n * muted over it. With options, a button with a play icon in the middle covers\n * the card, and a card with a video gets a sound button. The sound button is\n * beside the card's button, not inside it: a button can't contain another.\n */\nexport function createCard(story: StoryMedia, options?: CardOptions) {\n const card = document.createElement(\"div\");\n card.className = \"card\";\n\n const posterUrl = httpUrl(story.poster_url);\n if (posterUrl) {\n const poster = document.createElement(\"img\");\n poster.className = \"poster\";\n poster.alt = \"\";\n poster.src = posterUrl;\n card.append(poster);\n }\n\n const mediaUrl = httpUrl(story.media_url);\n const video = mediaUrl ? createVideo(mediaUrl, posterUrl) : null;\n if (video) card.append(video);\n\n if (options) {\n const open = document.createElement(\"button\");\n open.type = \"button\";\n open.className = \"card-open\";\n open.setAttribute(\"aria-label\", options.label);\n\n const play = document.createElement(\"span\");\n play.className = \"play\";\n play.setAttribute(\"aria-hidden\", \"true\");\n play.append(createIcon(\"play\"));\n open.append(play);\n open.addEventListener(\"click\", options.onSelect);\n\n card.append(open);\n if (video) card.append(createSoundButton(video, options));\n }\n\n return card;\n}\n","import { createCard, playVideo } from \"../card\";\nimport { createIcon, type IconName } from \"../icons\";\nimport type { StoryMedia } from \"../../types\";\n\n// The player is a <dialog> shown in the top layer, so no store z-index,\n// overflow or transform can hide or move it.\n//\n// Mini: a manual popover (non-modal, the page stays usable), with the card at\n// the bottom right and the controls above it. Without popover support it is a\n// non-modal dialog, fixed with a high z-index.\n// Expanded: a modal dialog (showModal), so the browser makes the page behind\n// it inert. The card is centered over a dark backdrop, with the controls at\n// the top right of the screen. On narrow screens it fills the screen.\nexport const playerStyles = `\n .player {\n position: fixed;\n inset: auto 16px 16px auto;\n z-index: 2147483000;\n box-sizing: border-box;\n width: calc(min(587px, 100vh - 80px) * 9 / 16);\n height: min(587px, 100vh - 80px);\n margin: 0;\n padding: 0;\n overflow: visible;\n border: 0;\n background: transparent;\n color: inherit;\n font: inherit;\n animation: player-in 0.25s ease;\n }\n\n /* A <dialog> shown as a popover has no open attribute, which the browser\n hides by default. */\n .player:popover-open {\n display: block;\n }\n\n /* Switching modes shows the dialog again; only the first opening fades in. */\n .player[data-switched] {\n animation: none;\n }\n\n .player::backdrop {\n background: transparent;\n }\n\n .player-frame {\n position: relative;\n width: 100%;\n height: 100%;\n }\n\n .player .card {\n width: 100%;\n height: 100%;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);\n }\n\n .player .card:has(.video) {\n cursor: pointer;\n }\n\n /* Play/pause reuses the card's glass .play button, as a real button. */\n .player-toggle {\n padding: 0;\n border: 0;\n color: #fff;\n font: inherit;\n cursor: pointer;\n }\n\n .player[data-paused] .player-toggle,\n .player-toggle:focus-visible {\n opacity: 1;\n transform: translate(-50%, -50%);\n }\n\n /* On touch, tapping the video pauses it; the button shows while paused. */\n @media (hover: none) {\n .player:not([data-paused]) .player-toggle {\n opacity: 0;\n }\n }\n\n .player-sound {\n position: absolute;\n top: 12px;\n right: 12px;\n z-index: 1;\n border-color: transparent;\n background: rgba(0, 0, 0, 0.3);\n }\n\n .player-sound .icon {\n width: 20px;\n height: 20px;\n }\n\n /* Above the card: on narrow screens the expanded card can cover them. */\n .player-controls {\n position: absolute;\n right: 0;\n bottom: calc(100% + 8px);\n z-index: 1;\n display: flex;\n gap: 8px;\n }\n\n .player-button {\n display: grid;\n width: 36px;\n height: 36px;\n place-items: center;\n padding: 0;\n border: 1px solid rgba(133, 133, 133, 0.3);\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.32);\n backdrop-filter: blur(5px);\n color: #fff;\n cursor: pointer;\n transition: background-color 0.2s;\n }\n\n .player-button:hover {\n background: rgba(0, 0, 0, 0.55);\n }\n\n .player-button .icon {\n width: 18px;\n height: 18px;\n }\n\n .player[data-expanded] {\n inset: 0;\n display: grid;\n width: 100%;\n max-width: none;\n height: 100%;\n max-height: none;\n place-items: center;\n background: rgba(0, 0, 0, 0.85);\n animation: none;\n }\n\n .player[data-expanded] .player-frame {\n width: calc(min(78vh, 720px) * 9 / 16);\n height: min(78vh, 720px);\n }\n\n .player[data-expanded] .player-controls {\n position: fixed;\n top: 24px;\n right: 24px;\n bottom: auto;\n }\n\n .player[data-expanded] .player-button {\n width: 40px;\n height: 40px;\n }\n\n @media (max-width: 576px) {\n .player {\n right: 12px;\n width: 220px;\n height: 391px;\n }\n\n .player[data-expanded] {\n background: #000;\n }\n\n /* The video stays 9:16 and centered; the rest of the screen is black. */\n .player[data-expanded] .player-frame {\n width: min(100vw, 100vh * 9 / 16);\n height: min(100vh, 100vw * 16 / 9);\n }\n\n .player[data-expanded] .card {\n border-radius: 0;\n }\n\n /* Below the sound button, at the top right of the video. Placed in the\n video frame, not the screen: the frame is centered, so on screens\n taller than 9:16 its top is below the screen's. */\n .player[data-expanded] .player-controls {\n position: absolute;\n top: 60px;\n right: 12px;\n }\n }\n\n @keyframes player-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .player {\n animation: none;\n }\n }\n`;\n\nexport interface PlayerOptions {\n /** Accessible name of the player. */\n label: string;\n /** Accessible names of the buttons. */\n expandLabel: string;\n collapseLabel: string;\n closeLabel: string;\n playLabel: string;\n pauseLabel: string;\n soundOnLabel: string;\n soundOffLabel: string;\n onClose: () => void;\n}\n\nfunction createButton(className: string, label: string, icon: IconName) {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = `player-button ${className}`;\n button.setAttribute(\"aria-label\", label);\n button.append(createIcon(icon));\n return button;\n}\n\nfunction supportsPopover(player: HTMLDialogElement) {\n return typeof player.showPopover === \"function\";\n}\n\n/** Shows the player as the mini player. It must already be in the page. */\nexport function showPlayer(player: HTMLDialogElement) {\n if (supportsPopover(player)) player.showPopover();\n else player.show();\n}\n\n/** Plays the player's video, if it has one. */\nexport function playPlayer(player: HTMLDialogElement) {\n const video = player.querySelector(\"video\");\n if (video) playVideo(video);\n}\n\n/**\n * Play/pause in the middle of the video and sound on/off at its top right.\n * Clicking the video also plays or pauses it. The buttons follow the video's\n * own events, so a blocked autoplay shows as paused.\n */\nfunction addVideoControls(\n player: HTMLDialogElement,\n card: HTMLElement,\n video: HTMLVideoElement,\n options: PlayerOptions,\n) {\n // Not a .player-button: it keeps the card's larger glass look.\n const toggle = document.createElement(\"button\");\n toggle.type = \"button\";\n toggle.className = \"play player-toggle\";\n const sound = createButton(\"player-sound\", \"\", \"soundOff\");\n\n function syncPlayback() {\n player.toggleAttribute(\"data-paused\", video.paused);\n toggle.setAttribute(\n \"aria-label\",\n video.paused ? options.playLabel : options.pauseLabel,\n );\n toggle.replaceChildren(createIcon(video.paused ? \"play\" : \"pause\"));\n }\n\n function syncSound() {\n sound.setAttribute(\n \"aria-label\",\n video.muted ? options.soundOnLabel : options.soundOffLabel,\n );\n sound.replaceChildren(createIcon(video.muted ? \"soundOff\" : \"soundOn\"));\n }\n\n function togglePlayback() {\n if (video.paused) playVideo(video);\n else video.pause();\n }\n\n video.addEventListener(\"play\", syncPlayback);\n video.addEventListener(\"pause\", syncPlayback);\n video.addEventListener(\"volumechange\", syncSound);\n // Without the video, the cover stays and there is nothing to control.\n video.addEventListener(\"error\", () => {\n toggle.remove();\n sound.remove();\n delete player.dataset.paused;\n });\n\n toggle.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n togglePlayback();\n });\n sound.addEventListener(\"click\", (event) => {\n event.stopPropagation();\n video.muted = !video.muted;\n });\n card.addEventListener(\"click\", () => {\n if (video.isConnected) togglePlayback();\n });\n\n syncPlayback();\n syncSound();\n card.append(toggle, sound);\n}\n\n/**\n * The Story player. It opens as the mini player (see showPlayer); expand\n * switches to the expanded view, a modal dialog, and back. Clicking the\n * backdrop of the expanded view or pressing Escape in it closes the player.\n * The video starts muted (see playPlayer).\n */\nexport function createPlayer(story: StoryMedia, options: PlayerOptions) {\n const player = document.createElement(\"dialog\");\n player.className = \"player\";\n player.setAttribute(\"popover\", \"manual\");\n player.setAttribute(\"aria-label\", options.label);\n\n const frame = document.createElement(\"div\");\n frame.className = \"player-frame\";\n\n const controls = document.createElement(\"div\");\n controls.className = \"player-controls\";\n\n const expand = createButton(\"player-expand\", options.expandLabel, \"expand\");\n const close = createButton(\"player-close\", options.closeLabel, \"close\");\n controls.append(expand, close);\n\n let expanded = false;\n\n // A dialog can't be shown as a popover and as a modal at the same time, so\n // switching modes hides it first, the same way it was shown.\n function hide() {\n if (!expanded && supportsPopover(player)) player.hidePopover();\n else player.close();\n }\n\n expand.addEventListener(\"click\", () => {\n hide();\n expanded = !expanded;\n player.toggleAttribute(\"data-expanded\", expanded);\n player.dataset.switched = \"\";\n expand.setAttribute(\n \"aria-label\",\n expanded ? options.collapseLabel : options.expandLabel,\n );\n expand.replaceChildren(createIcon(expanded ? \"collapse\" : \"expand\"));\n\n if (expanded) player.showModal();\n else showPlayer(player);\n expand.focus();\n });\n\n close.addEventListener(\"click\", options.onClose);\n\n // Clicks on the backdrop of the expanded view reach the dialog itself.\n player.addEventListener(\"click\", (event) => {\n if (expanded && event.target === player) options.onClose();\n });\n\n // Escape on a modal dialog would only hide it: close the player instead.\n player.addEventListener(\"cancel\", (event) => {\n event.preventDefault();\n options.onClose();\n });\n\n const card = createCard(story);\n const video = card.querySelector(\"video\");\n if (video) addVideoControls(player, card, video, options);\n\n frame.append(controls, card);\n player.append(frame);\n return player;\n}\n","import { cardStyles, createCard, playVideo } from \"../components/card\";\nimport {\n createPlayer,\n playerStyles,\n playPlayer,\n showPlayer,\n} from \"../components/player\";\nimport type { StoryMedia } from \"../types\";\n\nexport const TAG_NAME = \"vtex-ads-story\";\n\n// Keeps the module importable where HTMLElement doesn't exist (SSR, Node).\nconst BaseElement: typeof HTMLElement = globalThis.HTMLElement ?? Object;\n\nconst styles = `\n :host {\n display: block;\n font-family: var(--vtex-ads-story-font-family, inherit);\n color: var(--vtex-ads-story-color-text, inherit);\n }\n ${cardStyles}\n ${playerStyles}\n`;\n\n// Temporary: rendered until the element reads Stories from the ad API.\nconst PLACEHOLDER_STORY: StoryMedia = {\n poster_url: \"https://dummyimage.com/1080x1920/e31c57/fff\",\n media_url: \"https://samplelib.com/mp4/sample-10s-vp9.mp4\",\n};\n\n// Temporary: fixed texts until the store can set them by attribute.\nconst LABELS = {\n watch: \"Assistir vídeo\",\n player: \"Vídeo\",\n expand: \"Expandir vídeo\",\n collapse: \"Reduzir vídeo\",\n close: \"Fechar vídeo\",\n play: \"Reproduzir vídeo\",\n pause: \"Pausar vídeo\",\n soundOn: \"Ativar som\",\n soundOff: \"Desativar som\",\n};\n\nexport class VtexAdsStoryElement extends BaseElement {\n private player: HTMLDialogElement | null = null;\n\n private readonly onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") this.closePlayer();\n };\n\n private render() {\n const container = this.shadowRoot?.querySelector(\".root\");\n if (!container) return;\n\n container.replaceChildren(\n createCard(PLACEHOLDER_STORY, {\n label: LABELS.watch,\n soundOnLabel: LABELS.soundOn,\n soundOffLabel: LABELS.soundOff,\n onSelect: () => this.openPlayer(),\n }),\n );\n }\n\n private cardVideo() {\n return this.shadowRoot?.querySelector<HTMLVideoElement>(\n \".root .card video\",\n );\n }\n\n private openPlayer() {\n if (this.player || !this.shadowRoot) return;\n\n this.player = createPlayer(PLACEHOLDER_STORY, {\n label: LABELS.player,\n expandLabel: LABELS.expand,\n collapseLabel: LABELS.collapse,\n closeLabel: LABELS.close,\n playLabel: LABELS.play,\n pauseLabel: LABELS.pause,\n soundOnLabel: LABELS.soundOn,\n soundOffLabel: LABELS.soundOff,\n onClose: () => this.closePlayer(),\n });\n this.shadowRoot.append(this.player);\n showPlayer(this.player);\n // While the player is open, the card behind it stops on its cover.\n this.cardVideo()?.pause();\n playPlayer(this.player);\n document.addEventListener(\"keydown\", this.onKeyDown);\n\n this.player.querySelector<HTMLElement>(\".player-close\")?.focus();\n }\n\n // `removed`: the element is leaving the page, so there is no card to give\n // focus back to or to resume playing (it would play out of sight).\n private closePlayer({ removed = false } = {}) {\n if (!this.player) return;\n\n document.removeEventListener(\"keydown\", this.onKeyDown);\n this.player.remove();\n this.player = null;\n if (removed) return;\n\n const video = this.cardVideo();\n if (video?.autoplay) playVideo(video);\n\n this.shadowRoot?.querySelector<HTMLElement>(\".root .card-open\")?.focus();\n }\n\n connectedCallback() {\n if (!this.shadowRoot) {\n const root = this.attachShadow({ mode: \"open\" });\n root.innerHTML = `<style>${styles}</style><div class=\"root\"></div>`;\n }\n\n this.render();\n }\n\n disconnectedCallback() {\n this.closePlayer({ removed: true });\n }\n}\n\n// Types `document.createElement(\"vtex-ads-story\")` and `querySelector` results\n// as VtexAdsStoryElement in any TypeScript project, no framework needed.\ndeclare global {\n interface HTMLElementTagNameMap {\n \"vtex-ads-story\": VtexAdsStoryElement;\n }\n}\n\nexport function defineVtexAdsStories() {\n if (typeof customElements === \"undefined\") return;\n if (customElements.get(TAG_NAME)) return;\n\n customElements.define(TAG_NAME, VtexAdsStoryElement);\n}\n"],"mappings":"kcAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,cAAAE,EAAA,wBAAAC,EAAA,yBAAAC,ICAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECAA,IAAAC,EAAA;ECaO,IAAMC,EAAQ,CACnB,MAAAC,EACA,SAAAC,EACA,OAAAC,EACA,MAAAC,EACA,KAAAC,EACA,SAAAC,EACA,QAAAC,CACF,EAKO,SAASC,EAAWC,EAAgB,CACzC,IAAMC,EAAW,SAAS,cAAc,UAAU,EAClDA,EAAS,UAAYV,EAAMS,CAAI,EAE/B,IAAME,EAAMD,EAAS,QAAQ,kBAC7B,OAAAC,EAAI,UAAU,IAAI,MAAM,EACxBA,EAAI,aAAa,cAAe,MAAM,EACtCA,EAAI,aAAa,YAAa,OAAO,EAC9BA,CACT,CChCO,IAAMC,EAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,EAAK,UAAY,UAAUhB,EAAM,kCACnC,CAEA,KAAK,OAAO,CACd,CAEA,sBAAuB,CACrB,KAAK,YAAY,CAAE,QAAS,EAAK,CAAC,CACpC,CACF,EAUO,SAASiB,GAAuB,CACjC,OAAO,gBAAmB,cAC1B,eAAe,IAAIpB,CAAQ,GAE/B,eAAe,OAAOA,EAAUQ,CAAmB,EACrD,CXvIAa,EAAqB","names":["cdn_exports","__export","TAG_NAME","VtexAdsStoryElement","defineVtexAdsStories","close_default","collapse_default","expand_default","pause_fill_default","play_fill_default","speaker_x_fill_default","speaker_high_fill_default","icons","close_default","collapse_default","expand_default","pause_fill_default","play_fill_default","speaker_x_fill_default","speaker_high_fill_default","createIcon","name","template","svg","cardStyles","httpUrl","value","protocol","e","prefersReducedMotion","_a","_b","playVideo","video","createVideo","src","poster","createSoundButton","options","button","sync","createIcon","createCard","story","card","posterUrl","mediaUrl","open","play","playerStyles","createButton","className","label","icon","button","createIcon","supportsPopover","player","showPlayer","playPlayer","video","playVideo","addVideoControls","card","options","toggle","sound","syncPlayback","syncSound","togglePlayback","event","createPlayer","story","frame","controls","expand","close","expanded","hide","createCard","TAG_NAME","_a","BaseElement","styles","cardStyles","playerStyles","PLACEHOLDER_STORY","LABELS","VtexAdsStoryElement","event","container","createCard","_b","createPlayer","showPlayer","playPlayer","removed","video","playVideo","root","defineVtexAdsStories","defineVtexAdsStories"]}