@wix/himalaya-cli 0.1750.0 → 0.1752.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 (185) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-config.d.ts +1 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +16 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/himi-package.d.ts +478 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/host-compatibility.d.ts +56 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/icon-catalog.generated.d.ts +1 -1
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +154 -7
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/auth-providers/wix/src/index.d.ts +1 -1
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/auth-providers/wix/src/native-engine.d.ts +49 -3
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/auth/src/copy.generated.d.ts +16 -1
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/auth/src/feedback.d.ts +1 -1
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +2 -0
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast-service.d.ts +105 -0
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast.d.ts +116 -0
  18. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/auth.mjs +27 -2
  19. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +326 -13
  20. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +757 -83
  21. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +156 -0
  22. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-auth/worker.mjs +133 -13
  23. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-auth.mjs +139 -13
  24. package/dist/browser-plane/assets.json +5 -5
  25. package/dist/browser-plane/preview-deferred/{b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin → 2671d1cadb15daa5e59440f4c924e30c221ab3d405e8a56a0ab1cdbe4764af3d.bin} +1 -1
  26. package/dist/browser-plane/sw.js +7 -7
  27. package/dist/cli.mjs +37219 -33014
  28. package/dist/preview-assets.generated.bin +0 -0
  29. package/guides/app-config.md +1 -1
  30. package/guides/component-reference.json +1 -1
  31. package/guides/component-reference.md +4 -0
  32. package/guides/designing-himi-screens.md +7 -0
  33. package/guides/getting-started.md +2 -0
  34. package/guides/headless-loop.md +1 -1
  35. package/guides/himi-json-output.md +25 -3
  36. package/guides/himi-skill.md +2 -0
  37. package/guides/index.json +6 -0
  38. package/guides/push-cli-onboarding.md +13 -0
  39. package/guides/qa-builds.md +15 -2
  40. package/guides/recipe-podcast.md +149 -0
  41. package/guides/releasing-with-himi-serve.md +51 -0
  42. package/guides/store-submission.md +46 -1
  43. package/guides/tier-5-add-a-screen.md +16 -2
  44. package/guides/wix-business-context.md +29 -0
  45. package/guides/wix-platform-usage.md +7 -2
  46. package/package.json +10 -10
  47. package/template-icons/fitness-gym.png +0 -0
  48. package/templates/beauty-salon/dev/index.ts +1 -1
  49. package/templates/beauty-salon/l10n/en.json +1 -1
  50. package/templates/beauty-salon/tier5-src/_shared/program-fields.ts +16 -0
  51. package/templates/beauty-salon/tier5-src/_shared/programs-section.ts +5 -8
  52. package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  53. package/templates/branded-lite/dev/index.ts +101 -1
  54. package/templates/branded-lite/l10n/en.json +22 -1
  55. package/templates/branded-lite/l10n/es.json +22 -0
  56. package/templates/branded-lite/l10n/fr.json +18 -0
  57. package/templates/branded-lite/l10n/he.json +15 -0
  58. package/templates/branded-lite/tier5-src/_shared/program-fields.ts +16 -0
  59. package/templates/branded-lite/tier5-src/_shared/programs-section.ts +5 -8
  60. package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  61. package/templates/branded-lite/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
  62. package/templates/brandy/README.md +33 -0
  63. package/templates/brandy/config.ts +51 -7
  64. package/templates/brandy/dev/index.ts +23 -9
  65. package/templates/community-club/l10n/en.json +1 -1
  66. package/templates/community-club/tier5-src/_shared/program-fields.ts +16 -0
  67. package/templates/community-club/tier5-src/_shared/programs-section.ts +5 -8
  68. package/templates/events-meetups/l10n/en.json +1 -1
  69. package/templates/events-meetups/tier5-src/_shared/program-fields.ts +16 -0
  70. package/templates/events-meetups/tier5-src/_shared/programs-section.ts +5 -8
  71. package/templates/fitness-gym/README.md +53 -0
  72. package/templates/fitness-gym/config.ts +560 -0
  73. package/templates/fitness-gym/dev/index.ts +25787 -0
  74. package/templates/fitness-gym/himalaya.content.json +64 -0
  75. package/templates/fitness-gym/himalaya.template.json +15 -0
  76. package/templates/fitness-gym/icon.png +0 -0
  77. package/templates/fitness-gym/platforms.json +1 -0
  78. package/templates/fitness-gym/tier5-src/_shared/app-locale.ts +61 -0
  79. package/templates/fitness-gym/tier5-src/_shared/booking-location.ts +147 -0
  80. package/templates/fitness-gym/tier5-src/_shared/booking-session.ts +224 -0
  81. package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  82. package/templates/fitness-gym/tier5-src/_shared/branded-load-state.ts +109 -0
  83. package/templates/fitness-gym/tier5-src/_shared/business-chat-copy.ts +40 -0
  84. package/templates/fitness-gym/tier5-src/_shared/business-chat-history.ts +51 -0
  85. package/templates/fitness-gym/tier5-src/_shared/business-chat-message-model.ts +177 -0
  86. package/templates/fitness-gym/tier5-src/_shared/business-chat-model.ts +56 -0
  87. package/templates/fitness-gym/tier5-src/_shared/business-chat-presenter.ts +576 -0
  88. package/templates/fitness-gym/tier5-src/_shared/business-chat-transport.ts +148 -0
  89. package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +228 -0
  90. package/templates/fitness-gym/tier5-src/_shared/collection-query.ts +193 -0
  91. package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +400 -0
  92. package/templates/fitness-gym/tier5-src/_shared/detail-presence.ts +51 -0
  93. package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +523 -0
  94. package/templates/fitness-gym/tier5-src/_shared/himi-account.ts +194 -0
  95. package/templates/fitness-gym/tier5-src/_shared/himi-booking-saved.ts +88 -0
  96. package/templates/fitness-gym/tier5-src/_shared/himi-bookings.ts +318 -0
  97. package/templates/fitness-gym/tier5-src/_shared/himi-copy.ts +116 -0
  98. package/templates/fitness-gym/tier5-src/_shared/himi-media.ts +29 -0
  99. package/templates/fitness-gym/tier5-src/_shared/himi-store.ts +7 -0
  100. package/templates/fitness-gym/tier5-src/_shared/himi-text.ts +24 -0
  101. package/templates/fitness-gym/tier5-src/_shared/host-events.ts +66 -0
  102. package/templates/fitness-gym/tier5-src/_shared/hosted-checkout.ts +70 -0
  103. package/templates/fitness-gym/tier5-src/_shared/iap-attendance-form.ts +106 -0
  104. package/templates/fitness-gym/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  105. package/templates/fitness-gym/tier5-src/_shared/iap-attendance.ts +38 -0
  106. package/templates/fitness-gym/tier5-src/_shared/iap-worker.ts +127 -0
  107. package/templates/fitness-gym/tier5-src/_shared/inbox-rooms.ts +68 -0
  108. package/templates/fitness-gym/tier5-src/_shared/local-preferences.ts +38 -0
  109. package/templates/fitness-gym/tier5-src/_shared/member-access.ts +63 -0
  110. package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +52 -0
  111. package/templates/fitness-gym/tier5-src/_shared/member-bookings.ts +107 -0
  112. package/templates/fitness-gym/tier5-src/_shared/member-screen.ts +99 -0
  113. package/templates/fitness-gym/tier5-src/_shared/notification-target.ts +141 -0
  114. package/templates/fitness-gym/tier5-src/_shared/offset-page.ts +10 -0
  115. package/templates/fitness-gym/tier5-src/_shared/online-actions.ts +76 -0
  116. package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +348 -0
  117. package/templates/fitness-gym/tier5-src/_shared/payment-setup.ts +6 -0
  118. package/templates/fitness-gym/tier5-src/_shared/pricing-plan-display.ts +64 -0
  119. package/templates/fitness-gym/tier5-src/_shared/program-description.ts +11 -0
  120. package/templates/fitness-gym/tier5-src/_shared/program-fields.ts +16 -0
  121. package/templates/fitness-gym/tier5-src/_shared/program-standing.ts +46 -0
  122. package/templates/fitness-gym/tier5-src/_shared/rich-body.ts +78 -0
  123. package/templates/fitness-gym/tier5-src/_shared/rich-content-link.ts +34 -0
  124. package/templates/fitness-gym/tier5-src/_shared/sign-in-sheet.ts +18 -0
  125. package/templates/fitness-gym/tier5-src/_shared/staff-name.ts +18 -0
  126. package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +107 -0
  127. package/templates/fitness-gym/tier5-src/_shared/wix-bi.ts +85 -0
  128. package/templates/fitness-gym/tier5-src/_shared/wix-member-links.ts +114 -0
  129. package/templates/fitness-gym/tier5-src/_shared/wix-service-price.ts +146 -0
  130. package/templates/fitness-gym/tier5-src/business-chat/index.ts +732 -0
  131. package/templates/fitness-gym/tier5-src/business-contact/index.ts +6 -0
  132. package/templates/fitness-gym/tier5-src/himi-booking-account/index.ts +267 -0
  133. package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +468 -0
  134. package/templates/fitness-gym/tier5-src/himi-booking-service/index.ts +1190 -0
  135. package/templates/fitness-gym/tier5-src/himi-booking-services/index.ts +791 -0
  136. package/templates/fitness-gym/tier5-src/himi-booking-time/index.ts +1729 -0
  137. package/templates/fitness-gym/tier5-src/himi-branded-lite-agenda/index.ts +988 -0
  138. package/templates/fitness-gym/tier5-src/himi-branded-lite-member-programs/index.ts +656 -0
  139. package/templates/fitness-gym/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
  140. package/templates/fitness-gym/tier5-src/himi-branded-lite-plans/index.ts +495 -0
  141. package/templates/fitness-gym/tier5-src/himi-branded-lite-program/facts.ts +52 -0
  142. package/templates/fitness-gym/tier5-src/himi-branded-lite-program/index.ts +845 -0
  143. package/templates/fitness-gym/tier5-src/himi-fitcoach-goal/index.ts +190 -0
  144. package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +619 -0
  145. package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +1007 -0
  146. package/templates/fitness-gym/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
  147. package/templates/fitness-gym/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  148. package/templates/fitness-gym/tokens.json +414 -0
  149. package/templates/gym-fitness/dev/index.ts +1 -1
  150. package/templates/gym-fitness/l10n/en.json +1 -1
  151. package/templates/gym-fitness/tier5-src/_shared/program-fields.ts +16 -0
  152. package/templates/gym-fitness/tier5-src/_shared/programs-section.ts +5 -8
  153. package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  154. package/templates/medical-services/dev/index.ts +2 -1
  155. package/templates/medical-services/tier5-src/himi-booking-account/index.ts +16 -1
  156. package/templates/nonprofit-cause/l10n/en.json +1 -1
  157. package/templates/nonprofit-cause/tier5-src/_shared/program-fields.ts +16 -0
  158. package/templates/nonprofit-cause/tier5-src/_shared/programs-section.ts +5 -8
  159. package/templates/personal-fitness-trainer/dev/index.ts +2 -2
  160. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  161. package/templates/podcast-creator/dev/index.ts +100 -0
  162. package/templates/podcast-creator/l10n/en.json +22 -1
  163. package/templates/podcast-creator/l10n/es.json +22 -0
  164. package/templates/podcast-creator/l10n/fr.json +18 -0
  165. package/templates/podcast-creator/l10n/he.json +15 -0
  166. package/templates/podcast-creator/tier5-src/_shared/program-fields.ts +16 -0
  167. package/templates/podcast-creator/tier5-src/_shared/programs-section.ts +5 -8
  168. package/templates/podcast-creator/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
  169. package/templates/portfolio-creative/l10n/en.json +1 -1
  170. package/templates/portfolio-creative/tier5-src/_shared/program-fields.ts +16 -0
  171. package/templates/portfolio-creative/tier5-src/_shared/programs-section.ts +5 -8
  172. package/templates/restaurant/l10n/en.json +1 -1
  173. package/templates/restaurant/tier5-src/_shared/program-fields.ts +16 -0
  174. package/templates/restaurant/tier5-src/_shared/programs-section.ts +5 -8
  175. package/templates/retail-store/l10n/en.json +1 -1
  176. package/templates/retail-store/tier5-src/_shared/program-fields.ts +16 -0
  177. package/templates/retail-store/tier5-src/_shared/programs-section.ts +5 -8
  178. package/templates/salon-spa/dev/index.ts +1 -1
  179. package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +16 -1
  180. package/templates/salon-spa/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  181. package/templates/yoga-studio/dev/index.ts +1 -1
  182. package/templates/yoga-studio/l10n/en.json +1 -1
  183. package/templates/yoga-studio/tier5-src/_shared/program-fields.ts +16 -0
  184. package/templates/yoga-studio/tier5-src/_shared/programs-section.ts +5 -8
  185. package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
