@vtex/ads-stories 0.4.1 → 0.7.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 +87 -0
- package/README.md +44 -88
- package/dist/cdn/vtex-ads-stories.js +1313 -74
- package/dist/cdn/vtex-ads-stories.js.map +1 -1
- package/dist/cjs/index.cjs +3744 -513
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +46 -15
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/cjs/react.d.cts +51 -5
- package/dist/cjs/story-DAiAN9v-.d.cts +260 -0
- package/dist/esm/index.d.ts +46 -15
- package/dist/esm/index.js +3348 -217
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.d.ts +51 -5
- package/dist/esm/story-DAiAN9v-.d.ts +260 -0
- package/package.json +18 -4
- package/src/cdn.ts +7 -3
- package/src/commerce-events.ts +93 -0
- package/src/components/card/card.ts +79 -14
- package/src/components/carousel/carousel-skeleton.ts +113 -0
- package/src/components/carousel/carousel.ts +715 -0
- package/src/components/carousel/index.ts +22 -0
- package/src/components/events/events-controller.ts +222 -0
- package/src/components/events/index.ts +6 -0
- package/src/components/icons/assets/caret-left-bold.svg +1 -0
- package/src/components/icons/assets/caret-right-bold.svg +1 -0
- package/src/components/icons/assets/caret-up-bold.svg +1 -0
- package/src/components/icons/assets/minus.svg +1 -0
- package/src/components/icons/assets/plus.svg +1 -0
- package/src/components/icons/assets/trash.svg +1 -0
- package/src/components/icons/assets/warning-circle-fill.svg +1 -0
- package/src/components/icons/index.ts +14 -0
- package/src/components/media/index.ts +8 -1
- package/src/components/media/media.styles.ts +113 -0
- package/src/components/media/media.ts +124 -23
- package/src/components/media/video-controller.ts +127 -6
- package/src/components/player/index.ts +6 -2
- package/src/components/player/player.ts +824 -50
- package/src/components/product/cta.ts +56 -0
- package/src/components/product/index.ts +22 -0
- package/src/components/product/price.ts +86 -0
- package/src/components/product/product.styles.ts +426 -0
- package/src/components/product/product.ts +336 -0
- package/src/index.ts +17 -1
- package/src/locales/en.ts +39 -0
- package/src/locales/es.ts +40 -0
- package/src/locales/index.ts +36 -0
- package/src/locales/pt.ts +39 -0
- package/src/locales/types.ts +44 -0
- package/src/react.ts +55 -7
- package/src/story/index.ts +5 -1
- package/src/story/story.ts +679 -49
- package/src/tag-name.ts +1 -0
- package/src/types.ts +8 -12
- package/src/utils/fetch-story.ts +113 -0
- package/src/utils/hydrate-products.ts +112 -0
- package/src/utils/media-ready.ts +58 -0
- package/src/utils/safe-url.ts +36 -0
- package/src/utils/send-event.ts +71 -0
- package/src/utils/with-timeout.ts +43 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -20,9 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ADD_TO_CART_EVENT: () => ADD_TO_CART_EVENT,
|
|
24
|
+
REMOVE_FROM_CART_EVENT: () => REMOVE_FROM_CART_EVENT,
|
|
23
25
|
TAG_NAME: () => TAG_NAME,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
VtexAdsStoryCarouselElement: () => VtexAdsStoryCarouselElement,
|
|
27
|
+
defineVtexAdsStoryCarousel: () => defineVtexAdsStoryCarousel
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(index_exports);
|
|
28
30
|
|
|
@@ -244,7 +246,7 @@ Object.defineProperties(EventShim.prototype, {
|
|
|
244
246
|
stopPropagation: enumerableProperty,
|
|
245
247
|
isTrusted: enumerableProperty
|
|
246
248
|
});
|
|
247
|
-
var CustomEventShim = (_b = class
|
|
249
|
+
var CustomEventShim = (_b = class CustomEvent2 extends EventShim {
|
|
248
250
|
constructor(type, options = {}) {
|
|
249
251
|
var _a13;
|
|
250
252
|
super(type, options);
|
|
@@ -604,7 +606,7 @@ var ElementShim = class Element extends NodeShim {
|
|
|
604
606
|
return value != null ? value : null;
|
|
605
607
|
}
|
|
606
608
|
};
|
|
607
|
-
var HTMLElementShim = class
|
|
609
|
+
var HTMLElementShim = class HTMLElement2 extends ElementShim {
|
|
608
610
|
};
|
|
609
611
|
var HTMLElementShimWithRealType = HTMLElementShim;
|
|
610
612
|
var ShadowRootShim = class ShadowRoot extends NodeShim {
|
|
@@ -709,16 +711,16 @@ var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "a
|
|
|
709
711
|
var s = Symbol();
|
|
710
712
|
var o = /* @__PURE__ */ new WeakMap();
|
|
711
713
|
var n = class {
|
|
712
|
-
constructor(t5, e6,
|
|
713
|
-
if (this._$cssResult$ = true,
|
|
714
|
+
constructor(t5, e6, o9) {
|
|
715
|
+
if (this._$cssResult$ = true, o9 !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
714
716
|
this.cssText = t5, this.t = e6;
|
|
715
717
|
}
|
|
716
718
|
get styleSheet() {
|
|
717
719
|
let t5 = this.o;
|
|
718
|
-
const
|
|
720
|
+
const s6 = this.t;
|
|
719
721
|
if (e && void 0 === t5) {
|
|
720
|
-
const e6 = void 0 !==
|
|
721
|
-
e6 && (t5 = o.get(
|
|
722
|
+
const e6 = void 0 !== s6 && 1 === s6.length;
|
|
723
|
+
e6 && (t5 = o.get(s6)), void 0 === t5 && ((this.o = t5 = new CSSStyleSheet()).replaceSync(this.cssText), e6 && o.set(s6, t5));
|
|
722
724
|
}
|
|
723
725
|
return t5;
|
|
724
726
|
}
|
|
@@ -728,23 +730,23 @@ var n = class {
|
|
|
728
730
|
};
|
|
729
731
|
var r = (t5) => new n("string" == typeof t5 ? t5 : t5 + "", void 0, s);
|
|
730
732
|
var i = (t5, ...e6) => {
|
|
731
|
-
const
|
|
733
|
+
const o9 = 1 === t5.length ? t5[0] : e6.reduce((e7, s6, o10) => e7 + ((t6) => {
|
|
732
734
|
if (true === t6._$cssResult$) return t6.cssText;
|
|
733
735
|
if ("number" == typeof t6) return t6;
|
|
734
736
|
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
|
-
})(
|
|
736
|
-
return new n(
|
|
737
|
+
})(s6) + t5[o10 + 1], t5[0]);
|
|
738
|
+
return new n(o9, t5, s);
|
|
737
739
|
};
|
|
738
|
-
var S = (
|
|
739
|
-
if (e)
|
|
740
|
-
else for (const e6 of
|
|
741
|
-
const
|
|
742
|
-
void 0 !==
|
|
740
|
+
var S = (s6, o9) => {
|
|
741
|
+
if (e) s6.adoptedStyleSheets = o9.map((t5) => t5 instanceof CSSStyleSheet ? t5 : t5.styleSheet);
|
|
742
|
+
else for (const e6 of o9) {
|
|
743
|
+
const o10 = document.createElement("style"), n7 = t.litNonce;
|
|
744
|
+
void 0 !== n7 && o10.setAttribute("nonce", n7), o10.textContent = e6.cssText, s6.appendChild(o10);
|
|
743
745
|
}
|
|
744
746
|
};
|
|
745
747
|
var c = e || void 0 === t.CSSStyleSheet ? (t5) => t5 : (t5) => t5 instanceof CSSStyleSheet ? ((t6) => {
|
|
746
748
|
let e6 = "";
|
|
747
|
-
for (const
|
|
749
|
+
for (const s6 of t6.cssRules) e6 += s6.cssText;
|
|
748
750
|
return r(e6);
|
|
749
751
|
})(t5) : t5;
|
|
750
752
|
|
|
@@ -756,9 +758,9 @@ var _a6;
|
|
|
756
758
|
var p = l.trustedTypes;
|
|
757
759
|
var d = p ? p.emptyScript : "";
|
|
758
760
|
var u = l.reactiveElementPolyfillSupport;
|
|
759
|
-
var f = (t5,
|
|
760
|
-
var b = { toAttribute(t5,
|
|
761
|
-
switch (
|
|
761
|
+
var f = (t5, s6) => t5;
|
|
762
|
+
var b = { toAttribute(t5, s6) {
|
|
763
|
+
switch (s6) {
|
|
762
764
|
case Boolean:
|
|
763
765
|
t5 = t5 ? d : null;
|
|
764
766
|
break;
|
|
@@ -767,26 +769,26 @@ var b = { toAttribute(t5, s5) {
|
|
|
767
769
|
t5 = null == t5 ? t5 : JSON.stringify(t5);
|
|
768
770
|
}
|
|
769
771
|
return t5;
|
|
770
|
-
}, fromAttribute(t5,
|
|
771
|
-
let
|
|
772
|
-
switch (
|
|
772
|
+
}, fromAttribute(t5, s6) {
|
|
773
|
+
let i7 = t5;
|
|
774
|
+
switch (s6) {
|
|
773
775
|
case Boolean:
|
|
774
|
-
|
|
776
|
+
i7 = null !== t5;
|
|
775
777
|
break;
|
|
776
778
|
case Number:
|
|
777
|
-
|
|
779
|
+
i7 = null === t5 ? null : Number(t5);
|
|
778
780
|
break;
|
|
779
781
|
case Object:
|
|
780
782
|
case Array:
|
|
781
783
|
try {
|
|
782
|
-
|
|
784
|
+
i7 = JSON.parse(t5);
|
|
783
785
|
} catch (t6) {
|
|
784
|
-
|
|
786
|
+
i7 = null;
|
|
785
787
|
}
|
|
786
788
|
}
|
|
787
|
-
return
|
|
789
|
+
return i7;
|
|
788
790
|
} };
|
|
789
|
-
var m = (t5,
|
|
791
|
+
var m = (t5, s6) => !h(t5, s6);
|
|
790
792
|
var y = { attribute: true, type: String, converter: b, reflect: false, useDefault: false, hasChanged: m };
|
|
791
793
|
var _a7, _b2;
|
|
792
794
|
(_a7 = Symbol.metadata) != null ? _a7 : Symbol.metadata = Symbol("metadata"), (_b2 = l.litPropertyMetadata) != null ? _b2 : l.litPropertyMetadata = /* @__PURE__ */ new WeakMap();
|
|
@@ -799,22 +801,22 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
799
801
|
static get observedAttributes() {
|
|
800
802
|
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
801
803
|
}
|
|
802
|
-
static createProperty(t5,
|
|
803
|
-
if (
|
|
804
|
-
const
|
|
804
|
+
static createProperty(t5, s6 = y) {
|
|
805
|
+
if (s6.state && (s6.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t5) && ((s6 = Object.create(s6)).wrapped = true), this.elementProperties.set(t5, s6), !s6.noAccessor) {
|
|
806
|
+
const i7 = Symbol(), e6 = this.getPropertyDescriptor(t5, i7, s6);
|
|
805
807
|
void 0 !== e6 && r2(this.prototype, t5, e6);
|
|
806
808
|
}
|
|
807
809
|
}
|
|
808
|
-
static getPropertyDescriptor(t5,
|
|
810
|
+
static getPropertyDescriptor(t5, s6, i7) {
|
|
809
811
|
var _a13;
|
|
810
|
-
const { get: e6, set:
|
|
811
|
-
return this[
|
|
812
|
+
const { get: e6, set: h6 } = (_a13 = o2(this.prototype, t5)) != null ? _a13 : { get() {
|
|
813
|
+
return this[s6];
|
|
812
814
|
}, set(t6) {
|
|
813
|
-
this[
|
|
815
|
+
this[s6] = t6;
|
|
814
816
|
} };
|
|
815
|
-
return { get: e6, set(
|
|
817
|
+
return { get: e6, set(s7) {
|
|
816
818
|
const r6 = e6 == null ? void 0 : e6.call(this);
|
|
817
|
-
|
|
819
|
+
h6 == null ? void 0 : h6.call(this, s7), this.requestUpdate(t5, r6, i7);
|
|
818
820
|
}, configurable: true, enumerable: true };
|
|
819
821
|
}
|
|
820
822
|
static getPropertyOptions(t5) {
|
|
@@ -829,32 +831,32 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
829
831
|
static finalize() {
|
|
830
832
|
if (this.hasOwnProperty(f("finalized"))) return;
|
|
831
833
|
if (this.finalized = true, this._$Ei(), this.hasOwnProperty(f("properties"))) {
|
|
832
|
-
const t6 = this.properties,
|
|
833
|
-
for (const
|
|
834
|
+
const t6 = this.properties, s6 = [...n2(t6), ...a(t6)];
|
|
835
|
+
for (const i7 of s6) this.createProperty(i7, t6[i7]);
|
|
834
836
|
}
|
|
835
837
|
const t5 = this[Symbol.metadata];
|
|
836
838
|
if (null !== t5) {
|
|
837
|
-
const
|
|
838
|
-
if (void 0 !==
|
|
839
|
+
const s6 = litPropertyMetadata.get(t5);
|
|
840
|
+
if (void 0 !== s6) for (const [t6, i7] of s6) this.elementProperties.set(t6, i7);
|
|
839
841
|
}
|
|
840
842
|
this._$Eh = /* @__PURE__ */ new Map();
|
|
841
|
-
for (const [t6,
|
|
842
|
-
const
|
|
843
|
-
void 0 !==
|
|
843
|
+
for (const [t6, s6] of this.elementProperties) {
|
|
844
|
+
const i7 = this._$Eu(t6, s6);
|
|
845
|
+
void 0 !== i7 && this._$Eh.set(i7, t6);
|
|
844
846
|
}
|
|
845
847
|
this.elementStyles = this.finalizeStyles(this.styles);
|
|
846
848
|
}
|
|
847
849
|
static finalizeStyles(t5) {
|
|
848
|
-
const
|
|
850
|
+
const s6 = [];
|
|
849
851
|
if (Array.isArray(t5)) {
|
|
850
852
|
const e6 = new Set(t5.flat(1 / 0).reverse());
|
|
851
|
-
for (const t6 of e6)
|
|
852
|
-
} else void 0 !== t5 &&
|
|
853
|
-
return
|
|
853
|
+
for (const t6 of e6) s6.unshift(c(t6));
|
|
854
|
+
} else void 0 !== t5 && s6.push(c(t5));
|
|
855
|
+
return s6;
|
|
854
856
|
}
|
|
855
|
-
static _$Eu(t5,
|
|
856
|
-
const
|
|
857
|
-
return false ===
|
|
857
|
+
static _$Eu(t5, s6) {
|
|
858
|
+
const i7 = s6.attribute;
|
|
859
|
+
return false === i7 ? void 0 : "string" == typeof i7 ? i7 : "string" == typeof t5 ? t5.toLowerCase() : void 0;
|
|
858
860
|
}
|
|
859
861
|
constructor() {
|
|
860
862
|
super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
|
|
@@ -872,8 +874,8 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
872
874
|
(_a13 = this._$EO) == null ? void 0 : _a13.delete(t5);
|
|
873
875
|
}
|
|
874
876
|
_$E_() {
|
|
875
|
-
const t5 = /* @__PURE__ */ new Map(),
|
|
876
|
-
for (const
|
|
877
|
+
const t5 = /* @__PURE__ */ new Map(), s6 = this.constructor.elementProperties;
|
|
878
|
+
for (const i7 of s6.keys()) this.hasOwnProperty(i7) && (t5.set(i7, this[i7]), delete this[i7]);
|
|
877
879
|
t5.size > 0 && (this._$Ep = t5);
|
|
878
880
|
}
|
|
879
881
|
createRenderRoot() {
|
|
@@ -897,39 +899,39 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
897
899
|
return (_a14 = t5.hostDisconnected) == null ? void 0 : _a14.call(t5);
|
|
898
900
|
});
|
|
899
901
|
}
|
|
900
|
-
attributeChangedCallback(t5,
|
|
901
|
-
this._$AK(t5,
|
|
902
|
+
attributeChangedCallback(t5, s6, i7) {
|
|
903
|
+
this._$AK(t5, i7);
|
|
902
904
|
}
|
|
903
|
-
_$ET(t5,
|
|
905
|
+
_$ET(t5, s6) {
|
|
904
906
|
var _a13;
|
|
905
|
-
const
|
|
906
|
-
if (void 0 !== e6 && true ===
|
|
907
|
-
const
|
|
908
|
-
this._$Em = t5, null ==
|
|
907
|
+
const i7 = this.constructor.elementProperties.get(t5), e6 = this.constructor._$Eu(t5, i7);
|
|
908
|
+
if (void 0 !== e6 && true === i7.reflect) {
|
|
909
|
+
const h6 = (void 0 !== ((_a13 = i7.converter) == null ? void 0 : _a13.toAttribute) ? i7.converter : b).toAttribute(s6, i7.type);
|
|
910
|
+
this._$Em = t5, null == h6 ? this.removeAttribute(e6) : this.setAttribute(e6, h6), this._$Em = null;
|
|
909
911
|
}
|
|
910
912
|
}
|
|
911
|
-
_$AK(t5,
|
|
913
|
+
_$AK(t5, s6) {
|
|
912
914
|
var _a13, _b3, _c;
|
|
913
|
-
const
|
|
915
|
+
const i7 = this.constructor, e6 = i7._$Eh.get(t5);
|
|
914
916
|
if (void 0 !== e6 && this._$Em !== e6) {
|
|
915
|
-
const t6 =
|
|
917
|
+
const t6 = i7.getPropertyOptions(e6), h6 = "function" == typeof t6.converter ? { fromAttribute: t6.converter } : void 0 !== ((_a13 = t6.converter) == null ? void 0 : _a13.fromAttribute) ? t6.converter : b;
|
|
916
918
|
this._$Em = e6;
|
|
917
|
-
const r6 =
|
|
919
|
+
const r6 = h6.fromAttribute(s6, t6.type);
|
|
918
920
|
this[e6] = (_c = r6 != null ? r6 : (_b3 = this._$Ej) == null ? void 0 : _b3.get(e6)) != null ? _c : r6, this._$Em = null;
|
|
919
921
|
}
|
|
920
922
|
}
|
|
921
|
-
requestUpdate(t5,
|
|
923
|
+
requestUpdate(t5, s6, i7, e6 = false, h6) {
|
|
922
924
|
var _a13, _b3;
|
|
923
925
|
if (void 0 !== t5) {
|
|
924
926
|
const r6 = this.constructor;
|
|
925
|
-
if (false === e6 && (
|
|
926
|
-
this.C(t5,
|
|
927
|
+
if (false === e6 && (h6 = this[t5]), i7 != null ? i7 : i7 = r6.getPropertyOptions(t5), !(((_a13 = i7.hasChanged) != null ? _a13 : m)(h6, s6) || i7.useDefault && i7.reflect && h6 === ((_b3 = this._$Ej) == null ? void 0 : _b3.get(t5)) && !this.hasAttribute(r6._$Eu(t5, i7)))) return;
|
|
928
|
+
this.C(t5, s6, i7);
|
|
927
929
|
}
|
|
928
930
|
false === this.isUpdatePending && (this._$ES = this._$EP());
|
|
929
931
|
}
|
|
930
|
-
C(t5,
|
|
932
|
+
C(t5, s6, { useDefault: i7, reflect: e6, wrapped: h6 }, r6) {
|
|
931
933
|
var _a13, _b3, _c;
|
|
932
|
-
|
|
934
|
+
i7 && !((_a13 = this._$Ej) != null ? _a13 : this._$Ej = /* @__PURE__ */ new Map()).has(t5) && (this._$Ej.set(t5, (_b3 = r6 != null ? r6 : s6) != null ? _b3 : this[t5]), true !== h6 || void 0 !== r6) || (this._$AL.has(t5) || (this.hasUpdated || i7 || (s6 = void 0), this._$AL.set(t5, s6)), true === e6 && this._$Em !== t5 && ((_c = this._$Eq) != null ? _c : this._$Eq = /* @__PURE__ */ new Set()).add(t5));
|
|
933
935
|
}
|
|
934
936
|
async _$EP() {
|
|
935
937
|
this.isUpdatePending = true;
|
|
@@ -949,26 +951,26 @@ var g = class extends ((_a8 = globalThis.HTMLElement) != null ? _a8 : HTMLElemen
|
|
|
949
951
|
if (!this.isUpdatePending) return;
|
|
950
952
|
if (!this.hasUpdated) {
|
|
951
953
|
if ((_a13 = this.renderRoot) != null ? _a13 : this.renderRoot = this.createRenderRoot(), this._$Ep) {
|
|
952
|
-
for (const [t7,
|
|
954
|
+
for (const [t7, s7] of this._$Ep) this[t7] = s7;
|
|
953
955
|
this._$Ep = void 0;
|
|
954
956
|
}
|
|
955
957
|
const t6 = this.constructor.elementProperties;
|
|
956
|
-
if (t6.size > 0) for (const [
|
|
957
|
-
const { wrapped: t7 } =
|
|
958
|
-
true !== t7 || this._$AL.has(
|
|
958
|
+
if (t6.size > 0) for (const [s7, i7] of t6) {
|
|
959
|
+
const { wrapped: t7 } = i7, e6 = this[s7];
|
|
960
|
+
true !== t7 || this._$AL.has(s7) || void 0 === e6 || this.C(s7, void 0, i7, e6);
|
|
959
961
|
}
|
|
960
962
|
}
|
|
961
963
|
let t5 = false;
|
|
962
|
-
const
|
|
964
|
+
const s6 = this._$AL;
|
|
963
965
|
try {
|
|
964
|
-
t5 = this.shouldUpdate(
|
|
966
|
+
t5 = this.shouldUpdate(s6), t5 ? (this.willUpdate(s6), (_b3 = this._$EO) == null ? void 0 : _b3.forEach((t6) => {
|
|
965
967
|
var _a14;
|
|
966
968
|
return (_a14 = t6.hostUpdate) == null ? void 0 : _a14.call(t6);
|
|
967
|
-
}), this.update(
|
|
968
|
-
} catch (
|
|
969
|
-
throw t5 = false, this._$EM(),
|
|
969
|
+
}), this.update(s6)) : this._$EM();
|
|
970
|
+
} catch (s7) {
|
|
971
|
+
throw t5 = false, this._$EM(), s7;
|
|
970
972
|
}
|
|
971
|
-
t5 && this._$AE(
|
|
973
|
+
t5 && this._$AE(s6);
|
|
972
974
|
}
|
|
973
975
|
willUpdate(t5) {
|
|
974
976
|
}
|
|
@@ -1025,7 +1027,7 @@ var p2 = RegExp(`>|${f2}(?:([^\\s"'>=/]+)(${f2}*=${f2}*(?:[^
|
|
|
1025
1027
|
var g2 = /'/g;
|
|
1026
1028
|
var $ = /"/g;
|
|
1027
1029
|
var y2 = /^(?:script|style|textarea|title)$/i;
|
|
1028
|
-
var x = (t5) => (
|
|
1030
|
+
var x = (t5) => (i7, ...s6) => ({ _$litType$: t5, strings: i7, values: s6 });
|
|
1029
1031
|
var T = x(1);
|
|
1030
1032
|
var b2 = x(2);
|
|
1031
1033
|
var w = x(3);
|
|
@@ -1033,44 +1035,44 @@ var E = Symbol.for("lit-noChange");
|
|
|
1033
1035
|
var A = Symbol.for("lit-nothing");
|
|
1034
1036
|
var C = /* @__PURE__ */ new WeakMap();
|
|
1035
1037
|
var P = l2.createTreeWalker(l2, 129);
|
|
1036
|
-
function V(t5,
|
|
1038
|
+
function V(t5, i7) {
|
|
1037
1039
|
if (!u2(t5) || !t5.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
1038
|
-
return void 0 !== e2 ? e2.createHTML(
|
|
1040
|
+
return void 0 !== e2 ? e2.createHTML(i7) : i7;
|
|
1039
1041
|
}
|
|
1040
|
-
var N = (t5,
|
|
1041
|
-
const
|
|
1042
|
-
let
|
|
1043
|
-
for (let
|
|
1044
|
-
const
|
|
1045
|
-
let a3,
|
|
1046
|
-
for (; f4 <
|
|
1047
|
-
const x2 =
|
|
1048
|
-
l3 +=
|
|
1049
|
-
}
|
|
1050
|
-
return [V(t5, l3 + (t5[
|
|
1042
|
+
var N = (t5, i7) => {
|
|
1043
|
+
const s6 = t5.length - 1, e6 = [];
|
|
1044
|
+
let n7, l3 = 2 === i7 ? "<svg>" : 3 === i7 ? "<math>" : "", c6 = v;
|
|
1045
|
+
for (let i8 = 0; i8 < s6; i8++) {
|
|
1046
|
+
const s7 = t5[i8];
|
|
1047
|
+
let a3, u5, d3 = -1, f4 = 0;
|
|
1048
|
+
for (; f4 < s7.length && (c6.lastIndex = f4, u5 = c6.exec(s7), null !== u5); ) f4 = c6.lastIndex, c6 === v ? "!--" === u5[1] ? c6 = _ : void 0 !== u5[1] ? c6 = m2 : void 0 !== u5[2] ? (y2.test(u5[2]) && (n7 = RegExp("</" + u5[2], "g")), c6 = p2) : void 0 !== u5[3] && (c6 = p2) : c6 === p2 ? ">" === u5[0] ? (c6 = n7 != null ? n7 : v, d3 = -1) : void 0 === u5[1] ? d3 = -2 : (d3 = c6.lastIndex - u5[2].length, a3 = u5[1], c6 = void 0 === u5[3] ? p2 : '"' === u5[3] ? $ : g2) : c6 === $ || c6 === g2 ? c6 = p2 : c6 === _ || c6 === m2 ? c6 = v : (c6 = p2, n7 = void 0);
|
|
1049
|
+
const x2 = c6 === p2 && t5[i8 + 1].startsWith("/>") ? " " : "";
|
|
1050
|
+
l3 += c6 === v ? s7 + r3 : d3 >= 0 ? (e6.push(a3), s7.slice(0, d3) + h2 + s7.slice(d3) + o3 + x2) : s7 + o3 + (-2 === d3 ? i8 : x2);
|
|
1051
|
+
}
|
|
1052
|
+
return [V(t5, l3 + (t5[s6] || "<?>") + (2 === i7 ? "</svg>" : 3 === i7 ? "</math>" : "")), e6];
|
|
1051
1053
|
};
|
|
1052
1054
|
var S2 = class _S {
|
|
1053
|
-
constructor({ strings: t5, _$litType$:
|
|
1055
|
+
constructor({ strings: t5, _$litType$: i7 }, e6) {
|
|
1054
1056
|
let r6;
|
|
1055
1057
|
this.parts = [];
|
|
1056
1058
|
let l3 = 0, a3 = 0;
|
|
1057
|
-
const
|
|
1058
|
-
if (this.el = _S.createElement(f4, e6), P.currentNode = this.el.content, 2 ===
|
|
1059
|
+
const u5 = t5.length - 1, d3 = this.parts, [f4, v3] = N(t5, i7);
|
|
1060
|
+
if (this.el = _S.createElement(f4, e6), P.currentNode = this.el.content, 2 === i7 || 3 === i7) {
|
|
1059
1061
|
const t6 = this.el.content.firstChild;
|
|
1060
1062
|
t6.replaceWith(...t6.childNodes);
|
|
1061
1063
|
}
|
|
1062
|
-
for (; null !== (r6 = P.nextNode()) && d3.length <
|
|
1064
|
+
for (; null !== (r6 = P.nextNode()) && d3.length < u5; ) {
|
|
1063
1065
|
if (1 === r6.nodeType) {
|
|
1064
1066
|
if (r6.hasAttributes()) for (const t6 of r6.getAttributeNames()) if (t6.endsWith(h2)) {
|
|
1065
|
-
const
|
|
1066
|
-
d3.push({ type: 1, index: l3, name: e7[2], strings:
|
|
1067
|
+
const i8 = v3[a3++], s6 = r6.getAttribute(t6).split(o3), e7 = /([.?@])?(.*)/.exec(i8);
|
|
1068
|
+
d3.push({ type: 1, index: l3, name: e7[2], strings: s6, ctor: "." === e7[1] ? I : "?" === e7[1] ? L : "@" === e7[1] ? z : H }), r6.removeAttribute(t6);
|
|
1067
1069
|
} else t6.startsWith(o3) && (d3.push({ type: 6, index: l3 }), r6.removeAttribute(t6));
|
|
1068
1070
|
if (y2.test(r6.tagName)) {
|
|
1069
|
-
const t6 = r6.textContent.split(o3),
|
|
1070
|
-
if (
|
|
1071
|
+
const t6 = r6.textContent.split(o3), i8 = t6.length - 1;
|
|
1072
|
+
if (i8 > 0) {
|
|
1071
1073
|
r6.textContent = s2 ? s2.emptyScript : "";
|
|
1072
|
-
for (let
|
|
1073
|
-
r6.append(t6[
|
|
1074
|
+
for (let s6 = 0; s6 < i8; s6++) r6.append(t6[s6], c3()), P.nextNode(), d3.push({ type: 2, index: ++l3 });
|
|
1075
|
+
r6.append(t6[i8], c3());
|
|
1074
1076
|
}
|
|
1075
1077
|
}
|
|
1076
1078
|
} else if (8 === r6.nodeType) if (r6.data === n3) d3.push({ type: 2, index: l3 });
|
|
@@ -1081,21 +1083,21 @@ var S2 = class _S {
|
|
|
1081
1083
|
l3++;
|
|
1082
1084
|
}
|
|
1083
1085
|
}
|
|
1084
|
-
static createElement(t5,
|
|
1085
|
-
const
|
|
1086
|
-
return
|
|
1086
|
+
static createElement(t5, i7) {
|
|
1087
|
+
const s6 = l2.createElement("template");
|
|
1088
|
+
return s6.innerHTML = t5, s6;
|
|
1087
1089
|
}
|
|
1088
1090
|
};
|
|
1089
|
-
function M(t5,
|
|
1091
|
+
function M(t5, i7, s6 = t5, e6) {
|
|
1090
1092
|
var _a13, _b3, _c;
|
|
1091
|
-
if (
|
|
1092
|
-
let
|
|
1093
|
-
const
|
|
1094
|
-
return (
|
|
1093
|
+
if (i7 === E) return i7;
|
|
1094
|
+
let h6 = void 0 !== e6 ? (_a13 = s6._$Co) == null ? void 0 : _a13[e6] : s6._$Cl;
|
|
1095
|
+
const o9 = a2(i7) ? void 0 : i7._$litDirective$;
|
|
1096
|
+
return (h6 == null ? void 0 : h6.constructor) !== o9 && ((_b3 = h6 == null ? void 0 : h6._$AO) == null ? void 0 : _b3.call(h6, false), void 0 === o9 ? h6 = void 0 : (h6 = new o9(t5), h6._$AT(t5, s6, e6)), void 0 !== e6 ? ((_c = s6._$Co) != null ? _c : s6._$Co = [])[e6] = h6 : s6._$Cl = h6), void 0 !== h6 && (i7 = M(t5, h6._$AS(t5, i7.values), h6, e6)), i7;
|
|
1095
1097
|
}
|
|
1096
1098
|
var k = class {
|
|
1097
|
-
constructor(t5,
|
|
1098
|
-
this._$AV = [], this._$AN = void 0, this._$AD = t5, this._$AM =
|
|
1099
|
+
constructor(t5, i7) {
|
|
1100
|
+
this._$AV = [], this._$AN = void 0, this._$AD = t5, this._$AM = i7;
|
|
1099
1101
|
}
|
|
1100
1102
|
get parentNode() {
|
|
1101
1103
|
return this._$AM.parentNode;
|
|
@@ -1105,21 +1107,21 @@ var k = class {
|
|
|
1105
1107
|
}
|
|
1106
1108
|
u(t5) {
|
|
1107
1109
|
var _a13;
|
|
1108
|
-
const { el: { content:
|
|
1110
|
+
const { el: { content: i7 }, parts: s6 } = this._$AD, e6 = ((_a13 = t5 == null ? void 0 : t5.creationScope) != null ? _a13 : l2).importNode(i7, true);
|
|
1109
1111
|
P.currentNode = e6;
|
|
1110
|
-
let
|
|
1112
|
+
let h6 = P.nextNode(), o9 = 0, n7 = 0, r6 = s6[0];
|
|
1111
1113
|
for (; void 0 !== r6; ) {
|
|
1112
|
-
if (
|
|
1113
|
-
let
|
|
1114
|
-
2 === r6.type ?
|
|
1114
|
+
if (o9 === r6.index) {
|
|
1115
|
+
let i8;
|
|
1116
|
+
2 === r6.type ? i8 = new R(h6, h6.nextSibling, this, t5) : 1 === r6.type ? i8 = new r6.ctor(h6, r6.name, r6.strings, this, t5) : 6 === r6.type && (i8 = new W(h6, this, t5)), this._$AV.push(i8), r6 = s6[++n7];
|
|
1115
1117
|
}
|
|
1116
|
-
|
|
1118
|
+
o9 !== (r6 == null ? void 0 : r6.index) && (h6 = P.nextNode(), o9++);
|
|
1117
1119
|
}
|
|
1118
1120
|
return P.currentNode = l2, e6;
|
|
1119
1121
|
}
|
|
1120
1122
|
p(t5) {
|
|
1121
|
-
let
|
|
1122
|
-
for (const
|
|
1123
|
+
let i7 = 0;
|
|
1124
|
+
for (const s6 of this._$AV) void 0 !== s6 && (void 0 !== s6.strings ? (s6._$AI(t5, s6, i7), i7 += s6.strings.length - 2) : s6._$AI(t5[i7])), i7++;
|
|
1123
1125
|
}
|
|
1124
1126
|
};
|
|
1125
1127
|
var R = class _R {
|
|
@@ -1127,14 +1129,14 @@ var R = class _R {
|
|
|
1127
1129
|
var _a13, _b3;
|
|
1128
1130
|
return (_b3 = (_a13 = this._$AM) == null ? void 0 : _a13._$AU) != null ? _b3 : this._$Cv;
|
|
1129
1131
|
}
|
|
1130
|
-
constructor(t5,
|
|
1132
|
+
constructor(t5, i7, s6, e6) {
|
|
1131
1133
|
var _a13;
|
|
1132
|
-
this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t5, this._$AB =
|
|
1134
|
+
this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t5, this._$AB = i7, this._$AM = s6, this.options = e6, this._$Cv = (_a13 = e6 == null ? void 0 : e6.isConnected) != null ? _a13 : true;
|
|
1133
1135
|
}
|
|
1134
1136
|
get parentNode() {
|
|
1135
1137
|
let t5 = this._$AA.parentNode;
|
|
1136
|
-
const
|
|
1137
|
-
return void 0 !==
|
|
1138
|
+
const i7 = this._$AM;
|
|
1139
|
+
return void 0 !== i7 && 11 === (t5 == null ? void 0 : t5.nodeType) && (t5 = i7.parentNode), t5;
|
|
1138
1140
|
}
|
|
1139
1141
|
get startNode() {
|
|
1140
1142
|
return this._$AA;
|
|
@@ -1142,8 +1144,8 @@ var R = class _R {
|
|
|
1142
1144
|
get endNode() {
|
|
1143
1145
|
return this._$AB;
|
|
1144
1146
|
}
|
|
1145
|
-
_$AI(t5,
|
|
1146
|
-
t5 = M(this, t5,
|
|
1147
|
+
_$AI(t5, i7 = this) {
|
|
1148
|
+
t5 = M(this, t5, i7), 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
1149
|
}
|
|
1148
1150
|
O(t5) {
|
|
1149
1151
|
return this._$AA.parentNode.insertBefore(t5, this._$AB);
|
|
@@ -1156,29 +1158,29 @@ var R = class _R {
|
|
|
1156
1158
|
}
|
|
1157
1159
|
$(t5) {
|
|
1158
1160
|
var _a13;
|
|
1159
|
-
const { values:
|
|
1160
|
-
if (((_a13 = this._$AH) == null ? void 0 : _a13._$AD) === e6) this._$AH.p(
|
|
1161
|
+
const { values: i7, _$litType$: s6 } = t5, e6 = "number" == typeof s6 ? this._$AC(t5) : (void 0 === s6.el && (s6.el = S2.createElement(V(s6.h, s6.h[0]), this.options)), s6);
|
|
1162
|
+
if (((_a13 = this._$AH) == null ? void 0 : _a13._$AD) === e6) this._$AH.p(i7);
|
|
1161
1163
|
else {
|
|
1162
|
-
const t6 = new k(e6, this),
|
|
1163
|
-
t6.p(
|
|
1164
|
+
const t6 = new k(e6, this), s7 = t6.u(this.options);
|
|
1165
|
+
t6.p(i7), this.T(s7), this._$AH = t6;
|
|
1164
1166
|
}
|
|
1165
1167
|
}
|
|
1166
1168
|
_$AC(t5) {
|
|
1167
|
-
let
|
|
1168
|
-
return void 0 ===
|
|
1169
|
+
let i7 = C.get(t5.strings);
|
|
1170
|
+
return void 0 === i7 && C.set(t5.strings, i7 = new S2(t5)), i7;
|
|
1169
1171
|
}
|
|
1170
1172
|
k(t5) {
|
|
1171
1173
|
u2(this._$AH) || (this._$AH = [], this._$AR());
|
|
1172
|
-
const
|
|
1173
|
-
let
|
|
1174
|
-
for (const
|
|
1175
|
-
e6 <
|
|
1174
|
+
const i7 = this._$AH;
|
|
1175
|
+
let s6, e6 = 0;
|
|
1176
|
+
for (const h6 of t5) e6 === i7.length ? i7.push(s6 = new _R(this.O(c3()), this.O(c3()), this, this.options)) : s6 = i7[e6], s6._$AI(h6), e6++;
|
|
1177
|
+
e6 < i7.length && (this._$AR(s6 && s6._$AB.nextSibling, e6), i7.length = e6);
|
|
1176
1178
|
}
|
|
1177
|
-
_$AR(t5 = this._$AA.nextSibling,
|
|
1179
|
+
_$AR(t5 = this._$AA.nextSibling, s6) {
|
|
1178
1180
|
var _a13;
|
|
1179
|
-
for ((_a13 = this._$AP) == null ? void 0 : _a13.call(this, false, true,
|
|
1180
|
-
const
|
|
1181
|
-
i2(t5).remove(), t5 =
|
|
1181
|
+
for ((_a13 = this._$AP) == null ? void 0 : _a13.call(this, false, true, s6); t5 !== this._$AB; ) {
|
|
1182
|
+
const s7 = i2(t5).nextSibling;
|
|
1183
|
+
i2(t5).remove(), t5 = s7;
|
|
1182
1184
|
}
|
|
1183
1185
|
}
|
|
1184
1186
|
setConnected(t5) {
|
|
@@ -1193,19 +1195,19 @@ var H = class {
|
|
|
1193
1195
|
get _$AU() {
|
|
1194
1196
|
return this._$AM._$AU;
|
|
1195
1197
|
}
|
|
1196
|
-
constructor(t5,
|
|
1197
|
-
this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t5, this.name =
|
|
1198
|
+
constructor(t5, i7, s6, e6, h6) {
|
|
1199
|
+
this.type = 1, this._$AH = A, this._$AN = void 0, this.element = t5, this.name = i7, this._$AM = e6, this.options = h6, s6.length > 2 || "" !== s6[0] || "" !== s6[1] ? (this._$AH = Array(s6.length - 1).fill(new String()), this.strings = s6) : this._$AH = A;
|
|
1198
1200
|
}
|
|
1199
|
-
_$AI(t5,
|
|
1200
|
-
const
|
|
1201
|
-
let
|
|
1202
|
-
if (void 0 ===
|
|
1201
|
+
_$AI(t5, i7 = this, s6, e6) {
|
|
1202
|
+
const h6 = this.strings;
|
|
1203
|
+
let o9 = false;
|
|
1204
|
+
if (void 0 === h6) t5 = M(this, t5, i7, 0), o9 = !a2(t5) || t5 !== this._$AH && t5 !== E, o9 && (this._$AH = t5);
|
|
1203
1205
|
else {
|
|
1204
1206
|
const e7 = t5;
|
|
1205
|
-
let
|
|
1206
|
-
for (t5 =
|
|
1207
|
+
let n7, r6;
|
|
1208
|
+
for (t5 = h6[0], n7 = 0; n7 < h6.length - 1; n7++) r6 = M(this, e7[s6 + n7], i7, n7), r6 === E && (r6 = this._$AH[n7]), o9 || (o9 = !a2(r6) || r6 !== this._$AH[n7]), r6 === A ? t5 = A : t5 !== A && (t5 += (r6 != null ? r6 : "") + h6[n7 + 1]), this._$AH[n7] = r6;
|
|
1207
1209
|
}
|
|
1208
|
-
|
|
1210
|
+
o9 && !e6 && this.j(t5);
|
|
1209
1211
|
}
|
|
1210
1212
|
j(t5) {
|
|
1211
1213
|
t5 === A ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t5 != null ? t5 : "");
|
|
@@ -1228,14 +1230,14 @@ var L = class extends H {
|
|
|
1228
1230
|
}
|
|
1229
1231
|
};
|
|
1230
1232
|
var z = class extends H {
|
|
1231
|
-
constructor(t5,
|
|
1232
|
-
super(t5,
|
|
1233
|
+
constructor(t5, i7, s6, e6, h6) {
|
|
1234
|
+
super(t5, i7, s6, e6, h6), this.type = 5;
|
|
1233
1235
|
}
|
|
1234
|
-
_$AI(t5,
|
|
1236
|
+
_$AI(t5, i7 = this) {
|
|
1235
1237
|
var _a13;
|
|
1236
|
-
if ((t5 = (_a13 = M(this, t5,
|
|
1237
|
-
const
|
|
1238
|
-
e6 && this.element.removeEventListener(this.name, this,
|
|
1238
|
+
if ((t5 = (_a13 = M(this, t5, i7, 0)) != null ? _a13 : A) === E) return;
|
|
1239
|
+
const s6 = this._$AH, e6 = t5 === A && s6 !== A || t5.capture !== s6.capture || t5.once !== s6.once || t5.passive !== s6.passive, h6 = t5 !== A && (s6 === A || e6);
|
|
1240
|
+
e6 && this.element.removeEventListener(this.name, this, s6), h6 && this.element.addEventListener(this.name, this, t5), this._$AH = t5;
|
|
1239
1241
|
}
|
|
1240
1242
|
handleEvent(t5) {
|
|
1241
1243
|
var _a13, _b3;
|
|
@@ -1243,8 +1245,8 @@ var z = class extends H {
|
|
|
1243
1245
|
}
|
|
1244
1246
|
};
|
|
1245
1247
|
var W = class {
|
|
1246
|
-
constructor(t5,
|
|
1247
|
-
this.element = t5, this.type = 6, this._$AN = void 0, this._$AM =
|
|
1248
|
+
constructor(t5, i7, s6) {
|
|
1249
|
+
this.element = t5, this.type = 6, this._$AN = void 0, this._$AM = i7, this.options = s6;
|
|
1248
1250
|
}
|
|
1249
1251
|
get _$AU() {
|
|
1250
1252
|
return this._$AM._$AU;
|
|
@@ -1257,15 +1259,15 @@ var Z = { M: h2, P: o3, A: n3, C: 1, L: N, R: k, D: d2, V: M, I: R, H, N: L, U:
|
|
|
1257
1259
|
var j = t2.litHtmlPolyfillSupport;
|
|
1258
1260
|
var _a10;
|
|
1259
1261
|
j == null ? void 0 : j(S2, R), ((_a10 = t2.litHtmlVersions) != null ? _a10 : t2.litHtmlVersions = []).push("3.3.3");
|
|
1260
|
-
var B = (t5,
|
|
1262
|
+
var B = (t5, i7, s6) => {
|
|
1261
1263
|
var _a13, _b3;
|
|
1262
|
-
const e6 = (_a13 =
|
|
1263
|
-
let
|
|
1264
|
-
if (void 0 ===
|
|
1265
|
-
const t6 = (_b3 =
|
|
1266
|
-
e6._$litPart$ =
|
|
1264
|
+
const e6 = (_a13 = s6 == null ? void 0 : s6.renderBefore) != null ? _a13 : i7;
|
|
1265
|
+
let h6 = e6._$litPart$;
|
|
1266
|
+
if (void 0 === h6) {
|
|
1267
|
+
const t6 = (_b3 = s6 == null ? void 0 : s6.renderBefore) != null ? _b3 : null;
|
|
1268
|
+
e6._$litPart$ = h6 = new R(i7.insertBefore(c3(), t6), t6, void 0, s6 != null ? s6 : {});
|
|
1267
1269
|
}
|
|
1268
|
-
return
|
|
1270
|
+
return h6._$AI(t5), h6;
|
|
1269
1271
|
};
|
|
1270
1272
|
|
|
1271
1273
|
// ../../node_modules/.pnpm/lit-element@4.2.2/node_modules/lit-element/lit-element.js
|
|
@@ -1302,17 +1304,52 @@ o4 == null ? void 0 : o4({ LitElement: i3 });
|
|
|
1302
1304
|
var _a12;
|
|
1303
1305
|
((_a12 = s3.litElementVersions) != null ? _a12 : s3.litElementVersions = []).push("4.2.2");
|
|
1304
1306
|
|
|
1307
|
+
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive-helpers.js
|
|
1308
|
+
var { I: t3 } = Z;
|
|
1309
|
+
var i4 = (o9) => o9;
|
|
1310
|
+
var r4 = (o9) => void 0 === o9.strings;
|
|
1311
|
+
var s4 = () => document.createComment("");
|
|
1312
|
+
var v2 = (o9, n7, e6) => {
|
|
1313
|
+
var _a13;
|
|
1314
|
+
const l3 = o9._$AA.parentNode, d3 = void 0 === n7 ? o9._$AB : n7._$AA;
|
|
1315
|
+
if (void 0 === e6) {
|
|
1316
|
+
const i7 = l3.insertBefore(s4(), d3), n8 = l3.insertBefore(s4(), d3);
|
|
1317
|
+
e6 = new t3(i7, n8, o9, o9.options);
|
|
1318
|
+
} else {
|
|
1319
|
+
const t5 = e6._$AB.nextSibling, n8 = e6._$AM, c6 = n8 !== o9;
|
|
1320
|
+
if (c6) {
|
|
1321
|
+
let t6;
|
|
1322
|
+
(_a13 = e6._$AQ) == null ? void 0 : _a13.call(e6, o9), e6._$AM = o9, void 0 !== e6._$AP && (t6 = o9._$AU) !== n8._$AU && e6._$AP(t6);
|
|
1323
|
+
}
|
|
1324
|
+
if (t5 !== d3 || c6) {
|
|
1325
|
+
let o10 = e6._$AA;
|
|
1326
|
+
for (; o10 !== t5; ) {
|
|
1327
|
+
const t6 = i4(o10).nextSibling;
|
|
1328
|
+
i4(l3).insertBefore(o10, d3), o10 = t6;
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
return e6;
|
|
1333
|
+
};
|
|
1334
|
+
var u3 = (o9, t5, i7 = o9) => (o9._$AI(t5, i7), o9);
|
|
1335
|
+
var m3 = {};
|
|
1336
|
+
var p3 = (o9, t5 = m3) => o9._$AH = t5;
|
|
1337
|
+
var M2 = (o9) => o9._$AH;
|
|
1338
|
+
var h3 = (o9) => {
|
|
1339
|
+
o9._$AR(), o9._$AA.remove();
|
|
1340
|
+
};
|
|
1341
|
+
|
|
1305
1342
|
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directive.js
|
|
1306
|
-
var
|
|
1343
|
+
var t4 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 };
|
|
1307
1344
|
var e3 = (t5) => (...e6) => ({ _$litDirective$: t5, values: e6 });
|
|
1308
|
-
var
|
|
1345
|
+
var i5 = class {
|
|
1309
1346
|
constructor(t5) {
|
|
1310
1347
|
}
|
|
1311
1348
|
get _$AU() {
|
|
1312
1349
|
return this._$AM._$AU;
|
|
1313
1350
|
}
|
|
1314
|
-
_$AT(t5, e6,
|
|
1315
|
-
this._$Ct = t5, this._$AM = e6, this._$Ci =
|
|
1351
|
+
_$AT(t5, e6, i7) {
|
|
1352
|
+
this._$Ct = t5, this._$AM = e6, this._$Ci = i7;
|
|
1316
1353
|
}
|
|
1317
1354
|
_$AS(t5, e6) {
|
|
1318
1355
|
return this.update(t5, e6);
|
|
@@ -1322,10 +1359,104 @@ var i4 = class {
|
|
|
1322
1359
|
}
|
|
1323
1360
|
};
|
|
1324
1361
|
|
|
1362
|
+
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/async-directive.js
|
|
1363
|
+
var s5 = (i7, t5) => {
|
|
1364
|
+
var _a13;
|
|
1365
|
+
const e6 = i7._$AN;
|
|
1366
|
+
if (void 0 === e6) return false;
|
|
1367
|
+
for (const i8 of e6) (_a13 = i8._$AO) == null ? void 0 : _a13.call(i8, t5, false), s5(i8, t5);
|
|
1368
|
+
return true;
|
|
1369
|
+
};
|
|
1370
|
+
var o5 = (i7) => {
|
|
1371
|
+
let t5, e6;
|
|
1372
|
+
do {
|
|
1373
|
+
if (void 0 === (t5 = i7._$AM)) break;
|
|
1374
|
+
e6 = t5._$AN, e6.delete(i7), i7 = t5;
|
|
1375
|
+
} while (0 === (e6 == null ? void 0 : e6.size));
|
|
1376
|
+
};
|
|
1377
|
+
var r5 = (i7) => {
|
|
1378
|
+
for (let t5; t5 = i7._$AM; i7 = t5) {
|
|
1379
|
+
let e6 = t5._$AN;
|
|
1380
|
+
if (void 0 === e6) t5._$AN = e6 = /* @__PURE__ */ new Set();
|
|
1381
|
+
else if (e6.has(i7)) break;
|
|
1382
|
+
e6.add(i7), c4(t5);
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1385
|
+
function h4(i7) {
|
|
1386
|
+
void 0 !== this._$AN ? (o5(this), this._$AM = i7, r5(this)) : this._$AM = i7;
|
|
1387
|
+
}
|
|
1388
|
+
function n4(i7, t5 = false, e6 = 0) {
|
|
1389
|
+
const r6 = this._$AH, h6 = this._$AN;
|
|
1390
|
+
if (void 0 !== h6 && 0 !== h6.size) if (t5) if (Array.isArray(r6)) for (let i8 = e6; i8 < r6.length; i8++) s5(r6[i8], false), o5(r6[i8]);
|
|
1391
|
+
else null != r6 && (s5(r6, false), o5(r6));
|
|
1392
|
+
else s5(this, i7);
|
|
1393
|
+
}
|
|
1394
|
+
var c4 = (i7) => {
|
|
1395
|
+
var _a13, _b3;
|
|
1396
|
+
i7.type == t4.CHILD && ((_a13 = i7._$AP) != null ? _a13 : i7._$AP = n4, (_b3 = i7._$AQ) != null ? _b3 : i7._$AQ = h4);
|
|
1397
|
+
};
|
|
1398
|
+
var f3 = class extends i5 {
|
|
1399
|
+
constructor() {
|
|
1400
|
+
super(...arguments), this._$AN = void 0;
|
|
1401
|
+
}
|
|
1402
|
+
_$AT(i7, t5, e6) {
|
|
1403
|
+
super._$AT(i7, t5, e6), r5(this), this.isConnected = i7._$AU;
|
|
1404
|
+
}
|
|
1405
|
+
_$AO(i7, t5 = true) {
|
|
1406
|
+
var _a13, _b3;
|
|
1407
|
+
i7 !== this.isConnected && (this.isConnected = i7, i7 ? (_a13 = this.reconnected) == null ? void 0 : _a13.call(this) : (_b3 = this.disconnected) == null ? void 0 : _b3.call(this)), t5 && (s5(this, i7), o5(this));
|
|
1408
|
+
}
|
|
1409
|
+
setValue(t5) {
|
|
1410
|
+
if (r4(this._$Ct)) this._$Ct._$AI(t5, this);
|
|
1411
|
+
else {
|
|
1412
|
+
const i7 = [...this._$Ct._$AH];
|
|
1413
|
+
i7[this._$Ci] = t5, this._$Ct._$AI(i7, this, 0);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
disconnected() {
|
|
1417
|
+
}
|
|
1418
|
+
reconnected() {
|
|
1419
|
+
}
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1422
|
+
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/ref.js
|
|
1423
|
+
var e4 = () => new h5();
|
|
1424
|
+
var h5 = class {
|
|
1425
|
+
};
|
|
1426
|
+
var o6 = /* @__PURE__ */ new WeakMap();
|
|
1427
|
+
var n5 = e3(class extends f3 {
|
|
1428
|
+
render(i7) {
|
|
1429
|
+
return A;
|
|
1430
|
+
}
|
|
1431
|
+
update(i7, [s6]) {
|
|
1432
|
+
var _a13;
|
|
1433
|
+
const e6 = s6 !== this.G;
|
|
1434
|
+
return e6 && this.rt(void 0), (e6 || this.lt !== this.ct) && (this.G = s6, this.ht = (_a13 = i7.options) == null ? void 0 : _a13.host, this.rt(this.ct = i7.element)), A;
|
|
1435
|
+
}
|
|
1436
|
+
rt(t5) {
|
|
1437
|
+
var _a13;
|
|
1438
|
+
if (void 0 !== this.G) if (this.isConnected || (t5 = void 0), "function" == typeof this.G) {
|
|
1439
|
+
const i7 = (_a13 = this.ht) != null ? _a13 : globalThis;
|
|
1440
|
+
let s6 = o6.get(i7);
|
|
1441
|
+
void 0 === s6 && (s6 = /* @__PURE__ */ new WeakMap(), o6.set(i7, s6)), void 0 !== s6.get(this.G) && this.G.call(this.ht, void 0), s6.set(this.G, t5), void 0 !== t5 && this.G.call(this.ht, t5);
|
|
1442
|
+
} else this.G.value = t5;
|
|
1443
|
+
}
|
|
1444
|
+
get lt() {
|
|
1445
|
+
var _a13, _b3, _c;
|
|
1446
|
+
return "function" == typeof this.G ? (_b3 = o6.get((_a13 = this.ht) != null ? _a13 : globalThis)) == null ? void 0 : _b3.get(this.G) : (_c = this.G) == null ? void 0 : _c.value;
|
|
1447
|
+
}
|
|
1448
|
+
disconnected() {
|
|
1449
|
+
this.lt === this.ct && this.rt(void 0);
|
|
1450
|
+
}
|
|
1451
|
+
reconnected() {
|
|
1452
|
+
this.rt(this.ct);
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
|
|
1325
1456
|
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/unsafe-html.js
|
|
1326
|
-
var
|
|
1327
|
-
constructor(
|
|
1328
|
-
if (super(
|
|
1457
|
+
var e5 = class extends i5 {
|
|
1458
|
+
constructor(i7) {
|
|
1459
|
+
if (super(i7), this.it = A, i7.type !== t4.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
|
|
1329
1460
|
}
|
|
1330
1461
|
render(r6) {
|
|
1331
1462
|
if (r6 === A || null == r6) return this._t = void 0, this.it = r6;
|
|
@@ -1333,43 +1464,71 @@ var e4 = class extends i4 {
|
|
|
1333
1464
|
if ("string" != typeof r6) throw Error(this.constructor.directiveName + "() called with a non-string value");
|
|
1334
1465
|
if (r6 === this.it) return this._t;
|
|
1335
1466
|
this.it = r6;
|
|
1336
|
-
const
|
|
1337
|
-
return
|
|
1467
|
+
const s6 = [r6];
|
|
1468
|
+
return s6.raw = s6, this._t = { _$litType$: this.constructor.resultType, strings: s6, values: [] };
|
|
1338
1469
|
}
|
|
1339
1470
|
};
|
|
1340
|
-
|
|
1341
|
-
var
|
|
1471
|
+
e5.directiveName = "unsafeHTML", e5.resultType = 1;
|
|
1472
|
+
var o7 = e3(e5);
|
|
1473
|
+
|
|
1474
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-left-bold.svg
|
|
1475
|
+
var caret_left_bold_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z"/></svg>\n';
|
|
1476
|
+
|
|
1477
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-right-bold.svg
|
|
1478
|
+
var caret_right_bold_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"/></svg>\n';
|
|
1342
1479
|
|
|
1343
1480
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/close.svg
|
|
1344
1481
|
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';
|
|
1345
1482
|
|
|
1483
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/caret-up-bold.svg
|
|
1484
|
+
var caret_up_bold_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"/></svg>';
|
|
1485
|
+
|
|
1346
1486
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/collapse.svg
|
|
1347
1487
|
var collapse_default = '<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';
|
|
1348
1488
|
|
|
1349
1489
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg
|
|
1350
1490
|
var expand_default = '<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';
|
|
1351
1491
|
|
|
1492
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/minus.svg
|
|
1493
|
+
var minus_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z"/></svg>';
|
|
1494
|
+
|
|
1352
1495
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg
|
|
1353
1496
|
var pause_fill_default = '<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';
|
|
1354
1497
|
|
|
1355
1498
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg
|
|
1356
1499
|
var play_fill_default = '<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';
|
|
1357
1500
|
|
|
1501
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/plus.svg
|
|
1502
|
+
var plus_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/></svg>';
|
|
1503
|
+
|
|
1358
1504
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg
|
|
1359
1505
|
var speaker_x_fill_default = '<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';
|
|
1360
1506
|
|
|
1361
1507
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg
|
|
1362
1508
|
var speaker_high_fill_default = '<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';
|
|
1363
1509
|
|
|
1510
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/trash.svg
|
|
1511
|
+
var trash_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/></svg>';
|
|
1512
|
+
|
|
1513
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/warning-circle-fill.svg
|
|
1514
|
+
var warning_circle_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"/></svg>\n';
|
|
1515
|
+
|
|
1364
1516
|
// src/components/icons/index.ts
|
|
1365
1517
|
var icons = {
|
|
1518
|
+
caretUp: caret_up_bold_default,
|
|
1366
1519
|
close: close_default,
|
|
1367
1520
|
collapse: collapse_default,
|
|
1368
1521
|
expand: expand_default,
|
|
1522
|
+
minus: minus_default,
|
|
1523
|
+
next: caret_right_bold_default,
|
|
1369
1524
|
pause: pause_fill_default,
|
|
1370
1525
|
play: play_fill_default,
|
|
1526
|
+
plus: plus_default,
|
|
1527
|
+
previous: caret_left_bold_default,
|
|
1371
1528
|
soundOff: speaker_x_fill_default,
|
|
1372
|
-
soundOn: speaker_high_fill_default
|
|
1529
|
+
soundOn: speaker_high_fill_default,
|
|
1530
|
+
trash: trash_default,
|
|
1531
|
+
warning: warning_circle_fill_default
|
|
1373
1532
|
};
|
|
1374
1533
|
var markup = Object.fromEntries(
|
|
1375
1534
|
Object.entries(icons).map(([name, svg]) => [
|
|
@@ -1381,108 +1540,141 @@ var markup = Object.fromEntries(
|
|
|
1381
1540
|
])
|
|
1382
1541
|
);
|
|
1383
1542
|
function icon(name) {
|
|
1384
|
-
return
|
|
1543
|
+
return o7(markup[name]);
|
|
1385
1544
|
}
|
|
1386
1545
|
|
|
1387
|
-
//
|
|
1388
|
-
var
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
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);
|
|
1546
|
+
// src/locales/en.ts
|
|
1547
|
+
var en = {
|
|
1548
|
+
watch: "Watch video",
|
|
1549
|
+
show: "Show video",
|
|
1550
|
+
carousel: "Videos",
|
|
1551
|
+
carouselRole: "carousel",
|
|
1552
|
+
previous: "Previous video",
|
|
1553
|
+
next: "Next video",
|
|
1554
|
+
player: "Video",
|
|
1555
|
+
expand: "Expand video",
|
|
1556
|
+
collapse: "Collapse video",
|
|
1557
|
+
close: "Close video",
|
|
1558
|
+
play: "Play video",
|
|
1559
|
+
pause: "Pause video",
|
|
1560
|
+
soundOn: "Turn sound on",
|
|
1561
|
+
soundOff: "Turn sound off",
|
|
1562
|
+
addToCart: "Add to cart",
|
|
1563
|
+
cartQuantity: "Quantity in cart",
|
|
1564
|
+
decreaseQuantity: "Decrease quantity",
|
|
1565
|
+
removeFromCart: "Remove from cart",
|
|
1566
|
+
increaseQuantity: "Increase quantity",
|
|
1567
|
+
unavailable: "Product unavailable",
|
|
1568
|
+
soldOut: "Sold out",
|
|
1569
|
+
viewProduct: "View product",
|
|
1570
|
+
videoUnavailable: "Video unavailable",
|
|
1571
|
+
videoFailed: "Couldn't load the video",
|
|
1572
|
+
retry: "Try again",
|
|
1573
|
+
videoLoading: "Loading video",
|
|
1574
|
+
product: (name, price, listPrice, soldOut) => {
|
|
1575
|
+
let text = name;
|
|
1576
|
+
if (price && listPrice) text = `${name}, was ${listPrice}, now ${price}`;
|
|
1577
|
+
else if (price) text = `${name}, ${price}`;
|
|
1578
|
+
return soldOut ? `${text}, ${soldOut}` : text;
|
|
1579
|
+
},
|
|
1580
|
+
position: (label, index, count) => count > 1 ? `${label} ${index + 1} of ${count}` : label
|
|
1426
1581
|
};
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1582
|
+
|
|
1583
|
+
// src/locales/es.ts
|
|
1584
|
+
var es = {
|
|
1585
|
+
watch: "Ver video",
|
|
1586
|
+
show: "Mostrar video",
|
|
1587
|
+
carousel: "Videos",
|
|
1588
|
+
carouselRole: "carrusel",
|
|
1589
|
+
previous: "Video anterior",
|
|
1590
|
+
next: "Video siguiente",
|
|
1591
|
+
player: "Video",
|
|
1592
|
+
expand: "Ampliar video",
|
|
1593
|
+
collapse: "Reducir video",
|
|
1594
|
+
close: "Cerrar video",
|
|
1595
|
+
play: "Reproducir video",
|
|
1596
|
+
pause: "Pausar video",
|
|
1597
|
+
soundOn: "Activar sonido",
|
|
1598
|
+
soundOff: "Desactivar sonido",
|
|
1599
|
+
addToCart: "Agregar al carrito",
|
|
1600
|
+
cartQuantity: "Cantidad en el carrito",
|
|
1601
|
+
decreaseQuantity: "Disminuir cantidad",
|
|
1602
|
+
removeFromCart: "Quitar del carrito",
|
|
1603
|
+
increaseQuantity: "Aumentar cantidad",
|
|
1604
|
+
unavailable: "Producto no disponible",
|
|
1605
|
+
soldOut: "Agotado",
|
|
1606
|
+
viewProduct: "Ver producto",
|
|
1607
|
+
videoUnavailable: "Video no disponible",
|
|
1608
|
+
videoFailed: "No se pudo cargar el video",
|
|
1609
|
+
retry: "Intentar de nuevo",
|
|
1610
|
+
videoLoading: "Cargando video",
|
|
1611
|
+
product: (name, price, listPrice, soldOut) => {
|
|
1612
|
+
let text = name;
|
|
1613
|
+
if (price && listPrice)
|
|
1614
|
+
text = `${name}, antes ${listPrice}, ahora ${price}`;
|
|
1615
|
+
else if (price) text = `${name}, ${price}`;
|
|
1616
|
+
return soldOut ? `${text}, ${soldOut}` : text;
|
|
1617
|
+
},
|
|
1618
|
+
position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
|
|
1449
1619
|
};
|
|
1450
1620
|
|
|
1451
|
-
//
|
|
1452
|
-
var
|
|
1453
|
-
|
|
1621
|
+
// src/locales/pt.ts
|
|
1622
|
+
var pt = {
|
|
1623
|
+
watch: "Assistir v\xEDdeo",
|
|
1624
|
+
show: "Mostrar v\xEDdeo",
|
|
1625
|
+
carousel: "V\xEDdeos",
|
|
1626
|
+
carouselRole: "carrossel",
|
|
1627
|
+
previous: "V\xEDdeo anterior",
|
|
1628
|
+
next: "Pr\xF3ximo v\xEDdeo",
|
|
1629
|
+
player: "V\xEDdeo",
|
|
1630
|
+
expand: "Expandir v\xEDdeo",
|
|
1631
|
+
collapse: "Reduzir v\xEDdeo",
|
|
1632
|
+
close: "Fechar v\xEDdeo",
|
|
1633
|
+
play: "Reproduzir v\xEDdeo",
|
|
1634
|
+
pause: "Pausar v\xEDdeo",
|
|
1635
|
+
soundOn: "Ativar som",
|
|
1636
|
+
soundOff: "Desativar som",
|
|
1637
|
+
addToCart: "Adicionar ao carrinho",
|
|
1638
|
+
cartQuantity: "Quantidade no carrinho",
|
|
1639
|
+
decreaseQuantity: "Diminuir quantidade",
|
|
1640
|
+
removeFromCart: "Remover do carrinho",
|
|
1641
|
+
increaseQuantity: "Aumentar quantidade",
|
|
1642
|
+
unavailable: "Produto indispon\xEDvel",
|
|
1643
|
+
soldOut: "Esgotado",
|
|
1644
|
+
viewProduct: "Ver produto",
|
|
1645
|
+
videoUnavailable: "V\xEDdeo indispon\xEDvel",
|
|
1646
|
+
videoFailed: "N\xE3o foi poss\xEDvel carregar o v\xEDdeo",
|
|
1647
|
+
retry: "Tentar de novo",
|
|
1648
|
+
videoLoading: "Carregando v\xEDdeo",
|
|
1649
|
+
product: (name, price, listPrice, soldOut) => {
|
|
1650
|
+
let text = name;
|
|
1651
|
+
if (price && listPrice) text = `${name}, de ${listPrice} por ${price}`;
|
|
1652
|
+
else if (price) text = `${name}, ${price}`;
|
|
1653
|
+
return soldOut ? `${text}, ${soldOut}` : text;
|
|
1654
|
+
},
|
|
1655
|
+
position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
|
|
1454
1656
|
};
|
|
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
1657
|
|
|
1485
|
-
// src/
|
|
1658
|
+
// src/locales/index.ts
|
|
1659
|
+
var BY_LANGUAGE = /* @__PURE__ */ new Map([
|
|
1660
|
+
["pt", pt],
|
|
1661
|
+
["es", es],
|
|
1662
|
+
["en", en]
|
|
1663
|
+
]);
|
|
1664
|
+
function labelsFor(locale, overrides = {}) {
|
|
1665
|
+
var _a13, _b3, _c;
|
|
1666
|
+
const language = locale.split("-")[0].toLowerCase();
|
|
1667
|
+
const labels = (_a13 = BY_LANGUAGE.get(language)) != null ? _a13 : pt;
|
|
1668
|
+
const addToCart = (_b3 = overrides.addToCart) == null ? void 0 : _b3.trim();
|
|
1669
|
+
const viewProduct = (_c = overrides.viewProduct) == null ? void 0 : _c.trim();
|
|
1670
|
+
return {
|
|
1671
|
+
...labels,
|
|
1672
|
+
...addToCart && { addToCart },
|
|
1673
|
+
...viewProduct && { viewProduct }
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
// src/utils/safe-url.ts
|
|
1486
1678
|
function httpUrl(value) {
|
|
1487
1679
|
if (!value) return null;
|
|
1488
1680
|
try {
|
|
@@ -1492,16 +1684,82 @@ function httpUrl(value) {
|
|
|
1492
1684
|
return null;
|
|
1493
1685
|
}
|
|
1494
1686
|
}
|
|
1687
|
+
var STORE_BASE = "https://store.invalid";
|
|
1688
|
+
function storePath(value) {
|
|
1689
|
+
try {
|
|
1690
|
+
const url = new URL(value, STORE_BASE);
|
|
1691
|
+
if (url.origin !== STORE_BASE || url.pathname.startsWith("//")) {
|
|
1692
|
+
return null;
|
|
1693
|
+
}
|
|
1694
|
+
return `${url.pathname}${url.search}${url.hash}`;
|
|
1695
|
+
} catch (e6) {
|
|
1696
|
+
return null;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
function destinationUrl(value) {
|
|
1700
|
+
if (!value) return null;
|
|
1701
|
+
return value.startsWith("/") ? storePath(value) : httpUrl(value);
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
// src/components/media/media.ts
|
|
1705
|
+
var REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
|
|
1495
1706
|
function prefersReducedMotion() {
|
|
1496
1707
|
var _a13, _b3;
|
|
1497
|
-
return (_b3 = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis,
|
|
1708
|
+
return (_b3 = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, REDUCED_MOTION).matches) != null ? _b3 : false;
|
|
1498
1709
|
}
|
|
1499
1710
|
function hasVideo(story, video) {
|
|
1500
|
-
return !video.failed && httpUrl(story.media_url) !== null;
|
|
1711
|
+
return !video.failed && !video.retrying && httpUrl(story.media_url) !== null;
|
|
1712
|
+
}
|
|
1713
|
+
function renderFailed(labels, onRetry) {
|
|
1714
|
+
const retry = (event) => {
|
|
1715
|
+
event.stopPropagation();
|
|
1716
|
+
onRetry == null ? void 0 : onRetry();
|
|
1717
|
+
};
|
|
1718
|
+
return T`
|
|
1719
|
+
<div class="media-status" ?data-retry=${!!onRetry}>
|
|
1720
|
+
<span class="media-status-text">
|
|
1721
|
+
${icon("warning")}
|
|
1722
|
+
${onRetry ? labels.videoFailed : labels.videoUnavailable}
|
|
1723
|
+
</span>
|
|
1724
|
+
${onRetry ? T`
|
|
1725
|
+
<button type="button" class="media-retry" @click=${retry}>
|
|
1726
|
+
${labels.retry}
|
|
1727
|
+
</button>
|
|
1728
|
+
` : A}
|
|
1729
|
+
</div>
|
|
1730
|
+
`;
|
|
1731
|
+
}
|
|
1732
|
+
function renderVideoLoading(labels) {
|
|
1733
|
+
return T`
|
|
1734
|
+
<div class="media-status">
|
|
1735
|
+
<span class="media-status-text">
|
|
1736
|
+
<span class="media-spinner" aria-hidden="true"></span>
|
|
1737
|
+
${labels.videoLoading}
|
|
1738
|
+
</span>
|
|
1739
|
+
</div>
|
|
1740
|
+
`;
|
|
1501
1741
|
}
|
|
1502
|
-
function
|
|
1742
|
+
function renderStatus(video, labels, onRetry) {
|
|
1743
|
+
if (video.failed) return renderFailed(labels, onRetry);
|
|
1744
|
+
if (video.retrying) return renderVideoLoading(labels);
|
|
1745
|
+
return A;
|
|
1746
|
+
}
|
|
1747
|
+
function renderNotice(video, { labels = pt, onRetry, announce = true }) {
|
|
1748
|
+
return T`
|
|
1749
|
+
<div
|
|
1750
|
+
class="media-notice"
|
|
1751
|
+
role=${announce ? "status" : A}
|
|
1752
|
+
aria-hidden=${announce ? A : "true"}
|
|
1753
|
+
>
|
|
1754
|
+
${renderStatus(video, labels, onRetry)}
|
|
1755
|
+
</div>
|
|
1756
|
+
`;
|
|
1757
|
+
}
|
|
1758
|
+
function renderMedia(story, video, options = {}) {
|
|
1759
|
+
const { withVideo = true, loop = true, onEnded, autoplay = true } = options;
|
|
1503
1760
|
const posterUrl = httpUrl(story.poster_url);
|
|
1504
|
-
const mediaUrl = httpUrl(story.media_url);
|
|
1761
|
+
const mediaUrl = withVideo ? httpUrl(story.media_url) : null;
|
|
1762
|
+
const preload = autoplay ? "metadata" : "auto";
|
|
1505
1763
|
return T`
|
|
1506
1764
|
${posterUrl ? T`<img class="poster" alt="" src=${posterUrl} />` : A}
|
|
1507
1765
|
${mediaUrl && !video.failed ? T`
|
|
@@ -1509,22 +1767,138 @@ function renderMedia(story, video) {
|
|
|
1509
1767
|
class="video"
|
|
1510
1768
|
muted
|
|
1511
1769
|
playsinline
|
|
1512
|
-
loop
|
|
1513
|
-
preload
|
|
1770
|
+
?loop=${loop}
|
|
1771
|
+
preload=${preload}
|
|
1514
1772
|
.muted=${true}
|
|
1515
|
-
?autoplay=${!prefersReducedMotion()}
|
|
1773
|
+
?autoplay=${autoplay && !prefersReducedMotion()}
|
|
1516
1774
|
poster=${posterUrl != null ? posterUrl : A}
|
|
1517
1775
|
src=${mediaUrl}
|
|
1518
1776
|
${n5(video.ref)}
|
|
1519
1777
|
@play=${video.sync}
|
|
1520
1778
|
@pause=${video.sync}
|
|
1521
1779
|
@volumechange=${video.sync}
|
|
1780
|
+
@loadeddata=${video.loaded}
|
|
1522
1781
|
@error=${video.fail}
|
|
1782
|
+
@ended=${onEnded}
|
|
1523
1783
|
></video>
|
|
1524
1784
|
` : A}
|
|
1785
|
+
${mediaUrl ? renderNotice(video, options) : A}
|
|
1525
1786
|
`;
|
|
1526
1787
|
}
|
|
1527
1788
|
|
|
1789
|
+
// src/components/media/media.styles.ts
|
|
1790
|
+
var mediaStyles = i`
|
|
1791
|
+
/* The live region the notice shows in, over the cover. Empty until the
|
|
1792
|
+
video can't load or is loading again. Clicks go through to the card. */
|
|
1793
|
+
.media-notice {
|
|
1794
|
+
position: absolute;
|
|
1795
|
+
inset: 0;
|
|
1796
|
+
pointer-events: none;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
/* The notice: a dimmed layer with the text in the middle. */
|
|
1800
|
+
.media-status {
|
|
1801
|
+
position: absolute;
|
|
1802
|
+
inset: 0;
|
|
1803
|
+
display: flex;
|
|
1804
|
+
flex-direction: column;
|
|
1805
|
+
gap: 12px;
|
|
1806
|
+
align-items: center;
|
|
1807
|
+
justify-content: center;
|
|
1808
|
+
box-sizing: border-box;
|
|
1809
|
+
padding: 16px;
|
|
1810
|
+
background: rgba(0, 0, 0, 0.45);
|
|
1811
|
+
color: #fff;
|
|
1812
|
+
text-align: center;
|
|
1813
|
+
pointer-events: none;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
.media-status > * {
|
|
1817
|
+
animation: media-status-in 0.4s ease-out both;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
.media-status-text {
|
|
1821
|
+
display: flex;
|
|
1822
|
+
flex-direction: column;
|
|
1823
|
+
gap: 8px;
|
|
1824
|
+
align-items: center;
|
|
1825
|
+
max-width: 100%;
|
|
1826
|
+
font-size: 14px;
|
|
1827
|
+
font-weight: 600;
|
|
1828
|
+
line-height: 1.3;
|
|
1829
|
+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
.media-status-text .icon {
|
|
1833
|
+
width: 18px;
|
|
1834
|
+
height: 18px;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
.media-status[data-retry] .media-status-text .icon {
|
|
1838
|
+
width: 24px;
|
|
1839
|
+
height: 24px;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
.media-retry {
|
|
1843
|
+
min-height: 36px;
|
|
1844
|
+
padding: 0 16px;
|
|
1845
|
+
border: 0;
|
|
1846
|
+
border-radius: var(--_button-radius);
|
|
1847
|
+
background: rgba(255, 255, 255, 0.15);
|
|
1848
|
+
backdrop-filter: blur(4px);
|
|
1849
|
+
box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);
|
|
1850
|
+
color: #fff;
|
|
1851
|
+
font: inherit;
|
|
1852
|
+
font-size: 14px;
|
|
1853
|
+
font-weight: 600;
|
|
1854
|
+
cursor: pointer;
|
|
1855
|
+
pointer-events: auto;
|
|
1856
|
+
animation-delay: 0.06s;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
.media-retry:focus-visible {
|
|
1860
|
+
outline: 2px solid #fff;
|
|
1861
|
+
outline-offset: 2px;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
@media (hover: hover) and (pointer: fine) {
|
|
1865
|
+
.media-retry:hover {
|
|
1866
|
+
background: rgba(255, 255, 255, 0.25);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
/* It spins with reduced motion too: a still ring wouldn't read as
|
|
1871
|
+
loading. */
|
|
1872
|
+
.media-spinner {
|
|
1873
|
+
width: 24px;
|
|
1874
|
+
height: 24px;
|
|
1875
|
+
box-sizing: border-box;
|
|
1876
|
+
border: 2px solid rgba(255, 255, 255, 0.35);
|
|
1877
|
+
border-top-color: #fff;
|
|
1878
|
+
border-radius: 50%;
|
|
1879
|
+
animation: media-spin 0.8s linear infinite;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
@keyframes media-status-in {
|
|
1883
|
+
from {
|
|
1884
|
+
opacity: 0;
|
|
1885
|
+
transform: translateY(4px);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
@keyframes media-spin {
|
|
1890
|
+
to {
|
|
1891
|
+
transform: rotate(360deg);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1896
|
+
.media-status > :not(.media-spinner) {
|
|
1897
|
+
animation: none;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
`;
|
|
1901
|
+
|
|
1528
1902
|
// src/components/media/video-controller.ts
|
|
1529
1903
|
function playVideo(video) {
|
|
1530
1904
|
var _a13;
|
|
@@ -1534,12 +1908,11 @@ var VideoController = class {
|
|
|
1534
1908
|
constructor(host) {
|
|
1535
1909
|
this.host = host;
|
|
1536
1910
|
/** Bound to the <video> by renderMedia. */
|
|
1537
|
-
this.ref =
|
|
1911
|
+
this.ref = e4();
|
|
1538
1912
|
this.paused = true;
|
|
1539
1913
|
// The video always starts muted: that is what browsers allow to autoplay.
|
|
1540
1914
|
this.muted = true;
|
|
1541
|
-
|
|
1542
|
-
this.failed = false;
|
|
1915
|
+
this.status = "playable";
|
|
1543
1916
|
/** Listener for the video's play, pause and volumechange events. */
|
|
1544
1917
|
this.sync = () => {
|
|
1545
1918
|
const video = this.ref.value;
|
|
@@ -1548,17 +1921,78 @@ var VideoController = class {
|
|
|
1548
1921
|
this.muted = video.muted;
|
|
1549
1922
|
this.host.requestUpdate();
|
|
1550
1923
|
};
|
|
1924
|
+
/** Listener for the video's loadeddata event. */
|
|
1925
|
+
this.loaded = () => {
|
|
1926
|
+
this.settleReady(true);
|
|
1927
|
+
if (!this.retrying) return;
|
|
1928
|
+
this.status = "playable";
|
|
1929
|
+
this.host.requestUpdate();
|
|
1930
|
+
};
|
|
1551
1931
|
/** Listener for the video's error event. */
|
|
1552
1932
|
this.fail = () => {
|
|
1553
|
-
this.
|
|
1933
|
+
this.status = "failed";
|
|
1934
|
+
this.settleReady(false);
|
|
1554
1935
|
this.host.requestUpdate();
|
|
1555
1936
|
};
|
|
1937
|
+
this.waitForReady();
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Resolves true once the video's first frame has loaded, or false if it
|
|
1941
|
+
* fails. A new one for each new <video> (see reset).
|
|
1942
|
+
*/
|
|
1943
|
+
get ready() {
|
|
1944
|
+
return this.readyState;
|
|
1945
|
+
}
|
|
1946
|
+
/** The video could not load: the cover shows with a notice over it. */
|
|
1947
|
+
get failed() {
|
|
1948
|
+
return this.status === "failed";
|
|
1949
|
+
}
|
|
1950
|
+
/** A failed video is loading again (see retry), until it loads or fails. */
|
|
1951
|
+
get retrying() {
|
|
1952
|
+
return this.status === "retrying";
|
|
1953
|
+
}
|
|
1954
|
+
/** The rendered <video> is on the page and playing. */
|
|
1955
|
+
get playing() {
|
|
1956
|
+
const video = this.ref.value;
|
|
1957
|
+
return !!video && video.isConnected && !video.paused;
|
|
1556
1958
|
}
|
|
1557
|
-
/**
|
|
1959
|
+
/**
|
|
1960
|
+
* For a new <video>, such as each time the player opens. A retry still
|
|
1961
|
+
* loading resolves false.
|
|
1962
|
+
*/
|
|
1558
1963
|
reset() {
|
|
1964
|
+
this.cancelRetry();
|
|
1559
1965
|
this.paused = true;
|
|
1560
1966
|
this.muted = true;
|
|
1561
|
-
this.
|
|
1967
|
+
this.status = "playable";
|
|
1968
|
+
this.waitForReady();
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* For the next Story's <video>: neither failed nor loading again (a retry
|
|
1972
|
+
* still loading resolves false). Unlike reset, it keeps the playback and
|
|
1973
|
+
* sound state.
|
|
1974
|
+
*/
|
|
1975
|
+
clearFailure() {
|
|
1976
|
+
if (this.retrying) {
|
|
1977
|
+
this.cancelRetry();
|
|
1978
|
+
this.waitForReady();
|
|
1979
|
+
}
|
|
1980
|
+
this.status = "playable";
|
|
1981
|
+
this.host.requestUpdate();
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Loads a failed video again: renderMedia renders a new <video> with a
|
|
1985
|
+
* notice that it is loading, until it loads or fails. Resolves as `ready`
|
|
1986
|
+
* does: false too if the video is replaced first (see reset and
|
|
1987
|
+
* clearFailure), and at once for a video that didn't fail.
|
|
1988
|
+
*/
|
|
1989
|
+
retry() {
|
|
1990
|
+
if (this.retrying) return this.ready;
|
|
1991
|
+
if (!this.failed) return Promise.resolve(false);
|
|
1992
|
+
this.reset();
|
|
1993
|
+
this.status = "retrying";
|
|
1994
|
+
this.host.requestUpdate();
|
|
1995
|
+
return this.ready;
|
|
1562
1996
|
}
|
|
1563
1997
|
play() {
|
|
1564
1998
|
const video = this.ref.value;
|
|
@@ -1579,150 +2013,1787 @@ var VideoController = class {
|
|
|
1579
2013
|
if (video.paused) playVideo(video);
|
|
1580
2014
|
else video.pause();
|
|
1581
2015
|
}
|
|
2016
|
+
mute() {
|
|
2017
|
+
const video = this.ref.value;
|
|
2018
|
+
if (video) video.muted = true;
|
|
2019
|
+
}
|
|
2020
|
+
/**
|
|
2021
|
+
* Plays from the start, with the sound on if `withSound`. A new src starts
|
|
2022
|
+
* there anyway; the same src (two Stories with one video) would otherwise
|
|
2023
|
+
* go on where it was.
|
|
2024
|
+
*/
|
|
2025
|
+
restart({ withSound = false } = {}) {
|
|
2026
|
+
const video = this.ref.value;
|
|
2027
|
+
if (!video) return;
|
|
2028
|
+
video.currentTime = 0;
|
|
2029
|
+
if (withSound) this.playWithSound();
|
|
2030
|
+
else playVideo(video);
|
|
2031
|
+
}
|
|
2032
|
+
/**
|
|
2033
|
+
* Plays with the sound on. A browser that blocks playing with sound (for
|
|
2034
|
+
* example, without a recent tap) gets it muted instead: the video keeps
|
|
2035
|
+
* playing, and the sound button offers to turn it on. Not if the video was
|
|
2036
|
+
* replaced or removed meanwhile (the request then fails for that reason):
|
|
2037
|
+
* it would play out of sight.
|
|
2038
|
+
*/
|
|
2039
|
+
playWithSound() {
|
|
2040
|
+
var _a13;
|
|
2041
|
+
const video = this.ref.value;
|
|
2042
|
+
if (!video) return;
|
|
2043
|
+
video.muted = false;
|
|
2044
|
+
(_a13 = video.play()) == null ? void 0 : _a13.catch((error) => {
|
|
2045
|
+
const blocked = error instanceof DOMException && error.name === "NotAllowedError";
|
|
2046
|
+
if (!blocked || this.ref.value !== video || !video.isConnected) return;
|
|
2047
|
+
video.muted = true;
|
|
2048
|
+
playVideo(video);
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
1582
2051
|
toggleMuted() {
|
|
1583
2052
|
const video = this.ref.value;
|
|
1584
2053
|
if (video) video.muted = !video.muted;
|
|
1585
2054
|
}
|
|
2055
|
+
// The video loading again is replaced: its retry resolves false.
|
|
2056
|
+
cancelRetry() {
|
|
2057
|
+
if (this.retrying) this.settleReady(false);
|
|
2058
|
+
}
|
|
2059
|
+
waitForReady() {
|
|
2060
|
+
this.readyState = new Promise((settle) => this.settleReady = settle);
|
|
2061
|
+
}
|
|
1586
2062
|
};
|
|
1587
2063
|
|
|
2064
|
+
// src/components/product/price.ts
|
|
2065
|
+
var DEFAULT_LOCALE = "pt-BR";
|
|
2066
|
+
var DEFAULT_CURRENCY = "BRL";
|
|
2067
|
+
function toAmount(value) {
|
|
2068
|
+
let amount = Number.NaN;
|
|
2069
|
+
if (typeof value === "number") amount = value;
|
|
2070
|
+
else if (typeof value === "string" && value.trim() !== "") {
|
|
2071
|
+
amount = Number(value);
|
|
2072
|
+
}
|
|
2073
|
+
return Number.isFinite(amount) && amount > 0 ? amount : void 0;
|
|
2074
|
+
}
|
|
2075
|
+
function readProductPrice(metadata) {
|
|
2076
|
+
const regular = toAmount(metadata == null ? void 0 : metadata.price);
|
|
2077
|
+
const promotional = toAmount(metadata == null ? void 0 : metadata.promotional_price);
|
|
2078
|
+
if (promotional !== void 0 && (regular === void 0 || promotional < regular)) {
|
|
2079
|
+
return regular === void 0 ? { price: promotional } : { price: promotional, listPrice: regular };
|
|
2080
|
+
}
|
|
2081
|
+
return regular === void 0 ? void 0 : { price: regular };
|
|
2082
|
+
}
|
|
2083
|
+
function isLocale(locale) {
|
|
2084
|
+
try {
|
|
2085
|
+
return Intl.NumberFormat.supportedLocalesOf(locale).length > 0;
|
|
2086
|
+
} catch (e6) {
|
|
2087
|
+
return false;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
var intl = Intl;
|
|
2091
|
+
function isCurrency(currency) {
|
|
2092
|
+
var _a13;
|
|
2093
|
+
if (!/^[a-z]{3}$/i.test(currency)) return false;
|
|
2094
|
+
const known = (_a13 = intl.supportedValuesOf) == null ? void 0 : _a13.call(intl, "currency");
|
|
2095
|
+
return known ? known.includes(currency.toUpperCase()) : true;
|
|
2096
|
+
}
|
|
2097
|
+
function priceFormatter(locale, currency) {
|
|
2098
|
+
const format = new Intl.NumberFormat(
|
|
2099
|
+
locale && isLocale(locale) ? locale : DEFAULT_LOCALE,
|
|
2100
|
+
{
|
|
2101
|
+
style: "currency",
|
|
2102
|
+
currency: currency && isCurrency(currency) ? currency : DEFAULT_CURRENCY
|
|
2103
|
+
}
|
|
2104
|
+
);
|
|
2105
|
+
return (amount) => format.format(amount);
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
// src/components/product/product.ts
|
|
2109
|
+
function toCardProduct(story, format, labels, fetched) {
|
|
2110
|
+
var _a13, _b3, _c, _d, _e, _f;
|
|
2111
|
+
const product = story.product;
|
|
2112
|
+
const name = (_a13 = product == null ? void 0 : product.product_name) == null ? void 0 : _a13.trim();
|
|
2113
|
+
if (!product || !name) return void 0;
|
|
2114
|
+
const base = {
|
|
2115
|
+
name,
|
|
2116
|
+
imageUrl: (_b3 = httpUrl(product.image_url)) != null ? _b3 : void 0,
|
|
2117
|
+
url: (_c = destinationUrl(story.destination_url)) != null ? _c : void 0,
|
|
2118
|
+
sku: ((_d = product.product_sku) == null ? void 0 : _d.trim()) || void 0,
|
|
2119
|
+
seller: ((_e = product.seller_id) == null ? void 0 : _e.trim()) || void 0
|
|
2120
|
+
};
|
|
2121
|
+
if (fetched === "loading") {
|
|
2122
|
+
return { ...base, label: labels.product(name), isLoading: true };
|
|
2123
|
+
}
|
|
2124
|
+
const soldOut = (fetched == null ? void 0 : fetched.available) === false ? labels.soldOut : void 0;
|
|
2125
|
+
const shown = (amounts2) => soldOut && (amounts2 == null ? void 0 : amounts2.price) === 0 ? void 0 : amounts2;
|
|
2126
|
+
const amounts = (_f = shown(fetched == null ? void 0 : fetched.price)) != null ? _f : shown(readProductPrice(product.product_metadata));
|
|
2127
|
+
const price = amounts && format(amounts.price);
|
|
2128
|
+
const listPrice = (amounts == null ? void 0 : amounts.listPrice) === void 0 ? void 0 : format(amounts.listPrice);
|
|
2129
|
+
return {
|
|
2130
|
+
...base,
|
|
2131
|
+
price,
|
|
2132
|
+
listPrice,
|
|
2133
|
+
soldOut,
|
|
2134
|
+
label: labels.product(name, price, listPrice, soldOut)
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
var priceSkeleton = T`
|
|
2138
|
+
<span
|
|
2139
|
+
class="product-price product-loading product-price-loading"
|
|
2140
|
+
aria-hidden="true"
|
|
2141
|
+
></span>
|
|
2142
|
+
`;
|
|
2143
|
+
var addToCartSkeleton = T`
|
|
2144
|
+
<span
|
|
2145
|
+
class="product-loading product-add-to-cart-loading"
|
|
2146
|
+
aria-hidden="true"
|
|
2147
|
+
></span>
|
|
2148
|
+
`;
|
|
2149
|
+
function renderPrice({ isLoading, soldOut, price, listPrice }) {
|
|
2150
|
+
if (isLoading) return priceSkeleton;
|
|
2151
|
+
if (!price) {
|
|
2152
|
+
return soldOut ? T`<span class="product-price product-sold-out">${soldOut}</span>` : A;
|
|
2153
|
+
}
|
|
2154
|
+
return T`
|
|
2155
|
+
<span class="product-price">
|
|
2156
|
+
<span>${price}</span>
|
|
2157
|
+
${listPrice ? T`<s class="product-list-price">${listPrice}</s>` : A}
|
|
2158
|
+
</span>
|
|
2159
|
+
`;
|
|
2160
|
+
}
|
|
2161
|
+
function renderSummary(product) {
|
|
2162
|
+
return T`
|
|
2163
|
+
${product.imageUrl ? T`<img class="product-image" alt="" src=${product.imageUrl} />` : A}
|
|
2164
|
+
<span class="product-info">
|
|
2165
|
+
<span class="product-name">${product.name}</span>
|
|
2166
|
+
${renderPrice(product)}
|
|
2167
|
+
</span>
|
|
2168
|
+
`;
|
|
2169
|
+
}
|
|
2170
|
+
function renderProduct(product, onSelect) {
|
|
2171
|
+
return T`
|
|
2172
|
+
<button
|
|
2173
|
+
type="button"
|
|
2174
|
+
class="card-product"
|
|
2175
|
+
aria-label=${product.label}
|
|
2176
|
+
@click=${onSelect}
|
|
2177
|
+
>
|
|
2178
|
+
${renderSummary(product)}
|
|
2179
|
+
</button>
|
|
2180
|
+
`;
|
|
2181
|
+
}
|
|
2182
|
+
var STEPPER_ADD_CLASS = "product-stepper-add";
|
|
2183
|
+
var ADD_TO_CART_CLASS = "product-add-to-cart";
|
|
2184
|
+
function focusCartAction(root, action) {
|
|
2185
|
+
var _a13;
|
|
2186
|
+
const className = action === "stepper" ? STEPPER_ADD_CLASS : ADD_TO_CART_CLASS;
|
|
2187
|
+
(_a13 = root.querySelector(`.${className}`)) == null ? void 0 : _a13.focus();
|
|
2188
|
+
}
|
|
2189
|
+
function renderStepper(quantity, {
|
|
2190
|
+
labels,
|
|
2191
|
+
onAddToCart,
|
|
2192
|
+
onRemoveFromCart
|
|
2193
|
+
}) {
|
|
2194
|
+
const last = quantity === 1;
|
|
2195
|
+
return T`
|
|
2196
|
+
<div
|
|
2197
|
+
class="product-action product-stepper"
|
|
2198
|
+
role="group"
|
|
2199
|
+
aria-label=${labels.cartQuantity}
|
|
2200
|
+
>
|
|
2201
|
+
<button
|
|
2202
|
+
type="button"
|
|
2203
|
+
class="product-stepper-button product-stepper-remove"
|
|
2204
|
+
aria-label=${last ? labels.removeFromCart : labels.decreaseQuantity}
|
|
2205
|
+
@click=${onRemoveFromCart}
|
|
2206
|
+
>
|
|
2207
|
+
${icon(last ? "trash" : "minus")}
|
|
2208
|
+
</button>
|
|
2209
|
+
<span class="product-quantity">${quantity}</span>
|
|
2210
|
+
<button
|
|
2211
|
+
type="button"
|
|
2212
|
+
class="product-stepper-button ${STEPPER_ADD_CLASS}"
|
|
2213
|
+
aria-label=${labels.increaseQuantity}
|
|
2214
|
+
@click=${onAddToCart}
|
|
2215
|
+
>
|
|
2216
|
+
${icon("plus")}
|
|
2217
|
+
</button>
|
|
2218
|
+
</div>
|
|
2219
|
+
`;
|
|
2220
|
+
}
|
|
2221
|
+
function renderAddToCart({ isLoading, soldOut, sku }, options) {
|
|
2222
|
+
const { labels, onAddToCart, cartQuantity = 0 } = options;
|
|
2223
|
+
if (!sku || !onAddToCart) return A;
|
|
2224
|
+
if (isLoading) return addToCartSkeleton;
|
|
2225
|
+
if (soldOut) {
|
|
2226
|
+
return T`
|
|
2227
|
+
<button type="button" class="product-action product-unavailable" disabled>
|
|
2228
|
+
${labels.unavailable}
|
|
2229
|
+
</button>
|
|
2230
|
+
`;
|
|
2231
|
+
}
|
|
2232
|
+
if (cartQuantity > 0) return renderStepper(cartQuantity, options);
|
|
2233
|
+
return T`
|
|
2234
|
+
<button
|
|
2235
|
+
type="button"
|
|
2236
|
+
class="product-action ${ADD_TO_CART_CLASS}"
|
|
2237
|
+
@click=${onAddToCart}
|
|
2238
|
+
>
|
|
2239
|
+
${labels.addToCart}
|
|
2240
|
+
</button>
|
|
2241
|
+
`;
|
|
2242
|
+
}
|
|
2243
|
+
function renderCartStatus({ sku }, { labels, cartQuantity = 0, onAddToCart }) {
|
|
2244
|
+
if (!sku || !onAddToCart) return A;
|
|
2245
|
+
return T`
|
|
2246
|
+
<span class="product-cart-status" role="status">
|
|
2247
|
+
${cartQuantity > 0 ? `${labels.cartQuantity}: ${cartQuantity}` : ""}
|
|
2248
|
+
</span>
|
|
2249
|
+
`;
|
|
2250
|
+
}
|
|
2251
|
+
function renderExpandableProduct(product, options) {
|
|
2252
|
+
const { open } = options;
|
|
2253
|
+
return T`
|
|
2254
|
+
<div class="card-product product-expandable" ?data-open=${open}>
|
|
2255
|
+
<button
|
|
2256
|
+
type="button"
|
|
2257
|
+
class="product-summary"
|
|
2258
|
+
aria-label=${product.label}
|
|
2259
|
+
aria-expanded=${open ? "true" : "false"}
|
|
2260
|
+
aria-controls=${options.panelId}
|
|
2261
|
+
@click=${options.onToggle}
|
|
2262
|
+
>
|
|
2263
|
+
${renderSummary(product)}
|
|
2264
|
+
<span class="product-toggle">${icon("caretUp")}</span>
|
|
2265
|
+
</button>
|
|
2266
|
+
<div id=${options.panelId} class="product-panel" ?inert=${!open}>
|
|
2267
|
+
<div class="product-actions">
|
|
2268
|
+
${renderCartStatus(product, options)}
|
|
2269
|
+
${renderAddToCart(product, options)}
|
|
2270
|
+
${product.url ? T`
|
|
2271
|
+
<a
|
|
2272
|
+
class="product-action product-view"
|
|
2273
|
+
href=${product.url}
|
|
2274
|
+
target="_blank"
|
|
2275
|
+
rel="noopener noreferrer"
|
|
2276
|
+
>
|
|
2277
|
+
${options.labels.viewProduct}
|
|
2278
|
+
</a>
|
|
2279
|
+
` : A}
|
|
2280
|
+
</div>
|
|
2281
|
+
</div>
|
|
2282
|
+
</div>
|
|
2283
|
+
`;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
// src/components/product/cta.ts
|
|
2287
|
+
function toCardCta(story) {
|
|
2288
|
+
var _a13;
|
|
2289
|
+
if (story.product) return void 0;
|
|
2290
|
+
const label = (_a13 = story.call_to_action) == null ? void 0 : _a13.trim();
|
|
2291
|
+
const url = destinationUrl(story.destination_url);
|
|
2292
|
+
return label && url ? { label, url } : void 0;
|
|
2293
|
+
}
|
|
2294
|
+
function renderCta(cta, onSelect) {
|
|
2295
|
+
const onClick = onSelect ? (event) => {
|
|
2296
|
+
event.preventDefault();
|
|
2297
|
+
onSelect();
|
|
2298
|
+
} : void 0;
|
|
2299
|
+
return T`
|
|
2300
|
+
<a
|
|
2301
|
+
class="card-cta"
|
|
2302
|
+
href=${cta.url}
|
|
2303
|
+
target="_blank"
|
|
2304
|
+
rel="noopener noreferrer"
|
|
2305
|
+
@click=${onClick}
|
|
2306
|
+
>
|
|
2307
|
+
<span class="cta-label">${cta.label}</span>
|
|
2308
|
+
${icon("next")}
|
|
2309
|
+
</a>
|
|
2310
|
+
`;
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2313
|
+
// src/components/product/product.styles.ts
|
|
2314
|
+
var productStyles = i`
|
|
2315
|
+
/* A glass pill at the bottom of the card, above its button: the product or
|
|
2316
|
+
the call to action. */
|
|
2317
|
+
.card-product,
|
|
2318
|
+
.card-cta {
|
|
2319
|
+
position: absolute;
|
|
2320
|
+
right: 12px;
|
|
2321
|
+
bottom: 12px;
|
|
2322
|
+
left: 12px;
|
|
2323
|
+
z-index: 1;
|
|
2324
|
+
display: flex;
|
|
2325
|
+
gap: 8px;
|
|
2326
|
+
align-items: center;
|
|
2327
|
+
box-sizing: border-box;
|
|
2328
|
+
padding: var(--_pill-inset);
|
|
2329
|
+
border: 0;
|
|
2330
|
+
border-radius: var(--_pill-radius);
|
|
2331
|
+
background: rgba(255, 255, 255, 0.15);
|
|
2332
|
+
backdrop-filter: blur(5px);
|
|
2333
|
+
color: #fff;
|
|
2334
|
+
font: inherit;
|
|
2335
|
+
text-align: left;
|
|
2336
|
+
isolation: isolate;
|
|
2337
|
+
transition: transform 0.2s ease;
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
/* The glass's tint and inner light, darker on hover. */
|
|
2341
|
+
.card-product::before,
|
|
2342
|
+
.card-cta::before {
|
|
2343
|
+
position: absolute;
|
|
2344
|
+
inset: 0;
|
|
2345
|
+
z-index: -1;
|
|
2346
|
+
border-radius: inherit;
|
|
2347
|
+
background: rgba(0, 0, 0, 0.15);
|
|
2348
|
+
box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);
|
|
2349
|
+
content: "";
|
|
2350
|
+
transition: background-color 0.2s ease;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
button.card-product,
|
|
2354
|
+
.card-cta {
|
|
2355
|
+
cursor: pointer;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
.card-product:focus-visible,
|
|
2359
|
+
.card-cta:focus-visible {
|
|
2360
|
+
outline: 2px solid #fff;
|
|
2361
|
+
outline-offset: 2px;
|
|
2362
|
+
}
|
|
2363
|
+
|
|
2364
|
+
@media (hover: hover) and (pointer: fine) {
|
|
2365
|
+
.card-product:hover,
|
|
2366
|
+
.card-cta:hover {
|
|
2367
|
+
transform: translateY(-2px);
|
|
2368
|
+
}
|
|
2369
|
+
|
|
2370
|
+
.card-product:hover::before,
|
|
2371
|
+
.card-cta:hover::before {
|
|
2372
|
+
background: rgba(0, 0, 0, 0.32);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
/* A Story with a link: the pill is the call to action, its text centered
|
|
2377
|
+
with a caret after it. */
|
|
2378
|
+
.card-cta {
|
|
2379
|
+
justify-content: center;
|
|
2380
|
+
gap: 6px;
|
|
2381
|
+
height: 48px;
|
|
2382
|
+
padding: 0 16px;
|
|
2383
|
+
font-size: 14px;
|
|
2384
|
+
font-weight: 700;
|
|
2385
|
+
line-height: 1;
|
|
2386
|
+
text-decoration: none;
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
.cta-label {
|
|
2390
|
+
min-width: 0;
|
|
2391
|
+
overflow: hidden;
|
|
2392
|
+
text-overflow: ellipsis;
|
|
2393
|
+
white-space: nowrap;
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
.card-cta .icon {
|
|
2397
|
+
flex: none;
|
|
2398
|
+
width: 14px;
|
|
2399
|
+
height: 14px;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
/* In the player: the pill is a toggle, with the actions panel below. */
|
|
2403
|
+
.product-expandable {
|
|
2404
|
+
display: block;
|
|
2405
|
+
padding: 0;
|
|
2406
|
+
transition:
|
|
2407
|
+
background-color 0.3s ease,
|
|
2408
|
+
color 0.3s ease,
|
|
2409
|
+
box-shadow 0.3s ease,
|
|
2410
|
+
transform 0.2s ease;
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
.product-expandable::before {
|
|
2414
|
+
transition:
|
|
2415
|
+
opacity 0.3s ease,
|
|
2416
|
+
background-color 0.2s ease;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
.product-summary {
|
|
2420
|
+
display: flex;
|
|
2421
|
+
gap: 8px;
|
|
2422
|
+
align-items: center;
|
|
2423
|
+
box-sizing: border-box;
|
|
2424
|
+
width: 100%;
|
|
2425
|
+
padding: var(--_pill-inset);
|
|
2426
|
+
border: 0;
|
|
2427
|
+
border-radius: inherit;
|
|
2428
|
+
background: transparent;
|
|
2429
|
+
color: inherit;
|
|
2430
|
+
font: inherit;
|
|
2431
|
+
text-align: left;
|
|
2432
|
+
cursor: pointer;
|
|
2433
|
+
transition: padding 0.3s ease;
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
.product-summary:focus-visible {
|
|
2437
|
+
outline: 2px solid currentColor;
|
|
2438
|
+
outline-offset: 2px;
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
/* The caret points up while closed and down while open. */
|
|
2442
|
+
.product-toggle {
|
|
2443
|
+
display: grid;
|
|
2444
|
+
flex: none;
|
|
2445
|
+
margin-right: 4px;
|
|
2446
|
+
opacity: 0.7;
|
|
2447
|
+
transition:
|
|
2448
|
+
transform 0.3s ease,
|
|
2449
|
+
opacity 0.2s ease;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
.product-toggle .icon {
|
|
2453
|
+
width: 14px;
|
|
2454
|
+
height: 14px;
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2457
|
+
.product-summary:hover .product-toggle {
|
|
2458
|
+
opacity: 1;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
/* Closed: 0 rows tall, so it grows smoothly when it opens. */
|
|
2462
|
+
.product-panel {
|
|
2463
|
+
display: grid;
|
|
2464
|
+
grid-template-rows: 0fr;
|
|
2465
|
+
transition: grid-template-rows 0.3s ease;
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
.product-actions {
|
|
2469
|
+
display: grid;
|
|
2470
|
+
gap: 8px;
|
|
2471
|
+
min-height: 0;
|
|
2472
|
+
overflow: hidden;
|
|
2473
|
+
padding: 0 12px;
|
|
2474
|
+
opacity: 0;
|
|
2475
|
+
transition:
|
|
2476
|
+
padding 0.3s ease,
|
|
2477
|
+
opacity 0.2s ease;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
.product-action {
|
|
2481
|
+
display: flex;
|
|
2482
|
+
align-items: center;
|
|
2483
|
+
justify-content: center;
|
|
2484
|
+
box-sizing: border-box;
|
|
2485
|
+
height: 48px;
|
|
2486
|
+
padding: 0 16px;
|
|
2487
|
+
border: 1px solid var(--vtex-ads-story-color-accent, #1b75a8);
|
|
2488
|
+
border-radius: var(--_button-radius);
|
|
2489
|
+
font: inherit;
|
|
2490
|
+
font-size: 14px;
|
|
2491
|
+
font-weight: 700;
|
|
2492
|
+
text-decoration: none;
|
|
2493
|
+
cursor: pointer;
|
|
2494
|
+
transition: background-color 0.2s ease;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
.product-action:focus-visible {
|
|
2498
|
+
outline: 2px solid var(--vtex-ads-story-color-accent, #1b75a8);
|
|
2499
|
+
outline-offset: 2px;
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
.product-add-to-cart {
|
|
2503
|
+
background: var(--vtex-ads-story-color-accent, #1b75a8);
|
|
2504
|
+
color: var(--vtex-ads-story-color-accent-contrast, #fff);
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
.product-add-to-cart:hover {
|
|
2508
|
+
background: color-mix(
|
|
2509
|
+
in srgb,
|
|
2510
|
+
var(--vtex-ads-story-color-accent, #1b75a8) 85%,
|
|
2511
|
+
#000
|
|
2512
|
+
);
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
/* In the cart: the add to cart button's pill, with minus and plus at its
|
|
2516
|
+
ends and the quantity between them. */
|
|
2517
|
+
.product-stepper {
|
|
2518
|
+
justify-content: space-between;
|
|
2519
|
+
padding: 0;
|
|
2520
|
+
background: var(--vtex-ads-story-color-accent, #1b75a8);
|
|
2521
|
+
color: var(--vtex-ads-story-color-accent-contrast, #fff);
|
|
2522
|
+
cursor: auto;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
.product-stepper-button {
|
|
2526
|
+
display: grid;
|
|
2527
|
+
flex: none;
|
|
2528
|
+
place-items: center;
|
|
2529
|
+
width: 46px;
|
|
2530
|
+
height: 46px;
|
|
2531
|
+
padding: 0;
|
|
2532
|
+
border: 0;
|
|
2533
|
+
border-radius: var(--_button-radius);
|
|
2534
|
+
background: transparent;
|
|
2535
|
+
color: inherit;
|
|
2536
|
+
cursor: pointer;
|
|
2537
|
+
transition: background-color 0.2s ease;
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
.product-stepper-button .icon {
|
|
2541
|
+
width: 18px;
|
|
2542
|
+
height: 18px;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
.product-stepper-button:hover {
|
|
2546
|
+
background: rgba(0, 0, 0, 0.15);
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
.product-stepper-button:focus-visible {
|
|
2550
|
+
outline: 2px solid var(--vtex-ads-story-color-accent-contrast, #fff);
|
|
2551
|
+
outline-offset: -4px;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
.product-quantity {
|
|
2555
|
+
flex: 1;
|
|
2556
|
+
min-width: 0;
|
|
2557
|
+
font-size: 16px;
|
|
2558
|
+
text-align: center;
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
.product-cart-status {
|
|
2562
|
+
position: absolute;
|
|
2563
|
+
width: 1px;
|
|
2564
|
+
height: 1px;
|
|
2565
|
+
margin: -1px;
|
|
2566
|
+
overflow: hidden;
|
|
2567
|
+
clip-path: inset(50%);
|
|
2568
|
+
white-space: nowrap;
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
/* Sold out: add to cart, disabled and grayed. */
|
|
2572
|
+
.product-unavailable {
|
|
2573
|
+
border-color: transparent;
|
|
2574
|
+
background: rgba(0, 0, 0, 0.06);
|
|
2575
|
+
color: var(--vtex-ads-story-color-muted, #6b6b6b);
|
|
2576
|
+
cursor: not-allowed;
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
.product-view {
|
|
2580
|
+
background: var(--vtex-ads-story-color-surface, #fff);
|
|
2581
|
+
color: var(--vtex-ads-story-color-accent, #1b75a8);
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
/* A light tint of the accent. */
|
|
2585
|
+
.product-view:hover {
|
|
2586
|
+
background: color-mix(
|
|
2587
|
+
in srgb,
|
|
2588
|
+
var(--vtex-ads-story-color-accent, #1b75a8) 8%,
|
|
2589
|
+
var(--vtex-ads-story-color-surface, #fff)
|
|
2590
|
+
);
|
|
2591
|
+
}
|
|
2592
|
+
|
|
2593
|
+
/* Open: a solid card (white by default), without the glass. */
|
|
2594
|
+
.product-expandable[data-open] {
|
|
2595
|
+
background: var(--vtex-ads-story-color-surface, #fff);
|
|
2596
|
+
color: var(--vtex-ads-story-color-text, #242424);
|
|
2597
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
.product-expandable[data-open]::before {
|
|
2601
|
+
opacity: 0;
|
|
2602
|
+
}
|
|
2603
|
+
|
|
2604
|
+
.product-expandable[data-open] .product-price {
|
|
2605
|
+
color: inherit;
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
.product-expandable[data-open] .product-list-price {
|
|
2609
|
+
color: var(--vtex-ads-story-color-muted, #6b6b6b);
|
|
2610
|
+
opacity: 1;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
.product-expandable[data-open] .product-summary {
|
|
2614
|
+
padding: 12px;
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
.product-expandable[data-open] .product-toggle {
|
|
2618
|
+
transform: rotate(180deg);
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
.product-expandable[data-open] .product-panel {
|
|
2622
|
+
grid-template-rows: 1fr;
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
.product-expandable[data-open] .product-actions {
|
|
2626
|
+
padding: 0 12px 12px;
|
|
2627
|
+
opacity: 1;
|
|
2628
|
+
transition:
|
|
2629
|
+
padding 0.3s ease,
|
|
2630
|
+
opacity 0.25s ease 0.1s;
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2633
|
+
/* Open, it stays in place on hover. */
|
|
2634
|
+
@media (hover: hover) and (pointer: fine) {
|
|
2635
|
+
.product-expandable[data-open]:hover {
|
|
2636
|
+
transform: none;
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2641
|
+
.card-product,
|
|
2642
|
+
.card-product:hover,
|
|
2643
|
+
.card-cta,
|
|
2644
|
+
.card-cta:hover {
|
|
2645
|
+
transform: none;
|
|
2646
|
+
transition: none;
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
.card-product::before,
|
|
2650
|
+
.card-cta::before,
|
|
2651
|
+
.product-summary,
|
|
2652
|
+
.product-toggle,
|
|
2653
|
+
.product-panel,
|
|
2654
|
+
.product-actions,
|
|
2655
|
+
.product-expandable[data-open] .product-actions {
|
|
2656
|
+
transition: none;
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
/* Its corners follow the pill's, one inset in from them: 8px by default. */
|
|
2661
|
+
.product-image {
|
|
2662
|
+
flex: none;
|
|
2663
|
+
width: 60px;
|
|
2664
|
+
height: 60px;
|
|
2665
|
+
border-radius: max(0px, var(--_pill-radius) - var(--_pill-inset));
|
|
2666
|
+
background: #fff;
|
|
2667
|
+
object-fit: contain;
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
.product-info {
|
|
2671
|
+
display: grid;
|
|
2672
|
+
flex: 1;
|
|
2673
|
+
gap: 4px;
|
|
2674
|
+
min-width: 0;
|
|
2675
|
+
font-size: 12px;
|
|
2676
|
+
font-weight: 700;
|
|
2677
|
+
line-height: 16px;
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
.product-name {
|
|
2681
|
+
display: -webkit-box;
|
|
2682
|
+
overflow: hidden;
|
|
2683
|
+
-webkit-box-orient: vertical;
|
|
2684
|
+
-webkit-line-clamp: 2;
|
|
2685
|
+
overflow-wrap: anywhere;
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
.product-price {
|
|
2689
|
+
display: flex;
|
|
2690
|
+
flex-wrap: wrap;
|
|
2691
|
+
gap: 0 6px;
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
.product-list-price {
|
|
2695
|
+
font-weight: 400;
|
|
2696
|
+
opacity: 0.5;
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
/* In place of the price, for a product that can't be bought. */
|
|
2700
|
+
.product-sold-out {
|
|
2701
|
+
font-weight: 700;
|
|
2702
|
+
opacity: 0.75;
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
/* Placeholders while the product loads, pulsing gently. */
|
|
2706
|
+
.product-loading {
|
|
2707
|
+
background: currentColor;
|
|
2708
|
+
opacity: 0.25;
|
|
2709
|
+
animation: product-loading-pulse 1.2s ease-in-out infinite alternate;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
@keyframes product-loading-pulse {
|
|
2713
|
+
to {
|
|
2714
|
+
opacity: 0.1;
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
/* The price's: a line its height (the info's line height). */
|
|
2719
|
+
.product-price-loading {
|
|
2720
|
+
width: 64px;
|
|
2721
|
+
height: 16px;
|
|
2722
|
+
border-radius: 4px;
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2725
|
+
/* The add to cart button's: its size and shape. */
|
|
2726
|
+
.product-add-to-cart-loading {
|
|
2727
|
+
display: block;
|
|
2728
|
+
height: 48px;
|
|
2729
|
+
border-radius: var(--_button-radius);
|
|
2730
|
+
}
|
|
2731
|
+
|
|
2732
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2733
|
+
.product-loading {
|
|
2734
|
+
animation: none;
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
`;
|
|
2738
|
+
|
|
1588
2739
|
// src/components/card/card.ts
|
|
1589
2740
|
var cardStyles = i`
|
|
2741
|
+
/* 9:16 at the height its container gives it (--card-height, default
|
|
2742
|
+
500px). */
|
|
1590
2743
|
.card {
|
|
1591
2744
|
position: relative;
|
|
1592
2745
|
box-sizing: border-box;
|
|
1593
|
-
width: calc(500px * 9 / 16);
|
|
1594
|
-
height: 500px;
|
|
1595
|
-
overflow: hidden;
|
|
2746
|
+
width: calc(var(--card-height, 500px) * 9 / 16);
|
|
2747
|
+
height: var(--card-height, 500px);
|
|
2748
|
+
overflow: hidden;
|
|
2749
|
+
border-radius: var(--vtex-ads-story-radius, 20px);
|
|
2750
|
+
background: #000;
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
/* The card's button covers it. The focus ring goes on the card, since the
|
|
2754
|
+
card's overflow would clip the button's own. */
|
|
2755
|
+
.card-open {
|
|
2756
|
+
position: absolute;
|
|
2757
|
+
inset: 0;
|
|
2758
|
+
width: 100%;
|
|
2759
|
+
height: 100%;
|
|
2760
|
+
padding: 0;
|
|
2761
|
+
border: 0;
|
|
2762
|
+
background: transparent;
|
|
2763
|
+
cursor: pointer;
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
.card-open:focus-visible {
|
|
2767
|
+
outline: none;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
.card:has(> .card-open:focus-visible) {
|
|
2771
|
+
outline: auto;
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
.poster,
|
|
2775
|
+
.video {
|
|
2776
|
+
position: absolute;
|
|
2777
|
+
inset: 0;
|
|
2778
|
+
width: 100%;
|
|
2779
|
+
height: 100%;
|
|
2780
|
+
object-fit: cover;
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
.play {
|
|
2784
|
+
position: absolute;
|
|
2785
|
+
top: 50%;
|
|
2786
|
+
left: 50%;
|
|
2787
|
+
display: grid;
|
|
2788
|
+
width: 66px;
|
|
2789
|
+
height: 66px;
|
|
2790
|
+
place-items: center;
|
|
2791
|
+
border-radius: 50%;
|
|
2792
|
+
background:
|
|
2793
|
+
linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),
|
|
2794
|
+
rgba(255, 255, 255, 0.15);
|
|
2795
|
+
backdrop-filter: blur(2px);
|
|
2796
|
+
box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);
|
|
2797
|
+
transform: translate(-50%, -50%);
|
|
2798
|
+
transition:
|
|
2799
|
+
opacity 0.3s ease,
|
|
2800
|
+
transform 0.3s ease;
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
/* The icon's triangle is 18px tall and already sits slightly right of its
|
|
2804
|
+
box, so it looks centered in the circle. */
|
|
2805
|
+
.play .icon {
|
|
2806
|
+
width: 22px;
|
|
2807
|
+
height: 22px;
|
|
2808
|
+
color: #fff;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
/* Sound on/off, at the top right of the card (as in the prototype). */
|
|
2812
|
+
.card-sound {
|
|
2813
|
+
position: absolute;
|
|
2814
|
+
top: 22px;
|
|
2815
|
+
right: 12px;
|
|
2816
|
+
z-index: 1;
|
|
2817
|
+
display: grid;
|
|
2818
|
+
width: 28px;
|
|
2819
|
+
height: 28px;
|
|
2820
|
+
place-items: center;
|
|
2821
|
+
padding: 0;
|
|
2822
|
+
border: 0;
|
|
2823
|
+
background: transparent;
|
|
2824
|
+
color: #fff;
|
|
2825
|
+
cursor: pointer;
|
|
2826
|
+
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
.card-sound .icon {
|
|
2830
|
+
width: 20px;
|
|
2831
|
+
height: 20px;
|
|
2832
|
+
}
|
|
2833
|
+
|
|
2834
|
+
/* With a mouse, the play button shows only on hover or keyboard focus.
|
|
2835
|
+
Touch screens have no hover, so it stays visible there. */
|
|
2836
|
+
@media (hover: hover) and (pointer: fine) {
|
|
2837
|
+
.play {
|
|
2838
|
+
opacity: 0;
|
|
2839
|
+
transform: translate(-50%, -50%) scale(0.9);
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
.card:hover .play,
|
|
2843
|
+
.card-open:focus-visible .play {
|
|
2844
|
+
opacity: 1;
|
|
2845
|
+
transform: translate(-50%, -50%);
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
`;
|
|
2849
|
+
function renderSoundButton(video, options) {
|
|
2850
|
+
return T`
|
|
2851
|
+
<button
|
|
2852
|
+
type="button"
|
|
2853
|
+
class="card-sound"
|
|
2854
|
+
aria-label=${video.muted ? options.labels.soundOn : options.labels.soundOff}
|
|
2855
|
+
@click=${() => video.toggleMuted()}
|
|
2856
|
+
>
|
|
2857
|
+
${icon(video.muted ? "soundOff" : "soundOn")}
|
|
2858
|
+
</button>
|
|
2859
|
+
`;
|
|
2860
|
+
}
|
|
2861
|
+
function renderCard(story, video, options) {
|
|
2862
|
+
var _a13, _b3;
|
|
2863
|
+
const withVideo = (_a13 = options.withVideo) != null ? _a13 : true;
|
|
2864
|
+
return T`
|
|
2865
|
+
<div
|
|
2866
|
+
class="card"
|
|
2867
|
+
${n5(options.ref)}
|
|
2868
|
+
@click=${{ handleEvent: () => {
|
|
2869
|
+
var _a14;
|
|
2870
|
+
return (_a14 = options.onPress) == null ? void 0 : _a14.call(options);
|
|
2871
|
+
}, capture: true }}
|
|
2872
|
+
>
|
|
2873
|
+
${renderMedia(story, video, {
|
|
2874
|
+
withVideo,
|
|
2875
|
+
autoplay: options.autoplay,
|
|
2876
|
+
labels: options.labels,
|
|
2877
|
+
announce: false
|
|
2878
|
+
})}
|
|
2879
|
+
<button
|
|
2880
|
+
type="button"
|
|
2881
|
+
class="card-open"
|
|
2882
|
+
${n5(options.openRef)}
|
|
2883
|
+
aria-label=${options.label}
|
|
2884
|
+
@click=${options.onSelect}
|
|
2885
|
+
>
|
|
2886
|
+
${withVideo && video.failed ? A : T`<span class="play" aria-hidden="true">${icon("play")}</span>`}
|
|
2887
|
+
</button>
|
|
2888
|
+
${withVideo && hasVideo(story, video) && !video.paused ? renderSoundButton(video, options) : A}
|
|
2889
|
+
${options.product ? renderProduct(
|
|
2890
|
+
options.product,
|
|
2891
|
+
(_b3 = options.onProductSelect) != null ? _b3 : options.onSelect
|
|
2892
|
+
) : A}
|
|
2893
|
+
${options.cta ? renderCta(options.cta, options.onCtaSelect) : A}
|
|
2894
|
+
</div>
|
|
2895
|
+
`;
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/repeat.js
|
|
2899
|
+
var u4 = (e6, s6, t5) => {
|
|
2900
|
+
const r6 = /* @__PURE__ */ new Map();
|
|
2901
|
+
for (let l3 = s6; l3 <= t5; l3++) r6.set(e6[l3], l3);
|
|
2902
|
+
return r6;
|
|
2903
|
+
};
|
|
2904
|
+
var c5 = e3(class extends i5 {
|
|
2905
|
+
constructor(e6) {
|
|
2906
|
+
if (super(e6), e6.type !== t4.CHILD) throw Error("repeat() can only be used in text expressions");
|
|
2907
|
+
}
|
|
2908
|
+
dt(e6, s6, t5) {
|
|
2909
|
+
let r6;
|
|
2910
|
+
void 0 === t5 ? t5 = s6 : void 0 !== s6 && (r6 = s6);
|
|
2911
|
+
const l3 = [], o9 = [];
|
|
2912
|
+
let i7 = 0;
|
|
2913
|
+
for (const s7 of e6) l3[i7] = r6 ? r6(s7, i7) : i7, o9[i7] = t5(s7, i7), i7++;
|
|
2914
|
+
return { values: o9, keys: l3 };
|
|
2915
|
+
}
|
|
2916
|
+
render(e6, s6, t5) {
|
|
2917
|
+
return this.dt(e6, s6, t5).values;
|
|
2918
|
+
}
|
|
2919
|
+
update(s6, [t5, r6, c6]) {
|
|
2920
|
+
var _a13;
|
|
2921
|
+
const d3 = M2(s6), { values: p4, keys: a3 } = this.dt(t5, r6, c6);
|
|
2922
|
+
if (!Array.isArray(d3)) return this.ut = a3, p4;
|
|
2923
|
+
const h6 = (_a13 = this.ut) != null ? _a13 : this.ut = [], v3 = [];
|
|
2924
|
+
let m4, y3, x2 = 0, j2 = d3.length - 1, k2 = 0, w2 = p4.length - 1;
|
|
2925
|
+
for (; x2 <= j2 && k2 <= w2; ) if (null === d3[x2]) x2++;
|
|
2926
|
+
else if (null === d3[j2]) j2--;
|
|
2927
|
+
else if (h6[x2] === a3[k2]) v3[k2] = u3(d3[x2], p4[k2]), x2++, k2++;
|
|
2928
|
+
else if (h6[j2] === a3[w2]) v3[w2] = u3(d3[j2], p4[w2]), j2--, w2--;
|
|
2929
|
+
else if (h6[x2] === a3[w2]) v3[w2] = u3(d3[x2], p4[w2]), v2(s6, v3[w2 + 1], d3[x2]), x2++, w2--;
|
|
2930
|
+
else if (h6[j2] === a3[k2]) v3[k2] = u3(d3[j2], p4[k2]), v2(s6, d3[x2], d3[j2]), j2--, k2++;
|
|
2931
|
+
else if (void 0 === m4 && (m4 = u4(a3, k2, w2), y3 = u4(h6, x2, j2)), m4.has(h6[x2])) if (m4.has(h6[j2])) {
|
|
2932
|
+
const e6 = y3.get(a3[k2]), t6 = void 0 !== e6 ? d3[e6] : null;
|
|
2933
|
+
if (null === t6) {
|
|
2934
|
+
const e7 = v2(s6, d3[x2]);
|
|
2935
|
+
u3(e7, p4[k2]), v3[k2] = e7;
|
|
2936
|
+
} else v3[k2] = u3(t6, p4[k2]), v2(s6, d3[x2], t6), d3[e6] = null;
|
|
2937
|
+
k2++;
|
|
2938
|
+
} else h3(d3[j2]), j2--;
|
|
2939
|
+
else h3(d3[x2]), x2++;
|
|
2940
|
+
for (; k2 <= w2; ) {
|
|
2941
|
+
const e6 = v2(s6, v3[w2 + 1]);
|
|
2942
|
+
u3(e6, p4[k2]), v3[k2++] = e6;
|
|
2943
|
+
}
|
|
2944
|
+
for (; x2 <= j2; ) {
|
|
2945
|
+
const e6 = d3[x2++];
|
|
2946
|
+
null !== e6 && h3(e6);
|
|
2947
|
+
}
|
|
2948
|
+
return this.ut = a3, p3(s6, v3), E;
|
|
2949
|
+
}
|
|
2950
|
+
});
|
|
2951
|
+
|
|
2952
|
+
// ../../node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/node/directives/style-map.js
|
|
2953
|
+
var n6 = "important";
|
|
2954
|
+
var i6 = " !" + n6;
|
|
2955
|
+
var o8 = e3(class extends i5 {
|
|
2956
|
+
constructor(t5) {
|
|
2957
|
+
var _a13;
|
|
2958
|
+
if (super(t5), t5.type !== t4.ATTRIBUTE || "style" !== t5.name || ((_a13 = t5.strings) == null ? void 0 : _a13.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
|
|
2959
|
+
}
|
|
2960
|
+
render(t5) {
|
|
2961
|
+
return Object.keys(t5).reduce((e6, r6) => {
|
|
2962
|
+
const s6 = t5[r6];
|
|
2963
|
+
return null == s6 ? e6 : e6 + `${r6 = r6.includes("-") ? r6 : r6.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s6};`;
|
|
2964
|
+
}, "");
|
|
2965
|
+
}
|
|
2966
|
+
update(e6, [r6]) {
|
|
2967
|
+
const { style: s6 } = e6.element;
|
|
2968
|
+
if (void 0 === this.ft) return this.ft = new Set(Object.keys(r6)), this.render(r6);
|
|
2969
|
+
for (const t5 of this.ft) null == r6[t5] && (this.ft.delete(t5), t5.includes("-") ? s6.removeProperty(t5) : s6[t5] = null);
|
|
2970
|
+
for (const t5 in r6) {
|
|
2971
|
+
const e7 = r6[t5];
|
|
2972
|
+
if (null != e7) {
|
|
2973
|
+
this.ft.add(t5);
|
|
2974
|
+
const r7 = "string" == typeof e7 && e7.endsWith(i6);
|
|
2975
|
+
t5.includes("-") || r7 ? s6.setProperty(t5, r7 ? e7.slice(0, -11) : e7, r7 ? n6 : "") : s6[t5] = e7;
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
return E;
|
|
2979
|
+
}
|
|
2980
|
+
});
|
|
2981
|
+
|
|
2982
|
+
// src/components/carousel/carousel.ts
|
|
2983
|
+
var STAGE_HEIGHT = i`500px`;
|
|
2984
|
+
var SOLO_PADDING = i`24px`;
|
|
2985
|
+
var AUTO_ADVANCE_MS = 5e3;
|
|
2986
|
+
var MIN_SLIDE_DURATION_MS = 2e3;
|
|
2987
|
+
var MAX_SLIDE_DURATION_MS = 12e4;
|
|
2988
|
+
var toSlideDuration = (ms) => {
|
|
2989
|
+
if (ms === void 0 || !Number.isFinite(ms) || ms < 0) {
|
|
2990
|
+
return AUTO_ADVANCE_MS;
|
|
2991
|
+
}
|
|
2992
|
+
if (ms === 0) {
|
|
2993
|
+
return 0;
|
|
2994
|
+
}
|
|
2995
|
+
return Math.min(Math.max(ms, MIN_SLIDE_DURATION_MS), MAX_SLIDE_DURATION_MS);
|
|
2996
|
+
};
|
|
2997
|
+
var SWIPE_DISTANCE = 40;
|
|
2998
|
+
var NARROW_SCREEN = i`(max-width: 576px)`;
|
|
2999
|
+
var VISIBLE_SIDE = 2;
|
|
3000
|
+
var RENDERED_SIDE = VISIBLE_SIDE + 3;
|
|
3001
|
+
var carouselStyles = i`
|
|
3002
|
+
.carousel {
|
|
3003
|
+
position: relative;
|
|
3004
|
+
box-sizing: border-box;
|
|
3005
|
+
display: grid;
|
|
3006
|
+
height: ${STAGE_HEIGHT};
|
|
3007
|
+
place-items: center;
|
|
3008
|
+
--card-height: ${STAGE_HEIGHT};
|
|
3009
|
+
user-select: none;
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
.carousel[data-layout="solo"] {
|
|
3013
|
+
padding: ${SOLO_PADDING};
|
|
1596
3014
|
border-radius: var(--vtex-ads-story-radius, 20px);
|
|
1597
|
-
background: #
|
|
3015
|
+
background: var(--vtex-ads-story-color-surface, #fafafa);
|
|
3016
|
+
--card-height: calc(${STAGE_HEIGHT} - 2 * ${SOLO_PADDING});
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
.carousel[data-layout="solo"] .card {
|
|
3020
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
|
3021
|
+
}
|
|
3022
|
+
|
|
3023
|
+
.track {
|
|
3024
|
+
position: absolute;
|
|
3025
|
+
inset: 0;
|
|
3026
|
+
overflow: hidden;
|
|
3027
|
+
touch-action: pan-y;
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
/* Each slide starts centered, then moves by its own transform. */
|
|
3031
|
+
.slide {
|
|
3032
|
+
--ease: cubic-bezier(0.25, 1, 0.5, 1);
|
|
3033
|
+
--duration: var(--slide-duration, 0.4s);
|
|
3034
|
+
position: absolute;
|
|
3035
|
+
top: 0;
|
|
3036
|
+
left: 50%;
|
|
3037
|
+
width: calc(${STAGE_HEIGHT} * 9 / 16);
|
|
3038
|
+
height: 100%;
|
|
3039
|
+
margin-left: calc(${STAGE_HEIGHT} * 9 / -32);
|
|
3040
|
+
opacity: 0.5;
|
|
3041
|
+
transition:
|
|
3042
|
+
transform var(--duration) var(--ease),
|
|
3043
|
+
opacity var(--duration) var(--ease),
|
|
3044
|
+
visibility 0s;
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
.slide[data-active] {
|
|
3048
|
+
opacity: 1;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
/* Pair: --side is -1 for the first card, 1 for the second. The highlighted
|
|
3052
|
+
card sits 47.5% of its width off center, the other (scaled to 0.9)
|
|
3053
|
+
52.5%, so the gap between them stays 8px. */
|
|
3054
|
+
.carousel[data-layout="pair"] .slide {
|
|
3055
|
+
--side: 1;
|
|
3056
|
+
--offset: 52.5%;
|
|
3057
|
+
--scale: 0.9;
|
|
3058
|
+
transform: translateX(calc(var(--side) * (var(--offset) + 4px)))
|
|
3059
|
+
scale(var(--scale));
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
.carousel[data-layout="pair"] .slide[data-index="0"] {
|
|
3063
|
+
--side: -1;
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
.carousel[data-layout="pair"] .slide[data-active] {
|
|
3067
|
+
--offset: 47.5%;
|
|
3068
|
+
--scale: 1;
|
|
3069
|
+
}
|
|
3070
|
+
|
|
3071
|
+
/* Rolling: --place is the slide's distance from the highlighted one, in
|
|
3072
|
+
cards, 8px apart. A hidden slide fades out, then stops being visible. */
|
|
3073
|
+
.carousel[data-layout="rolling"] .slide {
|
|
3074
|
+
transform: translateX(calc(var(--place) * (100% + 8px))) scale(0.9);
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
.carousel[data-layout="rolling"] .slide[data-active] {
|
|
3078
|
+
transform: translateX(0) scale(1);
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
.slide[data-hidden] {
|
|
3082
|
+
opacity: 0;
|
|
3083
|
+
visibility: hidden;
|
|
3084
|
+
transition:
|
|
3085
|
+
transform var(--duration) var(--ease),
|
|
3086
|
+
opacity var(--duration) var(--ease),
|
|
3087
|
+
visibility 0s var(--duration);
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3090
|
+
/* Only the highlighted card opens the player, so only it shows play. Its
|
|
3091
|
+
sound is the only one to turn on: the others play muted, if at all. */
|
|
3092
|
+
.slide:not([data-active]) .play,
|
|
3093
|
+
.slide:not([data-active]) .card-sound {
|
|
3094
|
+
display: none;
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
.arrow {
|
|
3098
|
+
position: absolute;
|
|
3099
|
+
top: 50%;
|
|
3100
|
+
z-index: 2;
|
|
3101
|
+
display: grid;
|
|
3102
|
+
width: 32px;
|
|
3103
|
+
height: 32px;
|
|
3104
|
+
place-items: center;
|
|
3105
|
+
padding: 0;
|
|
3106
|
+
border: 1px solid rgba(133, 133, 133, 0.3);
|
|
3107
|
+
border-radius: 50%;
|
|
3108
|
+
background: rgba(0, 0, 0, 0.3);
|
|
3109
|
+
backdrop-filter: blur(5px);
|
|
3110
|
+
color: #fff;
|
|
3111
|
+
cursor: pointer;
|
|
3112
|
+
transform: translateY(-50%);
|
|
3113
|
+
transition: background-color 0.2s;
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
.arrow:hover {
|
|
3117
|
+
background: #262626;
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
.arrow:disabled {
|
|
3121
|
+
cursor: default;
|
|
3122
|
+
opacity: 0.5;
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
.arrow .icon {
|
|
3126
|
+
width: 16px;
|
|
3127
|
+
height: 16px;
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
.arrow-previous {
|
|
3131
|
+
left: 3px;
|
|
3132
|
+
}
|
|
3133
|
+
|
|
3134
|
+
.arrow-next {
|
|
3135
|
+
right: 3px;
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
@media ${NARROW_SCREEN} {
|
|
3139
|
+
.carousel[data-layout="solo"] {
|
|
3140
|
+
padding: 0;
|
|
3141
|
+
background: none;
|
|
3142
|
+
--card-height: ${STAGE_HEIGHT};
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
.carousel[data-layout="solo"] .card {
|
|
3146
|
+
box-shadow: none;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3151
|
+
.slide,
|
|
3152
|
+
.slide[data-hidden] {
|
|
3153
|
+
transition: none;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
`;
|
|
3157
|
+
var wrap = (value, count) => (value % count + count) % count;
|
|
3158
|
+
function tracker(elements, slide) {
|
|
3159
|
+
let last;
|
|
3160
|
+
return (element) => {
|
|
3161
|
+
if (last) elements.delete(last);
|
|
3162
|
+
last = element;
|
|
3163
|
+
if (element) elements.set(element, slide);
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
var CarouselController = class {
|
|
3167
|
+
constructor(host, options) {
|
|
3168
|
+
this.host = host;
|
|
3169
|
+
this.options = options;
|
|
3170
|
+
/**
|
|
3171
|
+
* Steps taken since the Stories loaded, back and forth, not wrapped: the
|
|
3172
|
+
* rolling layout keys its slides by it.
|
|
3173
|
+
*/
|
|
3174
|
+
this.position = 0;
|
|
3175
|
+
/** Stories moved by the last step: longer jumps animate a bit slower. */
|
|
3176
|
+
this.distance = 1;
|
|
3177
|
+
this.count = 0;
|
|
3178
|
+
this.narrow = false;
|
|
3179
|
+
this.reducedMotion = false;
|
|
3180
|
+
this.connected = false;
|
|
3181
|
+
this.hovered = false;
|
|
3182
|
+
this.focused = false;
|
|
3183
|
+
/** The interval the running timer was started with. */
|
|
3184
|
+
this.timerMs = 0;
|
|
3185
|
+
/** The rendered cards, as their cardRef reported them. */
|
|
3186
|
+
this.cards = /* @__PURE__ */ new Map();
|
|
3187
|
+
/** The rendered cards' focus targets, as their focusRef reported them. */
|
|
3188
|
+
this.focusTargets = /* @__PURE__ */ new Map();
|
|
3189
|
+
this.onMediaChange = (event) => {
|
|
3190
|
+
var _a13, _b3;
|
|
3191
|
+
const layout = this.layout;
|
|
3192
|
+
this.narrow = event.matches;
|
|
3193
|
+
if (this.layout === layout) return;
|
|
3194
|
+
(_b3 = (_a13 = this.options).onLayoutChange) == null ? void 0 : _b3.call(_a13);
|
|
3195
|
+
this.host.requestUpdate();
|
|
3196
|
+
};
|
|
3197
|
+
this.onPointerEnter = () => {
|
|
3198
|
+
this.hovered = true;
|
|
3199
|
+
this.syncTimer();
|
|
3200
|
+
};
|
|
3201
|
+
this.onPointerLeave = () => {
|
|
3202
|
+
this.hovered = false;
|
|
3203
|
+
this.syncTimer();
|
|
3204
|
+
};
|
|
3205
|
+
// Only keyboard focus stops the advance: a click also focuses the button
|
|
3206
|
+
// it hits, and the advance would then stay stopped after the pointer left.
|
|
3207
|
+
this.onFocusIn = (event) => {
|
|
3208
|
+
this.focused = event.target.matches(":focus-visible");
|
|
3209
|
+
this.syncTimer();
|
|
3210
|
+
};
|
|
3211
|
+
this.onFocusOut = (event) => {
|
|
3212
|
+
const carousel = event.currentTarget;
|
|
3213
|
+
const next = event.relatedTarget;
|
|
3214
|
+
if (!next || !carousel.contains(next)) this.focused = false;
|
|
3215
|
+
this.syncTimer();
|
|
3216
|
+
};
|
|
3217
|
+
// The release is listened for on the window: a mouse drag can end over an
|
|
3218
|
+
// arrow or off the carousel, where the track never gets the pointerup.
|
|
3219
|
+
this.onPointerDown = (event) => {
|
|
3220
|
+
this.endSwipe();
|
|
3221
|
+
this.swipe = { x: event.clientX, moved: false };
|
|
3222
|
+
globalThis.addEventListener("pointerup", this.onPointerUp);
|
|
3223
|
+
globalThis.addEventListener("pointercancel", this.onPointerCancel);
|
|
3224
|
+
};
|
|
3225
|
+
this.onPointerUp = (event) => {
|
|
3226
|
+
const { swipe } = this;
|
|
3227
|
+
this.removeSwipeListeners();
|
|
3228
|
+
if (!swipe) return;
|
|
3229
|
+
const distance = event.clientX - swipe.x;
|
|
3230
|
+
if (Math.abs(distance) > SWIPE_DISTANCE) {
|
|
3231
|
+
swipe.moved = true;
|
|
3232
|
+
this.step(distance < 0 ? 1 : -1);
|
|
3233
|
+
}
|
|
3234
|
+
};
|
|
3235
|
+
this.onPointerCancel = () => this.endSwipe();
|
|
3236
|
+
// A swipe ends with a click on the card under the pointer: it must not
|
|
3237
|
+
// open the player or select that card.
|
|
3238
|
+
this.onClickCapture = {
|
|
3239
|
+
handleEvent: (event) => {
|
|
3240
|
+
var _a13;
|
|
3241
|
+
if ((_a13 = this.swipe) == null ? void 0 : _a13.moved) {
|
|
3242
|
+
event.stopPropagation();
|
|
3243
|
+
event.preventDefault();
|
|
3244
|
+
}
|
|
3245
|
+
this.swipe = void 0;
|
|
3246
|
+
},
|
|
3247
|
+
capture: true
|
|
3248
|
+
};
|
|
3249
|
+
host.addController(this);
|
|
3250
|
+
}
|
|
3251
|
+
/** Index of the highlighted Story. */
|
|
3252
|
+
get active() {
|
|
3253
|
+
return this.count ? wrap(this.position, this.count) : 0;
|
|
3254
|
+
}
|
|
3255
|
+
get layout() {
|
|
3256
|
+
if (this.count < 2) return "solo";
|
|
3257
|
+
return this.count === 2 && !this.narrow ? "pair" : "rolling";
|
|
3258
|
+
}
|
|
3259
|
+
/** Key (see Slide) of the highlighted slide. */
|
|
3260
|
+
get activeKey() {
|
|
3261
|
+
if (this.layout === "rolling") return this.position;
|
|
3262
|
+
return this.active;
|
|
3263
|
+
}
|
|
3264
|
+
/**
|
|
3265
|
+
* The cards on screen, with their slide: not the hidden ones kept for the
|
|
3266
|
+
* slide in.
|
|
3267
|
+
*/
|
|
3268
|
+
*visibleCards() {
|
|
3269
|
+
for (const [card, slide] of this.cards) {
|
|
3270
|
+
if (!slide.hidden) yield [card, slide];
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
/** Moves the keyboard focus to the highlighted card, once rendered. */
|
|
3274
|
+
focusActive() {
|
|
3275
|
+
for (const [target, slide] of this.focusTargets) {
|
|
3276
|
+
if (slide.active && target instanceof HTMLElement) {
|
|
3277
|
+
target.focus();
|
|
3278
|
+
return;
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
hostConnected() {
|
|
3283
|
+
var _a13, _b3, _c, _d, _e, _f, _g;
|
|
3284
|
+
this.connected = true;
|
|
3285
|
+
this.media = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, NARROW_SCREEN.toString());
|
|
3286
|
+
(_b3 = this.media) == null ? void 0 : _b3.addEventListener("change", this.onMediaChange);
|
|
3287
|
+
this.narrow = (_d = (_c = this.media) == null ? void 0 : _c.matches) != null ? _d : false;
|
|
3288
|
+
this.reducedMotion = (_g = (_f = (_e = this.options).reducedMotion) == null ? void 0 : _f.call(_e)) != null ? _g : false;
|
|
3289
|
+
this.syncTimer();
|
|
3290
|
+
}
|
|
3291
|
+
hostDisconnected() {
|
|
3292
|
+
var _a13;
|
|
3293
|
+
this.connected = false;
|
|
3294
|
+
(_a13 = this.media) == null ? void 0 : _a13.removeEventListener("change", this.onMediaChange);
|
|
3295
|
+
this.media = void 0;
|
|
3296
|
+
this.endSwipe();
|
|
3297
|
+
this.syncTimer();
|
|
3298
|
+
}
|
|
3299
|
+
// Whatever the host changed (the player opening, new Stories, the slide
|
|
3300
|
+
// duration) may start, stop or restart the automatic advance.
|
|
3301
|
+
hostUpdated() {
|
|
3302
|
+
this.syncTimer();
|
|
3303
|
+
}
|
|
3304
|
+
/** For a new list of Stories: the first one gets the highlight. */
|
|
3305
|
+
reset(count) {
|
|
3306
|
+
this.count = count;
|
|
3307
|
+
this.position = 0;
|
|
3308
|
+
this.distance = 1;
|
|
3309
|
+
this.hovered = false;
|
|
3310
|
+
this.focused = false;
|
|
3311
|
+
this.restartTimer();
|
|
3312
|
+
}
|
|
3313
|
+
/**
|
|
3314
|
+
* Moves the highlight by `delta` Stories, wrapping around the ends. While
|
|
3315
|
+
* locked, only with `evenIfLocked` (for example, the player stepping to
|
|
3316
|
+
* the next Story it shows).
|
|
3317
|
+
*/
|
|
3318
|
+
step(delta, { evenIfLocked = false } = {}) {
|
|
3319
|
+
var _a13, _b3, _c, _d;
|
|
3320
|
+
if (this.count < 2 || delta === 0) return;
|
|
3321
|
+
if (((_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13)) && !evenIfLocked) return;
|
|
3322
|
+
const from = this.activeKey;
|
|
3323
|
+
this.position += delta;
|
|
3324
|
+
this.distance = Math.abs(delta);
|
|
3325
|
+
this.host.requestUpdate();
|
|
3326
|
+
(_d = (_c = this.options).onStep) == null ? void 0 : _d.call(_c, from, this.activeKey);
|
|
3327
|
+
this.restartTimer();
|
|
3328
|
+
}
|
|
3329
|
+
get slideDuration() {
|
|
3330
|
+
var _a13, _b3;
|
|
3331
|
+
return toSlideDuration((_b3 = (_a13 = this.options).slideDuration) == null ? void 0 : _b3.call(_a13));
|
|
3332
|
+
}
|
|
3333
|
+
get shouldAdvance() {
|
|
3334
|
+
var _a13, _b3;
|
|
3335
|
+
return this.slideDuration > 0 && !this.reducedMotion && this.connected && this.count > 1 && !this.hovered && !this.focused && !((_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13));
|
|
3336
|
+
}
|
|
3337
|
+
syncTimer() {
|
|
3338
|
+
const ms = this.slideDuration;
|
|
3339
|
+
if (this.timer && this.timerMs !== ms) this.stopTimer();
|
|
3340
|
+
if (this.shouldAdvance && !this.timer) {
|
|
3341
|
+
this.timerMs = ms;
|
|
3342
|
+
this.timer = setInterval(() => this.step(1), ms);
|
|
3343
|
+
} else if (!this.shouldAdvance && this.timer) {
|
|
3344
|
+
this.stopTimer();
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
stopTimer() {
|
|
3348
|
+
clearInterval(this.timer);
|
|
3349
|
+
this.timer = void 0;
|
|
3350
|
+
this.timerMs = 0;
|
|
3351
|
+
}
|
|
3352
|
+
restartTimer() {
|
|
3353
|
+
this.stopTimer();
|
|
3354
|
+
this.syncTimer();
|
|
3355
|
+
}
|
|
3356
|
+
endSwipe() {
|
|
3357
|
+
this.removeSwipeListeners();
|
|
3358
|
+
this.swipe = void 0;
|
|
3359
|
+
}
|
|
3360
|
+
removeSwipeListeners() {
|
|
3361
|
+
globalThis.removeEventListener("pointerup", this.onPointerUp);
|
|
3362
|
+
globalThis.removeEventListener("pointercancel", this.onPointerCancel);
|
|
3363
|
+
}
|
|
3364
|
+
slide(fields) {
|
|
3365
|
+
const slide = {
|
|
3366
|
+
...fields,
|
|
3367
|
+
cardRef: (element) => track(element),
|
|
3368
|
+
focusRef: (element) => trackFocus(element)
|
|
3369
|
+
};
|
|
3370
|
+
const track = tracker(this.cards, slide);
|
|
3371
|
+
const trackFocus = tracker(this.focusTargets, slide);
|
|
3372
|
+
return slide;
|
|
3373
|
+
}
|
|
3374
|
+
/** Pair: both Stories, each keyed by its index. */
|
|
3375
|
+
pairSlides() {
|
|
3376
|
+
const { active } = this;
|
|
3377
|
+
return [0, 1].map(
|
|
3378
|
+
(index) => this.slide({
|
|
3379
|
+
key: index,
|
|
3380
|
+
index,
|
|
3381
|
+
offset: index - active,
|
|
3382
|
+
active: index === active,
|
|
3383
|
+
hidden: false
|
|
3384
|
+
})
|
|
3385
|
+
);
|
|
3386
|
+
}
|
|
3387
|
+
/**
|
|
3388
|
+
* Rolling: the slides around the highlighted one, keyed by their position.
|
|
3389
|
+
* Up to VISIBLE_SIDE show on each side, fewer when there aren't enough
|
|
3390
|
+
* Stories to fill both sides without repeating: half on each side, the
|
|
3391
|
+
* extra one after it. With four, the Story opposite the highlighted one
|
|
3392
|
+
* shows at both ends; with two (narrow screens), the other one shows on
|
|
3393
|
+
* both sides.
|
|
3394
|
+
*/
|
|
3395
|
+
rollingSlides() {
|
|
3396
|
+
const { count } = this;
|
|
3397
|
+
const even = count === 2 || count === 4;
|
|
3398
|
+
const before = even ? count / 2 : Math.floor((count - 1) / 2);
|
|
3399
|
+
const after = even ? count / 2 : count - 1 - before;
|
|
3400
|
+
const slides = [];
|
|
3401
|
+
for (let offset = -RENDERED_SIDE; offset <= RENDERED_SIDE; offset += 1) {
|
|
3402
|
+
slides.push(
|
|
3403
|
+
this.slide({
|
|
3404
|
+
key: this.position + offset,
|
|
3405
|
+
index: wrap(this.position + offset, count),
|
|
3406
|
+
offset,
|
|
3407
|
+
active: offset === 0,
|
|
3408
|
+
hidden: Math.abs(offset) > VISIBLE_SIDE || offset < -before || offset > after
|
|
3409
|
+
})
|
|
3410
|
+
);
|
|
3411
|
+
}
|
|
3412
|
+
return slides;
|
|
3413
|
+
}
|
|
3414
|
+
renderSlides(items, renderSlide) {
|
|
3415
|
+
const { layout } = this;
|
|
3416
|
+
const slides = layout === "pair" ? this.pairSlides() : this.rollingSlides();
|
|
3417
|
+
return c5(
|
|
3418
|
+
slides,
|
|
3419
|
+
(slide) => `${layout}:${slide.key}`,
|
|
3420
|
+
(slide) => {
|
|
3421
|
+
const { index } = slide;
|
|
3422
|
+
return T`
|
|
3423
|
+
<div
|
|
3424
|
+
class="slide"
|
|
3425
|
+
data-index=${index}
|
|
3426
|
+
?data-active=${slide.active}
|
|
3427
|
+
?data-hidden=${slide.hidden}
|
|
3428
|
+
?inert=${slide.hidden}
|
|
3429
|
+
style=${o8({ "--place": String(slide.offset) })}
|
|
3430
|
+
>
|
|
3431
|
+
${renderSlide(items[index], slide)}
|
|
3432
|
+
</div>
|
|
3433
|
+
`;
|
|
3434
|
+
}
|
|
3435
|
+
);
|
|
3436
|
+
}
|
|
3437
|
+
/**
|
|
3438
|
+
* One item: the card centered over the background. More: the cards in the
|
|
3439
|
+
* pair or rolling layout, with the arrows.
|
|
3440
|
+
*/
|
|
3441
|
+
render(items, renderSlide, labels) {
|
|
3442
|
+
var _a13, _b3, _c;
|
|
3443
|
+
if (this.layout === "solo") {
|
|
3444
|
+
return T`
|
|
3445
|
+
<div class="carousel" data-layout="solo">
|
|
3446
|
+
${renderSlide(
|
|
3447
|
+
items[0],
|
|
3448
|
+
this.slide({
|
|
3449
|
+
key: 0,
|
|
3450
|
+
index: 0,
|
|
3451
|
+
offset: 0,
|
|
3452
|
+
active: true,
|
|
3453
|
+
hidden: false
|
|
3454
|
+
})
|
|
3455
|
+
)}
|
|
3456
|
+
</div>
|
|
3457
|
+
`;
|
|
3458
|
+
}
|
|
3459
|
+
const locked = (_c = (_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13)) != null ? _c : false;
|
|
3460
|
+
return T`
|
|
3461
|
+
<div
|
|
3462
|
+
class="carousel"
|
|
3463
|
+
data-layout=${this.layout}
|
|
3464
|
+
role="region"
|
|
3465
|
+
aria-roledescription=${labels.carouselRole}
|
|
3466
|
+
aria-label=${labels.carousel}
|
|
3467
|
+
@pointerenter=${this.onPointerEnter}
|
|
3468
|
+
@pointerleave=${this.onPointerLeave}
|
|
3469
|
+
@focusin=${this.onFocusIn}
|
|
3470
|
+
@focusout=${this.onFocusOut}
|
|
3471
|
+
>
|
|
3472
|
+
<div
|
|
3473
|
+
class="track"
|
|
3474
|
+
style=${o8({
|
|
3475
|
+
"--slide-duration": this.distance > 1 ? "0.52s" : "0.4s"
|
|
3476
|
+
})}
|
|
3477
|
+
@pointerdown=${this.onPointerDown}
|
|
3478
|
+
@click=${this.onClickCapture}
|
|
3479
|
+
>
|
|
3480
|
+
${this.renderSlides(items, renderSlide)}
|
|
3481
|
+
</div>
|
|
3482
|
+
<button
|
|
3483
|
+
type="button"
|
|
3484
|
+
class="arrow arrow-previous"
|
|
3485
|
+
aria-label=${labels.previous}
|
|
3486
|
+
?disabled=${locked}
|
|
3487
|
+
@click=${() => this.step(-1)}
|
|
3488
|
+
>
|
|
3489
|
+
${icon("previous")}
|
|
3490
|
+
</button>
|
|
3491
|
+
<button
|
|
3492
|
+
type="button"
|
|
3493
|
+
class="arrow arrow-next"
|
|
3494
|
+
aria-label=${labels.next}
|
|
3495
|
+
?disabled=${locked}
|
|
3496
|
+
@click=${() => this.step(1)}
|
|
3497
|
+
>
|
|
3498
|
+
${icon("next")}
|
|
3499
|
+
</button>
|
|
3500
|
+
</div>
|
|
3501
|
+
`;
|
|
1598
3502
|
}
|
|
3503
|
+
};
|
|
1599
3504
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
.
|
|
1603
|
-
position:
|
|
1604
|
-
inset: 0;
|
|
1605
|
-
width: 100%;
|
|
1606
|
-
height: 100%;
|
|
1607
|
-
padding: 0;
|
|
1608
|
-
border: 0;
|
|
1609
|
-
background: transparent;
|
|
1610
|
-
cursor: pointer;
|
|
3505
|
+
// src/components/carousel/carousel-skeleton.ts
|
|
3506
|
+
var carouselSkeletonStyles = i`
|
|
3507
|
+
.root {
|
|
3508
|
+
position: relative;
|
|
1611
3509
|
}
|
|
1612
3510
|
|
|
1613
|
-
.
|
|
1614
|
-
|
|
3511
|
+
.root[data-requesting] {
|
|
3512
|
+
height: ${STAGE_HEIGHT};
|
|
1615
3513
|
}
|
|
1616
3514
|
|
|
1617
|
-
.
|
|
1618
|
-
|
|
3515
|
+
.root[data-loading] .carousel {
|
|
3516
|
+
visibility: hidden;
|
|
1619
3517
|
}
|
|
1620
3518
|
|
|
1621
|
-
.
|
|
1622
|
-
.video {
|
|
3519
|
+
.skeleton {
|
|
1623
3520
|
position: absolute;
|
|
1624
3521
|
inset: 0;
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
3522
|
+
z-index: 2;
|
|
3523
|
+
box-sizing: border-box;
|
|
3524
|
+
overflow: hidden;
|
|
3525
|
+
pointer-events: none;
|
|
3526
|
+
transition:
|
|
3527
|
+
opacity 0.3s ease,
|
|
3528
|
+
visibility 0s;
|
|
1628
3529
|
}
|
|
1629
3530
|
|
|
1630
|
-
.
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
left: 50%;
|
|
1634
|
-
display: grid;
|
|
1635
|
-
width: 66px;
|
|
1636
|
-
height: 66px;
|
|
1637
|
-
place-items: center;
|
|
1638
|
-
border-radius: 50%;
|
|
1639
|
-
background:
|
|
1640
|
-
linear-gradient(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.06)),
|
|
1641
|
-
rgba(255, 255, 255, 0.15);
|
|
1642
|
-
backdrop-filter: blur(2px);
|
|
1643
|
-
box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);
|
|
1644
|
-
transform: translate(-50%, -50%);
|
|
3531
|
+
.skeleton[data-done] {
|
|
3532
|
+
opacity: 0;
|
|
3533
|
+
visibility: hidden;
|
|
1645
3534
|
transition:
|
|
1646
3535
|
opacity 0.3s ease,
|
|
1647
|
-
|
|
3536
|
+
visibility 0s 0.3s;
|
|
1648
3537
|
}
|
|
1649
3538
|
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
3539
|
+
.skeleton-slide {
|
|
3540
|
+
position: absolute;
|
|
3541
|
+
top: 0;
|
|
3542
|
+
left: 50%;
|
|
3543
|
+
width: calc(${STAGE_HEIGHT} * 9 / 16);
|
|
3544
|
+
height: 100%;
|
|
3545
|
+
margin-left: calc(${STAGE_HEIGHT} * 9 / -32);
|
|
3546
|
+
transform: translateX(calc(var(--place) * (100% + 8px))) scale(0.9);
|
|
1656
3547
|
}
|
|
1657
3548
|
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
position: absolute;
|
|
1661
|
-
top: 22px;
|
|
1662
|
-
right: 12px;
|
|
1663
|
-
z-index: 1;
|
|
1664
|
-
display: grid;
|
|
1665
|
-
width: 28px;
|
|
1666
|
-
height: 28px;
|
|
1667
|
-
place-items: center;
|
|
1668
|
-
padding: 0;
|
|
1669
|
-
border: 0;
|
|
1670
|
-
background: transparent;
|
|
1671
|
-
color: #fff;
|
|
1672
|
-
cursor: pointer;
|
|
1673
|
-
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
|
|
3549
|
+
.skeleton-slide[data-active] {
|
|
3550
|
+
transform: none;
|
|
1674
3551
|
}
|
|
1675
3552
|
|
|
1676
|
-
.card
|
|
1677
|
-
width:
|
|
1678
|
-
height:
|
|
3553
|
+
.skeleton-card {
|
|
3554
|
+
width: 100%;
|
|
3555
|
+
height: 100%;
|
|
3556
|
+
border-radius: var(--vtex-ads-story-radius, 20px);
|
|
3557
|
+
background: #ececec;
|
|
3558
|
+
animation: skeleton-pulse 1.2s ease-in-out infinite alternate;
|
|
1679
3559
|
}
|
|
1680
3560
|
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
3561
|
+
.skeleton[data-done] .skeleton-card {
|
|
3562
|
+
animation: none;
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
@keyframes skeleton-pulse {
|
|
3566
|
+
to {
|
|
3567
|
+
background-color: #f6f6f6;
|
|
1687
3568
|
}
|
|
3569
|
+
}
|
|
1688
3570
|
|
|
1689
|
-
|
|
1690
|
-
.
|
|
1691
|
-
|
|
1692
|
-
|
|
3571
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3572
|
+
.skeleton,
|
|
3573
|
+
.skeleton[data-done] {
|
|
3574
|
+
transition: none;
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
.skeleton-card {
|
|
3578
|
+
animation: none;
|
|
1693
3579
|
}
|
|
1694
3580
|
}
|
|
1695
3581
|
`;
|
|
1696
|
-
function
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
aria-label=${video.muted ? options.soundOnLabel : options.soundOffLabel}
|
|
1702
|
-
@click=${() => video.toggleMuted()}
|
|
1703
|
-
>
|
|
1704
|
-
${icon(video.muted ? "soundOff" : "soundOn")}
|
|
1705
|
-
</button>
|
|
1706
|
-
`;
|
|
1707
|
-
}
|
|
1708
|
-
function renderCard(story, video, options) {
|
|
3582
|
+
function renderCarouselSkeleton({ done }) {
|
|
3583
|
+
const places = Array.from(
|
|
3584
|
+
{ length: VISIBLE_SIDE * 2 + 1 },
|
|
3585
|
+
(_2, i7) => i7 - VISIBLE_SIDE
|
|
3586
|
+
);
|
|
1709
3587
|
return T`
|
|
1710
|
-
<div class="
|
|
1711
|
-
${
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
3588
|
+
<div class="skeleton" aria-hidden="true" ?data-done=${done}>
|
|
3589
|
+
${places.map(
|
|
3590
|
+
(place) => T`
|
|
3591
|
+
<div
|
|
3592
|
+
class="skeleton-slide"
|
|
3593
|
+
?data-active=${place === 0}
|
|
3594
|
+
style=${o8({ "--place": String(place) })}
|
|
3595
|
+
>
|
|
3596
|
+
<div class="skeleton-card"></div>
|
|
3597
|
+
</div>
|
|
3598
|
+
`
|
|
3599
|
+
)}
|
|
1721
3600
|
</div>
|
|
1722
3601
|
`;
|
|
1723
3602
|
}
|
|
1724
3603
|
|
|
3604
|
+
// src/tag-name.ts
|
|
3605
|
+
var TAG_NAME = "vtex-ads-story-carousel";
|
|
3606
|
+
|
|
3607
|
+
// src/utils/send-event.ts
|
|
3608
|
+
var CONTENT_TYPE = "text/plain;charset=utf-8";
|
|
3609
|
+
function sendEvent(url, { sessionId, userId }) {
|
|
3610
|
+
var _a13, _b3;
|
|
3611
|
+
const target = httpUrl(url);
|
|
3612
|
+
if (!target || globalThis.window === void 0) return false;
|
|
3613
|
+
const body = JSON.stringify(
|
|
3614
|
+
userId ? { session_id: sessionId, user_id: userId } : { session_id: sessionId }
|
|
3615
|
+
);
|
|
3616
|
+
try {
|
|
3617
|
+
const queued = (_b3 = (_a13 = globalThis.navigator) == null ? void 0 : _a13.sendBeacon) == null ? void 0 : _b3.call(
|
|
3618
|
+
_a13,
|
|
3619
|
+
target,
|
|
3620
|
+
new Blob([body], { type: CONTENT_TYPE })
|
|
3621
|
+
);
|
|
3622
|
+
if (queued) return true;
|
|
3623
|
+
} catch (e6) {
|
|
3624
|
+
}
|
|
3625
|
+
if (typeof globalThis.fetch !== "function") return false;
|
|
3626
|
+
globalThis.fetch(target, {
|
|
3627
|
+
method: "POST",
|
|
3628
|
+
headers: { "Content-Type": CONTENT_TYPE },
|
|
3629
|
+
body,
|
|
3630
|
+
keepalive: true,
|
|
3631
|
+
credentials: "omit"
|
|
3632
|
+
}).catch((error) => {
|
|
3633
|
+
console.error(`[${TAG_NAME}] Event request failed`, {
|
|
3634
|
+
url: target,
|
|
3635
|
+
error
|
|
3636
|
+
});
|
|
3637
|
+
});
|
|
3638
|
+
return true;
|
|
3639
|
+
}
|
|
3640
|
+
|
|
3641
|
+
// src/components/events/events-controller.ts
|
|
3642
|
+
var VIEW_THRESHOLD = 0.5;
|
|
3643
|
+
var VIEW_DURATION_MS = 2e3;
|
|
3644
|
+
var URL_FIELD = {
|
|
3645
|
+
impression: "impression_url",
|
|
3646
|
+
view: "view_url",
|
|
3647
|
+
click: "click_url"
|
|
3648
|
+
};
|
|
3649
|
+
var StoryEventsController = class {
|
|
3650
|
+
constructor(host, options) {
|
|
3651
|
+
this.host = host;
|
|
3652
|
+
this.options = options;
|
|
3653
|
+
this.sent = {
|
|
3654
|
+
impression: /* @__PURE__ */ new Set(),
|
|
3655
|
+
view: /* @__PURE__ */ new Set(),
|
|
3656
|
+
click: /* @__PURE__ */ new Set()
|
|
3657
|
+
};
|
|
3658
|
+
this.pendingImpressions = [];
|
|
3659
|
+
this.connected = false;
|
|
3660
|
+
this.watched = /* @__PURE__ */ new Map();
|
|
3661
|
+
this.onIntersect = (entries) => {
|
|
3662
|
+
for (const entry of entries) {
|
|
3663
|
+
const watched = this.watched.get(entry.target);
|
|
3664
|
+
if (!watched) continue;
|
|
3665
|
+
watched.visible = entry.isIntersecting && entry.intersectionRatio >= VIEW_THRESHOLD;
|
|
3666
|
+
if (watched.visible) this.startTimer(watched);
|
|
3667
|
+
else this.stopTimer(watched);
|
|
3668
|
+
}
|
|
3669
|
+
};
|
|
3670
|
+
// A hidden page (another tab, minimized) breaks the 2 seconds: they start
|
|
3671
|
+
// over when it shows again.
|
|
3672
|
+
this.onVisibilityChange = () => {
|
|
3673
|
+
for (const watched of this.watched.values()) {
|
|
3674
|
+
if (document.hidden) this.stopTimer(watched);
|
|
3675
|
+
else if (watched.visible) this.startTimer(watched);
|
|
3676
|
+
}
|
|
3677
|
+
};
|
|
3678
|
+
host.addController(this);
|
|
3679
|
+
}
|
|
3680
|
+
hostConnected() {
|
|
3681
|
+
var _a13;
|
|
3682
|
+
this.connected = true;
|
|
3683
|
+
if (typeof IntersectionObserver === "function") {
|
|
3684
|
+
this.observer = new IntersectionObserver(this.onIntersect, {
|
|
3685
|
+
threshold: VIEW_THRESHOLD
|
|
3686
|
+
});
|
|
3687
|
+
}
|
|
3688
|
+
(_a13 = globalThis.document) == null ? void 0 : _a13.addEventListener(
|
|
3689
|
+
"visibilitychange",
|
|
3690
|
+
this.onVisibilityChange
|
|
3691
|
+
);
|
|
3692
|
+
this.host.updateComplete.then(() => {
|
|
3693
|
+
if (!this.connected) return;
|
|
3694
|
+
this.sendImpressions();
|
|
3695
|
+
this.syncViewTargets();
|
|
3696
|
+
});
|
|
3697
|
+
}
|
|
3698
|
+
hostDisconnected() {
|
|
3699
|
+
var _a13, _b3;
|
|
3700
|
+
this.connected = false;
|
|
3701
|
+
(_a13 = globalThis.document) == null ? void 0 : _a13.removeEventListener(
|
|
3702
|
+
"visibilitychange",
|
|
3703
|
+
this.onVisibilityChange
|
|
3704
|
+
);
|
|
3705
|
+
(_b3 = this.observer) == null ? void 0 : _b3.disconnect();
|
|
3706
|
+
this.observer = void 0;
|
|
3707
|
+
for (const watched of this.watched.values()) clearTimeout(watched.timer);
|
|
3708
|
+
this.watched.clear();
|
|
3709
|
+
}
|
|
3710
|
+
hostUpdated() {
|
|
3711
|
+
if (!this.connected) return;
|
|
3712
|
+
this.sendImpressions();
|
|
3713
|
+
this.syncViewTargets();
|
|
3714
|
+
}
|
|
3715
|
+
/**
|
|
3716
|
+
* The Stories the host shows next: their impressions go out once that
|
|
3717
|
+
* render is done, on the page, with a session (or after the first render
|
|
3718
|
+
* that has both). Replaces Stories passed before and not sent yet.
|
|
3719
|
+
*/
|
|
3720
|
+
impress(stories) {
|
|
3721
|
+
this.pendingImpressions = stories;
|
|
3722
|
+
}
|
|
3723
|
+
sendImpressions() {
|
|
3724
|
+
const stories = this.pendingImpressions;
|
|
3725
|
+
if (!stories.length || !this.options.identity().sessionId) return;
|
|
3726
|
+
this.pendingImpressions = [];
|
|
3727
|
+
for (const story of stories) this.send("impression", story);
|
|
3728
|
+
}
|
|
3729
|
+
/** A touch on the Story: its click goes out, the first time only. */
|
|
3730
|
+
click(story) {
|
|
3731
|
+
this.send("click", story);
|
|
3732
|
+
}
|
|
3733
|
+
key(sessionId, story) {
|
|
3734
|
+
return `${sessionId}|${story.ad_id}`;
|
|
3735
|
+
}
|
|
3736
|
+
wasSent(kind, story) {
|
|
3737
|
+
const { sessionId } = this.options.identity();
|
|
3738
|
+
return !!sessionId && this.sent[kind].has(this.key(sessionId, story));
|
|
3739
|
+
}
|
|
3740
|
+
send(kind, story) {
|
|
3741
|
+
const { sessionId, userId } = this.options.identity();
|
|
3742
|
+
if (!sessionId || this.wasSent(kind, story)) return;
|
|
3743
|
+
const success = sendEvent(story[URL_FIELD[kind]], { sessionId, userId });
|
|
3744
|
+
if (success) {
|
|
3745
|
+
this.sent[kind].add(this.key(sessionId, story));
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
// Watches the elements the host shows now, and stops watching the others,
|
|
3749
|
+
// dropping the time they had on screen.
|
|
3750
|
+
syncViewTargets() {
|
|
3751
|
+
const { observer } = this;
|
|
3752
|
+
if (!observer) return;
|
|
3753
|
+
const current = /* @__PURE__ */ new Map();
|
|
3754
|
+
for (const [element, story] of this.options.viewTargets()) {
|
|
3755
|
+
if (!this.wasSent("view", story)) current.set(element, story);
|
|
3756
|
+
}
|
|
3757
|
+
for (const [element, watched] of this.watched) {
|
|
3758
|
+
if (current.get(element) !== watched.story) {
|
|
3759
|
+
this.unwatch(element, watched);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
for (const [element, story] of current) {
|
|
3763
|
+
if (this.watched.has(element)) continue;
|
|
3764
|
+
this.watched.set(element, { story, visible: false });
|
|
3765
|
+
observer.observe(element);
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
startTimer(watched) {
|
|
3769
|
+
var _a13;
|
|
3770
|
+
if (watched.timer || ((_a13 = globalThis.document) == null ? void 0 : _a13.hidden)) return;
|
|
3771
|
+
watched.timer = setTimeout(() => {
|
|
3772
|
+
watched.timer = void 0;
|
|
3773
|
+
this.send("view", watched.story);
|
|
3774
|
+
if (this.wasSent("view", watched.story)) this.unwatchStory(watched.story);
|
|
3775
|
+
}, VIEW_DURATION_MS);
|
|
3776
|
+
}
|
|
3777
|
+
stopTimer(watched) {
|
|
3778
|
+
clearTimeout(watched.timer);
|
|
3779
|
+
watched.timer = void 0;
|
|
3780
|
+
}
|
|
3781
|
+
unwatch(element, watched) {
|
|
3782
|
+
var _a13;
|
|
3783
|
+
this.stopTimer(watched);
|
|
3784
|
+
(_a13 = this.observer) == null ? void 0 : _a13.unobserve(element);
|
|
3785
|
+
this.watched.delete(element);
|
|
3786
|
+
}
|
|
3787
|
+
unwatchStory(story) {
|
|
3788
|
+
for (const [element, watched] of this.watched) {
|
|
3789
|
+
if (watched.story.ad_id === story.ad_id) this.unwatch(element, watched);
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
};
|
|
3793
|
+
|
|
1725
3794
|
// src/components/player/player.ts
|
|
3795
|
+
var NEAR_GAP = 72;
|
|
3796
|
+
var FAR_GAP = 48;
|
|
1726
3797
|
var playerStyles = i`
|
|
1727
3798
|
.player {
|
|
1728
3799
|
position: fixed;
|
|
@@ -1756,12 +3827,28 @@ var playerStyles = i`
|
|
|
1756
3827
|
background: transparent;
|
|
1757
3828
|
}
|
|
1758
3829
|
|
|
3830
|
+
/* Focusable only to keep the focus in the player when its video is clicked
|
|
3831
|
+
(see render): no ring around the whole player. */
|
|
3832
|
+
.player:focus {
|
|
3833
|
+
outline: none;
|
|
3834
|
+
}
|
|
3835
|
+
|
|
1759
3836
|
.player-frame {
|
|
1760
3837
|
position: relative;
|
|
1761
3838
|
width: 100%;
|
|
1762
3839
|
height: 100%;
|
|
1763
3840
|
}
|
|
1764
3841
|
|
|
3842
|
+
/* What moves in the expanded view, off center with two Stories and in the
|
|
3843
|
+
step animation: the video, its dimming and previous and next. Expand and
|
|
3844
|
+
close stay out of it: a transformed box becomes the one their fixed
|
|
3845
|
+
position, at the top right of the screen, is measured from. */
|
|
3846
|
+
.player-stage {
|
|
3847
|
+
position: relative;
|
|
3848
|
+
width: 100%;
|
|
3849
|
+
height: 100%;
|
|
3850
|
+
}
|
|
3851
|
+
|
|
1765
3852
|
.player .card {
|
|
1766
3853
|
width: 100%;
|
|
1767
3854
|
height: 100%;
|
|
@@ -1808,6 +3895,26 @@ var playerStyles = i`
|
|
|
1808
3895
|
height: 20px;
|
|
1809
3896
|
}
|
|
1810
3897
|
|
|
3898
|
+
/* The product pill or the call to action. Their wrapper only stops clicks:
|
|
3899
|
+
the pill places itself. The product is larger than on the carousel card
|
|
3900
|
+
(as in the prototype). */
|
|
3901
|
+
.player-destination {
|
|
3902
|
+
display: contents;
|
|
3903
|
+
}
|
|
3904
|
+
|
|
3905
|
+
.player .product-info {
|
|
3906
|
+
font-size: 14px;
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
.player .product-image {
|
|
3910
|
+
width: 72px;
|
|
3911
|
+
height: 72px;
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3914
|
+
.player .product-price {
|
|
3915
|
+
color: rgba(255, 255, 255, 0.7);
|
|
3916
|
+
}
|
|
3917
|
+
|
|
1811
3918
|
/* Above the card: on narrow screens the expanded card can cover them. */
|
|
1812
3919
|
.player-controls {
|
|
1813
3920
|
position: absolute;
|
|
@@ -1818,57 +3925,173 @@ var playerStyles = i`
|
|
|
1818
3925
|
gap: 8px;
|
|
1819
3926
|
}
|
|
1820
3927
|
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
3928
|
+
/* Previous and next Story, above the card's top left (mini player only). */
|
|
3929
|
+
.player-nav {
|
|
3930
|
+
right: auto;
|
|
3931
|
+
left: 0;
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
.player-button {
|
|
3935
|
+
display: grid;
|
|
3936
|
+
width: 36px;
|
|
3937
|
+
height: 36px;
|
|
3938
|
+
place-items: center;
|
|
3939
|
+
padding: 0;
|
|
3940
|
+
border: 1px solid rgba(133, 133, 133, 0.3);
|
|
3941
|
+
border-radius: 50%;
|
|
3942
|
+
background: rgba(0, 0, 0, 0.32);
|
|
3943
|
+
backdrop-filter: blur(5px);
|
|
3944
|
+
color: #fff;
|
|
3945
|
+
cursor: pointer;
|
|
3946
|
+
transition: background-color 0.2s;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
.player-button:hover {
|
|
3950
|
+
background: rgba(0, 0, 0, 0.55);
|
|
3951
|
+
}
|
|
3952
|
+
|
|
3953
|
+
.player-button .icon {
|
|
3954
|
+
width: 18px;
|
|
3955
|
+
height: 18px;
|
|
3956
|
+
}
|
|
3957
|
+
|
|
3958
|
+
.player[data-expanded] {
|
|
3959
|
+
inset: 0;
|
|
3960
|
+
display: grid;
|
|
3961
|
+
width: 100%;
|
|
3962
|
+
max-width: none;
|
|
3963
|
+
height: 100%;
|
|
3964
|
+
max-height: none;
|
|
3965
|
+
place-items: center;
|
|
3966
|
+
background: rgba(0, 0, 0, 0.85);
|
|
3967
|
+
animation: none;
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3970
|
+
.player[data-expanded] .player-frame {
|
|
3971
|
+
width: calc(min(78vh, 720px) * 9 / 16);
|
|
3972
|
+
height: min(78vh, 720px);
|
|
3973
|
+
}
|
|
3974
|
+
|
|
3975
|
+
.player[data-expanded] .player-controls {
|
|
3976
|
+
position: fixed;
|
|
3977
|
+
top: 24px;
|
|
3978
|
+
right: 24px;
|
|
3979
|
+
bottom: auto;
|
|
3980
|
+
}
|
|
3981
|
+
|
|
3982
|
+
.player[data-expanded] .player-button {
|
|
3983
|
+
width: 40px;
|
|
3984
|
+
height: 40px;
|
|
3985
|
+
}
|
|
3986
|
+
|
|
3987
|
+
/* Expanded with more than one Story: the other Stories' covers beside the
|
|
3988
|
+
video, smaller and dimmed, as in the prototype. --side is -1 (before)
|
|
3989
|
+
or 1 (after), --beyond how many places past the nearest one. */
|
|
3990
|
+
.player[data-expanded] {
|
|
3991
|
+
--center-height: min(78vh, 720px);
|
|
3992
|
+
--side-height: min(38vh, 320px);
|
|
3993
|
+
--side-width: calc(var(--side-height) * 9 / 16);
|
|
3994
|
+
--center-half: calc(var(--center-height) * 9 / 32);
|
|
3995
|
+
--near-gap: ${NEAR_GAP}px;
|
|
3996
|
+
--far-gap: ${FAR_GAP}px;
|
|
3997
|
+
--near: calc(var(--center-half) + var(--near-gap) + var(--side-width) / 2);
|
|
3998
|
+
--pitch: calc(var(--side-width) + var(--far-gap));
|
|
3999
|
+
}
|
|
4000
|
+
|
|
4001
|
+
.player-neighbor {
|
|
4002
|
+
position: absolute;
|
|
4003
|
+
top: 50%;
|
|
4004
|
+
left: 50%;
|
|
4005
|
+
width: var(--side-width);
|
|
4006
|
+
height: var(--side-height);
|
|
4007
|
+
padding: 0;
|
|
4008
|
+
overflow: hidden;
|
|
4009
|
+
border: 0;
|
|
4010
|
+
border-radius: var(--vtex-ads-story-radius, 16px);
|
|
4011
|
+
background: #111;
|
|
4012
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
|
|
4013
|
+
cursor: pointer;
|
|
4014
|
+
transform: translate(
|
|
4015
|
+
calc(-50% + var(--side) * var(--near) + var(--beyond) * var(--pitch)),
|
|
4016
|
+
-50%
|
|
4017
|
+
);
|
|
4018
|
+
}
|
|
4019
|
+
|
|
4020
|
+
.player-neighbor img {
|
|
4021
|
+
width: 100%;
|
|
4022
|
+
height: 100%;
|
|
4023
|
+
object-fit: cover;
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
/* Fades out as the video arrives from a dimmed cover (see animateStep). */
|
|
4027
|
+
.player-dim {
|
|
4028
|
+
position: absolute;
|
|
4029
|
+
inset: 0;
|
|
4030
|
+
z-index: 3;
|
|
4031
|
+
border-radius: var(--vtex-ads-story-radius, 20px);
|
|
4032
|
+
background: rgba(0, 0, 0, 0.35);
|
|
4033
|
+
opacity: 0;
|
|
4034
|
+
pointer-events: none;
|
|
4035
|
+
}
|
|
4036
|
+
|
|
4037
|
+
.player-neighbor::after {
|
|
4038
|
+
position: absolute;
|
|
4039
|
+
inset: 0;
|
|
4040
|
+
background: rgba(0, 0, 0, 0.35);
|
|
4041
|
+
content: "";
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
.player-neighbor:hover::after,
|
|
4045
|
+
.player-neighbor:focus-visible::after {
|
|
4046
|
+
background: rgba(0, 0, 0, 0.12);
|
|
4047
|
+
}
|
|
4048
|
+
|
|
4049
|
+
.player-neighbor:focus-visible {
|
|
4050
|
+
outline: 2px solid #fff;
|
|
4051
|
+
outline-offset: 2px;
|
|
1834
4052
|
}
|
|
1835
4053
|
|
|
1836
|
-
|
|
1837
|
-
|
|
4054
|
+
/* Two Stories: the video moves off center toward --pair-dir, and the other
|
|
4055
|
+
Story sits on the other side. */
|
|
4056
|
+
.player[data-pair] .player-stage {
|
|
4057
|
+
transform: translateX(
|
|
4058
|
+
calc(var(--pair-dir) * (var(--near-gap) + var(--side-width)) / 2)
|
|
4059
|
+
);
|
|
1838
4060
|
}
|
|
1839
4061
|
|
|
1840
|
-
.player-
|
|
1841
|
-
|
|
1842
|
-
|
|
4062
|
+
.player[data-pair] .player-neighbor {
|
|
4063
|
+
transform: translate(
|
|
4064
|
+
calc(
|
|
4065
|
+
-50% + var(--pair-dir) * -1 * (var(--center-half) + var(--near-gap) / 2)
|
|
4066
|
+
),
|
|
4067
|
+
-50%
|
|
4068
|
+
);
|
|
1843
4069
|
}
|
|
1844
4070
|
|
|
1845
|
-
.
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
max-width: none;
|
|
1850
|
-
height: 100%;
|
|
1851
|
-
max-height: none;
|
|
1852
|
-
place-items: center;
|
|
1853
|
-
background: rgba(0, 0, 0, 0.85);
|
|
1854
|
-
animation: none;
|
|
4071
|
+
/* Expanded previous and next: beside the video, centered on its height. */
|
|
4072
|
+
.player[data-expanded] .player-nav {
|
|
4073
|
+
position: static;
|
|
4074
|
+
display: contents;
|
|
1855
4075
|
}
|
|
1856
4076
|
|
|
1857
|
-
.player[data-expanded] .player-
|
|
1858
|
-
|
|
1859
|
-
|
|
4077
|
+
.player[data-expanded] .player-nav .player-button {
|
|
4078
|
+
position: absolute;
|
|
4079
|
+
top: 50%;
|
|
4080
|
+
z-index: 2;
|
|
4081
|
+
transform: translateY(-50%);
|
|
1860
4082
|
}
|
|
1861
4083
|
|
|
1862
|
-
.player[data-expanded] .player-
|
|
1863
|
-
|
|
1864
|
-
top: 24px;
|
|
1865
|
-
right: 24px;
|
|
1866
|
-
bottom: auto;
|
|
4084
|
+
.player[data-expanded] .player-previous {
|
|
4085
|
+
left: -56px;
|
|
1867
4086
|
}
|
|
1868
4087
|
|
|
1869
|
-
.player[data-expanded] .player-
|
|
1870
|
-
|
|
1871
|
-
|
|
4088
|
+
.player[data-expanded] .player-next {
|
|
4089
|
+
right: -56px;
|
|
4090
|
+
}
|
|
4091
|
+
|
|
4092
|
+
/* With two, the other Story's cover beside the video does that. */
|
|
4093
|
+
.player[data-expanded][data-pair] .player-nav {
|
|
4094
|
+
display: none;
|
|
1872
4095
|
}
|
|
1873
4096
|
|
|
1874
4097
|
@media (max-width: 576px) {
|
|
@@ -1878,6 +4101,18 @@ var playerStyles = i`
|
|
|
1878
4101
|
height: 391px;
|
|
1879
4102
|
}
|
|
1880
4103
|
|
|
4104
|
+
.player:not([data-expanded]) .product-image {
|
|
4105
|
+
width: 56px;
|
|
4106
|
+
height: 56px;
|
|
4107
|
+
}
|
|
4108
|
+
|
|
4109
|
+
/* "Adicionar ao carrinho" fits on one line in the narrow mini player. */
|
|
4110
|
+
.player:not([data-expanded]) .product-action {
|
|
4111
|
+
height: 40px;
|
|
4112
|
+
padding: 0 8px;
|
|
4113
|
+
font-size: 12px;
|
|
4114
|
+
}
|
|
4115
|
+
|
|
1881
4116
|
.player[data-expanded] {
|
|
1882
4117
|
background: #000;
|
|
1883
4118
|
}
|
|
@@ -1900,6 +4135,28 @@ var playerStyles = i`
|
|
|
1900
4135
|
top: 60px;
|
|
1901
4136
|
right: 12px;
|
|
1902
4137
|
}
|
|
4138
|
+
|
|
4139
|
+
/* No room for the other Stories' covers: previous and next go inside
|
|
4140
|
+
the video's edges instead, also with two. */
|
|
4141
|
+
.player-neighbor {
|
|
4142
|
+
display: none;
|
|
4143
|
+
}
|
|
4144
|
+
|
|
4145
|
+
.player[data-pair] .player-stage {
|
|
4146
|
+
transform: none;
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
.player[data-expanded][data-pair] .player-nav {
|
|
4150
|
+
display: contents;
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
.player[data-expanded] .player-previous {
|
|
4154
|
+
left: 12px;
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4157
|
+
.player[data-expanded] .player-next {
|
|
4158
|
+
right: 12px;
|
|
4159
|
+
}
|
|
1903
4160
|
}
|
|
1904
4161
|
|
|
1905
4162
|
@keyframes player-in {
|
|
@@ -1915,6 +4172,88 @@ var playerStyles = i`
|
|
|
1915
4172
|
}
|
|
1916
4173
|
}
|
|
1917
4174
|
`;
|
|
4175
|
+
function neighborOffsets(count, active) {
|
|
4176
|
+
if (count < 2) return [];
|
|
4177
|
+
if (count === 2) return [active === 0 ? 1 : -1];
|
|
4178
|
+
const offsets = [];
|
|
4179
|
+
const shown = /* @__PURE__ */ new Set([0]);
|
|
4180
|
+
for (const offset of [-1, 1, -2, 2]) {
|
|
4181
|
+
const index = (offset % count + count) % count;
|
|
4182
|
+
if (!shown.has(index)) {
|
|
4183
|
+
shown.add(index);
|
|
4184
|
+
offsets.push(offset);
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
return offsets;
|
|
4188
|
+
}
|
|
4189
|
+
var STEP_ANIMATION = {
|
|
4190
|
+
duration: 560,
|
|
4191
|
+
easing: "cubic-bezier(0.32, 0.72, 0, 1)"
|
|
4192
|
+
};
|
|
4193
|
+
var coverTransform = (x2, scale = 1) => `translate(-50%, -50%) translateX(${x2}px) scale(${scale})`;
|
|
4194
|
+
var fadeIn = (element) => element.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
4195
|
+
...STEP_ANIMATION,
|
|
4196
|
+
pseudoElement: "::after"
|
|
4197
|
+
});
|
|
4198
|
+
function animateRailStep(frame, frameFrom, neighbors, { frameWidth, sideWidth }) {
|
|
4199
|
+
const placeX = (place) => {
|
|
4200
|
+
if (place === 0) return 0;
|
|
4201
|
+
const side = Math.sign(place);
|
|
4202
|
+
const near = frameWidth / 2 + NEAR_GAP + sideWidth / 2;
|
|
4203
|
+
return side * near + (place - side) * (sideWidth + FAR_GAP);
|
|
4204
|
+
};
|
|
4205
|
+
const ratio = sideWidth / frameWidth;
|
|
4206
|
+
const animations = [
|
|
4207
|
+
frame.animate(
|
|
4208
|
+
[
|
|
4209
|
+
{ transform: `translateX(${placeX(frameFrom)}px) scale(${ratio})` },
|
|
4210
|
+
{ transform: "none" }
|
|
4211
|
+
],
|
|
4212
|
+
STEP_ANIMATION
|
|
4213
|
+
)
|
|
4214
|
+
];
|
|
4215
|
+
for (const { element, offset, from } of neighbors) {
|
|
4216
|
+
const wasVideo = from === 0;
|
|
4217
|
+
animations.push(
|
|
4218
|
+
element.animate(
|
|
4219
|
+
[
|
|
4220
|
+
{ transform: coverTransform(placeX(from), wasVideo ? 1 / ratio : 1) },
|
|
4221
|
+
{ transform: coverTransform(placeX(offset)) }
|
|
4222
|
+
],
|
|
4223
|
+
STEP_ANIMATION
|
|
4224
|
+
)
|
|
4225
|
+
);
|
|
4226
|
+
if (wasVideo) animations.push(fadeIn(element));
|
|
4227
|
+
}
|
|
4228
|
+
return animations;
|
|
4229
|
+
}
|
|
4230
|
+
function animatePairStep(frame, neighbor, direction, { frameWidth, sideWidth }) {
|
|
4231
|
+
const videoX = (side) => side * (NEAR_GAP + sideWidth) / 2;
|
|
4232
|
+
const coverX = (side) => -side * (frameWidth + NEAR_GAP) / 2;
|
|
4233
|
+
const ratio = sideWidth / frameWidth;
|
|
4234
|
+
return [
|
|
4235
|
+
frame.animate(
|
|
4236
|
+
[
|
|
4237
|
+
{ transform: `translateX(${coverX(-direction)}px) scale(${ratio})` },
|
|
4238
|
+
{ transform: `translateX(${videoX(direction)}px)` }
|
|
4239
|
+
],
|
|
4240
|
+
STEP_ANIMATION
|
|
4241
|
+
),
|
|
4242
|
+
neighbor.animate(
|
|
4243
|
+
[
|
|
4244
|
+
{ transform: coverTransform(videoX(-direction), 1 / ratio) },
|
|
4245
|
+
{ transform: coverTransform(coverX(direction)) }
|
|
4246
|
+
],
|
|
4247
|
+
STEP_ANIMATION
|
|
4248
|
+
),
|
|
4249
|
+
fadeIn(neighbor)
|
|
4250
|
+
];
|
|
4251
|
+
}
|
|
4252
|
+
var ARROW_STEPS = {
|
|
4253
|
+
ArrowLeft: -1,
|
|
4254
|
+
ArrowRight: 1
|
|
4255
|
+
};
|
|
4256
|
+
var isFreeArrowKey = (event) => !event.defaultPrevented && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
1918
4257
|
function supportsPopover(dialog) {
|
|
1919
4258
|
return typeof dialog.showPopover === "function";
|
|
1920
4259
|
}
|
|
@@ -1925,17 +4264,33 @@ var PlayerController = class {
|
|
|
1925
4264
|
/** Rendered and, once the host has updated, shown. */
|
|
1926
4265
|
this.isOpen = false;
|
|
1927
4266
|
this.expanded = false;
|
|
4267
|
+
/** The product panel is open. Closed again on a step and on opening. */
|
|
4268
|
+
this.productOpen = false;
|
|
1928
4269
|
/** Switched modes at least once: only the first opening fades in. */
|
|
1929
4270
|
this.switched = false;
|
|
1930
4271
|
/** The dialog is showing, in the mode `expanded` says. */
|
|
1931
4272
|
this.shown = false;
|
|
1932
|
-
this.dialog =
|
|
1933
|
-
this.expandButton =
|
|
1934
|
-
this.closeButton =
|
|
4273
|
+
this.dialog = e4();
|
|
4274
|
+
this.expandButton = e4();
|
|
4275
|
+
this.closeButton = e4();
|
|
4276
|
+
this.stage = e4();
|
|
4277
|
+
this.stageCardRef = e4();
|
|
4278
|
+
this.dim = e4();
|
|
4279
|
+
/** The covers beside the expanded video, by offset, as rendered. */
|
|
4280
|
+
this.neighborElements = /* @__PURE__ */ new Map();
|
|
4281
|
+
/** One ref callback per offset: a new one each render would detach it. */
|
|
4282
|
+
this.neighborRefs = /* @__PURE__ */ new Map();
|
|
4283
|
+
/** Rendered with previous and next (see PlayerRenderOptions). */
|
|
4284
|
+
this.navigation = false;
|
|
4285
|
+
/** Side the expanded video moved to with two Stories; 0 otherwise. */
|
|
4286
|
+
this.pairDirection = 0;
|
|
4287
|
+
/** The step animation running, cancelled by the next step. */
|
|
4288
|
+
this.animations = [];
|
|
1935
4289
|
this.toggleExpanded = async () => {
|
|
1936
4290
|
var _a13;
|
|
1937
4291
|
const dialog = this.dialog.value;
|
|
1938
4292
|
if (!dialog) return;
|
|
4293
|
+
this.cancelAnimations();
|
|
1939
4294
|
this.hide(dialog);
|
|
1940
4295
|
this.expanded = !this.expanded;
|
|
1941
4296
|
this.switched = true;
|
|
@@ -1949,6 +4304,17 @@ var PlayerController = class {
|
|
|
1949
4304
|
this.onKeyDown = (event) => {
|
|
1950
4305
|
if (event.key === "Escape") this.options.onClose();
|
|
1951
4306
|
};
|
|
4307
|
+
// With the focus in the player and more than one Story, the arrows step, as
|
|
4308
|
+
// the previous and next buttons do. Only there: the mini player leaves the
|
|
4309
|
+
// page usable, and the page's own arrow keys (a gallery, a slider) keep
|
|
4310
|
+
// working.
|
|
4311
|
+
this.onPlayerKeyDown = (event) => {
|
|
4312
|
+
var _a13, _b3;
|
|
4313
|
+
const delta = ARROW_STEPS[event.key];
|
|
4314
|
+
if (!delta || !this.navigation || !isFreeArrowKey(event)) return;
|
|
4315
|
+
event.preventDefault();
|
|
4316
|
+
(_b3 = (_a13 = this.options).onStep) == null ? void 0 : _b3.call(_a13, delta);
|
|
4317
|
+
};
|
|
1952
4318
|
// Clicks on the backdrop of the expanded view reach the dialog itself.
|
|
1953
4319
|
this.onDialogClick = (event) => {
|
|
1954
4320
|
if (this.expanded && event.target === event.currentTarget) {
|
|
@@ -1960,38 +4326,171 @@ var PlayerController = class {
|
|
|
1960
4326
|
event.preventDefault();
|
|
1961
4327
|
this.options.onClose();
|
|
1962
4328
|
};
|
|
4329
|
+
/**
|
|
4330
|
+
* Play/pause in the middle of the video and sound on/off at its top right.
|
|
4331
|
+
* They follow the video's own events, so a blocked autoplay shows as
|
|
4332
|
+
* paused.
|
|
4333
|
+
*/
|
|
4334
|
+
this.toggleProduct = () => {
|
|
4335
|
+
this.productOpen = !this.productOpen;
|
|
4336
|
+
this.host.requestUpdate();
|
|
4337
|
+
};
|
|
4338
|
+
/**
|
|
4339
|
+
* Loads the failed video again and, once it loads, plays it with the sound
|
|
4340
|
+
* on (muted if the browser blocks it). Not if the player closed or stepped
|
|
4341
|
+
* meanwhile, even back to the same Story: the retry then resolves false.
|
|
4342
|
+
*/
|
|
4343
|
+
this.retryVideo = () => {
|
|
4344
|
+
var _a13;
|
|
4345
|
+
(_a13 = this.dialog.value) == null ? void 0 : _a13.focus();
|
|
4346
|
+
void this.video.retry().then((loaded) => {
|
|
4347
|
+
if (loaded) this.video.playWithSound();
|
|
4348
|
+
});
|
|
4349
|
+
};
|
|
4350
|
+
/**
|
|
4351
|
+
* A click on the video: closes the product panel when it is open, plays or
|
|
4352
|
+
* pauses the video otherwise.
|
|
4353
|
+
*/
|
|
4354
|
+
this.onVideoClick = () => {
|
|
4355
|
+
if (this.productOpen) this.toggleProduct();
|
|
4356
|
+
else this.video.togglePlayback();
|
|
4357
|
+
};
|
|
1963
4358
|
host.addController(this);
|
|
1964
4359
|
this.video = new VideoController(host);
|
|
1965
4360
|
}
|
|
4361
|
+
/** Open in the expanded view, a modal over the page. */
|
|
4362
|
+
get isExpanded() {
|
|
4363
|
+
return this.isOpen && this.expanded;
|
|
4364
|
+
}
|
|
4365
|
+
/** The card with the video, while the player is open. */
|
|
4366
|
+
get stageCard() {
|
|
4367
|
+
return this.isOpen ? this.stageCardRef.value : void 0;
|
|
4368
|
+
}
|
|
1966
4369
|
hostDisconnected() {
|
|
1967
4370
|
this.close();
|
|
1968
4371
|
}
|
|
1969
|
-
/**
|
|
1970
|
-
|
|
4372
|
+
/**
|
|
4373
|
+
* Opens the mini player, plays the video with the sound on (muted if the
|
|
4374
|
+
* browser blocks it) and focuses the close button.
|
|
4375
|
+
* With `productOpen`, the product panel shows open (the shopper chose the
|
|
4376
|
+
* product).
|
|
4377
|
+
*/
|
|
4378
|
+
async open({ productOpen = false } = {}) {
|
|
1971
4379
|
var _a13;
|
|
1972
4380
|
if (this.isOpen) return;
|
|
1973
4381
|
document.addEventListener("keydown", this.onKeyDown);
|
|
1974
4382
|
this.isOpen = true;
|
|
1975
4383
|
this.expanded = false;
|
|
4384
|
+
this.productOpen = productOpen;
|
|
1976
4385
|
this.switched = false;
|
|
4386
|
+
this.rendered = void 0;
|
|
4387
|
+
this.beforeStep = void 0;
|
|
1977
4388
|
this.video.reset();
|
|
1978
4389
|
this.host.requestUpdate();
|
|
1979
4390
|
await this.host.updateComplete;
|
|
1980
4391
|
const dialog = this.dialog.value;
|
|
1981
4392
|
if (!this.isOpen || !dialog) return;
|
|
1982
4393
|
this.show(dialog);
|
|
1983
|
-
this.video.
|
|
4394
|
+
this.video.playWithSound();
|
|
1984
4395
|
(_a13 = this.closeButton.value) == null ? void 0 : _a13.focus();
|
|
1985
4396
|
}
|
|
1986
4397
|
/** Hides the player now; the host removes it on its next update. */
|
|
1987
4398
|
close() {
|
|
1988
4399
|
if (!this.isOpen) return;
|
|
1989
4400
|
document.removeEventListener("keydown", this.onKeyDown);
|
|
4401
|
+
this.cancelAnimations();
|
|
1990
4402
|
const dialog = this.dialog.value;
|
|
1991
4403
|
if (dialog) this.hide(dialog);
|
|
1992
4404
|
this.isOpen = false;
|
|
1993
4405
|
this.host.requestUpdate();
|
|
1994
4406
|
}
|
|
4407
|
+
/**
|
|
4408
|
+
* After the host renders a different Story in the open player, `delta`
|
|
4409
|
+
* places from the previous one: its video starts from the top and plays,
|
|
4410
|
+
* with the sound as the shopper left it. A failed load of the previous
|
|
4411
|
+
* video doesn't hide the new one. The expanded view animates the step.
|
|
4412
|
+
*/
|
|
4413
|
+
async showNext(delta = 0) {
|
|
4414
|
+
if (!this.isOpen) return;
|
|
4415
|
+
const withSound = !this.video.muted;
|
|
4416
|
+
this.video.clearFailure();
|
|
4417
|
+
this.productOpen = false;
|
|
4418
|
+
this.host.requestUpdate();
|
|
4419
|
+
await this.host.updateComplete;
|
|
4420
|
+
if (!this.isOpen) return;
|
|
4421
|
+
this.video.restart({ withSound });
|
|
4422
|
+
this.animateStep(delta);
|
|
4423
|
+
}
|
|
4424
|
+
/** Stops a step animation still running, leaving the CSS layout. */
|
|
4425
|
+
cancelAnimations() {
|
|
4426
|
+
for (const animation of this.animations) animation.cancel();
|
|
4427
|
+
this.animations = [];
|
|
4428
|
+
}
|
|
4429
|
+
/**
|
|
4430
|
+
* The expanded step, as in the prototype: the video grows from the cover
|
|
4431
|
+
* of the Story it now shows, and the covers slide to their new places, the
|
|
4432
|
+
* previous Story's shrinking from the video's size. With two Stories, the
|
|
4433
|
+
* video and the other cover swap sides. Not with reduced motion, nor
|
|
4434
|
+
* without covers (narrow screens).
|
|
4435
|
+
*/
|
|
4436
|
+
animateStep(delta) {
|
|
4437
|
+
var _a13, _b3;
|
|
4438
|
+
if (!this.expanded || delta === 0 || prefersReducedMotion()) return;
|
|
4439
|
+
const frame = this.stage.value;
|
|
4440
|
+
const dim = this.dim.value;
|
|
4441
|
+
if (!frame || !dim || typeof frame.animate !== "function") return;
|
|
4442
|
+
const { rendered, beforeStep } = this;
|
|
4443
|
+
const placeBefore = (story, fallback) => {
|
|
4444
|
+
var _a14;
|
|
4445
|
+
if (!story || !beforeStep) return fallback;
|
|
4446
|
+
if (story === beforeStep.story) return 0;
|
|
4447
|
+
const cover = beforeStep.neighbors.find((n7) => n7.story === story);
|
|
4448
|
+
return (_a14 = cover == null ? void 0 : cover.offset) != null ? _a14 : fallback;
|
|
4449
|
+
};
|
|
4450
|
+
const neighbors = [...this.neighborElements].map(([offset, element]) => {
|
|
4451
|
+
var _a14;
|
|
4452
|
+
return {
|
|
4453
|
+
offset,
|
|
4454
|
+
element,
|
|
4455
|
+
from: placeBefore(
|
|
4456
|
+
(_a14 = rendered == null ? void 0 : rendered.neighbors.find((n7) => n7.offset === offset)) == null ? void 0 : _a14.story,
|
|
4457
|
+
offset + delta
|
|
4458
|
+
)
|
|
4459
|
+
};
|
|
4460
|
+
});
|
|
4461
|
+
const sizes = {
|
|
4462
|
+
frameWidth: frame.offsetWidth,
|
|
4463
|
+
sideWidth: (_b3 = (_a13 = neighbors[0]) == null ? void 0 : _a13.element.offsetWidth) != null ? _b3 : 0
|
|
4464
|
+
};
|
|
4465
|
+
if (!sizes.frameWidth || !sizes.sideWidth) return;
|
|
4466
|
+
this.cancelAnimations();
|
|
4467
|
+
this.animations = [
|
|
4468
|
+
dim.animate([{ opacity: 1 }, { opacity: 0 }], STEP_ANIMATION),
|
|
4469
|
+
...this.pairDirection ? animatePairStep(
|
|
4470
|
+
frame,
|
|
4471
|
+
neighbors[0].element,
|
|
4472
|
+
this.pairDirection,
|
|
4473
|
+
sizes
|
|
4474
|
+
) : animateRailStep(
|
|
4475
|
+
frame,
|
|
4476
|
+
placeBefore(rendered == null ? void 0 : rendered.story, delta),
|
|
4477
|
+
neighbors,
|
|
4478
|
+
sizes
|
|
4479
|
+
)
|
|
4480
|
+
];
|
|
4481
|
+
}
|
|
4482
|
+
// Keeps neighborElements in step with the covers Lit renders.
|
|
4483
|
+
neighborRef(offset) {
|
|
4484
|
+
let callback = this.neighborRefs.get(offset);
|
|
4485
|
+
if (!callback) {
|
|
4486
|
+
callback = (element) => {
|
|
4487
|
+
if (element) this.neighborElements.set(offset, element);
|
|
4488
|
+
else this.neighborElements.delete(offset);
|
|
4489
|
+
};
|
|
4490
|
+
this.neighborRefs.set(offset, callback);
|
|
4491
|
+
}
|
|
4492
|
+
return callback;
|
|
4493
|
+
}
|
|
1995
4494
|
// Mini: a manual popover, or a non-modal dialog without popover support.
|
|
1996
4495
|
// Expanded: a modal dialog.
|
|
1997
4496
|
// Already showing: a second expand click in the same task resumes after the
|
|
@@ -2012,12 +4511,41 @@ var PlayerController = class {
|
|
|
2012
4511
|
this.shown = false;
|
|
2013
4512
|
}
|
|
2014
4513
|
/**
|
|
2015
|
-
*
|
|
2016
|
-
*
|
|
2017
|
-
*
|
|
4514
|
+
* At the bottom of the video, the product pill, which opens the panel with
|
|
4515
|
+
* its actions, or the call to action of a link destination. Clicks on them
|
|
4516
|
+
* don't reach the video.
|
|
2018
4517
|
*/
|
|
2019
|
-
|
|
2020
|
-
|
|
4518
|
+
renderDestination({
|
|
4519
|
+
product,
|
|
4520
|
+
cta,
|
|
4521
|
+
labels,
|
|
4522
|
+
productActions
|
|
4523
|
+
}) {
|
|
4524
|
+
let content;
|
|
4525
|
+
if (product) {
|
|
4526
|
+
content = renderExpandableProduct(product, {
|
|
4527
|
+
...productActions,
|
|
4528
|
+
labels,
|
|
4529
|
+
open: this.productOpen,
|
|
4530
|
+
onToggle: this.toggleProduct,
|
|
4531
|
+
panelId: "player-product-panel"
|
|
4532
|
+
});
|
|
4533
|
+
} else if (cta) {
|
|
4534
|
+
content = renderCta(cta);
|
|
4535
|
+
} else {
|
|
4536
|
+
return A;
|
|
4537
|
+
}
|
|
4538
|
+
return T`
|
|
4539
|
+
<div
|
|
4540
|
+
class="player-destination"
|
|
4541
|
+
@click=${(event) => event.stopPropagation()}
|
|
4542
|
+
>
|
|
4543
|
+
${content}
|
|
4544
|
+
</div>
|
|
4545
|
+
`;
|
|
4546
|
+
}
|
|
4547
|
+
renderVideoControls(labels) {
|
|
4548
|
+
const { video } = this;
|
|
2021
4549
|
const onToggle = (event) => {
|
|
2022
4550
|
event.stopPropagation();
|
|
2023
4551
|
video.togglePlayback();
|
|
@@ -2030,7 +4558,7 @@ var PlayerController = class {
|
|
|
2030
4558
|
<button
|
|
2031
4559
|
type="button"
|
|
2032
4560
|
class="play player-toggle"
|
|
2033
|
-
aria-label=${video.paused ?
|
|
4561
|
+
aria-label=${video.paused ? labels.play : labels.pause}
|
|
2034
4562
|
@click=${onToggle}
|
|
2035
4563
|
>
|
|
2036
4564
|
${icon(video.paused ? "play" : "pause")}
|
|
@@ -2038,57 +4566,193 @@ var PlayerController = class {
|
|
|
2038
4566
|
<button
|
|
2039
4567
|
type="button"
|
|
2040
4568
|
class="player-button player-sound"
|
|
2041
|
-
aria-label=${video.muted ?
|
|
4569
|
+
aria-label=${video.muted ? labels.soundOn : labels.soundOff}
|
|
2042
4570
|
@click=${onSound}
|
|
2043
4571
|
>
|
|
2044
4572
|
${icon(video.muted ? "soundOff" : "soundOn")}
|
|
2045
4573
|
</button>
|
|
2046
4574
|
`;
|
|
2047
4575
|
}
|
|
4576
|
+
/**
|
|
4577
|
+
* Previous and next Story: above the mini player's top left, beside the
|
|
4578
|
+
* expanded video.
|
|
4579
|
+
*/
|
|
4580
|
+
renderNavigation(labels) {
|
|
4581
|
+
const { options } = this;
|
|
4582
|
+
const step = (delta) => () => {
|
|
4583
|
+
var _a13;
|
|
4584
|
+
return (_a13 = options.onStep) == null ? void 0 : _a13.call(options, delta);
|
|
4585
|
+
};
|
|
4586
|
+
return T`
|
|
4587
|
+
<div class="player-controls player-nav">
|
|
4588
|
+
<button
|
|
4589
|
+
type="button"
|
|
4590
|
+
class="player-button player-previous"
|
|
4591
|
+
aria-label=${labels.previous}
|
|
4592
|
+
@click=${step(-1)}
|
|
4593
|
+
>
|
|
4594
|
+
${icon("previous")}
|
|
4595
|
+
</button>
|
|
4596
|
+
<button
|
|
4597
|
+
type="button"
|
|
4598
|
+
class="player-button player-next"
|
|
4599
|
+
aria-label=${labels.next}
|
|
4600
|
+
@click=${step(1)}
|
|
4601
|
+
>
|
|
4602
|
+
${icon("next")}
|
|
4603
|
+
</button>
|
|
4604
|
+
</div>
|
|
4605
|
+
`;
|
|
4606
|
+
}
|
|
4607
|
+
/** The other Stories' covers beside the expanded video. */
|
|
4608
|
+
renderNeighbors(neighbors, labels) {
|
|
4609
|
+
const { options } = this;
|
|
4610
|
+
return c5(
|
|
4611
|
+
neighbors,
|
|
4612
|
+
({ offset }) => neighbors.length === 1 ? "single" : offset,
|
|
4613
|
+
({ offset, story, label }) => {
|
|
4614
|
+
const poster = httpUrl(story.poster_url);
|
|
4615
|
+
const side = Math.sign(offset);
|
|
4616
|
+
return T`
|
|
4617
|
+
<button
|
|
4618
|
+
type="button"
|
|
4619
|
+
class="player-neighbor"
|
|
4620
|
+
aria-label=${label != null ? label : labels.show}
|
|
4621
|
+
style=${o8({
|
|
4622
|
+
"--side": String(side),
|
|
4623
|
+
"--beyond": String(offset - side)
|
|
4624
|
+
})}
|
|
4625
|
+
${n5(this.neighborRef(offset))}
|
|
4626
|
+
@click=${() => {
|
|
4627
|
+
var _a13;
|
|
4628
|
+
return (_a13 = options.onStep) == null ? void 0 : _a13.call(options, offset);
|
|
4629
|
+
}}
|
|
4630
|
+
>
|
|
4631
|
+
${poster ? T`<img alt="" src=${poster} />` : A}
|
|
4632
|
+
</button>
|
|
4633
|
+
`;
|
|
4634
|
+
}
|
|
4635
|
+
);
|
|
4636
|
+
}
|
|
4637
|
+
/** Expand or collapse, and close: above the video, or at the top right. */
|
|
4638
|
+
renderWindowControls(labels) {
|
|
4639
|
+
const { options, expanded } = this;
|
|
4640
|
+
return T`
|
|
4641
|
+
<div class="player-controls">
|
|
4642
|
+
<button
|
|
4643
|
+
type="button"
|
|
4644
|
+
class="player-button player-expand"
|
|
4645
|
+
aria-label=${expanded ? labels.collapse : labels.expand}
|
|
4646
|
+
${n5(this.expandButton)}
|
|
4647
|
+
@click=${this.toggleExpanded}
|
|
4648
|
+
>
|
|
4649
|
+
${icon(expanded ? "collapse" : "expand")}
|
|
4650
|
+
</button>
|
|
4651
|
+
<button
|
|
4652
|
+
type="button"
|
|
4653
|
+
class="player-button player-close"
|
|
4654
|
+
aria-label=${labels.close}
|
|
4655
|
+
${n5(this.closeButton)}
|
|
4656
|
+
@click=${options.onClose}
|
|
4657
|
+
>
|
|
4658
|
+
${icon("close")}
|
|
4659
|
+
</button>
|
|
4660
|
+
</div>
|
|
4661
|
+
`;
|
|
4662
|
+
}
|
|
4663
|
+
/**
|
|
4664
|
+
* The video with its controls and the product or call to action. With
|
|
4665
|
+
* `advances`, it plays once and moves on to the next Story when it ends;
|
|
4666
|
+
* otherwise it loops.
|
|
4667
|
+
*/
|
|
4668
|
+
renderVideo(story, advances, destination) {
|
|
4669
|
+
const { video, options } = this;
|
|
4670
|
+
return T`
|
|
4671
|
+
<div class="card" ${n5(this.stageCardRef)} @click=${this.onVideoClick}>
|
|
4672
|
+
${renderMedia(story, video, {
|
|
4673
|
+
loop: !advances,
|
|
4674
|
+
onEnded: advances ? () => {
|
|
4675
|
+
var _a13;
|
|
4676
|
+
return (_a13 = options.onStep) == null ? void 0 : _a13.call(options, 1);
|
|
4677
|
+
} : void 0,
|
|
4678
|
+
labels: destination.labels,
|
|
4679
|
+
onRetry: this.retryVideo
|
|
4680
|
+
})}
|
|
4681
|
+
${hasVideo(story, video) ? this.renderVideoControls(destination.labels) : A}
|
|
4682
|
+
${this.renderDestination(destination)}
|
|
4683
|
+
</div>
|
|
4684
|
+
`;
|
|
4685
|
+
}
|
|
4686
|
+
/**
|
|
4687
|
+
* Keeps what this render shows, for the step animation: the covers beside
|
|
4688
|
+
* the video (only in the expanded view) and the side the video moves to
|
|
4689
|
+
* with two Stories. A new Story makes what was shown the animation's
|
|
4690
|
+
* start.
|
|
4691
|
+
*/
|
|
4692
|
+
track(story, neighbors) {
|
|
4693
|
+
const shown = this.expanded ? neighbors : [];
|
|
4694
|
+
this.pairDirection = shown.length === 1 ? -Math.sign(shown[0].offset) : 0;
|
|
4695
|
+
if (this.rendered && story !== this.rendered.story) {
|
|
4696
|
+
this.beforeStep = this.rendered;
|
|
4697
|
+
}
|
|
4698
|
+
this.rendered = { story, neighbors: shown };
|
|
4699
|
+
return shown;
|
|
4700
|
+
}
|
|
2048
4701
|
/**
|
|
2049
4702
|
* The player <dialog> while it is open. Clicking the video also plays or
|
|
2050
|
-
* pauses it
|
|
4703
|
+
* pauses it, and keeps the focus in the player (the dialog is focusable,
|
|
4704
|
+
* though not by Tab), so the arrow keys still step. With `navigation`
|
|
4705
|
+
* (more than one Story), it has previous and next buttons and arrow keys,
|
|
4706
|
+
* and the expanded view moves on when the video ends instead of looping.
|
|
4707
|
+
* The expanded view also shows the `neighbors` beside it.
|
|
2051
4708
|
*/
|
|
2052
|
-
render(story
|
|
4709
|
+
render(story, {
|
|
4710
|
+
navigation = false,
|
|
4711
|
+
neighbors = [],
|
|
4712
|
+
onPress,
|
|
4713
|
+
...destination
|
|
4714
|
+
}) {
|
|
4715
|
+
const { labels } = destination;
|
|
2053
4716
|
if (!this.isOpen) return A;
|
|
2054
|
-
const { video,
|
|
2055
|
-
const
|
|
4717
|
+
const { video, expanded } = this;
|
|
4718
|
+
const shownNeighbors = this.track(story, neighbors);
|
|
4719
|
+
const pair = this.pairDirection !== 0;
|
|
4720
|
+
this.navigation = navigation;
|
|
2056
4721
|
return T`
|
|
2057
4722
|
<dialog
|
|
2058
4723
|
class="player"
|
|
2059
4724
|
popover="manual"
|
|
2060
|
-
aria-label=${
|
|
4725
|
+
aria-label=${labels.player}
|
|
2061
4726
|
?data-expanded=${expanded}
|
|
4727
|
+
?data-pair=${pair}
|
|
4728
|
+
style=${o8({
|
|
4729
|
+
"--pair-dir": pair ? String(this.pairDirection) : void 0
|
|
4730
|
+
})}
|
|
2062
4731
|
?data-switched=${this.switched}
|
|
2063
|
-
?data-paused=${
|
|
4732
|
+
?data-paused=${hasVideo(story, video) && video.paused}
|
|
4733
|
+
tabindex="-1"
|
|
2064
4734
|
${n5(this.dialog)}
|
|
2065
4735
|
@click=${this.onDialogClick}
|
|
2066
4736
|
@cancel=${this.onCancel}
|
|
4737
|
+
@keydown=${this.onPlayerKeyDown}
|
|
2067
4738
|
>
|
|
4739
|
+
${this.renderNeighbors(shownNeighbors, labels)}
|
|
2068
4740
|
<div class="player-frame">
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
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}
|
|
4741
|
+
${this.renderWindowControls(labels)}
|
|
4742
|
+
<div
|
|
4743
|
+
class="player-stage"
|
|
4744
|
+
${n5(this.stage)}
|
|
4745
|
+
@click=${{
|
|
4746
|
+
handleEvent: (event) => {
|
|
4747
|
+
const card = this.stageCardRef.value;
|
|
4748
|
+
if (card == null ? void 0 : card.contains(event.target)) onPress == null ? void 0 : onPress();
|
|
4749
|
+
},
|
|
4750
|
+
capture: true
|
|
4751
|
+
}}
|
|
4752
|
+
>
|
|
4753
|
+
${navigation ? this.renderNavigation(labels) : A}
|
|
4754
|
+
${this.renderVideo(story, navigation && expanded, destination)}
|
|
4755
|
+
<span class="player-dim" aria-hidden="true" ${n5(this.dim)}></span>
|
|
2092
4756
|
</div>
|
|
2093
4757
|
</div>
|
|
2094
4758
|
</dialog>
|
|
@@ -2096,38 +4760,285 @@ var PlayerController = class {
|
|
|
2096
4760
|
}
|
|
2097
4761
|
};
|
|
2098
4762
|
|
|
4763
|
+
// src/utils/hydrate-products.ts
|
|
4764
|
+
var import_ads_core = require("@vtex/ads-core");
|
|
4765
|
+
|
|
4766
|
+
// src/utils/with-timeout.ts
|
|
4767
|
+
var withTimeout = (timeout, fallback, signal) => {
|
|
4768
|
+
const ms = timeout !== void 0 && Number.isFinite(timeout) && timeout > 0 ? timeout : fallback;
|
|
4769
|
+
const controller = new AbortController();
|
|
4770
|
+
const timer = setTimeout(
|
|
4771
|
+
() => controller.abort(
|
|
4772
|
+
new DOMException(`Timed out after ${ms} ms`, "TimeoutError")
|
|
4773
|
+
),
|
|
4774
|
+
ms
|
|
4775
|
+
);
|
|
4776
|
+
const onAbort = () => controller.abort(signal == null ? void 0 : signal.reason);
|
|
4777
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
4778
|
+
onAbort();
|
|
4779
|
+
} else {
|
|
4780
|
+
signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
|
|
4781
|
+
}
|
|
4782
|
+
return {
|
|
4783
|
+
signal: controller.signal,
|
|
4784
|
+
clear: () => {
|
|
4785
|
+
clearTimeout(timer);
|
|
4786
|
+
signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
|
|
4787
|
+
}
|
|
4788
|
+
};
|
|
4789
|
+
};
|
|
4790
|
+
|
|
4791
|
+
// src/utils/hydrate-products.ts
|
|
4792
|
+
var DEFAULT_HYDRATION_TIMEOUT_MS = 5e3;
|
|
4793
|
+
var intelligentSearchHydration = {
|
|
4794
|
+
fetcher: import_ads_core.intelligentSearchFetcher,
|
|
4795
|
+
matcher: import_ads_core.intelligentSearchMatcher,
|
|
4796
|
+
price: import_ads_core.intelligentSearchPrice,
|
|
4797
|
+
available: import_ads_core.intelligentSearchAvailability
|
|
4798
|
+
};
|
|
4799
|
+
function toShownPrice(value) {
|
|
4800
|
+
const isAmount = (amount) => typeof amount === "number" && Number.isFinite(amount) && amount >= 0;
|
|
4801
|
+
if (!isAmount(value == null ? void 0 : value.price)) return void 0;
|
|
4802
|
+
const { price, listPrice } = value;
|
|
4803
|
+
return isAmount(listPrice) && listPrice > price ? { price, listPrice } : { price };
|
|
4804
|
+
}
|
|
4805
|
+
async function hydrateStoryProducts(placement, stories, hydration, identity, { signal, timeout } = {}) {
|
|
4806
|
+
var _a13, _b3;
|
|
4807
|
+
const products = /* @__PURE__ */ new Map();
|
|
4808
|
+
const limit = withTimeout(timeout, DEFAULT_HYDRATION_TIMEOUT_MS, signal);
|
|
4809
|
+
try {
|
|
4810
|
+
const hydrated = await (0, import_ads_core.hydrateAds)(
|
|
4811
|
+
{ stories: { [placement]: stories } },
|
|
4812
|
+
hydration.fetcher,
|
|
4813
|
+
(product, offer) => hydration.matcher(product, offer),
|
|
4814
|
+
identity,
|
|
4815
|
+
{ signal: limit.signal }
|
|
4816
|
+
);
|
|
4817
|
+
for (const { story, product, offer } of (_a13 = hydrated.stories[placement]) != null ? _a13 : []) {
|
|
4818
|
+
if (!product || !offer) continue;
|
|
4819
|
+
try {
|
|
4820
|
+
const price = toShownPrice(hydration.price(product, offer));
|
|
4821
|
+
const available = (_b3 = hydration.available) == null ? void 0 : _b3.call(hydration, product, offer);
|
|
4822
|
+
products.set(story.ad_id, {
|
|
4823
|
+
...price && { price },
|
|
4824
|
+
...available !== void 0 && { available }
|
|
4825
|
+
});
|
|
4826
|
+
} catch (error) {
|
|
4827
|
+
console.error(
|
|
4828
|
+
`[${TAG_NAME}] Product details failed for ad ${story.ad_id}`,
|
|
4829
|
+
error
|
|
4830
|
+
);
|
|
4831
|
+
}
|
|
4832
|
+
}
|
|
4833
|
+
} catch (error) {
|
|
4834
|
+
if (!limit.signal.aborted) {
|
|
4835
|
+
console.error(`[${TAG_NAME}] Product request failed`, error);
|
|
4836
|
+
}
|
|
4837
|
+
} finally {
|
|
4838
|
+
limit.clear();
|
|
4839
|
+
}
|
|
4840
|
+
return products;
|
|
4841
|
+
}
|
|
4842
|
+
|
|
4843
|
+
// src/utils/fetch-story.ts
|
|
4844
|
+
var import_ads_core2 = require("@vtex/ads-core");
|
|
4845
|
+
var DEFAULT_TIMEOUT_MS = 2e3;
|
|
4846
|
+
var DEFAULT_QUANTITY = 8;
|
|
4847
|
+
var toQuantity = (quantity) => quantity !== void 0 && Number.isFinite(quantity) && quantity >= 1 ? Math.floor(quantity) : DEFAULT_QUANTITY;
|
|
4848
|
+
async function fetchStories({
|
|
4849
|
+
publisherId,
|
|
4850
|
+
sessionId,
|
|
4851
|
+
placement,
|
|
4852
|
+
userId,
|
|
4853
|
+
accountName,
|
|
4854
|
+
channel,
|
|
4855
|
+
quantity
|
|
4856
|
+
}, { signal, timeout } = {}) {
|
|
4857
|
+
var _a13;
|
|
4858
|
+
const onServer = globalThis.window === void 0;
|
|
4859
|
+
if (onServer || !publisherId || !sessionId || !placement) return [];
|
|
4860
|
+
const limit = withTimeout(timeout, DEFAULT_TIMEOUT_MS, signal);
|
|
4861
|
+
const count = toQuantity(quantity);
|
|
4862
|
+
try {
|
|
4863
|
+
const { stories } = await (0, import_ads_core2.getRawAds)(
|
|
4864
|
+
{
|
|
4865
|
+
identity: {
|
|
4866
|
+
accountName: accountName != null ? accountName : "",
|
|
4867
|
+
publisherId,
|
|
4868
|
+
sessionId,
|
|
4869
|
+
userId,
|
|
4870
|
+
channel
|
|
4871
|
+
},
|
|
4872
|
+
search: {},
|
|
4873
|
+
placements: {
|
|
4874
|
+
[placement]: { quantity: count, types: ["story"] }
|
|
4875
|
+
}
|
|
4876
|
+
},
|
|
4877
|
+
{ signal: limit.signal }
|
|
4878
|
+
);
|
|
4879
|
+
return ((_a13 = stories[placement]) != null ? _a13 : []).slice(0, count);
|
|
4880
|
+
} catch (error) {
|
|
4881
|
+
if (!limit.signal.aborted) {
|
|
4882
|
+
console.error(`[${TAG_NAME}] Story request failed`, {
|
|
4883
|
+
placement,
|
|
4884
|
+
publisherId,
|
|
4885
|
+
error
|
|
4886
|
+
});
|
|
4887
|
+
}
|
|
4888
|
+
return [];
|
|
4889
|
+
} finally {
|
|
4890
|
+
limit.clear();
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
|
|
4894
|
+
// src/utils/media-ready.ts
|
|
4895
|
+
var MEDIA_TIMEOUT = 3e3;
|
|
4896
|
+
function decodeImage(url) {
|
|
4897
|
+
if (typeof Image === "undefined") return Promise.resolve(true);
|
|
4898
|
+
const image = new Image();
|
|
4899
|
+
image.src = url;
|
|
4900
|
+
if (!image.decode) return Promise.resolve(true);
|
|
4901
|
+
return image.decode().then(
|
|
4902
|
+
() => true,
|
|
4903
|
+
() => false
|
|
4904
|
+
);
|
|
4905
|
+
}
|
|
4906
|
+
function firstReady(checks, signal) {
|
|
4907
|
+
if (!checks.length) return Promise.resolve();
|
|
4908
|
+
const limit = withTimeout(void 0, MEDIA_TIMEOUT, signal);
|
|
4909
|
+
return new Promise((resolve) => {
|
|
4910
|
+
const done = () => {
|
|
4911
|
+
limit.clear();
|
|
4912
|
+
resolve();
|
|
4913
|
+
};
|
|
4914
|
+
if (limit.signal.aborted) return done();
|
|
4915
|
+
limit.signal.addEventListener("abort", done, { once: true });
|
|
4916
|
+
let failed = 0;
|
|
4917
|
+
for (const check of checks) {
|
|
4918
|
+
check.then(
|
|
4919
|
+
(ready) => {
|
|
4920
|
+
if (ready || ++failed === checks.length) done();
|
|
4921
|
+
},
|
|
4922
|
+
() => {
|
|
4923
|
+
if (++failed === checks.length) done();
|
|
4924
|
+
}
|
|
4925
|
+
);
|
|
4926
|
+
}
|
|
4927
|
+
});
|
|
4928
|
+
}
|
|
4929
|
+
|
|
4930
|
+
// src/commerce-events.ts
|
|
4931
|
+
var ADD_TO_CART_EVENT = "vtex-ads-story:add-to-cart";
|
|
4932
|
+
var REMOVE_FROM_CART_EVENT = "vtex-ads-story:remove-from-cart";
|
|
4933
|
+
function cartEvent(type, { sku, seller }, quantity) {
|
|
4934
|
+
return new CustomEvent(type, {
|
|
4935
|
+
detail: { sku, ...seller && { seller }, quantity },
|
|
4936
|
+
bubbles: true,
|
|
4937
|
+
composed: true
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
function addToCartEvent(item, quantity = 1) {
|
|
4941
|
+
return cartEvent(ADD_TO_CART_EVENT, item, quantity);
|
|
4942
|
+
}
|
|
4943
|
+
function removeFromCartEvent(item, quantity = 1) {
|
|
4944
|
+
return cartEvent(REMOVE_FROM_CART_EVENT, item, quantity);
|
|
4945
|
+
}
|
|
4946
|
+
|
|
2099
4947
|
// src/story/story.ts
|
|
2100
|
-
var
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
4948
|
+
var REQUEST_PROPERTIES = [
|
|
4949
|
+
"publisherId",
|
|
4950
|
+
"sessionId",
|
|
4951
|
+
"placement",
|
|
4952
|
+
"userId",
|
|
4953
|
+
"accountName",
|
|
4954
|
+
"channel",
|
|
4955
|
+
"quantity",
|
|
4956
|
+
"hydration"
|
|
4957
|
+
];
|
|
4958
|
+
var CHANNELS = /* @__PURE__ */ new Set(["site", "app"]);
|
|
4959
|
+
var isChannel = (value) => CHANNELS.has(value);
|
|
4960
|
+
var booleanConverter = {
|
|
4961
|
+
fromAttribute: (value) => typeof value === "string" && (value === "" || value.toLowerCase() === "true")
|
|
2104
4962
|
};
|
|
2105
|
-
var
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
close: "Fechar v\xEDdeo",
|
|
2111
|
-
play: "Reproduzir v\xEDdeo",
|
|
2112
|
-
pause: "Pausar v\xEDdeo",
|
|
2113
|
-
soundOn: "Ativar som",
|
|
2114
|
-
soundOff: "Desativar som"
|
|
4963
|
+
var channelConverter = {
|
|
4964
|
+
fromAttribute: (value) => isChannel(value) ? value : void 0
|
|
4965
|
+
};
|
|
4966
|
+
var hydrationConverter = {
|
|
4967
|
+
fromAttribute: (value) => value === "none" ? "none" : void 0
|
|
2115
4968
|
};
|
|
2116
|
-
var
|
|
4969
|
+
var cartKey = ({ sku, seller }) => JSON.stringify([sku, seller != null ? seller : ""]);
|
|
4970
|
+
var VtexAdsStoryCarouselElement = class extends i3 {
|
|
2117
4971
|
constructor() {
|
|
2118
|
-
super(
|
|
2119
|
-
|
|
4972
|
+
super();
|
|
4973
|
+
/**
|
|
4974
|
+
* How many of each SKU, from each seller (see cartKey), were added since
|
|
4975
|
+
* the player opened, for its stepper. It doesn't read the store's cart: it
|
|
4976
|
+
* counts the add and remove events sent, and starts over each time the
|
|
4977
|
+
* player opens, as the cart may have changed meanwhile.
|
|
4978
|
+
*/
|
|
4979
|
+
this.cartQuantities = /* @__PURE__ */ new Map();
|
|
4980
|
+
/**
|
|
4981
|
+
* One per rendered card, by its key (see Slide): a Story can show in more
|
|
4982
|
+
* than one card, each with its own video.
|
|
4983
|
+
*/
|
|
4984
|
+
this.cardVideos = /* @__PURE__ */ new Map();
|
|
4985
|
+
/** The sound was on when the highlight moved: the new card turns it on. */
|
|
4986
|
+
this.soundPending = false;
|
|
4987
|
+
this.carousel = new CarouselController(this, {
|
|
4988
|
+
onStep: (from, to) => this.leaveHighlight(from, to),
|
|
4989
|
+
// Every card is new: so are their videos. Behind an open player, the
|
|
4990
|
+
// new highlighted card stays on its cover, as after a step.
|
|
4991
|
+
onLayoutChange: () => {
|
|
4992
|
+
this.cardVideos.clear();
|
|
4993
|
+
if (this.player.isOpen) {
|
|
4994
|
+
this.afterRender = () => {
|
|
4995
|
+
var _a13;
|
|
4996
|
+
return (_a13 = this.activeVideo) == null ? void 0 : _a13.pause();
|
|
4997
|
+
};
|
|
4998
|
+
}
|
|
4999
|
+
},
|
|
5000
|
+
// The player shows the highlighted Story: the highlight stays on it.
|
|
5001
|
+
locked: () => this.player.isOpen || this.mediaLoading,
|
|
5002
|
+
slideDuration: () => this.slideDuration,
|
|
5003
|
+
reducedMotion: prefersReducedMotion
|
|
5004
|
+
});
|
|
2120
5005
|
this.player = new PlayerController(this, {
|
|
2121
|
-
|
|
2122
|
-
expandLabel: LABELS.expand,
|
|
2123
|
-
collapseLabel: LABELS.collapse,
|
|
2124
|
-
closeLabel: LABELS.close,
|
|
2125
|
-
playLabel: LABELS.play,
|
|
2126
|
-
pauseLabel: LABELS.pause,
|
|
2127
|
-
soundOnLabel: LABELS.soundOn,
|
|
2128
|
-
soundOffLabel: LABELS.soundOff,
|
|
5006
|
+
onStep: (delta) => this.stepInPlayer(delta),
|
|
2129
5007
|
onClose: () => this.closePlayer()
|
|
2130
5008
|
});
|
|
5009
|
+
// Added after the carousel and the player: its hostUpdated reads what
|
|
5010
|
+
// they rendered.
|
|
5011
|
+
this.events = new StoryEventsController(this, {
|
|
5012
|
+
identity: () => ({ sessionId: this.sessionId, userId: this.userId }),
|
|
5013
|
+
viewTargets: () => this.viewTargets()
|
|
5014
|
+
});
|
|
5015
|
+
// The highlighted card opens the player; another one takes the highlight.
|
|
5016
|
+
// Hidden cards, out of sight, show only their cover.
|
|
5017
|
+
this.renderSlide = (story, { key, index, offset, active, hidden, cardRef, focusRef }) => renderCard(story, this.videoFor(key), {
|
|
5018
|
+
label: this.labels.position(
|
|
5019
|
+
active ? this.labels.watch : this.labels.show,
|
|
5020
|
+
index,
|
|
5021
|
+
this.stories.length
|
|
5022
|
+
),
|
|
5023
|
+
labels: this.labels,
|
|
5024
|
+
withVideo: active || this.inactiveAutoplay && !hidden,
|
|
5025
|
+
autoplay: !this.mediaLoading,
|
|
5026
|
+
product: this.productOf(story),
|
|
5027
|
+
onSelect: active ? () => this.openPlayer() : () => this.carousel.step(offset),
|
|
5028
|
+
// On a card without the highlight, the product moves it, as the card.
|
|
5029
|
+
onProductSelect: active ? () => this.openPlayer({ productOpen: true }) : void 0,
|
|
5030
|
+
// On the highlighted card it follows the link; on another, it moves the
|
|
5031
|
+
// highlight.
|
|
5032
|
+
cta: toCardCta(story),
|
|
5033
|
+
onCtaSelect: active ? void 0 : () => this.carousel.step(offset),
|
|
5034
|
+
onPress: () => this.events.click(story),
|
|
5035
|
+
ref: cardRef,
|
|
5036
|
+
openRef: focusRef
|
|
5037
|
+
});
|
|
5038
|
+
this.inactiveAutoplay = false;
|
|
5039
|
+
this.stories = [];
|
|
5040
|
+
this.requesting = false;
|
|
5041
|
+
this.mediaLoading = false;
|
|
2131
5042
|
}
|
|
2132
5043
|
// Lit keeps the card's DOM when the element is moved (removed and appended
|
|
2133
5044
|
// again), but the browser pauses a removed video and doesn't autoplay it
|
|
@@ -2136,59 +5047,371 @@ var VtexAdsStoryElement = class extends i3 {
|
|
|
2136
5047
|
// Not in VideoController.hostConnected: there, the player's video is still
|
|
2137
5048
|
// in the DOM until the next update and would play for a moment.
|
|
2138
5049
|
connectedCallback() {
|
|
5050
|
+
var _a13;
|
|
2139
5051
|
super.connectedCallback();
|
|
2140
|
-
this.
|
|
5052
|
+
for (const video of this.cardVideos.values()) video.resume();
|
|
5053
|
+
if ((_a13 = this.request) == null ? void 0 : _a13.signal.aborted) void this.loadStory();
|
|
2141
5054
|
}
|
|
2142
|
-
|
|
5055
|
+
// A request still pending when the element leaves the page is cancelled.
|
|
5056
|
+
disconnectedCallback() {
|
|
5057
|
+
var _a13, _b3;
|
|
5058
|
+
super.disconnectedCallback();
|
|
5059
|
+
(_a13 = this.request) == null ? void 0 : _a13.abort();
|
|
5060
|
+
(_b3 = this.mediaWait) == null ? void 0 : _b3.abort();
|
|
5061
|
+
}
|
|
5062
|
+
willUpdate(changed) {
|
|
5063
|
+
if (REQUEST_PROPERTIES.some((name) => changed.has(name))) {
|
|
5064
|
+
void this.loadStory();
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
updated() {
|
|
5068
|
+
const afterRender = this.afterRender;
|
|
5069
|
+
this.afterRender = void 0;
|
|
5070
|
+
afterRender == null ? void 0 : afterRender();
|
|
5071
|
+
}
|
|
5072
|
+
// The strategy for the products' details, if any (see `hydration`).
|
|
5073
|
+
get activeHydration() {
|
|
5074
|
+
if (this.hydration === "none") return void 0;
|
|
5075
|
+
if (this.hydration) return this.hydration;
|
|
5076
|
+
return this.accountName ? intelligentSearchHydration : void 0;
|
|
5077
|
+
}
|
|
5078
|
+
/**
|
|
5079
|
+
* Requests the Story and shows it, then hydrates its products. Until the
|
|
5080
|
+
* Story arrives, and when there is none (see fetchStories), the element
|
|
5081
|
+
* renders nothing.
|
|
5082
|
+
*/
|
|
5083
|
+
async loadStory() {
|
|
5084
|
+
var _a13, _b3, _c, _d, _e;
|
|
5085
|
+
(_a13 = this.request) == null ? void 0 : _a13.abort();
|
|
5086
|
+
const request = new AbortController();
|
|
5087
|
+
this.request = request;
|
|
5088
|
+
this.player.close();
|
|
5089
|
+
this.requesting = false;
|
|
5090
|
+
this.showStories([]);
|
|
5091
|
+
if (!this.isConnected) {
|
|
5092
|
+
request.abort();
|
|
5093
|
+
return;
|
|
5094
|
+
}
|
|
5095
|
+
this.requesting = Boolean(
|
|
5096
|
+
this.publisherId && this.sessionId && this.placement
|
|
5097
|
+
);
|
|
5098
|
+
const stories = await fetchStories(this, {
|
|
5099
|
+
signal: request.signal,
|
|
5100
|
+
timeout: this.timeout
|
|
5101
|
+
});
|
|
5102
|
+
if (request.signal.aborted) return;
|
|
5103
|
+
this.requesting = false;
|
|
5104
|
+
const hydration = this.activeHydration;
|
|
5105
|
+
if (!hydration || !stories.some((story) => story.product)) {
|
|
5106
|
+
this.request = void 0;
|
|
5107
|
+
this.showStories(stories);
|
|
5108
|
+
return;
|
|
5109
|
+
}
|
|
5110
|
+
this.showStories(stories, "loading");
|
|
5111
|
+
const products = await hydrateStoryProducts(
|
|
5112
|
+
(_b3 = this.placement) != null ? _b3 : "",
|
|
5113
|
+
stories,
|
|
5114
|
+
hydration,
|
|
5115
|
+
{
|
|
5116
|
+
accountName: (_c = this.accountName) != null ? _c : "",
|
|
5117
|
+
publisherId: (_d = this.publisherId) != null ? _d : "",
|
|
5118
|
+
sessionId: (_e = this.sessionId) != null ? _e : "",
|
|
5119
|
+
userId: this.userId,
|
|
5120
|
+
channel: this.channel
|
|
5121
|
+
},
|
|
5122
|
+
{ signal: request.signal, timeout: this.hydrationTimeout }
|
|
5123
|
+
);
|
|
5124
|
+
if (request.signal.aborted) return;
|
|
5125
|
+
this.request = void 0;
|
|
5126
|
+
this.products = products;
|
|
5127
|
+
}
|
|
5128
|
+
// Each card's video starts fresh: a failed load of an old one doesn't hide
|
|
5129
|
+
// it.
|
|
5130
|
+
showStories(stories, products) {
|
|
5131
|
+
this.products = products;
|
|
5132
|
+
this.cardVideos.clear();
|
|
5133
|
+
this.soundPending = false;
|
|
5134
|
+
this.afterRender = void 0;
|
|
5135
|
+
this.carousel.reset(stories.length);
|
|
5136
|
+
this.stories = stories;
|
|
5137
|
+
void this.waitForFirstMedia(stories);
|
|
5138
|
+
}
|
|
5139
|
+
/**
|
|
5140
|
+
* Shows the cards once the first Story's cover or video is ready: whichever
|
|
5141
|
+
* loads first, or once both failed. Only then are the Stories impressed
|
|
5142
|
+
* and do their videos play, from the start.
|
|
5143
|
+
*/
|
|
5144
|
+
async waitForFirstMedia(stories) {
|
|
5145
|
+
var _a13, _b3, _c;
|
|
5146
|
+
(_a13 = this.mediaWait) == null ? void 0 : _a13.abort();
|
|
5147
|
+
const wait = new AbortController();
|
|
5148
|
+
this.mediaWait = wait;
|
|
5149
|
+
const cover = httpUrl((_b3 = stories[0]) == null ? void 0 : _b3.poster_url);
|
|
5150
|
+
const video = httpUrl((_c = stories[0]) == null ? void 0 : _c.media_url);
|
|
5151
|
+
const checks = [];
|
|
5152
|
+
if (cover) checks.push(decodeImage(cover));
|
|
5153
|
+
if (video) checks.push(this.videoFor(this.carousel.activeKey).ready);
|
|
5154
|
+
this.mediaLoading = checks.length > 0;
|
|
5155
|
+
await firstReady(checks, wait.signal);
|
|
5156
|
+
if (this.mediaWait !== wait) return;
|
|
5157
|
+
this.mediaWait = void 0;
|
|
5158
|
+
this.mediaLoading = false;
|
|
5159
|
+
this.events.impress(stories);
|
|
5160
|
+
this.afterRender = () => {
|
|
5161
|
+
if (!this.isConnected) return;
|
|
5162
|
+
for (const cardVideo of this.cardVideos.values()) cardVideo.resume();
|
|
5163
|
+
};
|
|
5164
|
+
this.requestUpdate();
|
|
5165
|
+
}
|
|
5166
|
+
/**
|
|
5167
|
+
* Where each Story is being watched: the cards on screen (not the hidden
|
|
5168
|
+
* ones kept for the slide in) and the open player's video, while their
|
|
5169
|
+
* video plays. A card showing only its cover doesn't count. Behind the
|
|
5170
|
+
* expanded player, a modal over the page, the cards are covered.
|
|
5171
|
+
*/
|
|
5172
|
+
*viewTargets() {
|
|
5173
|
+
var _a13;
|
|
5174
|
+
const { stories } = this;
|
|
5175
|
+
if (this.mediaLoading) return;
|
|
5176
|
+
if (!this.player.isExpanded) {
|
|
5177
|
+
for (const [card, { key, index }] of this.carousel.visibleCards()) {
|
|
5178
|
+
const story = stories[index];
|
|
5179
|
+
if (story && ((_a13 = this.cardVideos.get(key)) == null ? void 0 : _a13.playing)) yield [card, story];
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5182
|
+
const stageCard = this.player.stageCard;
|
|
5183
|
+
const active = stories[this.carousel.active];
|
|
5184
|
+
if (stageCard && active && this.player.video.playing) {
|
|
5185
|
+
yield [stageCard, active];
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
videoFor(key) {
|
|
5189
|
+
let video = this.cardVideos.get(key);
|
|
5190
|
+
if (!video) {
|
|
5191
|
+
video = new VideoController(this);
|
|
5192
|
+
this.cardVideos.set(key, video);
|
|
5193
|
+
}
|
|
5194
|
+
return video;
|
|
5195
|
+
}
|
|
5196
|
+
get activeVideo() {
|
|
5197
|
+
return this.cardVideos.get(this.carousel.activeKey);
|
|
5198
|
+
}
|
|
5199
|
+
// The card losing the highlight goes quiet: muted if it keeps playing, or
|
|
5200
|
+
// back to its cover. Its next video then starts fresh. If its sound was
|
|
5201
|
+
// on, the sound moves to the new highlighted card, once its video renders.
|
|
5202
|
+
// With the player open (it stepped), the new card stays on its cover
|
|
5203
|
+
// behind it instead. Cards no longer rendered (the rolling layout drops
|
|
5204
|
+
// them as it moves) leave with their videos.
|
|
5205
|
+
leaveHighlight(from, to) {
|
|
5206
|
+
const video = this.cardVideos.get(from);
|
|
5207
|
+
this.soundPending || (this.soundPending = video !== void 0 && !video.muted);
|
|
5208
|
+
if (this.inactiveAutoplay) video == null ? void 0 : video.mute();
|
|
5209
|
+
else video == null ? void 0 : video.reset();
|
|
5210
|
+
if (this.player.isOpen) {
|
|
5211
|
+
this.soundPending = false;
|
|
5212
|
+
this.afterRender = () => this.videoFor(to).pause();
|
|
5213
|
+
} else if (this.soundPending) {
|
|
5214
|
+
this.afterRender = () => {
|
|
5215
|
+
this.soundPending = false;
|
|
5216
|
+
this.videoFor(to).playWithSound();
|
|
5217
|
+
};
|
|
5218
|
+
}
|
|
5219
|
+
for (const key of this.cardVideos.keys()) {
|
|
5220
|
+
if (Math.abs(key - to) > RENDERED_SIDE) this.cardVideos.delete(key);
|
|
5221
|
+
}
|
|
5222
|
+
}
|
|
5223
|
+
// The player's previous and next buttons: the highlight moves with the
|
|
5224
|
+
// Story the player shows.
|
|
5225
|
+
stepInPlayer(delta) {
|
|
5226
|
+
this.carousel.step(delta, { evenIfLocked: true });
|
|
5227
|
+
void this.player.showNext(delta);
|
|
5228
|
+
}
|
|
5229
|
+
// From the card's product, the player opens with the product panel open.
|
|
5230
|
+
openPlayer({ productOpen = false } = {}) {
|
|
5231
|
+
var _a13;
|
|
2143
5232
|
if (this.player.isOpen) return;
|
|
2144
|
-
this.
|
|
2145
|
-
|
|
5233
|
+
this.cartQuantities.clear();
|
|
5234
|
+
(_a13 = this.activeVideo) == null ? void 0 : _a13.pause();
|
|
5235
|
+
void this.player.open({ productOpen });
|
|
2146
5236
|
}
|
|
2147
5237
|
// The player also closes on its own when the element leaves the page,
|
|
2148
5238
|
// without this: there is no card to give focus back to or to resume playing
|
|
2149
5239
|
// (it would play out of sight).
|
|
2150
5240
|
closePlayer() {
|
|
2151
|
-
var _a13;
|
|
2152
5241
|
if (!this.player.isOpen) return;
|
|
2153
5242
|
this.player.close();
|
|
2154
|
-
this.
|
|
2155
|
-
|
|
5243
|
+
for (const video of this.cardVideos.values()) video.resume();
|
|
5244
|
+
this.carousel.focusActive();
|
|
5245
|
+
}
|
|
5246
|
+
// Prices and texts follow the language of the closest element with a
|
|
5247
|
+
// `lang`, the element itself included, so a store can set one for the
|
|
5248
|
+
// widget alone. An empty `lang` (unknown) is skipped; none, or an unknown
|
|
5249
|
+
// one, falls back to pt-BR.
|
|
5250
|
+
get locale() {
|
|
5251
|
+
var _a13, _b3;
|
|
5252
|
+
return (_b3 = (_a13 = this.closest('[lang]:not([lang=""])')) == null ? void 0 : _a13.lang) != null ? _b3 : DEFAULT_LOCALE;
|
|
5253
|
+
}
|
|
5254
|
+
get labels() {
|
|
5255
|
+
var _a13;
|
|
5256
|
+
const { locale, labelAddToCart = "", labelViewProduct = "" } = this;
|
|
5257
|
+
const key = JSON.stringify([locale, labelAddToCart, labelViewProduct]);
|
|
5258
|
+
if (((_a13 = this.labelSet) == null ? void 0 : _a13.key) !== key) {
|
|
5259
|
+
this.labelSet = {
|
|
5260
|
+
key,
|
|
5261
|
+
labels: labelsFor(locale, {
|
|
5262
|
+
addToCart: labelAddToCart,
|
|
5263
|
+
viewProduct: labelViewProduct
|
|
5264
|
+
})
|
|
5265
|
+
};
|
|
5266
|
+
}
|
|
5267
|
+
return this.labelSet.labels;
|
|
5268
|
+
}
|
|
5269
|
+
get formatPrice() {
|
|
5270
|
+
var _a13, _b3;
|
|
5271
|
+
const { locale } = this;
|
|
5272
|
+
const key = `${locale}|${(_a13 = this.currency) != null ? _a13 : ""}`;
|
|
5273
|
+
if (((_b3 = this.formatter) == null ? void 0 : _b3.key) !== key) {
|
|
5274
|
+
this.formatter = { key, format: priceFormatter(locale, this.currency) };
|
|
5275
|
+
}
|
|
5276
|
+
return this.formatter.format;
|
|
5277
|
+
}
|
|
5278
|
+
productOf(story) {
|
|
5279
|
+
var _a13;
|
|
5280
|
+
const fetched = this.products === "loading" ? "loading" : (_a13 = this.products) == null ? void 0 : _a13.get(story.ad_id);
|
|
5281
|
+
return toCardProduct(story, this.formatPrice, this.labels, fetched);
|
|
2156
5282
|
}
|
|
2157
5283
|
render() {
|
|
5284
|
+
const { stories } = this;
|
|
5285
|
+
const index = this.carousel.active;
|
|
5286
|
+
const active = stories[index];
|
|
5287
|
+
if (!active && !this.requesting) return A;
|
|
5288
|
+
const loading = this.requesting || this.mediaLoading;
|
|
2158
5289
|
return T`
|
|
2159
|
-
<div
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
5290
|
+
<div
|
|
5291
|
+
class="root"
|
|
5292
|
+
?data-loading=${loading}
|
|
5293
|
+
?data-requesting=${this.requesting}
|
|
5294
|
+
>
|
|
5295
|
+
${active ? this.carousel.render(stories, this.renderSlide, this.labels) : A}
|
|
5296
|
+
${renderCarouselSkeleton({ done: !loading })}
|
|
2166
5297
|
</div>
|
|
2167
|
-
${this.
|
|
5298
|
+
${active ? this.renderPlayer(active) : A}
|
|
2168
5299
|
`;
|
|
2169
5300
|
}
|
|
5301
|
+
renderPlayer(active) {
|
|
5302
|
+
const { stories } = this;
|
|
5303
|
+
const index = this.carousel.active;
|
|
5304
|
+
const neighbors = neighborOffsets(stories.length, index).map((offset) => {
|
|
5305
|
+
const neighbor = (index + offset + stories.length) % stories.length;
|
|
5306
|
+
return {
|
|
5307
|
+
offset,
|
|
5308
|
+
story: stories[neighbor],
|
|
5309
|
+
label: this.labels.position(this.labels.show, neighbor, stories.length)
|
|
5310
|
+
};
|
|
5311
|
+
});
|
|
5312
|
+
const product = this.productOf(active);
|
|
5313
|
+
return this.player.render(active, {
|
|
5314
|
+
labels: this.labels,
|
|
5315
|
+
navigation: stories.length > 1,
|
|
5316
|
+
neighbors,
|
|
5317
|
+
product,
|
|
5318
|
+
cta: toCardCta(active),
|
|
5319
|
+
productActions: this.cartActionsFor(product),
|
|
5320
|
+
onPress: () => this.events.click(active)
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
cartActionsFor(product) {
|
|
5324
|
+
const sku = product == null ? void 0 : product.sku;
|
|
5325
|
+
if (!sku) return void 0;
|
|
5326
|
+
const item = { sku, seller: product.seller };
|
|
5327
|
+
return {
|
|
5328
|
+
cartQuantity: this.cartQuantities.get(cartKey(item)),
|
|
5329
|
+
onAddToCart: () => this.changeCart(item, 1),
|
|
5330
|
+
onRemoveFromCart: () => this.changeCart(item, -1)
|
|
5331
|
+
};
|
|
5332
|
+
}
|
|
5333
|
+
/**
|
|
5334
|
+
* Adds one of `item` to the stepper's count, or removes one, and tells the
|
|
5335
|
+
* store, which changes its cart: the element has none. When add to cart
|
|
5336
|
+
* and the stepper swap places, the focus moves to the one now shown.
|
|
5337
|
+
*/
|
|
5338
|
+
changeCart(item, delta) {
|
|
5339
|
+
var _a13;
|
|
5340
|
+
const key = cartKey(item);
|
|
5341
|
+
const before = (_a13 = this.cartQuantities.get(key)) != null ? _a13 : 0;
|
|
5342
|
+
const after = Math.max(0, before + delta);
|
|
5343
|
+
if (after === before) return;
|
|
5344
|
+
if (after > 0) this.cartQuantities.set(key, after);
|
|
5345
|
+
else this.cartQuantities.delete(key);
|
|
5346
|
+
this.requestUpdate();
|
|
5347
|
+
this.dispatchEvent(
|
|
5348
|
+
delta > 0 ? addToCartEvent(item) : removeFromCartEvent(item)
|
|
5349
|
+
);
|
|
5350
|
+
let swapped;
|
|
5351
|
+
if (before === 0) swapped = "stepper";
|
|
5352
|
+
else if (after === 0) swapped = "add";
|
|
5353
|
+
if (!swapped) return;
|
|
5354
|
+
const action = swapped;
|
|
5355
|
+
this.updateComplete.then(
|
|
5356
|
+
() => this.shadowRoot && focusCartAction(this.shadowRoot, action)
|
|
5357
|
+
);
|
|
5358
|
+
}
|
|
2170
5359
|
};
|
|
2171
|
-
|
|
5360
|
+
VtexAdsStoryCarouselElement.properties = {
|
|
5361
|
+
publisherId: { attribute: "publisher-id" },
|
|
5362
|
+
sessionId: { attribute: "session-id" },
|
|
5363
|
+
placement: {},
|
|
5364
|
+
userId: { attribute: "user-id" },
|
|
5365
|
+
accountName: { attribute: "account-name" },
|
|
5366
|
+
channel: { converter: channelConverter },
|
|
5367
|
+
timeout: { type: Number },
|
|
5368
|
+
quantity: { type: Number },
|
|
5369
|
+
currency: {},
|
|
5370
|
+
labelAddToCart: { attribute: "label-add-to-cart" },
|
|
5371
|
+
labelViewProduct: { attribute: "label-view-product" },
|
|
5372
|
+
hydration: { converter: hydrationConverter },
|
|
5373
|
+
hydrationTimeout: { type: Number, attribute: "hydration-timeout" },
|
|
5374
|
+
slideDuration: { type: Number, attribute: "slide-duration" },
|
|
5375
|
+
inactiveAutoplay: {
|
|
5376
|
+
type: Boolean,
|
|
5377
|
+
attribute: "inactive-autoplay",
|
|
5378
|
+
converter: booleanConverter
|
|
5379
|
+
},
|
|
5380
|
+
stories: { state: true },
|
|
5381
|
+
products: { state: true },
|
|
5382
|
+
requesting: { state: true },
|
|
5383
|
+
mediaLoading: { state: true }
|
|
5384
|
+
};
|
|
5385
|
+
VtexAdsStoryCarouselElement.styles = [
|
|
2172
5386
|
i`
|
|
2173
5387
|
:host {
|
|
2174
5388
|
display: block;
|
|
2175
5389
|
font-family: var(--vtex-ads-story-font-family, inherit);
|
|
2176
5390
|
color: var(--vtex-ads-story-color-text, inherit);
|
|
5391
|
+
--_pill-radius: var(--vtex-ads-story-radius, 16px);
|
|
5392
|
+
--_pill-inset: 8px;
|
|
5393
|
+
--_button-radius: var(--vtex-ads-story-radius, 999px);
|
|
2177
5394
|
}
|
|
2178
5395
|
`,
|
|
2179
5396
|
cardStyles,
|
|
5397
|
+
mediaStyles,
|
|
5398
|
+
productStyles,
|
|
5399
|
+
carouselStyles,
|
|
5400
|
+
carouselSkeletonStyles,
|
|
2180
5401
|
playerStyles
|
|
2181
5402
|
];
|
|
2182
|
-
function
|
|
5403
|
+
function defineVtexAdsStoryCarousel() {
|
|
2183
5404
|
if (typeof customElements === "undefined") return;
|
|
2184
5405
|
if (customElements.get(TAG_NAME)) return;
|
|
2185
|
-
customElements.define(TAG_NAME,
|
|
5406
|
+
customElements.define(TAG_NAME, VtexAdsStoryCarouselElement);
|
|
2186
5407
|
}
|
|
2187
5408
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2188
5409
|
0 && (module.exports = {
|
|
5410
|
+
ADD_TO_CART_EVENT,
|
|
5411
|
+
REMOVE_FROM_CART_EVENT,
|
|
2189
5412
|
TAG_NAME,
|
|
2190
|
-
|
|
2191
|
-
|
|
5413
|
+
VtexAdsStoryCarouselElement,
|
|
5414
|
+
defineVtexAdsStoryCarousel
|
|
2192
5415
|
});
|
|
2193
5416
|
/*! Icons from Phosphor Icons (https://phosphoricons.com), MIT License, Copyright (c) 2023 Phosphor Icons */
|
|
2194
5417
|
/*! Bundled license information:
|
|
@@ -2220,8 +5443,9 @@ function defineVtexAdsStories() {
|
|
|
2220
5443
|
lit-html/node/lit-html.js:
|
|
2221
5444
|
lit-element/lit-element.js:
|
|
2222
5445
|
lit-html/node/directive.js:
|
|
2223
|
-
lit-html/node/directives/unsafe-html.js:
|
|
2224
5446
|
lit-html/node/async-directive.js:
|
|
5447
|
+
lit-html/node/directives/unsafe-html.js:
|
|
5448
|
+
lit-html/node/directives/repeat.js:
|
|
2225
5449
|
(**
|
|
2226
5450
|
* @license
|
|
2227
5451
|
* Copyright 2017 Google LLC
|
|
@@ -2242,5 +5466,12 @@ lit-html/node/directives/ref.js:
|
|
|
2242
5466
|
* Copyright 2020 Google LLC
|
|
2243
5467
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
2244
5468
|
*)
|
|
5469
|
+
|
|
5470
|
+
lit-html/node/directives/style-map.js:
|
|
5471
|
+
(**
|
|
5472
|
+
* @license
|
|
5473
|
+
* Copyright 2018 Google LLC
|
|
5474
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5475
|
+
*)
|
|
2245
5476
|
*/
|
|
2246
5477
|
//# sourceMappingURL=index.cjs.map
|