@session-services/web-elements 0.1.20 → 0.1.22

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.
Files changed (32) hide show
  1. package/dist/cjs/{index-C6e98Atu.js → index-BYBgrATL.js} +1 -0
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/session-services-elements.cjs.js +2 -2
  4. package/dist/cjs/session-services-formatted-text.cjs.entry.js +181 -165
  5. package/dist/cjs/session-services-ticketing.cjs.entry.js +24370 -19296
  6. package/dist/collection/components/session-services-formatted-text/session-services-formatted-text.js +33 -34
  7. package/dist/collection/components/session-services-ticketing/session-services-ticketing.css +429 -340
  8. package/dist/collection/components/session-services-ticketing/session-services-ticketing.js +1090 -269
  9. package/dist/collection/components/session-services-ticketing/session-services-ticketing.logic.js +270 -0
  10. package/dist/collection/components/session-services-ticketing/session-services-ticketing.logic.test.js +368 -0
  11. package/dist/collection/components/session-services-ticketing/session-services-ticketing.test.js +264 -0
  12. package/dist/components/session-services-formatted-text.js +180 -164
  13. package/dist/components/session-services-ticketing.js +24458 -19366
  14. package/dist/esm/{index-CeXOR4aK.js → index-CNOpF6tk.js} +1 -1
  15. package/dist/esm/loader.js +3 -3
  16. package/dist/esm/session-services-elements.js +3 -3
  17. package/dist/esm/session-services-formatted-text.entry.js +181 -165
  18. package/dist/esm/session-services-ticketing.entry.js +24378 -19304
  19. package/dist/session-services-elements/{p-a2404c46.entry.js → p-703444ed.entry.js} +1 -1
  20. package/dist/session-services-elements/p-94173d1b.entry.js +1 -0
  21. package/dist/session-services-elements/p-CNOpF6tk.js +2 -0
  22. package/dist/session-services-elements/session-services-elements.esm.js +1 -1
  23. package/dist/sst-env.d.ts +1 -0
  24. package/dist/types/components/session-services-formatted-text/session-services-formatted-text.d.ts +3 -0
  25. package/dist/types/components/session-services-ticketing/session-services-ticketing.d.ts +117 -3
  26. package/dist/types/components/session-services-ticketing/session-services-ticketing.logic.d.ts +196 -0
  27. package/dist/types/components/session-services-ticketing/session-services-ticketing.logic.test.d.ts +1 -0
  28. package/dist/types/components/session-services-ticketing/session-services-ticketing.test.d.ts +1 -0
  29. package/dist/types/components.d.ts +18 -0
  30. package/package.json +8 -7
  31. package/dist/session-services-elements/p-3bb6ceef.entry.js +0 -1
  32. package/dist/session-services-elements/p-CeXOR4aK.js +0 -2
