@aglyn/plugins-commerce 1.0.0-beta.143

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 (417) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +10 -0
  3. package/package.json +57 -0
  4. package/src/index.d.ts +38 -0
  5. package/src/index.js +38 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/components/account.d.ts +31 -0
  8. package/src/lib/components/account.js +645 -0
  9. package/src/lib/components/account.js.map +1 -0
  10. package/src/lib/components/cart.d.ts +38 -0
  11. package/src/lib/components/cart.js +851 -0
  12. package/src/lib/components/cart.js.map +1 -0
  13. package/src/lib/components/commerce-console-page.d.ts +32 -0
  14. package/src/lib/components/commerce-console-page.js +296 -0
  15. package/src/lib/components/commerce-console-page.js.map +1 -0
  16. package/src/lib/components/commerce-console-sections.d.ts +34 -0
  17. package/src/lib/components/commerce-console-sections.js +62 -0
  18. package/src/lib/components/commerce-console-sections.js.map +1 -0
  19. package/src/lib/components/console/catalog-organization-card.component.d.ts +14 -0
  20. package/src/lib/components/console/catalog-organization-card.component.js +1087 -0
  21. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -0
  22. package/src/lib/components/console/commerce-analytics-card.component.d.ts +27 -0
  23. package/src/lib/components/console/commerce-analytics-card.component.js +310 -0
  24. package/src/lib/components/console/commerce-analytics-card.component.js.map +1 -0
  25. package/src/lib/components/console/commerce-glance-card.component.d.ts +20 -0
  26. package/src/lib/components/console/commerce-glance-card.component.js +340 -0
  27. package/src/lib/components/console/commerce-glance-card.component.js.map +1 -0
  28. package/src/lib/components/console/commerce-stat-tile.component.d.ts +37 -0
  29. package/src/lib/components/console/commerce-stat-tile.component.js +72 -0
  30. package/src/lib/components/console/commerce-stat-tile.component.js.map +1 -0
  31. package/src/lib/components/console/discounts-card.component.d.ts +14 -0
  32. package/src/lib/components/console/discounts-card.component.js +443 -0
  33. package/src/lib/components/console/discounts-card.component.js.map +1 -0
  34. package/src/lib/components/console/entitlement-gate.component.d.ts +76 -0
  35. package/src/lib/components/console/entitlement-gate.component.js +115 -0
  36. package/src/lib/components/console/entitlement-gate.component.js.map +1 -0
  37. package/src/lib/components/console/gift-cards-card.component.d.ts +29 -0
  38. package/src/lib/components/console/gift-cards-card.component.js +379 -0
  39. package/src/lib/components/console/gift-cards-card.component.js.map +1 -0
  40. package/src/lib/components/console/host-coupons-card.component.d.ts +14 -0
  41. package/src/lib/components/console/host-coupons-card.component.js +252 -0
  42. package/src/lib/components/console/host-coupons-card.component.js.map +1 -0
  43. package/src/lib/components/console/host-orders-card.component.d.ts +13 -0
  44. package/src/lib/components/console/host-orders-card.component.js +861 -0
  45. package/src/lib/components/console/host-orders-card.component.js.map +1 -0
  46. package/src/lib/components/console/locations-card.component.d.ts +14 -0
  47. package/src/lib/components/console/locations-card.component.js +256 -0
  48. package/src/lib/components/console/locations-card.component.js.map +1 -0
  49. package/src/lib/components/console/member-posts-card.component.d.ts +8 -0
  50. package/src/lib/components/console/member-posts-card.component.js +283 -0
  51. package/src/lib/components/console/member-posts-card.component.js.map +1 -0
  52. package/src/lib/components/console/newest-site-users-card.component.d.ts +36 -0
  53. package/src/lib/components/console/newest-site-users-card.component.js +126 -0
  54. package/src/lib/components/console/newest-site-users-card.component.js.map +1 -0
  55. package/src/lib/components/console/order-detail-dialog.component.d.ts +28 -0
  56. package/src/lib/components/console/order-detail-dialog.component.js +976 -0
  57. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -0
  58. package/src/lib/components/console/paid-media.d.ts +127 -0
  59. package/src/lib/components/console/paid-media.js +397 -0
  60. package/src/lib/components/console/paid-media.js.map +1 -0
  61. package/src/lib/components/console/payments-settings-card.component.d.ts +13 -0
  62. package/src/lib/components/console/payments-settings-card.component.js +295 -0
  63. package/src/lib/components/console/payments-settings-card.component.js.map +1 -0
  64. package/src/lib/components/console/pos-page.component.d.ts +13 -0
  65. package/src/lib/components/console/pos-page.component.js +916 -0
  66. package/src/lib/components/console/pos-page.component.js.map +1 -0
  67. package/src/lib/components/console/product-editor-dialog.component.d.ts +32 -0
  68. package/src/lib/components/console/product-editor-dialog.component.js +1374 -0
  69. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -0
  70. package/src/lib/components/console/products-hub-card.component.d.ts +16 -0
  71. package/src/lib/components/console/products-hub-card.component.js +1280 -0
  72. package/src/lib/components/console/products-hub-card.component.js.map +1 -0
  73. package/src/lib/components/console/products-hub-zone.component.d.ts +50 -0
  74. package/src/lib/components/console/products-hub-zone.component.js +200 -0
  75. package/src/lib/components/console/products-hub-zone.component.js.map +1 -0
  76. package/src/lib/components/console/recovery-queue-card.component.d.ts +39 -0
  77. package/src/lib/components/console/recovery-queue-card.component.js +262 -0
  78. package/src/lib/components/console/recovery-queue-card.component.js.map +1 -0
  79. package/src/lib/components/console/registers-card.component.d.ts +21 -0
  80. package/src/lib/components/console/registers-card.component.js +296 -0
  81. package/src/lib/components/console/registers-card.component.js.map +1 -0
  82. package/src/lib/components/console/reservations-card.component.d.ts +14 -0
  83. package/src/lib/components/console/reservations-card.component.js +650 -0
  84. package/src/lib/components/console/reservations-card.component.js.map +1 -0
  85. package/src/lib/components/console/reviews-moderation-card.component.d.ts +8 -0
  86. package/src/lib/components/console/reviews-moderation-card.component.js +235 -0
  87. package/src/lib/components/console/reviews-moderation-card.component.js.map +1 -0
  88. package/src/lib/components/console/shipping-settings-card.component.d.ts +38 -0
  89. package/src/lib/components/console/shipping-settings-card.component.js +560 -0
  90. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -0
  91. package/src/lib/components/console/stock-movements-card.component.d.ts +31 -0
  92. package/src/lib/components/console/stock-movements-card.component.js +333 -0
  93. package/src/lib/components/console/stock-movements-card.component.js.map +1 -0
  94. package/src/lib/components/console/store-settings-card.component.d.ts +14 -0
  95. package/src/lib/components/console/store-settings-card.component.js +300 -0
  96. package/src/lib/components/console/store-settings-card.component.js.map +1 -0
  97. package/src/lib/components/console/storefront-tax-summary-card.component.d.ts +73 -0
  98. package/src/lib/components/console/storefront-tax-summary-card.component.js +408 -0
  99. package/src/lib/components/console/storefront-tax-summary-card.component.js.map +1 -0
  100. package/src/lib/components/console/suppliers-card.component.d.ts +8 -0
  101. package/src/lib/components/console/suppliers-card.component.js +328 -0
  102. package/src/lib/components/console/suppliers-card.component.js.map +1 -0
  103. package/src/lib/components/console/tax-settings-card.component.d.ts +14 -0
  104. package/src/lib/components/console/tax-settings-card.component.js +473 -0
  105. package/src/lib/components/console/tax-settings-card.component.js.map +1 -0
  106. package/src/lib/components/gate.d.ts +39 -0
  107. package/src/lib/components/gate.js +202 -0
  108. package/src/lib/components/gate.js.map +1 -0
  109. package/src/lib/components/gated-video.d.ts +40 -0
  110. package/src/lib/components/gated-video.js +366 -0
  111. package/src/lib/components/gated-video.js.map +1 -0
  112. package/src/lib/components/member-feed.d.ts +32 -0
  113. package/src/lib/components/member-feed.js +198 -0
  114. package/src/lib/components/member-feed.js.map +1 -0
  115. package/src/lib/components/member-recovery.d.ts +35 -0
  116. package/src/lib/components/member-recovery.js +313 -0
  117. package/src/lib/components/member-recovery.js.map +1 -0
  118. package/src/lib/components/member-signin.d.ts +35 -0
  119. package/src/lib/components/member-signin.js +257 -0
  120. package/src/lib/components/member-signin.js.map +1 -0
  121. package/src/lib/components/member-signup.d.ts +34 -0
  122. package/src/lib/components/member-signup.js +287 -0
  123. package/src/lib/components/member-signup.js.map +1 -0
  124. package/src/lib/components/newsletter-signup.d.ts +39 -0
  125. package/src/lib/components/newsletter-signup.js +229 -0
  126. package/src/lib/components/newsletter-signup.js.map +1 -0
  127. package/src/lib/components/product-detail.d.ts +38 -0
  128. package/src/lib/components/product-detail.js +1022 -0
  129. package/src/lib/components/product-detail.js.map +1 -0
  130. package/src/lib/components/product-grid.d.ts +67 -0
  131. package/src/lib/components/product-grid.js +909 -0
  132. package/src/lib/components/product-grid.js.map +1 -0
  133. package/src/lib/components/product-reviews.d.ts +32 -0
  134. package/src/lib/components/product-reviews.js +349 -0
  135. package/src/lib/components/product-reviews.js.map +1 -0
  136. package/src/lib/components/related-products.d.ts +33 -0
  137. package/src/lib/components/related-products.js +232 -0
  138. package/src/lib/components/related-products.js.map +1 -0
  139. package/src/lib/components/reservation-widget.d.ts +33 -0
  140. package/src/lib/components/reservation-widget.js +418 -0
  141. package/src/lib/components/reservation-widget.js.map +1 -0
  142. package/src/lib/components/storefront-payment-element-fallback.d.ts +18 -0
  143. package/src/lib/components/storefront-payment-element-fallback.js +51 -0
  144. package/src/lib/components/storefront-payment-element-fallback.js.map +1 -0
  145. package/src/lib/components/storefront-payment-element.d.ts +78 -0
  146. package/src/lib/components/storefront-payment-element.js +156 -0
  147. package/src/lib/components/storefront-payment-element.js.map +1 -0
  148. package/src/lib/components/wishlist.d.ts +46 -0
  149. package/src/lib/components/wishlist.js +304 -0
  150. package/src/lib/components/wishlist.js.map +1 -0
  151. package/src/lib/constants/bundle-common.d.ts +18 -0
  152. package/src/lib/constants/bundle-common.js +18 -0
  153. package/src/lib/constants/bundle-common.js.map +1 -0
  154. package/src/lib/constants/product-filters.d.ts +35 -0
  155. package/src/lib/constants/product-filters.js +109 -0
  156. package/src/lib/constants/product-filters.js.map +1 -0
  157. package/src/lib/model/commerce-cart.d.ts +52 -0
  158. package/src/lib/model/commerce-cart.js +102 -0
  159. package/src/lib/model/commerce-cart.js.map +1 -0
  160. package/src/lib/model/commerce-connect-transfer.d.ts +243 -0
  161. package/src/lib/model/commerce-connect-transfer.js +231 -0
  162. package/src/lib/model/commerce-connect-transfer.js.map +1 -0
  163. package/src/lib/model/commerce-discounts.d.ts +164 -0
  164. package/src/lib/model/commerce-discounts.js +231 -0
  165. package/src/lib/model/commerce-discounts.js.map +1 -0
  166. package/src/lib/model/commerce-dispute.d.ts +124 -0
  167. package/src/lib/model/commerce-dispute.js +225 -0
  168. package/src/lib/model/commerce-dispute.js.map +1 -0
  169. package/src/lib/model/commerce-gift-cards.d.ts +107 -0
  170. package/src/lib/model/commerce-gift-cards.js +121 -0
  171. package/src/lib/model/commerce-gift-cards.js.map +1 -0
  172. package/src/lib/model/commerce-io.d.ts +36 -0
  173. package/src/lib/model/commerce-io.js +245 -0
  174. package/src/lib/model/commerce-io.js.map +1 -0
  175. package/src/lib/model/commerce-orders.d.ts +1040 -0
  176. package/src/lib/model/commerce-orders.js +1022 -0
  177. package/src/lib/model/commerce-orders.js.map +1 -0
  178. package/src/lib/model/commerce-promotions.d.ts +188 -0
  179. package/src/lib/model/commerce-promotions.js +199 -0
  180. package/src/lib/model/commerce-promotions.js.map +1 -0
  181. package/src/lib/model/commerce-reservations.d.ts +175 -0
  182. package/src/lib/model/commerce-reservations.js +157 -0
  183. package/src/lib/model/commerce-reservations.js.map +1 -0
  184. package/src/lib/model/commerce-shipping.d.ts +316 -0
  185. package/src/lib/model/commerce-shipping.js +484 -0
  186. package/src/lib/model/commerce-shipping.js.map +1 -0
  187. package/src/lib/model/commerce-stock-holds.d.ts +199 -0
  188. package/src/lib/model/commerce-stock-holds.js +190 -0
  189. package/src/lib/model/commerce-stock-holds.js.map +1 -0
  190. package/src/lib/model/commerce-subscription-status.d.ts +67 -0
  191. package/src/lib/model/commerce-subscription-status.js +76 -0
  192. package/src/lib/model/commerce-subscription-status.js.map +1 -0
  193. package/src/lib/model/commerce-tax-decision.d.ts +222 -0
  194. package/src/lib/model/commerce-tax-decision.js +165 -0
  195. package/src/lib/model/commerce-tax-decision.js.map +1 -0
  196. package/src/lib/model/commerce-tax.d.ts +176 -0
  197. package/src/lib/model/commerce-tax.js +92 -0
  198. package/src/lib/model/commerce-tax.js.map +1 -0
  199. package/src/lib/model/commerce.d.ts +551 -0
  200. package/src/lib/model/commerce.js +739 -0
  201. package/src/lib/model/commerce.js.map +1 -0
  202. package/src/lib/model/index.d.ts +40 -0
  203. package/src/lib/model/index.js +40 -0
  204. package/src/lib/model/index.js.map +1 -0
  205. package/src/lib/model/order-figures.d.ts +48 -0
  206. package/src/lib/model/order-figures.js +74 -0
  207. package/src/lib/model/order-figures.js.map +1 -0
  208. package/src/lib/model/plugin-permissions.d.ts +23 -0
  209. package/src/lib/model/plugin-permissions.js +34 -0
  210. package/src/lib/model/plugin-permissions.js.map +1 -0
  211. package/src/lib/model/purchase-analytics.d.ts +186 -0
  212. package/src/lib/model/purchase-analytics.js +216 -0
  213. package/src/lib/model/purchase-analytics.js.map +1 -0
  214. package/src/lib/plugin-config.d.ts +62 -0
  215. package/src/lib/plugin-config.js +78 -0
  216. package/src/lib/plugin-config.js.map +1 -0
  217. package/src/lib/plugin.d.ts +28 -0
  218. package/src/lib/plugin.js +147 -0
  219. package/src/lib/plugin.js.map +1 -0
  220. package/src/lib/server/billing-webhook.d.ts +26 -0
  221. package/src/lib/server/billing-webhook.js +4011 -0
  222. package/src/lib/server/billing-webhook.js.map +1 -0
  223. package/src/lib/server/cancel-order.d.ts +87 -0
  224. package/src/lib/server/cancel-order.js +368 -0
  225. package/src/lib/server/cancel-order.js.map +1 -0
  226. package/src/lib/server/cart-checkout.d.ts +25 -0
  227. package/src/lib/server/cart-checkout.js +976 -0
  228. package/src/lib/server/cart-checkout.js.map +1 -0
  229. package/src/lib/server/cart-cookie.d.ts +32 -0
  230. package/src/lib/server/cart-cookie.js +77 -0
  231. package/src/lib/server/cart-cookie.js.map +1 -0
  232. package/src/lib/server/cart.d.ts +34 -0
  233. package/src/lib/server/cart.js +181 -0
  234. package/src/lib/server/cart.js.map +1 -0
  235. package/src/lib/server/catalog.d.ts +127 -0
  236. package/src/lib/server/catalog.js +277 -0
  237. package/src/lib/server/catalog.js.map +1 -0
  238. package/src/lib/server/checkout.d.ts +36 -0
  239. package/src/lib/server/checkout.js +915 -0
  240. package/src/lib/server/checkout.js.map +1 -0
  241. package/src/lib/server/connect.d.ts +26 -0
  242. package/src/lib/server/connect.js +238 -0
  243. package/src/lib/server/connect.js.map +1 -0
  244. package/src/lib/server/contact-refund.d.ts +117 -0
  245. package/src/lib/server/contact-refund.js +196 -0
  246. package/src/lib/server/contact-refund.js.map +1 -0
  247. package/src/lib/server/download.d.ts +39 -0
  248. package/src/lib/server/download.js +206 -0
  249. package/src/lib/server/download.js.map +1 -0
  250. package/src/lib/server/draft-order.d.ts +26 -0
  251. package/src/lib/server/draft-order.js +706 -0
  252. package/src/lib/server/draft-order.js.map +1 -0
  253. package/src/lib/server/feed.d.ts +24 -0
  254. package/src/lib/server/feed.js +59 -0
  255. package/src/lib/server/feed.js.map +1 -0
  256. package/src/lib/server/fulfill-order.d.ts +97 -0
  257. package/src/lib/server/fulfill-order.js +235 -0
  258. package/src/lib/server/fulfill-order.js.map +1 -0
  259. package/src/lib/server/gate.d.ts +36 -0
  260. package/src/lib/server/gate.js +112 -0
  261. package/src/lib/server/gate.js.map +1 -0
  262. package/src/lib/server/gift-cards.d.ts +42 -0
  263. package/src/lib/server/gift-cards.js +219 -0
  264. package/src/lib/server/gift-cards.js.map +1 -0
  265. package/src/lib/server/low-stock.d.ts +49 -0
  266. package/src/lib/server/low-stock.js +60 -0
  267. package/src/lib/server/low-stock.js.map +1 -0
  268. package/src/lib/server/manual-tax-rate.d.ts +82 -0
  269. package/src/lib/server/manual-tax-rate.js +113 -0
  270. package/src/lib/server/manual-tax-rate.js.map +1 -0
  271. package/src/lib/server/member-feed.d.ts +24 -0
  272. package/src/lib/server/member-feed.js +72 -0
  273. package/src/lib/server/member-feed.js.map +1 -0
  274. package/src/lib/server/member-name-search.d.ts +37 -0
  275. package/src/lib/server/member-name-search.js +42 -0
  276. package/src/lib/server/member-name-search.js.map +1 -0
  277. package/src/lib/server/member-post.d.ts +23 -0
  278. package/src/lib/server/member-post.js +166 -0
  279. package/src/lib/server/member-post.js.map +1 -0
  280. package/src/lib/server/membership-account.d.ts +37 -0
  281. package/src/lib/server/membership-account.js +148 -0
  282. package/src/lib/server/membership-account.js.map +1 -0
  283. package/src/lib/server/membership-admin-password.d.ts +33 -0
  284. package/src/lib/server/membership-admin-password.js +202 -0
  285. package/src/lib/server/membership-admin-password.js.map +1 -0
  286. package/src/lib/server/membership-content.d.ts +23 -0
  287. package/src/lib/server/membership-content.js +105 -0
  288. package/src/lib/server/membership-content.js.map +1 -0
  289. package/src/lib/server/membership-login.d.ts +19 -0
  290. package/src/lib/server/membership-login.js +137 -0
  291. package/src/lib/server/membership-login.js.map +1 -0
  292. package/src/lib/server/membership-logout.d.ts +19 -0
  293. package/src/lib/server/membership-logout.js +35 -0
  294. package/src/lib/server/membership-logout.js.map +1 -0
  295. package/src/lib/server/membership-recover.d.ts +60 -0
  296. package/src/lib/server/membership-recover.js +244 -0
  297. package/src/lib/server/membership-recover.js.map +1 -0
  298. package/src/lib/server/membership-register.d.ts +22 -0
  299. package/src/lib/server/membership-register.js +241 -0
  300. package/src/lib/server/membership-register.js.map +1 -0
  301. package/src/lib/server/membership-reset.d.ts +26 -0
  302. package/src/lib/server/membership-reset.js +88 -0
  303. package/src/lib/server/membership-reset.js.map +1 -0
  304. package/src/lib/server/membership-wishlist.d.ts +23 -0
  305. package/src/lib/server/membership-wishlist.js +89 -0
  306. package/src/lib/server/membership-wishlist.js.map +1 -0
  307. package/src/lib/server/membership.d.ts +96 -0
  308. package/src/lib/server/membership.js +222 -0
  309. package/src/lib/server/membership.js.map +1 -0
  310. package/src/lib/server/native-checkout.d.ts +170 -0
  311. package/src/lib/server/native-checkout.js +193 -0
  312. package/src/lib/server/native-checkout.js.map +1 -0
  313. package/src/lib/server/newsletter.d.ts +23 -0
  314. package/src/lib/server/newsletter.js +323 -0
  315. package/src/lib/server/newsletter.js.map +1 -0
  316. package/src/lib/server/notify-restock.d.ts +22 -0
  317. package/src/lib/server/notify-restock.js +84 -0
  318. package/src/lib/server/notify-restock.js.map +1 -0
  319. package/src/lib/server/order-analytics.d.ts +134 -0
  320. package/src/lib/server/order-analytics.js +263 -0
  321. package/src/lib/server/order-analytics.js.map +1 -0
  322. package/src/lib/server/order-figures.d.ts +33 -0
  323. package/src/lib/server/order-figures.js +220 -0
  324. package/src/lib/server/order-figures.js.map +1 -0
  325. package/src/lib/server/paid-media-delivery.d.ts +173 -0
  326. package/src/lib/server/paid-media-delivery.js +212 -0
  327. package/src/lib/server/paid-media-delivery.js.map +1 -0
  328. package/src/lib/server/pos-order.d.ts +54 -0
  329. package/src/lib/server/pos-order.js +1137 -0
  330. package/src/lib/server/pos-order.js.map +1 -0
  331. package/src/lib/server/process-abandoned.d.ts +54 -0
  332. package/src/lib/server/process-abandoned.js +222 -0
  333. package/src/lib/server/process-abandoned.js.map +1 -0
  334. package/src/lib/server/process-restock.d.ts +42 -0
  335. package/src/lib/server/process-restock.js +219 -0
  336. package/src/lib/server/process-restock.js.map +1 -0
  337. package/src/lib/server/product-card.d.ts +29 -0
  338. package/src/lib/server/product-card.js +54 -0
  339. package/src/lib/server/product-card.js.map +1 -0
  340. package/src/lib/server/product.d.ts +70 -0
  341. package/src/lib/server/product.js +105 -0
  342. package/src/lib/server/product.js.map +1 -0
  343. package/src/lib/server/promotion-hold.d.ts +144 -0
  344. package/src/lib/server/promotion-hold.js +174 -0
  345. package/src/lib/server/promotion-hold.js.map +1 -0
  346. package/src/lib/server/reconcile-stock.d.ts +106 -0
  347. package/src/lib/server/reconcile-stock.js +349 -0
  348. package/src/lib/server/reconcile-stock.js.map +1 -0
  349. package/src/lib/server/refund.d.ts +45 -0
  350. package/src/lib/server/refund.js +607 -0
  351. package/src/lib/server/refund.js.map +1 -0
  352. package/src/lib/server/related.d.ts +24 -0
  353. package/src/lib/server/related.js +104 -0
  354. package/src/lib/server/related.js.map +1 -0
  355. package/src/lib/server/reservation-availability.d.ts +23 -0
  356. package/src/lib/server/reservation-availability.js +111 -0
  357. package/src/lib/server/reservation-availability.js.map +1 -0
  358. package/src/lib/server/reserve-stock.d.ts +156 -0
  359. package/src/lib/server/reserve-stock.js +146 -0
  360. package/src/lib/server/reserve-stock.js.map +1 -0
  361. package/src/lib/server/reserve.d.ts +25 -0
  362. package/src/lib/server/reserve.js +426 -0
  363. package/src/lib/server/reserve.js.map +1 -0
  364. package/src/lib/server/restock-flag.d.ts +202 -0
  365. package/src/lib/server/restock-flag.js +449 -0
  366. package/src/lib/server/restock-flag.js.map +1 -0
  367. package/src/lib/server/reviews.d.ts +51 -0
  368. package/src/lib/server/reviews.js +132 -0
  369. package/src/lib/server/reviews.js.map +1 -0
  370. package/src/lib/server/site-page-enricher.d.ts +42 -0
  371. package/src/lib/server/site-page-enricher.js +149 -0
  372. package/src/lib/server/site-page-enricher.js.map +1 -0
  373. package/src/lib/server/site-page-resolver.d.ts +26 -0
  374. package/src/lib/server/site-page-resolver.js +223 -0
  375. package/src/lib/server/site-page-resolver.js.map +1 -0
  376. package/src/lib/server/stock-hold.d.ts +127 -0
  377. package/src/lib/server/stock-hold.js +258 -0
  378. package/src/lib/server/stock-hold.js.map +1 -0
  379. package/src/lib/server/storefront-tax-record.d.ts +22 -0
  380. package/src/lib/server/storefront-tax-record.js +218 -0
  381. package/src/lib/server/storefront-tax-record.js.map +1 -0
  382. package/src/lib/server/storefront-tax.d.ts +197 -0
  383. package/src/lib/server/storefront-tax.js +245 -0
  384. package/src/lib/server/storefront-tax.js.map +1 -0
  385. package/src/lib/server/stream.d.ts +25 -0
  386. package/src/lib/server/stream.js +191 -0
  387. package/src/lib/server/stream.js.map +1 -0
  388. package/src/lib/server/subscription-portal.d.ts +24 -0
  389. package/src/lib/server/subscription-portal.js +91 -0
  390. package/src/lib/server/subscription-portal.js.map +1 -0
  391. package/src/lib/server/supplier-outbox.d.ts +190 -0
  392. package/src/lib/server/supplier-outbox.js +342 -0
  393. package/src/lib/server/supplier-outbox.js.map +1 -0
  394. package/src/lib/server/supplier-update.d.ts +23 -0
  395. package/src/lib/server/supplier-update.js +289 -0
  396. package/src/lib/server/supplier-update.js.map +1 -0
  397. package/src/lib/server/tax-profile.d.ts +29 -0
  398. package/src/lib/server/tax-profile.js +40 -0
  399. package/src/lib/server/tax-profile.js.map +1 -0
  400. package/src/lib/server.d.ts +32 -0
  401. package/src/lib/server.js +311 -0
  402. package/src/lib/server.js.map +1 -0
  403. package/src/lib/site.d.ts +27 -0
  404. package/src/lib/site.js +134 -0
  405. package/src/lib/site.js.map +1 -0
  406. package/src/lib/utils/escape-html.d.ts +41 -0
  407. package/src/lib/utils/escape-html.js +41 -0
  408. package/src/lib/utils/escape-html.js.map +1 -0
  409. package/src/lib/utils/generate-preset-id.d.ts +19 -0
  410. package/src/lib/utils/generate-preset-id.js +25 -0
  411. package/src/lib/utils/generate-preset-id.js.map +1 -0
  412. package/src/lib/utils/member-continue.d.ts +45 -0
  413. package/src/lib/utils/member-continue.js +49 -0
  414. package/src/lib/utils/member-continue.js.map +1 -0
  415. package/src/lib/utils/use-storefront-purchase-event.d.ts +60 -0
  416. package/src/lib/utils/use-storefront-purchase-event.js +142 -0
  417. package/src/lib/utils/use-storefront-purchase-event.js.map +1 -0
