@pisell/pisellos 0.0.569 → 0.10.2

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 (328) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +1 -1
  13. package/dist/modules/BaseModule.js +8 -10
  14. package/dist/modules/Cart/index.js +3 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  16. package/dist/modules/Cart/utils/cartResource.js +0 -2
  17. package/dist/modules/Cart/utils/changePrice.js +9 -16
  18. package/dist/modules/Date/index.js +5 -1
  19. package/dist/modules/Discount/index.d.ts +0 -1
  20. package/dist/modules/Discount/index.js +7 -22
  21. package/dist/modules/Discount/types.d.ts +0 -1
  22. package/dist/modules/OpenData/index.js +2 -0
  23. package/dist/modules/Order/index.js +70 -40
  24. package/dist/modules/Payment/index.js +162 -97
  25. package/dist/modules/Payment/types.d.ts +4 -8
  26. package/dist/modules/Payment/walletpass.d.ts +0 -2
  27. package/dist/modules/Payment/walletpass.js +5 -4
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -12
  30. package/dist/modules/ProductList/types.d.ts +0 -1
  31. package/dist/modules/Rules/index.js +126 -427
  32. package/dist/modules/SalesSummary/utils.js +1 -2
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  34. package/dist/modules/Schedule/index.js +1 -0
  35. package/dist/modules/Schedule/utils.js +1 -0
  36. package/dist/modules/Step/index.js +1 -0
  37. package/dist/modules/Summary/utils.js +22 -43
  38. package/dist/plugins/request.js +4 -1
  39. package/dist/plugins/window.js +6 -2
  40. package/dist/server/index.js +129 -97
  41. package/dist/server/modules/menu/index.js +41 -32
  42. package/dist/server/modules/order/index.js +4 -2
  43. package/dist/server/modules/products/index.js +42 -24
  44. package/dist/server/modules/quotation/index.js +38 -29
  45. package/dist/server/modules/resource/index.js +4 -3
  46. package/dist/server/modules/schedule/index.js +35 -27
  47. package/dist/server/utils/product.js +1 -0
  48. package/dist/solution/BaseSales/index.js +41 -38
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingByStep/index.js +60 -11
  51. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  52. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  53. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  54. package/dist/solution/BookingTicket/index.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.js +2 -0
  56. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
  57. package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
  58. package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
  59. package/dist/solution/BuyTickets/index.js +12 -9
  60. package/dist/solution/Checkout/index.js +252 -177
  61. package/dist/solution/Checkout/utils/index.js +16 -4
  62. package/dist/solution/RegisterAndLogin/index.js +76 -30
  63. package/dist/solution/ScanOrder/index.js +60 -50
  64. package/dist/solution/ShopDiscount/index.js +14 -15
  65. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  66. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  67. package/dist/solution/ShopDiscount/utils.js +0 -9
  68. package/dist/solution/VenueBooking/index.d.ts +3 -31
  69. package/dist/solution/VenueBooking/index.js +496 -651
  70. package/dist/solution/VenueBooking/types.d.ts +1 -3
  71. package/dist/solution/VenueBooking/types.js +0 -1
  72. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  73. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  74. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  75. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/utils/task.js +18 -15
  78. package/dist/utils/watch.js +1 -0
  79. package/lib/apis/picoding.js +0 -2
  80. package/lib/core/index.js +132 -130
  81. package/lib/effects/index.js +57 -46
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +50 -92
  84. package/lib/model/index.js +21 -14
  85. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  86. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  87. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  88. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  89. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  90. package/lib/model/strategy/adapter/index.js +64 -100
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  93. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  94. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  95. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  96. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  97. package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
  98. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  99. package/lib/model/strategy/adapter/promotion/index.js +49 -1
  100. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  101. package/lib/model/strategy/adapter/type.js +16 -4
  102. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  103. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  104. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  105. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  106. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  107. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  108. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  109. package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
  110. package/lib/model/strategy/engine.js +168 -270
  111. package/lib/model/strategy/index.js +34 -49
  112. package/lib/model/strategy/strategy-example.js +239 -243
  113. package/lib/model/strategy/type.js +40 -100
  114. package/lib/modules/Account/index.js +53 -39
  115. package/lib/modules/Account/types.js +33 -20
  116. package/lib/modules/AccountList/index.js +154 -116
  117. package/lib/modules/AccountList/types.js +31 -30
  118. package/lib/modules/AccountList/utils.js +30 -18
  119. package/lib/modules/BaseModule.d.ts +1 -1
  120. package/lib/modules/BaseModule.js +46 -25
  121. package/lib/modules/BookingContext/index.js +136 -158
  122. package/lib/modules/BookingContext/types.js +32 -46
  123. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
  124. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
  125. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
  126. package/lib/modules/BookingContext/utils/flexible.js +55 -38
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
  128. package/lib/modules/BookingContext/utils/index.js +41 -124
  129. package/lib/modules/BookingContext/utils/noResource.js +70 -58
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
  131. package/lib/modules/BookingContext/utils/productExtend.js +155 -202
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  133. package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
  134. package/lib/modules/BookingContext/utils/resources.js +167 -209
  135. package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
  136. package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
  137. package/lib/modules/Cart/index.js +124 -170
  138. package/lib/modules/Cart/types.js +51 -46
  139. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  140. package/lib/modules/Cart/utils/cartDate.js +61 -56
  141. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  142. package/lib/modules/Cart/utils/cartNote.js +32 -27
  143. package/lib/modules/Cart/utils/cartProduct.js +251 -321
  144. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  145. package/lib/modules/Cart/utils/cartResource.js +78 -72
  146. package/lib/modules/Cart/utils/changePrice.js +50 -28
  147. package/lib/modules/Cart/utils/index.js +48 -106
  148. package/lib/modules/Customer/constants.js +34 -13
  149. package/lib/modules/Customer/index.js +169 -232
  150. package/lib/modules/Customer/types.js +35 -38
  151. package/lib/modules/Date/index.js +115 -116
  152. package/lib/modules/Date/types.js +28 -16
  153. package/lib/modules/Date/utils.js +123 -174
  154. package/lib/modules/Discount/index.d.ts +0 -1
  155. package/lib/modules/Discount/index.js +128 -130
  156. package/lib/modules/Discount/types.d.ts +0 -1
  157. package/lib/modules/Discount/types.js +31 -9
  158. package/lib/modules/Guests/index.js +56 -30
  159. package/lib/modules/Guests/types.js +33 -23
  160. package/lib/modules/Holder/index.js +189 -209
  161. package/lib/modules/Holder/types.js +16 -4
  162. package/lib/modules/Holder/utils.js +49 -20
  163. package/lib/modules/OpenData/index.js +76 -69
  164. package/lib/modules/OpenData/types.js +16 -4
  165. package/lib/modules/OpenData/utils.js +78 -44
  166. package/lib/modules/Order/index.js +1909 -1572
  167. package/lib/modules/Order/types.js +35 -78
  168. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  169. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  171. package/lib/modules/Order/utils.js +634 -799
  172. package/lib/modules/Payment/cash.js +33 -20
  173. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  174. package/lib/modules/Payment/eftpos.js +30 -16
  175. package/lib/modules/Payment/index.js +378 -518
  176. package/lib/modules/Payment/mx51.js +0 -1
  177. package/lib/modules/Payment/types.d.ts +4 -8
  178. package/lib/modules/Payment/types.js +107 -216
  179. package/lib/modules/Payment/utils.js +48 -51
  180. package/lib/modules/Payment/walletpass.d.ts +0 -2
  181. package/lib/modules/Payment/walletpass.js +211 -226
  182. package/lib/modules/Product/index.js +46 -51
  183. package/lib/modules/Product/types.js +16 -4
  184. package/lib/modules/Product/utils.js +33 -32
  185. package/lib/modules/ProductList/index.d.ts +1 -1
  186. package/lib/modules/ProductList/index.js +117 -117
  187. package/lib/modules/ProductList/types.d.ts +0 -1
  188. package/lib/modules/ProductList/types.js +31 -9
  189. package/lib/modules/Quotation/index.js +100 -66
  190. package/lib/modules/Quotation/types.js +16 -4
  191. package/lib/modules/Resource/index.js +59 -27
  192. package/lib/modules/Resource/types.js +32 -22
  193. package/lib/modules/Resource/utils.js +38 -30
  194. package/lib/modules/ResourcePlanner/index.js +61 -60
  195. package/lib/modules/ResourcePlanner/planner.js +384 -346
  196. package/lib/modules/ResourcePlanner/types.js +16 -4
  197. package/lib/modules/Rules/index.js +903 -1475
  198. package/lib/modules/Rules/types.js +40 -17
  199. package/lib/modules/SalesSummary/index.js +90 -85
  200. package/lib/modules/SalesSummary/types.js +16 -4
  201. package/lib/modules/SalesSummary/utils.js +427 -351
  202. package/lib/modules/ScanOrderLogger/index.js +79 -59
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  205. package/lib/modules/ScanOrderLogger/types.js +16 -4
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  207. package/lib/modules/Schedule/index.js +114 -100
  208. package/lib/modules/Schedule/type.js +16 -4
  209. package/lib/modules/Schedule/types.js +16 -4
  210. package/lib/modules/Schedule/utils.js +291 -433
  211. package/lib/modules/Step/index.js +52 -40
  212. package/lib/modules/Step/tyeps.js +16 -4
  213. package/lib/modules/Summary/index.js +71 -66
  214. package/lib/modules/Summary/types.js +16 -4
  215. package/lib/modules/Summary/utils.js +418 -791
  216. package/lib/modules/SurchargeList/index.js +60 -46
  217. package/lib/modules/SurchargeList/types.js +16 -4
  218. package/lib/modules/index.js +63 -245
  219. package/lib/plugins/app.js +16 -4
  220. package/lib/plugins/index.js +25 -36
  221. package/lib/plugins/request.js +126 -137
  222. package/lib/plugins/shopStore.js +16 -4
  223. package/lib/plugins/user.js +16 -4
  224. package/lib/plugins/window.js +179 -171
  225. package/lib/server/index.js +2337 -2675
  226. package/lib/server/modules/floor-plan/index.js +123 -102
  227. package/lib/server/modules/floor-plan/types.js +30 -15
  228. package/lib/server/modules/index.js +68 -106
  229. package/lib/server/modules/menu/index.js +122 -146
  230. package/lib/server/modules/menu/types.js +31 -18
  231. package/lib/server/modules/order/index.js +642 -567
  232. package/lib/server/modules/order/types.js +32 -117
  233. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  234. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  235. package/lib/server/modules/payment/index.js +83 -59
  236. package/lib/server/modules/payment/types.js +16 -4
  237. package/lib/server/modules/products/index.js +459 -575
  238. package/lib/server/modules/products/types.js +34 -44
  239. package/lib/server/modules/quotation/index.js +172 -137
  240. package/lib/server/modules/quotation/types.js +31 -21
  241. package/lib/server/modules/resource/index.js +184 -213
  242. package/lib/server/modules/resource/types.js +33 -42
  243. package/lib/server/modules/schedule/index.js +123 -135
  244. package/lib/server/modules/schedule/types.js +21 -14
  245. package/lib/server/modules/schedule/utils.js +163 -334
  246. package/lib/server/types.js +16 -4
  247. package/lib/server/utils/index.js +23 -25
  248. package/lib/server/utils/product.js +139 -196
  249. package/lib/server/utils/schedule.js +41 -34
  250. package/lib/server/utils/small-ticket.js +456 -478
  251. package/lib/server/utils/time.js +49 -40
  252. package/lib/solution/BaseSales/index.js +1016 -850
  253. package/lib/solution/BaseSales/types.js +37 -41
  254. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  255. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  256. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  257. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  258. package/lib/solution/BaseSales/utils.js +140 -155
  259. package/lib/solution/BookingByStep/index.d.ts +1 -1
  260. package/lib/solution/BookingByStep/index.js +1340 -1530
  261. package/lib/solution/BookingByStep/types.js +99 -40
  262. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  263. package/lib/solution/BookingByStep/utils/products.js +52 -42
  264. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  265. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  266. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  267. package/lib/solution/BookingTicket/index.d.ts +1 -1
  268. package/lib/solution/BookingTicket/index.js +459 -543
  269. package/lib/solution/BookingTicket/types.js +77 -99
  270. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  271. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  272. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  273. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  274. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  275. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  276. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  277. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  278. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  279. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  280. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  281. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  282. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  283. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  284. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  285. package/lib/solution/BuyTickets/index.js +70 -67
  286. package/lib/solution/BuyTickets/types.js +38 -22
  287. package/lib/solution/Checkout/index.js +1158 -1451
  288. package/lib/solution/Checkout/types.js +61 -91
  289. package/lib/solution/Checkout/utils/index.js +156 -228
  290. package/lib/solution/PlaceOrder/index.js +0 -55
  291. package/lib/solution/RegisterAndLogin/config.js +460 -493
  292. package/lib/solution/RegisterAndLogin/index.js +630 -633
  293. package/lib/solution/RegisterAndLogin/types.js +76 -189
  294. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  295. package/lib/solution/Sales/index.js +320 -317
  296. package/lib/solution/Sales/types.js +33 -27
  297. package/lib/solution/ScanOrder/index.js +862 -831
  298. package/lib/solution/ScanOrder/types.js +34 -33
  299. package/lib/solution/ScanOrder/utils.js +371 -406
  300. package/lib/solution/ShopDiscount/index.js +233 -235
  301. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  302. package/lib/solution/ShopDiscount/types.js +37 -15
  303. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  304. package/lib/solution/ShopDiscount/utils.js +172 -309
  305. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  306. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  307. package/lib/solution/VenueBooking/index.d.ts +3 -31
  308. package/lib/solution/VenueBooking/index.js +916 -967
  309. package/lib/solution/VenueBooking/types.d.ts +1 -3
  310. package/lib/solution/VenueBooking/types.js +39 -20
  311. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  312. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  313. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  314. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  315. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  316. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  317. package/lib/solution/VenueBooking/utils.js +67 -130
  318. package/lib/solution/index.js +41 -124
  319. package/lib/store/createStore.js +29 -32
  320. package/lib/types/index.d.ts +1 -1
  321. package/lib/types/index.js +16 -4
  322. package/lib/utils/task.js +36 -36
  323. package/lib/utils/watch.js +47 -81
  324. package/package.json +2 -4
  325. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  326. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  327. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  328. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,242 +1,222 @@
