@pisell/pisellos 2.3.106 → 2.3.108

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 (69) hide show
  1. package/dist/modules/Discount/index.js +4 -1
  2. package/dist/modules/Discount/types.d.ts +10 -0
  3. package/dist/modules/OpenData/index.d.ts +15 -2
  4. package/dist/modules/OpenData/index.js +307 -19
  5. package/dist/modules/OpenData/types.d.ts +55 -0
  6. package/dist/modules/OpenData/types.js +7 -1
  7. package/dist/modules/OpenData/utils.d.ts +21 -1
  8. package/dist/modules/OpenData/utils.js +138 -0
  9. package/dist/modules/Order/index.d.ts +4 -2
  10. package/dist/modules/Order/index.js +69 -16
  11. package/dist/modules/Order/types.d.ts +13 -0
  12. package/dist/modules/Order/utils.d.ts +4 -1
  13. package/dist/modules/Order/utils.js +57 -3
  14. package/dist/plugins/request.d.ts +2 -1
  15. package/dist/plugins/request.js +4 -2
  16. package/dist/server/index.d.ts +14 -0
  17. package/dist/server/index.js +1732 -1285
  18. package/dist/server/modules/order/types.d.ts +50 -0
  19. package/dist/server/modules/order/types.js +2 -0
  20. package/dist/server/utils/small-ticket.d.ts +4 -1
  21. package/dist/server/utils/small-ticket.js +461 -96
  22. package/dist/solution/BaseSales/index.d.ts +7 -1
  23. package/dist/solution/BaseSales/index.js +128 -45
  24. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  25. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  26. package/dist/solution/BookingByStep/index.d.ts +1 -1
  27. package/dist/solution/BookingTicket/index.d.ts +8 -3
  28. package/dist/solution/BookingTicket/index.js +558 -443
  29. package/dist/solution/Sales/index.d.ts +16 -1
  30. package/dist/solution/Sales/index.js +338 -63
  31. package/dist/solution/Sales/types.d.ts +10 -0
  32. package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
  33. package/dist/solution/UnifiedBookingSales/index.js +526 -447
  34. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
  35. package/lib/modules/Discount/index.js +4 -1
  36. package/lib/modules/Discount/types.d.ts +10 -0
  37. package/lib/modules/OpenData/index.d.ts +15 -2
  38. package/lib/modules/OpenData/index.js +230 -3
  39. package/lib/modules/OpenData/types.d.ts +55 -0
  40. package/lib/modules/OpenData/types.js +9 -1
  41. package/lib/modules/OpenData/utils.d.ts +21 -1
  42. package/lib/modules/OpenData/utils.js +126 -0
  43. package/lib/modules/Order/index.d.ts +4 -2
  44. package/lib/modules/Order/index.js +52 -1
  45. package/lib/modules/Order/types.d.ts +13 -0
  46. package/lib/modules/Order/utils.d.ts +4 -1
  47. package/lib/modules/Order/utils.js +58 -1
  48. package/lib/plugins/request.d.ts +2 -1
  49. package/lib/plugins/request.js +3 -2
  50. package/lib/server/index.d.ts +14 -0
  51. package/lib/server/index.js +453 -105
  52. package/lib/server/modules/order/types.d.ts +50 -0
  53. package/lib/server/modules/order/types.js +1 -0
  54. package/lib/server/utils/small-ticket.d.ts +4 -1
  55. package/lib/server/utils/small-ticket.js +427 -72
  56. package/lib/solution/BaseSales/index.d.ts +7 -1
  57. package/lib/solution/BaseSales/index.js +90 -7
  58. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  59. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  60. package/lib/solution/BookingByStep/index.d.ts +1 -1
  61. package/lib/solution/BookingTicket/index.d.ts +8 -3
  62. package/lib/solution/BookingTicket/index.js +60 -15
  63. package/lib/solution/Sales/index.d.ts +16 -1
  64. package/lib/solution/Sales/index.js +168 -1
  65. package/lib/solution/Sales/types.d.ts +10 -0
  66. package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
  67. package/lib/solution/UnifiedBookingSales/index.js +44 -15
  68. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
  69. package/package.json +1 -1
@@ -37,6 +37,7 @@ import dayjs from 'dayjs';
37
37
  import { cloneDeep } from 'lodash-es';
38
38
  import { OpenDataModule } from "../../modules";
39
39
  import { isProductFlexibleDuration } from "../../modules/BookingContext/utils";
40
+ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from "../../modules/OpenData";
40
41
  import { getScheduleStartEndTimePoints } from "../../modules/Schedule/getDateIsInSchedule";
41
42
  import { AvailabilityError, createAvailabilityProjection, getProductTimeRanges as getProjectionProductTimeRanges, queryAvailabilityProjection, validateAvailabilitySelection } from "../../modules/ResourcePlanner";
42
43
  import { UnifiedBookingSalesHooks } from "./types";
@@ -47,7 +48,7 @@ import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/pl
47
48
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
48
49
  export * from "./types";
49
50
  export { AvailabilityError } from "../../modules/ResourcePlanner";
50
- var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability'];
51
+ var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents', 'basic', 'checkout', 'availability'];
51
52
  var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
52
53
  function normalizePositiveInteger(value) {
53
54
  var normalized = Number(value);
@@ -1314,9 +1315,6 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1314
1315
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
1315
1316
  _defineProperty(_assertThisInitialized(_this), "store", {});
1316
1317
  _defineProperty(_assertThisInitialized(_this), "unifiedProductCatalog", []);
1317
- _defineProperty(_assertThisInitialized(_this), "openDataTarget", null);
1318
- _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlight", null);
1319
- _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlightTarget", null);
1320
1318
  _defineProperty(_assertThisInitialized(_this), "availabilityRuntimeOffsetMinutes", null);
1321
1319
  _defineProperty(_assertThisInitialized(_this), "availabilityScheduleCatalog", null);
1322
1320
  _defineProperty(_assertThisInitialized(_this), "availabilityProjectionSequence", 0);
@@ -2168,7 +2166,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2168
2166
  key: "loadOpenData",
2169
2167
  value: (function () {
2170
2168
  var _loadOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
2171
- var businessCode, channel, target, cachedData, lastFetchedAt, openData;
2169
+ var businessCode, channel, target, cachedData, lastFetchedAt, request, openData;
2172
2170
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
2173
2171
  while (1) switch (_context11.prev = _context11.next) {
2174
2172
  case 0:
@@ -2190,55 +2188,67 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2190
2188
  cachedData = this.store.openData.getOpenData();
2191
2189
  lastFetchedAt = this.store.openData.getLastFetchedAt();
2192
2190
  if (!(!params.force && this.openDataTarget === target && cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
2193
- _context11.next = 11;
2191
+ _context11.next = 14;
2194
2192
  break;
2195
2193
  }
2194
+ if (!(typeof this.store.openData.ensureInvoiceTemplateSettings === 'function')) {
2195
+ _context11.next = 13;
2196
+ break;
2197
+ }
2198
+ _context11.next = 13;
2199
+ return this.store.openData.ensureInvoiceTemplateSettings(target);
2200
+ case 13:
2196
2201
  return _context11.abrupt("return", cachedData);
2197
- case 11:
2202
+ case 14:
2198
2203
  if (!this.loadOpenDataInFlight) {
2199
- _context11.next = 19;
2204
+ _context11.next = 22;
2200
2205
  break;
2201
2206
  }
2202
2207
  if (!(this.loadOpenDataInFlightTarget === target)) {
2203
- _context11.next = 16;
2208
+ _context11.next = 19;
2204
2209
  break;
2205
2210
  }
2206
- _context11.next = 15;
2207
- return this.loadOpenDataInFlight;
2208
- case 15:
2209
- return _context11.abrupt("return", _context11.sent);
2210
- case 16:
2211
2211
  _context11.next = 18;
2212
2212
  return this.loadOpenDataInFlight;
2213
2213
  case 18:
2214
- return _context11.abrupt("return", this.loadOpenData(params));
2214
+ return _context11.abrupt("return", _context11.sent);
2215
2215
  case 19:
2216
+ _context11.next = 21;
2217
+ return this.loadOpenDataInFlight;
2218
+ case 21:
2219
+ return _context11.abrupt("return", this.loadOpenData(params));
2220
+ case 22:
2216
2221
  this.loadOpenDataInFlightTarget = target;
2217
- this.loadOpenDataInFlight = this.store.openData.fetchOpenData({
2222
+ request = this.store.openData.fetchOpenData({
2218
2223
  scope: 'board',
2219
2224
  target: target,
2220
2225
  section_code: [].concat(OPEN_DATA_SECTION_CODES)
2221
2226
  });
2222
- _context11.prev = 21;
2223
- _context11.next = 24;
2224
- return this.loadOpenDataInFlight;
2225
- case 24:
2227
+ this.loadOpenDataInFlight = request;
2228
+ _context11.prev = 25;
2229
+ _context11.next = 28;
2230
+ return request;
2231
+ case 28:
2226
2232
  openData = _context11.sent;
2227
- this.openDataTarget = target;
2228
- this.otherParams.openData = openData;
2229
- this.otherParams.businessCode = businessCode;
2230
- this.otherParams.channel = channel;
2233
+ if (this.loadOpenDataInFlight === request) {
2234
+ this.openDataTarget = target;
2235
+ this.otherParams.openData = openData;
2236
+ this.otherParams.businessCode = businessCode;
2237
+ this.otherParams.channel = channel;
2238
+ }
2231
2239
  return _context11.abrupt("return", openData);
2232
- case 30:
2233
- _context11.prev = 30;
2234
- this.loadOpenDataInFlight = null;
2235
- this.loadOpenDataInFlightTarget = null;
2236
- return _context11.finish(30);
2240
+ case 31:
2241
+ _context11.prev = 31;
2242
+ if (this.loadOpenDataInFlight === request) {
2243
+ this.loadOpenDataInFlight = null;
2244
+ this.loadOpenDataInFlightTarget = null;
2245
+ }
2246
+ return _context11.finish(31);
2237
2247
  case 34:
2238
2248
  case "end":
2239
2249
  return _context11.stop();
2240
2250
  }
2241
- }, _callee11, this, [[21,, 30, 34]]);
2251
+ }, _callee11, this, [[25,, 31, 34]]);
2242
2252
  }));
