@wix/himalaya-cli 0.1642.0 → 0.1644.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.
Files changed (118) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +6 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +3 -1
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +3 -1
  5. package/dist/browser-plane/assets.json +5 -5
  6. package/dist/browser-plane/preview-deferred/{3361f61ce6b490c8b7b252658ea67f733d88c6e9f95906d0e31eea4827141df3.bin → 155f61519885c85d61a39fa595197071a3ca07680da56055ccb1dcff2e709cd1.bin} +1 -1
  7. package/dist/browser-plane/sw.js +6 -6
  8. package/dist/cli.mjs +358 -144
  9. package/dist/preview-assets.generated.bin +0 -0
  10. package/guides/component-reference.json +1 -1
  11. package/guides/component-reference.md +6 -0
  12. package/guides/designing-himi-screens.md +18 -0
  13. package/guides/offline-reading.md +1 -1
  14. package/guides/recipe-four-state.md +17 -0
  15. package/guides/release-notes.md +21 -0
  16. package/guides/sdk-reference.json +1 -1
  17. package/package.json +2 -2
  18. package/template-icons/conference.png +0 -0
  19. package/templates/beauty-salon/tier5-src/_shared/iap-presentation.ts +5 -2
  20. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +6 -3
  21. package/templates/branded-lite/dev/index.ts +152 -88
  22. package/templates/branded-lite/l10n/en.json +1 -1
  23. package/templates/branded-lite/tier5-src/_shared/featured-event.ts +63 -0
  24. package/templates/branded-lite/tier5-src/_shared/iap-presentation.ts +5 -2
  25. package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +93 -11
  26. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +7 -3
  27. package/templates/community-club/dev/index.ts +152 -88
  28. package/templates/community-club/tier5-src/_shared/featured-event.ts +63 -0
  29. package/templates/community-club/tier5-src/_shared/iap-presentation.ts +5 -2
  30. package/templates/community-club/tier5-src/himi-events-detail/index.ts +93 -11
  31. package/templates/conference/README.md +53 -0
  32. package/templates/conference/config.ts +321 -0
  33. package/templates/conference/dev/index.ts +17252 -0
  34. package/templates/conference/himalaya.content.json +46 -0
  35. package/templates/conference/himalaya.template.json +15 -0
  36. package/templates/conference/icon.png +0 -0
  37. package/templates/conference/platforms.json +1 -0
  38. package/templates/conference/tier5-src/_shared/agenda-stars.ts +64 -0
  39. package/templates/conference/tier5-src/_shared/app-locale.ts +61 -0
  40. package/templates/conference/tier5-src/_shared/branded-lite-hosted.ts +279 -0
  41. package/templates/conference/tier5-src/_shared/branded-load-state.ts +109 -0
  42. package/templates/conference/tier5-src/_shared/business-chat-copy.ts +40 -0
  43. package/templates/conference/tier5-src/_shared/business-chat-history.ts +51 -0
  44. package/templates/conference/tier5-src/_shared/business-chat-message-model.ts +177 -0
  45. package/templates/conference/tier5-src/_shared/business-chat-model.ts +56 -0
  46. package/templates/conference/tier5-src/_shared/business-chat-presenter.ts +576 -0
  47. package/templates/conference/tier5-src/_shared/business-chat-transport.ts +148 -0
  48. package/templates/conference/tier5-src/_shared/collection-contract.ts +229 -0
  49. package/templates/conference/tier5-src/_shared/collection-query.ts +193 -0
  50. package/templates/conference/tier5-src/_shared/collection-service.ts +400 -0
  51. package/templates/conference/tier5-src/_shared/engine-intl.ts +508 -0
  52. package/templates/conference/tier5-src/_shared/event-agenda.ts +122 -0
  53. package/templates/conference/tier5-src/_shared/event-registration.ts +86 -0
  54. package/templates/conference/tier5-src/_shared/featured-event.ts +63 -0
  55. package/templates/conference/tier5-src/_shared/himi-account.ts +164 -0
  56. package/templates/conference/tier5-src/_shared/himi-copy.ts +89 -0
  57. package/templates/conference/tier5-src/_shared/himi-events.ts +65 -0
  58. package/templates/conference/tier5-src/_shared/himi-store.ts +7 -0
  59. package/templates/conference/tier5-src/_shared/hosted-checkout.ts +70 -0
  60. package/templates/conference/tier5-src/_shared/iap-attendance-form.ts +106 -0
  61. package/templates/conference/tier5-src/_shared/iap-attendance-purchase.ts +211 -0
  62. package/templates/conference/tier5-src/_shared/iap-attendance.ts +38 -0
  63. package/templates/conference/tier5-src/_shared/iap-worker.ts +125 -0
  64. package/templates/conference/tier5-src/_shared/inbox-rooms.ts +68 -0
  65. package/templates/conference/tier5-src/_shared/local-preferences.ts +38 -0
  66. package/templates/conference/tier5-src/_shared/member-access.ts +52 -0
  67. package/templates/conference/tier5-src/_shared/member-account-routes.ts +52 -0
  68. package/templates/conference/tier5-src/_shared/member-read.ts +52 -0
  69. package/templates/conference/tier5-src/_shared/member-screen.ts +99 -0
  70. package/templates/conference/tier5-src/_shared/offset-page.ts +10 -0
  71. package/templates/conference/tier5-src/_shared/online-actions.ts +76 -0
  72. package/templates/conference/tier5-src/_shared/owner-load-error.ts +348 -0
  73. package/templates/conference/tier5-src/_shared/payment-setup.ts +6 -0
  74. package/templates/conference/tier5-src/_shared/rich-body.ts +78 -0
  75. package/templates/conference/tier5-src/_shared/rich-content-link.ts +34 -0
  76. package/templates/conference/tier5-src/_shared/sign-in-sheet.ts +18 -0
  77. package/templates/conference/tier5-src/business-chat/index.ts +724 -0
  78. package/templates/conference/tier5-src/himi-conference-agenda/index.ts +183 -0
  79. package/templates/conference/tier5-src/himi-conference-home/index.ts +389 -0
  80. package/templates/conference/tier5-src/himi-events-account/index.ts +219 -0
  81. package/templates/conference/tier5-src/himi-events-detail/index.ts +1304 -0
  82. package/templates/conference/tier5-src/himi-events-list/index.ts +124 -0
  83. package/templates/conference/tier5-src/himi-events-my-events/index.ts +225 -0
  84. package/templates/conference/tier5-src/himi-events-rsvp/index.ts +230 -0
  85. package/templates/conference/tier5-src/himi-store-account/index.ts +998 -0
  86. package/templates/conference/tokens.json +365 -0
  87. package/templates/events-meetups/dev/index.ts +152 -88
  88. package/templates/events-meetups/tier5-src/_shared/featured-event.ts +63 -0
  89. package/templates/events-meetups/tier5-src/_shared/iap-presentation.ts +5 -2
  90. package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +93 -11
  91. package/templates/gym-fitness/dev/index.ts +152 -88
  92. package/templates/gym-fitness/tier5-src/_shared/featured-event.ts +63 -0
  93. package/templates/gym-fitness/tier5-src/_shared/iap-presentation.ts +5 -2
  94. package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +93 -11
  95. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +6 -3
  96. package/templates/nonprofit-cause/dev/index.ts +152 -88
  97. package/templates/nonprofit-cause/tier5-src/_shared/featured-event.ts +63 -0
  98. package/templates/nonprofit-cause/tier5-src/_shared/iap-presentation.ts +5 -2
  99. package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +93 -11
  100. package/templates/podcast-creator/dev/index.ts +152 -88
  101. package/templates/podcast-creator/tier5-src/_shared/featured-event.ts +63 -0
  102. package/templates/podcast-creator/tier5-src/_shared/iap-presentation.ts +5 -2
  103. package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +93 -11
  104. package/templates/portfolio-creative/dev/index.ts +152 -88
  105. package/templates/portfolio-creative/tier5-src/_shared/featured-event.ts +63 -0
  106. package/templates/portfolio-creative/tier5-src/_shared/iap-presentation.ts +5 -2
  107. package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +93 -11
  108. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +6 -3
  109. package/templates/restaurant/dev/index.ts +152 -88
  110. package/templates/restaurant/tier5-src/_shared/featured-event.ts +63 -0
  111. package/templates/restaurant/tier5-src/_shared/iap-presentation.ts +5 -2
  112. package/templates/restaurant/tier5-src/himi-events-detail/index.ts +93 -11
  113. package/templates/retail-store/tier5-src/_shared/iap-presentation.ts +5 -2
  114. package/templates/retail-store/tier5-src/himi-store-product/index.ts +7 -3
  115. package/templates/yoga-studio/dev/index.ts +152 -88
  116. package/templates/yoga-studio/tier5-src/_shared/featured-event.ts +63 -0
  117. package/templates/yoga-studio/tier5-src/_shared/iap-presentation.ts +5 -2
  118. package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +93 -11