@@ -0,0 +1,916 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
19
+ import * as Aglyn from "@aglyn/aglyn";
20
+ import * as CommerceModel from "../../model/index.js";
21
+ import { PRODUCT_LIST_FILTER_FIELDS } from "../../constants/product-filters.js";
22
+ import { escapeHtml } from "../../utils/escape-html.js";
23
+ import { NextPageTitle } from "@aglyn/shared-ui-next/contexts/next-page-title-provider";
24
+ import { useSnackbar } from "@aglyn/shared-ui-snackstack";
25
+ import { Alert, Box, Button, Card, CardActionArea, Chip, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, Stack, TextField, Typography } from "@mui/material";
26
+ import { QRCodeSVG } from "qrcode.react";
27
+ import { collection, documentId, getDocs, limit, orderBy, query, where } from "firebase/firestore";
28
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
29
+ import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
30
+ import { listFilterConstraints, useFirestoreCollection } from "@aglyn/tenant-feature-instance";
31
+ import { useOrgPlan } from "@aglyn/tenant-feature-instance";
32
+ import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
33
+ const usd = (cents)=>`$${(cents / 100).toFixed(2)}`;
34
+ /**
35
+ * POS register (AGL-312): touch-first full-screen sale surface —
36
+ * product grid with search/barcode (keyboard-wedge scanners type into
37
+ * the search box and press Enter), a register cart with a whole-sale
38
+ * discount, and cash / QR-card / reservation-folio settlement through
39
+ * the server-priced pos-order API. Receipts print via the browser.
40
+ */ /*
41
+ * `managePos` is NOT read here. The nav item in `plugin.ts` declares it and
42
+ * the shell refuses the route before this component is constructed, so a
43
+ * reader without the key never reaches this file and there is no unpermitted
44
+ * state for it to render — the same arrangement the entitlement gate has.
45
+ *
46
+ * Re-adding a check off the `permissions` prop would be a second answer to a
47
+ * settled question, and a laxer one: a prop absent because the map has not
48
+ * landed reads as permitted here, while the shell holds the route on that
49
+ * same condition rather than guessing. `server/pos-order.ts` remains the
50
+ * enforcement point for the sale itself.
51
+ */ export function PosConsolePage({ hostId }) {
52
+ var _ref;
53
+ var _usableRegisters_;
54
+ const firestore = useFirestore();
55
+ const { data: user } = useUser();
56
+ const { enqueueSnackbar } = useSnackbar();
57
+ const [search, setSearch] = useState('');
58
+ const { data: productDocs } = useFirestoreCollection(()=>{
59
+ /*
60
+ * The till's grid, narrowed by the QUERY rather than by the rows it
61
+ * happened to fetch (AGL-2501, AGL-2292).
62
+ *
63
+ * `limit(500)` with no `orderBy` is document-id order over
64
+ * `createResourceUid()` — an arbitrary five hundred. Both filters then
65
+ * ran over that sample: `status === 'active'` below, and the search.
66
+ * The status one is the quieter of the two, because a catalog of five
67
+ * hundred archived products and a hundred live ones would fill the
68
+ * window with the archived and leave the register showing almost
69
+ * nothing to sell.
70
+ *
71
+ * Status moves into the query, so the window is five hundred SELLABLE
72
+ * products; the typed search moves in beside it, so a name reaches the
73
+ * whole catalog. The scan does not come through here at all — see
74
+ * `handleSearchEnter`, which is a lookup rather than a filter.
75
+ */ const typed = listFilterConstraints(PRODUCT_LIST_FILTER_FIELDS, search.trim() ? {
76
+ field: 'name',
77
+ op: 'contains',
78
+ value: search.trim()
79
+ } : null, // Status is already an equality on this query, so the translator must
80
+ // not add an ordering that would have to be the first `orderBy`.
81
+ {
82
+ fixedOrderBy: 'nameLower'
83
+ });
84
+ return query(collection(firestore, 'hosts', hostId, 'products'), where('status', '==', 'active'), ...typed != null ? typed : [], ...typed ? [
85
+ orderBy('nameLower')
86
+ ] : [
87
+ orderBy(documentId())
88
+ ], limit(500));
89
+ }, [
90
+ firestore,
91
+ hostId,
92
+ search
93
+ ], {
94
+ idField: '$id'
95
+ });
96
+ const { data: locationDocs } = useFirestoreCollection(()=>query(collection(firestore, 'hosts', hostId, 'locations'), limit(25)), [
97
+ firestore,
98
+ hostId
99
+ ], {
100
+ idField: '$id'
101
+ });
102
+ const { data: registerDocs } = useFirestoreCollection(()=>query(collection(firestore, 'hosts', hostId, 'registers'), limit(25)), [
103
+ firestore,
104
+ hostId
105
+ ], {
106
+ idField: '$id'
107
+ });
108
+ const { org, ready: planReady } = useOrgPlan(hostId);
109
+ const registers = [
110
+ ...registerDocs != null ? registerDocs : []
111
+ ].sort((a, b)=>{
112
+ var _a_name, _b_name;
113
+ return String((_a_name = a.name) != null ? _a_name : '').localeCompare(String((_b_name = b.name) != null ? _b_name : ''));
114
+ });
115
+ // Only registers within the plan cap can transact (pos-order.ts enforces
116
+ // this at sale time by creation rank, AGL-482) — offer only those.
117
+ //
118
+ // Not until the org doc has arrived (AGL-1064): an absent org resolves to
119
+ // the free tier's `posRegisters: 0`, which empties this list and tells a
120
+ // paying seller their registers exceed a plan nobody has read yet.
121
+ // Per SITE (AGL-1775): the plan's cap plus the register seats the org has
122
+ // allocated to this host out of the purchased pool. `checkQuota` on the
123
+ // org-level `posRegisters` no longer carries the pool and would hide
124
+ // registers this site is paying for.
125
+ const registerCap = Aglyn.checkHostRegisterQuota(org, hostId, registers.length).limit;
126
+ const withinCap = CommerceModel.registersWithinCap(registers, registerCap);
127
+ const usableRegisters = planReady ? registers.filter((r)=>withinCap.has(r.$id)) : [];
128
+ const { data: reservationDocs } = useFirestoreCollection(()=>query(collection(firestore, 'hosts', hostId, 'reservations'), limit(100)), [
129
+ firestore,
130
+ hostId
131
+ ], {
132
+ idField: '$id'
133
+ });
134
+ const openStays = (reservationDocs != null ? reservationDocs : []).filter((reservation)=>reservation.status === 'checked_in');
135
+ const [lines, setLines] = useState([]);
136
+ const [discountPct, setDiscountPct] = useState(0);
137
+ const [customerEmail, setCustomerEmail] = useState('');
138
+ const [locationId, setLocationId] = useState('');
139
+ // Register (AGL-472): a sale must run through a named register so the
140
+ // `posRegisters` cap is meaningful and takings are attributable.
141
+ const [registerId, setRegisterId] = useState('');
142
+ // Default to the first register once they load; if that register pins a
143
+ // location, adopt it (the cashier can still override below).
144
+ useEffect(()=>{
145
+ if (registerId || usableRegisters.length === 0) return;
146
+ const first = usableRegisters[0];
147
+ setRegisterId(first.$id);
148
+ if (first.locationId) setLocationId(first.locationId);
149
+ }, [
150
+ usableRegisters,
151
+ registerId
152
+ ]);
153
+ // `paying` routes the settlement DIALOGS — nothing else. It is deliberately
154
+ // not the tender `settle` acts on (AGL-1682): it used to be both, and the
155
+ // Card button had to `setPaying('link')` and call `settle()` in one handler,
156
+ // where `settle` still closed over the pre-click `null` and returned at its
157
+ // own guard. Card has no dialog of its own — the QR dialog is gated on
158
+ // `cardUrl` — so the card path sets nothing here at all.
159
+ const [paying, setPaying] = useState(null);
160
+ const [cashReceived, setCashReceived] = useState('');
161
+ const [folioReservation, setFolioReservation] = useState('');
162
+ const [cardUrl, setCardUrl] = useState('');
163
+ const [busy, setBusy] = useState(false);
164
+ // Re-entrancy guard for `settle`, deliberately a ref and not `busy`. `busy`
165
+ // is for RENDERING (it disables the settle buttons); a second tap arriving
166
+ // before React has re-rendered would read the pre-click `false` out of the
167
+ // handler's closure exactly the way `paying` was read above. The ref is
168
+ // written and read synchronously, so it holds whatever the scheduler does.
169
+ // It is no longer the last line of defence — the server dedupes on the
170
+ // attempt key below (AGL-1691) — but it is still the cheap one, and it stops
171
+ // the redundant round trip rather than merely making it harmless.
172
+ const inFlight = useRef(false);
173
+ /**
174
+ * Idempotency key for ONE settlement attempt (AGL-1691).
175
+ *
176
+ * The guards above are all client-side and none of them survives a reload, a
177
+ * lost response, or a retry. `/api/commerce/pos-order` now dedupes on this
178
+ * key, but only if the key is right, and the key is the whole design:
179
+ *
180
+ * - Minted lazily on the first settle of a basket, NOT per `settle()` call.
181
+ * Per-call would defeat the point — two taps would mint two keys and the
182
+ * server would see two distinct sales.
183
+ * - Retired whenever the register's contents change (the effect below),
184
+ * which covers the sale completing and clearing the lines. So a cashier
185
+ * ringing the same coffee twice gets a NEW key and a real second order —
186
+ * de-duplicating that would be a worse bug than the one being fixed.
187
+ */ const attemptKey = useRef('');
188
+ useEffect(()=>{
189
+ // A different basket is a different attempt. Also fires when `settle`
190
+ // clears the lines, which is what retires a spent key.
191
+ attemptKey.current = '';
192
+ }, [
193
+ lines,
194
+ discountPct
195
+ ]);
196
+ const [lastReceipt, setLastReceipt] = useState(null);
197
+ const products = useMemo(()=>[
198
+ ...productDocs != null ? productDocs : []
199
+ ]// `status` is now the query's; `deletedAt` stays here because
200
+ // Firestore cannot ask for documents that LACK a field.
201
+ .filter((product)=>!product.deletedAt).map((product)=>_extends({}, CommerceModel.liftLegacyProduct(product), {
202
+ $id: product.$id
203
+ })), [
204
+ productDocs
205
+ ]);
206
+ /*
207
+ * The grid is what the query returned. Re-filtering it by the same text
208
+ * would narrow it AGAIN and more strictly: the server matches a word prefix
209
+ * ("cof" finds "Coffee"), the old compare wanted the whole typed string as a
210
+ * substring, so "flat white" was sent as "flat" and then hidden again by a
211
+ * row that never contained "flat white". Rows found, then dropped.
212
+ */ const visible = products;
213
+ const productsById = useMemo(()=>new Map(products.map((product)=>[
214
+ product.$id,
215
+ product
216
+ ])), [
217
+ products
218
+ ]);
219
+ /**
220
+ * WHAT THE COUNT SAYS, at the line the cashier is looking at (AGL-2357).
221
+ *
222
+ * The register ignored `oversellPolicy` entirely — `pos-order.ts` had no
223
+ * `canPurchase` call — so a merchant who chose "deny" in the product editor
224
+ * silently got "backorder" at the counter. That silence is the defect.
225
+ *
226
+ * WARNS, NEVER BLOCKS (the decision on AGL-2357). Nothing here touches
227
+ * `disabled` on the settle buttons, and nothing gates `settle`: a till is the
228
+ * wrong place for a stale number to stop a real sale, because the cashier is
229
+ * holding the goods. Honouring the policy behind a manager override is the
230
+ * post-launch shape (AGL-2372).
231
+ *
232
+ * Indexed alongside `lines` rather than keyed, because the line list is
233
+ * rendered by index and two lines of the same product/variant cannot exist —
234
+ * `addProduct` merges them into one quantity.
235
+ */ const shortfalls = useMemo(()=>lines.map((line)=>{
236
+ var _line_variantId;
237
+ var _product_variants_, _product_variants;
238
+ const product = productsById.get(line.productId);
239
+ if (!product) return null;
240
+ return CommerceModel.stockShortfall(product, (_line_variantId = line.variantId) != null ? _line_variantId : (_product_variants = product.variants) == null ? void 0 : (_product_variants_ = _product_variants[0]) == null ? void 0 : _product_variants_.id, line.quantity);
241
+ }), [
242
+ lines,
243
+ productsById
244
+ ]);
245
+ const itemsCents = lines.reduce((sum, line)=>sum + line.unitAmountCents * line.quantity, 0);
246
+ const discountCents = Math.round(itemsCents * discountPct / 100);
247
+ const dueCents = itemsCents - discountCents;
248
+ const addProduct = useCallback((product, variant)=>{
249
+ const pick = variant != null ? variant : product.variants[0];
250
+ setLines((prev)=>{
251
+ var _pick_options, _pick_options1;
252
+ const key = `${product.$id}:${pick.id}`;
253
+ const existing = prev.find((line)=>{
254
+ var _line_variantId;
255
+ return `${line.productId}:${(_line_variantId = line.variantId) != null ? _line_variantId : pick.id}` === key;
256
+ });
257
+ if (existing) {
258
+ return prev.map((line)=>line === existing ? _extends({}, line, {
259
+ quantity: line.quantity + 1
260
+ }) : line);
261
+ }
262
+ return [
263
+ ...prev,
264
+ _extends({
265
+ productId: product.$id
266
+ }, pick.id !== 'default' ? {
267
+ variantId: pick.id
268
+ } : {}, {
269
+ name: product.name
270
+ }, Object.keys((_pick_options = pick.options) != null ? _pick_options : {}).length ? {
271
+ variantLabel: Object.values((_pick_options1 = pick.options) != null ? _pick_options1 : {}).join(' / ')
272
+ } : {}, {
273
+ unitAmountCents: Math.round(Number(pick.priceUsd) * 100),
274
+ quantity: 1
275
+ })
276
+ ];
277
+ });
278
+ }, []);
279
+ /**
280
+ * The barcode wedge: a scanner types the code and presses Enter.
281
+ *
282
+ * A LOOKUP against the whole catalog, not a scan of the rows on screen
283
+ * (AGL-2501). It used to walk `products` — the grid's `limit(500)` window —
284
+ * so a shop whose catalog was larger than that had items whose barcode
285
+ * simply did nothing when scanned. At a till, holding the goods, with a
286
+ * customer waiting.
287
+ *
288
+ * `barcodes` and `skus` are top-level arrays the write path flattens out of
289
+ * `variants`, because Firestore cannot query a field inside an array of
290
+ * objects. Barcode is tried first: it is what the scanner produced, and a
291
+ * SKU that happens to equal another product's barcode should not win over
292
+ * the code actually scanned.
293
+ *
294
+ * ⚠️ A MISS NOW SAYS SO. The old loop returned silently, so an unknown code
295
+ * and a code outside the window were indistinguishable from a scanner that
296
+ * had not fired — the cashier's only signal was that nothing happened.
297
+ */ const handleSearchEnter = useCallback(async ()=>{
298
+ var _product_variants_find;
299
+ var _hit_data;
300
+ const needle = search.trim().toLowerCase();
301
+ if (!needle) return;
302
+ const lookup = async (field)=>{
303
+ const found = await getDocs(query(collection(firestore, 'hosts', hostId, 'products'), where('status', '==', 'active'), where(field, 'array-contains', needle), limit(1)));
304
+ return found.docs[0];
305
+ };
306
+ let hit;
307
+ try {
308
+ var _ref;
309
+ hit = (_ref = await lookup('barcodes')) != null ? _ref : await lookup('skus');
310
+ } catch (error) {
311
+ console.error(error);
312
+ return void enqueueSnackbar('Could not reach the catalog — try again', {
313
+ variant: 'warning',
314
+ persist: false
315
+ });
316
+ }
317
+ if (!hit || ((_hit_data = hit.data()) == null ? void 0 : _hit_data['deletedAt'])) {
318
+ return void enqueueSnackbar(`No product matches “${search.trim()}”`, {
319
+ variant: 'warning',
320
+ persist: false
321
+ });
322
+ }
323
+ const product = _extends({}, CommerceModel.liftLegacyProduct(hit.data()), {
324
+ $id: hit.id
325
+ });
326
+ const variant = (_product_variants_find = product.variants.find((item)=>{
327
+ var _item_barcode, _item_sku;
328
+ return ((_item_barcode = item.barcode) == null ? void 0 : _item_barcode.trim().toLowerCase()) === needle || ((_item_sku = item.sku) == null ? void 0 : _item_sku.trim().toLowerCase()) === needle;
329
+ })) != null ? _product_variants_find : product.variants[0];
330
+ addProduct(product, variant);
331
+ setSearch('');
332
+ }, [
333
+ search,
334
+ firestore,
335
+ hostId,
336
+ addProduct,
337
+ enqueueSnackbar
338
+ ]);
339
+ /**
340
+ * Take payment. The tender is an ARGUMENT, never read back out of state
341
+ * (AGL-1682) — every caller already knows which button was pressed, and the
342
+ * one caller that had to announce it through `setPaying` first could not
343
+ * then observe its own write.
344
+ */ const settle = useCallback(async (tender)=>{
345
+ if (inFlight.current || lines.length === 0) return;
346
+ if (!registerId) {
347
+ return void enqueueSnackbar('Select a register before taking payment', {
348
+ variant: 'warning',
349
+ persist: false
350
+ });
351
+ }
352
+ inFlight.current = true;
353
+ setBusy(true);
354
+ // Reuse the key across retries of this basket; mint one if this is the
355
+ // first attempt (AGL-1691). `randomUUID` needs a secure context, which the
356
+ // console always is, but fall back rather than throw on a settle.
357
+ if (!attemptKey.current) {
358
+ var _ref;
359
+ var _globalThis_crypto_randomUUID, _globalThis_crypto;
360
+ attemptKey.current = (_ref = (_globalThis_crypto = globalThis.crypto) == null ? void 0 : (_globalThis_crypto_randomUUID = _globalThis_crypto.randomUUID) == null ? void 0 : _globalThis_crypto_randomUUID.call(_globalThis_crypto)) != null ? _ref : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
361
+ }
362
+ try {
363
+ var _ref1, _payload_changeCents;
364
+ var _payload_totals;
365
+ const response = await authorizedFetch(user, '/api/commerce/pos-order', {
366
+ method: 'POST',
367
+ headers: {
368
+ 'Content-Type': 'application/json',
369
+ 'Idempotency-Key': attemptKey.current
370
+ },
371
+ body: JSON.stringify({
372
+ hostId,
373
+ lines,
374
+ discountPct,
375
+ payment: tender,
376
+ registerId,
377
+ customerEmail: customerEmail || undefined,
378
+ locationId: locationId || undefined,
379
+ cashReceivedCents: Math.round(Number(cashReceived) * 100) || 0,
380
+ reservationId: tender === 'folio' ? folioReservation : undefined
381
+ })
382
+ });
383
+ const payload = await response.json();
384
+ if (!response.ok) {
385
+ var _ref2;
386
+ return void enqueueSnackbar((_ref2 = payload == null ? void 0 : payload.error) != null ? _ref2 : 'Sale failed', {
387
+ variant: 'error',
388
+ allowDuplicate: true
389
+ });
390
+ }
391
+ if (tender === 'link' && payload.url) {
392
+ setCardUrl(payload.url);
393
+ return;
394
+ }
395
+ setLastReceipt({
396
+ lines,
397
+ totalCents: (_ref1 = (_payload_totals = payload.totals) == null ? void 0 : _payload_totals.totalCents) != null ? _ref1 : dueCents,
398
+ changeCents: (_payload_changeCents = payload.changeCents) != null ? _payload_changeCents : 0
399
+ });
400
+ setLines([]);
401
+ setDiscountPct(0);
402
+ setCustomerEmail('');
403
+ setCashReceived('');
404
+ setPaying(null);
405
+ enqueueSnackbar(payload.changeCents > 0 ? `Paid — change ${usd(payload.changeCents)}` : 'Paid', {
406
+ variant: 'success',
407
+ persist: false
408
+ });
409
+ } finally{
410
+ inFlight.current = false;
411
+ setBusy(false);
412
+ }
413
+ }, [
414
+ lines,
415
+ registerId,
416
+ user,
417
+ hostId,
418
+ discountPct,
419
+ customerEmail,
420
+ locationId,
421
+ cashReceived,
422
+ folioReservation,
423
+ dueCents,
424
+ enqueueSnackbar
425
+ ]);
426
+ /**
427
+ * Close the card QR dialog. Clears the cart, because by the time this dialog
428
+ * exists the order is already on the server awaiting the webhook — leaving
429
+ * the lines behind meant a backdrop click or Escape dropped the cashier back
430
+ * on a full register that would mint a SECOND pending order and a SECOND
431
+ * Checkout session for the same basket on the next tap (AGL-1682). `Done`
432
+ * always did this; `onClose` did not, and only `onClose` can fire by
433
+ * accident.
434
+ */ const closeCardDialog = useCallback(()=>{
435
+ setCardUrl('');
436
+ setLines([]);
437
+ setPaying(null);
438
+ }, []);
439
+ const printReceipt = useCallback(()=>{
440
+ if (!lastReceipt) return;
441
+ const win = window.open('', '_blank', 'width=320,height=600');
442
+ if (!win) return;
443
+ // ESCAPED (AGL-2283), the same construction as the packing slip: a
444
+ // `document.write` into an `about:blank` popup that inherits the console's
445
+ // origin. These names are merchant-authored rather than shopper-typed, so
446
+ // the reach is a merchant's own session — still not a reason to build
447
+ // markup out of unescaped product text.
448
+ win.document.write(`<pre style="font-family:monospace;font-size:12px">` + lastReceipt.lines.map((line)=>`${escapeHtml(line.quantity)}x ${escapeHtml(line.name)}${line.variantLabel ? ` (${escapeHtml(line.variantLabel)})` : ''}` + ` ${usd(line.unitAmountCents * line.quantity)}`).join('\n') + `\n\nTOTAL ${usd(lastReceipt.totalCents)}` + (lastReceipt.changeCents ? `\nCHANGE ${usd(lastReceipt.changeCents)}` : '') + `\n${new Date().toLocaleString()}` + `</pre>`);
449
+ win.document.close();
450
+ // Print from HERE, not from a `<script>` written into the receipt
451
+ // (AGL-523). `window.open('')` yields an about:blank document that
452
+ // INHERITS the opener's CSP, so an injected inline script has no nonce and
453
+ // `strict-dynamic` means `'self'` will not save it either. Under the
454
+ // enforcing policy that script is blocked, the receipt window opens, and
455
+ // the print dialog never appears — a silent break of the one action the
456
+ // window exists for.
457
+ //
458
+ // This call is in the opener, whose script Next has already nonced.
459
+ win.focus();
460
+ win.print();
461
+ }, [
462
+ lastReceipt
463
+ ]);
464
+ return /*#__PURE__*/ _jsxs(_Fragment, {
465
+ children: [
466
+ /*#__PURE__*/ _jsx(NextPageTitle, {
467
+ screen: 'POS'
468
+ }),
469
+ /*#__PURE__*/ _jsxs(Box, {
470
+ sx: {
471
+ display: 'flex',
472
+ height: '100vh',
473
+ overflow: 'hidden'
474
+ },
475
+ children: [
476
+ /*#__PURE__*/ _jsxs(Box, {
477
+ sx: {
478
+ flex: 1,
479
+ p: 2,
480
+ overflowY: 'auto'
481
+ },
482
+ children: [
483
+ /*#__PURE__*/ _jsx(TextField, {
484
+ placeholder: "Search or scan barcode…",
485
+ value: search,
486
+ onChange: (event)=>setSearch(event.target.value),
487
+ onKeyDown: (event)=>{
488
+ if (event.key === 'Enter') void handleSearchEnter();
489
+ },
490
+ size: "small",
491
+ fullWidth: true,
492
+ autoFocus: true,
493
+ sx: {
494
+ mb: 2
495
+ }
496
+ }),
497
+ /*#__PURE__*/ _jsx(Box, {
498
+ sx: {
499
+ display: 'grid',
500
+ gap: 1.5,
501
+ gridTemplateColumns: 'repeat(auto-fill, minmax(140px, 1fr))'
502
+ },
503
+ children: visible.map((product)=>{
504
+ var _ref;
505
+ var _product_variants_;
506
+ return /*#__PURE__*/ _jsxs(Card, {
507
+ variant: "outlined",
508
+ children: [
509
+ /*#__PURE__*/ _jsxs(CardActionArea, {
510
+ onClick: ()=>addProduct(product),
511
+ sx: {
512
+ p: 1.5,
513
+ minHeight: 88
514
+ },
515
+ children: [
516
+ /*#__PURE__*/ _jsx(Typography, {
517
+ variant: "body2",
518
+ sx: {
519
+ fontWeight: 600
520
+ },
521
+ noWrap: true,
522
+ children: product.name
523
+ }),
524
+ /*#__PURE__*/ _jsxs(Typography, {
525
+ variant: "caption",
526
+ color: "text.secondary",
527
+ children: [
528
+ `$${(_ref = (_product_variants_ = product.variants[0]) == null ? void 0 : _product_variants_.priceUsd) != null ? _ref : 0}`,
529
+ product.variants.length > 1 ? ` · ${product.variants.length} variants` : ''
530
+ ]
531
+ })
532
+ ]
533
+ }),
534
+ product.variants.length > 1 ? /*#__PURE__*/ _jsx(Box, {
535
+ sx: {
536
+ display: 'flex',
537
+ flexWrap: 'wrap',
538
+ gap: 0.5,
539
+ p: 0.5
540
+ },
541
+ children: product.variants.slice(0, 6).map((variant)=>{
542
+ var _variant_options;
543
+ return /*#__PURE__*/ _jsx(Chip, {
544
+ label: Object.values((_variant_options = variant.options) != null ? _variant_options : {}).join('/') || 'Default',
545
+ size: "small",
546
+ onClick: ()=>addProduct(product, variant)
547
+ }, variant.id);
548
+ })
549
+ }) : null
550
+ ]
551
+ }, product.$id);
552
+ })
553
+ })
554
+ ]
555
+ }),
556
+ /*#__PURE__*/ _jsxs(Box, {
557
+ sx: {
558
+ width: 380,
559
+ borderLeft: 1,
560
+ borderColor: 'divider',
561
+ display: 'flex',
562
+ flexDirection: 'column',
563
+ p: 2,
564
+ gap: 1
565
+ },
566
+ children: [
567
+ /*#__PURE__*/ _jsx(Typography, {
568
+ variant: "h6",
569
+ children: 'Register'
570
+ }),
571
+ !planReady ? /*#__PURE__*/ _jsx(Typography, {
572
+ variant: "body2",
573
+ color: "text.secondary",
574
+ children: 'Checking your plan…'
575
+ }) : usableRegisters.length === 0 ? /*#__PURE__*/ _jsx(Typography, {
576
+ variant: "body2",
577
+ color: "warning.main",
578
+ children: registers.length > 0 ? 'Your registers exceed your plan — remove extras or ' + 'upgrade in Billing to take payments.' : 'No POS register yet. Add one under Commerce → Settings → ' + 'POS registers before taking payments.'
579
+ }) : usableRegisters.length > 1 ? /*#__PURE__*/ _jsx(TextField, {
580
+ label: "Register",
581
+ value: registerId,
582
+ onChange: (event)=>setRegisterId(event.target.value),
583
+ size: "small",
584
+ select: true,
585
+ children: usableRegisters.map((register)=>/*#__PURE__*/ _jsx(MenuItem, {
586
+ value: register.$id,
587
+ children: register.name
588
+ }, register.$id))
589
+ }) : /*#__PURE__*/ _jsx(Typography, {
590
+ variant: "body2",
591
+ color: "text.secondary",
592
+ children: (_usableRegisters_ = usableRegisters[0]) == null ? void 0 : _usableRegisters_.name
593
+ }),
594
+ ((_ref = locationDocs == null ? void 0 : locationDocs.length) != null ? _ref : 0) > 1 ? /*#__PURE__*/ _jsx(TextField, {
595
+ label: "Location",
596
+ value: locationId,
597
+ onChange: (event)=>setLocationId(event.target.value),
598
+ size: "small",
599
+ select: true,
600
+ children: (locationDocs != null ? locationDocs : []).map((location)=>/*#__PURE__*/ _jsx(MenuItem, {
601
+ value: location.$id,
602
+ children: location.name
603
+ }, location.$id))
604
+ }) : null,
605
+ /*#__PURE__*/ _jsx(Box, {
606
+ sx: {
607
+ flex: 1,
608
+ overflowY: 'auto'
609
+ },
610
+ children: lines.length === 0 ? /*#__PURE__*/ _jsx(Typography, {
611
+ variant: "body2",
612
+ color: "text.secondary",
613
+ children: 'Tap products to add them.'
614
+ }) : lines.map((line, index)=>{
615
+ var _shortfalls_index;
616
+ return /*#__PURE__*/ _jsxs(Box, {
617
+ sx: {
618
+ py: 0.5
619
+ },
620
+ children: [
621
+ /*#__PURE__*/ _jsxs(Stack, {
622
+ direction: "row",
623
+ spacing: 1,
624
+ sx: {
625
+ alignItems: 'center'
626
+ },
627
+ children: [
628
+ /*#__PURE__*/ _jsxs(Typography, {
629
+ variant: "body2",
630
+ sx: {
631
+ flex: 1
632
+ },
633
+ noWrap: true,
634
+ children: [
635
+ `${line.quantity}× ${line.name}`,
636
+ line.variantLabel ? ` (${line.variantLabel})` : ''
637
+ ]
638
+ }),
639
+ /*#__PURE__*/ _jsx(Typography, {
640
+ variant: "body2",
641
+ children: usd(line.unitAmountCents * line.quantity)
642
+ }),
643
+ /*#__PURE__*/ _jsx(Button, {
644
+ size: "small",
645
+ color: "error",
646
+ onClick: ()=>setLines((prev)=>prev.filter((_item, itemIndex)=>itemIndex !== index)),
647
+ children: '✕'
648
+ })
649
+ ]
650
+ }),
651
+ shortfalls[index] ? // AGL-2357: said, not enforced. The cashier reads it and
652
+ // rings the sale through — the settle buttons below are
653
+ // untouched by this.
654
+ /*#__PURE__*/ _jsx(Typography, {
655
+ variant: "caption",
656
+ color: "warning.main",
657
+ children: `Only ${(_shortfalls_index = shortfalls[index]) == null ? void 0 : _shortfalls_index.available} in stock — selling ${line.quantity}`
658
+ }) : null
659
+ ]
660
+ }, index);
661
+ })
662
+ }),
663
+ /*#__PURE__*/ _jsxs(Stack, {
664
+ direction: "row",
665
+ spacing: 1,
666
+ children: [
667
+ /*#__PURE__*/ _jsx(TextField, {
668
+ label: "Discount %",
669
+ value: discountPct || '',
670
+ onChange: (event)=>setDiscountPct(Math.min(100, Math.max(0, Number(event.target.value) || 0))),
671
+ size: "small",
672
+ sx: {
673
+ width: 110
674
+ },
675
+ slotProps: {
676
+ htmlInput: {
677
+ inputMode: 'numeric'
678
+ }
679
+ }
680
+ }),
681
+ /*#__PURE__*/ _jsx(TextField, {
682
+ label: "Customer email",
683
+ value: customerEmail,
684
+ onChange: (event)=>setCustomerEmail(event.target.value),
685
+ size: "small",
686
+ sx: {
687
+ flex: 1
688
+ }
689
+ })
690
+ ]
691
+ }),
692
+ /*#__PURE__*/ _jsxs(Box, {
693
+ sx: {
694
+ display: 'flex',
695
+ justifyContent: 'space-between'
696
+ },
697
+ children: [
698
+ /*#__PURE__*/ _jsx(Typography, {
699
+ variant: "h6",
700
+ children: 'Due'
701
+ }),
702
+ /*#__PURE__*/ _jsx(Typography, {
703
+ variant: "h6",
704
+ children: usd(dueCents)
705
+ })
706
+ ]
707
+ }),
708
+ /*#__PURE__*/ _jsxs(Stack, {
709
+ direction: "row",
710
+ spacing: 1,
711
+ children: [
712
+ /*#__PURE__*/ _jsx(Button, {
713
+ variant: "contained",
714
+ color: "primary",
715
+ disabled: lines.length === 0,
716
+ onClick: ()=>setPaying('cash'),
717
+ sx: {
718
+ flex: 1
719
+ },
720
+ children: 'Cash'
721
+ }),
722
+ /*#__PURE__*/ _jsx(Button, {
723
+ variant: "contained",
724
+ disabled: busy || lines.length === 0,
725
+ onClick: ()=>void settle('link'),
726
+ sx: {
727
+ flex: 1
728
+ },
729
+ children: 'Card (QR)'
730
+ }),
731
+ /*#__PURE__*/ _jsx(Button, {
732
+ variant: "outlined",
733
+ disabled: lines.length === 0 || openStays.length === 0,
734
+ onClick: ()=>setPaying('folio'),
735
+ sx: {
736
+ flex: 1
737
+ },
738
+ children: 'Room'
739
+ })
740
+ ]
741
+ }),
742
+ lastReceipt ? /*#__PURE__*/ _jsx(Button, {
743
+ size: "small",
744
+ onClick: printReceipt,
745
+ children: 'Print last receipt'
746
+ }) : null
747
+ ]
748
+ })
749
+ ]
750
+ }),
751
+ /*#__PURE__*/ _jsxs(Dialog, {
752
+ open: paying === 'cash',
753
+ onClose: ()=>setPaying(null),
754
+ maxWidth: "xs",
755
+ fullWidth: true,
756
+ children: [
757
+ /*#__PURE__*/ _jsx(DialogTitle, {
758
+ children: `Cash — due ${usd(dueCents)}`
759
+ }),
760
+ /*#__PURE__*/ _jsxs(DialogContent, {
761
+ sx: {
762
+ display: 'flex',
763
+ flexDirection: 'column',
764
+ gap: 2
765
+ },
766
+ children: [
767
+ /*#__PURE__*/ _jsx(TextField, {
768
+ label: "Cash received ($)",
769
+ value: cashReceived,
770
+ onChange: (event)=>setCashReceived(event.target.value.replace(/[^0-9.]/g, '')),
771
+ size: "small",
772
+ autoFocus: true,
773
+ sx: {
774
+ mt: 1
775
+ },
776
+ slotProps: {
777
+ htmlInput: {
778
+ inputMode: 'decimal'
779
+ }
780
+ }
781
+ }),
782
+ Number(cashReceived) * 100 >= dueCents && cashReceived ? /*#__PURE__*/ _jsx(Alert, {
783
+ severity: "success",
784
+ children: `Change: ${usd(Math.round(Number(cashReceived) * 100) - dueCents)}`
785
+ }) : null
786
+ ]
787
+ }),
788
+ /*#__PURE__*/ _jsxs(DialogActions, {
789
+ children: [
790
+ /*#__PURE__*/ _jsx(Button, {
791
+ onClick: ()=>setPaying(null),
792
+ children: 'Cancel'
793
+ }),
794
+ /*#__PURE__*/ _jsx(Button, {
795
+ variant: "contained",
796
+ color: "primary",
797
+ disabled: busy || Math.round(Number(cashReceived) * 100) < dueCents,
798
+ // `onClick={settle}` would hand MUI's click event to `tender`.
799
+ onClick: ()=>void settle('cash'),
800
+ children: 'Complete sale'
801
+ })
802
+ ]
803
+ })
804
+ ]
805
+ }),
806
+ /*#__PURE__*/ _jsxs(Dialog, {
807
+ open: paying === 'folio',
808
+ onClose: ()=>setPaying(null),
809
+ maxWidth: "xs",
810
+ fullWidth: true,
811
+ children: [
812
+ /*#__PURE__*/ _jsx(DialogTitle, {
813
+ children: `Charge to room — ${usd(dueCents)}`
814
+ }),
815
+ /*#__PURE__*/ _jsx(DialogContent, {
816
+ sx: {
817
+ display: 'flex',
818
+ flexDirection: 'column',
819
+ gap: 2
820
+ },
821
+ children: /*#__PURE__*/ _jsx(TextField, {
822
+ label: "Checked-in stay",
823
+ value: folioReservation,
824
+ onChange: (event)=>setFolioReservation(event.target.value),
825
+ size: "small",
826
+ select: true,
827
+ sx: {
828
+ mt: 1
829
+ },
830
+ children: openStays.map((stay)=>{
831
+ var _ref, _stay_guestName;
832
+ return /*#__PURE__*/ _jsx(MenuItem, {
833
+ value: stay.$id,
834
+ children: (_ref = (_stay_guestName = stay.guestName) != null ? _stay_guestName : stay.guestEmail) != null ? _ref : stay.$id
835
+ }, stay.$id);
836
+ })
837
+ })
838
+ }),
839
+ /*#__PURE__*/ _jsxs(DialogActions, {
840
+ children: [
841
+ /*#__PURE__*/ _jsx(Button, {
842
+ onClick: ()=>setPaying(null),
843
+ children: 'Cancel'
844
+ }),
845
+ /*#__PURE__*/ _jsx(Button, {
846
+ variant: "contained",
847
+ color: "primary",
848
+ disabled: busy || !folioReservation,
849
+ onClick: ()=>void settle('folio'),
850
+ children: 'Charge folio'
851
+ })
852
+ ]
853
+ })
854
+ ]
855
+ }),
856
+ /*#__PURE__*/ _jsxs(Dialog, {
857
+ open: Boolean(cardUrl),
858
+ onClose: closeCardDialog,
859
+ maxWidth: "xs",
860
+ fullWidth: true,
861
+ children: [
862
+ /*#__PURE__*/ _jsx(DialogTitle, {
863
+ children: 'Customer pays by card'
864
+ }),
865
+ /*#__PURE__*/ _jsxs(DialogContent, {
866
+ sx: {
867
+ display: 'flex',
868
+ flexDirection: 'column',
869
+ gap: 2
870
+ },
871
+ children: [
872
+ /*#__PURE__*/ _jsx(Typography, {
873
+ variant: "body2",
874
+ color: "text.secondary",
875
+ sx: {
876
+ mt: 1
877
+ },
878
+ children: 'Show this QR (or open the link on the customer display); the ' + 'order completes automatically once paid. Stripe Terminal ' + 'readers can replace this step later.'
879
+ }),
880
+ /*#__PURE__*/ _jsx(Box, {
881
+ sx: {
882
+ display: 'flex',
883
+ justifyContent: 'center'
884
+ },
885
+ children: /*#__PURE__*/ _jsx(QRCodeSVG, {
886
+ value: cardUrl,
887
+ size: 256,
888
+ level: "L",
889
+ marginSize: 4,
890
+ title: "Payment QR",
891
+ role: "img"
892
+ })
893
+ }),
894
+ /*#__PURE__*/ _jsx(Button, {
895
+ size: "small",
896
+ href: cardUrl,
897
+ target: "_blank",
898
+ children: 'Open payment page'
899
+ })
900
+ ]
901
+ }),
902
+ /*#__PURE__*/ _jsx(DialogActions, {
903
+ children: /*#__PURE__*/ _jsx(Button, {
904
+ onClick: closeCardDialog,
905
+ children: 'Done'
906
+ })
907
+ })
908
+ ]
909
+ })
910
+ ]
911
+ });
912
+ }
913
+ PosConsolePage.displayName = 'PosConsolePage';
914
+ export default PosConsolePage;
915
+
916
+ //# sourceMappingURL=pos-page.component.js.map