2243
2253
  function loadOpenData(_x7) {
2244
2254
  return _loadOpenData.apply(this, arguments);
@@ -2249,8 +2259,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2249
2259
  key: "getOpenData",
2250
2260
  value: function () {
2251
2261
  var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
2252
- var _this$otherParams18, _this$otherParams19, _this$store$openData;
2253
- var businessCode, channel, target, cachedData;
2262
+ var _this$otherParams18, _this$otherParams19;
2263
+ var businessCode, channel;
2254
2264
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
2255
2265
  while (1) switch (_context12.prev = _context12.next) {
2256
2266
  case 0:
@@ -2262,19 +2272,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2262
2272
  }
2263
2273
  return _context12.abrupt("return", null);
2264
2274
  case 4:
2265
- target = "".concat(businessCode, "+").concat(channel);
2266
- cachedData = ((_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData()) || null;
2267
- if (!(cachedData && this.openDataTarget === target)) {
2268
- _context12.next = 8;
2269
- break;
2270
- }
2271
- return _context12.abrupt("return", cachedData);
2272
- case 8:
2273
2275
  return _context12.abrupt("return", this.loadOpenData({
2274
2276
  businessCode: businessCode,
2275
2277
  channel: channel
2276
2278
  }));
2277
- case 9:
2279
+ case 5:
2278
2280
  case "end":
2279
2281
  return _context12.stop();
2280
2282
  }
@@ -2485,22 +2487,99 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2485
2487
  return _resolveProductAllergyRequirement.apply(this, arguments);
2486
2488
  }
2487
2489
  return resolveProductAllergyRequirement;
2490
+ }())
2491
+ }, {
2492
+ key: "clearOpenDataCache",
2493
+ value: function clearOpenDataCache() {
2494
+ this.openDataTarget = null;
2495
+ this.loadOpenDataInFlight = null;
2496
+ this.loadOpenDataInFlightTarget = null;
2497
+ _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "clearOpenDataCache", this).call(this);
2498
+ }
2499
+ }, {
2500
+ key: "getInvoiceLayoutConfig",
2501
+ value: function () {
2502
+ var _getInvoiceLayoutConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
2503
+ var openData;
2504
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2505
+ while (1) switch (_context17.prev = _context17.next) {
2506
+ case 0:
2507
+ _context17.next = 2;
2508
+ return this.getOpenData();
2509
+ case 2:
2510
+ openData = _context17.sent;
2511
+ if (!(!openData || !this.store.openData)) {
2512
+ _context17.next = 5;
2513
+ break;
2514
+ }
2515
+ return _context17.abrupt("return", getDefaultInvoiceLayoutConfig());
2516
+ case 5:
2517
+ return _context17.abrupt("return", this.store.openData.getInvoiceLayoutConfig());
2518
+ case 6:
2519
+ case "end":
2520
+ return _context17.stop();
2521
+ }
2522
+ }, _callee17, this);
2523
+ }));
2524
+ function getInvoiceLayoutConfig() {
2525
+ return _getInvoiceLayoutConfig.apply(this, arguments);
2526
+ }
2527
+ return getInvoiceLayoutConfig;
2528
+ }()
2529
+ }, {
2530
+ key: "getInvoiceTemplateSettings",
2531
+ value: function () {
2532
+ var _getInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
2533
+ var openData;
2534
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2535
+ while (1) switch (_context18.prev = _context18.next) {
2536
+ case 0:
2537
+ _context18.next = 2;
2538
+ return this.getOpenData();
2539
+ case 2:
2540
+ openData = _context18.sent;
2541
+ if (!(!openData || !this.store.openData)) {
2542
+ _context18.next = 5;
2543
+ break;
2544
+ }
2545
+ return _context18.abrupt("return", getDefaultInvoiceTemplateSettings());
2546
+ case 5:
2547
+ return _context18.abrupt("return", this.store.openData.getInvoiceTemplateSettings());
2548
+ case 6:
2549
+ case "end":
2550
+ return _context18.stop();
2551
+ }
2552
+ }, _callee18, this);
2553
+ }));
2554
+ function getInvoiceTemplateSettings() {
2555
+ return _getInvoiceTemplateSettings.apply(this, arguments);
2556
+ }
2557
+ return getInvoiceTemplateSettings;
2488
2558
  }()
2559
+ }, {
2560
+ key: "isInvoiceOpenDataCacheCurrent",
2561
+ value: function isInvoiceOpenDataCacheCurrent() {
2562
+ var _this$otherParams24, _this$otherParams25;
2563
+ var businessCode = String(((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.businessCode) || '').trim();
2564
+ var channel = String(((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.channel) || '').trim();
2565
+ if (!businessCode || !channel) return false;
2566
+ return this.openDataTarget === "".concat(businessCode, "+").concat(channel);
2567
+ }
2568
+
2489
2569
  /**
2490
2570
  * Load a resource policy without depending on the legacy appointmentBooking solution.
2491
2571
  */
2492
- )
2493
2572
  }, {
2494
2573
  key: "getProtocol",
2495
2574
  value: (function () {
2496
- var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(policyId) {
2575
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(policyId) {
2497
2576
  var normalizedPolicyId, policyUrl;
2498
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2499
- while (1) switch (_context17.prev = _context17.next) {
2577
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2578
+ while (1) switch (_context19.prev = _context19.next) {
2500
2579
  case 0:
2501
2580
  normalizedPolicyId = String(policyId !== null && policyId !== void 0 ? policyId : '').trim();
2502
2581
  if (normalizedPolicyId) {
2503
- _context17.next = 3;
2582
+ _context19.next = 3;
2504
2583
  break;
2505
2584
  }
2506
2585
  throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
@@ -2509,12 +2588,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2509
2588
  if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
2510
2589
  policyUrl = 'policy';
2511
2590
  }
2512
- return _context17.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
2591
+ return _context19.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
2513
2592
  case 6:
2514
2593
  case "end":
2515
- return _context17.stop();
2594
+ return _context19.stop();
2516
2595
  }
2517
- }, _callee17, this);
2596
+ }, _callee19, this);
2518
2597
  }));
2519
2598
  function getProtocol(_x10) {
2520
2599
  return _getProtocol.apply(this, arguments);
@@ -2529,27 +2608,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2529
2608
  }, {
2530
2609
  key: "loadProducts",
2531
2610
  value: (function () {
2532
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
2611
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2533
2612
  var params,
2534
2613
  options,
2535
2614
  schedule_date,
2536
2615
  schedule_datetime,
2537
2616
  result,
2538
- _args18 = arguments;
2539
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2540
- while (1) switch (_context18.prev = _context18.next) {
2617
+ _args20 = arguments;
2618
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2619
+ while (1) switch (_context20.prev = _context20.next) {
2541
2620
  case 0:
2542
- params = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
2543
- options = _args18.length > 1 ? _args18[1] : undefined;
2621
+ params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
2622
+ options = _args20.length > 1 ? _args20[1] : undefined;
2544
2623
  if (this.store.products) {
2545
- _context18.next = 4;
2624
+ _context20.next = 4;
2546
2625
  break;
2547
2626
  }
2548
2627
  throw new Error('[UnifiedBookingSales] products 模块未初始化');
2549
2628
  case 4:
2550
2629
  schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
2551
2630
  schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
2552
- _context18.next = 8;
2631
+ _context20.next = 8;
2553
2632
  return this.store.products.loadProducts(_objectSpread(_objectSpread({
2554
2633
  with_count: ['bundleGroup', 'optionGroup'],
2555
2634
  with_schedule: 1
@@ -2559,17 +2638,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2559
2638
  cacheId: this.cacheId
2560
2639
  }), options);
2561
2640
  case 8:
2562
- result = _context18.sent;
2641
+ result = _context20.sent;
2563
2642
  this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
2564
- _context18.next = 12;
2643
+ _context20.next = 12;
2565
2644
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
2566
2645
  case 12:
2567
- return _context18.abrupt("return", result);
2646
+ return _context20.abrupt("return", result);
2568
2647
  case 13:
2569
2648
  case "end":
2570
- return _context18.stop();
2649
+ return _context20.stop();
2571
2650
  }
2572
- }, _callee18, this);
2651
+ }, _callee20, this);
2573
2652
  }));
2574
2653
  function loadProducts() {
2575
2654
  return _loadProducts.apply(this, arguments);
@@ -2579,25 +2658,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2579
2658
  }, {
2580
2659
  key: "queryProducts",
2581
2660
  value: function () {
2582
- var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2661
+ var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2583
2662
  var params,
2584
- _args19 = arguments;
2585
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2586
- while (1) switch (_context19.prev = _context19.next) {
2663
+ _args21 = arguments;
2664
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2665
+ while (1) switch (_context21.prev = _context21.next) {
2587
2666
  case 0:
2588
- params = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
2667
+ params = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
2589
2668
  if (this.store.products) {
2590
- _context19.next = 3;
2669
+ _context21.next = 3;
2591
2670
  break;
2592
2671
  }
2593
2672
  throw new Error('[UnifiedBookingSales] products 模块未初始化');
2594
2673
  case 3:
2595
- return _context19.abrupt("return", this.store.products.queryProducts(params));
2674
+ return _context21.abrupt("return", this.store.products.queryProducts(params));
2596
2675
  case 4:
2597
2676
  case "end":
2598
- return _context19.stop();
2677
+ return _context21.stop();
2599
2678
  }
2600
- }, _callee19, this);
2679
+ }, _callee21, this);
2601
2680
  }));
2602
2681
  function queryProducts() {
2603
2682
  return _queryProducts.apply(this, arguments);
@@ -2607,22 +2686,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2607
2686
  }, {
2608
2687
  key: "loadScheduleAvailableDate",
2609
2688
  value: (function () {
2610
- var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2611
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2612
- while (1) switch (_context20.prev = _context20.next) {
2689
+ var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2690
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2691
+ while (1) switch (_context22.prev = _context22.next) {
2613
2692
  case 0:
2614
2693
  if (this.store.schedule) {
2615
- _context20.next = 2;
2694
+ _context22.next = 2;
2616
2695
  break;
2617
2696
  }
2618
2697
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
2619
2698
  case 2:
2620
- return _context20.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
2699
+ return _context22.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
2621
2700
  case 3:
2622
2701
  case "end":
2623
- return _context20.stop();
2702
+ return _context22.stop();
2624
2703
  }
2625
- }, _callee20, this);
2704
+ }, _callee22, this);
2626
2705
  }));
2627
2706
  function loadScheduleAvailableDate(_x11) {
2628
2707
  return _loadScheduleAvailableDate.apply(this, arguments);
@@ -2638,15 +2717,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2638
2717
  }, {
2639
2718
  key: "loadProductsByScheduleDate",
2640
2719
  value: (function () {
2641
- var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2720
+ var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2642
2721
  var _this$store$schedule$, _this$store$schedule, _this$store$schedule$2, _this$store$schedule2, _this$store$schedule$3, _this$store$schedule3, _this$store$schedule$4, _this$store$schedule4;
2643
2722
  var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator, _step, productId, result;
2644
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2645
- while (1) switch (_context21.prev = _context21.next) {
2723
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2724
+ while (1) switch (_context23.prev = _context23.next) {
2646
2725
  case 0:
2647
2726
  date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
2648
2727
  if (this.store.schedule) {
2649
- _context21.next = 3;
2728
+ _context23.next = 3;
2650
2729
  break;
2651
2730
  }
2652
2731
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
@@ -2657,10 +2736,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2657
2736
  });
2658
2737
  hasOtherProducts = (((_this$store$schedule$2 = (_this$store$schedule2 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$2 === void 0 ? void 0 : _this$store$schedule$2.call(_this$store$schedule2)) || []).length > 0;
2659
2738
  if (!(!hasCachedDate && !hasOtherProducts)) {
2660
- _context21.next = 9;
2739
+ _context23.next = 9;
2661
2740
  break;
2662
2741
  }
2663
- _context21.next = 9;
2742
+ _context23.next = 9;
2664
2743
  return this.loadScheduleAvailableDate({
2665
2744
  startDate: date,
2666
2745
  endDate: date,
@@ -2680,45 +2759,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2680
2759
  return !productIdFilter || productIdFilter.has(String(id));
2681
2760
  });
2682
2761
  if (availableProductIds.length) {
2683
- _context21.next = 17;
2762
+ _context23.next = 17;
2684
2763
  break;
2685
2764
  }
2686
2765
  this.unifiedProductCatalog = [];
2687
- _context21.next = 16;
2766
+ _context23.next = 16;
2688
2767
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
2689
2768
  case 16:
2690
- return _context21.abrupt("return", []);
2769
+ return _context23.abrupt("return", []);
2691
2770
  case 17:
2692
- _context21.next = 19;
2771
+ _context23.next = 19;
2693
2772
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
2694
2773
  product_ids: availableProductIds,
2695
2774
  schedule_date: date
2696
2775
  }));
2697
2776
  case 19:
2698
- products = _context21.sent;
2777
+ products = _context23.sent;
2699
2778
  if (!(products.length || availableProductIds.length <= 1)) {
2700
- _context21.next = 22;
2779
+ _context23.next = 22;
2701
2780
  break;
2702
2781
  }
2703
- return _context21.abrupt("return", products);
2782
+ return _context23.abrupt("return", products);
2704
2783
  case 22:
2705
2784
  fallbackProducts = [];
2706
2785
  _iterator = _createForOfIteratorHelper(availableProductIds);
2707
- _context21.prev = 24;
2786
+ _context23.prev = 24;
2708
2787
  _iterator.s();
2709
2788
  case 26:
2710
2789
  if ((_step = _iterator.n()).done) {
2711
- _context21.next = 34;
2790
+ _context23.next = 34;
2712
2791
  break;
2713
2792
  }
2714
2793
  productId = _step.value;
2715
- _context21.next = 30;
2794
+ _context23.next = 30;
2716
2795
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
2717
2796
  product_ids: [productId],
2718
2797
  schedule_date: date
2719
2798
  }));