@@ -1523,6 +1523,7 @@ function transformTag(tag) {
1523
1523
  exports.Host = Host;
1524
1524
  exports.bootstrapLazy = bootstrapLazy;
1525
1525
  exports.createEvent = createEvent;
1526
+ exports.getElement = getElement;
1526
1527
  exports.h = h;
1527
1528
  exports.promiseResolve = promiseResolve;
1528
1529
  exports.registerInstance = registerInstance;
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-C6e98Atu.js');
3
+ var index = require('./index-BYBgrATL.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
6
6
  const defineCustomElements = async (win, options) => {
7
7
  if (typeof window === 'undefined') return undefined;
8
8
  await appGlobals.globalScripts();
9
- return index.bootstrapLazy([["session-services-formatted-text.cjs",[[769,"session-services-formatted-text",{"text":[1],"theme":[1],"currentTheme":[32],"segments":[32]},null,{"text":["textChanged"],"theme":["themeChanged"]}]]],["session-services-ticketing.cjs",[[769,"session-services-ticketing",{"tenantId":[1,"tenant-id"],"eventId":[1,"event-id"],"apiUrl":[1,"api-url"],"locale":[1],"returnUrl":[1,"return-url"],"theme":[1],"enableAnalytics":[4,"enable-analytics"],"debugAnalytics":[4,"debug-analytics"],"event":[32],"selectedItems":[32],"quote":[32],"loading":[32],"error":[32],"quoteLoading":[32],"quoteError":[32],"checkoutLoading":[32],"currentTheme":[32],"openModalAdmissionId":[32]},null,{"tenantId":["propsChanged"],"eventId":["propsChanged"],"apiUrl":["propsChanged"],"theme":["themeChanged"]}]]]], options);
9
+ return index.bootstrapLazy([["session-services-formatted-text.cjs",[[769,"session-services-formatted-text",{"text":[1],"theme":[1],"currentTheme":[32],"segments":[32]},null,{"text":["textChanged"],"theme":["themeChanged"]}]]],["session-services-ticketing.cjs",[[769,"session-services-ticketing",{"tenantId":[1,"tenant-id"],"eventId":[1,"event-id"],"apiUrl":[1,"api-url"],"locale":[1],"returnUrl":[1,"return-url"],"couponCode":[1,"coupon-code"],"initialAdmissionPrices":[1,"initial-admission-prices"],"initialPreviewQuote":[1,"initial-preview-quote"],"passcode":[1],"stickyCheckout":[4,"sticky-checkout"],"theme":[1],"enableAnalytics":[4,"enable-analytics"],"debugAnalytics":[4,"debug-analytics"],"event":[32],"selectedItems":[32],"quote":[32],"previewQuote":[32],"loading":[32],"error":[32],"quoteLoading":[32],"previewLoading":[32],"quoteError":[32],"couponError":[32],"couponInput":[32],"appliedCouponCode":[32],"passcodeInput":[32],"activePasscode":[32],"passcodeDenied":[32],"selectionPrompt":[32],"checkoutLoading":[32],"currentTheme":[32],"openModalAdmissionId":[32]},null,{"tenantId":["propsChanged"],"eventId":["propsChanged"],"apiUrl":["propsChanged"],"passcode":["propsChanged"],"couponCode":["couponCodeChanged"],"initialAdmissionPrices":["couponCodeChanged"],"initialPreviewQuote":["couponCodeChanged"],"theme":["themeChanged"]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-C6e98Atu.js');
3
+ var index = require('./index-BYBgrATL.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
6
6
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["session-services-formatted-text.cjs",[[769,"session-services-formatted-text",{"text":[1],"theme":[1],"currentTheme":[32],"segments":[32]},null,{"text":["textChanged"],"theme":["themeChanged"]}]]],["session-services-ticketing.cjs",[[769,"session-services-ticketing",{"tenantId":[1,"tenant-id"],"eventId":[1,"event-id"],"apiUrl":[1,"api-url"],"locale":[1],"returnUrl":[1,"return-url"],"theme":[1],"enableAnalytics":[4,"enable-analytics"],"debugAnalytics":[4,"debug-analytics"],"event":[32],"selectedItems":[32],"quote":[32],"loading":[32],"error":[32],"quoteLoading":[32],"quoteError":[32],"checkoutLoading":[32],"currentTheme":[32],"openModalAdmissionId":[32]},null,{"tenantId":["propsChanged"],"eventId":["propsChanged"],"apiUrl":["propsChanged"],"theme":["themeChanged"]}]]]], options);
22
+ return index.bootstrapLazy([["session-services-formatted-text.cjs",[[769,"session-services-formatted-text",{"text":[1],"theme":[1],"currentTheme":[32],"segments":[32]},null,{"text":["textChanged"],"theme":["themeChanged"]}]]],["session-services-ticketing.cjs",[[769,"session-services-ticketing",{"tenantId":[1,"tenant-id"],"eventId":[1,"event-id"],"apiUrl":[1,"api-url"],"locale":[1],"returnUrl":[1,"return-url"],"couponCode":[1,"coupon-code"],"initialAdmissionPrices":[1,"initial-admission-prices"],"initialPreviewQuote":[1,"initial-preview-quote"],"passcode":[1],"stickyCheckout":[4,"sticky-checkout"],"theme":[1],"enableAnalytics":[4,"enable-analytics"],"debugAnalytics":[4,"debug-analytics"],"event":[32],"selectedItems":[32],"quote":[32],"previewQuote":[32],"loading":[32],"error":[32],"quoteLoading":[32],"previewLoading":[32],"quoteError":[32],"couponError":[32],"couponInput":[32],"appliedCouponCode":[32],"passcodeInput":[32],"activePasscode":[32],"passcodeDenied":[32],"selectionPrompt":[32],"checkoutLoading":[32],"currentTheme":[32],"openModalAdmissionId":[32]},null,{"tenantId":["propsChanged"],"eventId":["propsChanged"],"apiUrl":["propsChanged"],"passcode":["propsChanged"],"couponCode":["couponCodeChanged"],"initialAdmissionPrices":["couponCodeChanged"],"initialPreviewQuote":["couponCodeChanged"],"theme":["themeChanged"]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-C6e98Atu.js');
3
+ var index = require('./index-BYBgrATL.js');
4
4
 
5
5
  var tlds = [
6
6
  "aaa",
@@ -1445,7 +1445,7 @@ var tlds = [
1445
1445
 
1446
1446
  const URL_WITH_PROTOCOL = /https?:\/\/[^\s<>"]+/gi;
1447
1447
  const EMAIL = /[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}/gi;
1448
- const INSTAGRAM = /(?<![a-z0-9._%+-])@([a-z0-9][a-z0-9._]{0,29})\b/gi;
1448
+ const INSTAGRAM = /@([a-z0-9][a-z0-9._]{0,29})\b/gi;
1449
1449
  const SOUNDCLOUD = /https?:\/\/(?:www\.)?soundcloud\.com\/[a-z0-9_-]+(?:\/[^\s<>"]*)?/gi;
1450
1450
  const DIVIDER = /^[-=]{3,}$/gm;
1451
1451
  let bareDomainPattern = null;
@@ -1463,6 +1463,9 @@ const MAX_TEXT_LENGTH_FOR_BARE_DOMAIN = 2048;
1463
1463
  function cleanUrl(url) {
1464
1464
  return url.replace(/[.,;:!?)]+$/, "");
1465
1465
  }
1466
+ function matchIndex(match) {
1467
+ return match.index ?? 0;
1468
+ }
1466
1469
  function isSoundCloudUrl(url) {
1467
1470
  try {
1468
1471
  const parsed = new URL(url);
@@ -1471,86 +1474,105 @@ function isSoundCloudUrl(url) {
1471
1474
  return false;
1472
1475
  }
1473
1476
  }
1474
- function findLinks(text) {
1475
- const matches = [];
1476
- const usedRanges = [];
1477
- const isOverlapping = (start, end) => {
1478
- return usedRanges.some(
1479
- ([s, e]) => start >= s && start < e || end > s && end <= e || start <= s && end >= e
1480
- );
1477
+ function isLinkMatch(match) {
1478
+ return Boolean(match);
1479
+ }
1480
+ function isInstagramBoundary(text, index) {
1481
+ if (index === 0) return true;
1482
+ const prev = text[index - 1];
1483
+ return prev ? !/[a-z0-9._%+-]/i.test(prev) : true;
1484
+ }
1485
+ function soundCloudMatch(_text, match) {
1486
+ const index = matchIndex(match);
1487
+ const url = cleanUrl(match[0]);
1488
+ return {
1489
+ type: "soundcloud",
1490
+ start: index,
1491
+ end: index + url.length,
1492
+ text: url,
1493
+ href: url
1481
1494
  };
1482
- const addMatch = (match) => {
1483
- if (!isOverlapping(match.start, match.end)) {
1484
- matches.push(match);
1485
- usedRanges.push([match.start, match.end]);
1486
- }
1495
+ }
1496
+ function urlMatch(_text, match) {
1497
+ const url = cleanUrl(match[0]);
1498
+ if (isSoundCloudUrl(url)) return void 0;
1499
+ const index = matchIndex(match);
1500
+ return {
1501
+ type: "url",
1502
+ start: index,
1503
+ end: index + url.length,
1504
+ text: url,
1505
+ href: url
1487
1506
  };
1488
- SOUNDCLOUD.lastIndex = 0;
1489
- for (const match of text.matchAll(SOUNDCLOUD)) {
1490
- const index = match.index ?? 0;
1491
- const url = cleanUrl(match[0]);
1492
- addMatch({
1493
- type: "soundcloud",
1494
- start: index,
1495
- end: index + url.length,
1496
- text: url,
1497
- href: url
1498
- });
1499
- }
1500
- URL_WITH_PROTOCOL.lastIndex = 0;
1501
- for (const match of text.matchAll(URL_WITH_PROTOCOL)) {
1502
- const index = match.index ?? 0;
1503
- const url = cleanUrl(match[0]);
1504
- if (!isSoundCloudUrl(url)) {
1505
- addMatch({
1506
- type: "url",
1507
- start: index,
1508
- end: index + url.length,
1509
- text: url,
1510
- href: url
1511
- });
1512
- }
1513
- }
1514
- EMAIL.lastIndex = 0;
1515
- for (const match of text.matchAll(EMAIL)) {
1516
- const index = match.index ?? 0;
1517
- addMatch({
1518
- type: "email",
1519
- start: index,
1520
- end: index + match[0].length,
1521
- text: match[0],
1522
- href: `mailto:${match[0]}`
1523
- });
1524
- }
1525
- INSTAGRAM.lastIndex = 0;
1526
- for (const match of text.matchAll(INSTAGRAM)) {
1527
- const index = match.index ?? 0;
1528
- const username = match[1];
1529
- addMatch({
1530
- type: "instagram",
1531
- start: index,
1532
- end: index + match[0].length,
1533
- text: match[0],
1534
- href: `https://instagram.com/${username}`
1535
- });
1536
- }
1537
- if (text.length <= MAX_TEXT_LENGTH_FOR_BARE_DOMAIN) {
1538
- const bareDomain = getBareDomainPattern();
1539
- bareDomain.lastIndex = 0;
1540
- for (const match of text.matchAll(bareDomain)) {
1541
- const index = match.index ?? 0;
1542
- const domain = cleanUrl(match[0]);
1543
- addMatch({
1544
- type: "url",
1545
- start: index,
1546
- end: index + domain.length,
1547
- text: domain,
1548
- href: `https://${domain}`
1549
- });
1550
- }
1507
+ }
1508
+ function emailMatch(_text, match) {
1509
+ const index = matchIndex(match);
1510
+ return {
1511
+ type: "email",
1512
+ start: index,
1513
+ end: index + match[0].length,
1514
+ text: match[0],
1515
+ href: `mailto:${match[0]}`
1516
+ };
1517
+ }
1518
+ function instagramMatch(text, match) {
1519
+ const index = matchIndex(match);
1520
+ if (!isInstagramBoundary(text, index)) return void 0;
1521
+ const username = match[1];
1522
+ return {
1523
+ type: "instagram",
1524
+ start: index,
1525
+ end: index + match[0].length,
1526
+ text: match[0],
1527
+ href: `https://instagram.com/${username}`
1528
+ };
1529
+ }
1530
+ function bareDomainMatch(_text, match) {
1531
+ const index = matchIndex(match);
1532
+ const domain = cleanUrl(match[0]);
1533
+ return {
1534
+ type: "url",
1535
+ start: index,
1536
+ end: index + domain.length,
1537
+ text: domain,
1538
+ href: `https://${domain}`
1539
+ };
1540
+ }
1541
+ const BASE_LINK_EXTRACTORS = [
1542
+ { pattern: SOUNDCLOUD, toMatch: soundCloudMatch },
1543
+ { pattern: URL_WITH_PROTOCOL, toMatch: urlMatch },
1544
+ { pattern: EMAIL, toMatch: emailMatch },
1545
+ { pattern: INSTAGRAM, toMatch: instagramMatch }
1546
+ ];
1547
+ function bareDomainExtractor() {
1548
+ return { pattern: getBareDomainPattern(), toMatch: bareDomainMatch };
1549
+ }
1550
+ function matchesForExtractor(text, extractor) {
1551
+ extractor.pattern.lastIndex = 0;
1552
+ return Array.from(
1553
+ text.matchAll(extractor.pattern),
1554
+ (match) => extractor.toMatch(text, match)
1555
+ ).filter(isLinkMatch);
1556
+ }
1557
+ function rangesOverlap(a, b) {
1558
+ return a.start < b.end && a.end > b.start;
1559
+ }
1560
+ function withoutOverlaps(candidates) {
1561
+ const matches = [];
1562
+ const used = [];
1563
+ for (const candidate of candidates) {
1564
+ if (used.some((range) => rangesOverlap(candidate, range))) continue;
1565
+ matches.push(candidate);
1566
+ used.push(candidate);
1551
1567
  }
1552
1568
  return matches.sort((a, b) => a.start - b.start);
1553
1569
  }
1570
+ function findLinks(text) {
1571
+ const extractors = text.length <= MAX_TEXT_LENGTH_FOR_BARE_DOMAIN ? [...BASE_LINK_EXTRACTORS, bareDomainExtractor()] : BASE_LINK_EXTRACTORS;
1572
+ return withoutOverlaps(
1573
+ extractors.flatMap((extractor) => matchesForExtractor(text, extractor))
1574
+ );
1575
+ }
1554
1576
  function findDividers(text) {
1555
1577
  const dividers = [];
1556
1578
  DIVIDER.lastIndex = 0;
@@ -1575,72 +1597,67 @@ function parseFormattedText(text) {
1575
1597
  if (!text) {
1576
1598
  return [];
1577
1599
  }
1578
- const links = findLinks(text);
1579
- const dividers = findDividers(text);
1580
1600
  const segments = [];
1581
- const markers = [
1582
- ...links.map((l) => ({
1583
- type: "link",
1584
- data: l,
1585
- start: l.start,
1586
- end: l.end
1587
- })),
1588
- ...dividers.map((d) => ({
1589
- type: "divider",
1590
- start: d.start,
1591
- end: d.end
1592
- }))
1593
- ].sort((a, b) => a.start - b.start);
1601
+ const markers = buildMarkers(findLinks(text), findDividers(text));
1594
1602
  let lastEnd = 0;
1595
1603
  let lastWasDivider = false;
1596
1604
  for (const marker of markers) {
1597
1605
  if (marker.start < lastEnd) continue;
1598
- if (marker.start > lastEnd) {
1599
- let textContent = text.slice(lastEnd, marker.start);
1600
- if (lastWasDivider) {
1601
- textContent = textContent.replace(/^\n+/, "");
1602
- }
1603
- if (marker.type === "divider") {
1604
- textContent = textContent.replace(/\n+$/, "");
1605
- }
1606
- if (textContent) {
1607
- segments.push({ type: "text", content: textContent });
1608
- }
1609
- }
1610
- if (marker.type === "link") {
1611
- const link = marker.data;
1612
- if (link.type === "soundcloud") {
1613
- segments.push({
1614
- type: "soundcloud",
1615
- content: link.text,
1616
- href: link.href
1617
- });
1618
- } else {
1619
- segments.push({
1620
- type: "link",
1621
- content: link.text,
1622
- href: link.href,
1623
- linkType: link.type
1624
- });
1625
- }
1626
- lastWasDivider = false;
1627
- } else {
1628
- segments.push({ type: "divider", content: "" });
1629
- lastWasDivider = true;
1630
- }
1606
+ appendTextSegment(segments, text, lastEnd, marker.start, {
1607
+ trimLeading: lastWasDivider,
1608
+ trimTrailing: marker.type === "divider"
1609
+ });
1610
+ segments.push(markerSegment(marker));
1631
1611
  lastEnd = marker.end;
1612
+ lastWasDivider = marker.type === "divider";
1632
1613
  }
1633
- if (lastEnd < text.length) {
1634
- let textContent = text.slice(lastEnd);
1635
- if (lastWasDivider) {
1636
- textContent = textContent.replace(/^\n+/, "");
1637
- }
1638
- if (textContent) {
1639
- segments.push({ type: "text", content: textContent });
1640
- }
1641
- }
1614
+ appendTextSegment(segments, text, lastEnd, text.length, {
1615
+ trimLeading: lastWasDivider,
1616
+ trimTrailing: false
1617
+ });
1642
1618
  return segments;
1643
1619
  }
1620
+ function buildMarkers(links, dividers) {
1621
+ return [
1622
+ ...links.map((link) => ({
1623
+ type: "link",
1624
+ data: link,
1625
+ start: link.start,
1626
+ end: link.end
1627
+ })),
1628
+ ...dividers.map((divider) => ({
1629
+ type: "divider",
1630
+ start: divider.start,
1631
+ end: divider.end
1632
+ }))
1633
+ ].sort((a, b) => a.start - b.start);
1634
+ }
1635
+ function trimTextSegment(content, opts) {
1636
+ const leading = opts.trimLeading ? content.replace(/^\n+/, "") : content;
1637
+ return opts.trimTrailing ? leading.replace(/\n+$/, "") : leading;
1638
+ }
1639
+ function appendTextSegment(segments, text, start, end, opts) {
1640
+ if (start >= end) return;
1641
+ const content = trimTextSegment(text.slice(start, end), opts);
1642
+ if (content) segments.push({ type: "text", content });
1643
+ }
1644
+ function markerSegment(marker) {
1645
+ if (marker.type === "divider") return { type: "divider", content: "" };
1646
+ const link = marker.data;
1647
+ if (link.type === "soundcloud") {
1648
+ return {
1649
+ type: "soundcloud",
1650
+ content: link.text,
1651
+ href: link.href
1652
+ };
1653
+ }
1654
+ return {
1655
+ type: "link",
1656
+ content: link.text,
1657
+ href: link.href,
1658
+ linkType: link.type
1659
+ };
1660
+ }
1644
1661
 
1645
1662
  const sessionServicesFormattedTextCss = () => `:host{--foreground:oklch(0.145 0 0);--muted-foreground:oklch(0.556 0 0);--primary:oklch(0.42 0.24 264.376);--border:oklch(0.922 0 0);--ring:oklch(0.708 0 0);--radius:0.5rem;--spacing-md:1rem;--spacing-lg:1.5rem;--font-family:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
1646
1663
  "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;--transition-fast:150ms cubic-bezier(0.4, 0, 0.2, 1);--internal-foreground:var(--foreground, oklch(0.145 0 0));--internal-muted-foreground:var(--muted-foreground, oklch(0.556 0 0));--internal-primary:var(--primary, oklch(0.42 0.24 264.376));--internal-border:var(--border, oklch(0.922 0 0));--internal-ring:var(--ring, oklch(0.708 0 0));--internal-radius:var(--radius, 0.5rem);--internal-spacing-md:var(--spacing-md, 1rem);--internal-spacing-lg:var(--spacing-lg, 1.5rem);--internal-font-family:var(
@@ -1680,28 +1697,27 @@ const SessionServicesFormattedText = class {
1680
1697
  this.setupTheme();
1681
1698
  }
1682
1699
  disconnectedCallback() {
1683
- if (this.mediaQueryList) {
1684
- this.mediaQueryList.removeEventListener("change", this.handleSystemThemeChange);
1685
- }
1700
+ this.removeThemeListener();
1686
1701
  }
1687
1702
  setupTheme() {
1688
- if (this.mediaQueryList) {
1689
- this.mediaQueryList.removeEventListener("change", this.handleSystemThemeChange);
1690
- }
1691
- if (this.theme === "system") {
1692
- // Guard for testing environments (JSDOM) where matchMedia may not exist
1693
- if (typeof globalThis.matchMedia === "function") {
1694
- this.mediaQueryList = globalThis.matchMedia("(prefers-color-scheme: dark)");
1695
- this.currentTheme = this.mediaQueryList.matches ? "dark" : "light";
1696
- this.mediaQueryList.addEventListener("change", this.handleSystemThemeChange);
1697
- }
1698
- else {
1699
- this.currentTheme = "light";
1700
- }
1701
- }
1702
- else {
1703
+ this.removeThemeListener();
1704
+ if (this.theme !== "system") {
1703
1705
  this.currentTheme = this.theme;
1706
+ return;
1704
1707
  }
1708
+ this.setupSystemTheme();
1709
+ }
1710
+ removeThemeListener() {
1711
+ this.mediaQueryList?.removeEventListener("change", this.handleSystemThemeChange);
1712
+ }
1713
+ setupSystemTheme() {
1714
+ if (typeof globalThis.matchMedia !== "function") {
1715
+ this.currentTheme = "light";
1716
+ return;
1717
+ }
1718
+ this.mediaQueryList = globalThis.matchMedia("(prefers-color-scheme: dark)");
1719
+ this.currentTheme = this.mediaQueryList.matches ? "dark" : "light";
1720
+ this.mediaQueryList.addEventListener("change", this.handleSystemThemeChange);
1705
1721
  }
1706
1722
  handleSystemThemeChange = (e) => {
1707
1723
  if (this.theme === "system") {
@@ -1733,21 +1749,21 @@ const SessionServicesFormattedText = class {
1733
1749
  return (index.h("div", { key: key, class: "soundcloud-embed" }, index.h("iframe", { width: "100%", height: "166", scrolling: "no", allow: "autoplay", sandbox: "allow-scripts allow-same-origin allow-popups", src: embedUrl, title: iframeTitle, loading: "lazy" })));
1734
1750
  }
1735
1751
  renderSegment(segment, index$1) {
1736
- switch (segment.type) {
1737
- case "text":
1738
- return index.h("span", { key: index$1 }, segment.content);
1739
- case "link":
1740
- return this.renderLink(segment, index$1);
1741
- case "divider":
1742
- return index.h("hr", { key: index$1, class: "formatted-divider" });
1743
- case "soundcloud":
1744
- return this.renderSoundCloudEmbed(segment.href || "", index$1, segment.content);
1745
- default:
1746
- return null;
1747
- }
1752
+ if (segment.type === "text")
1753
+ return index.h("span", { key: index$1 }, segment.content);
1754
+ if (segment.type === "link")
1755
+ return this.renderLink(segment, index$1);
1756
+ if (segment.type === "divider")
1757
+ return index.h("hr", { key: index$1, class: "formatted-divider" });
1758
+ return this.renderMediaSegment(segment, index$1);
1759
+ }
1760
+ renderMediaSegment(segment, index) {
1761
+ if (segment.type !== "soundcloud")
1762
+ return null;
1763
+ return this.renderSoundCloudEmbed(segment.href || "", index, segment.content);
1748
1764
  }
1749
1765
  render() {
1750
- return (index.h(index.Host, { key: '1a7f36efb8cdbd1efdaa97c36b60593a13c99c4e', "data-theme": this.currentTheme }, index.h("div", { key: 'fce1176ff0ef2ea5c3f1b282ab9a52554491f9bf', class: "formatted-text" }, this.segments.map((segment, index) => this.renderSegment(segment, index)))));
1766
+ return (index.h(index.Host, { key: '3b477ff5db918a1b3b6872f48d330305d320ae3b', "data-theme": this.currentTheme }, index.h("div", { key: 'efe7fc93f9f1c2b38271a30e4a8fdf7306793d6e', class: "formatted-text" }, this.segments.map((segment, index) => this.renderSegment(segment, index)))));
1751
1767
  }
1752
1768
  static get watchers() { return {
1753
1769
  "text": ["textChanged"],