@curless/hotel-storefront 0.85.0 → 0.87.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 (251) hide show
  1. package/dist/server.d.ts +1 -1
  2. package/dist/server.js +1 -1
  3. package/dist/tools/accept-terms.d.ts +4 -0
  4. package/dist/tools/accept-terms.d.ts.map +1 -0
  5. package/dist/tools/accept-terms.js +26 -0
  6. package/dist/tools/accept-terms.js.map +1 -0
  7. package/dist/tools/add-booking-addon.d.ts +4 -0
  8. package/dist/tools/add-booking-addon.d.ts.map +1 -0
  9. package/dist/tools/add-booking-addon.js +44 -0
  10. package/dist/tools/add-booking-addon.js.map +1 -0
  11. package/dist/tools/add-to-trip.d.ts +4 -0
  12. package/dist/tools/add-to-trip.d.ts.map +1 -0
  13. package/dist/tools/add-to-trip.js +49 -0
  14. package/dist/tools/add-to-trip.js.map +1 -0
  15. package/dist/tools/all-tools.d.ts +19124 -0
  16. package/dist/tools/all-tools.d.ts.map +1 -0
  17. package/dist/tools/all-tools.js +43 -0
  18. package/dist/tools/all-tools.js.map +1 -0
  19. package/dist/tools/answer.d.ts +3 -0
  20. package/dist/tools/answer.d.ts.map +1 -0
  21. package/dist/tools/answer.js +104 -0
  22. package/dist/tools/answer.js.map +1 -0
  23. package/dist/tools/args.d.ts +149 -0
  24. package/dist/tools/args.d.ts.map +1 -0
  25. package/dist/tools/args.js +176 -0
  26. package/dist/tools/args.js.map +1 -0
  27. package/dist/tools/base-output-schemas.d.ts +3 -0
  28. package/dist/tools/base-output-schemas.d.ts.map +1 -0
  29. package/dist/tools/base-output-schemas.js +396 -0
  30. package/dist/tools/base-output-schemas.js.map +1 -0
  31. package/dist/tools/book-picked.d.ts +4 -0
  32. package/dist/tools/book-picked.d.ts.map +1 -0
  33. package/dist/tools/book-picked.js +14 -0
  34. package/dist/tools/book-picked.js.map +1 -0
  35. package/dist/tools/booking-answer.d.ts +24 -0
  36. package/dist/tools/booking-answer.d.ts.map +1 -0
  37. package/dist/tools/booking-answer.js +567 -0
  38. package/dist/tools/booking-answer.js.map +1 -0
  39. package/dist/tools/buy-shop-item.d.ts +4 -0
  40. package/dist/tools/buy-shop-item.d.ts.map +1 -0
  41. package/dist/tools/buy-shop-item.js +45 -0
  42. package/dist/tools/buy-shop-item.js.map +1 -0
  43. package/dist/tools/call.d.ts +11 -0
  44. package/dist/tools/call.d.ts.map +1 -0
  45. package/dist/tools/call.js +2 -0
  46. package/dist/tools/call.js.map +1 -0
  47. package/dist/tools/cancel-facts.d.ts +281 -0
  48. package/dist/tools/cancel-facts.d.ts.map +1 -0
  49. package/dist/tools/cancel-facts.js +309 -0
  50. package/dist/tools/cancel-facts.js.map +1 -0
  51. package/dist/tools/cancel.d.ts +4 -0
  52. package/dist/tools/cancel.d.ts.map +1 -0
  53. package/dist/tools/cancel.js +415 -0
  54. package/dist/tools/cancel.js.map +1 -0
  55. package/dist/tools/capability-adjust.d.ts +31 -0
  56. package/dist/tools/capability-adjust.d.ts.map +1 -0
  57. package/dist/tools/capability-adjust.js +299 -0
  58. package/dist/tools/capability-adjust.js.map +1 -0
  59. package/dist/tools/card-addons.d.ts +4 -0
  60. package/dist/tools/card-addons.d.ts.map +1 -0
  61. package/dist/tools/card-addons.js +76 -0
  62. package/dist/tools/card-addons.js.map +1 -0
  63. package/dist/tools/change-booking.d.ts +4 -0
  64. package/dist/tools/change-booking.d.ts.map +1 -0
  65. package/dist/tools/change-booking.js +145 -0
  66. package/dist/tools/change-booking.js.map +1 -0
  67. package/dist/tools/clear-trip.d.ts +4 -0
  68. package/dist/tools/clear-trip.d.ts.map +1 -0
  69. package/dist/tools/clear-trip.js +10 -0
  70. package/dist/tools/clear-trip.js.map +1 -0
  71. package/dist/tools/compare.d.ts +4 -0
  72. package/dist/tools/compare.d.ts.map +1 -0
  73. package/dist/tools/compare.js +114 -0
  74. package/dist/tools/compare.js.map +1 -0
  75. package/dist/tools/current-trip.d.ts +70 -0
  76. package/dist/tools/current-trip.d.ts.map +1 -0
  77. package/dist/tools/current-trip.js +269 -0
  78. package/dist/tools/current-trip.js.map +1 -0
  79. package/dist/tools/deps.d.ts +229 -0
  80. package/dist/tools/deps.d.ts.map +1 -0
  81. package/dist/tools/deps.js +2 -0
  82. package/dist/tools/deps.js.map +1 -0
  83. package/dist/tools/follow-ups.d.ts +120 -0
  84. package/dist/tools/follow-ups.d.ts.map +1 -0
  85. package/dist/tools/follow-ups.js +369 -0
  86. package/dist/tools/follow-ups.js.map +1 -0
  87. package/dist/tools/forget-preferences.d.ts +4 -0
  88. package/dist/tools/forget-preferences.d.ts.map +1 -0
  89. package/dist/tools/forget-preferences.js +24 -0
  90. package/dist/tools/forget-preferences.js.map +1 -0
  91. package/dist/tools/get-hotel.d.ts +4 -0
  92. package/dist/tools/get-hotel.d.ts.map +1 -0
  93. package/dist/tools/get-hotel.js +350 -0
  94. package/dist/tools/get-hotel.js.map +1 -0
  95. package/dist/tools/hotel-choices.d.ts +132 -0
  96. package/dist/tools/hotel-choices.d.ts.map +1 -0
  97. package/dist/tools/hotel-choices.js +587 -0
  98. package/dist/tools/hotel-choices.js.map +1 -0
  99. package/dist/tools/itinerary.d.ts +4 -0
  100. package/dist/tools/itinerary.d.ts.map +1 -0
  101. package/dist/tools/itinerary.js +158 -0
  102. package/dist/tools/itinerary.js.map +1 -0
  103. package/dist/tools/list-booking-addons.d.ts +4 -0
  104. package/dist/tools/list-booking-addons.d.ts.map +1 -0
  105. package/dist/tools/list-booking-addons.js +21 -0
  106. package/dist/tools/list-booking-addons.js.map +1 -0
  107. package/dist/tools/list-bookings.d.ts +4 -0
  108. package/dist/tools/list-bookings.d.ts.map +1 -0
  109. package/dist/tools/list-bookings.js +119 -0
  110. package/dist/tools/list-bookings.js.map +1 -0
  111. package/dist/tools/list-extras.d.ts +4 -0
  112. package/dist/tools/list-extras.d.ts.map +1 -0
  113. package/dist/tools/list-extras.js +90 -0
  114. package/dist/tools/list-extras.js.map +1 -0
  115. package/dist/tools/list-hotels-ask.d.ts +133 -0
  116. package/dist/tools/list-hotels-ask.d.ts.map +1 -0
  117. package/dist/tools/list-hotels-ask.js +326 -0
  118. package/dist/tools/list-hotels-ask.js.map +1 -0
  119. package/dist/tools/list-hotels-empty.d.ts +5 -0
  120. package/dist/tools/list-hotels-empty.d.ts.map +1 -0
  121. package/dist/tools/list-hotels-empty.js +130 -0
  122. package/dist/tools/list-hotels-empty.js.map +1 -0
  123. package/dist/tools/list-hotels-home.d.ts +9 -0
  124. package/dist/tools/list-hotels-home.d.ts.map +1 -0
  125. package/dist/tools/list-hotels-home.js +181 -0
  126. package/dist/tools/list-hotels-home.js.map +1 -0
  127. package/dist/tools/list-hotels-page.d.ts +43 -0
  128. package/dist/tools/list-hotels-page.d.ts.map +1 -0
  129. package/dist/tools/list-hotels-page.js +344 -0
  130. package/dist/tools/list-hotels-page.js.map +1 -0
  131. package/dist/tools/list-hotels.d.ts +4 -0
  132. package/dist/tools/list-hotels.d.ts.map +1 -0
  133. package/dist/tools/list-hotels.js +24 -0
  134. package/dist/tools/list-hotels.js.map +1 -0
  135. package/dist/tools/list-shop-items.d.ts +4 -0
  136. package/dist/tools/list-shop-items.d.ts.map +1 -0
  137. package/dist/tools/list-shop-items.js +34 -0
  138. package/dist/tools/list-shop-items.js.map +1 -0
  139. package/dist/tools/list-shop-orders.d.ts +4 -0
  140. package/dist/tools/list-shop-orders.d.ts.map +1 -0
  141. package/dist/tools/list-shop-orders.js +22 -0
  142. package/dist/tools/list-shop-orders.js.map +1 -0
  143. package/dist/tools/look-up.d.ts +4 -0
  144. package/dist/tools/look-up.d.ts.map +1 -0
  145. package/dist/tools/look-up.js +207 -0
  146. package/dist/tools/look-up.js.map +1 -0
  147. package/dist/tools/output-schemas.d.ts +645 -0
  148. package/dist/tools/output-schemas.d.ts.map +1 -0
  149. package/dist/tools/output-schemas.js +503 -0
  150. package/dist/tools/output-schemas.js.map +1 -0
  151. package/dist/tools/paid-lines.d.ts +718 -0
  152. package/dist/tools/paid-lines.d.ts.map +1 -0
  153. package/dist/tools/paid-lines.js +359 -0
  154. package/dist/tools/paid-lines.js.map +1 -0
  155. package/dist/tools/pay-with-union-pay.d.ts +4 -0
  156. package/dist/tools/pay-with-union-pay.d.ts.map +1 -0
  157. package/dist/tools/pay-with-union-pay.js +112 -0
  158. package/dist/tools/pay-with-union-pay.js.map +1 -0
  159. package/dist/tools/payment-words.d.ts +269 -0
  160. package/dist/tools/payment-words.d.ts.map +1 -0
  161. package/dist/tools/payment-words.js +365 -0
  162. package/dist/tools/payment-words.js.map +1 -0
  163. package/dist/tools/pick-room.d.ts +4 -0
  164. package/dist/tools/pick-room.d.ts.map +1 -0
  165. package/dist/tools/pick-room.js +23 -0
  166. package/dist/tools/pick-room.js.map +1 -0
  167. package/dist/tools/policies.d.ts +4 -0
  168. package/dist/tools/policies.d.ts.map +1 -0
  169. package/dist/tools/policies.js +74 -0
  170. package/dist/tools/policies.js.map +1 -0
  171. package/dist/tools/pricing.d.ts +55 -0
  172. package/dist/tools/pricing.d.ts.map +1 -0
  173. package/dist/tools/pricing.js +260 -0
  174. package/dist/tools/pricing.js.map +1 -0
  175. package/dist/tools/put-room-line.d.ts +12 -0
  176. package/dist/tools/put-room-line.d.ts.map +1 -0
  177. package/dist/tools/put-room-line.js +347 -0
  178. package/dist/tools/put-room-line.js.map +1 -0
  179. package/dist/tools/quote-card.d.ts +234 -0
  180. package/dist/tools/quote-card.d.ts.map +1 -0
  181. package/dist/tools/quote-card.js +375 -0
  182. package/dist/tools/quote-card.js.map +1 -0
  183. package/dist/tools/refund-booking.d.ts +4 -0
  184. package/dist/tools/refund-booking.d.ts.map +1 -0
  185. package/dist/tools/refund-booking.js +112 -0
  186. package/dist/tools/refund-booking.js.map +1 -0
  187. package/dist/tools/request-booking.d.ts +4 -0
  188. package/dist/tools/request-booking.d.ts.map +1 -0
  189. package/dist/tools/request-booking.js +5 -0
  190. package/dist/tools/request-booking.js.map +1 -0
  191. package/dist/tools/request-words.d.ts +238 -0
  192. package/dist/tools/request-words.d.ts.map +1 -0
  193. package/dist/tools/request-words.js +487 -0
  194. package/dist/tools/request-words.js.map +1 -0
  195. package/dist/tools/room-choices.d.ts +64 -0
  196. package/dist/tools/room-choices.d.ts.map +1 -0
  197. package/dist/tools/room-choices.js +374 -0
  198. package/dist/tools/room-choices.js.map +1 -0
  199. package/dist/tools/session-notes.d.ts +164 -0
  200. package/dist/tools/session-notes.d.ts.map +1 -0
  201. package/dist/tools/session-notes.js +412 -0
  202. package/dist/tools/session-notes.js.map +1 -0
  203. package/dist/tools/sign-in.d.ts +4 -0
  204. package/dist/tools/sign-in.d.ts.map +1 -0
  205. package/dist/tools/sign-in.js +72 -0
  206. package/dist/tools/sign-in.js.map +1 -0
  207. package/dist/tools/sign-out.d.ts +4 -0
  208. package/dist/tools/sign-out.d.ts.map +1 -0
  209. package/dist/tools/sign-out.js +13 -0
  210. package/dist/tools/sign-out.js.map +1 -0
  211. package/dist/tools/terms-answer.d.ts +114 -0
  212. package/dist/tools/terms-answer.d.ts.map +1 -0
  213. package/dist/tools/terms-answer.js +492 -0
  214. package/dist/tools/terms-answer.js.map +1 -0
  215. package/dist/tools/tool-defs-account.d.ts +80 -0
  216. package/dist/tools/tool-defs-account.d.ts.map +1 -0
  217. package/dist/tools/tool-defs-account.js +65 -0
  218. package/dist/tools/tool-defs-account.js.map +1 -0
  219. package/dist/tools/tool-defs-addons.d.ts +251 -0
  220. package/dist/tools/tool-defs-addons.d.ts.map +1 -0
  221. package/dist/tools/tool-defs-addons.js +198 -0
  222. package/dist/tools/tool-defs-addons.js.map +1 -0
  223. package/dist/tools/tool-defs-booking.d.ts +410 -0
  224. package/dist/tools/tool-defs-booking.d.ts.map +1 -0
  225. package/dist/tools/tool-defs-booking.js +285 -0
  226. package/dist/tools/tool-defs-booking.js.map +1 -0
  227. package/dist/tools/tool-defs-browse.d.ts +444 -0
  228. package/dist/tools/tool-defs-browse.d.ts.map +1 -0
  229. package/dist/tools/tool-defs-browse.js +307 -0
  230. package/dist/tools/tool-defs-browse.js.map +1 -0
  231. package/dist/tools/tool-defs-trip.d.ts +136 -0
  232. package/dist/tools/tool-defs-trip.d.ts.map +1 -0
  233. package/dist/tools/tool-defs-trip.js +79 -0
  234. package/dist/tools/tool-defs-trip.js.map +1 -0
  235. package/dist/tools/tool-env.d.ts +64 -0
  236. package/dist/tools/tool-env.d.ts.map +1 -0
  237. package/dist/tools/tool-env.js +49 -0
  238. package/dist/tools/tool-env.js.map +1 -0
  239. package/dist/tools/tool-set.d.ts +1425 -0
  240. package/dist/tools/tool-set.d.ts.map +1 -0
  241. package/dist/tools/tool-set.js +244 -0
  242. package/dist/tools/tool-set.js.map +1 -0
  243. package/dist/tools/view-trip.d.ts +4 -0
  244. package/dist/tools/view-trip.d.ts.map +1 -0
  245. package/dist/tools/view-trip.js +7 -0
  246. package/dist/tools/view-trip.js.map +1 -0
  247. package/dist/tools.d.ts +13 -2089
  248. package/dist/tools.d.ts.map +1 -1
  249. package/dist/tools.js +11 -10685
  250. package/dist/tools.js.map +1 -1
  251. package/package.json +1 -1
