@pisell/pisellos 0.0.569 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +1 -1
  13. package/dist/modules/BaseModule.js +8 -10
  14. package/dist/modules/Cart/index.js +3 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  16. package/dist/modules/Cart/utils/cartResource.js +0 -2
  17. package/dist/modules/Cart/utils/changePrice.js +9 -16
  18. package/dist/modules/Date/index.js +5 -1
  19. package/dist/modules/Discount/index.d.ts +0 -1
  20. package/dist/modules/Discount/index.js +7 -22
  21. package/dist/modules/Discount/types.d.ts +0 -1
  22. package/dist/modules/OpenData/index.js +2 -0
  23. package/dist/modules/Order/index.js +70 -40
  24. package/dist/modules/Payment/index.js +162 -97
  25. package/dist/modules/Payment/types.d.ts +4 -8
  26. package/dist/modules/Payment/walletpass.d.ts +0 -2
  27. package/dist/modules/Payment/walletpass.js +5 -4
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -12
  30. package/dist/modules/ProductList/types.d.ts +0 -1
  31. package/dist/modules/Rules/index.js +126 -427
  32. package/dist/modules/SalesSummary/utils.js +1 -2
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  34. package/dist/modules/Schedule/index.js +1 -0
  35. package/dist/modules/Schedule/utils.js +1 -0
  36. package/dist/modules/Step/index.js +1 -0
  37. package/dist/modules/Summary/utils.js +22 -43
  38. package/dist/plugins/request.js +4 -1
  39. package/dist/plugins/window.js +6 -2
  40. package/dist/server/index.js +129 -97
  41. package/dist/server/modules/menu/index.js +41 -32
  42. package/dist/server/modules/order/index.js +4 -2
  43. package/dist/server/modules/products/index.js +42 -24
  44. package/dist/server/modules/quotation/index.js +38 -29
  45. package/dist/server/modules/resource/index.js +4 -3
  46. package/dist/server/modules/schedule/index.js +35 -27
  47. package/dist/server/utils/product.js +1 -0
  48. package/dist/solution/BaseSales/index.js +41 -38
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingByStep/index.js +60 -11
  51. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  52. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  53. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  54. package/dist/solution/BookingTicket/index.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.js +2 -0
  56. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
  57. package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
  58. package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
  59. package/dist/solution/BuyTickets/index.js +12 -9
  60. package/dist/solution/Checkout/index.js +252 -177
  61. package/dist/solution/Checkout/utils/index.js +16 -4
  62. package/dist/solution/RegisterAndLogin/index.js +76 -30
  63. package/dist/solution/ScanOrder/index.js +60 -50
  64. package/dist/solution/ShopDiscount/index.js +14 -15
  65. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  66. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  67. package/dist/solution/ShopDiscount/utils.js +0 -9
  68. package/dist/solution/VenueBooking/index.d.ts +3 -31
  69. package/dist/solution/VenueBooking/index.js +496 -651
  70. package/dist/solution/VenueBooking/types.d.ts +1 -3
  71. package/dist/solution/VenueBooking/types.js +0 -1
  72. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  73. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  74. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  75. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/utils/task.js +18 -15
  78. package/dist/utils/watch.js +1 -0
  79. package/lib/apis/picoding.js +0 -2
  80. package/lib/core/index.js +132 -130
  81. package/lib/effects/index.js +57 -46
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +50 -92
  84. package/lib/model/index.js +21 -14
  85. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  86. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  87. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  88. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  89. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  90. package/lib/model/strategy/adapter/index.js +64 -100
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  93. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  94. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  95. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  96. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  97. package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
  98. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  99. package/lib/model/strategy/adapter/promotion/index.js +49 -1
  100. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  101. package/lib/model/strategy/adapter/type.js +16 -4
  102. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  103. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  104. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  105. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  106. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  107. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  108. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  109. package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
  110. package/lib/model/strategy/engine.js +168 -270
  111. package/lib/model/strategy/index.js +34 -49
  112. package/lib/model/strategy/strategy-example.js +239 -243
  113. package/lib/model/strategy/type.js +40 -100
  114. package/lib/modules/Account/index.js +53 -39
  115. package/lib/modules/Account/types.js +33 -20
  116. package/lib/modules/AccountList/index.js +154 -116
  117. package/lib/modules/AccountList/types.js +31 -30
  118. package/lib/modules/AccountList/utils.js +30 -18
  119. package/lib/modules/BaseModule.d.ts +1 -1
  120. package/lib/modules/BaseModule.js +46 -25
  121. package/lib/modules/BookingContext/index.js +136 -158
  122. package/lib/modules/BookingContext/types.js +32 -46
  123. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
  124. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
  125. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
  126. package/lib/modules/BookingContext/utils/flexible.js +55 -38
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
  128. package/lib/modules/BookingContext/utils/index.js +41 -124
  129. package/lib/modules/BookingContext/utils/noResource.js +70 -58
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
  131. package/lib/modules/BookingContext/utils/productExtend.js +155 -202
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  133. package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
  134. package/lib/modules/BookingContext/utils/resources.js +167 -209
  135. package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
  136. package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
  137. package/lib/modules/Cart/index.js +124 -170
  138. package/lib/modules/Cart/types.js +51 -46
  139. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  140. package/lib/modules/Cart/utils/cartDate.js +61 -56
  141. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  142. package/lib/modules/Cart/utils/cartNote.js +32 -27
  143. package/lib/modules/Cart/utils/cartProduct.js +251 -321
  144. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  145. package/lib/modules/Cart/utils/cartResource.js +78 -72
  146. package/lib/modules/Cart/utils/changePrice.js +50 -28
  147. package/lib/modules/Cart/utils/index.js +48 -106
  148. package/lib/modules/Customer/constants.js +34 -13
  149. package/lib/modules/Customer/index.js +169 -232
  150. package/lib/modules/Customer/types.js +35 -38
  151. package/lib/modules/Date/index.js +115 -116
  152. package/lib/modules/Date/types.js +28 -16
  153. package/lib/modules/Date/utils.js +123 -174
  154. package/lib/modules/Discount/index.d.ts +0 -1
  155. package/lib/modules/Discount/index.js +128 -130
  156. package/lib/modules/Discount/types.d.ts +0 -1
  157. package/lib/modules/Discount/types.js +31 -9
  158. package/lib/modules/Guests/index.js +56 -30
  159. package/lib/modules/Guests/types.js +33 -23
  160. package/lib/modules/Holder/index.js +189 -209
  161. package/lib/modules/Holder/types.js +16 -4
  162. package/lib/modules/Holder/utils.js +49 -20
  163. package/lib/modules/OpenData/index.js +76 -69
  164. package/lib/modules/OpenData/types.js +16 -4
  165. package/lib/modules/OpenData/utils.js +78 -44
  166. package/lib/modules/Order/index.js +1909 -1572
  167. package/lib/modules/Order/types.js +35 -78
  168. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  169. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  171. package/lib/modules/Order/utils.js +634 -799
  172. package/lib/modules/Payment/cash.js +33 -20
  173. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  174. package/lib/modules/Payment/eftpos.js +30 -16
  175. package/lib/modules/Payment/index.js +378 -518
  176. package/lib/modules/Payment/mx51.js +0 -1
  177. package/lib/modules/Payment/types.d.ts +4 -8
  178. package/lib/modules/Payment/types.js +107 -216
  179. package/lib/modules/Payment/utils.js +48 -51
  180. package/lib/modules/Payment/walletpass.d.ts +0 -2
  181. package/lib/modules/Payment/walletpass.js +211 -226
  182. package/lib/modules/Product/index.js +46 -51
  183. package/lib/modules/Product/types.js +16 -4
  184. package/lib/modules/Product/utils.js +33 -32
  185. package/lib/modules/ProductList/index.d.ts +1 -1
  186. package/lib/modules/ProductList/index.js +117 -117
  187. package/lib/modules/ProductList/types.d.ts +0 -1
  188. package/lib/modules/ProductList/types.js +31 -9
  189. package/lib/modules/Quotation/index.js +100 -66
  190. package/lib/modules/Quotation/types.js +16 -4
  191. package/lib/modules/Resource/index.js +59 -27
  192. package/lib/modules/Resource/types.js +32 -22
  193. package/lib/modules/Resource/utils.js +38 -30
  194. package/lib/modules/ResourcePlanner/index.js +61 -60
  195. package/lib/modules/ResourcePlanner/planner.js +384 -346
  196. package/lib/modules/ResourcePlanner/types.js +16 -4
  197. package/lib/modules/Rules/index.js +903 -1475
  198. package/lib/modules/Rules/types.js +40 -17
  199. package/lib/modules/SalesSummary/index.js +90 -85
  200. package/lib/modules/SalesSummary/types.js +16 -4
  201. package/lib/modules/SalesSummary/utils.js +427 -351
  202. package/lib/modules/ScanOrderLogger/index.js +79 -59
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  205. package/lib/modules/ScanOrderLogger/types.js +16 -4
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  207. package/lib/modules/Schedule/index.js +114 -100
  208. package/lib/modules/Schedule/type.js +16 -4
  209. package/lib/modules/Schedule/types.js +16 -4
  210. package/lib/modules/Schedule/utils.js +291 -433
  211. package/lib/modules/Step/index.js +52 -40
  212. package/lib/modules/Step/tyeps.js +16 -4
  213. package/lib/modules/Summary/index.js +71 -66
  214. package/lib/modules/Summary/types.js +16 -4
  215. package/lib/modules/Summary/utils.js +418 -791
  216. package/lib/modules/SurchargeList/index.js +60 -46
  217. package/lib/modules/SurchargeList/types.js +16 -4
  218. package/lib/modules/index.js +63 -245
  219. package/lib/plugins/app.js +16 -4
  220. package/lib/plugins/index.js +25 -36
  221. package/lib/plugins/request.js +126 -137
  222. package/lib/plugins/shopStore.js +16 -4
  223. package/lib/plugins/user.js +16 -4
  224. package/lib/plugins/window.js +179 -171
  225. package/lib/server/index.js +2337 -2675
  226. package/lib/server/modules/floor-plan/index.js +123 -102
  227. package/lib/server/modules/floor-plan/types.js +30 -15
  228. package/lib/server/modules/index.js +68 -106
  229. package/lib/server/modules/menu/index.js +122 -146
  230. package/lib/server/modules/menu/types.js +31 -18
  231. package/lib/server/modules/order/index.js +642 -567
  232. package/lib/server/modules/order/types.js +32 -117
  233. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  234. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  235. package/lib/server/modules/payment/index.js +83 -59
  236. package/lib/server/modules/payment/types.js +16 -4
  237. package/lib/server/modules/products/index.js +459 -575
  238. package/lib/server/modules/products/types.js +34 -44
  239. package/lib/server/modules/quotation/index.js +172 -137
  240. package/lib/server/modules/quotation/types.js +31 -21
  241. package/lib/server/modules/resource/index.js +184 -213
  242. package/lib/server/modules/resource/types.js +33 -42
  243. package/lib/server/modules/schedule/index.js +123 -135
  244. package/lib/server/modules/schedule/types.js +21 -14
  245. package/lib/server/modules/schedule/utils.js +163 -334
  246. package/lib/server/types.js +16 -4
  247. package/lib/server/utils/index.js +23 -25
  248. package/lib/server/utils/product.js +139 -196
  249. package/lib/server/utils/schedule.js +41 -34
  250. package/lib/server/utils/small-ticket.js +456 -478
  251. package/lib/server/utils/time.js +49 -40
  252. package/lib/solution/BaseSales/index.js +1016 -850
  253. package/lib/solution/BaseSales/types.js +37 -41
  254. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  255. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  256. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  257. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  258. package/lib/solution/BaseSales/utils.js +140 -155
  259. package/lib/solution/BookingByStep/index.d.ts +1 -1
  260. package/lib/solution/BookingByStep/index.js +1340 -1530
  261. package/lib/solution/BookingByStep/types.js +99 -40
  262. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  263. package/lib/solution/BookingByStep/utils/products.js +52 -42
  264. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  265. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  266. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  267. package/lib/solution/BookingTicket/index.d.ts +1 -1
  268. package/lib/solution/BookingTicket/index.js +459 -543
  269. package/lib/solution/BookingTicket/types.js +77 -99
  270. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  271. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  272. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  273. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  274. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  275. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  276. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  277. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  278. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  279. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  280. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  281. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  282. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  283. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  284. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  285. package/lib/solution/BuyTickets/index.js +70 -67
  286. package/lib/solution/BuyTickets/types.js +38 -22
  287. package/lib/solution/Checkout/index.js +1158 -1451
  288. package/lib/solution/Checkout/types.js +61 -91
  289. package/lib/solution/Checkout/utils/index.js +156 -228
  290. package/lib/solution/PlaceOrder/index.js +0 -55
  291. package/lib/solution/RegisterAndLogin/config.js +460 -493
  292. package/lib/solution/RegisterAndLogin/index.js +630 -633
  293. package/lib/solution/RegisterAndLogin/types.js +76 -189
  294. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  295. package/lib/solution/Sales/index.js +320 -317
  296. package/lib/solution/Sales/types.js +33 -27
  297. package/lib/solution/ScanOrder/index.js +862 -831
  298. package/lib/solution/ScanOrder/types.js +34 -33
  299. package/lib/solution/ScanOrder/utils.js +371 -406
  300. package/lib/solution/ShopDiscount/index.js +233 -235
  301. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  302. package/lib/solution/ShopDiscount/types.js +37 -15
  303. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  304. package/lib/solution/ShopDiscount/utils.js +172 -309
  305. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  306. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  307. package/lib/solution/VenueBooking/index.d.ts +3 -31
  308. package/lib/solution/VenueBooking/index.js +916 -967
  309. package/lib/solution/VenueBooking/types.d.ts +1 -3
  310. package/lib/solution/VenueBooking/types.js +39 -20
  311. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  312. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  313. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  314. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  315. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  316. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  317. package/lib/solution/VenueBooking/utils.js +67 -130
  318. package/lib/solution/index.js +41 -124
  319. package/lib/store/createStore.js +29 -32
  320. package/lib/types/index.d.ts +1 -1
  321. package/lib/types/index.js +16 -4
  322. package/lib/utils/task.js +36 -36
  323. package/lib/utils/watch.js +47 -81
  324. package/package.json +2 -4
  325. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  326. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  327. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  328. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,92 +1,119 @@
