@pisell/pisellos 0.0.569 → 0.10.1

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 (329) 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/walletPass/evaluator.js +7 -5
  5. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  6. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  7. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  8. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  9. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  10. package/dist/model/strategy/strategy-example.js +19 -5
  11. package/dist/modules/BaseModule.d.ts +1 -1
  12. package/dist/modules/BaseModule.js +8 -10
  13. package/dist/modules/Cart/index.js +3 -0
  14. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  15. package/dist/modules/Cart/utils/cartResource.js +0 -2
  16. package/dist/modules/Cart/utils/changePrice.js +9 -16
  17. package/dist/modules/Date/index.js +5 -1
  18. package/dist/modules/Discount/index.d.ts +0 -1
  19. package/dist/modules/Discount/index.js +7 -22
  20. package/dist/modules/Discount/types.d.ts +0 -1
  21. package/dist/modules/OpenData/index.js +2 -0
  22. package/dist/modules/Order/index.d.ts +1 -1
  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 +0 -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.d.ts +1 -1
  167. package/lib/modules/Order/index.js +1909 -1572
  168. package/lib/modules/Order/types.js +35 -78
  169. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  170. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  171. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  172. package/lib/modules/Order/utils.js +634 -799
  173. package/lib/modules/Payment/cash.js +33 -20
  174. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  175. package/lib/modules/Payment/eftpos.js +30 -16
  176. package/lib/modules/Payment/index.js +378 -518
  177. package/lib/modules/Payment/mx51.js +0 -1
  178. package/lib/modules/Payment/types.d.ts +4 -8
  179. package/lib/modules/Payment/types.js +107 -216
  180. package/lib/modules/Payment/utils.js +48 -51
  181. package/lib/modules/Payment/walletpass.d.ts +0 -2
  182. package/lib/modules/Payment/walletpass.js +211 -226
  183. package/lib/modules/Product/index.js +46 -51
  184. package/lib/modules/Product/types.js +16 -4
  185. package/lib/modules/Product/utils.js +33 -32
  186. package/lib/modules/ProductList/index.d.ts +1 -1
  187. package/lib/modules/ProductList/index.js +117 -117
  188. package/lib/modules/ProductList/types.d.ts +0 -1
  189. package/lib/modules/ProductList/types.js +31 -9
  190. package/lib/modules/Quotation/index.js +100 -66
  191. package/lib/modules/Quotation/types.js +16 -4
  192. package/lib/modules/Resource/index.js +59 -27
  193. package/lib/modules/Resource/types.js +32 -22
  194. package/lib/modules/Resource/utils.js +38 -30
  195. package/lib/modules/ResourcePlanner/index.js +61 -60
  196. package/lib/modules/ResourcePlanner/planner.js +384 -346
  197. package/lib/modules/ResourcePlanner/types.js +16 -4
  198. package/lib/modules/Rules/index.js +903 -1475
  199. package/lib/modules/Rules/types.js +40 -17
  200. package/lib/modules/SalesSummary/index.js +90 -85
  201. package/lib/modules/SalesSummary/types.js +16 -4
  202. package/lib/modules/SalesSummary/utils.js +427 -351
  203. package/lib/modules/ScanOrderLogger/index.js +79 -59
  204. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  205. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  206. package/lib/modules/ScanOrderLogger/types.js +16 -4
  207. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  208. package/lib/modules/Schedule/index.js +114 -100
  209. package/lib/modules/Schedule/type.js +16 -4
  210. package/lib/modules/Schedule/types.js +16 -4
  211. package/lib/modules/Schedule/utils.js +291 -433
  212. package/lib/modules/Step/index.js +52 -40
  213. package/lib/modules/Step/tyeps.js +16 -4
  214. package/lib/modules/Summary/index.js +71 -66
  215. package/lib/modules/Summary/types.js +16 -4
  216. package/lib/modules/Summary/utils.js +418 -791
  217. package/lib/modules/SurchargeList/index.js +60 -46
  218. package/lib/modules/SurchargeList/types.js +16 -4
  219. package/lib/modules/index.js +63 -245
  220. package/lib/plugins/app.js +16 -4
  221. package/lib/plugins/index.js +25 -36
  222. package/lib/plugins/request.js +126 -137
  223. package/lib/plugins/shopStore.js +16 -4
  224. package/lib/plugins/user.js +16 -4
  225. package/lib/plugins/window.js +179 -171
  226. package/lib/server/index.js +2337 -2675
  227. package/lib/server/modules/floor-plan/index.js +123 -102
  228. package/lib/server/modules/floor-plan/types.js +30 -15
  229. package/lib/server/modules/index.js +68 -106
  230. package/lib/server/modules/menu/index.js +122 -146
  231. package/lib/server/modules/menu/types.js +31 -18
  232. package/lib/server/modules/order/index.js +642 -567
  233. package/lib/server/modules/order/types.js +32 -117
  234. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  235. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  236. package/lib/server/modules/payment/index.js +83 -59
  237. package/lib/server/modules/payment/types.js +16 -4
  238. package/lib/server/modules/products/index.js +459 -575
  239. package/lib/server/modules/products/types.js +34 -44
  240. package/lib/server/modules/quotation/index.js +172 -137
  241. package/lib/server/modules/quotation/types.js +31 -21
  242. package/lib/server/modules/resource/index.js +184 -213
  243. package/lib/server/modules/resource/types.js +33 -42
  244. package/lib/server/modules/schedule/index.js +123 -135
  245. package/lib/server/modules/schedule/types.js +21 -14
  246. package/lib/server/modules/schedule/utils.js +163 -334
  247. package/lib/server/types.js +16 -4
  248. package/lib/server/utils/index.js +23 -25
  249. package/lib/server/utils/product.js +139 -196
  250. package/lib/server/utils/schedule.js +41 -34
  251. package/lib/server/utils/small-ticket.js +456 -478
  252. package/lib/server/utils/time.js +49 -40
  253. package/lib/solution/BaseSales/index.js +1016 -850
  254. package/lib/solution/BaseSales/types.js +37 -41
  255. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  256. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  257. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  258. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  259. package/lib/solution/BaseSales/utils.js +140 -155
  260. package/lib/solution/BookingByStep/index.d.ts +1 -1
  261. package/lib/solution/BookingByStep/index.js +1340 -1530
  262. package/lib/solution/BookingByStep/types.js +99 -40
  263. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  264. package/lib/solution/BookingByStep/utils/products.js +52 -42
  265. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  266. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  267. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  268. package/lib/solution/BookingTicket/index.d.ts +1 -1
  269. package/lib/solution/BookingTicket/index.js +459 -543
  270. package/lib/solution/BookingTicket/types.js +77 -99
  271. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  272. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  273. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  274. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  275. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  276. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  277. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  278. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  279. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  280. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  281. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  282. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  283. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  284. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  285. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  286. package/lib/solution/BuyTickets/index.js +70 -67
  287. package/lib/solution/BuyTickets/types.js +38 -22
  288. package/lib/solution/Checkout/index.js +1158 -1451
  289. package/lib/solution/Checkout/types.js +61 -91
  290. package/lib/solution/Checkout/utils/index.js +156 -228
  291. package/lib/solution/PlaceOrder/index.js +0 -55
  292. package/lib/solution/RegisterAndLogin/config.js +460 -493
  293. package/lib/solution/RegisterAndLogin/index.js +630 -633
  294. package/lib/solution/RegisterAndLogin/types.js +76 -189
  295. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  296. package/lib/solution/Sales/index.js +320 -317
  297. package/lib/solution/Sales/types.js +33 -27
  298. package/lib/solution/ScanOrder/index.js +862 -831
  299. package/lib/solution/ScanOrder/types.js +34 -33
  300. package/lib/solution/ScanOrder/utils.js +371 -406
  301. package/lib/solution/ShopDiscount/index.js +233 -235
  302. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  303. package/lib/solution/ShopDiscount/types.js +37 -15
  304. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  305. package/lib/solution/ShopDiscount/utils.js +172 -309
  306. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  307. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  308. package/lib/solution/VenueBooking/index.d.ts +3 -31
  309. package/lib/solution/VenueBooking/index.js +916 -967
  310. package/lib/solution/VenueBooking/types.d.ts +1 -3
  311. package/lib/solution/VenueBooking/types.js +39 -20
  312. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  313. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  314. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  315. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  316. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  317. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  318. package/lib/solution/VenueBooking/utils.js +67 -130
  319. package/lib/solution/index.js +41 -124
  320. package/lib/store/createStore.js +29 -32
  321. package/lib/types/index.d.ts +1 -1
  322. package/lib/types/index.js +16 -4
  323. package/lib/utils/task.js +36 -36
  324. package/lib/utils/watch.js +47 -81
  325. package/package.json +2 -4
  326. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  327. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  328. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  329. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,268 +1,221 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.derivePresetStartTimeFromDate = derivePresetStartTimeFromDate;
