@curless/hotel-storefront 0.84.8 → 0.86.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 (229) hide show
  1. package/dist/config.d.ts +35 -2
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js.map +1 -1
  4. package/dist/huazhu/ari-sync.d.ts +93 -6
  5. package/dist/huazhu/ari-sync.d.ts.map +1 -1
  6. package/dist/huazhu/ari-sync.js +303 -28
  7. package/dist/huazhu/ari-sync.js.map +1 -1
  8. package/dist/huazhu/backend.d.ts +9 -0
  9. package/dist/huazhu/backend.d.ts.map +1 -1
  10. package/dist/huazhu/backend.js +62 -22
  11. package/dist/huazhu/backend.js.map +1 -1
  12. package/dist/huazhu/catalog.d.ts +58 -1
  13. package/dist/huazhu/catalog.d.ts.map +1 -1
  14. package/dist/huazhu/catalog.js +318 -15
  15. package/dist/huazhu/catalog.js.map +1 -1
  16. package/dist/huazhu/live-asks.d.ts +63 -0
  17. package/dist/huazhu/live-asks.d.ts.map +1 -0
  18. package/dist/huazhu/live-asks.js +127 -0
  19. package/dist/huazhu/live-asks.js.map +1 -0
  20. package/dist/huazhu/make.d.ts.map +1 -1
  21. package/dist/huazhu/make.js +50 -4
  22. package/dist/huazhu/make.js.map +1 -1
  23. package/dist/server.d.ts +1 -1
  24. package/dist/server.js +1 -1
  25. package/dist/tools/accept-terms.d.ts +4 -0
  26. package/dist/tools/accept-terms.d.ts.map +1 -0
  27. package/dist/tools/accept-terms.js +26 -0
  28. package/dist/tools/accept-terms.js.map +1 -0
  29. package/dist/tools/add-booking-addon.d.ts +4 -0
  30. package/dist/tools/add-booking-addon.d.ts.map +1 -0
  31. package/dist/tools/add-booking-addon.js +44 -0
  32. package/dist/tools/add-booking-addon.js.map +1 -0
  33. package/dist/tools/add-to-trip.d.ts +4 -0
  34. package/dist/tools/add-to-trip.d.ts.map +1 -0
  35. package/dist/tools/add-to-trip.js +49 -0
  36. package/dist/tools/add-to-trip.js.map +1 -0
  37. package/dist/tools/all-tools.d.ts +1342 -0
  38. package/dist/tools/all-tools.d.ts.map +1 -0
  39. package/dist/tools/all-tools.js +954 -0
  40. package/dist/tools/all-tools.js.map +1 -0
  41. package/dist/tools/answer.d.ts +3 -0
  42. package/dist/tools/answer.d.ts.map +1 -0
  43. package/dist/tools/answer.js +104 -0
  44. package/dist/tools/answer.js.map +1 -0
  45. package/dist/tools/args.d.ts +149 -0
  46. package/dist/tools/args.d.ts.map +1 -0
  47. package/dist/tools/args.js +176 -0
  48. package/dist/tools/args.js.map +1 -0
  49. package/dist/tools/base-output-schemas.d.ts +3 -0
  50. package/dist/tools/base-output-schemas.d.ts.map +1 -0
  51. package/dist/tools/base-output-schemas.js +380 -0
  52. package/dist/tools/base-output-schemas.js.map +1 -0
  53. package/dist/tools/book-picked.d.ts +4 -0
  54. package/dist/tools/book-picked.d.ts.map +1 -0
  55. package/dist/tools/book-picked.js +14 -0
  56. package/dist/tools/book-picked.js.map +1 -0
  57. package/dist/tools/booking-answer.d.ts +24 -0
  58. package/dist/tools/booking-answer.d.ts.map +1 -0
  59. package/dist/tools/booking-answer.js +485 -0
  60. package/dist/tools/booking-answer.js.map +1 -0
  61. package/dist/tools/buy-shop-item.d.ts +4 -0
  62. package/dist/tools/buy-shop-item.d.ts.map +1 -0
  63. package/dist/tools/buy-shop-item.js +45 -0
  64. package/dist/tools/buy-shop-item.js.map +1 -0
  65. package/dist/tools/call.d.ts +11 -0
  66. package/dist/tools/call.d.ts.map +1 -0
  67. package/dist/tools/call.js +2 -0
  68. package/dist/tools/call.js.map +1 -0
  69. package/dist/tools/cancel-facts.d.ts +281 -0
  70. package/dist/tools/cancel-facts.d.ts.map +1 -0
  71. package/dist/tools/cancel-facts.js +309 -0
  72. package/dist/tools/cancel-facts.js.map +1 -0
  73. package/dist/tools/cancel.d.ts +4 -0
  74. package/dist/tools/cancel.d.ts.map +1 -0
  75. package/dist/tools/cancel.js +364 -0
  76. package/dist/tools/cancel.js.map +1 -0
  77. package/dist/tools/card-addons.d.ts +4 -0
  78. package/dist/tools/card-addons.d.ts.map +1 -0
  79. package/dist/tools/card-addons.js +76 -0
  80. package/dist/tools/card-addons.js.map +1 -0
  81. package/dist/tools/change-booking.d.ts +4 -0
  82. package/dist/tools/change-booking.d.ts.map +1 -0
  83. package/dist/tools/change-booking.js +145 -0
  84. package/dist/tools/change-booking.js.map +1 -0
  85. package/dist/tools/clear-trip.d.ts +4 -0
  86. package/dist/tools/clear-trip.d.ts.map +1 -0
  87. package/dist/tools/clear-trip.js +10 -0
  88. package/dist/tools/clear-trip.js.map +1 -0
  89. package/dist/tools/compare.d.ts +4 -0
  90. package/dist/tools/compare.d.ts.map +1 -0
  91. package/dist/tools/compare.js +114 -0
  92. package/dist/tools/compare.js.map +1 -0
  93. package/dist/tools/current-trip.d.ts +70 -0
  94. package/dist/tools/current-trip.d.ts.map +1 -0
  95. package/dist/tools/current-trip.js +261 -0
  96. package/dist/tools/current-trip.js.map +1 -0
  97. package/dist/tools/deps.d.ts +229 -0
  98. package/dist/tools/deps.d.ts.map +1 -0
  99. package/dist/tools/deps.js +2 -0
  100. package/dist/tools/deps.js.map +1 -0
  101. package/dist/tools/follow-ups.d.ts +120 -0
  102. package/dist/tools/follow-ups.d.ts.map +1 -0
  103. package/dist/tools/follow-ups.js +369 -0
  104. package/dist/tools/follow-ups.js.map +1 -0
  105. package/dist/tools/forget-preferences.d.ts +4 -0
  106. package/dist/tools/forget-preferences.d.ts.map +1 -0
  107. package/dist/tools/forget-preferences.js +24 -0
  108. package/dist/tools/forget-preferences.js.map +1 -0
  109. package/dist/tools/get-hotel.d.ts +4 -0
  110. package/dist/tools/get-hotel.d.ts.map +1 -0
  111. package/dist/tools/get-hotel.js +324 -0
  112. package/dist/tools/get-hotel.js.map +1 -0
  113. package/dist/tools/hotel-choices.d.ts +132 -0
  114. package/dist/tools/hotel-choices.d.ts.map +1 -0
  115. package/dist/tools/hotel-choices.js +558 -0
  116. package/dist/tools/hotel-choices.js.map +1 -0
  117. package/dist/tools/itinerary.d.ts +4 -0
  118. package/dist/tools/itinerary.d.ts.map +1 -0
  119. package/dist/tools/itinerary.js +148 -0
  120. package/dist/tools/itinerary.js.map +1 -0
  121. package/dist/tools/list-booking-addons.d.ts +4 -0
  122. package/dist/tools/list-booking-addons.d.ts.map +1 -0
  123. package/dist/tools/list-booking-addons.js +21 -0
  124. package/dist/tools/list-booking-addons.js.map +1 -0
  125. package/dist/tools/list-bookings.d.ts +4 -0
  126. package/dist/tools/list-bookings.d.ts.map +1 -0
  127. package/dist/tools/list-bookings.js +119 -0
  128. package/dist/tools/list-bookings.js.map +1 -0
  129. package/dist/tools/list-extras.d.ts +4 -0
  130. package/dist/tools/list-extras.d.ts.map +1 -0
  131. package/dist/tools/list-extras.js +90 -0
  132. package/dist/tools/list-extras.js.map +1 -0
  133. package/dist/tools/list-hotels.d.ts +4 -0
  134. package/dist/tools/list-hotels.d.ts.map +1 -0
  135. package/dist/tools/list-hotels.js +891 -0
  136. package/dist/tools/list-hotels.js.map +1 -0
  137. package/dist/tools/list-shop-items.d.ts +4 -0
  138. package/dist/tools/list-shop-items.d.ts.map +1 -0
  139. package/dist/tools/list-shop-items.js +34 -0
  140. package/dist/tools/list-shop-items.js.map +1 -0
  141. package/dist/tools/list-shop-orders.d.ts +4 -0
  142. package/dist/tools/list-shop-orders.d.ts.map +1 -0
  143. package/dist/tools/list-shop-orders.js +22 -0
  144. package/dist/tools/list-shop-orders.js.map +1 -0
  145. package/dist/tools/look-up.d.ts +4 -0
  146. package/dist/tools/look-up.d.ts.map +1 -0
  147. package/dist/tools/look-up.js +170 -0
  148. package/dist/tools/look-up.js.map +1 -0
  149. package/dist/tools/output-schemas.d.ts +645 -0
  150. package/dist/tools/output-schemas.d.ts.map +1 -0
  151. package/dist/tools/output-schemas.js +503 -0
  152. package/dist/tools/output-schemas.js.map +1 -0
  153. package/dist/tools/paid-lines.d.ts +718 -0
  154. package/dist/tools/paid-lines.d.ts.map +1 -0
  155. package/dist/tools/paid-lines.js +359 -0
  156. package/dist/tools/paid-lines.js.map +1 -0
  157. package/dist/tools/pay-with-union-pay.d.ts +4 -0
  158. package/dist/tools/pay-with-union-pay.d.ts.map +1 -0
  159. package/dist/tools/pay-with-union-pay.js +112 -0
  160. package/dist/tools/pay-with-union-pay.js.map +1 -0
  161. package/dist/tools/payment-words.d.ts +269 -0
  162. package/dist/tools/payment-words.d.ts.map +1 -0
  163. package/dist/tools/payment-words.js +365 -0
  164. package/dist/tools/payment-words.js.map +1 -0
  165. package/dist/tools/pick-room.d.ts +4 -0
  166. package/dist/tools/pick-room.d.ts.map +1 -0
  167. package/dist/tools/pick-room.js +23 -0
  168. package/dist/tools/pick-room.js.map +1 -0
  169. package/dist/tools/policies.d.ts +4 -0
  170. package/dist/tools/policies.d.ts.map +1 -0
  171. package/dist/tools/policies.js +74 -0
  172. package/dist/tools/policies.js.map +1 -0
  173. package/dist/tools/pricing.d.ts +55 -0
  174. package/dist/tools/pricing.d.ts.map +1 -0
  175. package/dist/tools/pricing.js +260 -0
  176. package/dist/tools/pricing.js.map +1 -0
  177. package/dist/tools/put-room-line.d.ts +12 -0
  178. package/dist/tools/put-room-line.d.ts.map +1 -0
  179. package/dist/tools/put-room-line.js +314 -0
  180. package/dist/tools/put-room-line.js.map +1 -0
  181. package/dist/tools/quote-card.d.ts +234 -0
  182. package/dist/tools/quote-card.d.ts.map +1 -0
  183. package/dist/tools/quote-card.js +375 -0
  184. package/dist/tools/quote-card.js.map +1 -0
  185. package/dist/tools/refund-booking.d.ts +4 -0
  186. package/dist/tools/refund-booking.d.ts.map +1 -0
  187. package/dist/tools/refund-booking.js +112 -0
  188. package/dist/tools/refund-booking.js.map +1 -0
  189. package/dist/tools/request-booking.d.ts +4 -0
  190. package/dist/tools/request-booking.d.ts.map +1 -0
  191. package/dist/tools/request-booking.js +5 -0
  192. package/dist/tools/request-booking.js.map +1 -0
  193. package/dist/tools/request-words.d.ts +238 -0
  194. package/dist/tools/request-words.d.ts.map +1 -0
  195. package/dist/tools/request-words.js +487 -0
  196. package/dist/tools/request-words.js.map +1 -0
  197. package/dist/tools/room-choices.d.ts +64 -0
  198. package/dist/tools/room-choices.d.ts.map +1 -0
  199. package/dist/tools/room-choices.js +348 -0
  200. package/dist/tools/room-choices.js.map +1 -0
  201. package/dist/tools/session-notes.d.ts +164 -0
  202. package/dist/tools/session-notes.d.ts.map +1 -0
  203. package/dist/tools/session-notes.js +412 -0
  204. package/dist/tools/session-notes.js.map +1 -0
  205. package/dist/tools/sign-in.d.ts +4 -0
  206. package/dist/tools/sign-in.d.ts.map +1 -0
  207. package/dist/tools/sign-in.js +72 -0
  208. package/dist/tools/sign-in.js.map +1 -0
  209. package/dist/tools/sign-out.d.ts +4 -0
  210. package/dist/tools/sign-out.d.ts.map +1 -0
  211. package/dist/tools/sign-out.js +13 -0
  212. package/dist/tools/sign-out.js.map +1 -0
  213. package/dist/tools/terms-answer.d.ts +114 -0
  214. package/dist/tools/terms-answer.d.ts.map +1 -0
  215. package/dist/tools/terms-answer.js +475 -0
  216. package/dist/tools/terms-answer.js.map +1 -0
  217. package/dist/tools/tool-set.d.ts +1474 -0
  218. package/dist/tools/tool-set.d.ts.map +1 -0
  219. package/dist/tools/tool-set.js +497 -0
  220. package/dist/tools/tool-set.js.map +1 -0
  221. package/dist/tools/view-trip.d.ts +4 -0
  222. package/dist/tools/view-trip.d.ts.map +1 -0
  223. package/dist/tools/view-trip.js +7 -0
  224. package/dist/tools/view-trip.js.map +1 -0
  225. package/dist/tools.d.ts +13 -2089
  226. package/dist/tools.d.ts.map +1 -1
  227. package/dist/tools.js +11 -10685
  228. package/dist/tools.js.map +1 -1
  229. package/package.json +1 -1