1
- "use strict";
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
28
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
29
+ // src/server/utils/small-ticket.ts
30
+ var small_ticket_exports = {};
31
+ __export(small_ticket_exports, {
32
+ buildSmallTicketData: () => buildSmallTicketData,
33
+ hasSmallTicketData: () => hasSmallTicketData
5
34
  });
6
- exports.buildSmallTicketData = buildSmallTicketData;
7
- exports.hasSmallTicketData = hasSmallTicketData;
8
- var _dayjs = _interopRequireDefault(require("dayjs"));
9
- var _decimal = _interopRequireDefault(require("decimal.js"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- const DEFAULT_LOCALES = ['en', 'zh_CN'];
12
- const LABELS = {
35
+ module.exports = __toCommonJS(small_ticket_exports);
36
+ var import_dayjs = __toESM(require("dayjs"));
37
+ var import_decimal = __toESM(require("decimal.js"));
38
+ var DEFAULT_LOCALES = ["en", "zh_CN"];
39
+ var LABELS = {
13
40
  en: {
14
- contactName: 'Contact name',
15
- contactMobile: 'Contact Mobile',
16
- email: 'email',
17
- dineIn: 'Dine-in',
18
- takeAway: 'Take away',
19
- delivery: 'Delivery',
20
- pickUp: 'Pick-up',
21
- shopService: 'Dine-in',
22
- pickUpTime: 'Pick-up time',
23
- asap: 'ASAP',
24
- cash: 'Cash',
25
- eftpos: 'Eftpos',
26
- wallet: 'Wallet',
27
- giftCard: 'Gift card',
28
- remainingAmount: 'Remaining amount',
29
- redeemPoints: 'Redeem points',
30
- remainingPoints: 'Remaining points',
31
- table: 'Table',
32
- orderDiscount: 'Order discount',
33
- manualDiscount: 'Manual discount',
34
- payProcessingFee: 'Pay processing fee',
35
- rounding: 'Rounding',
36
- gross: 'Gross',
37
- tare: 'Tare'
41
+ contactName: "Contact name",
42
+ contactMobile: "Contact Mobile",
43
+ email: "email",
44
+ dineIn: "Dine-in",
45
+ takeAway: "Take away",
46
+ delivery: "Delivery",
47
+ pickUp: "Pick-up",
48
+ shopService: "Dine-in",
49
+ pickUpTime: "Pick-up time",
50
+ asap: "ASAP",
51
+ cash: "Cash",
52
+ eftpos: "Eftpos",
53
+ wallet: "Wallet",
54
+ giftCard: "Gift card",
55
+ remainingAmount: "Remaining amount",
56
+ redeemPoints: "Redeem points",
57
+ remainingPoints: "Remaining points",
58
+ table: "Table",
59
+ orderDiscount: "Order discount",
60
+ manualDiscount: "Manual discount",
61
+ payProcessingFee: "Pay processing fee",
62
+ rounding: "Rounding",
63
+ gross: "Gross",
64
+ tare: "Tare"
38
65
  },
39
66
  zh_CN: {
40
- contactName: '联系人姓名',
41
- contactMobile: '联系电话',
42
- email: '邮箱',
43
- dineIn: '堂食',
44
- takeAway: '外带',
45
- delivery: '配送',
46
- pickUp: '自提',
47
- shopService: '堂食',
48
- pickUpTime: '取餐时间',
49
- asap: '尽快',
50
- cash: '现金支付',
51
- eftpos: '刷卡支付',
52
- wallet: '钱包支付',
53
- giftCard: '礼品卡',
54
- remainingAmount: '剩余金额',
55
- redeemPoints: '本次使用积分',
56
- remainingPoints: '剩余积分',
57
- table: '桌台',
58
- orderDiscount: '整单折扣',
59
- manualDiscount: '手动折扣',
60
- payProcessingFee: '支付手续费',
61
- rounding: '抹零',
62
- gross: '重量',
63
- tare: '去皮'
67
+ contactName: "联系人姓名",
68
+ contactMobile: "联系电话",
69
+ email: "邮箱",
70
+ dineIn: "堂食",
71
+ takeAway: "外带",
72
+ delivery: "配送",
73
+ pickUp: "自提",
74
+ shopService: "堂食",
75
+ pickUpTime: "取餐时间",
76
+ asap: "尽快",
77
+ cash: "现金支付",
78
+ eftpos: "刷卡支付",
79
+ wallet: "钱包支付",
80
+ giftCard: "礼品卡",
81
+ remainingAmount: "剩余金额",
82
+ redeemPoints: "本次使用积分",
83
+ remainingPoints: "剩余积分",
84
+ table: "桌台",
85
+ orderDiscount: "整单折扣",
86
+ manualDiscount: "手动折扣",
87
+ payProcessingFee: "支付手续费",
88
+ rounding: "抹零",
89
+ gross: "重量",
90
+ tare: "去皮"
64
91
  },
65
92
  zh_HK: {
66
- contactName: '聯絡人姓名',
67
- contactMobile: '聯絡電話',
68
- email: '電郵',
69
- dineIn: '堂食',
70
- takeAway: '外帶',
71
- delivery: '配送',
72
- pickUp: '自取',
73
- shopService: '堂食',
74
- pickUpTime: '取餐時間',
75
- asap: '盡快',
76
- cash: '現金支付',
77
- eftpos: '刷卡支付',
78
- wallet: '錢包支付',
79
- giftCard: '禮品卡',
80
- remainingAmount: '剩餘金額',
81
- redeemPoints: '本次使用積分',
82
- remainingPoints: '剩餘積分',
83
- table: '桌台',
84
- orderDiscount: '整單折扣',
85
- manualDiscount: '手動折扣',
86
- payProcessingFee: '支付手續費',
87
- rounding: '抹零',
88
- gross: '重量',
89
- tare: '去皮'
93
+ contactName: "聯絡人姓名",
94
+ contactMobile: "聯絡電話",
95
+ email: "電郵",
96
+ dineIn: "堂食",
97
+ takeAway: "外帶",
98
+ delivery: "配送",
99
+ pickUp: "自取",
100
+ shopService: "堂食",
101
+ pickUpTime: "取餐時間",
102
+ asap: "盡快",
103
+ cash: "現金支付",
104
+ eftpos: "刷卡支付",
105
+ wallet: "錢包支付",
106
+ giftCard: "禮品卡",
107
+ remainingAmount: "剩餘金額",
108
+ redeemPoints: "本次使用積分",
109
+ remainingPoints: "剩餘積分",
110
+ table: "桌台",
111
+ orderDiscount: "整單折扣",
112
+ manualDiscount: "手動折扣",
113
+ payProcessingFee: "支付手續費",
114
+ rounding: "抹零",
115
+ gross: "重量",
116
+ tare: "去皮"
90
117
  }
91
118
  };
92
119
  function buildSmallTicketData(params) {
@@ -95,52 +122,27 @@ function buildSmallTicketData(params) {
95
122
  const locales = resolveLocales(shopInfo, params.locales);
96
123
  const productMap = params.productMap || {};
97
124
  return locales.reduce((data, locale) => {
98
- data[locale] = buildLocaleData({
99
- order,
100
- shopInfo,
101
- locale,
102
- productMap
103
- });
125
+ data[locale] = buildLocaleData({ order, shopInfo, locale, productMap });
104
126
  return data;
105
127
  }, {});
106
128
  }
107
129
  function hasSmallTicketData(value) {
108
- return !!value && typeof value === 'object' && Object.keys(value).length > 0;
130
+ return !!value && typeof value === "object" && Object.keys(value).length > 0;
109
131
  }
110
132
  function buildLocaleData(params) {
111
- const {
112
- order,
113
- shopInfo,
114
- locale,
115
- productMap
116
- } = params;
133
+ const { order, shopInfo, locale, productMap } = params;
117
134
  const products = buildProducts(order, locale, productMap);
118
135
  const summary = getSummary(order);
119
136
  const currencySymbol = getCurrencySymbol(order, shopInfo);
120
137
  return {
121
- base_data: buildBaseData({
122
- order,
123
- shopInfo,
124
- locale
125
- }),
138
+ base_data: buildBaseData({ order, shopInfo, locale }),
126
139
  products,
127
- fees: buildFees({
128
- order,
129
- shopInfo,
130
- locale,
131
- products,
132
- summary,
133
- currencySymbol
134
- }),
140
+ fees: buildFees({ order, shopInfo, locale, products, summary, currencySymbol }),
135
141
  customer: buildCustomer(order, locale),
136
142
  appointment: buildAppointment(order, locale),
137
143
  // delivery: buildDelivery(order, locale),
138
144
  resources: buildResources(order, locale),
139
- payment_data: buildPaymentData({
140
- order,
141
- locale,
142
- currencySymbol
143
- }),
145
+ payment_data: buildPaymentData({ order, locale, currencySymbol }),
144
146
  tickets: Array.isArray(order.tickets) ? order.tickets : [],
145
147
  source_shop: [],
146
148
  refund_data: [],
@@ -148,12 +150,11 @@ function buildLocaleData(params) {
148
150
  };
149
151
  }
150
152
  function buildBaseData(params) {
151
- const {
152
- order,
153
- shopInfo,
154
- locale
155
- } = params;
156
- const orderNumber = stringify(order.buzzer || order.shop_full_order_number);
153
+ var _a;
154
+ const { order, shopInfo, locale } = params;
155
+ const orderNumber = stringify(
156
+ order.buzzer || order.shop_full_order_number
157
+ );
157
158
  return {
158
159
  shop_name: stringify(shopInfo.name || order.shop_name),
159
160
  note: stringify(order.note),
@@ -164,22 +165,18 @@ function buildBaseData(params) {
164
165
  shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
165
166
  original_payment_status: stringify(order.payment_status),
166
167
  is_repeat: 0,
167
- buzzer: stringify(order.buzzer || order.pickup_number || order.metadata?.buzzer),
168
+ buzzer: stringify(order.buzzer || order.pickup_number || ((_a = order.metadata) == null ? void 0 : _a.buzzer)),
168
169
  order_no: orderNumber,
169
- order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale)
170
+ order_time: formatDateTime(order.created_at || order.sales_time || /* @__PURE__ */ new Date(), locale)
170
171
  };
171
172
  }
172
173
  function buildProducts(order, locale, productMap) {
173
174
  const products = Array.isArray(order.products) ? order.products : [];
174
- return products.map(product => {
175
+ return products.map((product) => {
175
176
  const quantity = toNumber(product.product_quantity ?? product.quantity ?? product.num ?? 1, 1);
176
177
  const originalPrice = product.original_price ?? product.selling_price ?? product.payment_price ?? product.price ?? 0;
177
178
  const sellingPrice = product.selling_price ?? product.payment_price ?? product.price ?? originalPrice;
178
- const productTitle = resolveProductTitle({
179
- product,
180
- productMap,
181
- locale
182
- });
179
+ const productTitle = resolveProductTitle({ product, productMap, locale });
183
180
  const parentProduct = resolveProductFromMap(product.product_id ?? product.id, productMap);
184
181
  const currencySymbol = getCurrencySymbol(order, null);
185
182
  const options = normalizeProductOptions({
@@ -195,11 +192,7 @@ function buildProducts(order, locale, productMap) {
195
192
  currencySymbol,
196
193
  parentProduct
197
194
  });
198
- const resolvedVariant = resolveProductVariantText({
199
- product,
200
- parentProduct,
201
- locale
202
- });
195
+ const resolvedVariant = resolveProductVariantText({ product, parentProduct, locale });
203
196
  const extensionList = buildProductExtensionList({
204
197
  product,
205
198
  locale,
@@ -212,33 +205,20 @@ function buildProducts(order, locale, productMap) {
212
205
  product_quantity: quantity,
213
206
  selling_price: formatMoney(sellingPrice, currencySymbol),
214
207
  original_price: formatMoney(originalPrice, currencySymbol),
215
- total_original_price: formatMoney(new _decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
208
+ total_original_price: formatMoney(new import_decimal.default(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
216
209
  extension_list: extensionList,
217
- ...(options.length ? {
218
- options
219
- } : {}),
220
- ...(resolvedVariant ? {
221
- variant: resolvedVariant
222
- } : {}),
223
- ...(Array.isArray(product.combinations) ? {
224
- combinations: product.combinations
225
- } : combinations.length ? {
226
- combinations
227
- } : {})
210
+ ...options.length ? { options } : {},
211
+ ...resolvedVariant ? { variant: resolvedVariant } : {},
212
+ ...Array.isArray(product.combinations) ? { combinations: product.combinations } : combinations.length ? { combinations } : {}
228
213
  };
229
214
  });
230
215
  }
231
216
  function normalizeProductDiscounts(params) {
232
- const {
233
- product,
234
- locale,
235
- currencySymbol,
236
- quantity
237
- } = params;
238
- return normalizeArray(product.discount_list).map(discount => {
217
+ const { product, locale, currencySymbol, quantity } = params;
218
+ return normalizeArray(product.discount_list).map((discount) => {
239
219
  const title = resolveDiscountTitleWithPercent(discount, locale);
240
220
  const amount = discount.amount ?? discount.value ?? discount.discount_amount;
241
- const formattedAmount = formatNegativeMoney(new _decimal.default(toMoneyNumber(amount)).mul(quantity), currencySymbol);
221
+ const formattedAmount = formatNegativeMoney(new import_decimal.default(toMoneyNumber(amount)).mul(quantity), currencySymbol);
242
222
  return {
243
223
  item: title,
244
224
  value: formattedAmount
@@ -246,54 +226,35 @@ function normalizeProductDiscounts(params) {
246
226
  });
247
227
  }
248
228
  function buildProductExtensionList(params) {
249
- const {
250
- product,
251
- locale,
252
- currencySymbol,
253
- quantity,
254
- originalPrice
255
- } = params;
256
- const discountList = normalizeProductDiscounts({
257
- product,
258
- locale,
259
- currencySymbol,
260
- quantity
261
- });
262
- const extensionList = [...buildProductOpenWeightRows({
263
- product,
264
- locale,
265
- currencySymbol
266
- }), ...(quantity > 1 ? [{
267
- item: buildProductQuantityPriceText({
268
- quantity,
269
- currencySymbol,
270
- price: originalPrice
271
- }),
272
- value: ''
273
- }] : [])];
229
+ const { product, locale, currencySymbol, quantity, originalPrice } = params;
230
+ const discountList = normalizeProductDiscounts({ product, locale, currencySymbol, quantity });
231
+ const extensionList = [
232
+ ...buildProductOpenWeightRows({ product, locale, currencySymbol }),
233
+ ...quantity > 1 ? [{
234
+ item: buildProductQuantityPriceText({ quantity, currencySymbol, price: originalPrice }),
235
+ value: ""
236
+ }] : []
237
+ ];
274
238
  const productExtensionList = extensionList.length ? extensionList : normalizeArray(product.extension_list);
275
239
  return [...productExtensionList, ...discountList];
276
240
  }
277
241
  function buildProductOpenWeightRows(params) {
278
- const {
279
- product,
280
- locale,
281
- currencySymbol
282
- } = params;
242
+ const { product, locale, currencySymbol } = params;
283
243
  const productSku = product.product_sku || {};
284
- if (productSku.open_sold_weight != 1) return [];
285
- const unit = productSku.unit ?? '';
286
- const manualFlag = productSku.weight_source === 'manual' ? '(M) ' : '';
244
+ if (productSku.open_sold_weight != 1)
245
+ return [];
246
+ const unit = productSku.unit ?? "";
247
+ const manualFlag = productSku.weight_source === "manual" ? "(M) " : "";
287
248
  const hasTare = toNumber(productSku.tare_weight, 0) > 0;
288
249
  const rows = [];
289
250
  if (hasTare) {
290
251
  rows.push({
291
- item: `${manualFlag}${label(locale, 'gross')}: ${productSku.weight ?? 0}${unit}`,
292
- value: ''
252
+ item: `${manualFlag}${label(locale, "gross")}: ${productSku.weight ?? 0}${unit}`,
253
+ value: ""
293
254
  });
294
255
  rows.push({
295
- item: `${label(locale, 'tare')}: ${productSku.tare_weight}${unit}`,
296
- value: ''
256
+ item: `${label(locale, "tare")}: ${productSku.tare_weight}${unit}`,
257
+ value: ""
297
258
  });
298
259
  }
299
260
  const netWeight = productSku.net_weight ?? 0;
@@ -301,87 +262,71 @@ function buildProductOpenWeightRows(params) {
301
262
  const netItem = `${netWeight} ${unit} NET @ ${currencySymbol}${unitPrice}/${unit}`;
302
263
  rows.push({
303
264
  item: hasTare ? netItem : `${manualFlag}${netItem}`,
304
- value: ''
265
+ value: ""
305
266
  });
306
267
  return rows;
307
268
  }
308
269
  function buildProductQuantityPriceText(params) {
309
- const {
310
- quantity,
311
- currencySymbol,
312
- price
313
- } = params;
270
+ const { quantity, currencySymbol, price } = params;
314
271
  return `${quantity} @ ${currencySymbol}${stringify(price)} EACH`;
315
272
  }
316
273
  function resolveDiscountTitleWithPercent(discount, locale) {
274
+ var _a, _b;
317
275
  const title = resolveDiscountTitle(discount, locale);
318
- const percentRaw = discount.discount?.percent;
319
- const cardType = discount.discount?.discount_card_type ?? 'percent';
320
- const percent = percentRaw !== undefined && percentRaw !== null ? Math.trunc(Number(percentRaw)) : NaN;
321
- if (percentRaw === undefined || percentRaw === null) return title;
322
- if (cardType !== 'percent') return title;
323
- if (Number.isNaN(percent)) return title;
276
+ const percentRaw = (_a = discount.discount) == null ? void 0 : _a.percent;
277
+ const cardType = ((_b = discount.discount) == null ? void 0 : _b.discount_card_type) ?? "percent";
278
+ const percent = percentRaw !== void 0 && percentRaw !== null ? Math.trunc(Number(percentRaw)) : NaN;
279
+ if (percentRaw === void 0 || percentRaw === null)
280
+ return title;
281
+ if (cardType !== "percent")
282
+ return title;
283
+ if (Number.isNaN(percent))
284
+ return title;
324
285
  return `${title} (${percent}%)`;
325
286
  }
326
287
  function resolveDiscountTitle(discount, locale) {
327
- const title = getLocalizedValue(discount.discount?.name ?? discount.discount?.title ?? discount.discount?.message ?? discount.name ?? discount.title ?? discount.message, locale);
328
- if (title) return title;
329
- if (discount.type === 'product') return label(locale, 'manualDiscount');
330
- return '';
288
+ var _a, _b, _c;
289
+ const title = getLocalizedValue(
290
+ ((_a = discount.discount) == null ? void 0 : _a.name) ?? ((_b = discount.discount) == null ? void 0 : _b.title) ?? ((_c = discount.discount) == null ? void 0 : _c.message) ?? discount.name ?? discount.title ?? discount.message,
291
+ locale
292
+ );
293
+ if (title)
294
+ return title;
295
+ if (discount.type === "product")
296
+ return label(locale, "manualDiscount");
297
+ return "";
331
298
  }
332
299
  function resolveProductTitle(params) {
333
- const {
334
- product,
335
- productMap,
336
- locale
337
- } = params;
300
+ const { product, productMap, locale } = params;
338
301
  const ownTitle = getProductTitleSource(product, locale);
339
- if (ownTitle) return ownTitle;
302
+ if (ownTitle)
303
+ return ownTitle;
340
304
  const productId = product.product_id ?? product.id;
341
305
  const fallbackProduct = resolveProductFromMap(productId, productMap);
342
- if (!fallbackProduct) return ownTitle || '';
306
+ if (!fallbackProduct)
307
+ return ownTitle || "";
343
308
  return getProductTitleSource(fallbackProduct, locale);
344
309
  }
345
310
  function normalizeProductOptions(params) {
346
- const {
347
- product,
348
- locale,
349
- currencySymbol,
350
- parentProduct
351
- } = params;
352
- const rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray(product.product_sku?.option) ? product.product_sku.option : [];
353
- return rawOptions.map(option => {
311
+ var _a;
312
+ const { product, locale, currencySymbol, parentProduct } = params;
313
+ const rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_a = product.product_sku) == null ? void 0 : _a.option) ? product.product_sku.option : [];
314
+ return rawOptions.map((option) => {
354
315
  const price = option.original_price ?? option.add_price ?? option.price;
355
316
  const value = option.value ?? option.option ?? option.item;
356
- const name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({
357
- option,
358
- parentProduct,
359
- locale
360
- });
317
+ const name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({ option, parentProduct, locale });
361
318
  return {
362
319
  name,
363
- ...(option.num !== undefined || option.quantity !== undefined ? {
364
- num: toNumber(option.num ?? option.quantity, 1)
365
- } : {}),
366
- ...(price !== undefined && price !== null && price !== '' ? {
367
- price: formatMoney(price, currencySymbol)
368
- } : {}),
369
- ...(value !== undefined && value !== null && value !== '' ? {
370
- value: getLocalizedValue(value, locale)
371
- } : {})
320
+ ...option.num !== void 0 || option.quantity !== void 0 ? { num: toNumber(option.num ?? option.quantity, 1) } : {},
321
+ ...price !== void 0 && price !== null && price !== "" ? { price: formatMoney(price, currencySymbol) } : {},
322
+ ...value !== void 0 && value !== null && value !== "" ? { value: getLocalizedValue(value, locale) } : {}
372
323
  };
373
324
  });
374
325
  }
375
326
  function normalizeProductCombinations(params) {
376
- const {
377
- product,
378
- productMap,
379
- locale,
380
- currencySymbol,
381
- parentProduct
382
- } = params;
327
+ const { product, productMap, locale, currencySymbol, parentProduct } = params;
383
328
  const bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
384
- return bundles.map(bundle => {
329
+ return bundles.map((bundle) => {
385
330
  const combinationsOptions = normalizeProductOptions({
386
331
  product: {},
387
332
  locale,
@@ -405,47 +350,44 @@ function normalizeProductCombinations(params) {
405
350
  });
406
351
  }
407
352
  function resolveBundleProductTitle(params) {
408
- const {
409
- bundle,
410
- productMap,
411
- locale,
412
- parentProduct
413
- } = params;
353
+ const { bundle, productMap, locale, parentProduct } = params;
414
354
  const ownTitle = getProductTitleSource(bundle, locale);
415
- if (ownTitle) return ownTitle;
416
- const parentBundleItem = resolveBundleItemFromParentProduct({
417
- bundle,
418
- parentProduct
419
- });
420
- const parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : '';
421
- if (parentBundleTitle) return parentBundleTitle;
355
+ if (ownTitle)
356
+ return ownTitle;
357
+ const parentBundleItem = resolveBundleItemFromParentProduct({ bundle, parentProduct });
358
+ const parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : "";
359
+ if (parentBundleTitle)
360
+ return parentBundleTitle;
422
361
  const productId = bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id ?? bundle.id;
423
362
  const fallbackProduct = resolveProductFromMap(productId, productMap);
424
- if (!fallbackProduct) return '';
363
+ if (!fallbackProduct)
364
+ return "";
425
365
  return getProductTitleSource(fallbackProduct, locale);
426
366
  }
427
367
  function resolveProductFromMap(productId, productMap) {
428
- if (productId === undefined || productId === null || productId === '') return null;
368
+ if (productId === void 0 || productId === null || productId === "")
369
+ return null;
429
370
  return productMap[productId] || productMap[String(productId)] || null;
430
371
  }
431
372
  function resolveProductVariantText(params) {
432
- const {
433
- product,
434
- parentProduct,
435
- locale
436
- } = params;
437
- if (product.variant) return getLocalizedValue(product.variant, locale);
438
- if (!parentProduct) return '';
373
+ const { product, parentProduct, locale } = params;
374
+ if (product.variant)
375
+ return getLocalizedValue(product.variant, locale);
376
+ if (!parentProduct)
377
+ return "";
439
378
  const productVariantId = product.product_variant_id ?? product.variant_id;
440
- if (!isNonZeroId(productVariantId)) return '';
441
- const matchedVariant = normalizeArray(parentProduct.variant).find(variant => isSameId(variant.id, productVariantId));
442
- if (!matchedVariant) return '';
379
+ if (!isNonZeroId(productVariantId))
380
+ return "";
381
+ const matchedVariant = normalizeArray(parentProduct.variant).find((variant) => isSameId(variant.id, productVariantId));
382
+ if (!matchedVariant)
383
+ return "";
443
384
  const resolvedFromSkuKey = resolveVariantTextFromSkuKey({
444
385
  skuKey: matchedVariant.sku_key,
445
386
  parentProduct,
446
387
  locale
447
388
  });
448
- if (resolvedFromSkuKey) return resolvedFromSkuKey;
389
+ if (resolvedFromSkuKey)
390
+ return resolvedFromSkuKey;
449
391
  return resolveVariantTextFromNameMap({
450
392
  nameMap: matchedVariant.name || matchedVariant.title,
451
393
  parentProduct,
@@ -454,71 +396,86 @@ function resolveProductVariantText(params) {
454
396
  }
455
397
  function resolveVariantTextFromSkuKey(params) {
456
398
  const skuKey = stringify(params.skuKey);
457
- if (!skuKey) return '';
458
- return skuKey.split('_').map(item => {
459
- const [groupPositionId, itemPositionId] = item.split(':');
399
+ if (!skuKey)
400
+ return "";
401
+ return skuKey.split("_").map((item) => {
402
+ const [groupPositionId, itemPositionId] = item.split(":");
460
403
  return resolveVariantTextItem({
461
404
  parentProduct: params.parentProduct,
462
405
  groupPositionId,
463
406
  itemPositionId,
464
407
  locale: params.locale
465
408
  });
466
- }).filter(Boolean).join(',');
409
+ }).filter(Boolean).join(",");
467
410
  }
468
411
  function resolveVariantTextFromNameMap(params) {
469
- if (!params.nameMap || typeof params.nameMap !== 'object') return '';
412
+ if (!params.nameMap || typeof params.nameMap !== "object")
413
+ return "";
470
414
  return Object.entries(params.nameMap).map(([groupPositionId, value]) => {
471
415
  const group = resolveVariantGroup(params.parentProduct, groupPositionId);
472
- if (!group) return '';
416
+ if (!group)
417
+ return "";
473
418
  const groupName = getLocalizedValue(group.name, params.locale);
474
419
  const itemName = getLocalizedValue(value, params.locale);
475
- if (!groupName || !itemName) return '';
420
+ if (!groupName || !itemName)
421
+ return "";
476
422
  return `${groupName}:${itemName}`;
477
- }).filter(Boolean).join(',');
423
+ }).filter(Boolean).join(",");
478
424
  }
479
425
  function resolveVariantTextItem(params) {
480
426
  const group = resolveVariantGroup(params.parentProduct, params.groupPositionId);
481
427
  const item = resolveVariantItem(group, params.itemPositionId);
482
- if (!group || !item) return '';
428
+ if (!group || !item)
429
+ return "";
483
430
  const groupName = getLocalizedValue(group.name, params.locale);
484
431
  const itemName = getLocalizedValue(item.name, params.locale);
485
- if (!groupName || !itemName) return '';
432
+ if (!groupName || !itemName)
433
+ return "";
486
434
  return `${groupName}:${itemName}`;
487
435
  }
488
436
  function resolveVariantGroup(parentProduct, groupPositionId) {
489
- return normalizeArray(parentProduct.variant_group).find(group => isSameId(group.position_id, groupPositionId) || isSameId(group.id, groupPositionId)) || null;
437
+ return normalizeArray(parentProduct.variant_group).find(
438
+ (group) => isSameId(group.position_id, groupPositionId) || isSameId(group.id, groupPositionId)
439
+ ) || null;
490
440
  }
491
441
  function resolveVariantItem(group, itemPositionId) {
492
- if (!group) return null;
493
- return normalizeArray(group.variant_item).find(item => isSameId(item.position_id, itemPositionId) || isSameId(item.id, itemPositionId)) || null;
442
+ if (!group)
443
+ return null;
444
+ return normalizeArray(group.variant_item).find(
445
+ (item) => isSameId(item.position_id, itemPositionId) || isSameId(item.id, itemPositionId)
446
+ ) || null;
494
447
  }
495
448
  function getProductTitleSource(source, locale) {
496
- if (!source || typeof source !== 'object') return '';
449
+ if (!source || typeof source !== "object")
450
+ return "";
497
451
  return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
498
452
  }
499
453
  function resolveTitleValue(value, locale) {
500
- if (value === undefined || value === null) return '';
501
- if (typeof value !== 'object') return stringify(value);
502
- const dashedLocale = locale.replace('_', '-');
503
- const underscoredLocale = locale.replace('-', '_');
504
- return stringify(value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? '');
454
+ if (value === void 0 || value === null)
455
+ return "";
456
+ if (typeof value !== "object")
457
+ return stringify(value);
458
+ const dashedLocale = locale.replace("_", "-");
459
+ const underscoredLocale = locale.replace("-", "_");
460
+ return stringify(
461
+ value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? ""
462
+ );
505
463
  }
506
464
  function resolveOptionTitleFromParentProduct(params) {
507
- const {
508
- option,
509
- parentProduct,
510
- locale
511
- } = params;
512
- if (!parentProduct) return '';
465
+ const { option, parentProduct, locale } = params;
466
+ if (!parentProduct)
467
+ return "";
513
468
  const optionItems = flattenOptionItems(parentProduct);
514
- const matchedOption = optionItems.find(item => isOptionItemMatch(option, item));
469
+ const matchedOption = optionItems.find((item) => isOptionItemMatch(option, item));
515
470
  return getProductTitleSource(matchedOption, locale);
516
471
  }
517
472
  function flattenOptionItems(parentProduct) {
518
473
  const optionGroups = Array.isArray(parentProduct.option_group) ? parentProduct.option_group : [];
519
- return optionGroups.flatMap(group => {
520
- const items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
521
- return items.map(item => ({
474
+ return optionGroups.flatMap((group) => {
475
+ const items = normalizeArray(
476
+ group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item
477
+ );
478
+ return items.map((item) => ({
522
479
  ...item,
523
480
  option_group_id: item.option_group_id ?? group.id ?? group.option_group_id
524
481
  }));
@@ -527,7 +484,8 @@ function flattenOptionItems(parentProduct) {
527
484
  function isOptionItemMatch(option, item) {
528
485
  const optionItemId = option.option_group_item_id ?? option.product_option_item_id ?? option.id;
529
486
  const itemId = item.option_group_item_id ?? item.product_option_item_id ?? item.id;
530
- if (!isSameId(optionItemId, itemId)) return false;
487
+ if (!isSameId(optionItemId, itemId))
488
+ return false;
531
489
  const optionGroupId = option.option_group_id ?? option.group_id;
532
490
  const itemGroupId = item.option_group_id ?? item.group_id;
533
491
  if (isPresentId(optionGroupId) && isPresentId(itemGroupId)) {
@@ -536,82 +494,86 @@ function isOptionItemMatch(option, item) {
536
494
  return true;
537
495
  }
538
496
  function resolveBundleItemFromParentProduct(params) {
539
- const {
540
- bundle,
541
- parentProduct
542
- } = params;
543
- if (!parentProduct) return null;
497
+ const { bundle, parentProduct } = params;
498
+ if (!parentProduct)
499
+ return null;
544
500
  const bundleItems = flattenBundleItems(parentProduct);
545
501
  const bundleVariantId = bundle.bundle_variant_id ?? bundle.variant_id ?? bundle.product_variant_id;
546
502
  if (isNonZeroId(bundleVariantId)) {
547
- const matchedByVariant = bundleItems.find(item => isSameId(item.bundle_variant_id ?? item.variant_id ?? item.product_variant_id, bundleVariantId));
548
- if (matchedByVariant) return matchedByVariant;
503
+ const matchedByVariant = bundleItems.find(
504
+ (item) => isSameId(item.bundle_variant_id ?? item.variant_id ?? item.product_variant_id, bundleVariantId)
505
+ );
506
+ if (matchedByVariant)
507
+ return matchedByVariant;
549
508
  }
550
509
  const bundleId = bundle.bundle_id ?? bundle.id;
551
510
  if (isPresentId(bundleId)) {
552
- const matchedByBundleId = bundleItems.find(item => isSameId(item.id ?? item.bundle_id, bundleId));
553
- if (matchedByBundleId) return matchedByBundleId;
511
+ const matchedByBundleId = bundleItems.find((item) => isSameId(item.id ?? item.bundle_id, bundleId));
512
+ if (matchedByBundleId)
513
+ return matchedByBundleId;
554
514
  }
555
515
  const bundleGroupId = bundle.bundle_group_id ?? bundle.group_id;
556
516
  const bundleProductId = bundle.bundle_product_id ?? bundle._bundle_product_id ?? bundle.product_id;
557
517
  if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
558
- const matchedByGroupAndProduct = bundleItems.find(item => isSameId(item.group_id ?? item.bundle_group_id, bundleGroupId) && isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId));
559
- if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
518
+ const matchedByGroupAndProduct = bundleItems.find(
519
+ (item) => isSameId(item.group_id ?? item.bundle_group_id, bundleGroupId) && isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)
520
+ );
521
+ if (matchedByGroupAndProduct)
522
+ return matchedByGroupAndProduct;
560
523
  }
561
524
  if (isPresentId(bundleProductId)) {
562
- return bundleItems.find(item => isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)) || null;
525
+ return bundleItems.find(
526
+ (item) => isSameId(item.bundle_product_id ?? item._bundle_product_id ?? item.product_id, bundleProductId)
527
+ ) || null;
563
528
  }
564
529
  return null;
565
530
  }
566
531
  function flattenBundleItems(parentProduct) {
567
532
  const bundleGroups = Array.isArray(parentProduct.bundle_group) ? parentProduct.bundle_group : [];
568
- return bundleGroups.flatMap(group => {
533
+ return bundleGroups.flatMap((group) => {
569
534
  const items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
570
- return items.map(item => ({
535
+ return items.map((item) => ({
571
536
  ...item,
572
537
  group_id: item.group_id ?? group.id ?? group.group_id
573
538
  }));
574
539
  });
575
540
  }
576
541
  function isNonZeroId(value) {
577
- return isPresentId(value) && String(value) !== '0';
542
+ return isPresentId(value) && String(value) !== "0";
578
543
  }
579
544
  function isPresentId(value) {
580
- return value !== undefined && value !== null && value !== '';
545
+ return value !== void 0 && value !== null && value !== "";
581
546
  }
582
547
  function isSameId(left, right) {
583
- if (!isPresentId(left) || !isPresentId(right)) return false;
548
+ if (!isPresentId(left) || !isPresentId(right))
549
+ return false;
584
550
  return String(left) === String(right);
585
551
  }
586
552
  function buildOptionTitleSuffix(options) {
587
- const text = options.map(option => {
553
+ const text = options.map((option) => {
588
554
  const name = stringify(option.name).trim();
589
- if (!name) return '';
555
+ if (!name)
556
+ return "";
590
557
  const quantity = option.num ?? 1;
591
558
  return `${name} x ${quantity}`;
592
- }).filter(Boolean).join(', ');
593
- return text ? `(${text})` : '';
559
+ }).filter(Boolean).join(", ");
560
+ return text ? `(${text})` : "";
594
561
  }
595
562
  function formatBundlePrice(bundle, currencySymbol) {
596
563
  const value = bundle.bundle_selling_price ?? bundle.bundle_sum_price ?? bundle.price ?? 0;
597
- const amount = new _decimal.default(toMoneyNumber(value));
598
- const isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
599
- if (isNegative) return `-${currencySymbol}${amount.abs().toFixed(2)}`;
564
+ const amount = new import_decimal.default(toMoneyNumber(value));
565
+ const isNegative = bundle.price_type === "markdown" || bundle.price_type === "markup" && bundle.price_type_ext === "product_price";
566
+ if (isNegative)
567
+ return `-${currencySymbol}${amount.abs().toFixed(2)}`;
600
568
  return formatMoney(amount, currencySymbol);
601
569
  }
602
570
  function buildFees(params) {
603
- const {
604
- order,
605
- shopInfo,
606
- locale,
607
- products,
608
- summary,
609
- currencySymbol
610
- } = params;
571
+ const { order, shopInfo, locale, products, summary, currencySymbol } = params;
611
572
  const fees = [];
612
573
  for (const surcharge of normalizeArray(order.surcharges || summary.surcharges)) {
613
574
  const value = surcharge.amount ?? surcharge.value ?? surcharge.total_amount;
614
- if (!isNonZero(value)) continue;
575
+ if (!isNonZero(value))
576
+ continue;
615
577
  fees.push({
616
578
  item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
617
579
  value: formatMoney(value, currencySymbol)
@@ -620,7 +582,7 @@ function buildFees(params) {
620
582
  const discountAmount = order.shop_discount ?? summary.discount_amount ?? order.discount_amount;
621
583
  if (isNonZero(discountAmount)) {
622
584
  fees.push({
623
- item: label(locale, 'orderDiscount'),
585
+ item: label(locale, "orderDiscount"),
624
586
  value: formatNegativeMoney(discountAmount, currencySymbol)
625
587
  });
626
588
  }
@@ -634,154 +596,126 @@ function buildFees(params) {
634
596
  const roundingAmount = summary.rounding_amount || order.rounding_amount;
635
597
  if (isNonZero(roundingAmount)) {
636
598
  fees.push({
637
- item: label(locale, 'rounding'),
599
+ item: label(locale, "rounding"),
638
600
  value: formatMoney(roundingAmount, currencySymbol)
639
601
  });
640
602
  }
641
603
  const payProcessingFee = summary.pay_service_charge_amount || order.pay_service_charge_amount;
642
604
  if (isNonZero(payProcessingFee)) {
643
605
  fees.push({
644
- item: label(locale, 'payProcessingFee'),
606
+ item: label(locale, "payProcessingFee"),
645
607
  value: formatMoney(payProcessingFee, currencySymbol)
646
608
  });
647
609
  }
648
610
  const productExpectAmount = summary.product_expect_amount || summary.product_amount || order.product_expect_amount;
649
611
  const productOriginalAmount = summary.product_original_amount ?? order.product_original_amount ?? productExpectAmount;
650
- const totalSavingsAmount = new _decimal.default(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
612
+ const totalSavingsAmount = new import_decimal.default(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
651
613
  return {
652
614
  fees,
653
615
  countFee: {
654
616
  total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
655
617
  product_expect_amount: formatMoney(productExpectAmount, currencySymbol),
656
618
  expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
657
- product_quantity: toNumber(summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0), 0),
619
+ product_quantity: toNumber(
620
+ summary.product_quantity || products.reduce((sum, product) => sum + product.product_quantity, 0),
621
+ 0
622
+ ),
658
623
  has_pay: formatMoney(calculateReceiptPaidAmount(order, summary), currencySymbol),
659
- payment_method: '',
624
+ payment_method: "",
660
625
  tax_title: stringify(summary.tax_title || order.tax_title || shopInfo.tax_title),
661
626
  total_refund_amount: formatMoney(summary.total_refund_amount || order.total_refund_amount, currencySymbol),
662
- ...(isNonZero(roundingAmount) ? {
663
- rounding_amount: formatMoney(roundingAmount, currencySymbol)
664
- } : {}),
665
- ...(isNonZero(totalSavingsAmount) ? {
666
- order_total_discount: formatMoney(totalSavingsAmount, currencySymbol)
667
- } : {}),
668
- ...(isNonZero(payProcessingFee) ? {
669
- pay_processing_fee: formatMoney(payProcessingFee, currencySymbol)
670
- } : {}),
671
- ...(isNonZero(taxFee) ? {
672
- tax_fee: formatMoney(taxFee, currencySymbol)
673
- } : {})
627
+ ...isNonZero(roundingAmount) ? { rounding_amount: formatMoney(roundingAmount, currencySymbol) } : {},
628
+ ...isNonZero(totalSavingsAmount) ? { order_total_discount: formatMoney(totalSavingsAmount, currencySymbol) } : {},
629
+ ...isNonZero(payProcessingFee) ? { pay_processing_fee: formatMoney(payProcessingFee, currencySymbol) } : {},
630
+ ...isNonZero(taxFee) ? { tax_fee: formatMoney(taxFee, currencySymbol) } : {}
674
631
  }
675
632
  };
676
633
  }
677
634
  function buildCustomer(order, locale) {
678
- return [{
679
- item: label(locale, 'contactName'),
680
- value: normalizeCustomerDisplayValue(order.customer_name || order.customer?.name || order.customer?.display_name)
681
- }, {
682
- item: label(locale, 'contactMobile'),
683
- value: stringify(order.phone || order.customer?.phone)
684
- }, {
685
- item: label(locale, 'email'),
686
- value: stringify(order.email || order.customer?.email)
687
- }];
635
+ var _a, _b, _c, _d;
636
+ return [
637
+ { item: label(locale, "contactName"), value: normalizeCustomerDisplayValue(order.customer_name || ((_a = order.customer) == null ? void 0 : _a.name) || ((_b = order.customer) == null ? void 0 : _b.display_name)) },
638
+ { item: label(locale, "contactMobile"), value: stringify(order.phone || ((_c = order.customer) == null ? void 0 : _c.phone)) },
639
+ { item: label(locale, "email"), value: stringify(order.email || ((_d = order.customer) == null ? void 0 : _d.email)) }
640
+ ];
688
641
  }
689
642
  function normalizeCustomerDisplayValue(value) {
690
643
  const text = stringify(value).trim();
691
- if (!text) return 'Walk-In';
692
- if (text.toLowerCase() === 'select a customer') return 'Walk-In';
644
+ if (!text)
645
+ return "Walk-In";
646
+ if (text.toLowerCase() === "select a customer")
647
+ return "Walk-In";
693
648
  return text;
694
649
  }
695
- function buildDelivery(order, locale) {
696
- const serviceType = stringify(order.metadata?.service_type || order.service_type || order.delivery_type);
697
- if (!serviceType) return [];
698
- const serviceTypeLabelKey = serviceTypeToLabelKey(serviceType);
699
- const items = [{
700
- item: '',
701
- value: label(locale, serviceTypeLabelKey),
702
- size: 2,
703
- align: 'left'
704
- }];
705
- if (serviceType === 'shop_server' || serviceType === 'shop_service') {
706
- items.push({
707
- item: label(locale, 'pickUpTime'),
708
- value: label(locale, 'asap')
709
- });
710
- }
711
- return items;
712
- }
713
650
  function buildAppointment(order, locale) {
714
- const tableName = order.table_name || order.metadata?.table_name || order.metadata?.table?.name || order.form_data?.table_name;
715
- if (!tableName) return [];
716
- return [{
717
- item: label(locale, 'table'),
718
- value: getLocalizedValue(tableName, locale)
719
- }];
651
+ var _a, _b, _c, _d;
652
+ const tableName = order.table_name || ((_a = order.metadata) == null ? void 0 : _a.table_name) || ((_c = (_b = order.metadata) == null ? void 0 : _b.table) == null ? void 0 : _c.name) || ((_d = order.form_data) == null ? void 0 : _d.table_name);
653
+ if (!tableName)
654
+ return [];
655
+ return [
656
+ {
657
+ item: label(locale, "table"),
658
+ value: getLocalizedValue(tableName, locale)
659
+ }
660
+ ];
720
661
  }
721
662
  function buildResources(order, locale) {
722
- return normalizeArray(order.resources || order.resource_list).map(resource => ({
723
- id: resource.id || resource.resource_id || '',
724
- code: '',
663
+ return normalizeArray(order.resources || order.resource_list).map((resource) => ({
664
+ id: resource.id || resource.resource_id || "",
665
+ code: "",
725
666
  title: getLocalizedValue(resource.title || resource.name, locale),
726
- form_title: getLocalizedValue(resource.form_title || resource.type || '', locale)
667
+ form_title: getLocalizedValue(resource.form_title || resource.type || "", locale)
727
668
  }));
728
669
  }
729
670
  function buildPaymentData(params) {
730
671
  const payments = normalizeArray(params.order.payments);
731
- return payments.filter(payment => isPrintablePayment(payment)).map(payment => {
732
- const items = [{
733
- item: paymentMethodName(payment, params.locale),
734
- value: formatMoney(payment.amount ?? payment.origin_amount, params.currencySymbol)
735
- }];
672
+ return payments.filter((payment) => isPrintablePayment(payment)).map((payment) => {
673
+ var _a;
674
+ const items = [
675
+ {
676
+ item: paymentMethodName(payment, params.locale),
677
+ value: formatMoney(payment.amount ?? payment.origin_amount, params.currencySymbol)
678
+ }
679
+ ];
736
680
  const fundRecord = getFundRecord(payment);
737
681
  if (fundRecord) {
738
- items.push(...buildFundRecordPaymentItems({
739
- payment,
740
- fundRecord,
741
- locale: params.locale,
742
- currencySymbol: params.currencySymbol
743
- }));
682
+ items.push(...buildFundRecordPaymentItems({ payment, fundRecord, locale: params.locale, currencySymbol: params.currencySymbol }));
744
683
  } else {
745
- const remainingAmount = payment.remaining_amount ?? payment.balance ?? payment.metadata?.remaining_amount;
746
- if (remainingAmount !== undefined && remainingAmount !== null) {
684
+ const remainingAmount = payment.remaining_amount ?? payment.balance ?? ((_a = payment.metadata) == null ? void 0 : _a.remaining_amount);
685
+ if (remainingAmount !== void 0 && remainingAmount !== null) {
747
686
  items.push({
748
- item: label(params.locale, 'remainingAmount'),
687
+ item: label(params.locale, "remainingAmount"),
749
688
  value: formatMoney(remainingAmount, params.currencySymbol)
750
689
  });
751
690
  }
752
691
  }
753
692
  items.push({
754
- item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), params.locale),
755
- value: ''
693
+ item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || /* @__PURE__ */ new Date(), params.locale),
694
+ value: ""
756
695
  });
757
696
  return items;
758
697
  });
759
698
  }
760
699
  function buildFundRecordPaymentItems(params) {
761
- const {
762
- payment,
763
- fundRecord,
764
- locale,
765
- currencySymbol
766
- } = params;
700
+ const { payment, fundRecord, locale, currencySymbol } = params;
767
701
  const items = [];
768
702
  const usingBeforeValue = fundRecord.using_before_value;
769
703
  const usingAfterValue = fundRecord.using_after_value;
770
- if (isPointCardPayment(payment) && usingBeforeValue !== undefined && usingAfterValue !== undefined) {
771
- const usedPoints = new _decimal.default(toMoneyNumber(usingBeforeValue)).minus(toMoneyNumber(usingAfterValue));
704
+ if (isPointCardPayment(payment) && usingBeforeValue !== void 0 && usingAfterValue !== void 0) {
705
+ const usedPoints = new import_decimal.default(toMoneyNumber(usingBeforeValue)).minus(toMoneyNumber(usingAfterValue));
772
706
  items.push({
773
- item: label(locale, 'redeemPoints'),
707
+ item: label(locale, "redeemPoints"),
774
708
  value: trimDecimal(usedPoints)
775
709
  });
776
710
  items.push({
777
- item: label(locale, 'remainingPoints'),
778
- value: trimDecimal(new _decimal.default(toMoneyNumber(usingAfterValue)))
711
+ item: label(locale, "remainingPoints"),
712
+ value: trimDecimal(new import_decimal.default(toMoneyNumber(usingAfterValue)))
779
713
  });
780
714
  return items;
781
715
  }
782
- if (usingAfterValue !== undefined && usingAfterValue !== null) {
716
+ if (usingAfterValue !== void 0 && usingAfterValue !== null) {
783
717
  items.push({
784
- item: label(locale, 'remainingAmount'),
718
+ item: label(locale, "remainingAmount"),
785
719
  value: formatMoney(usingAfterValue, currencySymbol)
786
720
  });
787
721
  }
@@ -789,131 +723,169 @@ function buildFundRecordPaymentItems(params) {
789
723
  }
790
724
  function getFundRecord(payment) {
791
725
  const fundRecord = payment.fund_record;
792
- if (!fundRecord || typeof fundRecord !== 'object' || Array.isArray(fundRecord)) return null;
793
- if (!fundRecord.voucher_id && !fundRecord.code) return null;
726
+ if (!fundRecord || typeof fundRecord !== "object" || Array.isArray(fundRecord))
727
+ return null;
728
+ if (!fundRecord.voucher_id && !fundRecord.code)
729
+ return null;
794
730
  return fundRecord;
795
731
  }
796
732
  function isPointCardPayment(payment) {
733
+ var _a;
797
734
  const code = stringify(payment.code || payment.payment_method).toUpperCase();
798
- const type = stringify(payment.type || payment.fund_record?.tag).toLowerCase();
799
- return code === 'POINTCARD' || type === 'point_card';
735
+ const type = stringify(payment.type || ((_a = payment.fund_record) == null ? void 0 : _a.tag)).toLowerCase();
736
+ return code === "POINTCARD" || type === "point_card";
800
737
  }
801
738
  function maskMachineCode(code) {
802
739
  const text = stringify(code);
803
- if (text.length <= 6) return text;
740
+ if (text.length <= 6)
741
+ return text;
804
742
  return `${text.slice(0, 2)}**${text.slice(-4)}`;
805
743
  }
806
744
  function trimDecimal(value) {
807
- return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, '');
745
+ return value.toDecimalPlaces(2).toFixed(2).replace(/\.?0+$/, "");
808
746
  }
809
747
  function getFundRecordPaymentName(payment, locale) {
810
748
  const fundRecord = getFundRecord(payment);
811
- if (!fundRecord) return '';
749
+ if (!fundRecord)
750
+ return "";
812
751
  const name = getLocalizedValue(fundRecord.wallet_pass_name, locale);
813
752
  const code = maskMachineCode(fundRecord.code);
814
- if (!name && !code) return '';
815
- if (!code) return name;
816
- const fallbackName = getLocalizedValue(payment.name || payment.title || payment.payment_method_name || payment.method_name || payment.code, locale);
753
+ if (!name && !code)
754
+ return "";
755
+ if (!code)
756
+ return name;
757
+ const fallbackName = getLocalizedValue(
758
+ payment.name || payment.title || payment.payment_method_name || payment.method_name || payment.code,
759
+ locale
760
+ );
817
761
  return `${name || fallbackName}(${code})`;
818
762
  }
819
763
  function appendMachineCodeToName(name, payment) {
820
764
  const fundRecord = getFundRecord(payment);
821
- if (!fundRecord?.code) return name;
765
+ if (!(fundRecord == null ? void 0 : fundRecord.code))
766
+ return name;
822
767
  return `${name}(${maskMachineCode(fundRecord.code)})`;
823
768
  }
824
769
  function paymentMethodName(payment, locale) {
825
770
  const fundRecordName = getFundRecordPaymentName(payment, locale);
826
- if (fundRecordName) return fundRecordName;
771
+ if (fundRecordName)
772
+ return fundRecordName;
827
773
  const raw = payment.name || payment.title || payment.payment_method_name || payment.method_name;
828
- if (raw) return appendMachineCodeToName(getLocalizedValue(raw, locale), payment);
774
+ if (raw)
775
+ return appendMachineCodeToName(getLocalizedValue(raw, locale), payment);
829
776
  const code = stringify(payment.code || payment.type || payment.payment_method || payment.method).toLowerCase();
830
- if (code.includes('cash')) return label(locale, 'cash');
831
- if (code.includes('eftpos') || code.includes('card')) return label(locale, 'eftpos');
832
- if (code.includes('wallet')) return label(locale, 'wallet');
833
- if (code.includes('gift')) return label(locale, 'giftCard');
777
+ if (code.includes("cash"))
778
+ return label(locale, "cash");
779
+ if (code.includes("eftpos") || code.includes("card"))
780
+ return label(locale, "eftpos");
781
+ if (code.includes("wallet"))
782
+ return label(locale, "wallet");
783
+ if (code.includes("gift"))
784
+ return label(locale, "giftCard");
834
785
  return stringify(payment.code || payment.type || payment.payment_method || payment.method);
835
786
  }
836
787
  function getSummary(order) {
837
- return order.summary && typeof order.summary === 'object' ? order.summary : order;
788
+ return order.summary && typeof order.summary === "object" ? order.summary : order;
838
789
  }
839
790
  function getCurrencySymbol(order, shopInfo) {
840
- return stringify(order.currency_symbol || shopInfo?.currency_symbol || order.shop_symbol || '$') || '$';
791
+ return stringify(order.currency_symbol || (shopInfo == null ? void 0 : shopInfo.currency_symbol) || order.shop_symbol || "$") || "$";
841
792
  }
842
793
  function resolveLocales(shopInfo, locales) {
843
- const preferred = [...(locales || []), shopInfo.primary_locale, ...DEFAULT_LOCALES].filter(Boolean);
794
+ const preferred = [
795
+ ...locales || [],
796
+ shopInfo.primary_locale,
797
+ ...DEFAULT_LOCALES
798
+ ].filter(Boolean);
844
799
  return Array.from(new Set(preferred.map(normalizeLocaleKey)));
845
800
  }
846
801
  function normalizeLocaleKey(locale) {
847
- return locale.replace('-', '_');
802
+ return locale.replace("-", "_");
848
803
  }
849
804
  function label(locale, key) {
850
- return LABELS[locale]?.[key] || LABELS.en[key] || key;
805
+ var _a;
806
+ return ((_a = LABELS[locale]) == null ? void 0 : _a[key]) || LABELS.en[key] || key;
851
807
  }
852
808
  function getLocalizedValue(value, locale) {
853
- if (value === undefined || value === null) return '';
854
- if (typeof value !== 'object') return stringify(value);
855
- const dashedLocale = locale.replace('_', '-');
856
- const underscoredLocale = locale.replace('-', '_');
857
- return stringify(value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? value.default ?? value.en ?? '');
858
- }
859
- function serviceTypeToLabelKey(serviceType) {
860
- const normalized = serviceType.toLowerCase();
861
- if (normalized.includes('take')) return 'takeAway';
862
- if (normalized.includes('delivery')) return 'delivery';
863
- if (normalized.includes('pick')) return 'pickUp';
864
- if (normalized.includes('shop')) return 'shopService';
865
- return 'dineIn';
809
+ if (value === void 0 || value === null)
810
+ return "";
811
+ if (typeof value !== "object")
812
+ return stringify(value);
813
+ const dashedLocale = locale.replace("_", "-");
814
+ const underscoredLocale = locale.replace("-", "_");
815
+ return stringify(
816
+ value[locale] ?? value[dashedLocale] ?? value[underscoredLocale] ?? value.original ?? value.auto ?? value.default ?? value.en ?? ""
817
+ );
866
818
  }
867
819
  function buildShopAddress(shopInfo) {
868
- return [shopInfo.address_street, shopInfo.address_detail, shopInfo.city, shopInfo.province, shopInfo.country, shopInfo.zip].filter(Boolean).join(', ');
820
+ return [
821
+ shopInfo.address_street,
822
+ shopInfo.address_detail,
823
+ shopInfo.city,
824
+ shopInfo.province,
825
+ shopInfo.country,
826
+ shopInfo.zip
827
+ ].filter(Boolean).join(", ");
869
828
  }
870
829
  function formatDateTime(value, locale) {
871
- const date = (0, _dayjs.default)(value);
872
- if (!date.isValid()) return stringify(value);
873
- if (locale === 'en') return date.format('HH:mm:ss DD/MM/YYYY');
874
- return date.format('YYYY/MM/DD HH:mm:ss');
830
+ const date = (0, import_dayjs.default)(value);
831
+ if (!date.isValid())
832
+ return stringify(value);
833
+ if (locale === "en")
834
+ return date.format("HH:mm:ss DD/MM/YYYY");
835
+ return date.format("YYYY/MM/DD HH:mm:ss");
875
836
  }
876
837
  function formatMoney(value, currencySymbol) {
877
- if (value instanceof _decimal.default) return `${currencySymbol}${value.toFixed(2)}`;
878
- if (typeof value === 'string' && value.trim().startsWith(currencySymbol)) return value;
879
- const amount = new _decimal.default(toMoneyNumber(value));
838
+ if (value instanceof import_decimal.default)
839
+ return `${currencySymbol}${value.toFixed(2)}`;
840
+ if (typeof value === "string" && value.trim().startsWith(currencySymbol))
841
+ return value;
842
+ const amount = new import_decimal.default(toMoneyNumber(value));
880
843
  return `${currencySymbol}${amount.toFixed(2)}`;
881
844
  }
882
845
  function formatNegativeMoney(value, currencySymbol) {
883
- const amount = new _decimal.default(toMoneyNumber(value)).abs();
846
+ const amount = new import_decimal.default(toMoneyNumber(value)).abs();
884
847
  return `-${currencySymbol}${amount.toFixed(2)}`;
885
848
  }
886
849
  function calculateReceiptPaidAmount(order, summary) {
887
850
  const paidAmount = sumPayments(order.payments);
888
- const payProcessingFee = new _decimal.default(toMoneyNumber(summary.pay_service_charge_amount ?? order.pay_service_charge_amount));
889
- if (payProcessingFee.lte(0)) return paidAmount;
890
- const totalAmount = new _decimal.default(toMoneyNumber(summary.total_amount ?? order.total_amount));
891
- if (totalAmount.gt(0) && paidAmount.gte(totalAmount)) return paidAmount;
851
+ const payProcessingFee = new import_decimal.default(
852
+ toMoneyNumber(summary.pay_service_charge_amount ?? order.pay_service_charge_amount)
853
+ );
854
+ if (payProcessingFee.lte(0))
855
+ return paidAmount;
856
+ const totalAmount = new import_decimal.default(toMoneyNumber(summary.total_amount ?? order.total_amount));
857
+ if (totalAmount.gt(0) && paidAmount.gte(totalAmount))
858
+ return paidAmount;
892
859
  const paidAmountWithFee = paidAmount.plus(payProcessingFee);
893
- if (totalAmount.gt(0) && paidAmountWithFee.gt(totalAmount)) return totalAmount;
860
+ if (totalAmount.gt(0) && paidAmountWithFee.gt(totalAmount))
861
+ return totalAmount;
894
862
  return paidAmountWithFee;
895
863
  }
896
864
  function sumPayments(payments) {
897
- return normalizeArray(payments).filter(payment => isPrintablePayment(payment)).reduce((sum, payment) => {
865
+ return normalizeArray(payments).filter((payment) => isPrintablePayment(payment)).reduce((sum, payment) => {
898
866
  return sum.plus(toMoneyNumber(payment.amount ?? payment.origin_amount));
899
- }, new _decimal.default(0));
867
+ }, new import_decimal.default(0));
900
868
  }
901
869
  function isPrintablePayment(payment) {
902
870
  const status = stringify(payment.status).toLowerCase();
903
- if (!status) return true;
904
- return ['paid', 'success', 'succeeded', 'completed'].includes(status);
871
+ if (!status)
872
+ return true;
873
+ return ["paid", "success", "succeeded", "completed"].includes(status);
905
874
  }
906
875
  function normalizeArray(value) {
907
876
  return Array.isArray(value) ? value : [];
908
877
  }
909
878
  function isNonZero(value) {
910
- return !new _decimal.default(toMoneyNumber(value)).isZero();
879
+ return !new import_decimal.default(toMoneyNumber(value)).isZero();
911
880
  }
912
881
  function toMoneyNumber(value) {
913
- if (value instanceof _decimal.default) return value.toString();
914
- if (typeof value === 'number') return Number.isFinite(value) ? value : 0;
915
- if (typeof value !== 'string') return 0;
916
- const normalized = value.replace(/[^\d.-]/g, '');
882
+ if (value instanceof import_decimal.default)
883
+ return value.toString();
884
+ if (typeof value === "number")
885
+ return Number.isFinite(value) ? value : 0;
886
+ if (typeof value !== "string")
887
+ return 0;
888
+ const normalized = value.replace(/[^\d.-]/g, "");
917
889
  return normalized || 0;
918
890
  }
919
891
  function toNumber(value, fallback) {
@@ -921,6 +893,12 @@ function toNumber(value, fallback) {
921
893
  return Number.isFinite(numberValue) ? numberValue : fallback;
922
894
  }
923
895
  function stringify(value) {
924
- if (value === undefined || value === null) return '';
896
+ if (value === void 0 || value === null)
897
+ return "";
925
898
  return String(value);
926
- }
899
+ }
900
+ // Annotate the CommonJS export names for ESM import in node:
901
+ 0 && (module.exports = {
902
+ buildSmallTicketData,
903
+ hasSmallTicketData
904
+ });