7
- exports.getIsAutoClose = getIsAutoClose;
8
- exports.getProductExtend = getProductExtend;
9
- exports.getServiceStartTimeAndEndTime = getServiceStartTimeAndEndTime;
10
- Object.defineProperty(exports, "getSumCapacity", {
11
- enumerable: true,
12
- get: function () {
13
- return _resources.getSumCapacity;
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 });
14
16
  }
15
- });
16
- exports.getTimeObj = getTimeObj;
17
- var _dayjs = _interopRequireDefault(require("dayjs"));
18
- var _resources = require("./resources");
19
- var _resourceSelection = require("./resourceSelection");
20
- var _serviceTimes = require("./serviceTimes");
21
- var _timeSlices = require("./timeSlices");
22
- var _flexible = require("./flexible");
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
- /**
25
- * 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
26
- *
27
- * 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
28
- * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
29
- */
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);
30
28
 
31
- /** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
29
+ // src/modules/BookingContext/utils/productExtend.ts
30
+ var productExtend_exports = {};
31
+ __export(productExtend_exports, {
32
+ derivePresetStartTimeFromDate: () => derivePresetStartTimeFromDate,
33
+ getIsAutoClose: () => getIsAutoClose,
34
+ getProductExtend: () => getProductExtend,
35
+ getServiceStartTimeAndEndTime: () => getServiceStartTimeAndEndTime,
36
+ getSumCapacity: () => import_resources.getSumCapacity,
37
+ getTimeObj: () => getTimeObj
38
+ });
39
+ module.exports = __toCommonJS(productExtend_exports);
40
+ var import_dayjs = __toESM(require("dayjs"));
41
+ var import_resources = require("./resources");
42
+ var import_resourceSelection = require("./resourceSelection");
43
+ var import_serviceTimes = require("./serviceTimes");
44
+ var import_timeSlices = require("./timeSlices");
45
+ var import_flexible = require("./flexible");
32
46
  function derivePresetStartTimeFromDate(date) {
33
- if (date == null) return undefined;
34
- const d = (0, _dayjs.default)(date);
35
- if (!d.isValid()) return undefined;
36
- const hhmm = d.format('HH:mm');
37
- if (hhmm === '00:00') return undefined;
47
+ if (date == null)
48
+ return void 0;
49
+ const d = (0, import_dayjs.default)(date);
50
+ if (!d.isValid())
51
+ return void 0;
52
+ const hhmm = d.format("HH:mm");
53
+ if (hhmm === "00:00")
54
+ return void 0;
38
55
  return hhmm;
39
56
  }
40
-
41
- /**
42
- * 取预约时间偏好(sequential / parallel);默认 sequential。
43
- */
44
57
  function getAppointmentTimingPreference(ctx) {
45
- return ctx?.bookingConfig?.config?.information_tab?.appointment_timing_preference || 'sequential';
58
+ var _a, _b, _c;
59
+ return ((_c = (_b = (_a = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.information_tab) == null ? void 0 : _c.appointment_timing_preference) || "sequential";
46
60
  }
47
-
48
- /**
49
- * 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
50
- */
51
61
  function getFlexibleOption(params) {
52
- const {
53
- cacheItem,
54
- useStartTime
55
- } = params;
56
- const duration = (0, _flexible.getDurationValue)(cacheItem?.duration);
57
- if (duration !== 'flexible') return null;
58
- const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(cacheItem?._extend?.start_date).format('YYYY-MM-DD')} ${useStartTime || cacheItem?._extend?.start_time || '00:00'}`);
59
- const usable = (0, _resources.getUsableTime)(cacheItem);
60
- const usableEndAt = usable?._extend?.usableTime?.end_at ? (0, _dayjs.default)(usable._extend.usableTime.end_at) : null;
61
- const endDate = (0, _timeSlices.getEndDate)(startDate, 'flexible', usableEndAt, params.ctx?.shopOpeningHours);
62
- const timeValue = endDate.diff(startDate, 'minute');
63
- return {
64
- label: String(timeValue),
65
- value: _flexible.flexibleObj.create(timeValue)
66
- };
62
+ var _a, _b, _c, _d, _e;
63
+ const { cacheItem, useStartTime } = params;
64
+ const duration = (0, import_flexible.getDurationValue)(cacheItem == null ? void 0 : cacheItem.duration);
65
+ if (duration !== "flexible")
66
+ return null;
67
+ const startDate = (0, import_dayjs.default)(
68
+ `${(0, import_dayjs.default)((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.start_date).format("YYYY-MM-DD")} ${useStartTime || ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.start_time) || "00:00"}`
69
+ );
70
+ const usable = (0, import_resources.getUsableTime)(cacheItem);
71
+ const usableEndAt = ((_d = (_c = usable == null ? void 0 : usable._extend) == null ? void 0 : _c.usableTime) == null ? void 0 : _d.end_at) ? (0, import_dayjs.default)(usable._extend.usableTime.end_at) : null;
72
+ const endDate = (0, import_timeSlices.getEndDate)(
73
+ startDate,
74
+ "flexible",
75
+ usableEndAt,
76
+ (_e = params.ctx) == null ? void 0 : _e.shopOpeningHours
77
+ );
78
+ const timeValue = endDate.diff(startDate, "minute");
79
+ return { label: String(timeValue), value: import_flexible.flexibleObj.create(timeValue) };
67
80
  }
68
-
69
- /**
70
- * 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
71
- */
72
81
  function getTimeObj(params) {
73
- const {
74
- cacheItem,
75
- useStartTime,
76
- useDuration,
77
- ctx
78
- } = params;
79
- const isMultiDay = (0, _serviceTimes.isMultiDayProduct)(cacheItem);
80
- const flexibleOption = getFlexibleOption({
81
- cacheItem,
82
- useStartTime,
83
- ctx
84
- });
85
- const baseSlices = (0, _timeSlices.sliceDayIntoFiveMinutes)(ctx?.bookingConfig?.config?.basic?.service_time, isMultiDay);
82
+ var _a, _b, _c;
83
+ const { cacheItem, useStartTime, useDuration, ctx } = params;
84
+ const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem);
85
+ const flexibleOption = getFlexibleOption({ cacheItem, useStartTime, ctx });
86
+ const baseSlices = (0, import_timeSlices.sliceDayIntoFiveMinutes)(
87
+ (_c = (_b = (_a = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.basic) == null ? void 0 : _c.service_time,
88
+ isMultiDay
89
+ );
86
90
  const timeSlices = [...baseSlices.timeSlices];
87
91
  const durationSlicesBasedOnTime = [...baseSlices.durationSlicesBasedOnTime];
88
92
  if (flexibleOption) {
89
93
  durationSlicesBasedOnTime.unshift(flexibleOption);
90
94
  }
91
- if (useDuration && !durationSlicesBasedOnTime.some(d => d.value === useDuration)) {
95
+ if (useDuration && !durationSlicesBasedOnTime.some((d) => d.value === useDuration)) {
92
96
  durationSlicesBasedOnTime.unshift({
93
97
  label: String(useDuration),
94
98
  value: useDuration
95
99
  });
96
100
  }
97
- return {
98
- timeSlices,
99
- durationSlicesBasedOnTime
100
- };
101
+ return { timeSlices, durationSlicesBasedOnTime };
101
102
  }
102
-
103
- /**
104
- * 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
105
- * 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
106
- * - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
107
- * - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
108
- * - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
109
- */
110
103
  function getServiceStartTimeAndEndTime(params) {
111
- const {
112
- cacheItem,
113
- timeObj,
114
- ctx
115
- } = params;
116
- if (cacheItem?.isCustomItem) {
117
- return {
118
- duration: null
119
- };
104
+ var _a, _b, _c, _d, _e;
105
+ const { cacheItem, timeObj, ctx } = params;
106
+ if (cacheItem == null ? void 0 : cacheItem.isCustomItem) {
107
+ return { duration: null };
120
108
  }
121
109
  const appointmentTimingPreference = getAppointmentTimingPreference(ctx);
122
110
  const lastServer = ctx.previousService || null;
123
111
  const resolveDuration = () => {
124
- if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) return (0, _serviceTimes.getDays)(cacheItem, 'days');
125
- return (0, _timeSlices.findNextDuration)(cacheItem.duration, timeObj.durationSlicesBasedOnTime, cacheItem?.duration?.value);
126
- };
127
- let _extend = {
128
- duration: resolveDuration()
112
+ var _a2;
113
+ if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem))
114
+ return (0, import_serviceTimes.getDays)(cacheItem, "days");
115
+ return (0, import_timeSlices.findNextDuration)(cacheItem.duration, timeObj.durationSlicesBasedOnTime, (_a2 = cacheItem == null ? void 0 : cacheItem.duration) == null ? void 0 : _a2.value);
129
116
  };
117
+ let _extend = { duration: resolveDuration() };
130
118
  if (lastServer) {
131
- const lastStart = lastServer._extend?.startDate;
132
- const lastEnd = lastServer._extend?.endDate;
133
- if (appointmentTimingPreference === 'parallel') {
134
- _extend.start_time = (0, _dayjs.default)(lastStart).format('HH:mm');
135
- } else if ((0, _dayjs.default)(lastEnd).isAfter((0, _dayjs.default)(lastStart), 'day')) {
136
- _extend.start_time = timeObj.timeSlices[timeObj.timeSlices.length - 1]?.value;
119
+ const lastStart = (_a = lastServer._extend) == null ? void 0 : _a.startDate;
120
+ const lastEnd = (_b = lastServer._extend) == null ? void 0 : _b.endDate;
121
+ if (appointmentTimingPreference === "parallel") {
122
+ _extend.start_time = (0, import_dayjs.default)(lastStart).format("HH:mm");
123
+ } else if ((0, import_dayjs.default)(lastEnd).isAfter((0, import_dayjs.default)(lastStart), "day")) {
124
+ _extend.start_time = (_c = timeObj.timeSlices[timeObj.timeSlices.length - 1]) == null ? void 0 : _c.value;
137
125
  } else {
138
- _extend.start_time = lastEnd ? (0, _dayjs.default)(lastEnd).format('HH:mm') : (0, _dayjs.default)().format('HH:mm');
126
+ _extend.start_time = lastEnd ? (0, import_dayjs.default)(lastEnd).format("HH:mm") : (0, import_dayjs.default)().format("HH:mm");
139
127
  }
140
128
  } else {
141
129
  const presetStartTime = ctx.presetStartTime;
142
- // 与 info2 getServiceStartTimeAndEndTime 一致:日历/顶部日期带 HH:mm 时原样使用,
143
- // 不做 findNextSlice 栅格对齐(否则 01:47 会被抬到 01:50)。
144
- if (presetStartTime && presetStartTime !== '00:00') {
130
+ if (presetStartTime && presetStartTime !== "00:00") {
145
131
  _extend.start_time = presetStartTime;
146
132
  } else if (cacheItem.currentDefaultTime) {
147
133
  _extend.start_time = cacheItem.currentDefaultTime;
148
134
  } else {
149
- _extend.start_time = (0, _dayjs.default)().format('HH:mm');
135
+ _extend.start_time = (0, import_dayjs.default)().format("HH:mm");
150
136
  }
151
137
  }
152
- _extend = {
153
- ..._extend,
154
- ...cacheItem._extend
155
- };
156
- const {
157
- startDate,
158
- endDate
159
- } = (0, _serviceTimes.getServiceTimes)({
160
- ...cacheItem,
161
- _extend
162
- });
138
+ _extend = { ..._extend, ...cacheItem._extend };
139
+ const { startDate, endDate } = (0, import_serviceTimes.getServiceTimes)({ ...cacheItem, _extend });
163
140
  _extend.startDate = startDate;
164
141
  _extend.endDate = endDate;
165
- if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) {
166
- _extend.start_time = _extend.start_time || startDate.format('HH:mm');
167
- _extend.end_time = _extend.end_time || endDate.format('HH:mm');
142
+ if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem)) {
143
+ _extend.start_time = _extend.start_time || startDate.format("HH:mm");
144
+ _extend.end_time = _extend.end_time || endDate.format("HH:mm");
168
145
  _extend.start_date = _extend.start_date ?? startDate;
169
146
  _extend.end_date = _extend.end_date ?? endDate;
170
147
  }
171
- const session = cacheItem?._extend?.other?.session;
172
- if ((0, _serviceTimes.isSessionProduct)(cacheItem) && session) {
173
- const baseDate = ctx.date ? (0, _dayjs.default)(ctx.date) : (0, _dayjs.default)();
174
- const startAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.start_at).format('HH:mm:ss')}`);
175
- const endAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.end_at).format('HH:mm:ss')}`);
148
+ const session = (_e = (_d = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _d.other) == null ? void 0 : _e.session;
149
+ if ((0, import_serviceTimes.isSessionProduct)(cacheItem) && session) {
150
+ const baseDate = ctx.date ? (0, import_dayjs.default)(ctx.date) : (0, import_dayjs.default)();
151
+ const startAt = (0, import_dayjs.default)(`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.start_at).format("HH:mm:ss")}`);
152
+ const endAt = (0, import_dayjs.default)(`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.end_at).format("HH:mm:ss")}`);
176
153
  _extend.start_date = startAt;
177
154
  _extend.startDate = startAt;
178
155
  _extend.start_time = session.start_time;
179
156
  _extend.end_date = endAt;
180
157
  _extend.endDate = endAt;
181
158
  _extend.end_time = session.end_time;
182
- _extend.duration = (0, _serviceTimes.getDays)({
183
- _extend
184
- }, 'minutes');
159
+ _extend.duration = (0, import_serviceTimes.getDays)({ _extend }, "minutes");
185
160
  }
186
161
  return _extend;
187
162
  }
188
-
189
- /**
190
- * 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
191
- * 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
192
- *
193
- * 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
194
- */
195
163
  function getProductExtend(params) {
196
- const {
197
- cacheItem,
198
- ctx,
199
- isDisabledTime
200
- } = params;
201
- const isNew = cacheItem.new || !cacheItem._extend?.endDate;
202
- const _cacheItem = {
203
- ...cacheItem
204
- };
164
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
165
+ const { cacheItem, ctx, isDisabledTime } = params;
166
+ const isNew = cacheItem.new || !((_a = cacheItem._extend) == null ? void 0 : _a.endDate);
167
+ const _cacheItem = { ...cacheItem };
205
168
  const resourcesOriginMap = ctx.resourcesOriginMap || {};
206
169
  _cacheItem._data = {};
207
- if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) {
170
+ if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem)) {
208
171
  _cacheItem._extend = _cacheItem._extend || {};
209
- _cacheItem._extend.holder_id = cacheItem?._extend?.holder_id || [];
210
- _cacheItem._extend.sub_type = 'days';
172
+ _cacheItem._extend.holder_id = ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.holder_id) || [];
173
+ _cacheItem._extend.sub_type = "days";
211
174
  }
212
175
  if (isNew) {
213
- _cacheItem._data.timeObj = getTimeObj({
214
- cacheItem,
215
- ctx
216
- });
176
+ _cacheItem._data.timeObj = getTimeObj({ cacheItem, ctx });
217
177
  _cacheItem._extend = getServiceStartTimeAndEndTime({
218
178
  cacheItem,
219
179
  timeObj: _cacheItem._data.timeObj,
220
180
  ctx
221
181
  });
222
182
  _cacheItem._data.capacitys = cacheItem.capacity;
223
- _cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
224
- resourceTab: ctx?.bookingConfig?.config?.resource_tab,
183
+ _cacheItem._data.resourcesOrigin = (0, import_resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
184
+ resourceTab: (_d = (_c = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _c.config) == null ? void 0 : _d.resource_tab,
225
185
  resourcesOrigin: ctx.resourcesOrigin || []
226
186
  });
227
- _cacheItem._extend.capacity = (0, _resources.setDefaultCapacitys)({
187
+ _cacheItem._extend.capacity = (0, import_resources.setDefaultCapacitys)({
228
188
  capacitys: _cacheItem._data.capacitys,
229
189
  cacheItem: _cacheItem
230
190
  });
231
- const {
232
- list,
233
- maps
234
- } = (0, _resources.formatResources)({
191
+ const { list, maps } = (0, import_resources.formatResources)({
235
192
  cacheItem: _cacheItem,
236
193
  resourcesOrigin: _cacheItem._data.resourcesOrigin
237
194
  });
238
195
  _cacheItem._data.resources = list;
239
196
  _cacheItem._data.resourceMaps = maps;
240
- _cacheItem._extend.resource = (0, _resources.setDefaultResource)({
197
+ _cacheItem._extend.resource = (0, import_resources.setDefaultResource)({
241
198
  cacheItem: _cacheItem,
242
199
  resources: _cacheItem._data.resources,
243
200
  resourceIdFromCalendar: ctx.resourceIdFromCalendar,
244
201
  isAutoAllocationOn: ctx.isAutoAllocationOn
245
202
  });
246
-
247
- // 灵活时长二次计算(资源默认选中后,按 usableTime 重算 flexible 分钟数)
248
- if ((0, _flexible.isProductFlexibleDuration)(_cacheItem?.duration)) {
203
+ if ((0, import_flexible.isProductFlexibleDuration)(_cacheItem == null ? void 0 : _cacheItem.duration)) {
249
204
  _cacheItem._data.timeObj = getTimeObj({
250
205
  cacheItem: _cacheItem,
251
206
  useStartTime: _cacheItem._extend.start_time,
252
207
  ctx
253
208
  });
254
- _cacheItem._extend.duration = _cacheItem._data.timeObj?.durationSlicesBasedOnTime?.[0]?.value;
255
- const {
256
- endDate
257
- } = (0, _serviceTimes.getServiceTimes)(_cacheItem);
209
+ _cacheItem._extend.duration = (_g = (_f = (_e = _cacheItem._data.timeObj) == null ? void 0 : _e.durationSlicesBasedOnTime) == null ? void 0 : _f[0]) == null ? void 0 : _g.value;
210
+ const { endDate } = (0, import_serviceTimes.getServiceTimes)(_cacheItem);
258
211
  _cacheItem._extend.endDate = endDate;
259
212
  }
260
213
  _cacheItem.autoClose = getIsAutoClose(_cacheItem, ctx.isAutoAllocationOn || (() => true));
261
- if (_cacheItem._extend.bundle_edit !== undefined) {
214
+ if (_cacheItem._extend.bundle_edit !== void 0) {
262
215
  _cacheItem._extend.bundle_edit = 1;
263
216
  }
264
217
  if (!isDisabledTime) {
265
- _cacheItem._time = new Date().getTime();
218
+ _cacheItem._time = (/* @__PURE__ */ new Date()).getTime();
266
219
  }
267
220
  } else {
268
221
  if (!_cacheItem._data.capacitys) {
@@ -270,25 +223,19 @@ function getProductExtend(params) {
270
223
  }
271
224
  if (!_cacheItem._data.resourcesOrigin) {
272
225
  const extraResources = [];
273
- if (Array.isArray(_cacheItem._extend?.event_resources)) {
274
- _cacheItem._extend.event_resources.forEach(er => {
275
- extraResources.push({
276
- form_id: er.form_id,
277
- id: er.relation_id
278
- });
226
+ if (Array.isArray((_h = _cacheItem._extend) == null ? void 0 : _h.event_resources)) {
227
+ _cacheItem._extend.event_resources.forEach((er) => {
228
+ extraResources.push({ form_id: er.form_id, id: er.relation_id });
279
229
  });
280
230
  }
281
- _cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
231
+ _cacheItem._data.resourcesOrigin = (0, import_resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
282
232
  extraResources,
283
- resourceTab: ctx?.bookingConfig?.config?.resource_tab,
233
+ resourceTab: (_j = (_i = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _i.config) == null ? void 0 : _j.resource_tab,
284
234
  resourcesOrigin: ctx.resourcesOrigin || []
285
235
  });
286
236
  }
287
237
  if (!_cacheItem._data.resources) {
288
- const {
289
- list,
290
- maps
291
- } = (0, _resources.formatResources)({
238
+ const { list, maps } = (0, import_resources.formatResources)({
292
239
  cacheItem: _cacheItem,
293
240
  resourcesOrigin: _cacheItem._data.resourcesOrigin
294
241
  });
@@ -297,34 +244,40 @@ function getProductExtend(params) {
297
244
  }
298
245
  _cacheItem._data.timeObj = getTimeObj({
299
246
  cacheItem: _cacheItem,
300
- useStartTime: _cacheItem._extend?.start_time,
247
+ useStartTime: (_k = _cacheItem._extend) == null ? void 0 : _k.start_time,
301
248
  ctx
302
249
  });
303
250
  }
304
251
  return _cacheItem;
305
252
  }
306
-
307
- /**
308
- * 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
309
- * 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
310
- * `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
311
- */
312
253
  function getIsAutoClose(cacheItem, isAutoAllocationOn) {
313
- if ((0, _resourceSelection.productNeedsResourceExtend)(cacheItem) && !(0, _resourceSelection.hasActualResourceSelection)(cacheItem)) {
254
+ var _a, _b, _c, _d, _e;
255
+ if ((0, import_resourceSelection.productNeedsResourceExtend)(cacheItem) && !(0, import_resourceSelection.hasActualResourceSelection)(cacheItem)) {
314
256
  return false;
315
257
  }
316
- if (cacheItem._data?.capacitys?.type !== 'custom') {
317
- const resources = cacheItem?._data?.resources || [];
258
+ if (((_b = (_a = cacheItem._data) == null ? void 0 : _a.capacitys) == null ? void 0 : _b.type) !== "custom") {
259
+ const resources = ((_c = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _c.resources) || [];
318
260
  if (resources.length === 1) {
319
261
  const first = resources[0];
320
- if (first.select_type?.type === 'single' && (first.default_resource || []).length > 0) {
262
+ if (((_d = first.select_type) == null ? void 0 : _d.type) === "single" && (first.default_resource || []).length > 0) {
321
263
  return true;
322
264
  }
323
265
  }
324
266
  }
325
- const entries = Object.entries(cacheItem._extend?.resource || {});
267
+ const entries = Object.entries(((_e = cacheItem._extend) == null ? void 0 : _e.resource) || {});
326
268
  if (entries.length === 0) {
327
- return !(0, _resourceSelection.productNeedsResourceExtend)(cacheItem);
269
+ return !(0, import_resourceSelection.productNeedsResourceExtend)(cacheItem);
328
270
  }
329
- return entries.every(([key, value]) => isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0);
330
- }
271
+ return entries.every(
272
+ ([key, value]) => isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0
273
+ );
274
+ }
275
+ // Annotate the CommonJS export names for ESM import in node:
276
+ 0 && (module.exports = {
277
+ derivePresetStartTimeFromDate,
278
+ getIsAutoClose,
279
+ getProductExtend,
280
+ getServiceStartTimeAndEndTime,
281
+ getSumCapacity,
282
+ getTimeObj
283
+ });
@@ -1,56 +1,55 @@
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/resourceErrors.ts
30
+ var resourceErrors_exports = {};
31
+ __export(resourceErrors_exports, {
32
+ getResourceErrors: () => getResourceErrors
5
33
  });
6
- exports.getResourceErrors = getResourceErrors;
7
- var _dayjs = _interopRequireDefault(require("dayjs"));
8
- var _serviceTimes = require("./serviceTimes");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /**
11
- * 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
12
- *
13
- * 与 info2 type 字段映射:
14
- * - `no_product` ↔ type='products'
15
- * - `time_out_of_range` ↔ type='time'
16
- * - `count_out_of_range` ↔ type='limit'
17
- * - `resource_unbound` ↔ type='unbound'
18
- *
19
- * OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
20
- */
21
-
22
- /**
23
- * 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
24
- *
25
- * 行为对齐:
26
- * 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
27
- * 2. 资源 null / 无 _extend → 返回 []。
28
- * 3. resource.usable=false 时:
29
- * - 没有 _extend.usableTime → `time_out_of_range`
30
- * - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
31
- * 4. resource.unbound=true → 追加 `resource_unbound`。
32
- * 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
33
- */
34
+ module.exports = __toCommonJS(resourceErrors_exports);
35
+ var import_dayjs = __toESM(require("dayjs"));
36
+ var import_serviceTimes = require("./serviceTimes");
34
37
  function getResourceErrors(resource, cacheItem) {
35
- if (!cacheItem?.id) {
36
- return [{
37
- reason: 'no_product',
38
- params: {}
39
- }];
38
+ var _a, _b, _c, _d;
39
+ if (!(cacheItem == null ? void 0 : cacheItem.id)) {
40
+ return [{ reason: "no_product", params: {} }];
40
41
  }
41
- if (!resource) return [];
42
+ if (!resource)
43
+ return [];
42
44
  const list = [];
43
45
  if (!resource.usable) {
44
- const {
45
- startDate,
46
- endDate
47
- } = (0, _serviceTimes.getServiceTimes)(cacheItem);
48
- const startText = startDate.format('hh:mm A');
49
- const endText = endDate.format('hh:mm A');
50
- const isCrossDay = (0, _dayjs.default)(endDate).isAfter(startDate, 'day');
51
- if (!resource._extend?.usableTime) {
46
+ const { startDate, endDate } = (0, import_serviceTimes.getServiceTimes)(cacheItem);
47
+ const startText = startDate.format("hh:mm A");
48
+ const endText = endDate.format("hh:mm A");
49
+ const isCrossDay = (0, import_dayjs.default)(endDate).isAfter(startDate, "day");
50
+ if (!((_a = resource._extend) == null ? void 0 : _a.usableTime)) {
52
51
  list.push({
53
- reason: 'time_out_of_range',
52
+ reason: "time_out_of_range",
54
53
  params: {
55
54
  labelText: resource.labelText,
56
55
  startText,
@@ -58,9 +57,9 @@ function getResourceErrors(resource, cacheItem) {
58
57
  isCrossDay
59
58
  }
60
59
  });
61
- } else if (!resource._extend?.usableTime?._extend?.isCountRange) {
60
+ } else if (!((_d = (_c = (_b = resource._extend) == null ? void 0 : _b.usableTime) == null ? void 0 : _c._extend) == null ? void 0 : _d.isCountRange)) {
62
61
  list.push({
63
- reason: 'count_out_of_range',
62
+ reason: "count_out_of_range",
64
63
  params: {
65
64
  labelText: resource.labelText,
66
65
  startText,
@@ -71,10 +70,11 @@ function getResourceErrors(resource, cacheItem) {
71
70
  }
72
71
  }
73
72
  if (resource.unbound) {
74
- list.push({
75
- reason: 'resource_unbound',
76
- params: {}
77
- });
73
+ list.push({ reason: "resource_unbound", params: {} });
78
74
  }
79
75
  return list;
80
- }
76
+ }
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ getResourceErrors
80
+ });