1
- "use strict";
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
28
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
29
+ // src/modules/BookingContext/utils/cacheItemToBookingInput.ts
30
+ var cacheItemToBookingInput_exports = {};
31
+ __export(cacheItemToBookingInput_exports, {
32
+ cacheItemToBookingInput: () => cacheItemToBookingInput
5
33
  });
6
- exports.cacheItemToBookingInput = cacheItemToBookingInput;
7
- var _dayjs = _interopRequireDefault(require("dayjs"));
8
- var _serviceTimes = require("./serviceTimes");
9
- var _resources = require("./resources");
10
- var _flexible = require("./flexible");
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- /**
13
- * 把 info2 `cacheItem` 转换为 OS `addProductToOrder(product, booking)` 所需的 booking 入参。
14
- *
15
- * 协议严格对齐 `pisell_os/src/modules/Order/TEMP_ORDER_FIELDS_SUMMARY.md` 的 Bookings 章节:
16
- * - 顶层只允许出现:schedule_event_id / appointment_status / start_date / start_time / end_date /
17
- * end_time / select_date / duration / sub_type / like_status / number / resources / relation_forms /
18
- * holder / metadata / is_all / schedule_id / relation_id / form_id / relation_type / product_uid
19
- * - bookings[] 不允许出现 `_extend`
20
- * - bookings[].metadata 走白名单:unique_identification_number / collect_pax / capacity / holder_id / resource_select_type
21
- * - bookings[].resources[] 只接受协议白名单:form_id / relation_type / relation_id / capacity / like_status / metadata / children
22
- *
23
- * `product_uid` / `metadata.unique_identification_number` 不在这里生成:
24
- * OS `addProductToOrder` 内的 `createLinkedProductAndBooking` 会在最终一步统一改写,
25
- * 保证商品行 uid 与 booking root 唯一值始终对齐。
26
- *
27
- * 复杂 multi-day 展开(createBookingItemsByGroup / concatBookings)首版**不支持**,
28
- * 由 UI 在 `cart.confirmDetail` 之外通过辅助 API 处理。
29
- */
30
-
31
- /** custom / package 人数维度快照,与 info2 `_extend.capacity` / `metadata.capacity` 对齐。 */
32
-
33
- /** 将 UI `_extend.capacity[]` 规范化为 booking.metadata.capacity。 */
34
+ module.exports = __toCommonJS(cacheItemToBookingInput_exports);
35
+ var import_dayjs = __toESM(require("dayjs"));
36
+ var import_serviceTimes = require("./serviceTimes");
37
+ var import_resources = require("./resources");
38
+ var import_flexible = require("./flexible");
34
39
  function normalizeExtendCapacityForMetadata(capacity) {
35
- if (!Array.isArray(capacity) || capacity.length === 0) return undefined;
36
- const normalized = capacity.map(item => {
37
- if (!item || typeof item !== 'object') return null;
38
- if (item.id === undefined || item.id === null) return null;
40
+ if (!Array.isArray(capacity) || capacity.length === 0)
41
+ return void 0;
42
+ const normalized = capacity.map((item) => {
43
+ if (!item || typeof item !== "object")
44
+ return null;
45
+ if (item.id === void 0 || item.id === null)
46
+ return null;
39
47
  const row = {
40
48
  id: item.id,
41
49
  value: Number(item.value ?? 0)
42
50
  };
43
- if (item.name !== undefined) row.name = item.name;
51
+ if (item.name !== void 0)
52
+ row.name = item.name;
44
53
  return row;
45
- }).filter(item => item != null);
46
- return normalized.length > 0 ? normalized : undefined;
54
+ }).filter((item) => item != null);
55
+ return normalized.length > 0 ? normalized : void 0;
47
56
  }