@@ -16642,6 +16642,7 @@ const SCREENS = runtimeSetting({
16642
16642
  "type": "HStack",
16643
16643
  "props": {
16644
16644
  "spacing": 10,
16645
+ "alignment": "center",
16645
16646
  "children": [
16646
16647
  {
16647
16648
  "id": "",
@@ -16655,7 +16656,8 @@ const SCREENS = runtimeSetting({
16655
16656
  }
16656
16657
  },
16657
16658
  "modifiers": {
16658
- "accessibilityRole": "decorative"
16659
+ "accessibilityRole": "decorative",
16660
+ "hiddenPath": "$service:himiMyEvents.signInRequired"
16659
16661
  }
16660
16662
  },
16661
16663
  {
@@ -16667,6 +16669,39 @@ const SCREENS = runtimeSetting({
16667
16669
  "text": "Something did not load.",
16668
16670
  "style": "bodyEmphasis"
16669
16671
  }
16672
+ },
16673
+ "modifiers": {
16674
+ "hiddenPath": "$service:himiMyEvents.signInRequired"
16675
+ }
16676
+ },
16677
+ {
16678
+ "id": "",
16679
+ "body": {
16680
+ "package": "himalaya",
16681
+ "type": "Icon",
16682
+ "props": {
16683
+ "name": "person",
16684
+ "size": 18,
16685
+ "tint": "textSecondary"
16686
+ }
16687
+ },
16688
+ "modifiers": {
16689
+ "accessibilityRole": "decorative",
16690
+ "hiddenPath": "$service:himiMyEvents.noSignIn"
16691
+ }
16692
+ },
16693
+ {
16694
+ "id": "",
16695
+ "body": {
16696
+ "package": "himalaya",
16697
+ "type": "Text",
16698
+ "props": {
16699
+ "text": "Sign in to see your events.",
16700
+ "style": "bodyEmphasis"
16701
+ }
16702
+ },
16703
+ "modifiers": {
16704
+ "hiddenPath": "$service:himiMyEvents.noSignIn"
16670
16705
  }
16671
16706
  }
16672
16707
  ]
@@ -24461,12 +24496,19 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24461
24496
  }
24462
24497
  },
24463
24498
  {
24464
- "id": "",
24499
+ "id": "himi_event.full_schedule",
24465
24500
  "body": {
24466
24501
  "package": "himalaya",
24467
24502
  "type": "DisclosureGroup",
24468
24503
  "props": {
24469
24504
  "title": "See Full Schedule",
24505
+ "expandedPath": "$service:himiEventDetail.fullScheduleOpen",
24506
+ "onToggle": {
24507
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
24508
+ "params": {
24509
+ "id": "fullSchedule"
24510
+ }
24511
+ },
24470
24512
  "content": [
24471
24513
  {
24472
24514
  "id": "",
@@ -24652,12 +24694,19 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24652
24694
  }
24653
24695
  },
24654
24696
  {
24655
- "id": "",
24697
+ "id": "himi_event.all_dates",
24656
24698
  "body": {
24657
24699
  "package": "himalaya",
24658
24700
  "type": "DisclosureGroup",
24659
24701
  "props": {
24660
24702
  "title": "See All Dates",
24703
+ "expandedPath": "$service:himiEventDetail.allDatesOpen",
24704
+ "onToggle": {
24705
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
24706
+ "params": {
24707
+ "id": "allDates"
24708
+ }
24709
+ },
24661
24710
  "content": [
24662
24711
  {
24663
24712
  "id": "",
@@ -24753,6 +24802,13 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24753
24802
  "type": "DisclosureGroup",
24754
24803
  "props": {
24755
24804
  "title": "Policies",
24805
+ "expandedPath": "$service:himiEventDetail.policiesOpen",
24806
+ "onToggle": {
24807
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
24808
+ "params": {
24809
+ "id": "policies"
24810
+ }
24811
+ },
24756
24812
  "content": [
24757
24813
  {
24758
24814
  "id": "",
@@ -24901,8 +24957,7 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24901
24957
  "props": {
24902
24958
  "presentedPath": "$service:himiEventDetail.ticketSheetOpen",
24903
24959
  "detents": [
24904
- 0.48,
24905
- 0.9
24960
+ 0.62
24906
24961
  ],
24907
24962
  "showGrabber": true,
24908
24963
  "dismissible": true,
@@ -24972,6 +25027,89 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
24972
25027
  }
24973
25028
  }
24974
25029
  },
25030
+ {
25031
+ "id": "himi_event.ticket_summary",
25032
+ "body": {
25033
+ "package": "himalaya",
25034
+ "type": "VStack",
25035
+ "props": {
25036
+ "spacing": 8,
25037
+ "children": [
25038
+ {
25039
+ "id": "",
25040
+ "body": {
25041
+ "package": "himalaya",
25042
+ "type": "Text",
25043
+ "props": {
25044
+ "text": "$service:himiEventDetail.ticketCountLabel",
25045
+ "style": "caption",
25046
+ "color": "textSecondary"
25047
+ }
25048
+ }
25049
+ },
25050
+ {
25051
+ "id": "",
25052
+ "body": {
25053
+ "package": "himalaya",
25054
+ "type": "HStack",
25055
+ "props": {
25056
+ "spacing": 12,
25057
+ "alignment": "center",
25058
+ "children": [
25059
+ {
25060
+ "id": "",
25061
+ "body": {
25062
+ "package": "himalaya",
25063
+ "type": "Text",
25064
+ "props": {
25065
+ "text": "$service:himiEventDetail.ticketTotal",
25066
+ "style": "title3",
25067
+ "monospacedDigits": true
25068
+ }
25069
+ }
25070
+ },
25071
+ {
25072
+ "id": "",
25073
+ "body": {
25074
+ "package": "himalaya",
25075
+ "type": "Spacer",
25076
+ "props": {}
25077
+ }
25078
+ },
25079
+ {
25080
+ "id": "himi_event.checkout",
25081
+ "body": {
25082
+ "package": "himalaya",
25083
+ "type": "Button",
25084
+ "props": {
25085
+ "title": "Checkout",
25086
+ "style": "primary",
25087
+ "disabledPath": "$service:himiEventDetail.checkoutDisabled",
25088
+ "action": {
25089
+ "actionId": "tier5.himiEventDetail.checkout"
25090
+ }
25091
+ }
25092
+ }
25093
+ }
25094
+ ]
25095
+ }
25096
+ }
25097
+ },
25098
+ {
25099
+ "id": "",
25100
+ "body": {
25101
+ "package": "himalaya",
25102
+ "type": "Divider",
25103
+ "props": {}
25104
+ }
25105
+ }
25106
+ ]
25107
+ }
25108
+ },
25109
+ "modifiers": {
25110
+ "hiddenPath": "$service:himiEventDetail.regularTicketsHidden"
25111
+ }
25112
+ },
24975
25113
  {
24976
25114
  "id": "",
24977
25115
  "body": {
@@ -25071,12 +25209,20 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
25071
25209
  }
25072
25210
  },
25073
25211
  {
25074
- "id": "",
25212
+ "id": "himi_event.ticket_terms",
25075
25213
  "body": {
25076
25214
  "package": "himalaya",
25077
25215
  "type": "DisclosureGroup",
25078
25216
  "props": {
25079
25217
  "title": "Ticket terms",
25218
+ "expandedPath": "$item.termsOpen",
25219
+ "onToggle": {
25220
+ "actionId": "tier5.himiEventDetail.toggleDisclosure",
25221
+ "params": {
25222
+ "id": "terms",
25223
+ "tier": "$item.id"
25224
+ }
25225
+ },
25080
25226
  "content": [
25081
25227
  {
25082
25228
  "id": "",
@@ -25591,88 +25737,6 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
25591
25737
  "modifiers": {
25592
25738
  "hiddenPath": "$service:himiEventDetail.iapBuyHidden"
25593
25739
  }
25594
- },
25595
- {
25596
- "id": "",
25597
- "body": {
25598
- "package": "himalaya",
25599
- "type": "VStack",
25600
- "props": {
25601
- "spacing": 8,
25602
- "children": [
25603
- {
25604
- "id": "",
25605
- "body": {
25606
- "package": "himalaya",
25607
- "type": "Divider",
25608
- "props": {}
25609
- }
25610
- },
25611
- {
25612
- "id": "",
25613
- "body": {
25614
- "package": "himalaya",
25615
- "type": "Text",
25616
- "props": {
25617
- "text": "$service:himiEventDetail.ticketCountLabel",
25618
- "style": "caption",
25619
- "color": "textSecondary"
25620
- }
25621
- }
25622
- },
25623
- {
25624
- "id": "",
25625
- "body": {
25626
- "package": "himalaya",
25627
- "type": "HStack",
25628
- "props": {
25629
- "spacing": 12,
25630
- "children": [
25631
- {
25632
- "id": "",
25633
- "body": {
25634
- "package": "himalaya",
25635
- "type": "Text",
25636
- "props": {
25637
- "text": "$service:himiEventDetail.ticketTotal",
25638
- "style": "title3",
25639
- "monospacedDigits": true
25640
- }
25641
- }
25642
- },
25643
- {
25644
- "id": "",
25645
- "body": {
25646
- "package": "himalaya",
25647
- "type": "Spacer",
25648
- "props": {}
25649
- }
25650
- },
25651
- {
25652
- "id": "btn_tier5_himieventdetail_checkout",
25653
- "body": {
25654
- "package": "himalaya",
25655
- "type": "Button",
25656
- "props": {
25657
- "title": "Checkout",
25658
- "style": "primary",
25659
- "disabledPath": "$service:himiEventDetail.checkoutDisabled",
25660
- "action": {
25661
- "actionId": "tier5.himiEventDetail.checkout"
25662
- }
25663
- }
25664
- }
25665
- }
25666
- ]
25667
- }
25668
- }
25669
- }
25670
- ]
25671
- }
25672
- },
25673
- "modifiers": {
25674
- "hiddenPath": "$service:himiEventDetail.regularTicketsHidden"
25675
- }
25676
25740
  }
25677
25741
  ]
25678
25742
  }
@@ -0,0 +1,63 @@
1
+ // The site's featured event: the one on now, else the next one to start. A conference app is
2
+ // about one event at a time — its Home hero, its Tickets tab and its Agenda all show this one —
3
+ // and a site with several events reaches the rest from the events list.
4
+ //
5
+ // Read from the visitor-readable Events v3 query. "None" (no live or upcoming event) is a real
6
+ // answer, distinct from a failed read: the caller shows an empty state for the first and an
7
+ // error with Retry for the second, never a sample event.
8
+ import { queryEvents, startDateOf, endDateOf, type WixEvent, type WixEventFieldset } from "@himalaya/wix-events";
9
+
10
+ export type FeaturedEventRead = { ok: true; event: WixEvent | null } | { ok: false; event: null };
11
+
12
+ // Only live and upcoming events, earliest first, filtered and sorted by Wix (verified on a visitor
13
+ // token, 2026-11-10): the featured one is on the first page however many events the site has. The
14
+ // pick below still checks each row, and pages on (to Wix's own total) only while no page has
15
+ // produced an event to feature — never a fixed page cap that could miss one.
16
+ const FEATURED_QUERY = {
17
+ filter: { status: { $in: ["UPCOMING", "STARTED"] } },
18
+ sort: [{ fieldName: "dateAndTimeSettings.startDate", order: "ASC" }],
19
+ };
20
+ const PAGE = 50;
21
+
22
+ const millis = (iso: string | undefined): number => {
23
+ const ms = iso ? Date.parse(iso) : NaN;
24
+ return Number.isNaN(ms) ? NaN : ms;
25
+ };
26
+
27
+ /** The event to feature among `events` at `now`: a published event that has not ended — the one
28
+ * that started first when several run now, else the next to start. A draft, a canceled event
29
+ * and an ended one are never featured; an event with no date is featured only when no dated one
30
+ * qualifies (its date is "to be announced"). */
31
+ export function pickFeaturedEvent(events: WixEvent[], now: number): WixEvent | null {
32
+ const eligible = events.filter((e) => {
33
+ const status = String(e.eventStatus ?? (e as { status?: string }).status ?? "").toUpperCase();
34
+ if (status === "DRAFT" || status === "CANCELED" || status === "ENDED") return false;
35
+ const end = millis(endDateOf(e)), start = millis(startDateOf(e));
36
+ const last = Number.isNaN(end) ? start : end;
37
+ return Number.isNaN(last) || last >= now;
38
+ });
39
+ const dated = eligible.filter((e) => !Number.isNaN(millis(startDateOf(e))));
40
+ if (dated.length) return dated.slice().sort((a, b) => millis(startDateOf(a)) - millis(startDateOf(b)))[0];
41
+ return eligible[0] ?? null;
42
+ }
43
+
44
+ /** Read the site's live and upcoming events and pick the featured one. */
45
+ export async function readFeaturedEvent(fields: WixEventFieldset[] = ["DETAILS", "REGISTRATION"], now: number = Date.now()): Promise<FeaturedEventRead> {
46
+ const events: WixEvent[] = [];
47
+ try {
48
+ for (let offset = 0; ; offset += PAGE) {
49
+ const res = await queryEvents({ limit: PAGE, offset, fields, query: FEATURED_QUERY as never });
50
+ const page = (res.events ?? []).filter((e) => !!e.id);
51
+ events.push(...page);
52
+ const total = Number((res as { pagingMetadata?: { total?: unknown } }).pagingMetadata?.total);
53
+ const done = page.length < PAGE || (Number.isFinite(total) && offset + PAGE >= total);
54
+ // A dated pick is final (a later page starts later); an undated one is not — a dated event
55
+ // may still follow, and a dated event is always featured before a "to be announced" one.
56
+ const pick = pickFeaturedEvent(events, now);
57
+ if (done || (pick && !Number.isNaN(millis(startDateOf(pick))))) break;
58
+ }
59
+ } catch {
60
+ return { ok: false, event: null };
61
+ }
62
+ return { ok: true, event: pickFeaturedEvent(events, now) };
63
+ }
@@ -11,7 +11,9 @@ export function withIapPresentation<S extends object>(options: {
11
11
  onCreate?(commerce: IapCommerce): void;
12
12
  onContent?(state: S): void;
13
13
  items(state: S): IapCatalogItem[];
14
- present(state: S, price: (id: string, commercePrice?: string) => string, allowed: (id: string) => boolean, appleIapOrResolving: (id: string) => boolean): S;
14
+ /** `resolving` is true while the checkout guard has no answer yet (a cold boot, a refresh): a
15
+ * screen reads it as loading, never as "not allowed". */
16
+ present(state: S, price: (id: string, commercePrice?: string) => string, allowed: (id: string) => boolean, appleIapOrResolving: (id: string) => boolean, resolving: (id: string) => boolean): S;
15
17
  contentActions: string[];
16
18
  /** Defaults to load/refresh/retry; mutations can explicitly request fresh mapping. */
17
19
  forcePriceRefreshActions?: string[];
@@ -74,11 +76,12 @@ export function withIapPresentation<S extends object>(options: {
74
76
  return view.route === "disabled" || view.route === "regular" ? commercePrice ?? item.commerceDisplayPrice ?? "" : iapPriceFields(view, iapPriceCopy(options.prefix)).priceText;
75
77
  };
76
78
  const allowed = (id: string) => commerce.pricing.checkoutGuard({ kind: "storesProduct", id }).allowed;
79
+ const resolving = (id: string) => commerce.pricing.checkoutGuard({ kind: "storesProduct", id }).route === "resolving";
77
80
  const appleIapOrResolving = (id: string) => ["appleIap", "resolving", "unavailable"].includes(presentationView(id).route);
78
81
  // Re-evaluate the cadence first. A checkout can enter/leave due work while a prior
79
82
  // projection is waiting to retry; a fresh directive supersedes the retained one.
80
83
  const poll = commerce.pollDirective(`${name}.iapPoll`) ?? retainedPoll;
81
- return { ...options.present(state, price, allowed, appleIapOrResolving), ...(poll ? { _poll: poll } : {}) };
84
+ return { ...options.present(state, price, allowed, appleIapOrResolving, resolving), ...(poll ? { _poll: poll } : {}) };
82
85
  };
83
86
  const mergeConcurrent = (before: S, next: S, current: S): S => {
84
87
  if (current === before) return next;
@@ -35,6 +35,7 @@ import {
35
35
  type EventRow,
36
36
  } from "../_shared/himi-events";
37
37
  import { stashCopy, copyParam } from "../_shared/himi-copy.js";
38
+ import { readFeaturedEvent } from "../_shared/featured-event.js";
38
39
  import { eventPageUrlOf, eventStatus, registrationKindOf, registrationUi, registrationUrlOf, type RegistrationKind } from "../_shared/event-registration.js";
39
40
  export { eventPageUrlOf, registrationKindOf, registrationUrlOf, type RegistrationKind };
40
41
  import { openRichLink } from "../_shared/rich-content-link.js";
@@ -88,6 +89,8 @@ interface TicketTierRow {
88
89
  rowLimit?: number;
89
90
  noPolicy?: boolean;
90
91
  notAvailable?: boolean;
92
+ /** Its "Ticket terms" disclosure is open (`toggleDisclosure` with `terms:<id>`). */
93
+ termsOpen?: boolean;
91
94
  }
92
95
 
93
96
  // Offline-first (data-offline): the event detail is a read-through single-item read —
@@ -194,6 +197,13 @@ interface S extends AttendancePurchaseFields {
194
197
  /** Buyer-visible ticket tiers for a ticketed event (empty otherwise). Loaded
195
198
  * alongside the event so the price is on screen BEFORE the CTA is tapped. */
196
199
  ticketTiers: TicketTierRow[];
200
+ /** The ids of the open disclosures: "fullSchedule", "allDates", "policies", `terms:<tier id>`.
201
+ * A DisclosureGroup is worker-controlled on every renderer (`expandedPath` + `onToggle`):
202
+ * one with neither never opens. */
203
+ openDisclosures: string[];
204
+ fullScheduleOpen: boolean;
205
+ allDatesOpen: boolean;
206
+ policiesOpen: boolean;
197
207
  ticketCurrency: string;
198
208
  ticketLimitPerOrder: number;
199
209
  ticketPurchaseBlocked: boolean;
@@ -232,6 +242,15 @@ function inputId(): string {
232
242
  return currentInputId(["himi_event_"]);
233
243
  }
234
244
 
245
+ /** `featured: "1"` (an onAppear param): a screen with no event id — a conference app's Tickets
246
+ * tab — shows the site's featured event (the one on now, else the next to start). */
247
+ const featuredRequested = (arg: unknown): boolean => (arg as { featured?: unknown } | undefined)?.featured === "1";
248
+ // The last featured open found no live or upcoming event: the empty state says so, not "not found".
249
+ let noFeaturedEvent = false;
250
+ // This worker serves a featured screen: set by the first `featured` onAppear, kept for its Retry
251
+ // (the retry block's load carries no params, and must read the featured event again).
252
+ let featuredMode = false;
253
+
235
254
  /** Money for a tier, or the free label. */
236
255
  function tierPrice(t: WixAvailableTicket): string {
237
256
  const raw = t.price?.amount;
@@ -333,11 +352,12 @@ function derive(s: S): S {
333
352
  const hasContent = !!s.title;
334
353
  const count = s.ticketTiers.reduce((n, row) => n + (row.quantity ?? 0), 0);
335
354
  const total = s.ticketTiers.reduce((n, row) => n + (row.isGuestPrice ? Number(row.guestPrice || row.minPrice || 0) : row.priceAmount ?? 0) * (row.quantity ?? 0), 0);
355
+ const open = new Set(s.openDisclosures ?? []);
336
356
  const ticketTiers = s.ticketTiers.map((row) => {
337
357
  const definitionId = row.ticketDefinitionId ?? row.id;
338
358
  const sameDefinitionElsewhere = s.ticketTiers.reduce((n, other) => n + ((other.ticketDefinitionId ?? other.id) === definitionId && other.id !== row.id ? other.quantity ?? 0 : 0), 0);
339
359
  const selectedElsewhere = s.ticketTiers.reduce((n, other) => n + (other.id === row.id ? 0 : other.quantity ?? 0), 0);
340
- return { ...row, maxQuantity: Math.max(0, Math.min((row.rowLimit ?? 99) - sameDefinitionElsewhere, s.ticketLimitPerOrder - selectedElsewhere)) };
360
+ return { ...row, termsOpen: open.has(`terms:${row.id}`), maxQuantity: Math.max(0, Math.min((row.rowLimit ?? 99) - sameDefinitionElsewhere, s.ticketLimitPerOrder - selectedElsewhere)) };
341
361
  });
342
362
  const chosenRows = s.ticketTiers.filter((row) => (row.quantity ?? 0) > 0);
343
363
  const singleTicketSelected = chosenRows.length === 1 && chosenRows[0]!.quantity === 1;
@@ -405,6 +425,10 @@ function derive(s: S): S {
405
425
  noFullSchedule: s.fullSchedule.length === 0,
406
426
  noMoreDates: s.moreDates.length === 0,
407
427
  noAllDates: s.allDates.length === 0,
428
+ openDisclosures: [...open],
429
+ fullScheduleOpen: open.has("fullSchedule"),
430
+ allDatesOpen: open.has("allDates"),
431
+ policiesOpen: open.has("policies"),
408
432
  isLoading: s.status === "loading",
409
433
  notLoading: s.status !== "loading",
410
434
  notErrored: !s.errored,
@@ -413,7 +437,9 @@ function derive(s: S): S {
413
437
  ? ""
414
438
  : (s.errored
415
439
  ? copyParam("event.errorText", "Event could not be loaded.")
416
- : copyParam("event.notFoundText", "Event not found.")),
440
+ : noFeaturedEvent
441
+ ? copyParam("event.noUpcomingText", "No upcoming event.")
442
+ : copyParam("event.notFoundText", "Event not found.")),
417
443
  };
418
444
  return next;
419
445
  }
@@ -552,6 +578,7 @@ type DetailActions = {
552
578
  openMap: (s: S) => Promise<S>;
553
579
  openTickets: (s: S) => Promise<S | undefined>;
554
580
  closeTickets: (s: S) => S;
581
+ toggleDisclosure: (s: S, arg?: unknown) => S;
555
582
  setQuantity: (s: S, arg?: unknown) => Promise<S | undefined>;
556
583
  setGuestPrice: (s: S, arg?: unknown) => S;
557
584
  checkout: (s: S) => Promise<S | undefined>;
@@ -572,9 +599,10 @@ type DetailActions = {
572
599
  iapRefresh: (s: S) => Promise<S>;
573
600
  iapPoll: (s: S) => Promise<S>;
574
601
  };
575
- const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S, DetailActions>("himiEventDetail", {
576
- notHydrated: [...ATTENDANCE_NOT_HYDRATED, "ticketPurchaseBlocked", "ticketSheetOpen", "rsvpActionsOpen", "cancelConfirmOpen", "rsvpId", "rsvpState", "rsvpLabel"],
577
- state: derive({
602
+ /** The state before any event is read — also where a featured open starts when it finds no event,
603
+ * or a different one, so nothing of the previous event (its footer, tiers, About) carries over. */
604
+ function bootState(): S {
605
+ return derive({
578
606
  ...ATTENDANCE_INITIAL,
579
607
  status: "loading",
580
608
  id: inputId(),
@@ -630,6 +658,10 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
630
658
  noAllDates: true,
631
659
  policies: [],
632
660
  noPolicies: true,
661
+ openDisclosures: [],
662
+ fullScheduleOpen: false,
663
+ allDatesOpen: false,
664
+ policiesOpen: false,
633
665
  description: "",
634
666
  descriptionJson: "",
635
667
  hasDescriptionJson: false,
@@ -676,7 +708,12 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
676
708
  isLoading: true,
677
709
  notLoading: false,
678
710
  noEmpty: true,
679
- }),
711
+ });
712
+ }
713
+
714
+ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S, DetailActions>("himiEventDetail", {
715
+ notHydrated: [...ATTENDANCE_NOT_HYDRATED, "ticketPurchaseBlocked", "ticketSheetOpen", "rsvpActionsOpen", "cancelConfirmOpen", "rsvpId", "rsvpState", "rsvpLabel"],
716
+ state: bootState(),
680
717
  actions: {
681
718
  openTickets: async (s) => {
682
719
  if (s.ticketTiers.length) return derive({ ...s, ticketSheetOpen: true });
@@ -691,6 +728,18 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
691
728
  return ticketSelectionState;
692
729
  },
693
730
  closeTickets: (s) => derive({ ...s, ticketSheetOpen: false }),
731
+ // Open or close one disclosure by its id (see `openDisclosures`).
732
+ toggleDisclosure: (s, arg) => {
733
+ const base = String((arg as { id?: unknown } | undefined)?.id ?? "");
734
+ // A row's disclosure names its row in its own param: the web renderer substitutes a whole
735
+ // `$item.` value only, never one inside a longer string ("terms:$item.id").
736
+ const row = String((arg as { tier?: unknown } | undefined)?.tier ?? "");
737
+ const id = base && row ? `${base}:${row}` : base;
738
+ if (!id) return s;
739
+ const open = new Set(s.openDisclosures ?? []);
740
+ if (open.has(id)) open.delete(id); else open.add(id);
741
+ return derive({ ...s, openDisclosures: [...open] });
742
+ },
694
743
  openRsvpActions: (s) => derive({ ...s, rsvpActionsOpen: true, cancelConfirmOpen: false, snackbarMessage: "" }),
695
744
  closeRsvpActions: (s) => derive({ ...s, rsvpActionsOpen: false, cancelConfirmOpen: false }),
696
745
  beginCancelRsvp: (s) => derive({ ...s, cancelConfirmOpen: !!s.rsvpId, snackbarMessage: "" }),
@@ -960,10 +1009,29 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
960
1009
  ticketCheckoutDenied = false;
961
1010
  ticketSelectionState = undefined;
962
1011
  lastReady = undefined;
963
- s = { ...s, ticketSheetOpen: false, rsvpActionsOpen: false, cancelConfirmOpen: false, rsvpId: "", rsvpState: "none", rsvpLabel: "" };
1012
+ s = { ...s, ticketSheetOpen: false, rsvpActionsOpen: false, cancelConfirmOpen: false, rsvpId: "", rsvpState: "none", rsvpLabel: "", openDisclosures: [] };
964
1013
  applePurchase.invalidate();
965
1014
  stashCopy(arg);
966
- const id = s.id || inputId();
1015
+ let id = s.id || inputId();
1016
+ noFeaturedEvent = false;
1017
+ // A featured screen resolves its event on every load — each appear, and its Retry — since the
1018
+ // site's next event may have changed.
1019
+ if (featuredRequested(arg)) featuredMode = true;
1020
+ if (featuredMode && !inputId()) {
1021
+ const featured = await readFeaturedEvent(["DETAILS"]);
1022
+ if (selectionVersion !== ticketSelectionVersion) return undefined;
1023
+ // A failed read is a clean error: the last event's image, About, schedule and tiers must not
1024
+ // stay on screen under the Retry card (the loaded content hides only while loading).
1025
+ if (!featured.ok) return derive({ ...bootState(), id: "", status: "ready", errored: true, title: "" });
1026
+ if (!featured.event?.id) {
1027
+ noFeaturedEvent = true;
1028
+ return derive({ ...bootState(), id: "", status: "ready", errored: false, title: "" });
1029
+ }
1030
+ id = featured.event.id;
1031
+ // Another event than the one on screen starts clean: its offline fallback must not keep the
1032
+ // previous event's About, schedule or policies.
1033
+ s = s.id === id ? s : { ...bootState(), id };
1034
+ }
967
1035
  if (!id) return derive({ ...s, status: "ready", errored: true });
968
1036
  try {
969
1037
  // TEXTS adds the Ricos `description` to the base fieldset (a bare read returns none);
@@ -1002,13 +1070,23 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
1002
1070
  const memberProbeNeeded = kind === "rsvp" || rawEvent.registration?.allowedGuestTypes === "MEMBER";
1003
1071
  const isMember = memberProbeNeeded ? await signedInMember() : false;
1004
1072
  const [scheduleResponse, policyResponse, rsvpResponse] = await Promise.all([
1005
- rawEvent.agendaSettings?.enabled ? bestEffort("GET", `/events/v1/schedule?eventId=${encodeURIComponent(id)}`) : undefined,
1073
+ // `limit` is required: without it Wix answers the agenda's `total` with an EMPTY `items`.
1074
+ rawEvent.agendaSettings?.enabled ? bestEffort("GET", `/events/v1/schedule?eventId=${encodeURIComponent(id)}&limit=100`) : undefined,
1006
1075
  bestEffort("POST", "/events-policies/v2/policies/query", { query: { filter: { eventId: { $eq: id } }, paging: { limit: 100 } } }),
1007
1076
  kind === "rsvp" && isMember ? bestEffort("GET", `/events/v2/rsvps/current?eventId=${encodeURIComponent(id)}`) : undefined,
1008
1077
  ]);
1009
1078
  let optionalReadFailed = [scheduleResponse, policyResponse, rsvpResponse].some((response) => response?.ok === false);
1010
1079
  const scheduleRaw = (scheduleResponse?.ok ? scheduleResponse.value : undefined) as { agenda?: Array<Record<string, unknown>>; schedule?: Array<Record<string, unknown>>; items?: Array<Record<string, unknown>>; agendaItems?: Array<Record<string, unknown>> } | undefined;
1011
- const fullSchedule = (scheduleRaw?.agenda ?? scheduleRaw?.agendaItems ?? scheduleRaw?.schedule ?? scheduleRaw?.items ?? []).map((item) => {
1080
+ // A hidden or canceled session is not on the agenda, and an item id is listed once (an owner's
1081
+ // read carries a draft and its published copy); sessions in start order.
1082
+ const seenItems = new Set<string>();
1083
+ const scheduleSource = (scheduleRaw?.agenda ?? scheduleRaw?.agendaItems ?? scheduleRaw?.schedule ?? scheduleRaw?.items ?? [])
1084
+ .filter((item) => item.hidden !== true && String(item.status ?? "").toUpperCase() !== "CANCELED")
1085
+ .filter((item) => { const key = String(item.id ?? ""); if (!key) return true; if (seenItems.has(key)) return false; seenItems.add(key); return true; })
1086
+ .map((item) => ({ item, at: Date.parse(String((item.timeSlot as { start?: string } | undefined)?.start ?? item.startTime ?? item.startDate ?? "")) }))
1087
+ .sort((a, b) => (Number.isNaN(a.at) ? Infinity : a.at) - (Number.isNaN(b.at) ? Infinity : b.at))
1088
+ .map(({ item }) => item);
1089
+ const fullSchedule = scheduleSource.map((item) => {
1012
1090
  const slot = item.timeSlot as { start?: string; end?: string; timeZoneId?: string } | undefined;
1013
1091
  const start = String(slot?.start ?? item.startTime ?? item.startDate ?? item.time ?? "");
1014
1092
  const date = start ? new Date(start) : undefined;
@@ -1218,5 +1296,9 @@ const svc: ReturnType<typeof defineService<S, DetailActions>> = defineService<S,
1218
1296
  },
1219
1297
  });
1220
1298
  resetUnhydratedKeysOnOlderRuntime(svc, { ...svc.getState(), ...ATTENDANCE_INITIAL, ticketPurchaseBlocked: true, ticketSheetOpen: false, rsvpActionsOpen: false, cancelConfirmOpen: false, rsvpId: "", rsvpState: "none", rsvpLabel: "" }, [...ATTENDANCE_NOT_HYDRATED, "ticketPurchaseBlocked", "ticketSheetOpen", "rsvpActionsOpen", "cancelConfirmOpen", "rsvpId", "rsvpState", "rsvpLabel"]);
1221
- svc.load();
1299
+ // The boot load needs an event id. Without one it could only answer "not found" — and on a
1300
+ // screen that finds its event itself (`featured`, a conference app's Tickets tab) that error
1301
+ // showed for the whole featured read, seconds on web, instead of the skeleton. The screen's
1302
+ // onAppear load decides an id-less open: the featured event, or the error.
1303
+ if (inputId()) svc.load();
1222
1304
  export { svc };