@pisell/pisellos 0.10.15 → 0.10.16

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