2720
2799
  case 30:
2721
- result = _context21.sent;
2800
+ result = _context23.sent;
2722
2801
  result.forEach(function (product) {
2723
2802
  var _id;
2724
2803
  var id = (_id = product === null || product === void 0 ? void 0 : product.id) !== null && _id !== void 0 ? _id : product === null || product === void 0 ? void 0 : product.product_id;
@@ -2730,30 +2809,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2730
2809
  }
2731
2810
  });
2732
2811
  case 32:
2733
- _context21.next = 26;
2812
+ _context23.next = 26;
2734
2813
  break;
2735
2814
  case 34:
2736
- _context21.next = 39;
2815
+ _context23.next = 39;
2737
2816
  break;
2738
2817
  case 36:
2739
- _context21.prev = 36;
2740
- _context21.t0 = _context21["catch"](24);
2741
- _iterator.e(_context21.t0);
2818
+ _context23.prev = 36;
2819
+ _context23.t0 = _context23["catch"](24);
2820
+ _iterator.e(_context23.t0);
2742
2821
  case 39:
2743
- _context21.prev = 39;
2822
+ _context23.prev = 39;
2744
2823
  _iterator.f();
2745
- return _context21.finish(39);
2824
+ return _context23.finish(39);
2746
2825
  case 42:
2747
2826
  this.unifiedProductCatalog = [].concat(fallbackProducts);
2748
- _context21.next = 45;
2827
+ _context23.next = 45;
2749
2828
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
2750
2829
  case 45:
2751
- return _context21.abrupt("return", fallbackProducts);
2830
+ return _context23.abrupt("return", fallbackProducts);
2752
2831
  case 46:
2753
2832
  case "end":
2754
- return _context21.stop();
2833
+ return _context23.stop();
2755
2834
  }
2756
- }, _callee21, this, [[24, 36, 39, 42]]);
2835
+ }, _callee23, this, [[24, 36, 39, 42]]);
2757
2836
  }));
2758
2837
  function loadProductsByScheduleDate(_x12) {
2759
2838
  return _loadProductsByScheduleDate.apply(this, arguments);
@@ -2808,7 +2887,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2808
2887
  }, {
2809
2888
  key: "applyPlannerDiscounts",
2810
2889
  value: (function () {
2811
- var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2890
+ var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2812
2891
  var _params$customerId;
2813
2892
  var params,
2814
2893
  tempOrder,
@@ -2825,24 +2904,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2825
2904
  discount,
2826
2905
  discountId,
2827
2906
  nextTempOrder,
2828
- _args22 = arguments;
2829
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2830
- while (1) switch (_context22.prev = _context22.next) {
2907
+ _args24 = arguments;
2908
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2909
+ while (1) switch (_context24.prev = _context24.next) {
2831
2910
  case 0:
2832
- params = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
2911
+ params = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
2833
2912
  tempOrder = this.getTempOrder();
2834
2913
  requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
2835
2914
  parsedCustomerId = Number(requestedCustomerId);
2836
2915
  customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
2837
- _context22.next = 7;
2916
+ _context24.next = 7;
2838
2917
  return this.getSummary();
2839
2918
  case 7:
2840
- summaryBefore = _context22.sent;
2919
+ summaryBefore = _context24.sent;
2841
2920
  if (customerId) {
2842
- _context22.next = 10;
2921
+ _context24.next = 10;
2843
2922
  break;
2844
2923
  }
2845
- return _context22.abrupt("return", buildPlannerDiscountResult({
2924
+ return _context24.abrupt("return", buildPlannerDiscountResult({
2846
2925
  customerId: null,
2847
2926
  discountList: this.getDiscountList(),
2848
2927
  products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
@@ -2851,7 +2930,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2851
2930
  status: 'no_customer'
2852
2931
  }));
2853
2932
  case 10:
2854
- _context22.next = 12;
2933
+ _context24.next = 12;
2855
2934
  return this.loadDiscountConfig({
2856
2935
  customerId: customerId,
2857
2936
  action: 'create'
@@ -2863,7 +2942,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2863
2942
  return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
2864
2943
  });
2865
2944
  if (!preferredDiscount) {
2866
- _context22.next = 40;
2945
+ _context24.next = 40;
2867
2946
  break;
2868
2947
  }
2869
2948
  // A requested card is an explicit UI choice, not a best-effort preference. Clear prior
@@ -2875,98 +2954,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2875
2954
  return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
2876
2955
  });
2877
2956
  _iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
2878
- _context22.prev = 18;
2957
+ _context24.prev = 18;
2879
2958
  _iterator2.s();
2880
2959
  case 20:
2881
2960
  if ((_step2 = _iterator2.n()).done) {
2882
- _context22.next = 28;
2961
+ _context24.next = 28;
2883
2962
  break;
2884
2963
  }
2885
2964
  discount = _step2.value;
2886
2965
  discountId = Number(resolvePlannerDiscountId(discount));
2887
2966
  if (!Number.isFinite(discountId)) {
2888
- _context22.next = 26;
2967
+ _context24.next = 26;
2889
2968
  break;
2890
2969
  }
2891
- _context22.next = 26;
2970
+ _context24.next = 26;
2892
2971
  return this.setDiscountSelected({
2893
2972
  discountId: discountId,
2894
2973
  isSelected: false
2895
2974
  });
2896
2975
  case 26:
2897
- _context22.next = 20;
2976
+ _context24.next = 20;
2898
2977
  break;
2899
2978
  case 28:
2900
- _context22.next = 33;
2979
+ _context24.next = 33;
2901
2980
  break;
2902
2981
  case 30:
2903
- _context22.prev = 30;
2904
- _context22.t0 = _context22["catch"](18);
2905
- _iterator2.e(_context22.t0);
2982
+ _context24.prev = 30;
2983
+ _context24.t0 = _context24["catch"](18);
2984
+ _iterator2.e(_context24.t0);
2906
2985
  case 33:
2907
- _context22.prev = 33;
2986
+ _context24.prev = 33;
2908
2987
  _iterator2.f();
2909
- return _context22.finish(33);
2988
+ return _context24.finish(33);
2910
2989
  case 36:
2911
- _context22.next = 38;
2990
+ _context24.next = 38;
2912
2991
  return this.setDiscountSelected({
2913
2992
  discountId: Number(preferredId),
2914
2993
  isSelected: true
2915
2994
  });
2916
2995
  case 38:
2917
- _context22.next = 49;
2996
+ _context24.next = 49;
2918
2997
  break;
2919
2998
  case 40:
2920
2999
  if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
2921
- _context22.next = 46;
3000
+ _context24.next = 46;
2922
3001
  break;
2923
3002
  }
2924
3003
  if (!(params.applyBestDiscount !== false)) {
2925
- _context22.next = 44;
3004
+ _context24.next = 44;
2926
3005
  break;
2927
3006
  }
2928
- _context22.next = 44;
3007
+ _context24.next = 44;
2929
3008
  return this.bestDiscount();
2930
3009
  case 44:
2931
- _context22.next = 49;
3010
+ _context24.next = 49;
2932
3011
  break;
2933
3012
  case 46:
2934
3013
  if (!(params.applyBestDiscount !== false)) {
2935
- _context22.next = 49;
3014
+ _context24.next = 49;
2936
3015
  break;
2937
3016
  }
2938
- _context22.next = 49;
3017
+ _context24.next = 49;
2939
3018
  return this.bestDiscount();
2940
3019
  case 49:
2941
3020
  nextTempOrder = this.getTempOrder();
2942
- _context22.t1 = buildPlannerDiscountResult;
2943
- _context22.t2 = customerId;
2944
- _context22.t3 = this.getDiscountList();
2945
- _context22.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
2946
- _context22.t5 = summaryBefore;
2947
- _context22.next = 57;
3021
+ _context24.t1 = buildPlannerDiscountResult;
3022
+ _context24.t2 = customerId;
3023
+ _context24.t3 = this.getDiscountList();
3024
+ _context24.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
3025
+ _context24.t5 = summaryBefore;
3026
+ _context24.next = 57;
2948
3027
  return this.getSummary();
2949
3028
  case 57:
2950
- _context22.t6 = _context22.sent;
2951
- _context22.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
2952
- _context22.t8 = preferredDiscountId;
2953
- _context22.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
2954
- _context22.t10 = {
2955
- customerId: _context22.t2,
2956
- discountList: _context22.t3,
2957
- products: _context22.t4,
2958
- summaryBefore: _context22.t5,
2959
- summaryAfter: _context22.t6,
2960
- status: _context22.t7,
2961
- preferredDiscountId: _context22.t8,
2962
- preferredDiscountFound: _context22.t9
3029
+ _context24.t6 = _context24.sent;
3030
+ _context24.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
3031
+ _context24.t8 = preferredDiscountId;
3032
+ _context24.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
3033
+ _context24.t10 = {
3034
+ customerId: _context24.t2,
3035
+ discountList: _context24.t3,
3036
+ products: _context24.t4,
3037
+ summaryBefore: _context24.t5,
3038
+ summaryAfter: _context24.t6,
3039
+ status: _context24.t7,
3040
+ preferredDiscountId: _context24.t8,
3041
+ preferredDiscountFound: _context24.t9
2963
3042
  };
2964
- return _context22.abrupt("return", (0, _context22.t1)(_context22.t10));
3043
+ return _context24.abrupt("return", (0, _context24.t1)(_context24.t10));
2965
3044
  case 63:
2966
3045
  case "end":
2967
- return _context22.stop();
3046
+ return _context24.stop();
2968
3047
  }
2969
- }, _callee22, this, [[18, 30, 33, 36]]);
3048
+ }, _callee24, this, [[18, 30, 33, 36]]);
2970
3049
  }));
2971
3050
  function applyPlannerDiscounts() {
2972
3051
  return _applyPlannerDiscounts.apply(this, arguments);
@@ -3004,27 +3083,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3004
3083
  }, {
3005
3084
  key: "removeExistingStagedLines",
3006
3085
  value: (function () {
3007
- var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(ownershipKey) {
3086
+ var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(ownershipKey) {
3008
3087
  var _this$getTempOrder;
3009
3088
  var existingLines;
3010
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3011
- while (1) switch (_context23.prev = _context23.next) {
3089
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3090
+ while (1) switch (_context25.prev = _context25.next) {
3012
3091
  case 0:
3013
3092
  existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
3014
3093
  var _product$metadata4;
3015
3094
  return (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4[ownershipKey]) === true;
3016
3095
  });
3017
3096
  if (!(existingLines.length > 0)) {
3018
- _context23.next = 4;
3097
+ _context25.next = 4;
3019
3098
  break;
3020
3099
  }
3021
- _context23.next = 4;
3100
+ _context25.next = 4;
3022
3101
  return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
3023
3102
  case 4:
3024
3103
  case "end":
3025
- return _context23.stop();
3104
+ return _context25.stop();
3026
3105
  }
3027
- }, _callee23, this);
3106
+ }, _callee25, this);
3028
3107
  }));
3029
3108
  function removeExistingStagedLines(_x13) {
3030
3109
  return _removeExistingStagedLines.apply(this, arguments);
@@ -3034,25 +3113,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3034
3113
  }, {
3035
3114
  key: "stageProducts",
3036
3115
  value: function () {
3037
- var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params, ownershipKey) {
3116
+ var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params, ownershipKey) {
3038
3117
  var _params$rawProducts;
3039
3118
  var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
3040
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3041
- while (1) switch (_context24.prev = _context24.next) {
3119
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3120
+ while (1) switch (_context26.prev = _context26.next) {
3042
3121
  case 0:
3043
3122
  productIds = params.productIds || [];
3044
3123
  if (productIds.length) {
3045
- _context24.next = 3;
3124
+ _context26.next = 3;
3046
3125
  break;
3047
3126
  }
3048
- return _context24.abrupt("return", this.getTempOrder());
3127
+ return _context26.abrupt("return", this.getTempOrder());
3049
3128
  case 3:
3050
3129
  if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
3051
- _context24.next = 7;
3130
+ _context26.next = 7;
3052
3131
  break;
3053
3132
  }
3054
3133
  this.unifiedProductCatalog = params.rawProducts;
3055
- _context24.next = 12;
3134
+ _context26.next = 12;
3056
3135
  break;
3057
3136
  case 7:
3058
3137
  existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
@@ -3063,15 +3142,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3063
3142
  return !existingIds.has(String(id));
3064
3143
  });
3065
3144
  if (!(missingIds.length || params.productLoadParams)) {
3066
- _context24.next = 12;
3145
+ _context26.next = 12;
3067
3146
  break;
3068
3147
  }
3069
- _context24.next = 12;
3148
+ _context26.next = 12;
3070
3149
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
3071
3150
  product_ids: productIds.map(Number).filter(Number.isFinite)
3072
3151
  }));