@@ -0,0 +1,523 @@
1
+ // ECMA-402 is NOT part of the Tier-5 floor. Measured across the engines we actually ship
2
+ // (engine-parity runners, #1367):
3
+ //
4
+ // engine typeof Intl
5
+ // V8 (web, Android WebView) object
6
+ // JSC (iOS, macOS) object
7
+ // QuickJS-ng (watchOS, Wear OS) **undefined**
8
+ //
9
+ // The wrist engine has no ECMA-402 at all — `grep -c Intl quickjs.c` → 0, and its maintainer
10
+ // ruled ICU out as too large (quickjs-ng#467). RFC 0051's per-surface projection does NOT subset
11
+ // destinations: a watch keeps every screen the phone has and only REMAPS which one an entry
12
+ // opens. So any screen in a watch/Wear-enabled app can execute on QuickJS, and a bare `Intl.*`
13
+ // there is a `ReferenceError`.
14
+ //
15
+ // That is not hypothetical. `himi-branded-lite-order.formatDate` called `new Intl.DateTimeFormat`
16
+ // unguarded and with no try/catch, which KILLS the screen on the wrist rather than degrading it.
17
+ // `himi-events-detail` had the softer version — a guarded `Intl.NumberFormat` whose catch left a
18
+ // ticket price rendering "25" where the phone shows "$25", i.e. a price that reads as a quantity.
19
+ //
20
+ // These helpers are the sanctioned way to format across the whole fleet: real ECMA-402 where it
21
+ // exists, a deterministic en-US-shaped fallback where it does not, and never a throw.
22
+
23
+ import { appLocale } from "./app-locale.js";
24
+
25
+ /** Is ECMA-402 actually present in THIS engine? Cheap, and safe in a realm without `Intl`. */
26
+ export function hasIntl(): boolean {
27
+ return typeof Intl !== "undefined";
28
+ }
29
+
30
+ const MONTHS_SHORT = [
31
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
32
+ ] as const;
33
+
34
+ function pad2(n: number): string {
35
+ return n < 10 ? `0${n}` : `${n}`;
36
+ }
37
+
38
+ /** `h:mm AM/PM`, matching what `timeStyle: "short"` renders for en-US. */
39
+ function clock12(d: Date): string {
40
+ const h = d.getHours();
41
+ const suffix = h < 12 ? "AM" : "PM";
42
+ const hour = h % 12 === 0 ? 12 : h % 12;
43
+ return `${hour}:${pad2(d.getMinutes())} ${suffix}`;
44
+ }
45
+
46
+ const WEEKDAYS_SHORT = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] as const;
47
+
48
+ const MONTHS_LONG = [
49
+ "January", "February", "March", "April", "May", "June",
50
+ "July", "August", "September", "October", "November", "December",
51
+ ] as const;
52
+
53
+ /**
54
+ * A DateTimeFormat for `timeZone` when one is given and this engine knows it. An unknown or
55
+ * malformed IANA id is a RangeError in ECMA-402; these helpers never throw, so it degrades to
56
+ * the device zone rather than killing the screen. Without Intl there is no zone database at all,
57
+ * and the fallbacks below render in the device zone for the same reason.
58
+ *
59
+ * Formatters are memoised per (locale, zone, options): a management page formats several dates
60
+ * per row, and building a DateTimeFormat (or throwing on a bad zone) each time is not free on
61
+ * JSC or QuickJS. Only call it where `hasIntl()` holds — every caller does.
62
+ */
63
+ const FORMATTERS = new Map<string, Intl.DateTimeFormat>();
64
+ function dateFormat(locale: string, options: Intl.DateTimeFormatOptions, timeZone?: string): Intl.DateTimeFormat {
65
+ const key = `${locale}|${timeZone ?? ""}|${JSON.stringify(options)}`;
66
+ let formatter = FORMATTERS.get(key);
67
+ if (!formatter) {
68
+ if (hasIntl()) {
69
+ if (timeZone) {
70
+ try {
71
+ formatter = new Intl.DateTimeFormat(locale, { ...options, timeZone });
72
+ } catch {
73
+ /* unknown zone: device zone below, remembered under this key */
74
+ }
75
+ }
76
+ formatter ??= new Intl.DateTimeFormat(locale, options);
77
+ FORMATTERS.set(key, formatter);
78
+ }
79
+ }
80
+ return formatter as Intl.DateTimeFormat;
81
+ }
82
+
83
+ // The four shapes below are not invented — they are the option bags this corpus actually uses,
84
+ // counted across every bundle: "Jan 5, 2026" (33 sites), "Jan 5" (11), "Mon, Jan 5, 3:07 PM" (8)
85
+ // and "Jan 5, 3:07 PM" (4). Naming them means a conversion is a one-line swap rather than a
86
+ // judgement call about which fallback is close enough, and every one is diffed against real
87
+ // ECMA-402 in engine-intl-fallback.test.ts.
88
+
89
+ /** `{ month: "short", day: "numeric", year: "numeric" }` — "Jan 5, 2026". */
90
+ export function formatDateMedium(date: Date, locale = appLocale(), timeZone?: string): string {
91
+ if (hasIntl()) {
92
+ return dateFormat(locale, { month: "short", day: "numeric", year: "numeric" }, timeZone).format(date);
93
+ }
94
+ return `${MONTHS_SHORT[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
95
+ }
96
+
97
+ /** `{ month: "short", year: "numeric" }` — "Jul 2026", without parsing a localized day.
98
+ * Like the other date helpers, an engine without Intl keeps the documented en-US fallback. */
99
+ export function formatMonthYear(date: Date, locale = "en-US", timeZone?: string): string {
100
+ if (hasIntl()) return dateFormat(locale, { month: "short", year: "numeric" }, timeZone).format(date);
101
+ return `${MONTHS_SHORT[date.getMonth()]} ${date.getFullYear()}`;
102
+ }
103
+
104
+ /** `{ month: "short", day: "numeric" }` — "Jan 5". */
105
+ export function formatMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
106
+ if (hasIntl()) {
107
+ return dateFormat(locale, { month: "short", day: "numeric" }, timeZone).format(date);
108
+ }
109
+ return `${MONTHS_SHORT[date.getMonth()]} ${date.getDate()}`;
110
+ }
111
+
112
+ /** `{ month: "long", day: "numeric" }` — "January 5". */
113
+ export function formatMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
114
+ if (hasIntl()) {
115
+ return dateFormat(locale, { month: "long", day: "numeric" }, timeZone).format(date);
116
+ }
117
+ return `${MONTHS_LONG[date.getMonth()]} ${date.getDate()}`;
118
+ }
119
+
120
+ const WEEKDAYS_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] as const;
121
+
122
+ /** `{ weekday: "short", month: "short", day: "numeric" }` — "Mon, Jan 5". */
123
+ export function formatWeekdayMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
124
+ if (hasIntl()) {
125
+ return dateFormat(locale, { weekday: "short", month: "short", day: "numeric" }, timeZone).format(date);
126
+ }
127
+ return `${WEEKDAYS_SHORT[date.getDay()]}, ${MONTHS_SHORT[date.getMonth()]} ${date.getDate()}`;
128
+ }
129
+
130
+ /** `{ weekday: "long", month: "long", day: "numeric" }` — "Monday, January 5". */
131
+ export function formatWeekdayMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
132
+ if (hasIntl()) {
133
+ return dateFormat(locale, { weekday: "long", month: "long", day: "numeric" }, timeZone).format(date);
134
+ }
135
+ return `${WEEKDAYS_LONG[date.getDay()]}, ${MONTHS_LONG[date.getMonth()]} ${date.getDate()}`;
136
+ }
137
+
138
+ /** `{ weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }`
139
+ * — "Mon, Jan 5, 3:07 PM". */
140
+ export function formatWeekdayDateTime(date: Date, locale = appLocale(), timeZone?: string): string {
141
+ if (hasIntl()) {
142
+ return dateFormat(locale, {
143
+ weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
144
+ }, timeZone).format(date);
145
+ }
146
+ return `${WEEKDAYS_SHORT[date.getDay()]}, ${MONTHS_SHORT[date.getMonth()]} ${date.getDate()}, ${clock12(date)}`;
147
+ }
148
+
149
+ /** `{ month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }` — "Jan 5, 3:07 PM". */
150
+ export function formatMonthDayTime(date: Date, locale = appLocale(), timeZone?: string): string {
151
+ if (hasIntl()) {
152
+ return dateFormat(locale, {
153
+ month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
154
+ }, timeZone).format(date);
155
+ }
156
+ return `${MONTHS_SHORT[date.getMonth()]} ${date.getDate()}, ${clock12(date)}`;
157
+ }
158
+
159
+ /**
160
+ * `dateStyle: "medium", timeStyle: "short"` — "Jan 5, 2026, 3:07 PM".
161
+ * Falls back to the same SHAPE (not a different one) so a screen does not visibly change
162
+ * character between a phone and a watch.
163
+ */
164
+ export function formatDateTimeMedium(date: Date, locale = appLocale()): string {
165
+ if (hasIntl()) {
166
+ return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(date);
167
+ }
168
+ return `${MONTHS_SHORT[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}, ${clock12(date)}`;
169
+ }
170
+
171
+ /**
172
+ * Currency, e.g. "$25.00". The fallback covers the symbol-prefix currencies these apps actually
173
+ * use and degrades to "CODE amount" for anything else — deliberately NOT a bare number, because
174
+ * that is the exact defect this exists to prevent (a price rendering as a quantity).
175
+ */
176
+ const CURRENCY_SYMBOL: Record<string, string> = {
177
+ USD: "$", EUR: "€", GBP: "£", ILS: "₪", JPY: "¥", CAD: "CA$", AUD: "A$",
178
+ };
179
+
180
+ /**
181
+ * ISO 4217 minor units, for the currencies that are NOT the default 2.
182
+ *
183
+ * Without this the fallback rendered every non-JPY currency with 2 decimals while Intl used the
184
+ * currency's natural precision — so a Bahraini price was "BHD 25.00" on the wrist and
185
+ * "BHD 25.000" on the phone. Formatting money differently per engine is the exact defect this
186
+ * helper exists to prevent, so the table is part of the contract, not a nicety.
187
+ */
188
+ const CURRENCY_DIGITS: Record<string, number> = {
189
+ // Zero-decimal
190
+ BIF: 0, CLP: 0, DJF: 0, GNF: 0, ISK: 0, JPY: 0, KMF: 0, KRW: 0, PYG: 0, RWF: 0,
191
+ UGX: 0, UYI: 0, VND: 0, VUV: 0, XAF: 0, XOF: 0, XPF: 0,
192
+ // Three-decimal
193
+ BHD: 3, IQD: 3, JOD: 3, KWD: 3, LYD: 3, OMR: 3, TND: 3,
194
+ // Four-decimal
195
+ CLF: 4, UYW: 4,
196
+ };
197
+
198
+ export function formatCurrency(
199
+ amount: number,
200
+ currency = "USD",
201
+ locale = appLocale(),
202
+ /** Omit for the currency's natural digits. Pass 0 to render a whole amount as "$25" rather
203
+ * than "$25.00" — Intl clamps the minimum down to match, so max<min does not throw here. */
204
+ maximumFractionDigits?: number,
205
+ ): string {
206
+ if (!Number.isFinite(amount)) return "";
207
+ if (hasIntl()) {
208
+ // The Intl branch CAN throw: `new Intl.NumberFormat(…, { currency })` raises a RangeError for
209
+ // any code that is not three letters ("US", "12", ""), and a currency arriving from payload
210
+ // data is exactly where that happens. This helper replaced call sites that had their own
211
+ // try/catch (himi-events-detail's tierPrice returned the raw amount), so without this the
212
+ // refactor would have REMOVED a safety net and turned a degraded price into a dead service on
213
+ // web, iOS and Android alike — worse than the wrist bug it was written to fix.
214
+ //
215
+ // Falling through to the fallback rather than rethrowing also degrades better than the code
216
+ // it replaced: that returned a bare number, this still carries the currency code.
217
+ try {
218
+ return new Intl.NumberFormat(locale, {
219
+ style: "currency",
220
+ currency,
221
+ ...(maximumFractionDigits != null ? { maximumFractionDigits } : {}),
222
+ }).format(amount);
223
+ } catch { /* malformed currency — use the engine-independent path below */ }
224
+ }
225
+ // A blank/whitespace currency would otherwise produce " 25.00" — a bare number, which is the
226
+ // very defect this helper exists to prevent. Fall back to the documented default rather than
227
+ // emitting an unlabelled amount. (Found by the "never a bare number" assertion, not by reading.)
228
+ const code = (currency || "").trim().toUpperCase() || "USD";
229
+ const symbol = CURRENCY_SYMBOL[code];
230
+ // The sign goes OUTSIDE the symbol: ECMA-402 renders -42.5 USD as "-$42.50", not "$-42.50".
231
+ // Caught by diffing this fallback against Intl rather than by reading it.
232
+ const sign = amount < 0 ? "-" : "";
233
+ const abs = Math.abs(amount);
234
+ const digits = maximumFractionDigits ?? CURRENCY_DIGITS[code] ?? 2;
235
+ const raw = abs.toFixed(digits);
236
+ // Same trap as formatNumber: `toFixed` goes EXPONENTIAL at >=1e21, and groupThousands would
237
+ // then comma up the exponent ("1e,+21"). No real price is that large, but emitting garbage is
238
+ // never the right answer to an unexpected input.
239
+ const fixed = raw.includes("e") || raw.includes("E") ? String(abs) : groupThousands(raw);
240
+ return symbol ? `${sign}${symbol}${fixed}` : `${sign}${code} ${fixed}`;
241
+ }
242
+
243
+ /** "1234567.89" → "1,234,567.89". `toLocaleString` cannot be used: on QuickJS it silently
244
+ * returns the UNGROUPED string rather than throwing, which is why the wrist showed "1234.5"
245
+ * where every other engine showed "1,234.5". */
246
+ function groupThousands(fixed: string): string {
247
+ const [whole, frac] = fixed.split(".");
248
+ const sign = whole.startsWith("-") ? "-" : "";
249
+ const digits = sign ? whole.slice(1) : whole;
250
+ let out = "";
251
+ for (let i = 0; i < digits.length; i++) {
252
+ if (i > 0 && (digits.length - i) % 3 === 0) out += ",";
253
+ out += digits[i];
254
+ }
255
+ return frac ? `${sign}${out}.${frac}` : `${sign}${out}`;
256
+ }
257
+
258
+ /**
259
+ * Plain grouped number, e.g. "1,234.5".
260
+ *
261
+ * Two things the first cut of this got wrong, both found by diffing against Intl over values
262
+ * chosen to be AWKWARD rather than tidy:
263
+ *
264
+ * • `Intl.NumberFormat` defaults to `maximumFractionDigits: 3`. Feeding it `2/3` gives
265
+ * "0.667"; a fallback built on `String(value)` gave "0.6666666666666666".
266
+ * • `String(value)` is EXPONENTIAL outside ~1e21 / 1e-7, and the grouping loop below happily
267
+ * inserted commas into the exponent — `1e21` came out as "1e,+21" and `1e-7` as "1,e-7".
268
+ * Garbage, and silently so, because nothing in the corpus's tidy test numbers reached it.
269
+ */
270
+ export function formatNumber(value: number, locale = appLocale()): string {
271
+ if (!Number.isFinite(value)) return "";
272
+ if (hasIntl()) return new Intl.NumberFormat(locale).format(value);
273
+ // `toFixed` itself returns exponential notation at >=1e21, so anything that big keeps the
274
+ // plain JS form rather than being mangled. Intl would expand it in full; a number that large
275
+ // is not a price or a count, and an honest "1e+21" beats a wrong "1e,+21".
276
+ const fixed = value.toFixed(3);
277
+ if (fixed.includes("e") || fixed.includes("E")) return String(value);
278
+ // Trailing zeros go, so an integer stays "1,000" instead of "1,000.000".
279
+ const trimmed = fixed.includes(".") ? fixed.replace(/0+$/, "").replace(/\.$/, "") : fixed;
280
+ return groupThousands(trimmed);
281
+ }
282
+
283
+ /** Strip combining marks so "Ändern" folds to "andern". `String.prototype.normalize` is
284
+ * ECMA-262, NOT ECMA-402 — which is exactly why it is usable here: it exists on the engine that
285
+ * has no `Intl`. The range is the Unicode combining-diacritical block, written as an explicit
286
+ * range rather than a `\p{M}` property escape so no engine needs RegExp property support. */
287
+ function foldDiacritics(s: string): string {
288
+ try {
289
+ return s.normalize("NFD").replace(/[̀-ͯ]/g, "");
290
+ } catch {
291
+ return s; // no normalize (should not happen) — degrade to the un-folded form
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Locale-aware string ordering for SORTS.
297
+ *
298
+ * `localeCompare` is the trap here, because it does not throw where ECMA-402 is missing — it
299
+ * silently falls back to codepoint order. Measured on the engines we ship, that is not a subtle
300
+ * difference: for a realistic product list the wrist produced
301
+ *
302
+ * Banana, Zoë, andern, apple, cherry, Ändern, Über, éclair ← raw codepoint (QuickJS-ng)
303
+ * andern, Ändern, apple, Banana, cherry, éclair, Über, Zoë ← ICU (V8/JSC)
304
+ *
305
+ * i.e. a list that looks shuffled rather than sorted, with no error anywhere to explain it.
306
+ *
307
+ * The phone path is UNCHANGED — it is still `Intl.Collator`, so nothing about existing ordering
308
+ * moves. Only the engine that lacked ECMA-402 changes, and it changes from codepoint order to a
309
+ * case-folded, diacritic-folded comparison that agreed with ICU on 576/576 pairs of the probe
310
+ * corpus (accents included). This is deliberately NOT "pick one algorithm for every engine":
311
+ * that framing would have traded a wrist bug for a phone regression, and it is unnecessary.
312
+ */
313
+ export function compareText(a: string, b: string, locale = "en"): number {
314
+ if (hasIntl()) return new Intl.Collator(locale).compare(a, b);
315
+ const fa = foldDiacritics(a.toLowerCase());
316
+ const fb = foldDiacritics(b.toLowerCase());
317
+ if (fa < fb) return -1;
318
+ if (fa > fb) return 1;
319
+ // Same letters ignoring case and accents — fall back through the finer distinctions so the
320
+ // order is TOTAL (a comparator that returns 0 for distinct strings makes a sort unstable).
321
+ const ca = a.toLowerCase(), cb = b.toLowerCase();
322
+ if (ca < cb) return -1;
323
+ if (ca > cb) return 1;
324
+ if (a === b) return 0;
325
+ // en-US collation puts lowercase before uppercase for the same letter, which is the OPPOSITE
326
+ // of codepoint order — hence the inversion rather than a plain comparison.
327
+ return a > b ? -1 : 1;
328
+ }
329
+
330
+ /**
331
+ * Ordering for machine timestamps (ISO-8601, RFC-3339) and other fixed-format ASCII keys.
332
+ *
333
+ * Exists to keep `localeCompare` away from them. Sorting `"2026-01-05T15:07:00Z"` through a
334
+ * COLLATOR is the wrong tool — collation carries locale rules a timestamp has no use for, and on
335
+ * an engine without ECMA-402 it silently becomes codepoint order anyway. Measured: for ISO
336
+ * strings, plain comparison and `localeCompare` agree on 36/36 pairs, so this is a no-op on
337
+ * every engine AND removes the engine-variance question entirely.
338
+ */
339
+ export function compareIso(a: string, b: string): number {
340
+ return a < b ? -1 : a > b ? 1 : 0;
341
+ }
342
+
343
+ const MONTH_INDEX: Record<string, number> = {
344
+ jan: 0, feb: 1, mar: 2, apr: 3, may: 4, jun: 5,
345
+ jul: 6, aug: 7, sep: 8, oct: 9, nov: 10, dec: 11,
346
+ };
347
+
348
+ /**
349
+ * Epoch-ms for a date string that may be ISO-8601 **or** RFC-822/2822 ("Sun, 02 Aug 2026"), the
350
+ * shape RSS feeds use. `NaN` when it is neither.
351
+ *
352
+ * Hand-parsed rather than handed to `Date.parse` because `Date.parse` is only SPECIFIED for the
353
+ * ISO format — everything else is implementation-defined, which is precisely the kind of
354
+ * per-engine variance this module exists to remove.
355
+ */
356
+ export function parseDateish(value: string): number {
357
+ if (!value) return NaN;
358
+ // ISO / RFC-3339 — `Date` parses this by spec on every engine.
359
+ if (/^\d{4}-\d{2}-\d{2}/.test(value)) return new Date(value).getTime();
360
+ // RFC-822/2822: "[Ddd, ]DD Mon YYYY[ HH:MM[:SS]]"
361
+ const m = value.match(/(\d{1,2})\s+([A-Za-z]{3})[a-z]*\s+(\d{4})(?:\s+(\d{2}):(\d{2})(?::(\d{2}))?)?/);
362
+ if (!m) return NaN;
363
+ const month = MONTH_INDEX[m[2].toLowerCase()];
364
+ if (month === undefined) return NaN;
365
+ return Date.UTC(Number(m[3]), month, Number(m[1]), Number(m[4] ?? 0), Number(m[5] ?? 0), Number(m[6] ?? 0));
366
+ }
367
+
368
+ /**
369
+ * Chronological ordering for date strings — ASCENDING (oldest first); negate for newest-first.
370
+ *
371
+ * This exists because comparing RFC-822 dates as STRINGS sorts by weekday name. Measured on the
372
+ * podcast corpus, a "latest episodes" list built that way rendered
373
+ *
374
+ * Wed, 01 Jan 2025 ← shown FIRST
375
+ * Tue, 21 Jul 2026
376
+ * …
377
+ * Fri, 15 Aug 2026 ← the newest episode, shown LAST
378
+ *
379
+ * and it was wrong on EVERY engine, not just the one missing ECMA-402 — a plain product bug that
380
+ * the engine work happened to surface. Unparseable values sort last rather than throwing, so one
381
+ * malformed feed entry cannot take the screen down.
382
+ */
383
+ export function compareDate(a: string, b: string): number {
384
+ const ta = parseDateish(a);
385
+ const tb = parseDateish(b);
386
+ const aBad = Number.isNaN(ta);
387
+ const bBad = Number.isNaN(tb);
388
+ if (aBad && bBad) return compareIso(a, b); // both unparseable — arbitrary but TOTAL
389
+ if (aBad) return 1;
390
+ if (bBad) return -1;
391
+ return ta - tb;
392
+ }
393
+
394
+ /**
395
+ * Newest-first, which is what every call site here actually wants.
396
+ *
397
+ * A separate function rather than asking callers to write `-compareDate(a, b)`, because negating
398
+ * also flips the unparseable-values-last rule to unparseable-values-FIRST — a malformed feed entry
399
+ * would head the "latest episodes" list. My own test caught that on the negation idiom, which is
400
+ * exactly the footgun worth deleting rather than documenting.
401
+ */
402
+ export function compareDateDesc(a: string, b: string): number {
403
+ const ta = parseDateish(a);
404
+ const tb = parseDateish(b);
405
+ const aBad = Number.isNaN(ta);
406
+ const bBad = Number.isNaN(tb);
407
+ if (aBad && bBad) return compareIso(a, b);
408
+ if (aBad) return 1; // unparseable stays LAST in this direction too
409
+ if (bBad) return -1;
410
+ return tb - ta;
411
+ }
412
+
413
+ // --- [branded-lite-qa] #3079: one pattern per fact ---------------------------------------
414
+ //
415
+ // Before these existed, four screens formatted the same money four ways — Shop "69.00 ₪" (Wix's
416
+ // pre-formatted string), Services "₪70" (0 decimals), Menu "₪32.00", Plans "$24" — and two
417
+ // screens formatted the same clock two ways (Events "9:00 PM-11:00 PM", Reserve "20:00").
418
+ // Customers read that as sloppiness, and a whole "₪70" beside "₪69.50" reads as a different
419
+ // kind of number. So: one money pattern, one clock, one range.
420
+
421
+ // Money uses `formatCurrency(amount, currency)` — English unless the app pins another language, see app-locale — the currency's NATURAL decimals
422
+ // ("₪70.00", "¥500") — for Shop, Menu and every other price. The one exception is a Bookings
423
+ // SERVICE price (`_shared/wix-service-price.ts`): it drops the cents of a whole amount ("₪70",
424
+ // "₪69.50"), the format the redesigned service screen and services list were approved with. It
425
+ // must read the same on every screen that shows a service (the list, the service screen, the
426
+ // time screen, Home, the agenda); do not put those back on natural decimals one screen at a time.
427
+
428
+ const KNOWN_SYMBOLS = new Set(Object.values(CURRENCY_SYMBOL));
429
+
430
+ /** Wix hands some prices over PRE-formatted in the site's regional style — "69.00 ₪" with the
431
+ * symbol trailing, often wrapped in bidi marks. Reorder those to the house pattern ("₪69.00") so
432
+ * they match every price we format ourselves. Only an en-shaped number ("69.00", "1,234.50") with
433
+ * a known trailing symbol is reordered: a comma-decimal or space-grouped string ("69,00 €",
434
+ * "1 234,56 €") is kept as Wix wrote it, because half-converting it would be worse. Anything else
435
+ * ("Market price") is returned trimmed. The store SDK's product price applies the same rule. */
436
+ export function normalizeFormattedPrice(formatted: string): string {
437
+ const raw = (formatted || "").replace(/[‎‏]/g, "").trim();
438
+ const m = /^(-?)(\d{1,3}(?:,\d{3})*(?:\.\d+)?|\d+(?:\.\d+)?)[\s  ]*(\S+)$/.exec(raw);
439
+ if (!m || !KNOWN_SYMBOLS.has(m[3])) return raw;
440
+ return `${m[1]}${m[3]}${m[2]}`;
441
+ }
442
+
443
+ function clockParts(d: Date, locale: string, timeZone?: string): { time: string; meridiem: string } {
444
+ const full = hasIntl()
445
+ ? dateFormat(locale, { hour: "numeric", minute: "2-digit", hour12: true }, timeZone).format(d)
446
+ : clock12(d);
447
+ // ICU puts a narrow no-break space before the meridiem; normalize so callers can split on it.
448
+ const clean = full.replace(/[  ]/g, " ");
449
+ const m = /^(.*?)\s*([AP]\.?\s?M\.?)$/i.exec(clean);
450
+ return m ? { time: m[1], meridiem: m[2] } : { time: clean, meridiem: "" };
451
+ }
452
+
453
+ /** "8:00 PM" — the one clock every customer screen uses (12-hour, en-US shape). */
454
+ export function formatClock(date: Date, locale = appLocale(), timeZone?: string): string {
455
+ const { time, meridiem } = clockParts(date, locale, timeZone);
456
+ return meridiem ? `${time} ${meridiem}` : time;
457
+ }
458
+
459
+ /** "10:00 – 11:15 AM" when both ends share the meridiem, "11:30 AM – 12:45 PM" otherwise. The meridiem is whatever the
460
+ * locale writes (`AM`, `p. m.`), so it is compared as a whole, never as the last word of the text. */
461
+ export function formatClockRange(start: Date, end: Date, locale = appLocale(), timeZone?: string): string {
462
+ const a = clockParts(start, locale, timeZone), b = clockParts(end, locale, timeZone);
463
+ if (a.meridiem && a.meridiem === b.meridiem) return `${a.time} – ${b.time} ${b.meridiem}`;
464
+ return `${formatClock(start, locale, timeZone)} – ${formatClock(end, locale, timeZone)}`;
465
+ }
466
+
467
+ /** Is this ISO instant before `now`? A missing or unparseable value is NOT past — "no expiry"
468
+ * must never classify an offer as expired. */
469
+ export function isPastDate(iso: string | undefined | null, now: number = Date.now()): boolean {
470
+ if (!iso) return false;
471
+ const t = Date.parse(iso);
472
+ return !Number.isNaN(t) && t < now;
473
+ }
474
+
475
+ /** The calendar day `date` falls on in `timeZone` (device zone when absent, unknown, or when
476
+ * the engine has no Intl), as `YYYY-MM-DD`. For "is this today / this year" comparisons. */
477
+ export function calendarDay(date: Date, timeZone?: string): string {
478
+ if (hasIntl()) {
479
+ const parts = dateFormat("en-CA", { year: "numeric", month: "2-digit", day: "2-digit" }, timeZone).formatToParts(date);
480
+ const get = (type: string) => parts.find((p) => p.type === type)?.value ?? "";
481
+ return `${get("year")}-${get("month")}-${get("day")}`;
482
+ }
483
+ return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`;
484
+ }
485
+
486
+ /**
487
+ * [timeZone]'s offset from UTC in ms at instant [at] (Asia/Jerusalem in winter: 7_200_000), or NaN
488
+ * where it cannot be known — no ECMA-402 (the wrist engines) or a zone this engine does not know.
489
+ * Callers fall back to the device zone on NaN, as the formatters above do.
490
+ */
491
+ export function zoneOffsetAt(at: number, timeZone: string): number {
492
+ if (hasIntl() && Number.isFinite(at)) {
493
+ try {
494
+ const parts = new Intl.DateTimeFormat("en-US", {
495
+ timeZone, hourCycle: "h23", year: "numeric", month: "2-digit", day: "2-digit",
496
+ hour: "2-digit", minute: "2-digit", second: "2-digit",
497
+ }).formatToParts(new Date(at));
498
+ const n = (type: string) => Number(parts.find((p) => p.type === type)?.value);
499
+ return Date.UTC(n("year"), n("month") - 1, n("day"), n("hour") % 24, n("minute"), n("second")) - at;
500
+ } catch {
501
+ /* a zone this engine does not know: NaN below */
502
+ }
503
+ }
504
+ return NaN;
505
+ }
506
+
507
+ /** Long zone label plus its short offset, e.g. "Israel Standard Time (GMT+2)". An engine
508
+ * without ECMA-402 has no zone database, so callers omit the supplementary label there. */
509
+ export function formatTimeZoneLabel(date: Date, timeZone: string, locale = "en"): string {
510
+ if (hasIntl()) {
511
+ if (!timeZone) return "";
512
+ try {
513
+ const parts = new Intl.DateTimeFormat(locale, { timeZone, timeZoneName: "long" }).formatToParts(date);
514
+ const name = parts.find((part) => part.type === "timeZoneName")?.value || timeZone;
515
+ const offset = new Intl.DateTimeFormat(locale, { timeZone, timeZoneName: "shortOffset" })
516
+ .formatToParts(date).find((part) => part.type === "timeZoneName")?.value;
517
+ return offset ? `${name} (${offset.replace(/:00$/, "")})` : name;
518
+ } catch {
519
+ return timeZone;
520
+ }
521
+ }
522
+ return "";
523
+ }