48
57
  function safeFormat(value, fmt) {
49
- if (value === undefined || value === null) return undefined;
50
- const d = (0, _dayjs.default)(value);
51
- if (!d.isValid()) return undefined;
58
+ if (value === void 0 || value === null)
59
+ return void 0;
60
+ const d = (0, import_dayjs.default)(value);
61
+ if (!d.isValid())
62
+ return void 0;
52
63
  return d.format(fmt);
53
64
  }
54
-
55
- /** booking 协议 start_time / end_time:统一 HH:mm(不带秒)。 */
56
65
  function normalizeTimeString(value) {
57
- if (value === undefined || value === null) return undefined;
58
- if (typeof value === 'string') {
66
+ if (value === void 0 || value === null)
67
+ return void 0;
68
+ if (typeof value === "string") {
59
69
  const t = value.trim();
60
70
  const hhmmFromHhmmss = t.match(/^(\d{1,2}:\d{2}):\d{2}$/);
61
- if (hhmmFromHhmmss) return hhmmFromHhmmss[1];
62
- if (/^\d{1,2}:\d{2}$/.test(t)) return t;
71
+ if (hhmmFromHhmmss)
72
+ return hhmmFromHhmmss[1];
73
+ if (/^\d{1,2}:\d{2}$/.test(t))
74
+ return t;
63
75
  }
64
- const d = (0, _dayjs.default)(value);
65
- if (d.isValid()) return d.format('HH:mm');
66
- return undefined;
76
+ const d = (0, import_dayjs.default)(value);
77
+ if (d.isValid())
78
+ return d.format("HH:mm");
79
+ return void 0;
67
80
  }
68
81
  function resolveDurationMinutes(value) {
69
- if (typeof value === 'number' && Number.isFinite(value)) return value;
70
- if (typeof value !== 'string') return undefined;
71
- if (_flexible.flexibleObj.isFlexible(value)) return _flexible.flexibleObj.getValue(value);
82
+ if (typeof value === "number" && Number.isFinite(value))
83
+ return value;
84
+ if (typeof value !== "string")
85
+ return void 0;
86
+ if (import_flexible.flexibleObj.isFlexible(value))
87
+ return import_flexible.flexibleObj.getValue(value);
72
88
  const n = Number(value);
73
- return Number.isNaN(n) ? undefined : n;
89
+ return Number.isNaN(n) ? void 0 : n;
74
90
  }
75
-
76
- /**
77
- * 将组合资源子项收敛为 checkout resources 协议。
78
- *
79
- * resourcesOriginMap 中的子资源是 UI 运行态结构,通常只有 id / main_field / form_id,
80
- * 不保证携带后端必填的 relation_type。这里不能原样透传,否则会触发
81
- * `bookings.*.resources.*.children.*.relation_type` 校验错误。
82
- */
83
91
  function normalizeChildResource(child, parentFormId) {
84
92
  const item = {
85
- form_id: child?.form_id ?? parentFormId,
86
- relation_type: child?.relation_type || 'form',
87
- relation_id: child?.relation_id ?? child?.id,
88
- capacity: child?.capacity,
89
- like_status: child?.like_status || 'common'
93
+ form_id: (child == null ? void 0 : child.form_id) ?? parentFormId,
94
+ relation_type: (child == null ? void 0 : child.relation_type) || "form",
95
+ relation_id: (child == null ? void 0 : child.relation_id) ?? (child == null ? void 0 : child.id),
96
+ capacity: child == null ? void 0 : child.capacity,
97
+ like_status: (child == null ? void 0 : child.like_status) || "common"
90
98
  };
91
- if (child?.metadata !== undefined) {
92
- item.metadata = {
93
- ...child.metadata
94
- };
99
+ if ((child == null ? void 0 : child.metadata) !== void 0) {
100
+ item.metadata = { ...child.metadata };
95
101
  }
96
- if (Array.isArray(child?.children)) {
97
- item.children = child.children.map(nestedChild => normalizeChildResource(nestedChild, item.form_id));
102
+ if (Array.isArray(child == null ? void 0 : child.children)) {
103
+ item.children = child.children.map(
104
+ (nestedChild) => normalizeChildResource(nestedChild, item.form_id)
105
+ );
98
106
  }
99
107
  return item;
100
108
  }
101
-
102
- /**
103
- * cacheItem._extend.resource 形如 `{ [form_id]: [{ relation_id, form_id, like_status, metadata, children }] }`。
104
- * 这里扁平化为符合协议的 resources[] 数组;id=0 的「无资源」占位行**保留**(与 info2 业务等价;协议 `relation_id=0` 合法)。
105
- *
106
- * 顶层 resources[].capacity 与 info2 `checkResourcesFormat` 一致:Σ capacity[].value(不含 quantity)。
107
- */
108
109
  function flattenResources(cacheItem) {
109
- const resourceMap = cacheItem?._extend?.resource || {};
110
- const topLevelCapacity = (0, _resources.getSumCapacity)(cacheItem, false);
110
+ var _a;
111
+ const resourceMap = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
112
+ const topLevelCapacity = (0, import_resources.getSumCapacity)(cacheItem, false);
111
113
  const result = [];
112
- Object.values(resourceMap).forEach(arr => {
113
- if (!Array.isArray(arr)) return;
114
- arr.forEach(r => {
114
+ Object.values(resourceMap).forEach((arr) => {
115
+ if (!Array.isArray(arr))
116
+ return;
117
+ arr.forEach((r) => {
115
118
  const item = {
116
- form_id: r?.form_id,
117
- relation_type: r?.relation_type || 'form',
118
- relation_id: r?.relation_id,
119
+ form_id: r == null ? void 0 : r.form_id,
120
+ relation_type: (r == null ? void 0 : r.relation_type) || "form",
121
+ relation_id: r == null ? void 0 : r.relation_id,
119
122
  capacity: topLevelCapacity
120
123
  };
121
- item.like_status = r?.like_status || 'common';
122
- if (r?.metadata !== undefined) {
123
- // 协议允许 metadata 自由透传;为了与 info2 行为等价,把 form_name / resource_name / combined_resource 一并保留。
124
- item.metadata = {
125
- ...r.metadata
126
- };
124
+ item.like_status = (r == null ? void 0 : r.like_status) || "common";
125
+ if ((r == null ? void 0 : r.metadata) !== void 0) {
126
+ item.metadata = { ...r.metadata };
127
127
  }
128
- if (Array.isArray(r?.children)) {
129
- item.children = r.children.map(child => normalizeChildResource(child, item.form_id));
128
+ if (Array.isArray(r == null ? void 0 : r.children)) {
129
+ item.children = r.children.map(
130
+ (child) => normalizeChildResource(child, item.form_id)
131
+ );
130
132
  }
131
133
  result.push(item);
132
134
  });
133
135
  });
134
136
  return result;
135
137
  }
136
-
137
- /**
138
- * 从 cacheItem 中派生 metadata.resource_select_type;优先级:
139
- * 1. cacheItem._data.resources[0].select_type.type
140
- * 2. cacheItem.product_resource.resources[0].select_type.type
141
- * 3. 默认 undefined(由 OS / 后端兜底)。
142
- */
143
138
  function deriveResourceSelectType(cacheItem) {
144
- const localFirst = cacheItem?._data?.resources?.[0]?.select_type?.type;
145
- if (localFirst) return localFirst;
146
- const productFirst = cacheItem?.product_resource?.resources?.[0]?.select_type?.type;
147
- if (productFirst) return productFirst;
148
- return undefined;
139
+ var _a, _b, _c, _d, _e, _f, _g, _h;
140
+ const localFirst = (_d = (_c = (_b = (_a = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _a.resources) == null ? void 0 : _b[0]) == null ? void 0 : _c.select_type) == null ? void 0 : _d.type;
141
+ if (localFirst)
142
+ return localFirst;
143
+ const productFirst = (_h = (_g = (_f = (_e = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f[0]) == null ? void 0 : _g.select_type) == null ? void 0 : _h.type;
144
+ if (productFirst)
145
+ return productFirst;
146
+ return void 0;
149
147
  }
150
-
151
- /**
152
- * 主入口。
153
- */
154
148
  function cacheItemToBookingInput(cacheItem, options) {
155
- if (!cacheItem) return {
156
- metadata: {
157
- holder_id: null
158
- }
159
- };
149
+ var _a, _b;
150
+ if (!cacheItem)
151
+ return { metadata: { holder_id: null } };
160
152
  const ext = cacheItem._extend || {};
161
- const isMultiDay = (0, _serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === 'days';
162
- const isSession = (0, _serviceTimes.isSessionProduct)(cacheItem);
153
+ const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem) || ext.is_all === 1 || ext.sub_type === "days";
154
+ const isSession = (0, import_serviceTimes.isSessionProduct)(cacheItem);
163
155
  const result = {};
164
-
165
- // ──── 日期 / 时间 ───────────────────────────────────────────────
166
- if (isSession && ext?.other?.session) {
156
+ if (isSession && ((_a = ext == null ? void 0 : ext.other) == null ? void 0 : _a.session)) {
167
157
  const session = ext.other.session;
168
- // 优先 _extend 上已按顶部 date 对齐过的起止(catalog cartDetailValue.session → applySessionTimesToExtend)
169
- result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, 'YYYY-MM-DD');
170
- result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, 'HH:mm');
171
- result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, 'YYYY-MM-DD');
172
- result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, 'HH:mm');
158
+ result.start_date = safeFormat(ext.start_date || ext.startDate || session.start_at, "YYYY-MM-DD");
159
+ result.start_time = normalizeTimeString(ext.start_time) || normalizeTimeString(session.start_time) || safeFormat(session.start_at, "HH:mm");
160
+ result.end_date = safeFormat(ext.end_date || ext.endDate || session.end_at, "YYYY-MM-DD");
161
+ result.end_time = normalizeTimeString(ext.end_time) || normalizeTimeString(session.end_time) || safeFormat(session.end_at, "HH:mm");
173
162
  } else {
174
- result.start_date = safeFormat(ext.start_date || ext.startDate, 'YYYY-MM-DD');
175
- result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, 'HH:mm');
176
- result.end_date = safeFormat(ext.end_date || ext.endDate, 'YYYY-MM-DD');
177
- result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, 'HH:mm');
163
+ result.start_date = safeFormat(ext.start_date || ext.startDate, "YYYY-MM-DD");
164
+ result.start_time = normalizeTimeString(ext.start_time) || safeFormat(ext.startDate, "HH:mm");
165
+ result.end_date = safeFormat(ext.end_date || ext.endDate, "YYYY-MM-DD");
166
+ result.end_time = normalizeTimeString(ext.end_time) || safeFormat(ext.endDate, "HH:mm");
178
167
  }
179
-
180
- // ──── duration / sub_type / is_all ──────────────────────────────
181
168
  if (isMultiDay) {
182
169
  result.is_all = 1;
183
- result.sub_type = 'days';
184
- result.duration = Number(ext.duration) || (0, _serviceTimes.getDays)(cacheItem, 'days');
185
- // 全天选择日期 = 起始日
186
- if (result.start_date) result.select_date = result.start_date;
187
- // 跨日结束时刻与开始一致(如 11:24),避免 endDate 仅日期落为 00:00
188
- if (result.start_time && (!result.end_time || result.end_time === '00:00')) {
170
+ result.sub_type = "days";
171
+ result.duration = Number(ext.duration) || (0, import_serviceTimes.getDays)(cacheItem, "days");
172
+ if (result.start_date)
173
+ result.select_date = result.start_date;
174
+ if (result.start_time && (!result.end_time || result.end_time === "00:00")) {
189
175
  result.end_time = result.start_time;
190
176
  }
191
177
  } else {
192
178
  result.is_all = 0;
193
- result.sub_type = ext.sub_type || 'minutes';
179
+ result.sub_type = ext.sub_type || "minutes";
194
180
  const duration = resolveDurationMinutes(ext.duration);
195
- if (duration !== undefined) result.duration = duration;
181
+ if (duration !== void 0)
182
+ result.duration = duration;
196
183
  }
197
-
198
- // ──── number(人数/容量占用) ───────────────────────────────────
199
- result.number = (0, _resources.getSumCapacity)(cacheItem, true);
200
-
201
- // ──── resources ─────────────────────────────────────────────────
184
+ result.number = (0, import_resources.getSumCapacity)(cacheItem, true);
202
185
  result.resources = flattenResources(cacheItem);
203
-
204
- // ──── holder / relation_forms / like_status / schedule_event_id ──
205
- if (ext.holder !== undefined) result.holder = ext.holder;
206
- if (Array.isArray(ext.relation_forms)) result.relation_forms = ext.relation_forms;
207
- // 与 info2 booking/components/footer/utils formatBooking 一致:默认 common
208
- result.like_status = ext.like_status || 'common';
209
- if (cacheItem.schedule_event_id !== undefined) {
186
+ if (ext.holder !== void 0)
187
+ result.holder = ext.holder;
188
+ if (Array.isArray(ext.relation_forms))
189
+ result.relation_forms = ext.relation_forms;
190
+ result.like_status = ext.like_status || "common";
191
+ if (cacheItem.schedule_event_id !== void 0) {
210
192
  result.schedule_event_id = cacheItem.schedule_event_id;
211
193
  }
212
-
213
- // ──── metadata(严格白名单) ────────────────────────────────────
214
- const metadata = {
215
- holder_id: null
216
- };
217
- if (ext.holder_id !== undefined && ext.holder_id !== null) {
194
+ const metadata = { holder_id: null };
195
+ if (ext.holder_id !== void 0 && ext.holder_id !== null) {
218
196
  metadata.holder_id = ext.holder_id;
219
197
  }
220
- if (ext.holder !== undefined) {
198
+ if (ext.holder !== void 0) {
221
199
  metadata.holder = ext.holder;
222
200
  }
223
- if (ext.collect_pax !== undefined) metadata.collect_pax = ext.collect_pax;
224
- // 与 info2 formatMetaData 一致:优先写入完整人数维度数组,供编辑回显 / 详情回灌。
201
+ if (ext.collect_pax !== void 0)
202
+ metadata.collect_pax = ext.collect_pax;
225
203
  const extendCapacity = normalizeExtendCapacityForMetadata(ext.capacity);
226
204
  if (extendCapacity) {
227
205
  metadata.capacity = extendCapacity;
228
- } else if (ext.capacity_snapshot !== undefined) {
206
+ } else if (ext.capacity_snapshot !== void 0) {
229
207
  metadata.capacity = ext.capacity_snapshot;
230
208
  }
231
- const selectType = deriveResourceSelectType(cacheItem) || options?.bookingConfig?.resource_select_type;
232
- if (selectType) metadata.resource_select_type = selectType;
233
- // unique_identification_number 不在这里生成(由 OS createLinkedProductAndBooking 统一写)。
209
+ const selectType = deriveResourceSelectType(cacheItem) || ((_b = options == null ? void 0 : options.bookingConfig) == null ? void 0 : _b.resource_select_type);
210
+ if (selectType)
211
+ metadata.resource_select_type = selectType;
234
212
  result.metadata = metadata;
235
-
236
- // ──── booking root 占位字段(与 TEMP_ORDER_FIELDS_SUMMARY 一致) ──
237
213
  result.schedule_id = 0;
238
214
  result.relation_id = 0;
239
215
  result.form_id = 0;
240
- result.relation_type = '';
216
+ result.relation_type = "";
241
217
  return result;
242
- }
218
+ }
219
+ // Annotate the CommonJS export names for ESM import in node:
220
+ 0 && (module.exports = {
221
+ cacheItemToBookingInput
222
+ });
@@ -1,31 +1,43 @@
1
- "use strict";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
18
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
19
+ // src/modules/BookingContext/utils/flexible.ts
20
+ var flexible_exports = {};
21
+ __export(flexible_exports, {
22
+ flexibleObj: () => flexibleObj,
23
+ getDurationValue: () => getDurationValue,
24
+ isProductFlexibleDuration: () => isProductFlexibleDuration
5
25
  });
6
- exports.flexibleObj = void 0;
7
- exports.getDurationValue = getDurationValue;
8
- exports.isProductFlexibleDuration = isProductFlexibleDuration;
9
- /**
10
- * 灵活时长(flexible duration)协议工具。
11
- *
12
- * info2 用 `flexible_<minutes>` 字符串前缀标记"灵活时长",对外用同名 API 暴露 create / getValue / isFlexible / add。
13
- * OS 这边一比一搬运,无外部依赖。
14
- */
15
-
16
- const PREFIX = 'flexible_';
17
- const flexibleObj = exports.flexibleObj = {
26
+ module.exports = __toCommonJS(flexible_exports);
27
+ var PREFIX = "flexible_";
28
+ var flexibleObj = {
18
29
  create(num) {
19
30
  return `${PREFIX}${num}`;
20
31
  },
21
32
  getValue(str) {
22
- if (typeof str === 'string' && flexibleObj.isFlexible(str)) {
23
- return Number(str.replace(PREFIX, ''));
33
+ if (typeof str === "string" && flexibleObj.isFlexible(str)) {
34
+ return Number(str.replace(PREFIX, ""));
24
35
  }
25
36
  return Number(str);
26
37
  },
27
38
  isFlexible(str) {
28
- if (typeof str !== 'string') return false;
39
+ if (typeof str !== "string")
40
+ return false;
29
41
  return str.indexOf(PREFIX) > -1;
30
42
  },
31
43
  add(current, duration) {
@@ -35,29 +47,34 @@ const flexibleObj = exports.flexibleObj = {
35
47
  return Number(current) + duration;
36
48
  }
37
49
  };
38
-
39
- /**
40
- * 取 duration 数值(兼容 number / { type, value } / 灵活时长字符串)。
41
- * 与 info2 `getDuration` 行为等价。
42
- */
43
- /**
44
- * 商品定义是否为「灵活时长」类型(仅看 product.duration 对象,不把 flexible_423 字符串当类型)。
45
- * 与 info2 `getDuration({ type: 'flexible' }) === 'flexible'` 判定对齐。
46
- */
47
50
  function isProductFlexibleDuration(duration) {
48
- return Boolean(duration && typeof duration === 'object' && duration.type === 'flexible');
51
+ return Boolean(
52
+ duration && typeof duration === "object" && duration.type === "flexible"
53
+ );
49
54
  }
50
55
  function getDurationValue(duration) {
51
- if (duration === undefined || duration === null) return undefined;
52
- if (typeof duration === 'number') return duration;
53
- if (typeof duration === 'string') {
54
- if (flexibleObj.isFlexible(duration)) return 'flexible';
56
+ if (duration === void 0 || duration === null)
57
+ return void 0;
58
+ if (typeof duration === "number")
59
+ return duration;
60
+ if (typeof duration === "string") {
61
+ if (flexibleObj.isFlexible(duration))
62
+ return "flexible";
55
63
  return Number(duration);
56
64
  }
57
- if (typeof duration === 'object') {
58
- if (duration.type === 'minutes') return duration.value;
59
- if (duration.type === 'flexible') return 'flexible';
60
- if (duration.type === 'days') return duration.value;
65
+ if (typeof duration === "object") {
66
+ if (duration.type === "minutes")
67
+ return duration.value;
68
+ if (duration.type === "flexible")
69
+ return "flexible";
70
+ if (duration.type === "days")
71
+ return duration.value;
61
72
  }
62
- return undefined;
63
- }
73
+ return void 0;
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ flexibleObj,
78
+ getDurationValue,
79
+ isProductFlexibleDuration
80
+ });
@@ -1,35 +1,50 @@
1
- "use strict";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
18
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
19
+ // src/modules/BookingContext/utils/formatResourceList.ts
20
+ var formatResourceList_exports = {};
21
+ __export(formatResourceList_exports, {
22
+ formatResourceListAndMap: () => formatResourceListAndMap
5
23
  });
6
- exports.formatResourceListAndMap = formatResourceListAndMap;
7
- var _noResource = require("./noResource");
8
- /**
9
- * 将 `/schedule/resource/list` 原始数组格式化为 `list + listMap`。
10
- * 逻辑与 info2 [`getFormatResourceListAndMap`] 对齐:追加无资源占位行、按 id 建 map。
11
- */
24
+ module.exports = __toCommonJS(formatResourceList_exports);
25
+ var import_noResource = require("./noResource");
12
26
  function formatResourceListAndMap(data, _bookingIds = []) {
13
- const resourceList = (Array.isArray(data) ? data : []).concat([(0, _noResource.getNoResource2)({})]);
27
+ const resourceList = (Array.isArray(data) ? data : []).concat([(0, import_noResource.getNoResource2)({})]);
14
28
  const map = resourceList.reduce((prev, item) => {
15
- if (item?.id !== undefined && item?.id !== null) {
29
+ if ((item == null ? void 0 : item.id) !== void 0 && (item == null ? void 0 : item.id) !== null) {
16
30
  prev[String(item.id)] = item;
17
31
  }
18
32
  return prev;
19
33
  }, {});
20
- const getCapacity = item => item.capacity;
21
- const list = resourceList.map(item => {
34
+ const getCapacity = (item) => item.capacity;
35
+ const list = resourceList.map((item) => {
22
36
  const newItem = {
23
37
  ...item,
24
38
  capacity: getCapacity(item)
25
39
  };
26
- if (newItem.id !== undefined && newItem.id !== null) {
40
+ if (newItem.id !== void 0 && newItem.id !== null) {
27
41
  map[String(newItem.id)] = newItem;
28
42
  }
29
43
  return newItem;
30
44
  });
31
- return {
32
- list,
33
- listMap: map
34
- };
35
- }
45
+ return { list, listMap: map };
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ formatResourceListAndMap
50
+ });