3073
3152
  case 12:
3074
- _context24.next = 14;
3153
+ _context26.next = 14;
3075
3154
  return this.removeExistingStagedLines(ownershipKey);
3076
3155
  case 14:
3077
3156
  productIdSet = new Set(productIds.map(function (id) {
@@ -3084,28 +3163,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3084
3163
  _i = 0, _arr = selectedProducts;
3085
3164
  case 17:
3086
3165
  if (!(_i < _arr.length)) {
3087
- _context24.next = 26;
3166
+ _context26.next = 26;
3088
3167
  break;
3089
3168
  }
3090
3169
  sourceProduct = _arr[_i];
3091
3170
  productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
3092
3171
  if (!productInput) {
3093
- _context24.next = 23;
3172
+ _context26.next = 23;
3094
3173
  break;
3095
3174
  }
3096
- _context24.next = 23;
3175
+ _context26.next = 23;
3097
3176
  return this.addProductToOrder(productInput);
3098
3177
  case 23:
3099
3178
  _i++;
3100
- _context24.next = 17;
3179
+ _context26.next = 17;
3101
3180
  break;
3102
3181
  case 26:
3103
- return _context24.abrupt("return", this.getTempOrder());
3182
+ return _context26.abrupt("return", this.getTempOrder());
3104
3183
  case 27:
3105
3184
  case "end":
3106
- return _context24.stop();
3185
+ return _context26.stop();
3107
3186
  }
3108
- }, _callee24, this);
3187
+ }, _callee26, this);
3109
3188
  }));
3110
3189
  function stageProducts(_x14, _x15) {
3111
3190
  return _stageProducts.apply(this, arguments);
@@ -3119,16 +3198,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3119
3198
  }, {
3120
3199
  key: "stageRetailProducts",
3121
3200
  value: (function () {
3122
- var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
3123
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3124
- while (1) switch (_context25.prev = _context25.next) {
3201
+ var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3202
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3203
+ while (1) switch (_context27.prev = _context27.next) {
3125
3204
  case 0:
3126
- return _context25.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
3205
+ return _context27.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
3127
3206
  case 1:
3128
3207
  case "end":
3129
- return _context25.stop();
3208
+ return _context27.stop();
3130
3209
  }
3131
- }, _callee25, this);
3210
+ }, _callee27, this);
3132
3211
  }));
3133
3212
  function stageRetailProducts(_x16) {
3134
3213
  return _stageRetailProducts.apply(this, arguments);
@@ -3144,15 +3223,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3144
3223
  }, {
3145
3224
  key: "addRetailProduct",
3146
3225
  value: (function () {
3147
- var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
3226
+ var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3148
3227
  var _params$quantity, _ref44, _params$productId, _params$product, _params$product2;
3149
3228
  var quantity, productId, sourceProduct, products, orderProduct;
3150
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3151
- while (1) switch (_context26.prev = _context26.next) {
3229
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3230
+ while (1) switch (_context28.prev = _context28.next) {
3152
3231
  case 0:
3153
3232
  quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
3154
3233
  if (!(!Number.isFinite(quantity) || quantity <= 0)) {
3155
- _context26.next = 3;
3234
+ _context28.next = 3;
3156
3235
  break;
3157
3236
  }
3158
3237
  throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
@@ -3166,22 +3245,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3166
3245
  });
3167
3246
  }
3168
3247
  if (!(!sourceProduct && productId !== undefined && productId !== null)) {
3169
- _context26.next = 11;
3248
+ _context28.next = 11;
3170
3249
  break;
3171
3250
  }
3172
- _context26.next = 9;
3251
+ _context28.next = 9;
3173
3252
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
3174
3253
  product_ids: [Number(productId)].filter(Number.isFinite)
3175
3254
  }));
3176
3255
  case 9:
3177
- products = _context26.sent;
3256
+ products = _context28.sent;
3178
3257
  sourceProduct = products.find(function (product) {
3179
3258
  var _product$id4;
3180
3259
  return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
3181
3260
  });
3182
3261
  case 11:
3183
3262
  if (sourceProduct) {
3184
- _context26.next = 13;
3263
+ _context28.next = 13;
3185
3264
  break;
3186
3265
  }
3187
3266
  throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
@@ -3190,17 +3269,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3190
3269
  quantity: quantity
3191
3270
  }), 'unified_booking_sales_retail');
3192
3271
  if (orderProduct) {
3193
- _context26.next = 16;
3272
+ _context28.next = 16;
3194
3273
  break;
3195
3274
  }
3196
3275
  throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
3197
3276
  case 16:
3198
- return _context26.abrupt("return", this.addProductToOrder(orderProduct));
3277
+ return _context28.abrupt("return", this.addProductToOrder(orderProduct));
3199
3278
  case 17:
3200
3279
  case "end":
3201
- return _context26.stop();
3280
+ return _context28.stop();
3202
3281
  }
3203
- }, _callee26, this);
3282
+ }, _callee28, this);
3204
3283
  }));
3205
3284
  function addRetailProduct(_x17) {
3206
3285
  return _addRetailProduct.apply(this, arguments);
@@ -3390,46 +3469,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3390
3469
  }, {
3391
3470
  key: "loadAvailabilityProducts",
3392
3471
  value: function () {
3393
- var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3472
+ var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3394
3473
  var _prepare$catalogScope,
3395
3474
  _prepare$catalogScope2,
3396
3475
  _this5 = this,
3397
3476
  _prepare$resourceIds;
3398
3477
  var prepare, dateRange, explicitProductIds, rawProducts, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
3399
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3400
- while (1) switch (_context27.prev = _context27.next) {
3478
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3479
+ while (1) switch (_context29.prev = _context29.next) {
3401
3480
  case 0:
3402
3481
  prepare = params.prepare, dateRange = params.dateRange;
3403
3482
  explicitProductIds = prepare.productIds || [];
3404
3483
  rawProducts = [];
3405
3484
  if (!Array.isArray(prepare.rawProducts)) {
3406
- _context27.next = 8;
3485
+ _context29.next = 8;
3407
3486
  break;
3408
3487
  }
3409
3488
  rawProducts = prepare.rawProducts;
3410
3489
  this.unifiedProductCatalog = _toConsumableArray(rawProducts);
3411
- _context27.next = 34;
3490
+ _context29.next = 34;
3412
3491
  break;
3413
3492
  case 8:
3414
3493
  if (!(explicitProductIds.length > 0)) {
3415
- _context27.next = 14;
3494
+ _context29.next = 14;
3416
3495
  break;
3417
3496
  }
3418
- _context27.next = 11;
3497
+ _context29.next = 11;
3419
3498
  return this.loadProducts({
3420
3499
  product_ids: explicitProductIds,
3421
3500
  schedule_date: dateRange.startDate
3422
3501
  });
3423
3502
  case 11:
3424
- rawProducts = _context27.sent;
3425
- _context27.next = 34;
3503
+ rawProducts = _context29.sent;
3504
+ _context29.next = 34;
3426
3505
  break;
3427
3506
  case 14:
3428
3507
  if (!(((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'schedule')) {
3429
- _context27.next = 30;
3508
+ _context29.next = 30;
3430
3509
  break;
3431
3510
  }
3432
- _context27.next = 17;
3511
+ _context29.next = 17;
3433
3512
  return this.loadScheduleAvailableDate({
3434
3513
  startDate: dateRange.startDate,
3435
3514
  endDate: dateRange.endDate,
@@ -3445,44 +3524,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3445
3524
  });
3446
3525
  productIds = uniqueAvailabilityIds([].concat(_toConsumableArray(scheduleProductIds), _toConsumableArray(((_this$store$schedule$7 = (_this$store$schedule7 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$7 === void 0 ? void 0 : _this$store$schedule$7.call(_this$store$schedule7)) || [])));
3447
3526
  if (!(productIds.length > 0)) {
3448
- _context27.next = 27;
3527
+ _context29.next = 27;
3449
3528
  break;
3450
3529
  }
3451
3530
  assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
3452
- _context27.next = 24;
3531
+ _context29.next = 24;
3453
3532
  return this.loadProducts({
3454
3533
  product_ids: productIds,
3455
3534
  schedule_date: dateRange.startDate
3456
3535
  });
3457
3536
  case 24:
3458
- rawProducts = _context27.sent;
3459
- _context27.next = 28;
3537
+ rawProducts = _context29.sent;
3538
+ _context29.next = 28;
3460
3539
  break;
3461
3540
  case 27:
3462
3541
  this.unifiedProductCatalog = [];
3463
3542
  case 28:
3464
- _context27.next = 34;
3543
+ _context29.next = 34;
3465
3544
  break;
3466
3545
  case 30:
3467
3546
  if (!(((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList')) {
3468
- _context27.next = 34;
3547
+ _context29.next = 34;
3469
3548
  break;
3470
3549
  }
3471
- _context27.next = 33;
3550
+ _context29.next = 33;
3472
3551
  return this.loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
3473
3552
  schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
3474
3553
  }));
3475
3554
  case 33:
3476
- rawProducts = _context27.sent;
3555
+ rawProducts = _context29.sent;
3477
3556
  case 34:
3478
3557
  normalized = rawProducts.map(function (product) {
3479
3558
  return normalizeProductForAvailability(product, params.scheduleList, _this5.getAvailabilityRuntimeOffsetMinutes());
3480
3559
  });
3481
3560
  if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
3482
- _context27.next = 37;
3561
+ _context29.next = 37;
3483
3562
  break;
3484
3563
  }
3485
- return _context27.abrupt("return", normalized.filter(function (product) {
3564
+ return _context29.abrupt("return", normalized.filter(function (product) {
3486
3565
  var _product$requirementG2;
3487
3566
  return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
3488
3567
  var _group$resourceIds3;
@@ -3495,14 +3574,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3495
3574
  }));
3496
3575
  case 37:
3497
3576
  productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
3498
- return _context27.abrupt("return", productIdSet ? normalized.filter(function (product) {
3577
+ return _context29.abrupt("return", productIdSet ? normalized.filter(function (product) {
3499
3578
  return productIdSet.has(String(product.id));
3500
3579
  }) : normalized);
3501
3580
  case 39:
3502
3581
  case "end":
3503
- return _context27.stop();
3582
+ return _context29.stop();
3504
3583
  }
3505
- }, _callee27, this);
3584
+ }, _callee29, this);
3506
3585
  }));
3507
3586
  function loadAvailabilityProducts(_x18) {
3508
3587
  return _loadAvailabilityProducts.apply(this, arguments);
@@ -3517,12 +3596,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3517
3596
  }, {
3518
3597
  key: "fetchAvailabilityResourcesV2",
3519
3598
  value: (function () {
3520
- var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3599
+ var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3521
3600
  var response, data;
3522
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3523
- while (1) switch (_context28.prev = _context28.next) {
3601
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3602
+ while (1) switch (_context30.prev = _context30.next) {
3524
3603
  case 0:
3525
- _context28.next = 2;
3604
+ _context30.next = 2;
3526
3605
  return this.request.get('/schedule/resource/list/v2', {
3527
3606
  start_date: params.dateRange.startDate,
3528
3607
  end_date: params.dateRange.endDate,
@@ -3532,26 +3611,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3532
3611
  useCache: false
3533
3612
  });
3534
3613
  case 2:
3535
- response = _context28.sent;
3614
+ response = _context30.sent;
3536
3615
  data = response === null || response === void 0 ? void 0 : response.data;
3537
3616
  if (!Array.isArray(data)) {
3538
- _context28.next = 6;
3617
+ _context30.next = 6;
3539
3618
  break;
3540
3619
  }
3541
- return _context28.abrupt("return", data);
3620
+ return _context30.abrupt("return", data);
3542
3621
  case 6:
3543
3622
  if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
3544
- _context28.next = 8;
3623
+ _context30.next = 8;
3545
3624
  break;
3546
3625
  }
3547
- return _context28.abrupt("return", data.list);
3626
+ return _context30.abrupt("return", data.list);
3548
3627
  case 8:
3549
- return _context28.abrupt("return", []);
3628
+ return _context30.abrupt("return", []);
3550
3629
  case 9:
3551
3630
  case "end":
3552
- return _context28.stop();
3631
+ return _context30.stop();
3553
3632
  }
3554
- }, _callee28, this);
3633
+ }, _callee30, this);
3555
3634
  }));
3556
3635
  function fetchAvailabilityResourcesV2(_x19) {
3557
3636
  return _fetchAvailabilityResourcesV.apply(this, arguments);
@@ -3561,17 +3640,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3561
3640
  }, {
3562
3641
  key: "fetchAndPublishAvailabilityResourcesV2",
3563
3642
  value: function () {
3564
- var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3643
+ var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3565
3644
  var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
3566
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3567
- while (1) switch (_context29.prev = _context29.next) {
3645
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3646
+ while (1) switch (_context31.prev = _context31.next) {
3568
3647
  case 0:
3569
3648
  normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
3570
3649
  if (!(normalizedResourceIds.length === 0)) {
3571
- _context29.next = 3;
3650
+ _context31.next = 3;
3572
3651
  break;
3573
3652
  }
3574
- return _context29.abrupt("return", []);
3653
+ return _context31.abrupt("return", []);
3575
3654
  case 3:
3576
3655
  scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
3577
3656
  cacheParams = {
@@ -3581,7 +3660,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3581
3660
  };
3582
3661
  cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
3583
3662
  if (!cachedRawResources) {
3584
- _context29.next = 9;
3663
+ _context31.next = 9;
3585
3664
  break;
3586
3665
  }
3587
3666
  if (params.useCacheOnHit) {
@@ -3593,21 +3672,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3593
3672
  console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
3594
3673
  });
3595
3674
  }
3596
- return _context29.abrupt("return", cachedRawResources);
3675
+ return _context31.abrupt("return", cachedRawResources);
3597
3676
  case 9:
3598
- _context29.next = 11;
3677
+ _context31.next = 11;
3599
3678
  return this.refreshAvailabilityRemoteResourceQuery({
3600
3679
  timezone: params.timezone,
3601
3680
  dateRange: params.dateRange,
3602
3681
  resourceIds: normalizedResourceIds
3603
3682
  });
3604
3683
  case 11:
3605
- return _context29.abrupt("return", _context29.sent);
3684
+ return _context31.abrupt("return", _context31.sent);
3606
3685
  case 12:
3607
3686
  case "end":
3608
- return _context29.stop();
3687
+ return _context31.stop();
3609
3688
  }
3610
- }, _callee29, this);
3689
+ }, _callee31, this);
3611
3690
  }));
