@vio-live/web-sdk 0.23.0 → 0.24.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.
@@ -1,4 +1,4 @@
1
- import { Vio, __decorateClass, primaryImageUrl, displayPrice, getGlobalCurrency, ensureVippsButton, formatPrice, nexiReturnPaymentId, readNexiPending, kustomReturnOutcome, KUSTOM_RETURN_QUERY_KEYS, ADYEN_RETURN_METHOD, adyenReturnParams, ADYEN_RETURN_QUERY_KEYS, adyenReturnOutcome, AdyenOriginError, autoSlotDisplayName, autoSlotId, normalizeScope } from './chunk-AMDI7KH3.js';
1
+ import { Vio, __decorateClass, primaryImageUrl, displayPrice, toCampaignId, getGlobalCurrency, ensureVippsButton, formatPrice, nexiReturnPaymentId, readNexiPending, kustomReturnOutcome, KUSTOM_RETURN_QUERY_KEYS, ADYEN_RETURN_METHOD, adyenReturnParams, ADYEN_RETURN_QUERY_KEYS, adyenReturnOutcome, AdyenOriginError, normalizeSlotId, autoSlotDisplayName, autoSlotId, normalizeScope, campaignCandidates } from './chunk-AXJKB2CW.js';
2
2
  import { LitElement, css, html } from 'lit';
3
3
  import { property, state, query } from 'lit/decorators.js';
4
4
 
@@ -171,61 +171,94 @@ var SCOPE_ATTR = "vio-scope";
171
171
  var SCOPE_NAME_ATTR = "vio-scope-name";
172
172
  var SCOPE_DATA_ATTR = "data-vio-scope";
173
173
  var SCOPE_NAME_DATA_ATTR = "data-vio-scope-name";