@@ -0,0 +1,269 @@
1
+ import type { ToolNames } from '../config.js';
2
+ import type { Booking, BookingPayment } from '../types.js';
3
+ import type { ToolAnswer, ToolContext, ToolDeps } from './deps.js';
4
+ /**
5
+ * Its money in a line - the booking's status first (2026-10-16 audit, P0-C): a
6
+ * stay cancelled with nothing going back is never "paid in advance by card".
7
+ */
8
+ export declare const paymentWords: (b: Booking) => string;
9
+ /**
10
+ * What a booking holds and what cancelling it costs, in a line - to a client
11
+ * that draws no card, where the words are all the guest has of it.
12
+ *
13
+ * ⚠️ A CODE, A HOTEL AND A DATE WERE ALL IT SAID (2026-11-02 audit, P3-3): in
14
+ * the same conversation a model fills in the room from what came before, but
15
+ * a booking looked up later by its code had no room and no terms beside it.
16
+ */
17
+ export declare const heldRoomsWords: (b: Booking, terms?: boolean) => string;
18
+ /**
19
+ * A booking's status said for the model where the booking was never sent to its
20
+ * group (0.55.7, 总线程 11-05): "requested" - or "confirmed", paid on a page that moved
21
+ * no money - promised an answer from a group that never heard of it. The card says
22
+ * the same (`shownStatus`); `undefined` where the status says what it is.
23
+ */
24
+ export declare const notSentStatus: (deps: ToolDeps, b: Booking) => string | undefined;
25
+ /**
26
+ * An `unconfirmed` booking said for what it is (Otaless 0.63.2): a person is
27
+ * checking a payment that was not the amount asked, or the group never said
28
+ * whether it was made - it may have been. `undefined` for any other.
29
+ */
30
+ export declare const unconfirmedSaid: (deps: ToolDeps, b: Booking) => string | undefined;
31
+ /**
32
+ * The words for an order whose payment page is held back for the group's new
33
+ * cancellation terms (Otaless 0.66.0; 总线程 11-11, D): only the facts - never "nothing
34
+ * is ordered" (it is), never "cancelling is free before paying".
35
+ */
36
+ export declare const termsHeldWords: (deps: ToolDeps, b: Booking) => string;
37
+ /** The words for a payment page that has closed on its own (Otaless 0.63.2). */
38
+ export declare const LINK_CLOSED_WORDS = "the payment link is no longer open - look at the bookings again; nothing is paid until it is";
39
+ export declare const bookingNotes: (deps: ToolDeps, b: Booking) => string;
40
+ /**
41
+ * A booking of a rate paid in advance made without its payment (0.77.5,
42
+ * `Booking.paymentNotConnected`): the fact - not paid, nothing charged, payment not connected
43
+ * here yet - in the text and, word for word, in the structure (`notPaidSaid`). Never "paid at
44
+ * the hotel", and nothing about what kind of booking it is.
45
+ */
46
+ export declare const notPaidWords: (b: Booking) => string;
47
+ /**
48
+ * ⚠️ VALUE-ADDED SERVICES (增值服务), SAID WHERE A BOOKING IS DONE (0.84.0, robin 11-24: 「应该在订单完成的
49
+ * 时候就可以购买,而不是要去我的预订买」). Only where the deployment sells them (`/claude`: the shop with
50
+ * buying open), only for a booking of this account that can still take them - confirmed: a booking still
51
+ * waiting for its room payment is paid first, in the bookings list too (0.84.2, the 11-25 UI review's
52
+ * P2-1 - `canAdd` takes confirmed bookings alone; it had offered them for one awaiting payment). The next
53
+ * step in words, tool names and what each takes, so a client that draws no card can go on; a card
54
+ * client is told the card shows them under the booking. ⚠️ NOTHING IS BOUGHT BY THE ASSISTANT: the buy
55
+ * tool prepares a page the guest confirms on.
56
+ */
57
+ export declare const valueAddedLine: (deps: ToolDeps, t: ToolNames, ctx: ToolContext, list: readonly Booking[], confirmedOnly: boolean) => string;
58
+ /** A booking for the card and the model's structure, with `notSentStatus` where there is one. */
59
+ export declare const listedForCard: (deps: ToolDeps, b: Booking) => {
60
+ addons?: true | undefined;
61
+ termsOverdue?: true | undefined;
62
+ termsHeldSaid?: string | undefined;
63
+ statusSaid?: string | undefined;
64
+ termsAutoAcceptedSaid?: string | undefined;
65
+ notPaidSaid?: string | undefined;
66
+ confirmUnseenSaid?: string | undefined;
67
+ noTermsSaid?: string | undefined;
68
+ payment?: BookingPayment | {
69
+ quotedAs?: string | import("../types.js").Money | undefined;
70
+ refundAmountText?: string | undefined;
71
+ amount: string;
72
+ payByWords?: string | undefined;
73
+ linkClosed?: true | undefined;
74
+ linkClosedSaid?: string | undefined;
75
+ host?: string | undefined;
76
+ method: import("../types.js").PaymentMethod;
77
+ status: "awaiting" | "issued" | "paid" | "lapsed" | "refunding" | "refunded" | "hotel-refunds";
78
+ url?: string;
79
+ payBy?: string;
80
+ payByLocal?: string;
81
+ payByLocalIso?: import("../types.js").LocalIso;
82
+ refundReason?: string;
83
+ refundAmount?: import("../types.js").Money;
84
+ refundStuck?: boolean;
85
+ groupReviews?: true;
86
+ refundUnsure?: true;
87
+ chargedWhenBooked?: true;
88
+ amountUnsaid?: true;
89
+ cancelledUnpaid?: true;
90
+ } | undefined;
91
+ cancellationFeeText?: string | undefined;
92
+ quote: {
93
+ dropped?: import("../types.js").DroppedLine[] | undefined;
94
+ stay?: import("../types.js").Stay | undefined;
95
+ coupons?: {
96
+ spend?: string | import("../types.js").Money | undefined;
97
+ off?: string | import("../types.js").Money | undefined;
98
+ minSpend?: string | import("../types.js").Money | undefined;
99
+ maxOff?: string | import("../types.js").Money | undefined;
100
+ amountOff?: string | import("../types.js").Money | undefined;
101
+ id: string;
102
+ kind: import("../types.js").CouponKind;
103
+ name: string;
104
+ names?: import("../types.js").Names;
105
+ percentOff?: number;
106
+ brands?: {
107
+ name: string;
108
+ names?: import("../types.js").Names;
109
+ }[];
110
+ hotels?: {
111
+ id: string;
112
+ name: string;
113
+ names?: import("../types.js").Names;
114
+ }[];
115
+ validFrom: string;
116
+ validUntil: string;
117
+ state: "usable" | "used" | "expired" | "not-yet";
118
+ usedOn?: {
119
+ code?: string;
120
+ stands: boolean;
121
+ };
122
+ }[] | undefined;
123
+ couponRefused?: {
124
+ spend?: string | import("../types.js").Money | undefined;
125
+ minSpend?: string | import("../types.js").Money | undefined;
126
+ id: string;
127
+ name?: string;
128
+ names?: import("../types.js").Names;
129
+ code: import("../types.js").CouponRefusal;
130
+ why: string;
131
+ } | undefined;
132
+ coupon?: {
133
+ off: string;
134
+ id: string;
135
+ name: string;
136
+ names?: import("../types.js").Names;
137
+ kind: import("../types.js").CouponKind;
138
+ hotelId: string;
139
+ hotelName: string;
140
+ hotelNames?: import("../types.js").Names;
141
+ checkIn: string;
142
+ checkOut: string;
143
+ validUntil: string;
144
+ } | undefined;
145
+ memberSaving?: {
146
+ memberTotal: string;
147
+ roomSaved?: string | undefined;
148
+ saved: string;
149
+ publicTotal: string;
150
+ publicSubtotal: string;
151
+ programme: string;
152
+ tier: string;
153
+ points: number;
154
+ } | undefined;
155
+ lines: {
156
+ day: string | undefined;
157
+ paymentNotConnected?: boolean | undefined;
158
+ payment?: "at-hotel" | "prepaid" | undefined;
159
+ freeCancellationLocalIso?: string | undefined;
160
+ freeCancellationLocal?: string | undefined;
161
+ freeCancellationUntil: string | undefined;
162
+ terms?: string | undefined;
163
+ refundable: boolean | undefined;
164
+ totalWithTaxes?: string | undefined;
165
+ total: string;
166
+ publicUnit?: string | undefined;
167
+ roomCharges?: string | undefined;
168
+ unit: string;
169
+ ordered?: number | undefined;
170
+ quantity: number | undefined;
171
+ hourly?: import("../types.js").HourlyStay | undefined;
172
+ stay: import("../types.js").Stay | undefined;
173
+ nights: number | undefined;
174
+ rate?: {
175
+ name: string;
176
+ kind?: import("../types.js").RateKind;
177
+ } | undefined;
178
+ meal?: import("../types.js").MealPlan | undefined;
179
+ window?: import("../types.js").WindowKind | undefined;
180
+ bedTypes?: import("../types.js").BedType[] | undefined;
181
+ detail: string | undefined;
182
+ titleNames?: Partial<Record<import("../types.js").NameLang, string>> | undefined;
183
+ roomRef: string | undefined;
184
+ extraRef: string | undefined;
185
+ title: string;
186
+ hotelNames?: Partial<Record<import("../types.js").NameLang, string>> | undefined;
187
+ hotelName: string;
188
+ supplier?: string | undefined;
189
+ kind: "room" | "extra";
190
+ hotelId: string;
191
+ }[];
192
+ subtotal: string;
193
+ taxesAndFees: string;
194
+ total: string;
195
+ };
196
+ couponNotReturnedBecause?: import("../types.js").CouponKeptWhy;
197
+ id: string;
198
+ supplier?: string;
199
+ confirmationCode: string;
200
+ status: import("../types.js").BookingStatus;
201
+ unverifiable?: true;
202
+ needsPerson?: "paid-amount" | "release";
203
+ termsChanged?: true;
204
+ confirmAsked?: true;
205
+ noTermsGiven?: true;
206
+ confirmUnseen?: true;
207
+ groupTermsAutoAccepted?: true;
208
+ termsUntil?: string;
209
+ rebookable?: true;
210
+ createdAt: string;
211
+ holdUntil?: string;
212
+ holdUntilLocal?: string;
213
+ holdUntilLocalIso?: import("../types.js").LocalIso;
214
+ hotelId: string;
215
+ hotelName: string;
216
+ hotelNames?: import("../types.js").Names;
217
+ stay: import("../types.js").Stay;
218
+ hourly?: import("../types.js").HourlyStay;
219
+ paymentNotConnected?: true;
220
+ orderNumber?: string;
221
+ guest: import("../types.js").Guest;
222
+ cancelledAt?: string;
223
+ cancellationFee?: import("../types.js").Money;
224
+ couponReturned?: boolean;
225
+ changedAt?: string;
226
+ requests?: import("../types.js").RoomRequests;
227
+ };
228
+ /**
229
+ * The host a payment page is on - what a guest checks before they pay - or
230
+ * nothing when the address is not one.
231
+ */
232
+ export declare const hostOf: (url: string | undefined) => string | undefined;
233
+ /**
234
+ * No confirm page can be made for the guest (not signed in to the account, too many links just now,
235
+ * or no account page here): nothing was prepared, and it is said so - the add-on is never done any
236
+ * other way.
237
+ */
238
+ export declare const noConfirmPage: (base: Record<string, unknown>) => {
239
+ structured: {
240
+ error: string;
241
+ view: "error";
242
+ };
243
+ text: string;
244
+ isError: true;
245
+ };
246
+ /**
247
+ * A moment as a clock time with its offset - "17:30 UTC+08:00, 10 Nov" - never
248
+ * a bare ISO string. Read from the string itself: its own offset when it has
249
+ * one, else UTC, since no hotel record here carries a time zone. Undefined for
250
+ * anything that is not an ISO moment.
251
+ */
252
+ export declare const clockWords: (iso: string | undefined) => string | undefined;
253
+ /** When a payment page is paid by: the hotel's own clock where the backend gave it, else the moment with its offset. */
254
+ export declare const payByWords: (p: Pick<BookingPayment, "payBy" | "payByLocal">) => string | undefined;
255
+ /**
256
+ * The answer to a booking refusal, or undefined when `err` is not one.
257
+ *
258
+ * ⚠️ `groups` IS READ DEFENSIVELY: a refusal that carries none says nothing of
259
+ * where to sign in. Per group: the account's link tool with that group's code
260
+ * where the deployment has one (`ToolDeps.groupSignIn`), else its sign-in tool.
261
+ */
262
+ export declare const refusalAnswer: (deps: ToolDeps, key: string, err: unknown) => (ToolAnswer & {
263
+ isError?: boolean;
264
+ }) | undefined;
265
+ /** A booking refusal as its answer (`view: 'error'`, its code), or undefined when `err` is not one. */
266
+ export declare const bookingRefusal: (deps: ToolDeps, key: string, err: unknown) => (ToolAnswer & {
267
+ isError?: boolean;
268
+ }) | undefined;
269
+ //# sourceMappingURL=payment-words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-words.d.ts","sourceRoot":"","sources":["../../src/tools/payment-words.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAsBnE;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,OAAO,KAAG,MA2BzC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,EAAE,eAAY,KAAG,MAuB3C,CAAC;AAEhB;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,QAAQ,EAAE,GAAG,OAAO,KAAG,MAAM,GAAG,SAKnE,CAAC;AAYF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,QAAQ,EAAE,GAAG,OAAO,KAAG,MAAM,GAAG,SAgBrE,CAAC;AAQF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,QAAQ,EAAE,GAAG,OAAO,KAAG,MAiB3D,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,iGACkE,CAAC;AA0BjG,eAAO,MAAM,YAAY,GAAI,MAAM,QAAQ,EAAE,GAAG,OAAO,KAAG,MAG5C,CAAC;AAEf;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,GAAG,OAAO,KAAG,MAKuG,CAAC;AAElJ;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,QAAQ,EACd,GAAG,SAAS,EACZ,KAAK,WAAW,EAChB,MAAM,SAAS,OAAO,EAAE,EACxB,eAAe,OAAO,KACrB,MAkBF,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,aAAa,GAAI,MAAM,QAAQ,EAAE,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA6K2+zB,CAAC;;;;;qBAAwF,CAAC;;;;;;oBAAqqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAxJly1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAOzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;CAIzD,CAAC;AAIH;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAY7D,CAAC;AAEF,wHAAwH;AACxH,eAAO,MAAM,UAAU,GAAI,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,YAAY,CAAC,KAAG,MAAM,GAAG,SACjD,CAAC;AA8BtC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,QAAQ,EACd,KAAK,MAAM,EACX,KAAK,OAAO,KACX,CAAC,UAAU,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,SAyDzC,CAAC;AAEF,uGAAuG;AACvG,eAAO,MAAM,cAAc,SA/DnB,QAAQ,OACT,MAAM,OACN,OAAO,KACX,CAAC,UAAU,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,SA4DC,CAAC"}
@@ -0,0 +1,365 @@
1
+ import { formatMoney } from '../money.js';
2
+ import { bookingForCard, holderOf } from './cancel-facts.js';
3
+ import { common } from './paid-lines.js';
4
+ import { SAYS_NON_REFUNDABLE, freeUntilText, withZh } from './quote-card.js';
5
+ const PAYMENT_WORDS = {
6
+ awaiting: 'to be paid on the card page',
7
+ issued: 'confirmed on UnionPay - the hotel is being asked to book it',
8
+ paid: 'paid in advance by card',
9
+ lapsed: 'not paid in time - nothing booked or charged',
10
+ refunding: 'refund in full under way',
11
+ refunded: 'refunded in full',
12
+ 'hotel-refunds': 'cancelled - the hotel returns the amount to the card it charged',
13
+ };
14
+ /**
15
+ * With UnionPay the hotel charges a one-time card UnionPay issued: the page
16
+ * is UnionPay's, the money is the hotel's to take and to give back.
17
+ */
18
+ const UNIONPAY_WORDS = {
19
+ awaiting: "to be confirmed on UnionPay's page",
20
+ paid: 'paid in advance with UnionPay - the hotel charges the card UnionPay issued',
21
+ lapsed: 'not booked - the hotel turned it down before charging, so nothing was charged',
22
+ };
23
+ /**
24
+ * Its money in a line - the booking's status first (2026-10-16 audit, P0-C): a
25
+ * stay cancelled with nothing going back is never "paid in advance by card".
26
+ */
27
+ export const paymentWords = (b) => {
28
+ const p = b.payment;
29
+ const ended = b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed';
30
+ if (ended && p.status === 'paid')
31
+ return b.cancellationFee && b.cancellationFee.minor >= p.amount.minor
32
+ ? 'cancelled after its free time - the fee was the whole amount paid, and nothing goes back'
33
+ : 'cancelled - what comes back of it depends on the cancellation fee, which a person is settling';
34
+ if (p.status === 'refunding' && p.groupReviews && p.refundUnsure)
35
+ return 'cancelled - whether the refund request reached the group is being checked';
36
+ if (p.status === 'refunding' && p.refundStuck)
37
+ return p.groupReviews
38
+ ? 'cancelled - the refund was not submitted to the group; a person is taking it up'
39
+ : 'due back to the card it was paid with - sending it back did not go through, and a person is seeing to it';
40
+ if (p.status === 'refunding' && p.groupReviews)
41
+ return `refund of ${p.refundAmount && p.refundAmount.minor !== p.amount.minor ? formatMoney(p.refundAmount) : `all ${formatMoney(p.amount)}`} submitted - back to the card it was paid with once the group has reviewed it`;
42
+ if ((p.status === 'refunding' || p.status === 'refunded') &&
43
+ p.refundAmount &&
44
+ p.refundAmount.minor !== p.amount.minor)
45
+ return `${formatMoney(p.refundAmount)} of ${formatMoney(p.amount)} ${p.status === 'refunded' ? 'refunded' : 'going back'} - the rest was the fee`;
46
+ // ⚠️ CANCELLED BEFORE IT WAS PAID IS NOT "NOT PAID IN TIME" (Otaless 0.84.2, the UI review's P2-2).
47
+ if (p.status === 'lapsed' && p.cancelledUnpaid)
48
+ return 'cancelled before it was paid - nothing booked or charged';
49
+ return ((p.method === 'unionpay' ? UNIONPAY_WORDS[p.status] : undefined) ?? PAYMENT_WORDS[p.status]);
50
+ };
51
+ /**
52
+ * What a booking holds and what cancelling it costs, in a line - to a client
53
+ * that draws no card, where the words are all the guest has of it.
54
+ *
55
+ * ⚠️ A CODE, A HOTEL AND A DATE WERE ALL IT SAID (2026-11-02 audit, P3-3): in
56
+ * the same conversation a model fills in the room from what came before, but
57
+ * a booking looked up later by its code had no room and no terms beside it.
58
+ */
59
+ export const heldRoomsWords = (b, terms = true) => b.quote.lines
60
+ .filter((l) => l.kind === 'room')
61
+ .map((l) => `${(l.quantity ?? 1) > 1 ? `${l.quantity}× ` : ''}${withZh(l.title, l.titleNames, true)}${!terms || b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed'
62
+ ? ''
63
+ : l.freeCancellationUntil
64
+ ? `, free to cancel until ${freeUntilText(l)}`
65
+ : l.refundable === false
66
+ ? // ⚠️ NOT TWICE (0.55.0, review r3 T10): 「… · Non-refundable(… · 不可取消),
67
+ // non-refundable」 - a rate whose name says it is not told it again.
68
+ SAYS_NON_REFUNDABLE.test(`${l.title} ${Object.values(l.titleNames ?? {}).join(' ')}`)
69
+ ? ''
70
+ : ', non-refundable'
71
+ : l.refundable
72
+ ? ', past its free cancellation - cancelling has a fee'
73
+ : ''}`)
74
+ .join('; ');
75
+ /**
76
+ * A booking's status said for the model where the booking was never sent to its
77
+ * group (0.55.7, 总线程 11-05): "requested" - or "confirmed", paid on a page that moved
78
+ * no money - promised an answer from a group that never heard of it. The card says
79
+ * the same (`shownStatus`); `undefined` where the status says what it is.
80
+ */
81
+ export const notSentStatus = (deps, b) => {
82
+ const h = holderOf(deps, b.supplier);
83
+ return h.notReal && ['requested', 'unconfirmed', 'confirmed'].includes(b.status)
84
+ ? `not sent to ${h.name} - nobody confirms it, and no room is held`
85
+ : undefined;
86
+ };
87
+ /**
88
+ * ⚠️ A BOOKING WITH A PERSON FOR HOURS (Otaless 0.67.0, 总线程's review of 0.66.0, 6): once
89
+ * the guest has been told it is still with a person, it no longer holds the stay back
90
+ * (`Booking.rebookable`) - and it may already stand at the group. So "cannot be booked
91
+ * again" is no longer true of it; say what is: check with the group first, and booking
92
+ * again makes a NEW order.
93
+ */
94
+ const rebookableWords = (group) => `the earlier order may already exist at ${group}: the guest should check with ${group} first - booking this stay again makes a new order`;
95
+ /**
96
+ * An `unconfirmed` booking said for what it is (Otaless 0.63.2): a person is
97
+ * checking a payment that was not the amount asked, or the group never said
98
+ * whether it was made - it may have been. `undefined` for any other.
99
+ */
100
+ export const unconfirmedSaid = (deps, b) => {
101
+ if (b.status !== 'unconfirmed')
102
+ return undefined;
103
+ const group = holderOf(deps, b.supplier).name;
104
+ if (b.needsPerson === 'paid-amount')
105
+ return `unconfirmed: ${group} says it was paid, but not at the amount asked - a person is checking the payment. No payment link is given, and ${b.rebookable ? rebookableWords(group) : 'this stay cannot be booked again until it is settled'}.`;
106
+ // 0.66.0: an order the group made that was not the one asked for, and cancelling it
107
+ // at once did not go through. It may still stand at the group: never paid.
108
+ if (b.needsPerson === 'release')
109
+ return `unconfirmed: ${group} made an order that is not the one the guest was shown, and cancelling it did not go through - a person is looking at it. Do not pay it: no payment link is given, and ${b.rebookable ? rebookableWords(group) : 'this stay cannot be booked again until it is settled'}.`;
110
+ if (b.unverifiable)
111
+ return `unconfirmed: ${group} never confirmed whether it was made, and it could not be found in its bookings - it may have been made. The guest should check with ${group} before booking it again; asked again, a new booking is made.`;
112
+ return undefined;
113
+ };
114
+ /** An order held for new terms whose time to agree has gone by (it is not settled yet). */
115
+ const termsOverdue = (deps, b) => (b.termsChanged === true || b.confirmAsked === true) &&
116
+ !!b.termsUntil &&
117
+ Date.parse(b.termsUntil) <= deps.trips.now();
118
+ /**
119
+ * The words for an order whose payment page is held back for the group's new
120
+ * cancellation terms (Otaless 0.66.0; 总线程 11-11, D): only the facts - never "nothing
121
+ * is ordered" (it is), never "cancelling is free before paying".
122
+ */
123
+ export const termsHeldWords = (deps, b) => {
124
+ const group = holderOf(deps, b.supplier).name;
125
+ // 0.67.1 (questions #68): the group made the order and asks the guest to CONFIRM what it
126
+ // sent - not new cancellation terms, not a closed link. Same shape: the facts only.
127
+ if (b.confirmAsked) {
128
+ if (termsOverdue(deps, b))
129
+ return 'the time for the guest to confirm has passed, so the order is being cancelled; if it cannot be cancelled, a person takes it over. Do not pay it';
130
+ const by = b.termsUntil ? (clockWords(b.termsUntil) ?? b.termsUntil) : undefined;
131
+ return `waiting for the guest to confirm what ${group} asked to confirm: no payment page until they do${by ? `; not confirmed by ${by}, the order is cancelled` : ''}`;
132
+ }
133
+ // ⚠️ PAST ITS TIME AND NOT SETTLED YET (0.67.0, 总线程's review of 0.66.0, 1): "the order is
134
+ // cancelled at <time>" of a time that has gone by promises what has not happened. The facts:
135
+ // the time has passed, it is being cancelled, and if that does not go through a person takes over.
136
+ if (termsOverdue(deps, b))
137
+ return `the time for the guest to agree to ${group}'s new cancellation terms has passed, so the order is being cancelled; if it cannot be cancelled, a person takes it over. Do not pay it`;
138
+ const until = b.termsUntil ? (clockWords(b.termsUntil) ?? b.termsUntil) : undefined;
139
+ return `waiting for the guest to agree to ${group}'s new cancellation terms: ${group} answered the order with terms that are not the ones the guest saw before, so there is no payment page until the guest reads them and agrees${until ? `; not agreed by ${until}, the order is cancelled` : ''}`;
140
+ };
141
+ /** The words for a payment page that has closed on its own (Otaless 0.63.2). */
142
+ export const LINK_CLOSED_WORDS = 'the payment link is no longer open - look at the bookings again; nothing is paid until it is';
143
+ /**
144
+ * What is said of a booking made with no terms to agree to, or one the group may want
145
+ * confirmed separately (0.67.1) - the facts, beside the price and the dates; '' for neither.
146
+ */
147
+ const noTermsWords = (deps, b) => b.noTermsGiven
148
+ ? `${holderOf(deps, b.supplier).name} gave no cancellation terms for this room.`
149
+ : '';
150
+ const confirmUnseenWords = (deps, b) => {
151
+ const g = holderOf(deps, b.supplier).name;
152
+ return b.confirmUnseen
153
+ ? `${g} may ask for this booking to be confirmed separately; what it would ask is not shown here.`
154
+ : '';
155
+ };
156
+ /**
157
+ * Terms agreed for the guest (0.68.1, 酒店对接 a4760ae1 - the dev backend's switch alone): the
158
+ * group asked for them, gave no text of them, and this service agreed to them when it placed the
159
+ * booking. Said as that - who agreed (0.68.2, 总线程's re-review: 「写明是谁同意的」) - never as
160
+ * the guest's own agreement.
161
+ */
162
+ const autoAcceptedWords = (deps, b) => b.groupTermsAutoAccepted
163
+ ? `${holderOf(deps, b.supplier).name} asked for its terms to be agreed to before booking but gave no text of them; this service agreed to them on the guest's behalf when it placed the booking.`
164
+ : '';
165
+ export const bookingNotes = (deps, b) => [noTermsWords(deps, b), autoAcceptedWords(deps, b), confirmUnseenWords(deps, b), notPaidWords(b)]
166
+ .filter(Boolean)
167
+ .join(' ');
168
+ /**
169
+ * A booking of a rate paid in advance made without its payment (0.77.5,
170
+ * `Booking.paymentNotConnected`): the fact - not paid, nothing charged, payment not connected
171
+ * here yet - in the text and, word for word, in the structure (`notPaidSaid`). Never "paid at
172
+ * the hotel", and nothing about what kind of booking it is.
173
+ */
174
+ export const notPaidWords = (b) => !b.paymentNotConnected
175
+ ? ''
176
+ : b.status === 'cancelled' || b.status === 'expired' || b.status === 'failed'
177
+ ? 'Nothing was paid or charged for this booking.'
178
+ : '**It is not paid: nothing has been charged** - payment is not connected here yet. Say exactly that; never that it is paid at the hotel.';
179
+ /**
180
+ * ⚠️ VALUE-ADDED SERVICES (增值服务), SAID WHERE A BOOKING IS DONE (0.84.0, robin 11-24: 「应该在订单完成的
181
+ * 时候就可以购买,而不是要去我的预订买」). Only where the deployment sells them (`/claude`: the shop with
182
+ * buying open), only for a booking of this account that can still take them - confirmed: a booking still
183
+ * waiting for its room payment is paid first, in the bookings list too (0.84.2, the 11-25 UI review's
184
+ * P2-1 - `canAdd` takes confirmed bookings alone; it had offered them for one awaiting payment). The next
185
+ * step in words, tool names and what each takes, so a client that draws no card can go on; a card
186
+ * client is told the card shows them under the booking. ⚠️ NOTHING IS BOUGHT BY THE ASSISTANT: the buy
187
+ * tool prepares a page the guest confirms on.
188
+ */
189
+ export const valueAddedLine = (deps, t, ctx, list, confirmedOnly) => {
190
+ const api = deps.backend.otalessAddons;
191
+ if (!api?.buyOpen || !t.listShopItems || !t.buyShopItem)
192
+ return '';
193
+ const codes = list
194
+ .filter((b) => b.confirmationCode && api.canAdd(b))
195
+ .filter((b) => !confirmedOnly || b.status === 'confirmed')
196
+ .map((b) => b.confirmationCode);
197
+ if (!codes.length)
198
+ return '';
199
+ const one = codes[0];
200
+ return [
201
+ `Value-added services (增值服务: goods from the Otaless shop to go with a stay) can be bought now for ${codes.join(', ')} - tell the guest.`,
202
+ ctx.noCards
203
+ ? ''
204
+ : 'Where the booking is drawn for the guest they are shown under it, each with its picture, price and a Buy button to press.',
205
+ `${t.listShopItems} lists them (each item's id, price and currency); then ${t.buyShopItem} with \`item\` (the item id), \`quantity\`, \`booking\` ("${one}"), \`unitPrice\` and \`currency\` as listed prepares a one-time page where the guest confirms the purchase - nothing is bought by the assistant.`,
206
+ ]
207
+ .filter(Boolean)
208
+ .join(' ');
209
+ };
210
+ /** A booking for the card and the model's structure, with `notSentStatus` where there is one. */
211
+ export const listedForCard = (deps, b) => {
212
+ const said = notSentStatus(deps, b) ?? unconfirmedSaid(deps, b);
213
+ return {
214
+ ...bookingForCard(b),
215
+ // 0.67.1: no terms given / may need the group's own confirmation - the same words as the text.
216
+ ...(b.noTermsGiven ? { noTermsSaid: noTermsWords(deps, b) } : {}),
217
+ ...(b.confirmUnseen ? { confirmUnseenSaid: confirmUnseenWords(deps, b) } : {}),
218
+ // 0.77.5: booked without its payment - the same words as the text.
219
+ ...(b.paymentNotConnected ? { notPaidSaid: notPaidWords(b) } : {}),
220
+ // 0.68.1: the group's terms agreed for the guest - the same words as the text.
221
+ ...(b.groupTermsAutoAccepted ? { termsAutoAcceptedSaid: autoAcceptedWords(deps, b) } : {}),
222
+ ...(said ? { statusSaid: said } : {}),
223
+ // 0.66.0: its payment page held back for the group's new terms - said, for the model.
224
+ ...(b.termsChanged || b.confirmAsked ? { termsHeldSaid: termsHeldWords(deps, b) } : {}),
225
+ // …and past its time: for the card, which has no clock of the deployment's (0.67.0).
226
+ ...(termsOverdue(deps, b) ? { termsOverdue: true } : {}),
227
+ // 0.84.0: a booking of this account that can still take value-added services, wherever it is
228
+ // drawn - the booking just made and paid too, not only My bookings (robin 11-24). Only where the
229
+ // deployment has them (`otalessAddons`); everywhere else nothing changes.
230
+ ...(deps.backend.otalessAddons?.canAdd(b) ? { addons: true } : {}),
231
+ };
232
+ };
233
+ /**
234
+ * The host a payment page is on - what a guest checks before they pay - or
235
+ * nothing when the address is not one.
236
+ */
237
+ export const hostOf = (url) => {
238
+ if (!url)
239
+ return undefined;
240
+ try {
241
+ return new URL(url).host || undefined;
242
+ }
243
+ catch {
244
+ return undefined;
245
+ }
246
+ };
247
+ /**
248
+ * No confirm page can be made for the guest (not signed in to the account, too many links just now,
249
+ * or no account page here): nothing was prepared, and it is said so - the add-on is never done any
250
+ * other way.
251
+ */
252
+ export const noConfirmPage = (base) => ({
253
+ structured: { view: 'error', ...base, error: 'no-confirm-page' },
254
+ text: "Nothing was prepared: a one-time page for the guest to confirm on could not be made (they must be signed in to their account here, and not asked for too many links at once). Nothing was added, ordered or charged - and it is never done without the guest's own confirm.",
255
+ isError: true,
256
+ });
257
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
258
+ /**
259
+ * A moment as a clock time with its offset - "17:30 UTC+08:00, 10 Nov" - never
260
+ * a bare ISO string. Read from the string itself: its own offset when it has
261
+ * one, else UTC, since no hotel record here carries a time zone. Undefined for
262
+ * anything that is not an ISO moment.
263
+ */
264
+ export const clockWords = (iso) => {
265
+ const m = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?$/.exec(iso ?? '');
266
+ if (!m)
267
+ return undefined;
268
+ const [, , mo, d, hh, mm, zone] = m;
269
+ const offset = !zone || zone === 'Z'
270
+ ? 'UTC'
271
+ : `UTC${zone.slice(0, 3)}:${zone.length === 6 ? zone.slice(4) : zone.slice(3)}`;
272
+ return `${hh}:${mm} ${offset}, ${Number(d)} ${MONTHS[Number(mo) - 1] ?? mo}`;
273
+ };
274
+ /** When a payment page is paid by: the hotel's own clock where the backend gave it, else the moment with its offset. */
275
+ export const payByWords = (p) => p.payByLocal ?? clockWords(p.payBy);
276
+ /**
277
+ * The refusals `otaless/booking.ts` raises with a `code` (docs §13.5): each is
278
+ * answered as `view: 'error'` with the code itself, never as the generic
279
+ * 'not-bookable' / 'uncertain' - the card says each in its own words, and its
280
+ * `detail` is already the guest's.
281
+ */
282
+ const BOOKING_REFUSALS = new Set([
283
+ 'sign-in',
284
+ 'link-redo',
285
+ 'signed-out',
286
+ 'session-expired',
287
+ 'guest',
288
+ 'terms-gone',
289
+ 'unconfirmed',
290
+ 'not-cancelled',
291
+ 'not-paid',
292
+ 'not-refunded',
293
+ 'refund-preview',
294
+ 'refunded',
295
+ 'cancel-unknown',
296
+ 'addons-off',
297
+ 'unknown-addon',
298
+ 'addon',
299
+ 'price-changed',
300
+ ]);
301
+ /** The three that mean "sign in at this group": they carry the groups (`groups`, provider codes). */
302
+ const SIGN_IN_REFUSALS = new Set(['sign-in', 'link-redo', 'signed-out', 'session-expired']);
303
+ /**
304
+ * The answer to a booking refusal, or undefined when `err` is not one.
305
+ *
306
+ * ⚠️ `groups` IS READ DEFENSIVELY: a refusal that carries none says nothing of
307
+ * where to sign in. Per group: the account's link tool with that group's code
308
+ * where the deployment has one (`ToolDeps.groupSignIn`), else its sign-in tool.
309
+ */
310
+ export const refusalAnswer = (deps, key, err) => {
311
+ const raw = err;
312
+ if (!(raw instanceof Error) || typeof raw.code !== 'string')
313
+ return undefined;
314
+ // 0.79.1: a `sign-in` the group's 409 asked for (`redo`) is said as its own refusal.
315
+ const e = raw.code === 'sign-in' && raw.redo === true
316
+ ? Object.assign(new Error(raw.message), { code: 'link-redo', groups: raw.groups })
317
+ : { ...raw, message: raw.message, code: raw.code };
318
+ if (!BOOKING_REFUSALS.has(e.code))
319
+ return undefined;
320
+ const codes = SIGN_IN_REFUSALS.has(e.code) && Array.isArray(e.groups)
321
+ ? [...new Set(e.groups.filter((g) => typeof g === 'string' && !!g))]
322
+ : [];
323
+ const suppliers = deps.backend.suppliers?.() ?? [];
324
+ const groups = codes.map((code) => {
325
+ const s = suppliers.find((x) => x.id === code);
326
+ return { code, name: s?.name ?? code, ...(s?.names ? { names: s.names } : {}) };
327
+ });
328
+ const how = deps.groupSignIn;
329
+ // ⚠️ A GROUP NAMED IS ONE TO LINK, AS THE BACKEND SAID (0.74.0, robin 11-17): no group is asked
330
+ // to be linked before a booking any more - a refusal with none is the account's own sign-in.
331
+ const signIn = (groups.length
332
+ ? groups.map((g) => how?.linkTool
333
+ ? `To link the guest's ${g.name} membership: ${how.linkTool} with group "${g.code}" gives the guest a one-time page for it.`
334
+ : how?.signInTool
335
+ ? `${how.signInTool} gives the guest a one-time page to sign in to their ${deps.vocab.brand} account.`
336
+ : '')
337
+ : SIGN_IN_REFUSALS.has(e.code) && how?.signInTool
338
+ ? [
339
+ `${how.signInTool} gives the guest a one-time page to sign in to their ${deps.vocab.brand} account.`,
340
+ ]
341
+ : []).filter((x, i, all) => !!x && all.indexOf(x) === i);
342
+ // The guest's words for the refusals whose own message does not say enough
343
+ // (总线程's review of 0.63.0): a cancellation the group did not confirm may
344
+ // still stand - never "cancelled".
345
+ const more = e.code === 'cancel-unknown'
346
+ ? 'The group has not confirmed the cancellation, so the booking may still stand - nothing here has changed. Tell the guest to look at their bookings again in a few minutes.'
347
+ : e.code === 'refund-preview'
348
+ ? `Nothing was refunded. Show the guest the refund preview first (${deps.tools.refundBooking} without \`confirmed\`), then ask again once they say yes.`
349
+ : e.code === 'addons-off'
350
+ ? 'Add-ons are not offered here; tell the guest nothing can be added to the booking.'
351
+ : '';
352
+ return {
353
+ structured: {
354
+ view: 'error',
355
+ ...common(deps, key),
356
+ error: e.code,
357
+ detail: more ? `${e.message} ${more}` : e.message,
358
+ ...(groups.length ? { groups } : {}),
359
+ },
360
+ text: [e.message, more, ...signIn].filter(Boolean).join(' '),
361
+ };
362
+ };
363
+ /** A booking refusal as its answer (`view: 'error'`, its code), or undefined when `err` is not one. */
364
+ export const bookingRefusal = refusalAnswer;
365
+ //# sourceMappingURL=payment-words.js.map