@wix/himalaya-cli 0.1871.0 → 0.1872.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 (180) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +3 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/portfolio/src/index.d.ts +19 -0
  3. package/dist/cli.mjs +89 -39
  4. package/fixtures/wix-canned.json +8 -0
  5. package/guides/release-notes.md +18 -0
  6. package/guides/sdk-reference.json +8 -1
  7. package/package.json +2 -2
  8. package/template-icons/professional-services.png +0 -0
  9. package/templates/bare-fashion/config.ts +37 -2
  10. package/templates/bare-fashion/dev/index.ts +4006 -48
  11. package/templates/bare-fashion/himalaya.content.json +15 -0
  12. package/templates/bare-fashion/tier5-src/_shared/member-account-routes.ts +56 -0
  13. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  14. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  15. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  16. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  17. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  18. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  19. package/templates/branded-lite/dev/index.ts +2 -1
  20. package/templates/branded-lite/tier5-src/_shared/portfolio-details.ts +70 -0
  21. package/templates/branded-lite/tier5-src/himi-branded-lite-coupons/index.ts +13 -2
  22. package/templates/branded-lite/tier5-src/himi-branded-lite-portfolio/index.ts +90 -9
  23. package/templates/branded-lite/tier5-src/himi-branded-lite-portfolio-project/index.ts +53 -4
  24. package/templates/branded-lite/tier5-src/himi-events-list/index.ts +5 -1
  25. package/templates/community-club/tier5-src/himi-events-list/index.ts +5 -1
  26. package/templates/conference/config.ts +43 -1
  27. package/templates/conference/dev/index.ts +4127 -0
  28. package/templates/conference/himalaya.content.json +18 -0
  29. package/templates/conference/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  30. package/templates/conference/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  31. package/templates/conference/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  32. package/templates/conference/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  33. package/templates/conference/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  34. package/templates/conference/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  35. package/templates/conference/tier5-src/himi-events-list/index.ts +5 -1
  36. package/templates/conference/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  37. package/templates/events-meetups/tier5-src/himi-events-list/index.ts +5 -1
  38. package/templates/gym-fitness/tier5-src/himi-events-list/index.ts +5 -1
  39. package/templates/medical-services/config.ts +42 -0
  40. package/templates/medical-services/dev/index.ts +4136 -0
  41. package/templates/medical-services/himalaya.content.json +18 -0
  42. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  43. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  44. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  45. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  46. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  47. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  48. package/templates/medical-services/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  49. package/templates/nonprofit-cause/tier5-src/himi-events-list/index.ts +5 -1
  50. package/templates/podcast-creator/tier5-src/himi-events-list/index.ts +5 -1
  51. package/templates/portfolio-creative/dev/index.ts +2 -1
  52. package/templates/portfolio-creative/tier5-src/_shared/portfolio-details.ts +70 -0
  53. package/templates/portfolio-creative/tier5-src/himi-branded-lite-portfolio/index.ts +90 -9
  54. package/templates/portfolio-creative/tier5-src/himi-branded-lite-portfolio-project/index.ts +53 -4
  55. package/templates/portfolio-creative/tier5-src/himi-events-list/index.ts +5 -1
  56. package/templates/professional-services/README.md +55 -0
  57. package/templates/professional-services/config.ts +436 -0
  58. package/templates/professional-services/dev/index.ts +44772 -0
  59. package/templates/professional-services/himalaya.content.json +100 -0
  60. package/templates/professional-services/himalaya.template.json +16 -0
  61. package/templates/professional-services/icon.png +0 -0
  62. package/templates/professional-services/platforms.json +1 -0
  63. package/templates/professional-services/tier5-src/_shared/app-locale.ts +70 -0
  64. package/templates/professional-services/tier5-src/_shared/booking-location.ts +147 -0
  65. package/templates/professional-services/tier5-src/_shared/booking-session.ts +224 -0
  66. package/templates/professional-services/tier5-src/_shared/branded-lite-hosted.ts +282 -0
  67. package/templates/professional-services/tier5-src/_shared/branded-load-state.ts +109 -0
  68. package/templates/professional-services/tier5-src/_shared/business-chat-copy.ts +40 -0
  69. package/templates/professional-services/tier5-src/_shared/business-chat-history.ts +51 -0
  70. package/templates/professional-services/tier5-src/_shared/business-chat-message-model.ts +177 -0
  71. package/templates/professional-services/tier5-src/_shared/business-chat-model.ts +56 -0
  72. package/templates/professional-services/tier5-src/_shared/business-chat-presenter.ts +587 -0
  73. package/templates/professional-services/tier5-src/_shared/business-chat-transport.ts +164 -0
  74. package/templates/professional-services/tier5-src/_shared/chat-live.ts +242 -0
  75. package/templates/professional-services/tier5-src/_shared/collection-contract.ts +232 -0
  76. package/templates/professional-services/tier5-src/_shared/collection-query.ts +201 -0
  77. package/templates/professional-services/tier5-src/_shared/collection-service.ts +429 -0
  78. package/templates/professional-services/tier5-src/_shared/detail-presence.ts +51 -0
  79. package/templates/professional-services/tier5-src/_shared/engine-intl.ts +538 -0
  80. package/templates/professional-services/tier5-src/_shared/event-registration.ts +86 -0
  81. package/templates/professional-services/tier5-src/_shared/events-inline-options.ts +77 -0
  82. package/templates/professional-services/tier5-src/_shared/faq-list.ts +405 -0
  83. package/templates/professional-services/tier5-src/_shared/featured-event.ts +63 -0
  84. package/templates/professional-services/tier5-src/_shared/group-member-count.ts +15 -0
  85. package/templates/professional-services/tier5-src/_shared/group-privacy.ts +14 -0
  86. package/templates/professional-services/tier5-src/_shared/guest-sign-in.ts +36 -0
  87. package/templates/professional-services/tier5-src/_shared/himi-account.ts +222 -0
  88. package/templates/professional-services/tier5-src/_shared/himi-blog-hidden.ts +66 -0
  89. package/templates/professional-services/tier5-src/_shared/himi-blog-post-row.ts +214 -0
  90. package/templates/professional-services/tier5-src/_shared/himi-blog-saved.ts +64 -0
  91. package/templates/professional-services/tier5-src/_shared/himi-booking-saved.ts +88 -0
  92. package/templates/professional-services/tier5-src/_shared/himi-bookings.ts +318 -0
  93. package/templates/professional-services/tier5-src/_shared/himi-copy.ts +123 -0
  94. package/templates/professional-services/tier5-src/_shared/himi-events.ts +92 -0
  95. package/templates/professional-services/tier5-src/_shared/himi-media.ts +33 -0
  96. package/templates/professional-services/tier5-src/_shared/himi-store.ts +7 -0
  97. package/templates/professional-services/tier5-src/_shared/himi-text.ts +24 -0
  98. package/templates/professional-services/tier5-src/_shared/host-events.ts +66 -0
  99. package/templates/professional-services/tier5-src/_shared/hosted-checkout.ts +70 -0
  100. package/templates/professional-services/tier5-src/_shared/iap-attendance-form.ts +106 -0
  101. package/templates/professional-services/tier5-src/_shared/iap-attendance-purchase.ts +235 -0
  102. package/templates/professional-services/tier5-src/_shared/iap-attendance.ts +38 -0
  103. package/templates/professional-services/tier5-src/_shared/iap-worker.ts +127 -0
  104. package/templates/professional-services/tier5-src/_shared/inbox-rooms.ts +163 -0
  105. package/templates/professional-services/tier5-src/_shared/local-preferences.ts +38 -0
  106. package/templates/professional-services/tier5-src/_shared/member-access.ts +63 -0
  107. package/templates/professional-services/tier5-src/_shared/member-account-routes.ts +56 -0
  108. package/templates/professional-services/tier5-src/_shared/member-avatar.ts +76 -0
  109. package/templates/professional-services/tier5-src/_shared/member-bookings.ts +107 -0
  110. package/templates/professional-services/tier5-src/_shared/member-read.ts +82 -0
  111. package/templates/professional-services/tier5-src/_shared/member-screen.ts +99 -0
  112. package/templates/professional-services/tier5-src/_shared/notification-target.ts +141 -0
  113. package/templates/professional-services/tier5-src/_shared/offset-page.ts +10 -0
  114. package/templates/professional-services/tier5-src/_shared/online-actions.ts +76 -0
  115. package/templates/professional-services/tier5-src/_shared/owner-load-error.ts +348 -0
  116. package/templates/professional-services/tier5-src/_shared/payment-setup.ts +6 -0
  117. package/templates/professional-services/tier5-src/_shared/portfolio-details.ts +70 -0
  118. package/templates/professional-services/tier5-src/_shared/pricing-plan-display.ts +64 -0
  119. package/templates/professional-services/tier5-src/_shared/relative-time.ts +21 -0
  120. package/templates/professional-services/tier5-src/_shared/result-snackbar.ts +26 -0
  121. package/templates/professional-services/tier5-src/_shared/rich-body.ts +78 -0
  122. package/templates/professional-services/tier5-src/_shared/rich-content-link.ts +34 -0
  123. package/templates/professional-services/tier5-src/_shared/sign-in-sheet.ts +18 -0
  124. package/templates/professional-services/tier5-src/_shared/staff-name.ts +18 -0
  125. package/templates/professional-services/tier5-src/_shared/weekly-goal.ts +111 -0
  126. package/templates/professional-services/tier5-src/_shared/wix-bi.ts +85 -0
  127. package/templates/professional-services/tier5-src/_shared/wix-member-links.ts +114 -0
  128. package/templates/professional-services/tier5-src/_shared/wix-service-price.ts +146 -0
  129. package/templates/professional-services/tier5-src/business-chat/index.ts +797 -0
  130. package/templates/professional-services/tier5-src/business-contact/index.ts +6 -0
  131. package/templates/professional-services/tier5-src/himi-blog-feed/index.ts +444 -0
  132. package/templates/professional-services/tier5-src/himi-blog-post/index.ts +1239 -0
  133. package/templates/professional-services/tier5-src/himi-booking-account/index.ts +278 -0
  134. package/templates/professional-services/tier5-src/himi-booking-bookings/index.ts +475 -0
  135. package/templates/professional-services/tier5-src/himi-booking-service/index.ts +1197 -0
  136. package/templates/professional-services/tier5-src/himi-booking-services/index.ts +795 -0
  137. package/templates/professional-services/tier5-src/himi-booking-time/index.ts +1840 -0
  138. package/templates/professional-services/tier5-src/himi-branded-lite-coupons/index.ts +96 -0
  139. package/templates/professional-services/tier5-src/himi-branded-lite-faq/index.ts +6 -0
  140. package/templates/professional-services/tier5-src/himi-branded-lite-file-share/index.ts +12 -0
  141. package/templates/professional-services/tier5-src/himi-branded-lite-group/index.ts +310 -0
  142. package/templates/professional-services/tier5-src/himi-branded-lite-group-about/index.ts +240 -0
  143. package/templates/professional-services/tier5-src/himi-branded-lite-my-groups/index.ts +237 -0
  144. package/templates/professional-services/tier5-src/himi-branded-lite-notifications/index.ts +263 -0
  145. package/templates/professional-services/tier5-src/himi-branded-lite-plans/index.ts +498 -0
  146. package/templates/professional-services/tier5-src/himi-branded-lite-portfolio/index.ts +136 -0
  147. package/templates/professional-services/tier5-src/himi-branded-lite-portfolio-project/index.ts +198 -0
  148. package/templates/professional-services/tier5-src/himi-events-detail/index.ts +1306 -0
  149. package/templates/professional-services/tier5-src/himi-events-list/index.ts +171 -0
  150. package/templates/professional-services/tier5-src/himi-events-my-events/index.ts +227 -0
  151. package/templates/professional-services/tier5-src/himi-events-rsvp/index.ts +230 -0
  152. package/templates/professional-services/tier5-src/himi-professional-services-community/index.ts +318 -0
  153. package/templates/professional-services/tier5-src/himi-professional-services-home/index.ts +772 -0
  154. package/templates/professional-services/tier5-src/himi-store-account/index.ts +1514 -0
  155. package/templates/professional-services/tier5-src/wix-spaces-coupon-detail/index.ts +43 -0
  156. package/templates/professional-services/tier5-src/wix-spaces-my-subscriptions/index.ts +89 -0
  157. package/templates/professional-services/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  158. package/templates/professional-services/tokens.json +456 -0
  159. package/templates/restaurant/tier5-src/himi-events-list/index.ts +5 -1
  160. package/templates/salon-spa/config.ts +42 -0
  161. package/templates/salon-spa/dev/index.ts +4136 -0
  162. package/templates/salon-spa/himalaya.content.json +18 -0
  163. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  164. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  165. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  166. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  167. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  168. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  169. package/templates/salon-spa/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  170. package/templates/wholesale-store/config.ts +43 -1
  171. package/templates/wholesale-store/dev/index.ts +4136 -0
  172. package/templates/wholesale-store/himalaya.content.json +18 -0
  173. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  174. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  175. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  176. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  177. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  178. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  179. package/templates/wholesale-store/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  180. package/templates/yoga-studio/tier5-src/himi-events-list/index.ts +5 -1