3612
3691
  function fetchAndPublishAvailabilityResourcesV2(_x20) {
3613
3692
  return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
@@ -3617,17 +3696,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3617
3696
  }, {
3618
3697
  key: "refreshAvailabilityRemoteResourceQuery",
3619
3698
  value: function () {
3620
- var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3699
+ var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3621
3700
  var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
3622
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3623
- while (1) switch (_context30.prev = _context30.next) {
3701
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3702
+ while (1) switch (_context32.prev = _context32.next) {
3624
3703
  case 0:
3625
3704
  normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
3626
3705
  if (!(normalizedResourceIds.length === 0)) {
3627
- _context30.next = 3;
3706
+ _context32.next = 3;
3628
3707
  break;
3629
3708
  }
3630
- return _context30.abrupt("return", []);
3709
+ return _context32.abrupt("return", []);
3631
3710
  case 3:
3632
3711
  queryKey = this.buildAvailabilityRemoteResourceQueryKey({
3633
3712
  timezone: params.timezone,
@@ -3637,13 +3716,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3637
3716
  epoch = this.availabilityRemoteResourceEpoch;
3638
3717
  existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
3639
3718
  if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
3640
- _context30.next = 10;
3719
+ _context32.next = 10;
3641
3720
  break;
3642
3721
  }
3643
- _context30.next = 9;
3722
+ _context32.next = 9;
3644
3723
  return existing.promise;
3645
3724
  case 9:
3646
- return _context30.abrupt("return", _context30.sent);
3725
+ return _context32.abrupt("return", _context32.sent);
3647
3726
  case 10:
3648
3727
  this.availabilityRemoteResourceQuerySequence += 1;
3649
3728
  writeVersion = this.availabilityRemoteResourceQuerySequence;
@@ -3655,11 +3734,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3655
3734
  epoch: epoch,
3656
3735
  promise: promise
3657
3736
  });
3658
- _context30.prev = 14;
3659
- _context30.next = 17;
3737
+ _context32.prev = 14;
3738
+ _context32.next = 17;
3660
3739
  return promise;
3661
3740
  case 17:
3662
- rawResources = _context30.sent;
3741
+ rawResources = _context32.sent;
3663
3742
  if (epoch === this.availabilityRemoteResourceEpoch) {
3664
3743
  this.availabilityRemoteOccupancyCache.publish({
3665
3744
  scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
@@ -3670,19 +3749,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3670
3749
  version: writeVersion
3671
3750
  });
3672
3751
  }
3673
- return _context30.abrupt("return", rawResources);
3752
+ return _context32.abrupt("return", rawResources);
3674
3753
  case 20:
3675
- _context30.prev = 20;
3754
+ _context32.prev = 20;
3676
3755
  current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
3677
3756
  if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
3678
3757
  this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
3679
3758
  }
3680
- return _context30.finish(20);
3759
+ return _context32.finish(20);
3681
3760
  case 24:
3682
3761
  case "end":
3683
- return _context30.stop();
3762
+ return _context32.stop();
3684
3763
  }
3685
- }, _callee30, this, [[14,, 20, 24]]);
3764
+ }, _callee32, this, [[14,, 20, 24]]);
3686
3765
  }));
3687
3766
  function refreshAvailabilityRemoteResourceQuery(_x21) {
3688
3767
  return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
@@ -3692,26 +3771,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3692
3771
  }, {
3693
3772
  key: "loadAvailabilityResources",
3694
3773
  value: function () {
3695
- var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3774
+ var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
3696
3775
  var resourceIds, cachedRawResources, rawResources;
3697
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3698
- while (1) switch (_context31.prev = _context31.next) {
3776
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3777
+ while (1) switch (_context33.prev = _context33.next) {
3699
3778
  case 0:
3700
3779
  resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
3701
3780
  if (!(resourceIds.length === 0)) {
3702
- _context31.next = 3;
3781
+ _context33.next = 3;
3703
3782
  break;
3704
3783
  }
3705
- return _context31.abrupt("return", {
3784
+ return _context33.abrupt("return", {
3706
3785
  resources: [],
3707
3786
  resourceOccupancies: []
3708
3787
  });
3709
3788
  case 3:
3710
3789
  if (!Array.isArray(params.rawResources)) {
3711
- _context31.next = 5;
3790
+ _context33.next = 5;
3712
3791
  break;
3713
3792
  }
3714
- return _context31.abrupt("return", buildAvailabilityResourcesFromV2({
3793
+ return _context33.abrupt("return", buildAvailabilityResourcesFromV2({
3715
3794
  rawResources: params.rawResources,
3716
3795
  scheduleList: params.scheduleList,
3717
3796
  dateRange: params.dateRange,
@@ -3719,7 +3798,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3719
3798
  }));
3720
3799
  case 5:
3721
3800
  if (!(params.fetchPolicy === 'cache_only')) {
3722
- _context31.next = 10;
3801
+ _context33.next = 10;
3723
3802
  break;
3724
3803
  }
3725
3804
  cachedRawResources = this.availabilityRemoteOccupancyCache.read({
@@ -3728,22 +3807,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3728
3807
  dateRange: params.dateRange
3729
3808
  });
3730
3809
  if (!cachedRawResources) {
3731
- _context31.next = 9;
3810
+ _context33.next = 9;
3732
3811
  break;
3733
3812
  }
3734
- return _context31.abrupt("return", buildAvailabilityResourcesFromV2({
3813
+ return _context33.abrupt("return", buildAvailabilityResourcesFromV2({
3735
3814
  rawResources: cachedRawResources,
3736
3815
  scheduleList: params.scheduleList,
3737
3816
  dateRange: params.dateRange,
3738
3817
  fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
3739
3818
  }));
3740
3819
  case 9:
3741
- return _context31.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
3820
+ return _context33.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
3742
3821
  resources: [],
3743
3822
  resourceOccupancies: []
3744
3823
  });
3745
3824
  case 10:
3746
- _context31.next = 12;
3825
+ _context33.next = 12;
3747
3826
  return this.fetchAndPublishAvailabilityResourcesV2({
3748
3827
  timezone: params.timezone,
3749
3828
  dateRange: params.dateRange,
@@ -3751,8 +3830,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3751
3830
  useCacheOnHit: true
3752
3831
  });
3753
3832
  case 12:
3754
- rawResources = _context31.sent;
3755
- return _context31.abrupt("return", buildAvailabilityResourcesFromV2({
3833
+ rawResources = _context33.sent;
3834
+ return _context33.abrupt("return", buildAvailabilityResourcesFromV2({
3756
3835
  rawResources: rawResources,
3757
3836
  scheduleList: params.scheduleList,
3758
3837
  dateRange: params.dateRange,
@@ -3760,9 +3839,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3760
3839
  }));
3761
3840
  case 14:
3762
3841
  case "end":
3763
- return _context31.stop();
3842
+ return _context33.stop();
3764
3843
  }
3765
- }, _callee31, this);
3844
+ }, _callee33, this);
3766
3845
  }));
3767
3846
  function loadAvailabilityResources(_x22) {
3768
3847
  return _loadAvailabilityResources.apply(this, arguments);
@@ -3995,7 +4074,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3995
4074
  }, {
3996
4075
  key: "buildAvailabilityProjectionSnapshot",
3997
4076
  value: function () {
3998
- var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4077
+ var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3999
4078
  var _this8 = this;
4000
4079
  var options,
4001
4080
  normalizedPrepareParams,
@@ -4017,11 +4096,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4017
4096
  durationCandidateAnchorAt,
4018
4097
  orderRevision,
4019
4098
  projection,
4020
- _args32 = arguments;
4021
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
4022
- while (1) switch (_context32.prev = _context32.next) {
4099
+ _args34 = arguments;
4100
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4101
+ while (1) switch (_context34.prev = _context34.next) {
4023
4102
  case 0:
4024
- options = _args32.length > 1 && _args32[1] !== undefined ? _args32[1] : {};
4103
+ options = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
4025
4104
  normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
4026
4105
  timezoneLabel = String(normalizedPrepareParams.timezone);
4027
4106
  dateRange = normalizedPrepareParams.dateRange;
@@ -4035,15 +4114,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4035
4114
  scheduleList: scheduleList,
4036
4115
  businessHours: businessHours
4037
4116
  });
4038
- _context32.next = 11;
4117
+ _context34.next = 11;
4039
4118
  return this.loadAvailabilityProducts({
4040
4119
  prepare: normalizedPrepareParams,
4041
4120
  dateRange: dateRange,
4042
4121
  scheduleList: scheduleList
4043
4122
  });
4044
4123
  case 11:
4045
- products = _context32.sent;
4046
- _context32.next = 14;
4124
+ products = _context34.sent;
4125
+ _context34.next = 14;
4047
4126
  return this.loadAvailabilityResources({
4048
4127
  timezone: timezoneLabel,
4049
4128
  dateRange: dateRange,
@@ -4055,7 +4134,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4055
4134
  fallbackResources: options.fallbackResources
4056
4135
  });
4057
4136
  case 14:
4058
- loadedResources = _context32.sent;
4137
+ loadedResources = _context34.sent;
4059
4138
  tempOrder = this.getTempOrder();
4060
4139
  exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
4061
4140
  injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
@@ -4101,16 +4180,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4101
4180
  prepareParams: normalizedPrepareParams,
4102
4181
  durationCandidateAnchorAt: durationCandidateAnchorAt
4103
4182
  });
4104
- return _context32.abrupt("return", {
4183
+ return _context34.abrupt("return", {
4105
4184
  projection: projection,
4106
4185
  prepareParams: normalizedPrepareParams,
4107
4186
  orderRevision: orderRevision
4108
4187
  });
4109
4188
  case 26:
4110
4189
  case "end":
4111
- return _context32.stop();
4190
+ return _context34.stop();
4112
4191
  }
4113
- }, _callee32, this);
4192
+ }, _callee34, this);
4114
4193
  }));