174
+ var CAMPAIGN_ATTR = "vio-campaign";
175
+ var CAMPAIGN_DATA_ATTR = "data-vio-campaign";
176
+ var liveAutoIds = (() => {
177
+ const g = globalThis;
178
+ return g.__VIO_LIVE_SLOT_IDS__ ?? (g.__VIO_LIVE_SLOT_IDS__ = /* @__PURE__ */ new Map());
179
+ })();
174
180
  var SlotRegistration = class {
175
181
  constructor(host, kind) {
176
182
  this.host = host;
177
183
  this.kind = kind;
178
184
  this.identity = null;
179
185
  this.release = null;
180
- /** The element's position-based identity, fixed at connect time. */
181
- this.position = null;
186
+ /** The auto identity held (its number is kept while the element lives). */
187
+ this.auto = null;
188
+ /** Set by connect(); the scope label is read then too. */
189
+ this.connected = false;
190
+ this.scope = "";
191
+ this.scopeName = "";
182
192
  }
183
193
  /** The effective slot id ('' before connect / after disconnect). */
184
194
  get effective() {
185
195
  return this.identity?.id ?? "";
186
196
  }
187
- /** The identity in effect, or null. */
188
- get current() {
189
- return this.identity;
197
+ /** The element's own page campaign (`vio-campaign` / ancestor `data-vio-campaign`); undefined → `Vio.init`'s applies. */
198
+ get campaignId() {
199
+ return this.identity?.campaignId;
190
200
  }
191
- /** On connect: fix scope + ordinal from the element's position, then register. */
201
+ /** The element's page-campaign candidates in order (own, ancestor) — the hint for `Vio.attribution` / `campaignForSlot`. */
202
+ get campaignHint() {
203
+ return this.identity?.campaignCandidates ?? [];
204
+ }
205
+ /** On connect: read the scope from the DOM, then register. */
192
206
  connect(attrs) {
193
- this.position = positionOf(this.host, attrs);
207
+ this.connected = true;
208
+ this.scope = scopeOf(this.host, attrs);
209
+ this.scopeName = scopeNameOf(this.host, attrs);
194
210
  this.sync(attrs);
195
211
  }
196
212
  /** (Re)register when the attributes changed the identity. */
197
213
  sync(attrs) {
198
- if (this.position && scopeOf(this.host, attrs) !== this.position.scope) {
199
- this.position = positionOf(this.host, attrs);
214
+ if (!this.connected) return;
215
+ const scope = scopeOf(this.host, attrs);
216
+ if (scope !== this.scope) {
217
+ this.scope = scope;
218
+ this.scopeName = scopeNameOf(this.host, attrs);
219
+ this.releaseAuto();
220
+ } else {
221
+ const scopeName = scopeNameOf(this.host, attrs);
222
+ if (scopeName !== this.scopeName) this.scopeName = scopeName;
200
223
  }
201
224
  const next = this.resolve(attrs);
202
225
  if (sameIdentity(next, this.identity)) return;
203
- this.clear();
226
+ this.unregister();
204
227
  if (!next) return;
205
228
  try {
206
- this.release = Vio.registerSlot(next.id, next.displayName);
229
+ this.release = typeof Vio.registerSlot !== "function" ? null : next.campaignId !== void 0 ? Vio.registerSlot(next.id, next.displayName, next.campaignId) : Vio.registerSlot(next.id, next.displayName);
207
230
  this.identity = next;
208
231
  } catch {
209
232
  this.release = null;
210
233
  this.identity = null;
211
234
  }
212
235
  }
213
- /** What the identity would be for these attributes (null before connect without a host id). */
236
+ /** What the identity is for these attributes (null before connect without a host id). */
214
237
  resolve(attrs) {
215
- const explicit = typeof attrs.vioSlot === "string" ? attrs.vioSlot.trim() : "";
238
+ const explicit = normalizeSlotId(attrs.vioSlot);
216
239
  const name = typeof attrs.vioSlotName === "string" && attrs.vioSlotName.trim() ? attrs.vioSlotName.trim() : void 0;
217
- if (explicit) return { id: explicit, displayName: name, auto: false, scope: this.position?.scope ?? "" };
218
- if (!this.position) return null;
219
- const { scope, scopeName, ordinal } = this.position;
240
+ const campaignCandidates2 = campaignCandidatesOf(this.host, attrs);
241
+ const campaignId = campaignCandidates2[0];
242
+ if (explicit) {
243
+ this.releaseAuto();
244
+ return { id: explicit, displayName: name, campaignId, campaignCandidates: campaignCandidates2 };
245
+ }
246
+ if (!this.connected) return null;
247
+ const auto = this.claimAuto();
220
248
  return {
221
- id: autoSlotId(this.kind, ordinal, scope),
222
- displayName: name ?? autoSlotDisplayName(this.kind, ordinal, scopeName),
223
- auto: true,
224
- scope
249
+ id: auto.id,
250
+ displayName: name ?? autoSlotDisplayName(this.kind, auto.number - 1, this.scopeName),
251
+ campaignId,
252
+ campaignCandidates: campaignCandidates2
225
253
  };
226
254
  }
227
- /** Unregister whatever is registered. */
255
+ /** Unregister whatever is registered and free the auto number. */
228
256
  clear() {
257
+ this.unregister();
258
+ this.releaseAuto();
259
+ this.connected = false;
260
+ }
261
+ unregister() {
229
262
  try {
230
263
  this.release?.();
231
264
  } catch {
@@ -233,40 +266,46 @@ var SlotRegistration = class {
233
266
  this.release = null;
234
267
  this.identity = null;
235
268
  }
269
+ /** The element's auto id: the one it already holds, else the first free number. */
270
+ claimAuto() {
271
+ if (this.auto && this.auto.scope === this.scope) return this.auto;
272
+ this.releaseAuto();
273
+ for (let number = 1; ; number++) {
274
+ const id = autoSlotId(this.kind, number - 1, this.scope);
275
+ const holders = liveAutoIds.get(id);
276
+ if (!holders || holders.size === 0 || holders.size === 1 && holders.has(this.host)) {
277
+ const set = holders ?? /* @__PURE__ */ new Set();
278
+ set.add(this.host);
279
+ liveAutoIds.set(id, set);
280
+ this.auto = { id, scope: this.scope, number };
281
+ return this.auto;
282
+ }
283
+ }
284
+ }
285
+ releaseAuto() {
286
+ if (!this.auto) return;
287
+ const holders = liveAutoIds.get(this.auto.id);
288
+ holders?.delete(this.host);
289
+ if (holders && holders.size === 0) liveAutoIds.delete(this.auto.id);
290
+ this.auto = null;
291
+ }
236
292
  };
237
293
  function sameIdentity(a, b) {
238
294
  if (!a || !b) return a === b;
239
- return a.id === b.id && a.displayName === b.displayName;
295
+ return a.id === b.id && a.displayName === b.displayName && a.campaignId === b.campaignId;
296
+ }
297
+ function campaignCandidatesOf(el, attrs) {
298
+ const own = attrs && attrs.vioCampaign !== void 0 && attrs.vioCampaign !== null ? attrs.vioCampaign : el.vioCampaign !== void 0 ? el.vioCampaign : el.getAttribute(CAMPAIGN_ATTR);
299
+ const ancestor = closestAcrossShadow(el, `[${CAMPAIGN_DATA_ATTR}]`)?.getAttribute(CAMPAIGN_DATA_ATTR);
300
+ return campaignCandidates([own, ancestor]);
240
301
  }
241
302
  function scopeOf(el, attrs) {
242
303
  const own = attrs && typeof attrs.vioScope === "string" ? attrs.vioScope : typeof el.vioScope === "string" ? el.vioScope ?? "" : el.getAttribute(SCOPE_ATTR) ?? "";
243
- const value = normalizeScope(own) || normalizeScope(closestAcrossShadow(el, `[${SCOPE_DATA_ATTR}]`)?.getAttribute(SCOPE_DATA_ATTR));
244
- return value;
304
+ return normalizeScope(own) || normalizeScope(closestAcrossShadow(el, `[${SCOPE_DATA_ATTR}]`)?.getAttribute(SCOPE_DATA_ATTR));
245
305
  }
246
306
  function scopeNameOf(el, attrs) {
247
307
  const own = attrs && typeof attrs.vioScopeName === "string" ? attrs.vioScopeName : typeof el.vioScopeName === "string" ? el.vioScopeName ?? "" : el.getAttribute(SCOPE_NAME_ATTR) ?? "";
248
- const value = own.trim() || (closestAcrossShadow(el, `[${SCOPE_NAME_DATA_ATTR}]`)?.getAttribute(SCOPE_NAME_DATA_ATTR) ?? "").trim();
249
- return value;
250
- }
251
- function positionOf(host, attrs) {
252
- const scope = scopeOf(host, attrs);
253
- const scopeName = scopeNameOf(host, attrs);
254
- let ordinal = 0;
255
- try {
256
- const tag = host.tagName.toLowerCase();
257
- const root = host.getRootNode();
258
- const scopeRoot = root && typeof root.querySelectorAll === "function" ? root : typeof document !== "undefined" ? document : null;
259
- if (scopeRoot) {
260
- const peers = Array.from(scopeRoot.querySelectorAll(tag)).filter(
261
- (el) => el === host || scopeOf(el) === scope
262
- );
263
- const index = peers.indexOf(host);
264
- ordinal = index >= 0 ? index : 0;
265
- }
266
- } catch {
267
- ordinal = 0;
268
- }
269
- return { scope, scopeName, ordinal };
308
+ return own.trim() || (closestAcrossShadow(el, `[${SCOPE_NAME_DATA_ATTR}]`)?.getAttribute(SCOPE_NAME_DATA_ATTR) ?? "").trim();
270
309
  }
271
310
  function closestAcrossShadow(start, selector) {
272
311
  try {
@@ -297,6 +336,7 @@ var VioProduct = class extends LitElement {
297
336
  this.vioSlotName = "";
298
337
  this.vioScope = "";
299
338
  this.vioScopeName = "";
339
+ this.vioCampaign = "";
300
340
  this.vioContentId = "";
301
341
  this.vioContentTitle = "";
302
342
  this.slotRegistration = new SlotRegistration(this, "card");
@@ -313,9 +353,13 @@ var VioProduct = class extends LitElement {
313
353
  get effectiveSlot() {
314
354
  return this.slotRegistration.effective;
315
355
  }
356
+ /** The element's own page campaign (`vio-campaign` / ancestor), if any; `Vio.init`'s applies otherwise. */
357
+ get effectiveCampaignId() {
358
+ return this.slotRegistration.campaignId;
359
+ }
316
360
  /** The slot campaign's sponsor as the string the attributes use ('' when unknown). */
317
361
  sponsorFromAttribution() {
318
- const id = Vio.attribution(this.effectiveSlot).sponsorId;
362
+ const id = typeof Vio.attribution === "function" ? Vio.attribution(this.effectiveSlot, { campaignId: this.slotRegistration.campaignHint }).sponsorId : void 0;
319
363
  return id !== void 0 ? String(id) : "";
320
364
  }
321
365
  slotAttributes() {
@@ -323,7 +367,8 @@ var VioProduct = class extends LitElement {
323
367
  vioSlot: this.vioSlot,
324
368
  vioSlotName: this.vioSlotName,
325
369
  vioScope: this.vioScope,
326
- vioScopeName: this.vioScopeName
370
+ vioScopeName: this.vioScopeName,
371
+ vioCampaign: this.vioCampaign
327
372
  };
328
373
  }
329
374
  /**
@@ -332,7 +377,10 @@ var VioProduct = class extends LitElement {
332
377
  * set `vio-content-id` / `vio-content-title` on this card.
333
378
  */
334
379
  attribution() {
335
- const base = Vio.attribution(this.effectiveSlot, { sponsorId: this.sponsorId || void 0 });
380
+ const base = typeof Vio.attribution === "function" ? Vio.attribution(this.effectiveSlot, {
381
+ sponsorId: this.sponsorId || void 0,
382
+ campaignId: this.slotRegistration.campaignHint
383
+ }) : { slot: this.effectiveSlot || void 0 };
336
384
  return {
337
385
  ...base,
338
386
  ...this.vioContentId ? { contentId: this.vioContentId } : {},
@@ -462,7 +510,7 @@ var VioProduct = class extends LitElement {
462
510
  }
463
511
  updated(changed) {
464
512
  if (changed.has("productId") || changed.has("sponsorId")) this.updateInCart();
465
- if (changed.has("vioSlot") || changed.has("vioSlotName") || changed.has("vioScope") || changed.has("vioScopeName")) {
513
+ if (changed.has("vioSlot") || changed.has("vioSlotName") || changed.has("vioScope") || changed.has("vioScopeName") || changed.has("vioCampaign")) {
466
514
  this.slotRegistration.sync(this.slotAttributes());
467
515
  }
468
516
  }
@@ -618,6 +666,9 @@ __decorateClass([
618
666
  __decorateClass([
619
667
  property({ type: String, attribute: "vio-scope-name" })
620
668
  ], VioProduct.prototype, "vioScopeName", 2);
669
+ __decorateClass([
670
+ property({ type: String, attribute: "vio-campaign" })
671
+ ], VioProduct.prototype, "vioCampaign", 2);
621
672
  __decorateClass([
622
673
  property({ type: String, attribute: "vio-content-id" })
623
674
  ], VioProduct.prototype, "vioContentId", 2);
@@ -662,6 +713,7 @@ var VioProductCarousel = class extends LitElement {
662
713
  this.vioSlotName = "";
663
714
  this.vioScope = "";
664
715
  this.vioScopeName = "";
716
+ this.vioCampaign = "";
665
717
  this.vioContentId = "";
666
718
  this.vioContentTitle = "";
667
719
  this.slotRegistration = new SlotRegistration(this, "carousel");
@@ -680,17 +732,25 @@ var VioProductCarousel = class extends LitElement {
680
732
  get effectiveSlot() {
681
733
  return this.slotRegistration.effective;
682
734
  }
735
+ /** The element's own page campaign (`vio-campaign` / ancestor), if any; `Vio.init`'s applies otherwise. */
736
+ get effectiveCampaignId() {
737
+ return this.slotRegistration.campaignId;
738
+ }
683
739
  slotAttributes() {
684
740
  return {
685
741
  vioSlot: this.vioSlot,
686
742
  vioSlotName: this.vioSlotName,
687
743
  vioScope: this.vioScope,
688
- vioScopeName: this.vioScopeName
744
+ vioScopeName: this.vioScopeName,
745
+ vioCampaign: this.vioCampaign
689
746
  };
690
747
  }
691
748
  /** Attribution every analytics event of this carousel carries (`Vio.attribution` + the content overrides). */
692
749
  attribution() {
693
- const base = Vio.attribution(this.effectiveSlot, { sponsorId: this.sponsorId > 0 ? this.sponsorId : void 0 });
750
+ const base = typeof Vio.attribution === "function" ? Vio.attribution(this.effectiveSlot, {
751
+ sponsorId: this.sponsorId > 0 ? this.sponsorId : void 0,
752
+ campaignId: this.slotRegistration.campaignHint
753
+ }) : { slot: this.effectiveSlot || void 0 };
694
754
  return {
695
755
  ...base,
696
756
  ...this.vioContentId ? { contentId: this.vioContentId } : {},
@@ -857,10 +917,10 @@ var VioProductCarousel = class extends LitElement {
857
917
  super.disconnectedCallback();
858
918
  }
859
919
  updated(changed) {
860
- if (changed.has("vioSlot") || changed.has("vioSlotName") || changed.has("vioScope") || changed.has("vioScopeName")) {
920
+ if (changed.has("vioSlot") || changed.has("vioSlotName") || changed.has("vioScope") || changed.has("vioScopeName") || changed.has("vioCampaign")) {
861
921
  this.slotRegistration.sync(this.slotAttributes());
862
922
  }
863
- const propChanged = changed.has("productRefs") || changed.has("productIds") || changed.has("commerceKey") || changed.has("sponsorId") || changed.has("vioSlot");
923
+ const propChanged = changed.has("productRefs") || changed.has("productIds") || changed.has("commerceKey") || changed.has("sponsorId") || changed.has("vioSlot") || changed.has("vioCampaign");
864
924
  if (propChanged && (this.productRefs.trim() || this.productIds.trim())) {
865
925
  void this.autoFetch();
866
926
  }
@@ -872,7 +932,7 @@ var VioProductCarousel = class extends LitElement {
872
932
  */
873
933
  effectiveSponsorId() {
874
934
  if (this.sponsorId > 0) return this.sponsorId;
875
- const fromSlot = Number(Vio.campaignForSlot(this.effectiveSlot || null)?.primarySponsor?.id);
935
+ const fromSlot = typeof Vio.campaignForSlot === "function" ? Number(Vio.campaignForSlot(this.effectiveSlot || null, { campaignId: this.slotRegistration.campaignHint })?.primarySponsor?.id) : NaN;
876
936
  return Number.isFinite(fromSlot) && fromSlot > 0 ? fromSlot : 0;
877
937
  }
878
938
  async autoFetch() {
@@ -1021,6 +1081,7 @@ var VioProductCarousel = class extends LitElement {
1021
1081
  image-url=${img}
1022
1082
  ?has-variants=${(p.variants?.length ?? 0) > 1}
1023
1083
  .vioSlot=${this.effectiveSlot}
1084
+ .vioCampaign=${this.effectiveCampaignId !== void 0 ? String(this.effectiveCampaignId) : ""}
1024
1085
  .vioContentId=${this.vioContentId}
1025
1086
  .vioContentTitle=${this.vioContentTitle}
1026
1087
  ></vio-product>
@@ -1104,6 +1165,9 @@ __decorateClass([
1104
1165
  __decorateClass([
1105
1166
  property({ type: String, attribute: "vio-scope-name" })
1106
1167
  ], VioProductCarousel.prototype, "vioScopeName", 2);
1168
+ __decorateClass([
1169
+ property({ type: String, attribute: "vio-campaign" })
1170
+ ], VioProductCarousel.prototype, "vioCampaign", 2);
1107
1171
  __decorateClass([
1108
1172
  property({ type: String, attribute: "vio-content-id" })
1109
1173
  ], VioProductCarousel.prototype, "vioContentId", 2);
@@ -1352,13 +1416,16 @@ var VioProductDetail = class extends LitElement {
1352
1416
  this.vioSlotName = "";
1353
1417
  this.vioScope = "";
1354
1418
  this.vioScopeName = "";
1419
+ this.vioCampaign = "";
1355
1420
  this.vioContentId = "";
1356
1421
  this.vioContentTitle = "";
1357
1422
  this.slotRegistration = new SlotRegistration(this, "detail");
1358
- /** What the click that opened the detail carried ('' when nothing). */
1423
+ /** What the click that opened the detail carried ('' when nothing), and for which product. */
1359
1424
  this.eventSlot = "";
1360
1425
  this.eventContentId = "";
1361
1426
  this.eventContentTitle = "";
1427
+ this.eventCampaignId = void 0;
1428
+ this.eventProductId = "";
1362
1429
  this.product = null;
1363
1430
  this.sellerName = null;
1364
1431
  this.sellerSettled = false;
@@ -1392,11 +1459,17 @@ var VioProductDetail = class extends LitElement {
1392
1459
  const slot = typeof ev.detail.slot === "string" ? ev.detail.slot.trim() : "";
1393
1460
  let sponsorIdNum = parseInt(ev.detail.sponsorId, 10);
1394
1461
  if (Number.isNaN(sponsorIdNum) || sponsorIdNum <= 0) {
1395
- const fromSlot = Number(Vio.campaignForSlot(slot || this.effectiveSlot || null)?.primarySponsor?.id);
1462
+ const fromSlot = typeof Vio.campaignForSlot === "function" ? Number(
1463
+ Vio.campaignForSlot(slot || this.effectiveSlot || null, {
1464
+ campaignId: [ev.detail.campaignId, ...this.slotRegistration.campaignHint]
1465
+ })?.primarySponsor?.id
1466
+ ) : NaN;
1396
1467
  if (!Number.isFinite(fromSlot) || fromSlot <= 0) return;
1397
1468
  sponsorIdNum = fromSlot;
1398
1469
  }
1399
1470
  this.eventSlot = slot;
1471
+ this.eventCampaignId = toCampaignId(ev.detail.campaignId);
1472
+ this.eventProductId = String(ev.detail.productId);
1400
1473
  this.eventContentId = ev.detail.contentId !== void 0 && ev.detail.contentId !== null ? String(ev.detail.contentId).trim() : "";
1401
1474
  this.eventContentTitle = typeof ev.detail.contentTitle === "string" ? ev.detail.contentTitle.trim() : "";
1402
1475
  this.productId = ev.detail.productId;
@@ -1406,27 +1479,44 @@ var VioProductDetail = class extends LitElement {
1406
1479
  void this.fetchProduct();
1407
1480
  };
1408
1481
  }
1482
+ /** The card's context applies to the product it opened — not to one the host opened by hand later. */
1483
+ get fromCard() {
1484
+ return this.eventProductId !== "" && this.eventProductId === String(this.productId);
1485
+ }
1409
1486
  /** The slot id in effect for this element: `vio-slot`, else the auto id (`detail-N`). Read-only. */
1410
1487
  get effectiveSlot() {
1411
1488
  return this.slotRegistration.effective;
1412
1489
  }
1490
+ /** The element's own page campaign (`vio-campaign` / ancestor), if any; `Vio.init`'s applies otherwise. */
1491
+ get effectiveCampaignId() {
1492
+ return this.slotRegistration.campaignId;
1493
+ }
1413
1494
  /** The slot the open product is attributed to: the opening card's, else this element's. */
1414
1495
  get activeSlot() {
1415
- return this.eventSlot || this.effectiveSlot;
1496
+ return this.fromCard && this.eventSlot || this.effectiveSlot;
1497
+ }
1498
+ /** The page-campaign candidates of the open product: the opening card's, then this element's own and its ancestor's. */
1499
+ get activeCampaignHint() {
1500
+ const own = this.slotRegistration.campaignHint;
1501
+ return this.fromCard && this.eventCampaignId !== void 0 ? [this.eventCampaignId, ...own] : own;
1416
1502
  }
1417
1503
  slotAttributes() {
1418
1504
  return {
1419
1505
  vioSlot: this.vioSlot,
1420
1506
  vioSlotName: this.vioSlotName,
1421
1507
  vioScope: this.vioScope,
1422
- vioScopeName: this.vioScopeName
1508
+ vioScopeName: this.vioScopeName,
1509
+ vioCampaign: this.vioCampaign
1423
1510
  };
1424
1511
  }
1425
1512
  /** Attribution every event of the open product carries (`Vio.attribution` of the opening card's slot, else this element's). */
1426
1513
  attribution() {
1427
- const base = Vio.attribution(this.activeSlot, { sponsorId: this.sponsorId > 0 ? this.sponsorId : void 0 });
1428
- const contentId = this.eventContentId || this.vioContentId;
1429
- const contentTitle = this.eventContentTitle || this.vioContentTitle;
1514
+ const base = typeof Vio.attribution === "function" ? Vio.attribution(this.activeSlot, {
1515
+ sponsorId: this.sponsorId > 0 ? this.sponsorId : void 0,
1516
+ campaignId: this.activeCampaignHint
1517
+ }) : { slot: this.activeSlot || void 0 };
1518
+ const contentId = this.fromCard && this.eventContentId || this.vioContentId;
1519
+ const contentTitle = this.fromCard && this.eventContentTitle || this.vioContentTitle;
1430
1520
  return {
1431
1521
  ...base,
1432
1522
  ...contentId ? { contentId } : {},
@@ -1891,7 +1981,7 @@ var VioProductDetail = class extends LitElement {
1891
1981
  }
1892
1982
  updated(changed) {
1893
1983
  if (changed.has("open")) this.dialogFocus.update(this.open);
1894
- if (changed.has("vioSlot") || changed.has("vioSlotName") || changed.has("vioScope") || changed.has("vioScopeName")) {
1984
+ if (changed.has("vioSlot") || changed.has("vioSlotName") || changed.has("vioScope") || changed.has("vioScopeName") || changed.has("vioCampaign")) {
1895
1985
  this.slotRegistration.sync(this.slotAttributes());
1896
1986
  }
1897
1987
  }
@@ -1902,6 +1992,11 @@ var VioProductDetail = class extends LitElement {
1902
1992
  this.open = false;
1903
1993
  setTimeout(() => {
1904
1994
  if (!this.open) {
1995
+ this.eventSlot = "";
1996
+ this.eventContentId = "";
1997
+ this.eventContentTitle = "";
1998
+ this.eventCampaignId = void 0;
1999
+ this.eventProductId = "";
1905
2000
  this.product = null;
1906
2001
  this.sellerName = null;
1907
2002
  this.sellerSettled = false;
@@ -2001,7 +2096,7 @@ var VioProductDetail = class extends LitElement {
2001
2096
  }
2002
2097
  /** Which buy buttons to render — backend-configured per sponsor. */
2003
2098
  async loadAvailablePaymentMethods() {
2004
- const spId = this.sponsorId || Number(Vio.campaignForSlot(this.activeSlot || null)?.primarySponsor?.id) || globalThis.__VIO_SPONSOR_ID__;
2099
+ const spId = this.sponsorId || (typeof Vio.campaignForSlot === "function" ? Number(Vio.campaignForSlot(this.activeSlot || null, { campaignId: this.activeCampaignHint })?.primarySponsor?.id) : 0) || globalThis.__VIO_SPONSOR_ID__;
2005
2100
  if (!spId) return;
2006
2101
  try {
2007
2102
  const methods = await Vio.checkout.getAvailablePaymentMethods(spId);
@@ -2707,6 +2802,9 @@ __decorateClass([
2707
2802
  __decorateClass([
2708
2803
  property({ type: String, attribute: "vio-scope-name" })
2709
2804
  ], VioProductDetail.prototype, "vioScopeName", 2);
2805
+ __decorateClass([
2806
+ property({ type: String, attribute: "vio-campaign" })
2807
+ ], VioProductDetail.prototype, "vioCampaign", 2);
2710
2808
  __decorateClass([
2711
2809
  property({ type: String, attribute: "vio-content-id" })
2712
2810
  ], VioProductDetail.prototype, "vioContentId", 2);
@@ -7007,5 +7105,5 @@ function registerVioElements() {
7007
7105
  }
7008
7106
 
7009
7107
  export { VioCart, VioCheckout, VioProduct, VioProductCarousel, VioProductDetail, VioTokens, applyVioTheme, registerVioElements };
7010
- //# sourceMappingURL=chunk-COCHGJ2K.js.map
7011
- //# sourceMappingURL=chunk-COCHGJ2K.js.map
7108
+ //# sourceMappingURL=chunk-N6U65DWG.js.map
7109
+ //# sourceMappingURL=chunk-N6U65DWG.js.map