@@ -0,0 +1,278 @@
1
+ // Tier-5 bundle: himi-booking — visitor/member account state.
2
+ import { defineService, navigate } from "@himalaya/state";
3
+ import { dispatch } from "@himalaya/dispatch";
4
+ import { queryBookings, type WixBooking } from "@himalaya/wix-bookings";
5
+ import { loadMemberProfile, memberIdentity, strOf, fmtDateTime, titleCase, type AccountActivityRow } from "../_shared/himi-account";
6
+ import { stashCopy, copyParam } from "../_shared/himi-copy.js";
7
+ import { memberScreenOpener } from "../_shared/member-screen.js";
8
+
9
+ const openMemberScreen = memberScreenOpener();
10
+
11
+ interface S {
12
+ status: "loading" | "ready";
13
+ isMember: boolean;
14
+ notMember: boolean;
15
+ identityLine: string;
16
+ detailLine: string;
17
+ memberName: string;
18
+ memberEmail: string;
19
+ memberImage: string;
20
+ memberInitials: string;
21
+ hasMemberImage: boolean;
22
+ noMemberImage: boolean;
23
+ authTitle: string;
24
+ authBody: string;
25
+ email: string;
26
+ password: string;
27
+ firstName: string;
28
+ lastName: string;
29
+ message: string;
30
+ isLoading: boolean;
31
+ notLoading: boolean;
32
+ isRegistering: boolean;
33
+ notRegistering: boolean;
34
+ activityTitle: string;
35
+ activitySummary: string;
36
+ activityRows: AccountActivityRow[];
37
+ activityEmptyText: string;
38
+ hasActivity: boolean;
39
+ noActivity: boolean;
40
+ servicesScreenId: string;
41
+ bookingsScreenId: string;
42
+ /** Sign out asks first on a screen that binds the confirm step (askSignOut → signOut, or
43
+ * cancelSignOut). A screen that calls signOut directly signs out at once, as before. */
44
+ confirmingSignOut?: boolean;
45
+ notConfirmingSignOut?: boolean;
46
+ }
47
+
48
+ function derive(s: S): S {
49
+ const isRegistering = !!s.isRegistering;
50
+ const hasActivity = s.activityRows.length > 0;
51
+ return {
52
+ ...s,
53
+ confirmingSignOut: !!s.confirmingSignOut && s.isMember,
54
+ notConfirmingSignOut: !(s.confirmingSignOut && s.isMember),
55
+ isLoading: s.status === "loading",
56
+ notLoading: s.status !== "loading",
57
+ notMember: !s.isMember,
58
+ isRegistering,
59
+ notRegistering: !isRegistering,
60
+ hasActivity,
61
+ noActivity: !hasActivity,
62
+ authTitle: isRegistering
63
+ ? copyParam("bookingAccount.authTitleRegister", "Create account")
64
+ : copyParam("bookingAccount.authTitle", "Welcome"),
65
+ authBody: isRegistering
66
+ ? copyParam("bookingAccount.authBodyRegister", "Create a member account to book services and see your history.")
67
+ : copyParam("bookingAccount.authBody", "Sign in to book services and see your history."),
68
+ };
69
+ }
70
+
71
+ function bookingEmail(booking: WixBooking): string {
72
+ const contact = booking.contactDetails as { email?: string; contactEmail?: string } | undefined;
73
+ return (contact?.email ?? contact?.contactEmail ?? "").toLowerCase();
74
+ }
75
+
76
+ function bookingTitle(booking: WixBooking): string {
77
+ const entity = booking.bookedEntity as { serviceName?: string; title?: string } | undefined;
78
+ return entity?.serviceName || entity?.title || "Booking";
79
+ }
80
+
81
+ function bookingStart(booking: WixBooking): string | undefined {
82
+ const entity = booking.bookedEntity as { slot?: { startDate?: string } } | undefined;
83
+ return entity?.slot?.startDate || booking.startDate || booking.createdDate;
84
+ }
85
+
86
+ function bookingRow(booking: WixBooking): AccountActivityRow {
87
+ const start = bookingStart(booking);
88
+ return {
89
+ id: booking.id || start || bookingTitle(booking),
90
+ title: bookingTitle(booking),
91
+ subtitle: fmtDateTime(start) || "Booked time",
92
+ meta: titleCase(booking.paymentStatus) || "",
93
+ status: titleCase(booking.status) || "Booked",
94
+ };
95
+ }
96
+
97
+ async function bookingRows(memberEmail: string): Promise<AccountActivityRow[]> {
98
+ if (!memberEmail) return [];
99
+ const res = await queryBookings({ query: { paging: { limit: 50 } } });
100
+ return (res.bookings ?? [])
101
+ .filter((booking) => bookingEmail(booking) === memberEmail.toLowerCase())
102
+ .sort((a, b) => (Date.parse(bookingStart(b) || "") || 0) - (Date.parse(bookingStart(a) || "") || 0))
103
+ .slice(0, 3)
104
+ .map(bookingRow);
105
+ }
106
+
107
+ async function probe(s: S): Promise<S> {
108
+ const profile = await loadMemberProfile(copyParam("bookingAccount.guestDetail", "Sign in to book services and see your booking history."));
109
+ let activityRows: AccountActivityRow[] = [];
110
+ if (profile.isMember) {
111
+ try {
112
+ activityRows = await bookingRows(profile.memberEmail);
113
+ } catch {
114
+ activityRows = [];
115
+ }
116
+ }
117
+ return derive({
118
+ ...s,
119
+ status: "ready",
120
+ isMember: profile.isMember,
121
+ identityLine: profile.identityLine,
122
+ detailLine: profile.detailLine,
123
+ memberName: profile.memberName,
124
+ memberEmail: profile.memberEmail,
125
+ memberImage: profile.memberImage,
126
+ memberInitials: profile.memberInitials,
127
+ hasMemberImage: profile.hasMemberImage,
128
+ noMemberImage: profile.noMemberImage,
129
+ email: profile.memberEmail || s.email,
130
+ message: "",
131
+ activityRows,
132
+ activityTitle: copyParam("bookingAccount.activityTitle", "Recent bookings"),
133
+ activitySummary: activityRows.length
134
+ ? `${activityRows.length} recent ${activityRows.length === 1 ? "booking" : "bookings"}`
135
+ : copyParam("bookingAccount.activityHint", "Bookings are loaded from Wix Bookings."),
136
+ activityEmptyText: profile.isMember
137
+ ? copyParam("bookingAccount.activityEmptyMember", "No bookings for this member yet.")
138
+ : copyParam("bookingAccount.activityEmptyGuest", "Sign in to see bookings."),
139
+ });
140
+ }
141
+
142
+ function optimisticMember(s: S, email: string): S {
143
+ return derive({
144
+ ...s,
145
+ status: "ready",
146
+ isMember: true,
147
+ identityLine: copyParam("bookingAccount.signedIn", "Signed in"),
148
+ detailLine: email,
149
+ memberName: email,
150
+ memberEmail: email,
151
+ memberImage: "",
152
+ memberInitials: "M",
153
+ hasMemberImage: false,
154
+ noMemberImage: true,
155
+ email,
156
+ password: "",
157
+ firstName: "",
158
+ lastName: "",
159
+ isRegistering: false,
160
+ message: "",
161
+ });
162
+ }
163
+
164
+ /** The session (a host read, no network) before the profile's network reads: right after a sign-in
165
+ * on the sign-in sheet, this screen reloads under it still showing the guest card, for as long as
166
+ * the profile and bookings took. A member now shows as signed in at once; the name follows. */
167
+ async function primeFromSession(s: S): Promise<S> {
168
+ if (s.isMember) return s;
169
+ const identity = await memberIdentity();
170
+ return identity.signedIn ? svc.primeMember(identity.email) : s;
171
+ }
172
+
173
+ const svc = defineService<S, {
174
+ primeMember: (s: S, arg?: unknown) => S;
175
+ load: (s: S, arg?: unknown) => Promise<S>;
176
+ refresh: (s: S, arg?: unknown) => Promise<S>;
177
+ setEmail: (s: S, arg?: unknown) => S;
178
+ setPassword: (s: S, arg?: unknown) => S;
179
+ setFirstName: (s: S, arg?: unknown) => S;
180
+ setLastName: (s: S, arg?: unknown) => S;
181
+ showRegister: (s: S) => S;
182
+ showSignIn: (s: S) => S;
183
+ signIn: (s: S) => Promise<S>;
184
+ register: (s: S) => Promise<S>;
185
+ signOut: (s: S) => Promise<S>;
186
+ askSignOut: (s: S) => S;
187
+ cancelSignOut: (s: S) => S;
188
+ openForMember: (s: S, arg?: unknown) => Promise<S>;
189
+ }>("himiBookingAccount", {
190
+ // An open sign-out confirm is this run's: a cold start never re-opens the dialog, and the flag
191
+ // is never written to the device.
192
+ notHydrated: ["confirmingSignOut", "notConfirmingSignOut"],
193
+ notPersisted: ["confirmingSignOut", "notConfirmingSignOut"],
194
+ state: derive({
195
+ status: "loading",
196
+ isMember: false,
197
+ notMember: true,
198
+ identityLine: "",
199
+ detailLine: "",
200
+ memberName: "",
201
+ memberEmail: "",
202
+ memberImage: "",
203
+ memberInitials: "M",
204
+ hasMemberImage: false,
205
+ noMemberImage: true,
206
+ authTitle: "Welcome",
207
+ authBody: "Sign in to book services and see your history.",
208
+ email: "",
209
+ password: "",
210
+ firstName: "",
211
+ lastName: "",
212
+ message: "",
213
+ isLoading: true,
214
+ notLoading: false,
215
+ isRegistering: false,
216
+ notRegistering: true,
217
+ activityTitle: "Recent bookings",
218
+ activitySummary: "",
219
+ activityRows: [],
220
+ activityEmptyText: "No bookings for this member yet.",
221
+ hasActivity: false,
222
+ noActivity: true,
223
+ servicesScreenId: "himi_services",
224
+ bookingsScreenId: "himi_bookings",
225
+ }),
226
+ actions: {
227
+ primeMember: (s, arg) => derive({ ...optimisticMember(s, strOf(arg)), memberName: "" }),
228
+ load: async (s, arg) => { stashCopy(arg); return probe(await primeFromSession(s)); },
229
+ refresh: async (s, arg) => { stashCopy(arg); return probe(await primeFromSession(s)); },
230
+ setEmail: (s, arg) => derive({ ...s, email: strOf(arg), message: "" }),
231
+ setPassword: (s, arg) => derive({ ...s, password: strOf(arg), message: "" }),
232
+ setFirstName: (s, arg) => derive({ ...s, firstName: strOf(arg), message: "" }),
233
+ setLastName: (s, arg) => derive({ ...s, lastName: strOf(arg), message: "" }),
234
+ showRegister: (s) => derive({ ...s, isRegistering: true, message: "" }),
235
+ showSignIn: (s) => derive({ ...s, isRegistering: false, message: "" }),
236
+ signIn: async (s) => {
237
+ if (!s.email || !s.password) return derive({ ...s, message: copyParam("bookingAccount.validationEmailPassword", "Enter your email and password.") });
238
+ try {
239
+ await dispatch("himi.wix.signInDirect", { email: s.email, password: s.password });
240
+ const next = await probe(optimisticMember(s, s.email));
241
+ return derive({ ...next, password: "", message: next.isMember ? "" : copyParam("bookingAccount.signInCheckDetails", "Sign in failed. Check your details.") });
242
+ } catch {
243
+ return derive({ ...s, password: "", message: copyParam("bookingAccount.signInFailed", "Sign in failed. Try again.") });
244
+ }
245
+ },
246
+ register: async (s) => {
247
+ if (!s.email || !s.password) return derive({ ...s, message: copyParam("bookingAccount.validationEmailPassword", "Enter your email and password.") });
248
+ try {
249
+ await dispatch("himi.wix.registerDirect", {
250
+ email: s.email,
251
+ password: s.password,
252
+ firstName: s.firstName,
253
+ lastName: s.lastName,
254
+ });
255
+ const next = await probe(optimisticMember(s, s.email));
256
+ return derive({ ...next, password: "", message: next.isMember ? "" : copyParam("bookingAccount.registerTrySignIn", "Account creation failed. Try signing in.") });
257
+ } catch {
258
+ return derive({ ...s, password: "", message: copyParam("bookingAccount.registerFailed", "Account creation failed. Try another email.") });
259
+ }
260
+ },
261
+ // A member-only screen from Profile (Salon & Spa's Messages row): a guest signs in first, and the
262
+ // screen opens on `returnTab` once signed in (_shared/member-screen.ts).
263
+ openForMember: async (s, arg): Promise<S> => {
264
+ const nav = await openMemberScreen(arg);
265
+ const current: S = svc.getState?.() ?? s;
266
+ return nav ? navigate(current, nav) : current;
267
+ },
268
+ signOut: async (s) => {
269
+ try { await dispatch("himi.wix.signOut"); } catch { /* ignore */ }
270
+ return probe({ ...s, isMember: false, isRegistering: false, message: "", confirmingSignOut: false });
271
+ },
272
+ // The confirm step before a sign-out (a destructive action always confirms).
273
+ askSignOut: (s) => derive({ ...s, confirmingSignOut: true }),
274
+ cancelSignOut: (s) => derive({ ...s, confirmingSignOut: false }),
275
+ },
276
+ });
277
+ svc.load();
278
+ export { svc };