4115
4194
  function buildAvailabilityProjectionSnapshot(_x23) {
4116
4195
  return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
@@ -4120,10 +4199,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4120
4199
  }, {
4121
4200
  key: "getSharedPreparedAvailabilitySnapshot",
4122
4201
  value: function () {
4123
- var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4202
+ var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4124
4203
  var lifecycleGeneration, normalizedParams, hasRawInputs, prepareKey, snapshot, existing, promise, _snapshot, current;
4125
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
4126
- while (1) switch (_context33.prev = _context33.next) {
4204
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4205
+ while (1) switch (_context35.prev = _context35.next) {
4127
4206
  case 0:
4128
4207
  lifecycleGeneration = this.availabilityLifecycleGeneration;
4129
4208
  normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
@@ -4142,15 +4221,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4142
4221
  }
4143
4222
  })) : this.buildAvailabilityPrepareKey(normalizedParams);
4144
4223
  if (!hasRawInputs) {
4145
- _context33.next = 11;
4224
+ _context35.next = 11;
4146
4225
  break;
4147
4226
  }
4148
- _context33.next = 7;
4227
+ _context35.next = 7;
4149
4228
  return this.buildAvailabilityProjectionSnapshot(normalizedParams);
4150
4229
  case 7:
4151
- snapshot = _context33.sent;
4230
+ snapshot = _context35.sent;
4152
4231
  if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
4153
- _context33.next = 10;
4232
+ _context35.next = 10;
4154
4233
  break;
4155
4234
  }
4156
4235
  throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
@@ -4159,7 +4238,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4159
4238
  currentLifecycleGeneration: this.availabilityLifecycleGeneration
4160
4239
  });
4161
4240
  case 10:
4162
- return _context33.abrupt("return", {
4241
+ return _context35.abrupt("return", {
4163
4242
  prepareKey: prepareKey,
4164
4243
  snapshot: snapshot
4165
4244
  });
@@ -4173,13 +4252,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4173
4252
  promise: promise
4174
4253
  });
4175
4254
  }
4176
- _context33.prev = 14;
4177
- _context33.next = 17;
4255
+ _context35.prev = 14;
4256
+ _context35.next = 17;
4178
4257
  return promise;
4179
4258
  case 17:
4180
- _snapshot = _context33.sent;
4259
+ _snapshot = _context35.sent;
4181
4260
  if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
4182
- _context33.next = 20;
4261
+ _context35.next = 20;
4183
4262
  break;
4184
4263
  }
4185
4264
  throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
@@ -4188,22 +4267,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4188
4267
  currentLifecycleGeneration: this.availabilityLifecycleGeneration
4189
4268
  });
4190
4269
  case 20:
4191
- return _context33.abrupt("return", {
4270
+ return _context35.abrupt("return", {
4192
4271
  prepareKey: prepareKey,
4193
4272
  snapshot: _snapshot
4194
4273
  });
4195
4274
  case 21:
4196
- _context33.prev = 21;
4275
+ _context35.prev = 21;
4197
4276
  current = this.availabilityPrepareInFlight.get(prepareKey);
4198
4277
  if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
4199
4278
  this.availabilityPrepareInFlight.delete(prepareKey);
4200
4279
  }
4201
- return _context33.finish(21);
4280
+ return _context35.finish(21);
4202
4281
  case 25:
4203
4282
  case "end":
4204
- return _context33.stop();
4283
+ return _context35.stop();
4205
4284
  }
4206
- }, _callee33, this, [[14,, 21, 25]]);
4285
+ }, _callee35, this, [[14,, 21, 25]]);
4207
4286
  }));
4208
4287
  function getSharedPreparedAvailabilitySnapshot(_x24) {
4209
4288
  return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
@@ -4213,49 +4292,49 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4213
4292
  }, {
4214
4293
  key: "refreshAvailabilityContextProjection",
4215
4294
  value: function () {
4216
- var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4295
+ var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4217
4296
  var _this9 = this;
4218
4297
  var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
4219
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4220
- while (1) switch (_context35.prev = _context35.next) {
4298
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4299
+ while (1) switch (_context37.prev = _context37.next) {
4221
4300
  case 0:
4222
4301
  existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
4223
4302
  if (!existingInFlight) {
4224
- _context35.next = 5;
4303
+ _context37.next = 5;
4225
4304
  break;
4226
4305
  }
4227
- _context35.next = 4;
4306
+ _context37.next = 4;
4228
4307
  return existingInFlight;
4229
4308
  case 4:
4230
- return _context35.abrupt("return", _context35.sent);
4309
+ return _context37.abrupt("return", _context37.sent);
4231
4310
  case 5:
4232
4311
  context = this.getAvailabilityContextEntry(params.contextId);
4233
4312
  expectedVersion = context.activeVersion;
4234
4313
  expectedRefreshNonce = context.refreshNonce;
4235
4314
  expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
4236
- refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
4315
+ refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
4237
4316
  var snapshot, currentContext, projectionEntry;
4238
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4239
- while (1) switch (_context34.prev = _context34.next) {
4317
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4318
+ while (1) switch (_context36.prev = _context36.next) {
4240
4319
  case 0:
4241
- _context34.next = 2;
4320
+ _context36.next = 2;
4242
4321
  return _this9.buildAvailabilityProjectionSnapshot(_this9.cloneAvailabilityPrepareParams(context.prepareParams), {
4243
4322
  durationCandidateAnchorAt: context.durationCandidateAnchorAt
4244
4323
  });
4245
4324
  case 2:
4246
- snapshot = _context34.sent;
4325
+ snapshot = _context36.sent;
4247
4326
  currentContext = _this9.availabilityContextRegistry.get(params.contextId);
4248
4327
  if (currentContext) {
4249
- _context34.next = 6;
4328
+ _context36.next = 6;
4250
4329
  break;
4251
4330
  }
4252
- return _context34.abrupt("return", null);
4331
+ return _context36.abrupt("return", null);
4253
4332
  case 6:
4254
4333
  if (!(expectedLifecycleGeneration !== _this9.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
4255
- _context34.next = 8;
4334
+ _context36.next = 8;
4256
4335
  break;
4257
4336
  }
4258
- return _context34.abrupt("return", null);
4337
+ return _context36.abrupt("return", null);
4259
4338
  case 8:
4260
4339
  projectionEntry = _this9.storeAvailabilityProjectionEntry({
4261
4340
  contextId: currentContext.contextId,
@@ -4265,7 +4344,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4265
4344
  orderRevision: snapshot.orderRevision,
4266
4345
  incrementVersion: true
4267
4346
  });
4268
- _context34.next = 11;
4347
+ _context36.next = 11;
4269
4348
  return _this9.emitAvailabilityDiagnostic({
4270
4349
  action: 'refresh',
4271
4350
  contextId: currentContext.contextId,
@@ -4277,31 +4356,31 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4277
4356
  reason: params.reason
4278
4357
  });
4279
4358
  case 11:
4280
- return _context34.abrupt("return", projectionEntry);
4359
+ return _context36.abrupt("return", projectionEntry);
4281
4360
  case 12:
4282
4361
  case "end":
4283
- return _context34.stop();
4362
+ return _context36.stop();
4284
4363
  }
4285
- }, _callee34);
4364
+ }, _callee36);
4286
4365
  }))();
4287
4366
  this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
4288
- _context35.prev = 11;
4289
- _context35.next = 14;
4367
+ _context37.prev = 11;
4368
+ _context37.next = 14;
4290
4369
  return refreshPromise;
4291
4370
  case 14:
4292
- return _context35.abrupt("return", _context35.sent);
4371
+ return _context37.abrupt("return", _context37.sent);
4293
4372
  case 15:
4294
- _context35.prev = 15;
4373
+ _context37.prev = 15;
4295
4374
  current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
4296
4375
  if (current === refreshPromise) {
4297
4376
  this.availabilityProjectionRefreshInFlight.delete(params.contextId);
4298
4377
  }
4299
- return _context35.finish(15);
4378
+ return _context37.finish(15);
4300
4379
  case 19:
4301
4380
  case "end":
4302
- return _context35.stop();
4381
+ return _context37.stop();
4303
4382
  }
4304
- }, _callee35, this, [[11,, 15, 19]]);
4383
+ }, _callee37, this, [[11,, 15, 19]]);
4305
4384
  }));
4306
4385
  function refreshAvailabilityContextProjection(_x25) {
4307
4386
  return _refreshAvailabilityContextProjection.apply(this, arguments);
@@ -4311,53 +4390,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4311
4390
  }, {
4312
4391
  key: "ensureAvailabilityContextProjection",
4313
4392
  value: function () {
4314
- var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(contextId, reason) {
4393
+ var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(contextId, reason) {
4315
4394
  var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
4316
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4317
- while (1) switch (_context36.prev = _context36.next) {
4395
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4396
+ while (1) switch (_context38.prev = _context38.next) {
4318
4397
  case 0:
4319
4398
  retries = 0;
4320
4399
  case 1:
4321
4400
  if (!(retries < 3)) {
4322
- _context36.next = 19;
4401
+ _context38.next = 19;
4323
4402
  break;
4324
4403
  }
4325
4404
  context = this.getAvailabilityContextEntry(contextId);
4326
4405
  currentOrderRevision = this.getCurrentOrderRevision();
4327
4406
  projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
4328
4407
  if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
4329
- _context36.next = 7;
4408
+ _context38.next = 7;
4330
4409
  break;
4331
4410
  }
4332
- return _context36.abrupt("return", {
4411
+ return _context38.abrupt("return", {
4333
4412
  context: context,
4334
4413
  projectionEntry: projectionEntry,
4335
4414
  refreshed: false
4336
4415
  });
4337
4416
  case 7:
4338
- _context36.next = 9;
4417
+ _context38.next = 9;
4339
4418
  return this.refreshAvailabilityContextProjection({
4340
4419
  contextId: contextId,
4341
4420
  reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
4342
4421
  previousOrderRevision: context.lastKnownOrderRevision
4343
4422
  });
4344
4423
  case 9:
4345
- refreshedProjectionEntry = _context36.sent;
4424
+ refreshedProjectionEntry = _context38.sent;
4346
4425
  if (refreshedProjectionEntry) {
4347
- _context36.next = 13;
4426
+ _context38.next = 13;
4348
4427
  break;
4349
4428
  }
4350
4429
  retries += 1;
4351
- return _context36.abrupt("continue", 1);
4430
+ return _context38.abrupt("continue", 1);
4352
4431
  case 13:
4353
4432
  if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
4354
- _context36.next = 16;
4433
+ _context38.next = 16;
4355
4434
  break;
4356
4435
  }
4357
4436
  retries += 1;
4358
- return _context36.abrupt("continue", 1);
4437
+ return _context38.abrupt("continue", 1);
4359
4438
  case 16:
4360
- return _context36.abrupt("return", {
4439
+ return _context38.abrupt("return", {
4361
4440
  context: this.getAvailabilityContextEntry(contextId),
4362
4441
  projectionEntry: refreshedProjectionEntry,
4363
4442
  refreshed: true
@@ -4369,9 +4448,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4369
4448
  });
4370
4449
  case 20:
4371
4450
  case "end":
4372
- return _context36.stop();
4451
+ return _context38.stop();
4373
4452
  }
4374
- }, _callee36, this);
4453
+ }, _callee38, this);
4375
4454
  }));