@@ -0,0 +1,145 @@
1
+ import { nights as nightsBetween } from '../dates.js';
2
+ import { formatMoney, money } from '../money.js';
3
+ import { str } from './args.js';
4
+ import { bookingForCard } from './cancel-facts.js';
5
+ import { common, demoBookingNote } from './paid-lines.js';
6
+ import { changeSentence } from './request-words.js';
7
+ import { TOO_MANY_TRIES, guarded, guestWords, identity, previewsOf, remember, } from './session-notes.js';
8
+ import { noBookingLike } from './terms-answer.js';
9
+ export const answerChangeBooking = async ({ deps, name, args, ctx, t, key, }) => {
10
+ const ref = str(args.booking);
11
+ const who = identity(deps, ctx, key, args);
12
+ const change = {
13
+ ...(str(args.checkIn) ? { checkIn: str(args.checkIn) } : {}),
14
+ ...(str(args.checkOut) ? { checkOut: str(args.checkOut) } : {}),
15
+ ...(typeof args.rooms === 'number' ? { rooms: args.rooms } : {}),
16
+ ...(str(args.room) ? { room: str(args.room) } : {}),
17
+ ...(str(args.extra) ? { extra: str(args.extra) } : {}),
18
+ ...(typeof args.quantity === 'number' ? { quantity: args.quantity } : {}),
19
+ };
20
+ const { found: preview, tooMany } = await guarded(deps, ctx, who, ref, () => deps.backend.previewChange(ref, change, who));
21
+ if (!preview) {
22
+ return {
23
+ structured: {
24
+ view: 'booking-not-found',
25
+ ...common(deps, key),
26
+ query: ref,
27
+ ...(tooMany ? { tooMany: true } : {}),
28
+ },
29
+ text: tooMany ? TOO_MANY_TRIES : noBookingLike(deps),
30
+ };
31
+ }
32
+ const stayOf = (x) => ({
33
+ checkIn: x.stay.checkIn,
34
+ checkOut: x.stay.checkOut,
35
+ nights: nightsBetween(x.stay.checkIn, x.stay.checkOut),
36
+ rooms: x.rooms,
37
+ roomName: x.roomName,
38
+ ...(x.roomNames ? { roomNames: x.roomNames } : {}),
39
+ total: formatMoney(x.total),
40
+ });
41
+ // Money back reads differently from money owed, and the card must not have
42
+ // to work that out from a minus sign.
43
+ const refundDue = (preview.difference?.minor ?? 0) < 0;
44
+ const diff = preview.difference
45
+ ? formatMoney(money(Math.abs(preview.difference.minor), preview.difference.currency))
46
+ : undefined;
47
+ const asPreview = {
48
+ structured: {
49
+ view: 'change-preview',
50
+ ...common(deps, key),
51
+ booking: { id: preview.bookingId, confirmationCode: preview.confirmationCode },
52
+ hotelName: preview.hotelName,
53
+ ...(preview.hotelNames ? { hotelNames: preview.hotelNames } : {}),
54
+ from: stayOf(preview.from),
55
+ ...(preview.to ? { to: stayOf(preview.to) } : {}),
56
+ ...(diff ? { difference: diff, refundDue } : {}),
57
+ changeable: preview.changeable,
58
+ ...(preview.roomsLeft === undefined ? {} : { roomsLeft: preview.roomsLeft }),
59
+ ...(preview.addOn ? { addOn: preview.addOn } : {}),
60
+ rule: preview.rule,
61
+ toolToConfirm: t.changeBooking,
62
+ },
63
+ text: preview.changeable
64
+ ? [
65
+ changeSentence(preview),
66
+ diff && preview.difference?.minor !== 0
67
+ ? refundDue
68
+ ? `That is ${diff} less than it holds now.`
69
+ : `That is ${diff} more than it holds now.`
70
+ : 'The total is unchanged.',
71
+ preview.rule,
72
+ `Say the word and it moves (${t.changeBooking} with \`confirmed\`).`,
73
+ demoBookingNote(deps, preview.supplier),
74
+ ]
75
+ .filter(Boolean)
76
+ .join(' ')
77
+ : preview.rule,
78
+ };
79
+ // ⚠️ THE PREVIEW IS NOT ADVISORY, for the same reason the cancellation's is
80
+ // not: a change re-prices the stay, and a guest who never saw the new total
81
+ // finds it at the desk. And it confirms what was SHOWN - see
82
+ // `shownPreviews`.
83
+ // Keyed by what the change COMES TO, not how it was asked: the card sends
84
+ // its confirmation from the preview's own nights and rooms, which need not
85
+ // be the words the preview was asked in.
86
+ const shownKey = [
87
+ key,
88
+ 'change',
89
+ preview.bookingId,
90
+ preview.to?.stay.checkIn,
91
+ preview.to?.stay.checkOut,
92
+ preview.to?.rooms,
93
+ preview.to?.roomName,
94
+ preview.addOn ? `${preview.addOn.id}:${preview.addOn.to}` : '',
95
+ ].join('|');
96
+ const wasShown = previewsOf(deps).get(shownKey);
97
+ const newTotal = preview.to?.total.minor;
98
+ if (newTotal !== undefined)
99
+ remember(deps, shownKey, newTotal);
100
+ if (name === t.previewChange || args.confirmed !== true)
101
+ return asPreview;
102
+ if (!preview.changeable)
103
+ return asPreview;
104
+ if (wasShown === undefined || wasShown !== newTotal) {
105
+ return {
106
+ ...asPreview,
107
+ text: [
108
+ wasShown === undefined
109
+ ? 'Nothing has changed yet: this is what the change would do, for the guest to see first.'
110
+ : `The price of this change has moved since it was shown - it is now ${preview.to ? formatMoney(preview.to.total) : '-'} in all. Nothing has changed yet.`,
111
+ asPreview.text,
112
+ ].join(' '),
113
+ };
114
+ }
115
+ try {
116
+ const changed = await deps.backend.changeBooking(ref, change, who);
117
+ if (!changed)
118
+ return asPreview;
119
+ return {
120
+ structured: {
121
+ view: 'changed',
122
+ ...common(deps, key),
123
+ booking: bookingForCard(changed),
124
+ hotelName: preview.hotelName,
125
+ from: stayOf(preview.from),
126
+ ...(preview.to ? { to: stayOf(preview.to) } : {}),
127
+ ...(diff ? { difference: diff, refundDue } : {}),
128
+ ...(preview.addOn ? { addOn: preview.addOn } : {}),
129
+ changeable: false,
130
+ rule: preview.rule,
131
+ },
132
+ text: [
133
+ `${changed.confirmationCode} now holds ${changed.stay.checkIn} to ${changed.stay.checkOut}, ${formatMoney(changed.quote.total)} all in.`,
134
+ 'The confirmation code has not changed. **Nothing has been charged.**',
135
+ demoBookingNote(deps, changed.supplier),
136
+ ]
137
+ .filter(Boolean)
138
+ .join(' '),
139
+ };
140
+ }
141
+ catch (err) {
142
+ return { ...asPreview, text: guestWords(err) };
143
+ }
144
+ };
145
+ //# sourceMappingURL=change-booking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-booking.js","sourceRoot":"","sources":["../../src/tools/change-booking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,cAAc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AAM,CAAC,IAAI,EAAE,GAAG,CAAC;gBACpB,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC;gBAChC,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;gBAC1B,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChD,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClD,UAAU,EAAE,KAAK;gBACjB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB;YACD,IAAI,EAAE;gBACJ,GAAG,OAAO,CAAC,gBAAgB,cAAc,OAAO,CAAC,IAAI,CAAC,OAAO,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,KAAK,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU;gBACxI,sEAAsE;gBACtE,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;aACxC;iBACE,MAAM,CAAC,OAAO,CAAC;iBACf,IAAI,CAAC,GAAG,CAAC;SACb,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;IACjD,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ToolCall } from './call.js';
2
+ import type { ToolAnswer } from './deps.js';
3
+ export declare const answerClearTrip: ({ deps, key }: ToolCall) => Promise<ToolAnswer>;
4
+ //# sourceMappingURL=clear-trip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-trip.d.ts","sourceRoot":"","sources":["../../src/tools/clear-trip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,eAAO,MAAM,eAAe,GAAU,eAAe,QAAQ,KAAG,OAAO,CAAC,UAAU,CAOjF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { common } from './paid-lines.js';
2
+ export const answerClearTrip = async ({ deps, key }) => {
3
+ deps.trips.clear(key);
4
+ return {
5
+ // No `total` at all: an empty trip has none, and `null` broke the schema.
6
+ structured: { view: 'trip', ...common(deps, key), lines: [], count: 0 },
7
+ text: 'The trip is empty.',
8
+ };
9
+ };
10
+ //# sourceMappingURL=clear-trip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-trip.js","sourceRoot":"","sources":["../../src/tools/clear-trip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAY,EAAuB,EAAE;IACpF,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO;QACL,0EAA0E;QAC1E,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE;QACvE,IAAI,EAAE,oBAAoB;KAC3B,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ToolCall } from './call.js';
2
+ import type { ToolAnswer } from './deps.js';
3
+ export declare const answerCompare: ({ deps, args, ctx, key }: ToolCall) => Promise<ToolAnswer>;
4
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/tools/compare.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAO5C,eAAO,MAAM,aAAa,GAAU,0BAA0B,QAAQ,KAAG,OAAO,CAAC,UAAU,CA8G1F,CAAC"}
@@ -0,0 +1,114 @@
1
+ import { compareHotels } from '../present.js';
2
+ import { catalogue } from '../vocab.js';
3
+ import { asStay, str } from './args.js';
4
+ import { COMPARISON_NOT_DRAWN, fitsManyOf } from './follow-ups.js';
5
+ import { comparedInWords } from './hotel-choices.js';
6
+ import { common } from './paid-lines.js';
7
+ import { notBookableOf } from './request-words.js';
8
+ import { askLater, identity } from './session-notes.js';
9
+ export const answerCompare = async ({ deps, args, ctx, key }) => {
10
+ const asks = Array.isArray(args.entries) ? args.entries : [];
11
+ const comparison = await compareHotels(deps.backend, asks.map((e) => ({
12
+ hotel: str(e.hotel),
13
+ bestFor: typeof e.bestFor === 'string' ? e.bestFor : undefined,
14
+ pros: e.pros,
15
+ cons: e.cons,
16
+ })), {
17
+ stay: asStay(args),
18
+ recommended: str(args.recommended) || undefined,
19
+ title: str(args.title) || undefined,
20
+ // The member's rate, like the list and the hotel beside it: without
21
+ // it the comparison quoted HK$5,424 where both said HK$4,610.
22
+ who: identity(deps, ctx, key),
23
+ });
24
+ if (comparison.columns.length === 0) {
25
+ // A group that did not answer is not "not ours" (2026-11-03 review, C5):
26
+ // its hotels are said as left out for that.
27
+ const silent = comparison.dropped.filter((d) => d.code === 'supplier-timeout');
28
+ // A hotel with no room for the nights is one of ours too (`code` 'no-rooms'): left out, said as that.
29
+ const noRooms = comparison.dropped.filter((d) => d.code === 'no-rooms');
30
+ const unknown = comparison.dropped.filter((d) => !d.candidates?.length && d.code !== 'supplier-timeout' && d.code !== 'no-rooms');
31
+ const fitsMany = fitsManyOf(deps, comparison.dropped);
32
+ return {
33
+ structured: {
34
+ view: 'nothing-to-compare',
35
+ ...common(deps, key),
36
+ dropped: comparison.dropped,
37
+ },
38
+ // A name that fits several IS one of ours - only the rest are "none".
39
+ text: [
40
+ ...(unknown.length || (!fitsMany.length && !silent.length && !noRooms.length)
41
+ ? [
42
+ `None of those are ${catalogue(deps.vocab)}: ${unknown.map((d) => d.name).join(', ')}.`,
43
+ ]
44
+ : []),
45
+ ...fitsMany,
46
+ ...noRooms.map((d) => `Left out: ${d.name} — ${d.why}`),
47
+ ...silent.map((d) => `Left out: ${d.name} — ${d.why}`),
48
+ silent.length ? askLater(!ctx.noCards) : '',
49
+ ]
50
+ .filter(Boolean)
51
+ .join('\n'),
52
+ };
53
+ }
54
+ const stayWords = comparison.stay
55
+ ? ` for ${comparison.stay.checkIn} to ${comparison.stay.checkOut}`
56
+ : '';
57
+ const notBookable = notBookableOf(deps);
58
+ return {
59
+ structured: {
60
+ view: 'comparison',
61
+ ...common(deps, key),
62
+ ...comparison,
63
+ columns: comparison.columns.map((c) => ({
64
+ ...c,
65
+ hotel: { ...c.hotel, fromNightly: undefined },
66
+ })),
67
+ // In both, like the itinerary's: a host with no card may hand its
68
+ // model this rather than the text.
69
+ ...(ctx.noCards ? { notDrawn: COMPARISON_NOT_DRAWN } : {}),
70
+ ...(notBookable ? { notBookable } : {}),
71
+ },
72
+ text: [
73
+ notBookable,
74
+ // The card carries the table; the text carries only what the model
75
+ // could not see before it asked - what was dropped, and why.
76
+ //
77
+ // ⚠️ UNLESS THERE IS NO CARD (总线程, 2026-10-28): a client that shows
78
+ // none was answered "2 side by side" and nothing else, and its model
79
+ // could not say what either hotel cost. Then the table is said here,
80
+ // one line a hotel, from the same records the card's rows are read off.
81
+ //
82
+ // ⚠️ A COMPARISON OF ONE IS NOT "1 SIDE BY SIDE" (总线程 11-13): when the
83
+ // others were left out, say how many were asked for and that only one
84
+ // could be compared - the "Left out" lines below say why.
85
+ ...(ctx.noCards
86
+ ? [
87
+ comparison.columns.length === 1 && comparison.dropped.length > 0
88
+ ? `Only 1 of the ${comparison.columns.length + comparison.dropped.length} could be compared${stayWords}. ${COMPARISON_NOT_DRAWN}`
89
+ : `${comparison.columns.length} compared${stayWords}. ${COMPARISON_NOT_DRAWN}`,
90
+ ...comparison.columns.map(comparedInWords),
91
+ ]
92
+ : [
93
+ comparison.columns.length === 1 && comparison.dropped.length > 0
94
+ ? `Only 1 of the ${comparison.columns.length + comparison.dropped.length} could be compared${stayWords}.`
95
+ : `${comparison.columns.length} side by side${stayWords}.`,
96
+ ]),
97
+ // ⚠️ SAY IT IN THE TEXT TOO. The card carries the warning for whoever is
98
+ // looking at it; this line is for the model, which is about to describe
99
+ // the table in prose and would otherwise read "¥67,500" against
100
+ // "€1,060" as a price difference and say which one is cheaper.
101
+ comparison.currencies
102
+ ? `These are priced in different currencies (${comparison.currencies.join(', ')}) and nothing here converts them — do not call one cheaper than another.`
103
+ : '',
104
+ // ⚠️ THE GROUP'S TWO PRICE ANSWERS DISAGREE (总线程 11-13, `HotelDetail.priceNotes`).
105
+ ...(comparison.priceNotes ?? []),
106
+ ...comparison.dropped.map((d) => `Left out: ${d.name} — ${d.why}`),
107
+ ...fitsManyOf(deps, comparison.dropped),
108
+ comparison.dropped.some((d) => d.code === 'supplier-timeout') ? askLater(!ctx.noCards) : '',
109
+ ]
110
+ .filter(Boolean)
111
+ .join('\n'),
112
+ };
113
+ };
114
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/tools/compare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EAAE,oBA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CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;YAClE,GAAG,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC;YACvC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;SAC5F;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC;KACd,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,70 @@
1
+ import type { HotelFilters, HotelSearchResult, Identity } from '../types.js';
2
+ import type { ToolAnswer, ToolContext, ToolDeps } from './deps.js';
3
+ /**
4
+ * The lines in one slot of the trip store, priced - the trip itself, or (with
5
+ * `store`) the picked room's slot. `key` stays the conversation's trip key: it
6
+ * is the one `common` reads, so a header's trip count never counts a pick.
7
+ */
8
+ export declare const currentTrip: (deps: ToolDeps, key: string, who?: Identity, store?: string, coupon?: string, ctx?: ToolContext) => Promise<ToolAnswer>;
9
+ /** The filters a list call asked for, or undefined when it asked for none. */
10
+ export declare const filtersOf: (args: Record<string, unknown>) => HotelFilters | undefined;
11
+ /** The filters in words, for the one line the model reads. */
12
+ export declare const filterWords: (f: HotelFilters) => string;
13
+ /** What to say when the filters left nothing - one filter said plainly, several as "together". */
14
+ export declare const emptiedBy: (f: HotelFilters, before: number, nouns: string) => string;
15
+ /**
16
+ * The filter chips a list offers, each with what it would leave.
17
+ *
18
+ * ⚠️ ONLY WHAT NARROWS. A chip every hotel on the list passes - breakfast
19
+ * where every hotel has a breakfast rate, one brand where only one is here -
20
+ * changes nothing when pressed, and a panel of those is a panel of noise. One
21
+ * that is ON always shows, so it can be turned off again.
22
+ */
23
+ export declare const refineFor: (r: NonNullable<HotelSearchResult["refine"]>, on: HotelFilters | undefined, total: number,
24
+ /**
25
+ * A dated list. There a room term changes which room is PRICED even where
26
+ * every hotel keeps one - so free cancellation and breakfast always show.
27
+ */
28
+ dated?: boolean) => {
29
+ brands: {
30
+ on: boolean;
31
+ name: string;
32
+ count: number;
33
+ names?: import("../types.js").Names;
34
+ }[];
35
+ facilities: {
36
+ on: boolean;
37
+ key: string;
38
+ label: string;
39
+ count: number;
40
+ }[];
41
+ room: {
42
+ key: string;
43
+ label: string;
44
+ count: number;
45
+ on: boolean;
46
+ }[];
47
+ groups?: {
48
+ on: boolean;
49
+ id: string;
50
+ count: number;
51
+ }[] | undefined;
52
+ };
53
+ /**
54
+ * From how many cities a country is a list of cities to choose from rather
55
+ * than a list of hotels. China is forty; Malaysia's six hotels in three cities
56
+ * read better as hotels, grouped by city.
57
+ */
58
+ export declare const CITY_PICKER_MIN = 4;
59
+ /**
60
+ * Up to how many hotels a whole deployment is a list rather than places to
61
+ * choose from. Huazhu's production had two, in two cities, and "where to?"
62
+ * over two city chips and "browse all 2" had the model list them all again -
63
+ * two cards for one question (robin, 2026-10-30). Six is what the card shows
64
+ * whole at every width, with no "Next" (its inline page is five rows on a
65
+ * phone and lets two more in - see the card's `pageSize`): a place picker
66
+ * over that many saves no one a tap. A group of nine in four cities still
67
+ * chooses a city first.
68
+ */
69
+ export declare const HOME_LIST_MAX = 6;
70
+ //# sourceMappingURL=current-trip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-trip.d.ts","sourceRoot":"","sources":["../../src/tools/current-trip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAMnE;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,QAAQ,EACd,KAAK,MAAM,EACX,MAAM,QAAQ,EACd,QAAO,MAAY,EACnB,SAAS,MAAM,EACf,MAAM,WAAW,KAChB,OAAO,CAAC,UAAU,CAmJpB,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,YAAY,GAAG,SAexE,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,WAAW,GAAI,GAAG,YAAY,KAAG,MAY/B,CAAC;AAEhB,kGAAkG;AAClG,eAAO,MAAM,SAAS,GAAI,GAAG,YAAY,EAAE,QAAQ,MAAM,EAAE,OAAO,MAAM,KAAG,MAc1E,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GACpB,GAAG,WAAW,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,EAC3C,IAAI,YAAY,GAAG,SAAS,EAC5B,OAAO,MAAM;AACb;;;GAGG;AACH,eAAa;;;;;;;;;;;;;;;;;;;;;;;;CAuCd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC"}
@@ -0,0 +1,261 @@
1
+ import { FULL_CAPABILITIES } from '../backend.js';
2
+ import { FACILITIES } from '../facilities.js';
3
+ import { hotelName } from '../fence.js';
4
+ import { overlapsOf } from '../overlap.js';
5
+ import { shownOf, stampOf } from '../trip.js';
6
+ import { place, str } from './args.js';
7
+ import { common } from './paid-lines.js';
8
+ import { detailsAsked, needsRoomIn, noPrice, quoteParts, refreshMember } from './pricing.js';
9
+ import { quoteForCard, tripText } from './quote-card.js';
10
+ import { readOnlyWords } from './tool-set.js';
11
+ /**
12
+ * The lines in one slot of the trip store, priced - the trip itself, or (with
13
+ * `store`) the picked room's slot. `key` stays the conversation's trip key: it
14
+ * is the one `common` reads, so a header's trip count never counts a pick.
15
+ */
16
+ export const currentTrip = async (deps, key, who, store = key, coupon, ctx) => {
17
+ await refreshMember(deps, key);
18
+ const member = deps.members.read(key);
19
+ const lines = deps.trips.read(store);
20
+ const parts = await quoteParts(deps, lines, who && member ? { ...who, member } : who, coupon);
21
+ // ⚠️ WHAT THE GUEST IS SHOWN IS WHAT IS BOOKED - see `ShownQuote`. Every
22
+ // priced trip answer goes through here: add_to_trip, view_trip, and the
23
+ // card's own trip view.
24
+ if (lines.length)
25
+ deps.trips.show(store, shownOf(parts));
26
+ // What this answer drew, for the card's form to send back - see `stampOf`.
27
+ const stamp = lines.length ? { stamp: stampOf(lines, deps.trips.shown(store)) } : {};
28
+ const [only] = parts;
29
+ const orphans = needsRoomIn(deps.tools, lines, parts);
30
+ const needs = orphans.needsRoom.length ? { needsRoom: orphans.needsRoom } : {};
31
+ const groupOf = deps.backend.supplierOf
32
+ ? (id) => deps.backend.supplierOf?.(id)
33
+ : undefined;
34
+ // Two hotels on the same nights - said, never refused (overlap.ts). In
35
+ // both, in the same words.
36
+ const overlaps = overlapsOf(parts.flatMap((p) => p.lines.flatMap((l) => l.kind === 'room' && l.stay && !l.hourly
37
+ ? [
38
+ {
39
+ hotelId: l.hotelId,
40
+ name: hotelName(l.hotelName),
41
+ checkIn: l.stay.checkIn,
42
+ checkOut: l.stay.checkOut,
43
+ },
44
+ ]
45
+ : [])));
46
+ const overlapping = overlaps.length ? { overlaps } : {};
47
+ // ⚠️ WHAT COMES NEXT, IN WORDS (2026-11-02 audit, P2-4): the card has a
48
+ // Book button under the trip, and the words had nothing in its place.
49
+ //
50
+ // ⚠️ AND A PHONE NUMBER WHERE THE TRIP'S GROUP NEEDS ONE (the 0.52.0 gap): the
51
+ // card's form asks for it, and this sentence - the whole of the card for a
52
+ // client that draws none - said only "name and email", so the first booking
53
+ // came back "needs a phone number". Whose need it is is the trip's groups',
54
+ // as `requestBooking` judges it.
55
+ //
56
+ // ⚠️ AND SAID BACK ONCE BEFORE IT IS BOOKED (robin 11-06: 确认下单): the card
57
+ // shows the stay beside its Book button, and a guest who picked "the second
58
+ // one" or "next Friday for two nights" in words has not seen what that came
59
+ // to. One message - every stay, its nights by weekday, the room, the party,
60
+ // the total and what cancelling costs - and a yes, or what to change. A
61
+ // guest whose own words already named all of it, dates and all, has said it.
62
+ const nextStep = ctx?.noCards && parts.some((p) => p.lines.some((l) => l.kind === 'room'))
63
+ ? (deps.backend.capabilities ?? FULL_CAPABILITIES).readOnly
64
+ ? readOnlyWords(deps.vocab)
65
+ : `Nothing in the trip is booked yet. Before booking, say it back to the guest once, in one message: each ${deps.vocab.noun}, its nights with their weekdays, the room, the guests, the total and the cancellation terms, as this answer gives them - and ask them to reply "confirm" (确认) to book it, or to say what to change. In the same message, ${detailsAsked(deps, key, lines.filter((l) => l.kind === 'room'))} Call ${deps.tools.requestBooking} only after that yes - unless the guest's own message just now named all of it (the ${deps.vocab.noun}, the room, the nights as dates) and asked for it to be booked, which is the yes. A guest changing the room or the nights is not adding a stay: take the old line out (its rooms to 0).`
66
+ : '';
67
+ if (parts.length === 1 && only) {
68
+ return {
69
+ structured: {
70
+ view: 'trip',
71
+ ...common(deps, key),
72
+ ...(only.lines.length === 0 && only.dropped?.length
73
+ ? noPrice(quoteForCard(only, groupOf))
74
+ : quoteForCard(only, groupOf)),
75
+ ...needs,
76
+ ...stamp,
77
+ ...overlapping,
78
+ count: lines.length,
79
+ ...(nextStep ? { nextStep } : {}),
80
+ },
81
+ text: [tripText(only, ctx?.noCards), ...overlaps.map((o) => o.said), orphans.line, nextStep]
82
+ .filter(Boolean)
83
+ .join('\n'),
84
+ };
85
+ }
86
+ const shaped = parts.map((p) => quoteForCard(p, groupOf));
87
+ const bookable = parts.map((p) => p.lines.some((l) => l.kind === 'room'));
88
+ // Every line of every currency left out: no total to name, no zero to show. Each
89
+ // group says the currency its hotels are listed in; the words are what was left out.
90
+ if (parts.every((p) => p.lines.length === 0)) {
91
+ return {
92
+ structured: {
93
+ view: 'trip',
94
+ ...common(deps, key),
95
+ lines: [],
96
+ groups: shaped.map((p, i) => ({ ...noPrice(p), currency: parts[i]?.total.currency })),
97
+ currencies: [...new Set(parts.map((p) => p.total.currency))],
98
+ dropped: shaped.flatMap((p) => p.dropped ?? []),
99
+ ...stamp,
100
+ ...overlapping,
101
+ count: lines.length,
102
+ },
103
+ text: parts
104
+ .map((q) => tripText(q, ctx?.noCards))
105
+ .filter(Boolean)
106
+ .join('\n'),
107
+ };
108
+ }
109
+ return {
110
+ structured: {
111
+ view: 'trip',
112
+ ...common(deps, key),
113
+ lines: shaped.flatMap((p) => p.lines),
114
+ // One block per currency, each with its own taxes and total. `total` is
115
+ // the totals side by side for anything that reads one string - a list,
116
+ // never a sum.
117
+ //
118
+ // ⚠️ A CURRENCY OF ADD-ONS ALONE IS NOT PART OF WHAT IS BOOKED. A
119
+ // transfer at a Paris hotel with no Paris room made its own € block, and
120
+ // the trip's total read "HK$8,588 · €347" for a request that refuses
121
+ // the €347 (2026-09-28 audit). It is drawn, marked, and left out.
122
+ groups: shaped.map((p, i) => ({
123
+ ...p,
124
+ currency: parts[i]?.total.currency,
125
+ ...(bookable[i] ? {} : { goesWithAStay: true }),
126
+ })),
127
+ currencies: parts.map((p) => p.total.currency),
128
+ // Side by side with a dot, not a plus: "HK$8,588 + ¥152,550" reads as
129
+ // a sum nobody can do.
130
+ total: (shaped.filter((_, i) => bookable[i]).length
131
+ ? shaped.filter((_, i) => bookable[i])
132
+ : shaped)
133
+ .map((p) => p.total)
134
+ .join(' · '),
135
+ ...needs,
136
+ ...(shaped.some((p) => p.dropped) ? { dropped: shaped.flatMap((p) => p.dropped ?? []) } : {}),
137
+ ...stamp,
138
+ ...overlapping,
139
+ count: lines.length,
140
+ ...(nextStep ? { nextStep } : {}),
141
+ },
142
+ text: [
143
+ `This trip is in ${parts.length} currencies, priced separately and not converted - each hotel is booked and paid in its own.`,
144
+ ...parts.map((q) => tripText(q, ctx?.noCards)),
145
+ ...overlaps.map((o) => o.said),
146
+ orphans.line,
147
+ nextStep,
148
+ ]
149
+ .filter(Boolean)
150
+ .join('\n\n'),
151
+ };
152
+ };
153
+ /** The filters a list call asked for, or undefined when it asked for none. */
154
+ export const filtersOf = (args) => {
155
+ const keys = FACILITIES.map((x) => x.key);
156
+ const facilities = Array.isArray(args.facilities)
157
+ ? [...new Set(args.facilities.map(String).filter((k) => keys.includes(k)))]
158
+ : [];
159
+ const f = {
160
+ ...(str(args.brand) ? { brand: str(args.brand) } : {}),
161
+ ...(place(args.group) ? { supplier: place(args.group) } : {}),
162
+ ...(facilities.length ? { facilities } : {}),
163
+ ...(args.freeCancellation === true ? { freeCancellation: true } : {}),
164
+ ...(args.breakfast === true ? { breakfast: true } : {}),
165
+ ...(args.bed === 'king' || args.bed === 'twin' ? { bed: args.bed } : {}),
166
+ ...(args.hourly === true ? { hourly: true } : {}),
167
+ };
168
+ return Object.keys(f).length ? f : undefined;
169
+ };
170
+ /** The filters in words, for the one line the model reads. */
171
+ export const filterWords = (f) => [
172
+ f.brand,
173
+ ...(f.facilities ?? []).map((k) => FACILITIES.find((x) => x.key === k)?.label.toLowerCase()),
174
+ f.freeCancellation ? 'free cancellation' : '',
175
+ f.breakfast ? 'breakfast included' : '',
176
+ f.bed === 'king' ? 'king beds' : f.bed === 'twin' ? 'twin beds' : '',
177
+ f.hourly ? 'rooms by the hour today' : '',
178
+ ]
179
+ .filter(Boolean)
180
+ .join(', ');
181
+ /** What to say when the filters left nothing - one filter said plainly, several as "together". */
182
+ export const emptiedBy = (f, before, nouns) => {
183
+ const terms = (f.brand ? 1 : 0) +
184
+ (f.facilities?.length ?? 0) +
185
+ (f.freeCancellation ? 1 : 0) +
186
+ (f.breakfast ? 1 : 0) +
187
+ (f.bed ? 1 : 0) +
188
+ // By the hour is a term like the others: alone, it is said alone - not
189
+ // "has rooms by the hour today together" (huazhu, 2026-10-13).
190
+ (f.hourly ? 1 : 0);
191
+ if (terms === 1 && f.brand)
192
+ return `None of the ${before} ${nouns} here is ${f.brand}. Another brand, or none, lists them.`;
193
+ if (terms === 1)
194
+ return `None of the ${before} ${nouns} here has ${filterWords(f)}.`;
195
+ return `None of the ${before} ${nouns} here has ${filterWords(f)} together. Taking one of those off widens it.`;
196
+ };
197
+ /**
198
+ * The filter chips a list offers, each with what it would leave.
199
+ *
200
+ * ⚠️ ONLY WHAT NARROWS. A chip every hotel on the list passes - breakfast
201
+ * where every hotel has a breakfast rate, one brand where only one is here -
202
+ * changes nothing when pressed, and a panel of those is a panel of noise. One
203
+ * that is ON always shows, so it can be turned off again.
204
+ */
205
+ export const refineFor = (r, on, total,
206
+ /**
207
+ * A dated list. There a room term changes which room is PRICED even where
208
+ * every hotel keeps one - so free cancellation and breakfast always show.
209
+ */
210
+ dated = false) => {
211
+ const narrows = (count, active) => active || (count > 0 && count < total);
212
+ // ⚠️ A BRAND OR A GROUP IS ONE AT A TIME: with one picked, each other one is
213
+ // a switch to it, not a narrowing of this list - so it shows whenever it has
214
+ // any. Measured against the picked one's total it vanished: with Huazhu's 5
215
+ // picked, Shangri-La's 6 was "no narrower" and the guest could not get back
216
+ // (Marketplace, 2026-10-08); a brand bigger than the one picked, the same.
217
+ const switches = (count, active, picked) => picked ? active || count > 0 : narrows(count, active);
218
+ const brands = r.brands.filter((b) => switches(b.count, b.name === on?.brand, !!on?.brand));
219
+ // In a market: the groups, by id - the card names them from `market`.
220
+ const groups = (r.suppliers ?? []).filter((x) => switches(x.count, x.id === on?.supplier, !!on?.supplier));
221
+ return {
222
+ ...(r.suppliers
223
+ ? {
224
+ groups: groups.length > 1 || on?.supplier
225
+ ? groups.map((x) => ({ ...x, on: x.id === on?.supplier }))
226
+ : [],
227
+ }
228
+ : {}),
229
+ brands: brands.length > 1 || on?.brand ? brands.map((b) => ({ ...b, on: b.name === on?.brand })) : [],
230
+ facilities: r.facilities
231
+ .filter((x) => narrows(x.count, !!on?.facilities?.includes(x.key)))
232
+ .map((x) => ({ ...x, on: !!on?.facilities?.includes(x.key) })),
233
+ room: [
234
+ {
235
+ key: 'freeCancellation',
236
+ label: 'Free cancellation',
237
+ count: r.freeCancellation,
238
+ on: !!on?.freeCancellation,
239
+ },
240
+ { key: 'breakfast', label: 'Breakfast included', count: r.breakfast, on: !!on?.breakfast },
241
+ ].filter((x) => narrows(x.count, x.on) || (dated && x.count > 0)),
242
+ };
243
+ };
244
+ /**
245
+ * From how many cities a country is a list of cities to choose from rather
246
+ * than a list of hotels. China is forty; Malaysia's six hotels in three cities
247
+ * read better as hotels, grouped by city.
248
+ */
249
+ export const CITY_PICKER_MIN = 4;
250
+ /**
251
+ * Up to how many hotels a whole deployment is a list rather than places to
252
+ * choose from. Huazhu's production had two, in two cities, and "where to?"
253
+ * over two city chips and "browse all 2" had the model list them all again -
254
+ * two cards for one question (robin, 2026-10-30). Six is what the card shows
255
+ * whole at every width, with no "Next" (its inline page is five rows on a
256
+ * phone and lets two more in - see the card's `pageSize`): a place picker
257
+ * over that many saves no one a tap. A group of nine in four cities still
258
+ * chooses a city first.
259
+ */
260
+ export const HOME_LIST_MAX = 6;
261
+ //# sourceMappingURL=current-trip.js.map