4376
4455
  function ensureAvailabilityContextProjection(_x26, _x27) {
4377
4456
  return _ensureAvailabilityContextProjection.apply(this, arguments);
@@ -4381,18 +4460,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4381
4460
  }, {
4382
4461
  key: "tryAcquireAvailabilityCommitLock",
4383
4462
  value: function () {
4384
- var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId) {
4463
+ var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(contextId) {
4385
4464
  var _currentContext$activ;
4386
4465
  var _waitingContext$activ, waitingContext, currentContext;
4387
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4388
- while (1) switch (_context37.prev = _context37.next) {
4466
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4467
+ while (1) switch (_context39.prev = _context39.next) {
4389
4468
  case 0:
4390
4469
  if (!this.availabilityCommitLocks.has(contextId)) {
4391
- _context37.next = 5;
4470
+ _context39.next = 5;
4392
4471
  break;
4393
4472
  }
4394
4473
  waitingContext = this.availabilityContextRegistry.get(contextId);
4395
- _context37.next = 4;
4474
+ _context39.next = 4;
4396
4475
  return this.emitAvailabilityDiagnostic({
4397
4476
  action: 'commit_lock_wait',
4398
4477
  contextId: contextId,
@@ -4409,7 +4488,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4409
4488
  case 5:
4410
4489
  this.availabilityCommitLocks.add(contextId);
4411
4490
  currentContext = this.availabilityContextRegistry.get(contextId);
4412
- _context37.next = 9;
4491
+ _context39.next = 9;
4413
4492
  return this.emitAvailabilityDiagnostic({
4414
4493
  action: 'commit_lock_acquired',
4415
4494
  contextId: contextId,
@@ -4421,9 +4500,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4421
4500
  });
4422
4501
  case 9:
4423
4502
  case "end":
4424
- return _context37.stop();
4503
+ return _context39.stop();
4425
4504
  }
4426
- }, _callee37, this);
4505
+ }, _callee39, this);
4427
4506
  }));
4428
4507
  function tryAcquireAvailabilityCommitLock(_x28) {
4429
4508
  return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
@@ -4433,15 +4512,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4433
4512
  }, {
4434
4513
  key: "releaseAvailabilityCommitLock",
4435
4514
  value: function () {
4436
- var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(contextId) {
4515
+ var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(contextId) {
4437
4516
  var _releasedContext$acti;
4438
4517
  var releasedContext;
4439
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4440
- while (1) switch (_context38.prev = _context38.next) {
4518
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4519
+ while (1) switch (_context40.prev = _context40.next) {
4441
4520
  case 0:
4442
4521
  this.availabilityCommitLocks.delete(contextId);
4443
4522
  releasedContext = this.availabilityContextRegistry.get(contextId);
4444
- _context38.next = 4;
4523
+ _context40.next = 4;
4445
4524
  return this.emitAvailabilityDiagnostic({
4446
4525
  action: 'commit_lock_released',
4447
4526
  contextId: contextId,
@@ -4453,9 +4532,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4453
4532
  });
4454
4533
  case 4:
4455
4534
  case "end":
4456
- return _context38.stop();
4535
+ return _context40.stop();
4457
4536
  }
4458
- }, _callee38, this);
4537
+ }, _callee40, this);
4459
4538
  }));
4460
4539
  function releaseAvailabilityCommitLock(_x29) {
4461
4540
  return _releaseAvailabilityCommitLock.apply(this, arguments);
@@ -4465,20 +4544,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4465
4544
  }, {
4466
4545
  key: "prepareAvailabilityProjection",
4467
4546
  value: (function () {
4468
- var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
4547
+ var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
4469
4548
  var paramsWithDefaults, _yield$this$getShared, prepareKey, snapshot, contextId, projectionEntry, context, handle, payload;
4470
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4471
- while (1) switch (_context39.prev = _context39.next) {
4549
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4550
+ while (1) switch (_context41.prev = _context41.next) {
4472
4551
  case 0:
4473
4552
  this.assertAvailabilityPrepareParams(params);
4474
- _context39.next = 3;
4553
+ _context41.next = 3;
4475
4554
  return this.resolveAvailabilityPrepareDefaults(params);
4476
4555
  case 3:
4477
- paramsWithDefaults = _context39.sent;
4478
- _context39.next = 6;
4556
+ paramsWithDefaults = _context41.sent;
4557
+ _context41.next = 6;
4479
4558
  return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
4480
4559
  case 6:
4481
- _yield$this$getShared = _context39.sent;
4560
+ _yield$this$getShared = _context41.sent;
4482
4561
  prepareKey = _yield$this$getShared.prepareKey;
4483
4562
  snapshot = _yield$this$getShared.snapshot;
4484
4563
  contextId = this.createAvailabilityContextId();
@@ -4499,7 +4578,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4499
4578
  refreshed: false,
4500
4579
  reason: 'prepare'
4501
4580
  };
4502
- _context39.next = 16;
4581
+ _context41.next = 16;
4503
4582
  return this.emitAvailabilityDiagnostic({
4504
4583
  action: 'prepare',
4505
4584
  contextId: contextId,
@@ -4510,15 +4589,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4510
4589
  reason: 'prepare'
4511
4590
  });
4512
4591
  case 16:
4513
- _context39.next = 18;
4592
+ _context41.next = 18;
4514
4593
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
4515
4594
  case 18:
4516
- return _context39.abrupt("return", handle);
4595
+ return _context41.abrupt("return", handle);
4517
4596
  case 19:
4518
4597
  case "end":
4519
- return _context39.stop();
4598
+ return _context41.stop();
4520
4599
  }
4521
- }, _callee39, this);
4600
+ }, _callee41, this);
4522
4601
  }));
4523
4602
  function prepareAvailabilityProjection(_x30) {
4524
4603
  return _prepareAvailabilityProjection.apply(this, arguments);
@@ -4528,9 +4607,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4528
4607
  }, {
4529
4608
  key: "getProductTimeRanges",
4530
4609
  value: (function () {
4531
- var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(contextId) {
4610
+ var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(contextId) {
4532
4611
  var _this$otherParams$pla,
4533
- _this$otherParams24,
4612
+ _this$otherParams26,
4534
4613
  _this10 = this;
4535
4614
  var request,
4536
4615
  _yield$this$ensureAva,
@@ -4539,23 +4618,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4539
4618
  contextVersion,
4540
4619
  isPosAvailabilityRequest,
4541
4620
  allowOutsideOperatingHoursForRequestedStartTimes,
4542
- _args40 = arguments;
4543
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4544
- while (1) switch (_context40.prev = _context40.next) {
4621
+ _args42 = arguments;
4622
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4623
+ while (1) switch (_context42.prev = _context42.next) {
4545
4624
  case 0:
4546
- request = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {};
4547
- _context40.next = 3;
4625
+ request = _args42.length > 1 && _args42[1] !== undefined ? _args42[1] : {};
4626
+ _context42.next = 3;
4548
4627
  return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
4549
4628
  case 3:
4550
- _yield$this$ensureAva = _context40.sent;
4629
+ _yield$this$ensureAva = _context42.sent;
4551
4630
  context = _yield$this$ensureAva.context;
4552
4631
  projectionEntry = _yield$this$ensureAva.projectionEntry;
4553
4632
  contextVersion = context.activeVersion;
4554
- isPosAvailabilityRequest = String((_this$otherParams$pla = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos';
4633
+ isPosAvailabilityRequest = String((_this$otherParams$pla = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos';
4555
4634
  allowOutsideOperatingHoursForRequestedStartTimes = isPosAvailabilityRequest && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
4556
4635
  return Array.isArray(startTimes) && startTimes.length > 0;
4557
4636
  });
4558
- return _context40.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
4637
+ return _context42.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
4559
4638
  allowOutsideOperatingHoursForRequestedStartTimes: true
4560
4639
  } : {}), {
4561
4640
  evaluatedAt: this.getAvailabilityRuntimeDateTime(),
@@ -4571,9 +4650,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4571
4650
  }));
4572
4651
  case 10:
4573
4652
  case "end":
4574
- return _context40.stop();
4653
+ return _context42.stop();
4575
4654
  }
4576
- }, _callee40, this);
4655
+ }, _callee42, this);
4577
4656
  }));
4578
4657
  function getProductTimeRanges(_x31) {
4579
4658
  return _getProductTimeRanges.apply(this, arguments);
@@ -4583,21 +4662,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4583
4662
  }, {
4584
4663
  key: "queryBookingAvailability",
4585
4664
  value: (function () {
4586
- var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(contextId, request) {
4587
- var _this$otherParams$pla2, _this$otherParams25;
4665
+ var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(contextId, request) {
4666
+ var _this$otherParams$pla2, _this$otherParams27;
4588
4667
  var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
4589
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4590
- while (1) switch (_context41.prev = _context41.next) {
4668
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4669
+ while (1) switch (_context43.prev = _context43.next) {
4591
4670
  case 0:
4592
- _context41.next = 2;
4671
+ _context43.next = 2;
4593
4672
  return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
4594
4673
  case 2:
4595
- _yield$this$ensureAva2 = _context41.sent;
4674
+ _yield$this$ensureAva2 = _context43.sent;
4596
4675
  context = _yield$this$ensureAva2.context;
4597
4676
  projectionEntry = _yield$this$ensureAva2.projectionEntry;
4598
4677
  refreshed = _yield$this$ensureAva2.refreshed;
4599
4678
  this.assertContextualQueryFreshness(context, request);
4600
- isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4679
+ isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4601
4680
  result = queryAvailabilityProjection(projectionEntry.projection, request, {
4602
4681
  useExactDurationCandidateMinute: isPosAvailabilityRequest,
4603
4682
  allowExcludedScheduleDateOverride: isPosAvailabilityRequest
@@ -4628,16 +4707,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4628
4707
  });
4629
4708
  })
4630
4709
  }) : result;
4631
- return _context41.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
4710
+ return _context43.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
4632
4711
  contextId: context.contextId,
4633
4712
  contextVersion: contextVersion,
4634
4713
  refreshed: refreshed
4635
4714
  }));
4636
4715
  case 12:
4637
4716
  case "end":
4638
- return _context41.stop();
4717
+ return _context43.stop();
4639
4718
  }
4640
- }, _callee41, this);
4719
+ }, _callee43, this);
4641
4720
  }));
4642
4721
  function queryBookingAvailability(_x32, _x33) {
4643
4722
  return _queryBookingAvailability.apply(this, arguments);
@@ -4709,27 +4788,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4709
4788
  }, {
4710
4789
  key: "commitAvailabilitySelection",
4711
4790
  value: (function () {
4712
- var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(contextId, params) {
4713
- var normalizedContextId, _params$bookingCount, _ref51, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams26, _ref52, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref53, _ref54, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref55, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4714
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4715
- while (1) switch (_context42.prev = _context42.next) {
4791
+ var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(contextId, params) {
4792
+ var normalizedContextId, _params$bookingCount, _ref51, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams28, _ref52, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref53, _ref54, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref55, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4793
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4794
+ while (1) switch (_context44.prev = _context44.next) {
4716
4795
  case 0:
4717
4796
  normalizedContextId = String(contextId || '').trim();
4718
4797
  if (normalizedContextId) {
4719
- _context42.next = 3;
4798
+ _context44.next = 3;
4720
4799
  break;
4721
4800
  }
4722
4801
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
4723
4802
  candidate: params.candidate
4724
4803
  });
4725
4804
  case 3:
4726
- _context42.next = 5;
4805
+ _context44.next = 5;
4727
4806
  return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
4728
4807
  case 5:
4729
- _context42.prev = 5;
4808
+ _context44.prev = 5;
4730
4809
  bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
4731
4810
  if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
4732
- _context42.next = 9;
4811
+ _context44.next = 9;
4733
4812
  break;
4734
4813
  }
4735
4814
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
@@ -4737,7 +4816,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4737
4816
  });
4738
4817
  case 9:
4739
4818
  if (!(params.mode === 'edit' && bookingCount !== 1)) {
4740
- _context42.next = 11;
4819
+ _context44.next = 11;
4741
4820
  break;
4742
4821
  }
4743
4822
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
@@ -4746,7 +4825,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4746
4825
  case 11:
4747
4826
  orderProductQuantity = (_ref51 = (_params$orderProduct$ = (_params$orderProduct = params.orderProduct) === null || _params$orderProduct === void 0 ? void 0 : _params$orderProduct.num) !== null && _params$orderProduct$ !== void 0 ? _params$orderProduct$ : (_params$orderProduct2 = params.orderProduct) === null || _params$orderProduct2 === void 0 ? void 0 : _params$orderProduct2.quantity) !== null && _ref51 !== void 0 ? _ref51 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
4748
4827
  if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
4749
- _context42.next = 14;
4828
+ _context44.next = 14;
4750
4829
  break;
4751
4830
  }
4752
4831
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
@@ -4756,22 +4835,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4756
4835
  case 14:
4757
4836
  partySize = Number(params.partySize);
4758
4837
  if (!(!Number.isInteger(partySize) || partySize <= 0)) {
4759
- _context42.next = 17;
4838
+ _context44.next = 17;
4760
4839
  break;
4761
4840
  }
4762
4841
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
4763
4842
  partySize: params.partySize
4764
4843
  });
4765
4844
  case 17:
4766
- _context42.next = 19;
4845
+ _context44.next = 19;
4767
4846
  return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
4768
4847
  case 19:
4769
- _yield$this$ensureAva3 = _context42.sent;
4848
+ _yield$this$ensureAva3 = _context44.sent;
4770
4849
  context = _yield$this$ensureAva3.context;
4771
4850
  projectionEntry = _yield$this$ensureAva3.projectionEntry;
4772
4851
  refreshed = _yield$this$ensureAva3.refreshed;
4773
4852
  if (!refreshed) {
4774
- _context42.next = 25;
4853
+ _context44.next = 25;
4775
4854
  break;
4776
4855
  }
4777
4856
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -4782,11 +4861,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4782
4861
  case 25:
4783
4862
  boundEditingUids = context.prepareParams.editingProductLineUids || [];
4784
4863
  if (!(params.mode === 'edit')) {
4785
- _context42.next = 31;
4864
+ _context44.next = 31;
4786
4865
  break;
4787
4866
  }
4788
4867
  if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
4789
- _context42.next = 29;
4868
+ _context44.next = 29;
4790
4869
  break;
4791
4870
  }
4792
4871
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
@@ -4795,11 +4874,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4795
4874
  editingProductLineUids: boundEditingUids
4796
4875
  });
4797
4876
  case 29:
4798
- _context42.next = 33;
4877
+ _context44.next = 33;
4799
4878
  break;
4800
4879
  case 31:
4801
4880
  if (!(boundEditingUids.length > 0)) {
4802
- _context42.next = 33;
4881
+ _context44.next = 33;
4803
4882
  break;
4804
4883
  }
4805
4884
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
@@ -4808,7 +4887,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4808
4887
  });
4809
4888
  case 33:
4810
4889
  if (!(projectionEntry.contextVersion !== context.activeVersion)) {
4811
- _context42.next = 35;
4890
+ _context44.next = 35;
4812
4891
  break;
4813
4892
  }
4814
4893
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -4818,7 +4897,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4818
4897
  });
4819
4898
  case 35:
4820
4899
  if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
4821
- _context42.next = 37;
4900
+ _context44.next = 37;
4822
4901
  break;
4823
4902
  }
4824
4903
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
@@ -4829,7 +4908,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4829
4908
  });
4830
4909
  case 37:
4831
4910
  if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
4832
- _context42.next = 39;
4911
+ _context44.next = 39;
4833
4912
  break;
4834
4913
  }
4835
4914
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
@@ -4841,7 +4920,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4841
4920
  this.assertAvailabilityCandidateFreshness(context, params.candidate);
4842
4921
  orderProductId = (_params$orderProduct$2 = (_params$orderProduct4 = params.orderProduct) === null || _params$orderProduct4 === void 0 ? void 0 : _params$orderProduct4.product_id) !== null && _params$orderProduct$2 !== void 0 ? _params$orderProduct$2 : (_params$orderProduct5 = params.orderProduct) === null || _params$orderProduct5 === void 0 ? void 0 : _params$orderProduct5.id;
4843
4922
  if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
4844
- _context42.next = 43;
4923
+ _context44.next = 43;
4845
4924
  break;
4846
4925
  }
4847
4926
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
@@ -4850,14 +4929,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4850
4929
  });
4851
4930
  case 43:
4852
4931
  if (!(params.mode === 'edit' && !params.productLineUid)) {
4853
- _context42.next = 45;
4932
+ _context44.next = 45;
4854
4933
  break;
4855
4934
  }
4856
4935
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
4857
4936
  case 45:
4858
4937
  editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
4859
4938
  if (!(params.mode === 'edit' && !editingLine)) {
4860
- _context42.next = 48;
4939
+ _context44.next = 48;
4861
4940
  break;
4862
4941
  }
4863
4942
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
@@ -4865,7 +4944,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4865
4944
  });
4866
4945
  case 48:
4867
4946
  if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
4868
- _context42.next = 50;
4947
+ _context44.next = 50;
4869
4948
  break;
4870
4949
  }
4871
4950
  throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
@@ -4875,7 +4954,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4875
4954
  });
4876
4955
  case 50:
4877
4956
  if (Array.isArray(params.requirementSelections)) {
4878
- _context42.next = 52;
4957
+ _context44.next = 52;
4879
4958
  break;
4880
4959
  }
4881
4960
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
@@ -4892,7 +4971,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4892
4971
  };
4893
4972
  prepareParams = baseProjection.meta.prepareParams;
4894
4973
  if (prepareParams) {
4895
- _context42.next = 57;
4974
+ _context44.next = 57;
4896
4975
  break;
4897
4976
  }
4898
4977
  throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
@@ -4904,7 +4983,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4904
4983
  })),
4905
4984
  includesInjectedRawOccupancies: true
4906
4985
  };
4907
- _context42.next = 60;
4986
+ _context44.next = 60;
4908
4987
  return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
4909
4988
  editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
4910
4989
  }), {
@@ -4913,13 +4992,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4913
4992
  durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
4914
4993
  });
4915
4994
  case 60:
4916
- commitSnapshot = _context42.sent;
4995
+ commitSnapshot = _context44.sent;
4917
4996
  refreshedProjection = commitSnapshot.projection;
4918
4997
  if (!(String((_refreshedProjection$ = refreshedProjection.meta.orderRevision) !== null && _refreshedProjection$ !== void 0 ? _refreshedProjection$ : '') !== String((_baseProjection$meta$2 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$2 !== void 0 ? _baseProjection$meta$2 : ''))) {
4919
- _context42.next = 67;
4998
+ _context44.next = 67;
4920
4999
  break;
4921
5000
  }
4922
- _context42.next = 65;
5001
+ _context44.next = 65;
4923
5002
  return this.refreshAvailabilityContextProjection({
4924
5003
  contextId: normalizedContextId,
4925
5004
  reason: 'commit_order_revision_changed',
@@ -4940,7 +5019,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4940
5019
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4941
5020
  candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
4942
5021
  candidateStartTime = getCandidateStartTime(params.candidate);
4943
- allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
5022
+ allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
4944
5023
  refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
4945
5024
  productIds: [params.candidate.productId],
4946
5025
  dateRange: {
@@ -4964,7 +5043,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4964
5043
  return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
4965
5044
  });
4966
5045
  if (refreshedCandidateBase) {
4967
- _context42.next = 75;
5046
+ _context44.next = 75;
4968
5047
  break;
4969
5048
  }
4970
5049
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
@@ -4977,7 +5056,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4977
5056
  return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
4978
5057
  });
4979
5058
  if (product) {
4980
- _context42.next = 78;
5059
+ _context44.next = 78;
4981
5060
  break;
4982
5061
  }
4983
5062
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
@@ -5014,7 +5093,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5014
5093
  });
5015
5094
  }
5016
5095
  if (validation.ok) {
5017
- _context42.next = 83;
5096
+ _context44.next = 83;
5018
5097
  break;
5019
5098
  }
5020
5099
  capacityConflict = validation.conflicts.find(function (conflict) {
@@ -5037,7 +5116,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5037
5116
  incrementVersion: true
5038
5117
  });
5039
5118
  revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
5040
- _context42.next = 87;
5119
+ _context44.next = 87;
5041
5120
  return this.emitAvailabilityDiagnostic({
5042
5121
  action: 'refresh',
5043
5122
  contextId: normalizedContextId,
@@ -5060,7 +5139,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5060
5139
  existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
5061
5140
  existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
5062
5141
  if (!(params.mode === 'edit' && !existingBookingUid)) {
5063
- _context42.next = 93;
5142
+ _context44.next = 93;
5064
5143
  break;
5065
5144
  }
5066
5145
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
@@ -5082,7 +5161,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5082
5161
  quantity: bookingCount
5083
5162
  }), 'unified_booking_sales', product);
5084
5163
  if (transformed) {
5085
- _context42.next = 98;
5164
+ _context44.next = 98;
5086
5165
  break;
5087
5166
  }
5088
5167
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
@@ -5101,7 +5180,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5101
5180
  productLineUids = [];
5102
5181
  bookingUids = [];
5103
5182
  if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
5104
- _context42.next = 117;
5183
+ _context44.next = 117;
5105
5184
  break;
5106
5185
  }
5107
5186
  transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
@@ -5111,7 +5190,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5111
5190
  unique_identification_number: params.productLineUid,
5112
5191
  booking_uid: existingBookingUid
5113
5192
  });
5114
- _context42.next = 111;
5193
+ _context44.next = 111;
5115
5194
  return this.updateOrderProduct(_objectSpread(_objectSpread({
5116
5195
  product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
5117
5196
  product_variant_id: (_ref55 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref55 !== void 0 ? _ref55 : 0,
@@ -5128,7 +5207,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5128
5207
  bookingUid = existingBookingUid;
5129
5208
  productLineUids = [productLineUid];
5130
5209
  bookingUids = [bookingUid];
5131
- _context42.next = 129;
5210
+ _context44.next = 129;
5132
5211
  break;
5133
5212
  case 117:
5134
5213
  beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
@@ -5137,12 +5216,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5137
5216
  beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
5138
5217
  return getBookingUid(item);
5139
5218
  }).filter(Boolean));
5140
- _context42.next = 121;
5219
+ _context44.next = 121;
5141
5220
  return this.addProductToOrder(transformed, booking, (_params$salesNotes = params.salesNotes) !== null && _params$salesNotes !== void 0 && _params$salesNotes.length ? {
5142
5221
  salesNotes: params.salesNotes
5143
5222
  } : undefined);
5144
5223
  case 121:
5145
- products = _context42.sent;
5224
+ products = _context44.sent;
5146
5225
  addedLines = products.filter(function (line) {
5147
5226
  var _line$product_id, _line$metadata;
5148
5227
  return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
@@ -5179,21 +5258,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5179
5258
  productLineUids: productLineUids,
5180
5259
  bookingUids: bookingUids
5181
5260
  };
5182
- _context42.next = 134;
5261
+ _context44.next = 134;
5183
5262
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
5184
5263
  case 134:
5185
- return _context42.abrupt("return", result);
5264
+ return _context44.abrupt("return", result);
5186
5265
  case 135:
5187
- _context42.prev = 135;
5188
- _context42.next = 138;
5266
+ _context44.prev = 135;
5267
+ _context44.next = 138;
5189
5268
  return this.releaseAvailabilityCommitLock(normalizedContextId);
5190
5269
  case 138:
5191
- return _context42.finish(135);
5270
+ return _context44.finish(135);
5192
5271
  case 139:
5193
5272
  case "end":
5194
- return _context42.stop();
5273
+ return _context44.stop();
5195
5274
  }
5196
- }, _callee42, this, [[5,, 135, 139]]);
5275
+ }, _callee44, this, [[5,, 135, 139]]);
5197
5276
  }));
5198
5277
  function commitAvailabilitySelection(_x34, _x35) {
5199
5278
  return _commitAvailabilitySelection.apply(this, arguments);