@aglyn/plugins-commerce 1.14.0 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/account-subscriptions.d.ts +51 -0
  3. package/src/lib/components/account-subscriptions.js +168 -0
  4. package/src/lib/components/account-subscriptions.js.map +1 -0
  5. package/src/lib/components/account.js +12 -48
  6. package/src/lib/components/account.js.map +1 -1
  7. package/src/lib/components/cart.js +38 -9
  8. package/src/lib/components/cart.js.map +1 -1
  9. package/src/lib/components/commerce-console-page.js +6 -0
  10. package/src/lib/components/commerce-console-page.js.map +1 -1
  11. package/src/lib/components/commerce-console-sections.d.ts +1 -1
  12. package/src/lib/components/commerce-console-sections.js +5 -0
  13. package/src/lib/components/commerce-console-sections.js.map +1 -1
  14. package/src/lib/components/console/paid-media.d.ts +1 -0
  15. package/src/lib/components/console/paid-media.js +15 -4
  16. package/src/lib/components/console/paid-media.js.map +1 -1
  17. package/src/lib/components/console/payments-settings-card.component.js +1 -1
  18. package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
  19. package/src/lib/components/console/pos/pos-hardware-api.d.ts +10 -1
  20. package/src/lib/components/console/pos/pos-hardware-api.js.map +1 -1
  21. package/src/lib/components/console/pos/pos-hardware-buyer.component.js +2 -2
  22. package/src/lib/components/console/pos/pos-hardware-buyer.component.js.map +1 -1
  23. package/src/lib/components/console/pos/pos-hardware-sale-api.d.ts +2 -0
  24. package/src/lib/components/console/pos/pos-hardware-sale-api.js.map +1 -1
  25. package/src/lib/components/console/pos-cellular-control.component.d.ts +1 -1
  26. package/src/lib/components/console/pos-cellular-control.component.js +5 -5
  27. package/src/lib/components/console/pos-cellular-control.component.js.map +1 -1
  28. package/src/lib/components/console/pos-devices-card.component.js +2 -2
  29. package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
  30. package/src/lib/components/console/pos-hardware-card.component.d.ts +5 -0
  31. package/src/lib/components/console/pos-hardware-card.component.js +77 -8
  32. package/src/lib/components/console/pos-hardware-card.component.js.map +1 -1
  33. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js +137 -19
  34. package/src/lib/components/console/pos-hardware-orders-staff-page.component.js.map +1 -1
  35. package/src/lib/components/console/pos-page.component.js +19 -2
  36. package/src/lib/components/console/pos-page.component.js.map +1 -1
  37. package/src/lib/components/console/product-editor-dialog.component.js +21 -2
  38. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  39. package/src/lib/components/console/subscription-detail-dialog.component.d.ts +58 -0
  40. package/src/lib/components/console/subscription-detail-dialog.component.js +201 -0
  41. package/src/lib/components/console/subscription-detail-dialog.component.js.map +1 -0
  42. package/src/lib/components/console/subscriptions-card.component.d.ts +60 -0
  43. package/src/lib/components/console/subscriptions-card.component.js +282 -0
  44. package/src/lib/components/console/subscriptions-card.component.js.map +1 -0
  45. package/src/lib/components/hardware-terms-consent.d.ts +22 -0
  46. package/src/lib/components/hardware-terms-consent.js +85 -0
  47. package/src/lib/components/hardware-terms-consent.js.map +1 -0
  48. package/src/lib/components/product-detail.js +32 -8
  49. package/src/lib/components/product-detail.js.map +1 -1
  50. package/src/lib/components/quote-page-body.js +7 -3
  51. package/src/lib/components/quote-page-body.js.map +1 -1
  52. package/src/lib/components/related-products.js +6 -3
  53. package/src/lib/components/related-products.js.map +1 -1
  54. package/src/lib/components/storefront-payment-element.d.ts +7 -1
  55. package/src/lib/components/storefront-payment-element.js +11 -7
  56. package/src/lib/components/storefront-payment-element.js.map +1 -1
  57. package/src/lib/constants/operator-alerts.d.ts +1 -1
  58. package/src/lib/constants/operator-alerts.js +4 -4
  59. package/src/lib/constants/operator-alerts.js.map +1 -1
  60. package/src/lib/model/commerce-orders.d.ts +6 -2
  61. package/src/lib/model/commerce-orders.js.map +1 -1
  62. package/src/lib/model/commerce-payment-methods.d.ts +27 -16
  63. package/src/lib/model/commerce-payment-methods.js +11 -83
  64. package/src/lib/model/commerce-payment-methods.js.map +1 -1
  65. package/src/lib/model/commerce.d.ts +6 -0
  66. package/src/lib/model/commerce.js.map +1 -1
  67. package/src/lib/model/index.d.ts +1 -0
  68. package/src/lib/model/index.js +1 -0
  69. package/src/lib/model/index.js.map +1 -1
  70. package/src/lib/model/paid-media.d.ts +8 -0
  71. package/src/lib/model/paid-media.js +13 -0
  72. package/src/lib/model/paid-media.js.map +1 -1
  73. package/src/lib/model/pos-hardware-in-person.d.ts +23 -2
  74. package/src/lib/model/pos-hardware-in-person.js +52 -20
  75. package/src/lib/model/pos-hardware-in-person.js.map +1 -1
  76. package/src/lib/model/pos-hardware-tax-summary.d.ts +5 -1
  77. package/src/lib/model/pos-hardware-tax-summary.js +2 -1
  78. package/src/lib/model/pos-hardware-tax-summary.js.map +1 -1
  79. package/src/lib/model/pos-hardware-terms.d.ts +37 -2
  80. package/src/lib/model/pos-hardware-terms.js +68 -3
  81. package/src/lib/model/pos-hardware-terms.js.map +1 -1
  82. package/src/lib/model/pos-hardware.d.ts +101 -15
  83. package/src/lib/model/pos-hardware.js +128 -18
  84. package/src/lib/model/pos-hardware.js.map +1 -1
  85. package/src/lib/model/pos-reader-splash.js +2 -2
  86. package/src/lib/model/pos-reader-splash.js.map +1 -1
  87. package/src/lib/model/product-write.d.ts +3 -0
  88. package/src/lib/model/subscription-view.d.ts +90 -0
  89. package/src/lib/model/subscription-view.js +176 -0
  90. package/src/lib/model/subscription-view.js.map +1 -0
  91. package/src/lib/server/billing-webhook.d.ts +27 -6
  92. package/src/lib/server/billing-webhook.js +271 -81
  93. package/src/lib/server/billing-webhook.js.map +1 -1
  94. package/src/lib/server/cancel-order.js +4 -3
  95. package/src/lib/server/cancel-order.js.map +1 -1
  96. package/src/lib/server/cart-checkout.js +105 -23
  97. package/src/lib/server/cart-checkout.js.map +1 -1
  98. package/src/lib/server/cart.js +15 -3
  99. package/src/lib/server/cart.js.map +1 -1
  100. package/src/lib/server/catalog.js +58 -22
  101. package/src/lib/server/catalog.js.map +1 -1
  102. package/src/lib/server/checkout-session-expiry.d.ts +1 -1
  103. package/src/lib/server/checkout-session-expiry.js +19 -5
  104. package/src/lib/server/checkout-session-expiry.js.map +1 -1
  105. package/src/lib/server/checkout-status.js +4 -3
  106. package/src/lib/server/checkout-status.js.map +1 -1
  107. package/src/lib/server/checkout.js +98 -26
  108. package/src/lib/server/checkout.js.map +1 -1
  109. package/src/lib/server/connect.js +42 -11
  110. package/src/lib/server/connect.js.map +1 -1
  111. package/src/lib/server/draft-order.js +36 -7
  112. package/src/lib/server/draft-order.js.map +1 -1
  113. package/src/lib/server/manual-tax-rate.d.ts +11 -3
  114. package/src/lib/server/manual-tax-rate.js +10 -6
  115. package/src/lib/server/manual-tax-rate.js.map +1 -1
  116. package/src/lib/server/membership-account.d.ts +22 -0
  117. package/src/lib/server/membership-account.js +52 -8
  118. package/src/lib/server/membership-account.js.map +1 -1
  119. package/src/lib/server/native-checkout.d.ts +10 -3
  120. package/src/lib/server/native-checkout.js +8 -3
  121. package/src/lib/server/native-checkout.js.map +1 -1
  122. package/src/lib/server/payment-method-domains.d.ts +50 -9
  123. package/src/lib/server/payment-method-domains.js +150 -51
  124. package/src/lib/server/payment-method-domains.js.map +1 -1
  125. package/src/lib/server/payment-methods.js +3 -2
  126. package/src/lib/server/payment-methods.js.map +1 -1
  127. package/src/lib/server/pos-auth.d.ts +3 -3
  128. package/src/lib/server/pos-auth.js +3 -3
  129. package/src/lib/server/pos-auth.js.map +1 -1
  130. package/src/lib/server/pos-cellular-billing.js +1 -1
  131. package/src/lib/server/pos-cellular-billing.js.map +1 -1
  132. package/src/lib/server/pos-cellular-notify.js +1 -1
  133. package/src/lib/server/pos-cellular-notify.js.map +1 -1
  134. package/src/lib/server/pos-cellular.js +1 -1
  135. package/src/lib/server/pos-cellular.js.map +1 -1
  136. package/src/lib/server/pos-hardware-admin.js +86 -13
  137. package/src/lib/server/pos-hardware-admin.js.map +1 -1
  138. package/src/lib/server/pos-hardware-attach.js +5 -5
  139. package/src/lib/server/pos-hardware-attach.js.map +1 -1
  140. package/src/lib/server/pos-hardware-cancel.js +65 -0
  141. package/src/lib/server/pos-hardware-cancel.js.map +1 -1
  142. package/src/lib/server/pos-hardware-closure-notices.js +2 -5
  143. package/src/lib/server/pos-hardware-closure-notices.js.map +1 -1
  144. package/src/lib/server/pos-hardware-closure.js +5 -8
  145. package/src/lib/server/pos-hardware-closure.js.map +1 -1
  146. package/src/lib/server/pos-hardware-in-person.d.ts +2 -1
  147. package/src/lib/server/pos-hardware-in-person.js +72 -17
  148. package/src/lib/server/pos-hardware-in-person.js.map +1 -1
  149. package/src/lib/server/pos-hardware-notify.d.ts +2 -0
  150. package/src/lib/server/pos-hardware-notify.js +30 -5
  151. package/src/lib/server/pos-hardware-notify.js.map +1 -1
  152. package/src/lib/server/pos-hardware-readers.d.ts +25 -0
  153. package/src/lib/server/pos-hardware-readers.js +206 -85
  154. package/src/lib/server/pos-hardware-readers.js.map +1 -1
  155. package/src/lib/server/pos-hardware-returns.d.ts +8 -3
  156. package/src/lib/server/pos-hardware-returns.js +39 -7
  157. package/src/lib/server/pos-hardware-returns.js.map +1 -1
  158. package/src/lib/server/pos-hardware-sale-fields.d.ts +76 -0
  159. package/src/lib/server/pos-hardware-sale-fields.js +114 -1
  160. package/src/lib/server/pos-hardware-sale-fields.js.map +1 -1
  161. package/src/lib/server/pos-hardware-sale.d.ts +2 -0
  162. package/src/lib/server/pos-hardware-sale.js +1 -0
  163. package/src/lib/server/pos-hardware-sale.js.map +1 -1
  164. package/src/lib/server/pos-hardware-tax-return-source.js +7 -4
  165. package/src/lib/server/pos-hardware-tax-return-source.js.map +1 -1
  166. package/src/lib/server/pos-hardware-webhook.js +16 -3
  167. package/src/lib/server/pos-hardware-webhook.js.map +1 -1
  168. package/src/lib/server/pos-hardware.d.ts +14 -3
  169. package/src/lib/server/pos-hardware.js +83 -18
  170. package/src/lib/server/pos-hardware.js.map +1 -1
  171. package/src/lib/server/pos-ops-routes.js +2 -10
  172. package/src/lib/server/pos-ops-routes.js.map +1 -1
  173. package/src/lib/server/pos-order.js +5 -1
  174. package/src/lib/server/pos-order.js.map +1 -1
  175. package/src/lib/server/pos-stripe.d.ts +7 -7
  176. package/src/lib/server/pos-stripe.js +15 -13
  177. package/src/lib/server/pos-stripe.js.map +1 -1
  178. package/src/lib/server/pos-terminal.js +11 -3
  179. package/src/lib/server/pos-terminal.js.map +1 -1
  180. package/src/lib/server/quote-pay.d.ts +23 -1
  181. package/src/lib/server/quote-pay.js +111 -27
  182. package/src/lib/server/quote-pay.js.map +1 -1
  183. package/src/lib/server/quote.d.ts +2 -1
  184. package/src/lib/server/quote.js +12 -11
  185. package/src/lib/server/quote.js.map +1 -1
  186. package/src/lib/server/refund.js +13 -6
  187. package/src/lib/server/refund.js.map +1 -1
  188. package/src/lib/server/related.js +10 -3
  189. package/src/lib/server/related.js.map +1 -1
  190. package/src/lib/server/reserve.js +19 -6
  191. package/src/lib/server/reserve.js.map +1 -1
  192. package/src/lib/server/revenue-source.d.ts +6 -0
  193. package/src/lib/server/revenue-source.js +25 -9
  194. package/src/lib/server/revenue-source.js.map +1 -1
  195. package/src/lib/server/seller-stripe-account.d.ts +45 -0
  196. package/src/lib/server/seller-stripe-account.js +99 -0
  197. package/src/lib/server/seller-stripe-account.js.map +1 -0
  198. package/src/lib/server/storefront-tax-record.js +6 -1
  199. package/src/lib/server/storefront-tax-record.js.map +1 -1
  200. package/src/lib/server/storefront-tax.d.ts +33 -2
  201. package/src/lib/server/storefront-tax.js +39 -3
  202. package/src/lib/server/storefront-tax.js.map +1 -1
  203. package/src/lib/server/stream.d.ts +2 -0
  204. package/src/lib/server/stream.js +22 -2
  205. package/src/lib/server/stream.js.map +1 -1
  206. package/src/lib/server/stripe-refund.d.ts +15 -0
  207. package/src/lib/server/stripe-refund.js +54 -26
  208. package/src/lib/server/stripe-refund.js.map +1 -1
  209. package/src/lib/server/subscription-portal.js +8 -3
  210. package/src/lib/server/subscription-portal.js.map +1 -1
  211. package/src/lib/server/tax-return-source.js +5 -1
  212. package/src/lib/server/tax-return-source.js.map +1 -1
  213. package/src/lib/server.js +2 -2
  214. package/src/lib/server.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/commerce-console-page.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { GridItems } from '@aglyn/shared-ui-jsx'\nimport { HubSections } from '@aglyn/shared-ui-next'\nimport { lazy, Suspense, type ReactNode } from 'react'\nimport { Stack } from '@mui/material'\nimport {\n COMMERCE_SETTINGS_PAGE_ZONES,\n type CommerceConsoleSectionId,\n type CommerceSettingsSectionId,\n} from './commerce-console-sections'\nimport CatalogOrganizationCard from './console/catalog-organization-card.component'\nimport CommerceAnalyticsCard from './console/commerce-analytics-card.component'\nimport CustomerNotificationsCard from './console/customer-notifications-card.component'\nimport DiscountsCard from './console/discounts-card.component'\nimport GiftCardsCard from './console/gift-cards-card.component'\nimport HostCouponsCard from './console/host-coupons-card.component'\nimport HostOrdersCard from './console/host-orders-card.component'\nimport HostQuotesCard from './console/host-quotes-card.component'\nimport LocationsCard from './console/locations-card.component'\nimport LocalDeliverySettingsCard from './console/local-delivery-settings-card.component'\nimport PickupDeliveryQueueCard from './console/pickup-delivery-queue-card.component'\nimport MemberPostsCard from './console/member-posts-card.component'\nimport OrderWebhooksCard from './console/order-webhooks-card.component'\nimport PaymentsSettingsCard from './console/payments-settings-card.component'\nimport PosCheckInsCard from './console/pos-ops/pos-check-ins-card.component'\nimport PosDayTotalsCard from './console/pos-ops/pos-day-totals-card.component'\nimport PosShiftHistoryCard from './console/pos-ops/pos-shift-history-card.component'\nimport PosStaffPinsCard from './console/pos-ops/pos-staff-pins-card.component'\nimport PaymentMethodsCard from './console/payment-methods-card.component'\nimport ProductsHubCard from './console/products-hub-card.component'\nimport QuoteSettingsCard from './console/quote-settings-card.component'\nimport RecoveryQueueCard from './console/recovery-queue-card.component'\nimport RegistersCard from './console/registers-card.component'\nimport RegisterHardwareCards from './console/register-hardware-card.component'\nimport PosDevicesCard from './console/pos-devices-card.component'\nimport PosHardwareCard from './console/pos-hardware-card.component'\n\n/**\n * Card readers the workspace bought in person, waiting to be set up\n * (AGL-4038): its own chunk, drawn only while there is one.\n */\nconst PosHardwareWaitingCard = lazy(() => import('./console/pos-hardware-waiting-card.component'))\nimport { holdsPosPermission, posPermissionRefusal } from '../model/plugin-permissions'\nimport ReservationsCard from './console/reservations-card.component'\nimport ReturnSettingsCard from './console/return-settings-card.component'\nimport ReturnsCard from './console/returns-card.component'\nimport ReviewsModerationCard from './console/reviews-moderation-card.component'\nimport ReviewSettingsCard from './console/review-settings-card.component'\nimport ShippingSettingsCard from './console/shipping-settings-card.component'\nimport ShipStationCard from './console/shipstation-card.component'\nimport ShippingEasyCard from './console/shippingeasy-card.component'\nimport StockMovementsCard from './console/stock-movements-card.component'\nimport StoreSettingsCard from './console/store-settings-card.component'\nimport StorefrontTaxSummaryCard from './console/storefront-tax-summary-card.component'\nimport SuppliersCard from './console/suppliers-card.component'\nimport TaxSettingsCard from './console/tax-settings-card.component'\nimport { COMMERCE_PROMOTIONS_ZONE } from './console/store-zones'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\n\n/**\n * A settings page's zone (AGL-3612, AGL-3713): other plugins' settings for\n * the store — label settings, carrier accounts, a tax service — under the\n * page's own cards. One zone per page, from `COMMERCE_SETTINGS_PAGE_ZONES`;\n * Integrations draws `commerceSettings`, where a widget naming no page lands.\n */\nfunction CommerceSettingsZone(props: {\n hostId: string\n page: CommerceSettingsSectionId\n}) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot\n slot={COMMERCE_SETTINGS_PAGE_ZONES[props.page]}\n hostId={props.hostId}\n orgId={undefined}\n />\n ) : null\n}\n\n/** One settings page: its cards in order, then its zone (AGL-3713). */\nfunction settingsPage(\n page: CommerceSettingsSectionId,\n hostId: string,\n cards: readonly ReactNode[],\n): ReactNode {\n return (\n <GridItems\n spacing={3}\n items={[\n ...cards.map((children) => ({ size: { xs: 12 }, children })),\n {\n size: { xs: 12 },\n children: <CommerceSettingsZone hostId={hostId} page={page} />,\n },\n ]}\n />\n )\n}\n\n/**\n * The `commercePromotions` zone (AGL-3640): other plugins' programs beside\n * the store's own money-off surfaces — a rewards program first.\n */\nfunction CommercePromotionsZone(props: { hostId: string }) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot slot={COMMERCE_PROMOTIONS_ZONE.id} hostId={props.hostId} orgId={undefined} />\n ) : null\n}\n\n/**\n * The body of one commerce section, built only when that section is the one\n * being read (AGL-2501).\n *\n * A function rather than a map of nodes on purpose: a `Record<id, ReactNode>`\n * would CONSTRUCT every section every render, and each card opens its Firestore\n * listens on mount — which is the entire cost this page exists to stop paying.\n * Only the returned branch is ever built.\n */\nfunction sectionBody(\n section: CommerceConsoleSectionId,\n hostId: string,\n canManagePos: boolean,\n /** The register's finer keys this page's cards ask (AGL-4047). */\n pos: { canSetUpDevices: boolean; canBuyHardware: boolean; canCashDrawer: boolean } = {\n canSetUpDevices: canManagePos,\n canBuyHardware: canManagePos,\n canCashDrawer: canManagePos,\n },\n /** The reservation keys this site decides for the member (AGL-4047). */\n reservations: { canManage: boolean; canWalkIn: boolean } = { canManage: true, canWalkIn: true },\n /** \"Create and edit quotes\" and \"Send quotes and invoices to customers\" on this site (AGL-4093, AGL-4094). */\n quotes: { canEdit: boolean; canSend: boolean } = { canEdit: true, canSend: true },\n): ReactNode {\n switch (section) {\n case 'catalog':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <ProductsHubCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <CatalogOrganizationCard hostId={hostId} />,\n },\n // The ledger every stock writer fills and nothing displayed\n // (AGL-2341). Directly under the catalog, because the question\n // it answers — \"why does this count disagree with the shelf\" —\n // is asked while looking at the count.\n {\n size: { xs: 12 },\n children: <StockMovementsCard hostId={hostId} />,\n },\n { size: { xs: 12 }, children: <MemberPostsCard hostId={hostId} /> },\n ]}\n />\n )\n case 'orders':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <HostOrdersCard hostId={hostId} canSendInvoices={quotes.canSend} /> },\n // Prices put to a customer before they buy (AGL-4093), beside the\n // orders they become once paid.\n {\n size: { xs: 12 },\n children: <HostQuotesCard hostId={hostId} canEdit={quotes.canEdit} canSend={quotes.canSend} />,\n },\n // What to prepare, hand over and drive out (AGL-3624). Renders\n // nothing for a store with no pickup and no local delivery.\n {\n size: { xs: 12 },\n children: <PickupDeliveryQueueCard hostId={hostId} />,\n },\n // The two queues that feed orders rather than record them\n // (AGL-2227): checkouts that stalled and shoppers waiting on\n // stock. Beneath the orders list because both are pre-order.\n {\n size: { xs: 12 },\n children: <RecoveryQueueCard hostId={hostId} />,\n },\n // One day's or one event's totals across every register, shift\n // and cashier (AGL-4037), above the shifts it adds up.\n {\n size: { xs: 12 },\n children: <PosDayTotalsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n // Who is due at the window and who checked in (AGL-4043), beside\n // the day's totals.\n {\n size: { xs: 12 },\n children: <PosCheckInsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n {\n size: { xs: 12 },\n children: <PosShiftHistoryCard hostId={hostId} />,\n },\n ]}\n />\n )\n case 'returns':\n // Returns (AGL-3611); `?return={id}` opens one on arrival.\n return <ReturnsCard hostId={hostId} />\n case 'promotions':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <DiscountsCard hostId={hostId} /> },\n { size: { xs: 12 }, children: <HostCouponsCard hostId={hostId} /> },\n // Store credit lives with the other money-off surfaces\n // (AGL-2226) — it had no console anywhere before this.\n { size: { xs: 12 }, children: <GiftCardsCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <ReviewsModerationCard hostId={hostId} />,\n },\n // Who may review, and the review-request email (AGL-3736),\n // beside the queue those reviews land in.\n {\n size: { xs: 12 },\n children: <ReviewSettingsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <CommercePromotionsZone hostId={hostId} />,\n },\n ]}\n />\n )\n case 'reservations':\n return (\n <ReservationsCard\n hostId={hostId}\n canManage={reservations.canManage}\n canWalkIn={reservations.canWalkIn}\n />\n )\n /*\n * The store's settings, a page each (AGL-3713). They were one `settings`\n * section — every card below in one column — and its old address opens\n * Payments (`COMMERCE_RETIRED_SECTIONS`). Each page is its cards, then\n * the zone where other plugins' cards for that page land.\n */\n case 'payments':\n return settingsPage(section, hostId, [\n <PaymentsSettingsCard key=\"payments\" hostId={hostId} />,\n // What shoppers may pay with (AGL-3629), beside the account the\n // money lands in.\n <PaymentMethodsCard key=\"methods\" hostId={hostId} />,\n ])\n case 'checkout':\n return settingsPage(section, hostId, [\n <StoreSettingsCard key=\"store\" hostId={hostId} />,\n // Whether buyers may ask for a return online (AGL-3611): the store's\n // policy, beside the terms and guest-checkout rules above it.\n <ReturnSettingsCard key=\"returns\" hostId={hostId} />,\n // What a new quote starts with (AGL-4093).\n <QuoteSettingsCard key=\"quotes\" hostId={hostId} />,\n ])\n case 'taxes':\n return settingsPage(section, hostId, [\n <TaxSettingsCard key=\"tax\" hostId={hostId} />,\n ])\n case 'shipping':\n return settingsPage(section, hostId, [\n <ShippingSettingsCard key=\"shipping\" hostId={hostId} />,\n // Where parcels ship from, and pickup, per location.\n <LocationsCard key=\"locations\" hostId={hostId} />,\n // The store's own delivery (AGL-3624); pickup is per location, on\n // the Inventory locations card above.\n <LocalDeliverySettingsCard key=\"local\" hostId={hostId} />,\n <SuppliersCard key=\"suppliers\" hostId={hostId} />,\n <ShipStationCard key=\"shipstation\" hostId={hostId} />,\n // ShippingEasy, with the merchant's own keys (AGL-3633).\n <ShippingEasyCard key=\"shippingeasy\" hostId={hostId} />,\n ])\n case 'notifications':\n return settingsPage(section, hostId, [\n <CustomerNotificationsCard key=\"customers\" hostId={hostId} />,\n // The store's own endpoints for order events (AGL-3611). Renders\n // nothing for a person who may not manage them.\n <OrderWebhooksCard key=\"webhooks\" hostId={hostId} />,\n ])\n case 'pos':\n return settingsPage(section, hostId, [\n // A reader bought in person waits at the top until it is set up\n // (AGL-4038), in the registers' own grid cell so an empty one\n // leaves no gap.\n <Stack key=\"registers\" spacing={3}>\n <Suspense fallback={null}>\n <PosHardwareWaitingCard\n hostId={hostId}\n {...(pos.canSetUpDevices ? {} : { devicesBlockedReason: posPermissionRefusal('posDevices') })}\n />\n </Suspense>\n <RegistersCard hostId={hostId} />\n </Stack>,\n <PosStaffPinsCard key=\"pins\" hostId={hostId} />,\n // A register's printers, cash drawer and status (AGL-3619), one card\n // per register, after the list that names them.\n <RegisterHardwareCards\n key=\"hardware\"\n hostId={hostId}\n blocked={{\n ...(pos.canSetUpDevices ? {} : { devices: posPermissionRefusal('posDevices') }),\n ...(pos.canCashDrawer ? {} : { drawer: posPermissionRefusal('posCashDrawer') }),\n }}\n />,\n <PosDevicesCard\n key=\"devices\"\n hostId={hostId}\n canManagePos={canManagePos}\n canSetUpDevices={pos.canSetUpDevices}\n />,\n // Card readers bought from the platform (AGL-4038), after the card\n // that registers them. Draws nothing until the deployment opens the\n // shop.\n <PosHardwareCard\n key=\"hardware-shop\"\n hostId={hostId}\n canManagePos={canManagePos}\n canBuyHardware={pos.canBuyHardware}\n />,\n ])\n case 'channels':\n case 'integrations':\n // Other plugins' cards only; the rail leaves either page out while\n // its zone has nothing to draw (`onlyWithZones`).\n return settingsPage(section, hostId, [])\n case 'analytics':\n return (\n // Two cards since AGL-2440. The tax summary lives here rather\n // than on the Taxes settings page because that page CONFIGURES tax and\n // this REPORTS what was collected — a merchant reading a figure\n // they may file from should not be one field away from changing\n // the rate that produced it.\n <GridItems\n spacing={3}\n items={[\n {\n size: { xs: 12 },\n children: <CommerceAnalyticsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <StorefrontTaxSummaryCard hostId={hostId} />,\n },\n ]}\n />\n )\n default:\n return null\n }\n}\n\n/**\n * Commerce console page (AGL-395): the Products management surface, owned by\n * the commerce plugin and rendered by the shell's generic plugin route. The\n * product editor's media browser is supplied by the shell's\n * ConsoleMediaPickerProvider (the media library is org/session coupled and\n * stays in the app).\n *\n * ## Sections are ROUTES (AGL-2501)\n *\n * The sections hold thirty-two Firestore listens between them, and a tab\n * strip mounts every panel: opening Catalog also subscribed the orders,\n * promotions, reservations, settings and analytics cards. The `limit()` on\n * those queries is the bill — several ask for 500, and one load reached a\n * ceiling of ~4,460 documents to render one tab.\n *\n * `HubTabs lazy` bought that back as a flag somebody has to remember. A URL\n * per section makes it structural instead: the page builds one section's body\n * and the others do not exist to subscribe. Three things come with it that the\n * tab version faked — a section is linkable, the back button walks sections,\n * and which one is open is a fact about the URL rather than state kept in sync\n * with it. `commerce-console-read-cost.spec.tsx` meters it at the Firestore\n * boundary and refuses a section that listens before it is opened.\n *\n * The shell resolves the section, gates it and hands back the rail's hrefs;\n * this page only has to say what each section contains.\n */\nexport function CommerceConsolePage(props: ConsolePluginPageProps) {\n const { hostId, section, sections, basePath, permissions } = props\n /*\n * The register's own gate, for the devices card's Pair display (AGL-3712):\n * `managePos` — what the server's `mayWorkRegister` asks. The key decides,\n * not the site role (AGL-4047). The server stays the enforcement point.\n */\n const canManagePos = permissions?.managePos === true\n // The register's finer keys (AGL-4047), each following `managePos` unless a\n // role or the member sets it — what the devices and hardware routes ask.\n // Buying hardware stands on its own: the Hardware card is this page's for a\n // member who holds it without the register.\n const pos = {\n canSetUpDevices: canManagePos && holdsPosPermission(permissions, 'posDevices'),\n canBuyHardware: holdsPosPermission(permissions, 'posBuyHardware'),\n canCashDrawer: canManagePos && holdsPosPermission(permissions, 'posCashDrawer'),\n }\n // The reservation keys (AGL-4047), whose preset is the member's role on\n // this site; the shell decides them for the site in view. A map that does\n // not carry one (a shell that predates them) leaves the card as it was:\n // the rules and the routes decide.\n const reservations = {\n canManage: permissions?.['commerce.reservations'] !== false,\n canWalkIn: permissions?.['commerce.walkIns'] !== false,\n }\n // \"Create and edit quotes\" (AGL-4093), read the same way; the quote route\n // decides.\n const quotes = {\n canEdit: permissions?.['commerce.quotes'] !== false,\n canSend: permissions?.['commerce.quotes.send'] !== false,\n }\n\n /*\n * Nothing, deliberately, while the redirect is in flight.\n *\n * Rendering the default section here instead would issue that section's\n * listens on a URL that is about to be replaced — paying for Catalog on\n * every arrival at `/products`, which is every click of the nav tab.\n */\n if (!section || !sections?.length || !basePath) return null\n\n return (\n <HubSections sections={sections}>\n {sectionBody(section as CommerceConsoleSectionId, hostId, canManagePos, pos, reservations, quotes)}\n </HubSections>\n )\n}\nCommerceConsolePage.displayName = 'CommerceConsolePage'\n\nexport default CommerceConsolePage\n"],"names":["GridItems","HubSections","lazy","Suspense","Stack","COMMERCE_SETTINGS_PAGE_ZONES","CatalogOrganizationCard","CommerceAnalyticsCard","CustomerNotificationsCard","DiscountsCard","GiftCardsCard","HostCouponsCard","HostOrdersCard","HostQuotesCard","LocationsCard","LocalDeliverySettingsCard","PickupDeliveryQueueCard","MemberPostsCard","OrderWebhooksCard","PaymentsSettingsCard","PosCheckInsCard","PosDayTotalsCard","PosShiftHistoryCard","PosStaffPinsCard","PaymentMethodsCard","ProductsHubCard","QuoteSettingsCard","RecoveryQueueCard","RegistersCard","RegisterHardwareCards","PosDevicesCard","PosHardwareCard","PosHardwareWaitingCard","holdsPosPermission","posPermissionRefusal","ReservationsCard","ReturnSettingsCard","ReturnsCard","ReviewsModerationCard","ReviewSettingsCard","ShippingSettingsCard","ShipStationCard","ShippingEasyCard","StockMovementsCard","StoreSettingsCard","StorefrontTaxSummaryCard","SuppliersCard","TaxSettingsCard","COMMERCE_PROMOTIONS_ZONE","useConsoleWidgetSlot","CommerceSettingsZone","props","WidgetSlot","slot","page","hostId","orgId","undefined","settingsPage","cards","spacing","items","map","children","size","xs","CommercePromotionsZone","id","sectionBody","section","canManagePos","pos","canSetUpDevices","canBuyHardware","canCashDrawer","reservations","canManage","canWalkIn","quotes","canEdit","canSend","canSendInvoices","fallback","devicesBlockedReason","blocked","devices","drawer","CommerceConsolePage","sections","basePath","permissions","managePos","length","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAAQ,uBAAsB;AAChD,SAASC,WAAW,QAAQ,wBAAuB;AACnD,SAASC,IAAI,EAAEC,QAAQ,QAAwB,QAAO;AACtD,SAASC,KAAK,QAAQ,gBAAe;AACrC,SACEC,4BAA4B,QAGvB,iCAA6B;AACpC,OAAOC,6BAA6B,mDAA+C;AACnF,OAAOC,2BAA2B,iDAA6C;AAC/E,OAAOC,+BAA+B,qDAAiD;AACvF,OAAOC,mBAAmB,wCAAoC;AAC9D,OAAOC,mBAAmB,yCAAqC;AAC/D,OAAOC,qBAAqB,2CAAuC;AACnE,OAAOC,oBAAoB,0CAAsC;AACjE,OAAOC,oBAAoB,0CAAsC;AACjE,OAAOC,mBAAmB,wCAAoC;AAC9D,OAAOC,+BAA+B,sDAAkD;AACxF,OAAOC,6BAA6B,oDAAgD;AACpF,OAAOC,qBAAqB,2CAAuC;AACnE,OAAOC,uBAAuB,6CAAyC;AACvE,OAAOC,0BAA0B,gDAA4C;AAC7E,OAAOC,qBAAqB,oDAAgD;AAC5E,OAAOC,sBAAsB,qDAAiD;AAC9E,OAAOC,yBAAyB,wDAAoD;AACpF,OAAOC,sBAAsB,qDAAiD;AAC9E,OAAOC,wBAAwB,8CAA0C;AACzE,OAAOC,qBAAqB,2CAAuC;AACn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
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/commerce-console-page.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { GridItems } from '@aglyn/shared-ui-jsx'\nimport { HubSections } from '@aglyn/shared-ui-next'\nimport { lazy, Suspense, type ReactNode } from 'react'\nimport { Stack } from '@mui/material'\nimport {\n COMMERCE_SETTINGS_PAGE_ZONES,\n type CommerceConsoleSectionId,\n type CommerceSettingsSectionId,\n} from './commerce-console-sections'\nimport CatalogOrganizationCard from './console/catalog-organization-card.component'\nimport CommerceAnalyticsCard from './console/commerce-analytics-card.component'\nimport CustomerNotificationsCard from './console/customer-notifications-card.component'\nimport DiscountsCard from './console/discounts-card.component'\nimport GiftCardsCard from './console/gift-cards-card.component'\nimport HostCouponsCard from './console/host-coupons-card.component'\nimport HostOrdersCard from './console/host-orders-card.component'\nimport HostQuotesCard from './console/host-quotes-card.component'\nimport LocationsCard from './console/locations-card.component'\nimport LocalDeliverySettingsCard from './console/local-delivery-settings-card.component'\nimport PickupDeliveryQueueCard from './console/pickup-delivery-queue-card.component'\nimport MemberPostsCard from './console/member-posts-card.component'\nimport OrderWebhooksCard from './console/order-webhooks-card.component'\nimport PaymentsSettingsCard from './console/payments-settings-card.component'\nimport PosCheckInsCard from './console/pos-ops/pos-check-ins-card.component'\nimport PosDayTotalsCard from './console/pos-ops/pos-day-totals-card.component'\nimport PosShiftHistoryCard from './console/pos-ops/pos-shift-history-card.component'\nimport PosStaffPinsCard from './console/pos-ops/pos-staff-pins-card.component'\nimport PaymentMethodsCard from './console/payment-methods-card.component'\nimport ProductsHubCard from './console/products-hub-card.component'\nimport QuoteSettingsCard from './console/quote-settings-card.component'\nimport RecoveryQueueCard from './console/recovery-queue-card.component'\nimport RegistersCard from './console/registers-card.component'\nimport RegisterHardwareCards from './console/register-hardware-card.component'\nimport PosDevicesCard from './console/pos-devices-card.component'\nimport PosHardwareCard from './console/pos-hardware-card.component'\n\n/**\n * Card readers the workspace bought in person, waiting to be set up\n * (AGL-4038): its own chunk, drawn only while there is one.\n */\nconst PosHardwareWaitingCard = lazy(() => import('./console/pos-hardware-waiting-card.component'))\nimport { holdsPosPermission, posPermissionRefusal } from '../model/plugin-permissions'\nimport ReservationsCard from './console/reservations-card.component'\nimport ReturnSettingsCard from './console/return-settings-card.component'\nimport ReturnsCard from './console/returns-card.component'\nimport ReviewsModerationCard from './console/reviews-moderation-card.component'\nimport ReviewSettingsCard from './console/review-settings-card.component'\nimport ShippingSettingsCard from './console/shipping-settings-card.component'\nimport ShipStationCard from './console/shipstation-card.component'\nimport ShippingEasyCard from './console/shippingeasy-card.component'\nimport StockMovementsCard from './console/stock-movements-card.component'\nimport StoreSettingsCard from './console/store-settings-card.component'\nimport StorefrontTaxSummaryCard from './console/storefront-tax-summary-card.component'\nimport SubscriptionsCard from './console/subscriptions-card.component'\nimport SuppliersCard from './console/suppliers-card.component'\nimport TaxSettingsCard from './console/tax-settings-card.component'\nimport { COMMERCE_PROMOTIONS_ZONE } from './console/store-zones'\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\n\n/**\n * A settings page's zone (AGL-3612, AGL-3713): other plugins' settings for\n * the store — label settings, carrier accounts, a tax service — under the\n * page's own cards. One zone per page, from `COMMERCE_SETTINGS_PAGE_ZONES`;\n * Integrations draws `commerceSettings`, where a widget naming no page lands.\n */\nfunction CommerceSettingsZone(props: {\n hostId: string\n page: CommerceSettingsSectionId\n}) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot\n slot={COMMERCE_SETTINGS_PAGE_ZONES[props.page]}\n hostId={props.hostId}\n orgId={undefined}\n />\n ) : null\n}\n\n/** One settings page: its cards in order, then its zone (AGL-3713). */\nfunction settingsPage(\n page: CommerceSettingsSectionId,\n hostId: string,\n cards: readonly ReactNode[],\n): ReactNode {\n return (\n <GridItems\n spacing={3}\n items={[\n ...cards.map((children) => ({ size: { xs: 12 }, children })),\n {\n size: { xs: 12 },\n children: <CommerceSettingsZone hostId={hostId} page={page} />,\n },\n ]}\n />\n )\n}\n\n/**\n * The `commercePromotions` zone (AGL-3640): other plugins' programs beside\n * the store's own money-off surfaces — a rewards program first.\n */\nfunction CommercePromotionsZone(props: { hostId: string }) {\n const WidgetSlot = useConsoleWidgetSlot()\n return WidgetSlot ? (\n <WidgetSlot slot={COMMERCE_PROMOTIONS_ZONE.id} hostId={props.hostId} orgId={undefined} />\n ) : null\n}\n\n/**\n * The body of one commerce section, built only when that section is the one\n * being read (AGL-2501).\n *\n * A function rather than a map of nodes on purpose: a `Record<id, ReactNode>`\n * would CONSTRUCT every section every render, and each card opens its Firestore\n * listens on mount — which is the entire cost this page exists to stop paying.\n * Only the returned branch is ever built.\n */\nfunction sectionBody(\n section: CommerceConsoleSectionId,\n hostId: string,\n canManagePos: boolean,\n /** The register's finer keys this page's cards ask (AGL-4047). */\n pos: { canSetUpDevices: boolean; canBuyHardware: boolean; canCashDrawer: boolean } = {\n canSetUpDevices: canManagePos,\n canBuyHardware: canManagePos,\n canCashDrawer: canManagePos,\n },\n /** The reservation keys this site decides for the member (AGL-4047). */\n reservations: { canManage: boolean; canWalkIn: boolean } = { canManage: true, canWalkIn: true },\n /** \"Create and edit quotes\" and \"Send quotes and invoices to customers\" on this site (AGL-4093, AGL-4094). */\n quotes: { canEdit: boolean; canSend: boolean } = { canEdit: true, canSend: true },\n): ReactNode {\n switch (section) {\n case 'catalog':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <ProductsHubCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <CatalogOrganizationCard hostId={hostId} />,\n },\n // The ledger every stock writer fills and nothing displayed\n // (AGL-2341). Directly under the catalog, because the question\n // it answers — \"why does this count disagree with the shelf\" —\n // is asked while looking at the count.\n {\n size: { xs: 12 },\n children: <StockMovementsCard hostId={hostId} />,\n },\n { size: { xs: 12 }, children: <MemberPostsCard hostId={hostId} /> },\n ]}\n />\n )\n case 'orders':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <HostOrdersCard hostId={hostId} canSendInvoices={quotes.canSend} /> },\n // Prices put to a customer before they buy (AGL-4093), beside the\n // orders they become once paid.\n {\n size: { xs: 12 },\n children: <HostQuotesCard hostId={hostId} canEdit={quotes.canEdit} canSend={quotes.canSend} />,\n },\n // What to prepare, hand over and drive out (AGL-3624). Renders\n // nothing for a store with no pickup and no local delivery.\n {\n size: { xs: 12 },\n children: <PickupDeliveryQueueCard hostId={hostId} />,\n },\n // The two queues that feed orders rather than record them\n // (AGL-2227): checkouts that stalled and shoppers waiting on\n // stock. Beneath the orders list because both are pre-order.\n {\n size: { xs: 12 },\n children: <RecoveryQueueCard hostId={hostId} />,\n },\n // One day's or one event's totals across every register, shift\n // and cashier (AGL-4037), above the shifts it adds up.\n {\n size: { xs: 12 },\n children: <PosDayTotalsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n // Who is due at the window and who checked in (AGL-4043), beside\n // the day's totals.\n {\n size: { xs: 12 },\n children: <PosCheckInsCard hostId={hostId} canManagePos={canManagePos} />,\n },\n {\n size: { xs: 12 },\n children: <PosShiftHistoryCard hostId={hostId} />,\n },\n ]}\n />\n )\n case 'subscriptions':\n // Every subscription, its recurring revenue and its invoices (AGL-4191).\n return <SubscriptionsCard hostId={hostId} />\n case 'returns':\n // Returns (AGL-3611); `?return={id}` opens one on arrival.\n return <ReturnsCard hostId={hostId} />\n case 'promotions':\n return (\n <GridItems\n spacing={3}\n items={[\n { size: { xs: 12 }, children: <DiscountsCard hostId={hostId} /> },\n { size: { xs: 12 }, children: <HostCouponsCard hostId={hostId} /> },\n // Store credit lives with the other money-off surfaces\n // (AGL-2226) — it had no console anywhere before this.\n { size: { xs: 12 }, children: <GiftCardsCard hostId={hostId} /> },\n {\n size: { xs: 12 },\n children: <ReviewsModerationCard hostId={hostId} />,\n },\n // Who may review, and the review-request email (AGL-3736),\n // beside the queue those reviews land in.\n {\n size: { xs: 12 },\n children: <ReviewSettingsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <CommercePromotionsZone hostId={hostId} />,\n },\n ]}\n />\n )\n case 'reservations':\n return (\n <ReservationsCard\n hostId={hostId}\n canManage={reservations.canManage}\n canWalkIn={reservations.canWalkIn}\n />\n )\n /*\n * The store's settings, a page each (AGL-3713). They were one `settings`\n * section — every card below in one column — and its old address opens\n * Payments (`COMMERCE_RETIRED_SECTIONS`). Each page is its cards, then\n * the zone where other plugins' cards for that page land.\n */\n case 'payments':\n return settingsPage(section, hostId, [\n <PaymentsSettingsCard key=\"payments\" hostId={hostId} />,\n // What shoppers may pay with (AGL-3629), beside the account the\n // money lands in.\n <PaymentMethodsCard key=\"methods\" hostId={hostId} />,\n ])\n case 'checkout':\n return settingsPage(section, hostId, [\n <StoreSettingsCard key=\"store\" hostId={hostId} />,\n // Whether buyers may ask for a return online (AGL-3611): the store's\n // policy, beside the terms and guest-checkout rules above it.\n <ReturnSettingsCard key=\"returns\" hostId={hostId} />,\n // What a new quote starts with (AGL-4093).\n <QuoteSettingsCard key=\"quotes\" hostId={hostId} />,\n ])\n case 'taxes':\n return settingsPage(section, hostId, [\n <TaxSettingsCard key=\"tax\" hostId={hostId} />,\n ])\n case 'shipping':\n return settingsPage(section, hostId, [\n <ShippingSettingsCard key=\"shipping\" hostId={hostId} />,\n // Where parcels ship from, and pickup, per location.\n <LocationsCard key=\"locations\" hostId={hostId} />,\n // The store's own delivery (AGL-3624); pickup is per location, on\n // the Inventory locations card above.\n <LocalDeliverySettingsCard key=\"local\" hostId={hostId} />,\n <SuppliersCard key=\"suppliers\" hostId={hostId} />,\n <ShipStationCard key=\"shipstation\" hostId={hostId} />,\n // ShippingEasy, with the merchant's own keys (AGL-3633).\n <ShippingEasyCard key=\"shippingeasy\" hostId={hostId} />,\n ])\n case 'notifications':\n return settingsPage(section, hostId, [\n <CustomerNotificationsCard key=\"customers\" hostId={hostId} />,\n // The store's own endpoints for order events (AGL-3611). Renders\n // nothing for a person who may not manage them.\n <OrderWebhooksCard key=\"webhooks\" hostId={hostId} />,\n ])\n case 'pos':\n return settingsPage(section, hostId, [\n // A reader bought in person waits at the top until it is set up\n // (AGL-4038), in the registers' own grid cell so an empty one\n // leaves no gap.\n <Stack key=\"registers\" spacing={3}>\n <Suspense fallback={null}>\n <PosHardwareWaitingCard\n hostId={hostId}\n {...(pos.canSetUpDevices ? {} : { devicesBlockedReason: posPermissionRefusal('posDevices') })}\n />\n </Suspense>\n <RegistersCard hostId={hostId} />\n </Stack>,\n <PosStaffPinsCard key=\"pins\" hostId={hostId} />,\n // A register's printers, cash drawer and status (AGL-3619), one card\n // per register, after the list that names them.\n <RegisterHardwareCards\n key=\"hardware\"\n hostId={hostId}\n blocked={{\n ...(pos.canSetUpDevices ? {} : { devices: posPermissionRefusal('posDevices') }),\n ...(pos.canCashDrawer ? {} : { drawer: posPermissionRefusal('posCashDrawer') }),\n }}\n />,\n <PosDevicesCard\n key=\"devices\"\n hostId={hostId}\n canManagePos={canManagePos}\n canSetUpDevices={pos.canSetUpDevices}\n />,\n // Card readers bought from the platform (AGL-4038), after the card\n // that registers them. Draws nothing until the deployment opens the\n // shop.\n <PosHardwareCard\n key=\"hardware-shop\"\n hostId={hostId}\n canManagePos={canManagePos}\n canBuyHardware={pos.canBuyHardware}\n />,\n ])\n case 'channels':\n case 'integrations':\n // Other plugins' cards only; the rail leaves either page out while\n // its zone has nothing to draw (`onlyWithZones`).\n return settingsPage(section, hostId, [])\n case 'analytics':\n return (\n // Two cards since AGL-2440. The tax summary lives here rather\n // than on the Taxes settings page because that page CONFIGURES tax and\n // this REPORTS what was collected — a merchant reading a figure\n // they may file from should not be one field away from changing\n // the rate that produced it.\n <GridItems\n spacing={3}\n items={[\n {\n size: { xs: 12 },\n children: <CommerceAnalyticsCard hostId={hostId} />,\n },\n {\n size: { xs: 12 },\n children: <StorefrontTaxSummaryCard hostId={hostId} />,\n },\n ]}\n />\n )\n default:\n return null\n }\n}\n\n/**\n * Commerce console page (AGL-395): the Products management surface, owned by\n * the commerce plugin and rendered by the shell's generic plugin route. The\n * product editor's media browser is supplied by the shell's\n * ConsoleMediaPickerProvider (the media library is org/session coupled and\n * stays in the app).\n *\n * ## Sections are ROUTES (AGL-2501)\n *\n * The sections hold thirty-two Firestore listens between them, and a tab\n * strip mounts every panel: opening Catalog also subscribed the orders,\n * promotions, reservations, settings and analytics cards. The `limit()` on\n * those queries is the bill — several ask for 500, and one load reached a\n * ceiling of ~4,460 documents to render one tab.\n *\n * `HubTabs lazy` bought that back as a flag somebody has to remember. A URL\n * per section makes it structural instead: the page builds one section's body\n * and the others do not exist to subscribe. Three things come with it that the\n * tab version faked — a section is linkable, the back button walks sections,\n * and which one is open is a fact about the URL rather than state kept in sync\n * with it. `commerce-console-read-cost.spec.tsx` meters it at the Firestore\n * boundary and refuses a section that listens before it is opened.\n *\n * The shell resolves the section, gates it and hands back the rail's hrefs;\n * this page only has to say what each section contains.\n */\nexport function CommerceConsolePage(props: ConsolePluginPageProps) {\n const { hostId, section, sections, basePath, permissions } = props\n /*\n * The register's own gate, for the devices card's Pair display (AGL-3712):\n * `managePos` — what the server's `mayWorkRegister` asks. The key decides,\n * not the site role (AGL-4047). The server stays the enforcement point.\n */\n const canManagePos = permissions?.managePos === true\n // The register's finer keys (AGL-4047), each following `managePos` unless a\n // role or the member sets it — what the devices and hardware routes ask.\n // Buying hardware stands on its own: the Hardware card is this page's for a\n // member who holds it without the register.\n const pos = {\n canSetUpDevices: canManagePos && holdsPosPermission(permissions, 'posDevices'),\n canBuyHardware: holdsPosPermission(permissions, 'posBuyHardware'),\n canCashDrawer: canManagePos && holdsPosPermission(permissions, 'posCashDrawer'),\n }\n // The reservation keys (AGL-4047), whose preset is the member's role on\n // this site; the shell decides them for the site in view. A map that does\n // not carry one (a shell that predates them) leaves the card as it was:\n // the rules and the routes decide.\n const reservations = {\n canManage: permissions?.['commerce.reservations'] !== false,\n canWalkIn: permissions?.['commerce.walkIns'] !== false,\n }\n // \"Create and edit quotes\" (AGL-4093), read the same way; the quote route\n // decides.\n const quotes = {\n canEdit: permissions?.['commerce.quotes'] !== false,\n canSend: permissions?.['commerce.quotes.send'] !== false,\n }\n\n /*\n * Nothing, deliberately, while the redirect is in flight.\n *\n * Rendering the default section here instead would issue that section's\n * listens on a URL that is about to be replaced — paying for Catalog on\n * every arrival at `/products`, which is every click of the nav tab.\n */\n if (!section || !sections?.length || !basePath) return null\n\n return (\n <HubSections sections={sections}>\n {sectionBody(section as CommerceConsoleSectionId, hostId, canManagePos, pos, reservations, quotes)}\n </HubSections>\n )\n}\nCommerceConsolePage.displayName = 'CommerceConsolePage'\n\nexport default CommerceConsolePage\n"],"names":["GridItems","HubSections","lazy","Suspense","Stack","COMMERCE_SETTINGS_PAGE_ZONES","CatalogOrganizationCard","CommerceAnalyticsCard","CustomerNotificationsCard","DiscountsCard","GiftCardsCard","HostCouponsCard","HostOrdersCard","HostQuotesCard","LocationsCard","LocalDeliverySettingsCard","PickupDeliveryQueueCard","MemberPostsCard","OrderWebhooksCard","PaymentsSettingsCard","PosCheckInsCard","PosDayTotalsCard","PosShiftHistoryCard","PosStaffPinsCard","PaymentMethodsCard","ProductsHubCard","QuoteSettingsCard","RecoveryQueueCard","RegistersCard","RegisterHardwareCards","PosDevicesCard","PosHardwareCard","PosHardwareWaitingCard","holdsPosPermission","posPermissionRefusal","ReservationsCard","ReturnSettingsCard","ReturnsCard","ReviewsModerationCard","ReviewSettingsCard","ShippingSettingsCard","ShipStationCard","ShippingEasyCard","StockMovementsCard","StoreSettingsCard","StorefrontTaxSummaryCard","SubscriptionsCard","SuppliersCard","TaxSettingsCard","COMMERCE_PROMOTIONS_ZONE","useConsoleWidgetSlot","CommerceSettingsZone","props","WidgetSlot","slot","page","hostId","orgId","undefined","settingsPage","cards","spacing","items","map","children","size","xs","CommercePromotionsZone","id","sectionBody","section","canManagePos","pos","canSetUpDevices","canBuyHardware","canCashDrawer","reservations","canManage","canWalkIn","quotes","canEdit","canSend","canSendInvoices","fallback","devicesBlockedReason","blocked","devices","drawer","CommerceConsolePage","sections","basePath","permissions","managePos","length","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAAQ,uBAAsB;AAChD,SAASC,WAAW,QAAQ,wBAAuB;AACnD,SAASC,IAAI,EAAEC,QAAQ,QAAwB,QAAO;AACtD,SAASC,KAAK,QAAQ,gBAAe;AACrC,SACEC,4BAA4B,QAGvB,iCAA6B;AACpC,OAAOC,6BAA6B,mDAA+C;AACnF,OAAOC,2BAA2B,iDAA6C;AAC/E,OAAOC,+BAA+B,qDAAiD;AACvF,OAAOC,mBAAmB,wCAAoC;AAC9D,OAAOC,mBAAmB,yCAAqC;AAC/D,OAAOC,qBAAqB,2CAAuC;AACnE,OAAOC,oBAAoB,0CAAsC;AACjE,OAAOC,oBAAoB,0CAAsC;AACjE,OAAOC,mBAAmB,wCAAoC;AAC9D,OAAOC,+BAA+B,sDAAkD;AACxF,OAAOC,6BAA6B,oDAAgD;AACpF,OAAOC,qBAAqB,2CAAuC;AACnE,OAAOC,uBAAuB,6CAAyC;AACvE,OAAOC,0BAA0B,gDAA4C;AAC7E,OAAOC,qBAAqB,oDAAgD;AAC5E,OAAOC,sBAAsB,qDAAiD;AAC9E,OAAOC,yBAAyB,wDAAoD;AACpF,OAAOC,sBAAsB,qDAAiD;AAC9E,OAAOC,wBAAwB,8CAA0C;AACzE,OAAOC,qBAAqB,2CAAu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B,YAAYC,SAAqCd,QAAQe,cAAcC,KAAKI,cAAcG;;AAGjG;AACAS,oBAAoBM,WAAW,GAAG;AAElC,eAAeN,oBAAmB"}
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import type { ConsoleNavSection } from '@aglyn/aglyn';
18
- export type CommerceConsoleSectionId = 'catalog' | 'orders' | 'returns' | 'promotions' | 'reservations' | 'analytics' | CommerceSettingsSectionId;
18
+ export type CommerceConsoleSectionId = 'catalog' | 'orders' | 'subscriptions' | 'returns' | 'promotions' | 'reservations' | 'analytics' | CommerceSettingsSectionId;
19
19
  /**
20
20
  * The store's settings, one page each (AGL-3713). They were one section,
21
21
  * `settings`, and one long column: payments, taxes, shipping, the register
@@ -60,6 +60,11 @@
60
60
  id: 'orders',
61
61
  label: 'Orders'
62
62
  },
63
+ // Every subscription and its recurring revenue (AGL-4191).
64
+ {
65
+ id: 'subscriptions',
66
+ label: 'Subscriptions'
67
+ },
63
68
  {
64
69
  id: 'returns',
65
70
  label: 'Returns'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/commerce-console-sections.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleNavSection } from '@aglyn/aglyn'\n\nexport type CommerceConsoleSectionId =\n | 'catalog'\n | 'orders'\n | 'returns'\n | 'promotions'\n | 'reservations'\n | 'analytics'\n | CommerceSettingsSectionId\n\n/**\n * The store's settings, one page each (AGL-3713). They were one section,\n * `settings`, and one long column: payments, taxes, shipping, the register\n * and every other plugin's cards, one after another.\n */\nexport type CommerceSettingsSectionId =\n | 'payments'\n | 'checkout'\n | 'taxes'\n | 'shipping'\n | 'notifications'\n | 'pos'\n | 'channels'\n | 'integrations'\n\n/** The words above the settings pages in the rail (AGL-3713). */\nexport const COMMERCE_SETTINGS_GROUP = 'Settings'\n\n/**\n * The zone each settings page draws at its foot, keyed by page (AGL-3713).\n *\n * One zone per page, so a plugin chooses its page by the zone it names and\n * nothing else: a contributor restates the id, never imports this package.\n * `commerceSettings` — the zone every store-settings widget named before the\n * split — is the Integrations page's, so a widget that names no page lands\n * there rather than nowhere.\n */\nexport const COMMERCE_SETTINGS_PAGE_ZONES: Readonly<\n Record<CommerceSettingsSectionId, string>\n> = {\n payments: 'commerceSettingsPayments',\n checkout: 'commerceSettingsCheckout',\n taxes: 'commerceSettingsTaxes',\n shipping: 'commerceSettingsShipping',\n notifications: 'commerceSettingsNotifications',\n pos: 'commerceSettingsPos',\n channels: 'commerceSettingsChannels',\n integrations: 'commerceSettings',\n}\n\n/** Under the \"Settings\" subheader (AGL-3713). */\nconst SETTINGS = COMMERCE_SETTINGS_GROUP\n\n/**\n * The commerce console's sections, in rail order (AGL-2501).\n *\n * One list, read twice and never copied: `plugin.ts` registers it on the nav\n * item so the shell can route and gate each section, and the page switches its\n * body on the id the shell resolves back. A second copy is how a section comes\n * to be routable under one id and drawn under another.\n *\n * Ids appear in links people keep — treat them as persisted, and rename a\n * LABEL rather than an id. An id that has to go is mapped in\n * {@link COMMERCE_RETIRED_SECTIONS} to the section that replaced it.\n *\n * No `navTabId` on any of them: every section here ships with the surface, so\n * they inherit the Products nav item's gate. A section that ships later\n * declares its own, which ANDs with the parent's rather than replacing it.\n *\n * The store's own work first, then its settings under a divider and a\n * \"Settings\" subheader (AGL-3713).\n */\nexport const COMMERCE_CONSOLE_SECTIONS: readonly ConsoleNavSection[] = [\n { id: 'catalog', label: 'Catalog' },\n { id: 'orders', label: 'Orders' },\n { id: 'returns', label: 'Returns' },\n { id: 'promotions', label: 'Promotions' },\n { id: 'reservations', label: 'Reservations' },\n { id: 'analytics', label: 'Analytics' },\n { id: 'payments', label: 'Payments', group: SETTINGS },\n { id: 'checkout', label: 'Checkout', group: SETTINGS },\n { id: 'taxes', label: 'Taxes', group: SETTINGS },\n { id: 'shipping', label: 'Shipping & delivery', group: SETTINGS },\n { id: 'notifications', label: 'Notifications', group: SETTINGS },\n { id: 'pos', label: 'Point of sale', group: SETTINGS },\n // Nothing but other plugins' cards, so each is left out of the rail while\n // none of them has anything to draw (`onlyWithZones`).\n {\n id: 'channels',\n label: 'Sales channels',\n group: SETTINGS,\n onlyWithZones: [COMMERCE_SETTINGS_PAGE_ZONES.channels],\n },\n {\n id: 'integrations',\n label: 'Integrations',\n group: SETTINGS,\n onlyWithZones: [COMMERCE_SETTINGS_PAGE_ZONES.integrations],\n },\n]\n\n/**\n * Section ids the console no longer has, and where each one's links go\n * (AGL-3713). `/products/settings` was every setting on one page; it opens\n * Payments, the first of the pages it was split into.\n */\nexport const COMMERCE_RETIRED_SECTIONS: Readonly<Record<string, string>> = {\n settings: 'payments',\n}\n\n/*\n * Rail ORDER decides where `/products` lands: the shell redirects a bare hub\n * URL to the first section in this list the reader may open (AGL-2501). There\n * is deliberately no separate default constant — a second place to say which\n * section is first is a second place for it to disagree with the rail.\n */\n"],"names":["COMMERCE_SETTINGS_GROUP","COMMERCE_SETTINGS_PAGE_ZONES","payments","checkout","taxes","shipping","notifications","pos","channels","integrations","SETTINGS","COMMERCE_CONSOLE_SECTIONS","id","label","group","onlyWithZones","COMMERCE_RETIRED_SECTIONS","settings"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GA4BD,+DAA+D,GAC/D,OAAO,MAAMA,0BAA0B,WAAU;AAEjD;;;;;;;;CAQC,GACD,OAAO,MAAMC,+BAET;IACFC,UAAU;IACVC,UAAU;IACVC,OAAO;IACPC,UAAU;IACVC,eAAe;IACfC,KAAK;IACLC,UAAU;IACVC,cAAc;AAChB,EAAC;AAED,+CAA+C,GAC/C,MAAMC,WAAWV;AAEjB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMW,4BAA0D;IACrE;QAAEC,IAAI;QAAWC,OAAO;IAAU;IAClC;QAAED,IAAI;QAAUC,OAAO;IAAS;IAChC;QAAED,IAAI;QAAWC,OAAO;IAAU;IAClC;QAAED,IAAI;QAAcC,OAAO;IAAa;IACxC;QAAED,IAAI;QAAgBC,OAAO;IAAe;IAC5C;QAAED,IAAI;QAAaC,OAAO;IAAY;IACtC;QAAED,IAAI;QAAYC,OAAO;QAAYC,OAAOJ;IAAS;IACrD;QAAEE,IAAI;QAAYC,OAAO;QAAYC,OAAOJ;IAAS;IACrD;QAAEE,IAAI;QAASC,OAAO;QAASC,OAAOJ;IAAS;IAC/C;QAAEE,IAAI;QAAYC,OAAO;QAAuBC,OAAOJ;IAAS;IAChE;QAAEE,IAAI;QAAiBC,OAAO;QAAiBC,OAAOJ;IAAS;IAC/D;QAAEE,IAAI;QAAOC,OAAO;QAAiBC,OAAOJ;IAAS;IACrD,0EAA0E;IAC1E,uDAAuD;IACvD;QACEE,IAAI;QACJC,OAAO;QACPC,OAAOJ;QACPK,eAAe;YAACd,6BAA6BO,QAAQ;SAAC;IACxD;IACA;QACEI,IAAI;QACJC,OAAO;QACPC,OAAOJ;QACPK,eAAe;YAACd,6BAA6BQ,YAAY;SAAC;IAC5D;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,MAAMO,4BAA8D;IACzEC,UAAU;AACZ,EAEA;;;;;CAKC,IAPA"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/commerce-console-sections.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleNavSection } from '@aglyn/aglyn'\n\nexport type CommerceConsoleSectionId =\n | 'catalog'\n | 'orders'\n | 'subscriptions'\n | 'returns'\n | 'promotions'\n | 'reservations'\n | 'analytics'\n | CommerceSettingsSectionId\n\n/**\n * The store's settings, one page each (AGL-3713). They were one section,\n * `settings`, and one long column: payments, taxes, shipping, the register\n * and every other plugin's cards, one after another.\n */\nexport type CommerceSettingsSectionId =\n | 'payments'\n | 'checkout'\n | 'taxes'\n | 'shipping'\n | 'notifications'\n | 'pos'\n | 'channels'\n | 'integrations'\n\n/** The words above the settings pages in the rail (AGL-3713). */\nexport const COMMERCE_SETTINGS_GROUP = 'Settings'\n\n/**\n * The zone each settings page draws at its foot, keyed by page (AGL-3713).\n *\n * One zone per page, so a plugin chooses its page by the zone it names and\n * nothing else: a contributor restates the id, never imports this package.\n * `commerceSettings` — the zone every store-settings widget named before the\n * split — is the Integrations page's, so a widget that names no page lands\n * there rather than nowhere.\n */\nexport const COMMERCE_SETTINGS_PAGE_ZONES: Readonly<\n Record<CommerceSettingsSectionId, string>\n> = {\n payments: 'commerceSettingsPayments',\n checkout: 'commerceSettingsCheckout',\n taxes: 'commerceSettingsTaxes',\n shipping: 'commerceSettingsShipping',\n notifications: 'commerceSettingsNotifications',\n pos: 'commerceSettingsPos',\n channels: 'commerceSettingsChannels',\n integrations: 'commerceSettings',\n}\n\n/** Under the \"Settings\" subheader (AGL-3713). */\nconst SETTINGS = COMMERCE_SETTINGS_GROUP\n\n/**\n * The commerce console's sections, in rail order (AGL-2501).\n *\n * One list, read twice and never copied: `plugin.ts` registers it on the nav\n * item so the shell can route and gate each section, and the page switches its\n * body on the id the shell resolves back. A second copy is how a section comes\n * to be routable under one id and drawn under another.\n *\n * Ids appear in links people keep — treat them as persisted, and rename a\n * LABEL rather than an id. An id that has to go is mapped in\n * {@link COMMERCE_RETIRED_SECTIONS} to the section that replaced it.\n *\n * No `navTabId` on any of them: every section here ships with the surface, so\n * they inherit the Products nav item's gate. A section that ships later\n * declares its own, which ANDs with the parent's rather than replacing it.\n *\n * The store's own work first, then its settings under a divider and a\n * \"Settings\" subheader (AGL-3713).\n */\nexport const COMMERCE_CONSOLE_SECTIONS: readonly ConsoleNavSection[] = [\n { id: 'catalog', label: 'Catalog' },\n { id: 'orders', label: 'Orders' },\n // Every subscription and its recurring revenue (AGL-4191).\n { id: 'subscriptions', label: 'Subscriptions' },\n { id: 'returns', label: 'Returns' },\n { id: 'promotions', label: 'Promotions' },\n { id: 'reservations', label: 'Reservations' },\n { id: 'analytics', label: 'Analytics' },\n { id: 'payments', label: 'Payments', group: SETTINGS },\n { id: 'checkout', label: 'Checkout', group: SETTINGS },\n { id: 'taxes', label: 'Taxes', group: SETTINGS },\n { id: 'shipping', label: 'Shipping & delivery', group: SETTINGS },\n { id: 'notifications', label: 'Notifications', group: SETTINGS },\n { id: 'pos', label: 'Point of sale', group: SETTINGS },\n // Nothing but other plugins' cards, so each is left out of the rail while\n // none of them has anything to draw (`onlyWithZones`).\n {\n id: 'channels',\n label: 'Sales channels',\n group: SETTINGS,\n onlyWithZones: [COMMERCE_SETTINGS_PAGE_ZONES.channels],\n },\n {\n id: 'integrations',\n label: 'Integrations',\n group: SETTINGS,\n onlyWithZones: [COMMERCE_SETTINGS_PAGE_ZONES.integrations],\n },\n]\n\n/**\n * Section ids the console no longer has, and where each one's links go\n * (AGL-3713). `/products/settings` was every setting on one page; it opens\n * Payments, the first of the pages it was split into.\n */\nexport const COMMERCE_RETIRED_SECTIONS: Readonly<Record<string, string>> = {\n settings: 'payments',\n}\n\n/*\n * Rail ORDER decides where `/products` lands: the shell redirects a bare hub\n * URL to the first section in this list the reader may open (AGL-2501). There\n * is deliberately no separate default constant — a second place to say which\n * section is first is a second place for it to disagree with the rail.\n */\n"],"names":["COMMERCE_SETTINGS_GROUP","COMMERCE_SETTINGS_PAGE_ZONES","payments","checkout","taxes","shipping","notifications","pos","channels","integrations","SETTINGS","COMMERCE_CONSOLE_SECTIONS","id","label","group","onlyWithZones","COMMERCE_RETIRED_SECTIONS","settings"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GA6BD,+DAA+D,GAC/D,OAAO,MAAMA,0BAA0B,WAAU;AAEjD;;;;;;;;CAQC,GACD,OAAO,MAAMC,+BAET;IACFC,UAAU;IACVC,UAAU;IACVC,OAAO;IACPC,UAAU;IACVC,eAAe;IACfC,KAAK;IACLC,UAAU;IACVC,cAAc;AAChB,EAAC;AAED,+CAA+C,GAC/C,MAAMC,WAAWV;AAEjB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMW,4BAA0D;IACrE;QAAEC,IAAI;QAAWC,OAAO;IAAU;IAClC;QAAED,IAAI;QAAUC,OAAO;IAAS;IAChC,2DAA2D;IAC3D;QAAED,IAAI;QAAiBC,OAAO;IAAgB;IAC9C;QAAED,IAAI;QAAWC,OAAO;IAAU;IAClC;QAAED,IAAI;QAAcC,OAAO;IAAa;IACxC;QAAED,IAAI;QAAgBC,OAAO;IAAe;IAC5C;QAAED,IAAI;QAAaC,OAAO;IAAY;IACtC;QAAED,IAAI;QAAYC,OAAO;QAAYC,OAAOJ;IAAS;IACrD;QAAEE,IAAI;QAAYC,OAAO;QAAYC,OAAOJ;IAAS;IACrD;QAAEE,IAAI;QAASC,OAAO;QAASC,OAAOJ;IAAS;IAC/C;QAAEE,IAAI;QAAYC,OAAO;QAAuBC,OAAOJ;IAAS;IAChE;QAAEE,IAAI;QAAiBC,OAAO;QAAiBC,OAAOJ;IAAS;IAC/D;QAAEE,IAAI;QAAOC,OAAO;QAAiBC,OAAOJ;IAAS;IACrD,0EAA0E;IAC1E,uDAAuD;IACvD;QACEE,IAAI;QACJC,OAAO;QACPC,OAAOJ;QACPK,eAAe;YAACd,6BAA6BO,QAAQ;SAAC;IACxD;IACA;QACEI,IAAI;QACJC,OAAO;QACPC,OAAOJ;QACPK,eAAe;YAACd,6BAA6BQ,YAAY;SAAC;IAC5D;CACD,CAAA;AAED;;;;CAIC,GACD,OAAO,MAAMO,4BAA8D;IACzEC,UAAU;AACZ,EAEA;;;;;CAKC,IAPA"}
@@ -48,6 +48,7 @@ export declare function usePaidMediaAttach(product: {
48
48
  mediaId: string;
49
49
  }, options: {
50
50
  adding: boolean;
51
+ fileName?: string;
51
52
  }) => Promise<boolean>;
52
53
  };
53
54
  /**
@@ -24,7 +24,7 @@ import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
24
24
  import { Button, Chip, Stack, Tooltip, Typography } from "@mui/material";
25
25
  import { doc, getDoc } from "firebase/firestore";
26
26
  import { useCallback, useEffect, useState } from "react";
27
- import { PAID_MEDIA_COPY, paidMediaConfirmation, paidMediaScopeBody, usesBesideProduct } from "../../model/paid-media.js";
27
+ import { PAID_MEDIA_COPY, paidMediaCheckingNotice, paidMediaConfirmation, paidMediaScopeBody, paidMediaTitle, usesBesideProduct } from "../../model/paid-media.js";
28
28
  /**
29
29
  * A product's members videos (AGL-2814) and paid downloads (AGL-2847) are
30
30
  * private files.
@@ -51,11 +51,18 @@ import { PAID_MEDIA_COPY, paidMediaConfirmation, paidMediaScopeBody, usesBesideP
51
51
  const copy = PAID_MEDIA_COPY[kind];
52
52
  const { data: user } = useUser();
53
53
  const { confirm } = useConfirmationContext();
54
- const { enqueueSnackbar } = useSnackbar();
54
+ const { enqueueSnackbar, closeSnackbar } = useSnackbar();
55
55
  const protect = useCallback(async (asset, options)=>{
56
56
  const scopeBody = paidMediaScopeBody(asset.scope);
57
57
  let others = [];
58
58
  let checked = 'failed';
59
+ // The where-used scan can take seconds (AGL-4189). Without a word on
60
+ // screen the pick looks like it did nothing, and the question then
61
+ // opens over whatever the author did next.
62
+ const checking = enqueueSnackbar(paidMediaCheckingNotice(options.fileName), {
63
+ variant: 'info',
64
+ persist: true
65
+ });
59
66
  try {
60
67
  const response = await authorizedFetch(user, '/api/media/references', {
61
68
  method: 'POST',
@@ -77,9 +84,11 @@ import { PAID_MEDIA_COPY, paidMediaConfirmation, paidMediaScopeBody, usesBesideP
77
84
  } catch (unused) {
78
85
  // Said in the confirmation instead: "we could not check" is not
79
86
  // "nothing uses it".
87
+ } finally{
88
+ closeSnackbar == null ? void 0 : closeSnackbar(checking);
80
89
  }
81
90
  const confirmed = await confirm({
82
- title: copy.title,
91
+ title: paidMediaTitle(kind, options.fileName),
83
92
  description: paidMediaConfirmation({
84
93
  others,
85
94
  checked,
@@ -117,6 +126,7 @@ import { PAID_MEDIA_COPY, paidMediaConfirmation, paidMediaScopeBody, usesBesideP
117
126
  }
118
127
  return true;
119
128
  }, [
129
+ closeSnackbar,
120
130
  confirm,
121
131
  copy,
122
132
  enqueueSnackbar,
@@ -139,7 +149,8 @@ import { PAID_MEDIA_COPY, paidMediaConfirmation, paidMediaScopeBody, usesBesideP
139
149
  scope: picked.mediaScope,
140
150
  mediaId: picked.mediaId
141
151
  }, {
142
- adding: true
152
+ adding: true,
153
+ fileName: picked.fileName
143
154
  });
144
155
  return madePrivate ? reference : null;
145
156
  }, [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/paid-media.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport {\n formatMediaRef,\n paidMediaAssetOf,\n parsePaidMediaSource,\n type PickedMedia,\n useMediaPicker,\n} from '@aglyn/aglyn'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { Button, Chip, Stack, Tooltip, Typography } from '@mui/material'\nimport { doc, getDoc } from 'firebase/firestore'\nimport { useCallback, useEffect, useState } from 'react'\nimport {\n PAID_MEDIA_COPY,\n paidMediaConfirmation,\n paidMediaScopeBody,\n usesBesideProduct,\n type PaidMediaKind,\n type PaidMediaReference,\n type PaidMediaUsageCheck,\n} from '../../model/paid-media'\n\n/**\n * A product's members videos (AGL-2814) and paid downloads (AGL-2847) are\n * private files.\n *\n * The stream and download routes only ever hand a buyer a link that expires,\n * and they can only do that for a PRIVATE asset: a public one already has a\n * URL that works for anyone, forever, and the routes refuse to deliver it. So\n * adding a file to a product makes it private, and the product editor shows,\n * per file, whether that is still true.\n *\n * Making a file private is visible outside the product. A trailer that is\n * also on a public page stops playing there, and every public link to it that\n * was already shared dies. The author is told which places use it before\n * confirming, from the same where-used scan the media library runs before a\n * delete.\n */\n\nexport {\n paidMediaConfirmation,\n paidMediaScopeBody,\n usesBesideProduct,\n type PaidMediaKind,\n type PaidMediaReference,\n type PaidMediaUsageCheck,\n} from '../../model/paid-media'\n/**\n * Adds a picked file to a product as paid media, making it private first when\n * it is not, and makes an already-added one private.\n */\nexport function usePaidMediaAttach(product: {\n hostId: string\n productId?: string\n kind?: PaidMediaKind\n}) {\n const { hostId, productId } = product\n const kind = product.kind ?? 'video'\n const copy = PAID_MEDIA_COPY[kind]\n const { data: user } = useUser()\n const { confirm } = useConfirmationContext()\n const { enqueueSnackbar } = useSnackbar()\n\n const protect = useCallback(\n async (\n asset: { scope: string; mediaId: string },\n options: { adding: boolean },\n ): Promise<boolean> => {\n const scopeBody = paidMediaScopeBody(asset.scope)\n let others: PaidMediaReference[] = []\n let checked: PaidMediaUsageCheck = 'failed'\n try {\n const response = await authorizedFetch(user, '/api/media/references', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ ...scopeBody, mediaId: asset.mediaId }),\n })\n if (response.ok) {\n const payload = await response.json()\n others = usesBesideProduct(\n Array.isArray(payload?.references) ? payload.references : [],\n { hostId, productId },\n )\n checked = payload?.complete ? 'full' : 'partial'\n }\n } catch {\n // Said in the confirmation instead: \"we could not check\" is not\n // \"nothing uses it\".\n }\n const confirmed = await confirm({\n title: copy.title,\n description: paidMediaConfirmation({ others, checked, kind }),\n confirmationText: 'Make private',\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return false\n const response = await authorizedFetch(user, '/api/media/folders', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n ...scopeBody,\n action: 'set-private',\n mediaId: asset.mediaId,\n private: true,\n }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n const reason = String(payload?.error ?? 'Could not make the video private')\n enqueueSnackbar(\n `${reason}. ${options.adding ? copy.notAdded : copy.unusable}`,\n { variant: 'error', allowDuplicate: true },\n )\n return false\n }\n if (payload?.rawUrlCleared === false) {\n enqueueSnackbar(\n 'The video is private, but an old public download link to it could ' +\n 'not be confirmed dead. Make it private again from the media ' +\n 'library to retry.',\n { variant: 'warning', persist: false },\n )\n }\n return true\n },\n [confirm, copy, enqueueSnackbar, hostId, kind, productId, user],\n )\n\n /** The value to store on the product, or null when nothing was added. */\n const attach = useCallback(\n async (picked: PickedMedia): Promise<string | null> => {\n const reference =\n picked.mediaScope && picked.mediaId\n ? formatMediaRef(picked.mediaScope, picked.mediaId)\n : undefined\n if (!reference || !picked.mediaScope || !picked.mediaId) {\n enqueueSnackbar(copy.choose, { variant: 'warning', persist: false })\n return null\n }\n if (picked.private) return reference\n const madePrivate = await protect(\n { scope: picked.mediaScope, mediaId: picked.mediaId },\n { adding: true },\n )\n return madePrivate ? reference : null\n },\n [copy, enqueueSnackbar, protect],\n )\n\n return { attach, protect }\n}\n\ntype Protection = 'checking' | 'private' | 'public' | 'missing' | 'unknown'\n\n/**\n * Whether one stored paid file can be delivered, read off its media document.\n * A public one gets the button that fixes it.\n */\nexport function PaidMediaProtection(props: {\n url: string\n hostId: string\n productId?: string\n kind?: PaidMediaKind\n}) {\n const { url, hostId, productId, kind } = props\n const firestore = useFirestore()\n const { protect } = usePaidMediaAttach({ hostId, productId, kind })\n const [protection, setProtection] = useState<Protection>('checking')\n const [generation, setGeneration] = useState(0)\n const source = parsePaidMediaSource(url)\n const asset = paidMediaAssetOf(url)\n\n useEffect(() => {\n const target = paidMediaAssetOf(url)\n if (!target) return\n let active = true\n setProtection('checking')\n const reference = target.scope.startsWith('org:')\n ? doc(\n firestore,\n 'orgs',\n target.scope.slice('org:'.length).split(':')[0],\n 'media',\n target.mediaId,\n )\n : doc(firestore, 'hosts', target.scope, 'media', target.mediaId)\n getDoc(reference)\n .then((snapshot) => {\n if (!active) return\n if (!snapshot.exists() || snapshot.get('deletedAt')) {\n setProtection('missing')\n } else {\n setProtection(snapshot.get('private') === true ? 'private' : 'public')\n }\n })\n .catch(() => {\n if (active) setProtection('unknown')\n })\n return () => {\n active = false\n }\n }, [firestore, url, generation])\n\n if (source.kind === 'external') {\n return (\n <Tooltip title=\"Served by another site, so its links cannot be made to expire.\">\n <Chip size=\"small\" label=\"Hosted elsewhere\" />\n </Tooltip>\n )\n }\n if (source.kind === 'malformed') {\n return <Chip size=\"small\" color=\"error\" label=\"Cannot be played\" />\n }\n if (!asset) return null\n if (protection === 'private') {\n return (\n <Tooltip title=\"Buyers get a link that expires.\">\n <Chip size=\"small\" color=\"success\" label=\"Private\" />\n </Tooltip>\n )\n }\n if (protection === 'public') {\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Tooltip title=\"Anyone with its link can open a public file, so buyers cannot get it until it is private.\">\n <Chip size=\"small\" color=\"warning\" label=\"Public\" />\n </Tooltip>\n <Button\n size=\"small\"\n onClick={() =>\n void protect(asset, { adding: false }).then((madePrivate) => {\n if (madePrivate) setGeneration((value) => value + 1)\n })\n }\n >\n {'Make private'}\n </Button>\n </Stack>\n )\n }\n if (protection === 'missing') {\n return <Chip size=\"small\" color=\"error\" label=\"Not in the media library\" />\n }\n return null\n}\n\n/** One entry of a product's members video list. */\nexport interface MembersVideo {\n url: string\n title?: string\n}\n\n/**\n * A product's members videos: each with whether it can play, and the button\n * that adds one.\n *\n * Its own component so the product editor's body stays free while the editor\n * is closed: the editor is rendered on every visit to the catalog, and this\n * only mounts inside the open dialog.\n */\nexport function MembersVideosField(props: {\n hostId: string\n productId?: string\n videos: readonly MembersVideo[]\n onChange: (videos: MembersVideo[]) => void\n}) {\n const { hostId, productId, videos, onChange } = props\n const { pickMedia } = useMediaPicker()\n const { attach } = usePaidMediaAttach({ hostId, productId })\n return (\n <>\n {videos.map((video, index) => (\n <Stack key={index} direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {`🎬 ${video.title || video.url}`}\n </Typography>\n <PaidMediaProtection url={video.url} hostId={hostId} productId={productId} />\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() =>\n onChange(videos.filter((_item, itemIndex) => itemIndex !== index))\n }\n >\n {'✕'}\n </Button>\n </Stack>\n ))}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n void (async () => {\n // A private file is the only kind a members video can be, so the\n // picker offers private files here and nowhere else. And a film is\n // the only kind of file it can play, so the picker lists and\n // uploads nothing else (AGL-2953).\n const media = await pickMedia?.({\n allowPrivate: true,\n kind: 'video',\n })\n if (!media) return\n const url = await attach(media)\n if (!url) return\n onChange([...videos, { url, title: media.fileName ?? '' }])\n })()\n }\n >\n {'Add members video'}\n </Button>\n </>\n )\n}\n\n/**\n * The button that adds a paid download (AGL-2847): the picker offers private\n * files, and a public one is made private before it is added.\n *\n * Its own component for the same reason as {@link MembersVideosField}: the\n * product editor's body runs while the editor is closed, and this only mounts\n * inside the open dialog.\n */\nexport function PaidDownloadAddButton(props: {\n hostId: string\n productId?: string\n onAdd: (file: { url: string; fileName: string }) => void\n}) {\n const { hostId, productId, onAdd } = props\n const { pickMedia } = useMediaPicker()\n const { attach } = usePaidMediaAttach({ hostId, productId, kind: 'download' })\n return (\n <Button\n size=\"small\"\n onClick={() =>\n void (async () => {\n const media = await pickMedia?.({ allowPrivate: true })\n if (!media) return\n const url = await attach(media)\n if (!url) return\n onAdd({ url, fileName: media.fileName ?? 'download' })\n })()\n }\n >\n {'Add file (media library)'}\n </Button>\n )\n}\n"],"names":["formatMediaRef","paidMediaAssetOf","parsePaidMediaSource","useMediaPicker","useConfirmationContext","useSnackbar","authorizedFetch","useFirestore","useUser","Button","Chip","Stack","Tooltip","Typography","doc","getDoc","useCallback","useEffect","useState","PAID_MEDIA_COPY","paidMediaConfirmation","paidMediaScopeBody","usesBesideProduct","usePaidMediaAttach","product","hostId","productId","kind","copy","data","user","confirm","enqueueSnackbar","protect","asset","options","scopeBody","scope","others","checked","response","method","headers","body","JSON","stringify","mediaId","ok","payload","json","Array","isArray","references","complete","confirmed","title","description","confirmationText","then","catch","action","private","reason","String","error","adding","notAdded","unusable","variant","allowDuplicate","rawUrlCleared","persist","attach","picked","reference","mediaScope","undefined","choose","madePrivate","PaidMediaProtection","props","url","firestore","protection","setProtection","generation","setGeneration","source","target","active","startsWith","slice","length","split","snapshot","exists","get","size","label","color","direction","spacing","sx","alignItems","onClick","value","MembersVideosField","videos","onChange","pickMedia","map","video","index","flex","noWrap","filter","_item","itemIndex","alignSelf","media","allowPrivate","fileName","PaidDownloadAddButton","onAdd"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SACEA,cAAc,EACdC,gBAAgB,EAChBC,oBAAoB,EAEpBC,cAAc,QACT,eAAc;AACrB,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,OAAO,QAA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AAdF,kBAAkB;4BAAG;yBAAE;oBAC5D,CAAA;0BAGD;;;;AAIT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASG,sBAAsB1C,KAIrC;IACC,MAAM,EAAEvD,MAAM,EAAEC,SAAS,EAAEiG,KAAK,EAAE,GAAG3C;IACrC,MAAM,EAAE6B,SAAS,EAAE,GAAG1G;IACtB,MAAM,EAAEqE,MAAM,EAAE,GAAGjD,mBAAmB;QAAEE;QAAQC;QAAWC,MAAM;IAAW;IAC5E,qBACE,KAAClB;QACCwF,MAAK;QACLO,SAAS,IACP,KAAK,AAAC,CAAA;oBAKmBe;gBAJvB,MAAMA,QAAQ,OAAMV,6BAAAA,UAAY;oBAAEW,cAAc;gBAAK;gBACrD,IAAI,CAACD,OAAO;gBACZ,MAAMtC,MAAM,MAAMT,OAAO+C;gBACzB,IAAI,CAACtC,KAAK;gBACV0C,MAAM;oBAAE1C;oBAAKwC,QAAQ,GAAEF,kBAAAA,MAAME,QAAQ,YAAdF,kBAAkB;gBAAW;YACtD,CAAA;kBAGD;;AAGP"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/paid-media.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport {\n formatMediaRef,\n paidMediaAssetOf,\n parsePaidMediaSource,\n type PickedMedia,\n useMediaPicker,\n} from '@aglyn/aglyn'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { Button, Chip, Stack, Tooltip, Typography } from '@mui/material'\nimport { doc, getDoc } from 'firebase/firestore'\nimport { useCallback, useEffect, useState } from 'react'\nimport {\n PAID_MEDIA_COPY,\n paidMediaCheckingNotice,\n paidMediaConfirmation,\n paidMediaScopeBody,\n paidMediaTitle,\n usesBesideProduct,\n type PaidMediaKind,\n type PaidMediaReference,\n type PaidMediaUsageCheck,\n} from '../../model/paid-media'\n\n/**\n * A product's members videos (AGL-2814) and paid downloads (AGL-2847) are\n * private files.\n *\n * The stream and download routes only ever hand a buyer a link that expires,\n * and they can only do that for a PRIVATE asset: a public one already has a\n * URL that works for anyone, forever, and the routes refuse to deliver it. So\n * adding a file to a product makes it private, and the product editor shows,\n * per file, whether that is still true.\n *\n * Making a file private is visible outside the product. A trailer that is\n * also on a public page stops playing there, and every public link to it that\n * was already shared dies. The author is told which places use it before\n * confirming, from the same where-used scan the media library runs before a\n * delete.\n */\n\nexport {\n paidMediaConfirmation,\n paidMediaScopeBody,\n usesBesideProduct,\n type PaidMediaKind,\n type PaidMediaReference,\n type PaidMediaUsageCheck,\n} from '../../model/paid-media'\n/**\n * Adds a picked file to a product as paid media, making it private first when\n * it is not, and makes an already-added one private.\n */\nexport function usePaidMediaAttach(product: {\n hostId: string\n productId?: string\n kind?: PaidMediaKind\n}) {\n const { hostId, productId } = product\n const kind = product.kind ?? 'video'\n const copy = PAID_MEDIA_COPY[kind]\n const { data: user } = useUser()\n const { confirm } = useConfirmationContext()\n const { enqueueSnackbar, closeSnackbar } = useSnackbar()\n\n const protect = useCallback(\n async (\n asset: { scope: string; mediaId: string },\n options: { adding: boolean; fileName?: string },\n ): Promise<boolean> => {\n const scopeBody = paidMediaScopeBody(asset.scope)\n let others: PaidMediaReference[] = []\n let checked: PaidMediaUsageCheck = 'failed'\n // The where-used scan can take seconds (AGL-4189). Without a word on\n // screen the pick looks like it did nothing, and the question then\n // opens over whatever the author did next.\n const checking = enqueueSnackbar(paidMediaCheckingNotice(options.fileName), {\n variant: 'info',\n persist: true,\n })\n try {\n const response = await authorizedFetch(user, '/api/media/references', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ ...scopeBody, mediaId: asset.mediaId }),\n })\n if (response.ok) {\n const payload = await response.json()\n others = usesBesideProduct(\n Array.isArray(payload?.references) ? payload.references : [],\n { hostId, productId },\n )\n checked = payload?.complete ? 'full' : 'partial'\n }\n } catch {\n // Said in the confirmation instead: \"we could not check\" is not\n // \"nothing uses it\".\n } finally {\n closeSnackbar?.(checking)\n }\n const confirmed = await confirm({\n title: paidMediaTitle(kind, options.fileName),\n description: paidMediaConfirmation({ others, checked, kind }),\n confirmationText: 'Make private',\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return false\n const response = await authorizedFetch(user, '/api/media/folders', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n ...scopeBody,\n action: 'set-private',\n mediaId: asset.mediaId,\n private: true,\n }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n const reason = String(payload?.error ?? 'Could not make the video private')\n enqueueSnackbar(\n `${reason}. ${options.adding ? copy.notAdded : copy.unusable}`,\n { variant: 'error', allowDuplicate: true },\n )\n return false\n }\n if (payload?.rawUrlCleared === false) {\n enqueueSnackbar(\n 'The video is private, but an old public download link to it could ' +\n 'not be confirmed dead. Make it private again from the media ' +\n 'library to retry.',\n { variant: 'warning', persist: false },\n )\n }\n return true\n },\n [closeSnackbar, confirm, copy, enqueueSnackbar, hostId, kind, productId, user],\n )\n\n /** The value to store on the product, or null when nothing was added. */\n const attach = useCallback(\n async (picked: PickedMedia): Promise<string | null> => {\n const reference =\n picked.mediaScope && picked.mediaId\n ? formatMediaRef(picked.mediaScope, picked.mediaId)\n : undefined\n if (!reference || !picked.mediaScope || !picked.mediaId) {\n enqueueSnackbar(copy.choose, { variant: 'warning', persist: false })\n return null\n }\n if (picked.private) return reference\n const madePrivate = await protect(\n { scope: picked.mediaScope, mediaId: picked.mediaId },\n { adding: true, fileName: picked.fileName },\n )\n return madePrivate ? reference : null\n },\n [copy, enqueueSnackbar, protect],\n )\n\n return { attach, protect }\n}\n\ntype Protection = 'checking' | 'private' | 'public' | 'missing' | 'unknown'\n\n/**\n * Whether one stored paid file can be delivered, read off its media document.\n * A public one gets the button that fixes it.\n */\nexport function PaidMediaProtection(props: {\n url: string\n hostId: string\n productId?: string\n kind?: PaidMediaKind\n}) {\n const { url, hostId, productId, kind } = props\n const firestore = useFirestore()\n const { protect } = usePaidMediaAttach({ hostId, productId, kind })\n const [protection, setProtection] = useState<Protection>('checking')\n const [generation, setGeneration] = useState(0)\n const source = parsePaidMediaSource(url)\n const asset = paidMediaAssetOf(url)\n\n useEffect(() => {\n const target = paidMediaAssetOf(url)\n if (!target) return\n let active = true\n setProtection('checking')\n const reference = target.scope.startsWith('org:')\n ? doc(\n firestore,\n 'orgs',\n target.scope.slice('org:'.length).split(':')[0],\n 'media',\n target.mediaId,\n )\n : doc(firestore, 'hosts', target.scope, 'media', target.mediaId)\n getDoc(reference)\n .then((snapshot) => {\n if (!active) return\n if (!snapshot.exists() || snapshot.get('deletedAt')) {\n setProtection('missing')\n } else {\n setProtection(snapshot.get('private') === true ? 'private' : 'public')\n }\n })\n .catch(() => {\n if (active) setProtection('unknown')\n })\n return () => {\n active = false\n }\n }, [firestore, url, generation])\n\n if (source.kind === 'external') {\n return (\n <Tooltip title=\"Served by another site, so its links cannot be made to expire.\">\n <Chip size=\"small\" label=\"Hosted elsewhere\" />\n </Tooltip>\n )\n }\n if (source.kind === 'malformed') {\n return <Chip size=\"small\" color=\"error\" label=\"Cannot be played\" />\n }\n if (!asset) return null\n if (protection === 'private') {\n return (\n <Tooltip title=\"Buyers get a link that expires.\">\n <Chip size=\"small\" color=\"success\" label=\"Private\" />\n </Tooltip>\n )\n }\n if (protection === 'public') {\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Tooltip title=\"Anyone with its link can open a public file, so buyers cannot get it until it is private.\">\n <Chip size=\"small\" color=\"warning\" label=\"Public\" />\n </Tooltip>\n <Button\n size=\"small\"\n onClick={() =>\n void protect(asset, { adding: false }).then((madePrivate) => {\n if (madePrivate) setGeneration((value) => value + 1)\n })\n }\n >\n {'Make private'}\n </Button>\n </Stack>\n )\n }\n if (protection === 'missing') {\n return <Chip size=\"small\" color=\"error\" label=\"Not in the media library\" />\n }\n return null\n}\n\n/** One entry of a product's members video list. */\nexport interface MembersVideo {\n url: string\n title?: string\n}\n\n/**\n * A product's members videos: each with whether it can play, and the button\n * that adds one.\n *\n * Its own component so the product editor's body stays free while the editor\n * is closed: the editor is rendered on every visit to the catalog, and this\n * only mounts inside the open dialog.\n */\nexport function MembersVideosField(props: {\n hostId: string\n productId?: string\n videos: readonly MembersVideo[]\n onChange: (videos: MembersVideo[]) => void\n}) {\n const { hostId, productId, videos, onChange } = props\n const { pickMedia } = useMediaPicker()\n const { attach } = usePaidMediaAttach({ hostId, productId })\n return (\n <>\n {videos.map((video, index) => (\n <Stack key={index} direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {`🎬 ${video.title || video.url}`}\n </Typography>\n <PaidMediaProtection url={video.url} hostId={hostId} productId={productId} />\n <Button\n size=\"small\"\n color=\"error\"\n onClick={() =>\n onChange(videos.filter((_item, itemIndex) => itemIndex !== index))\n }\n >\n {'✕'}\n </Button>\n </Stack>\n ))}\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n onClick={() =>\n void (async () => {\n // A private file is the only kind a members video can be, so the\n // picker offers private files here and nowhere else. And a film is\n // the only kind of file it can play, so the picker lists and\n // uploads nothing else (AGL-2953).\n const media = await pickMedia?.({\n allowPrivate: true,\n kind: 'video',\n })\n if (!media) return\n const url = await attach(media)\n if (!url) return\n onChange([...videos, { url, title: media.fileName ?? '' }])\n })()\n }\n >\n {'Add members video'}\n </Button>\n </>\n )\n}\n\n/**\n * The button that adds a paid download (AGL-2847): the picker offers private\n * files, and a public one is made private before it is added.\n *\n * Its own component for the same reason as {@link MembersVideosField}: the\n * product editor's body runs while the editor is closed, and this only mounts\n * inside the open dialog.\n */\nexport function PaidDownloadAddButton(props: {\n hostId: string\n productId?: string\n onAdd: (file: { url: string; fileName: string }) => void\n}) {\n const { hostId, productId, onAdd } = props\n const { pickMedia } = useMediaPicker()\n const { attach } = usePaidMediaAttach({ hostId, productId, kind: 'download' })\n return (\n <Button\n size=\"small\"\n onClick={() =>\n void (async () => {\n const media = await pickMedia?.({ allowPrivate: true })\n if (!media) return\n const url = await attach(media)\n if (!url) return\n onAdd({ url, fileName: media.fileName ?? 'download' })\n })()\n }\n >\n {'Add file (media library)'}\n </Button>\n )\n}\n"],"names":["formatMediaRef","paidMediaAssetOf","parsePaidMediaSource","useMediaPicker","useConfirmationContext","useSnackbar","authorizedFetch","useFirestore","useUser","Button","Chip","Stack","Tooltip","Typography","doc","getDoc","useCallback","useEffect","useState","PAID_MEDIA_COPY","paidMediaCheckingNotice","paidMediaConfirmation","paidMediaScopeBody","paidMediaTitle","usesBesideProduct","usePaidMediaAttach","product","hostId","productId","kind","copy","data","user","confirm","enqueueSnackbar","closeSnackbar","protect","asset","options","scopeBody","scope","others","checked","checking","fileName","variant","persist","response","method","headers","body","JSON","stringify","mediaId","ok","payload","json","Array","isArray","references","complete","confirmed","title","description","confirmationText","then","catch","action","private","reason","String","error","adding","notAdded","unusable","allowDuplicate","rawUrlCleared","attach","picked","reference","mediaScope","undefined","choose","madePrivate","PaidMediaProtection","props","url","firestore","protection","setProtection","generation","setGeneration","source","target","active","startsWith","slice","length","split","snapshot","exists","get","size","label","color","direction","spacing","sx","alignItems","onClick","value","MembersVideosField","videos","onChange","pickMedia","map","video","index","flex","noWrap","filter","_item","itemIndex","alignSelf","media","allowPrivate","PaidDownloadAddButton","onAdd"],"mappings":"AAAA;;;;;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entitlement-gate.component.js";
247
247
  /*#__PURE__*/ _jsx(Typography, {
248
248
  variant: "body2",
249
249
  color: "text.secondary",
250
- children: 'Card processing is passed through at cost on top of that: ' + `${Aglyn.CARD_PROCESSING_PERCENT}–` + `${Aglyn.BNPL_PROCESSING_PERCENT}% + ` + `${Aglyn.PROCESSING_FIXED_CENTS}¢ per online ` + 'sale, what Stripe charges to take the payment. It is not a ' + `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} margin.`
250
+ children: 'Card processing is passed through at cost on top of that: ' + `${Aglyn.SALE_PROCESSING_PERCENT}% + ${Aglyn.SALE_PROCESSING_FIXED_CENTS}¢ per card sale, ` + 'online or on a card reader, what Stripe charges to take the payment. It is not a ' + `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} margin. Where the platform fee is smaller than ` + `what Stripe charges to pay you out (${Aglyn.CONNECT_PAYOUT_PERCENT}% + ` + `${Aglyn.CONNECT_PAYOUT_FIXED_CENTS}¢ a payout, and ${Aglyn.STRIPE_TAX_PERCENT}% where ` + 'Stripe Tax works out the tax), the fee is that cost instead.'
251
251
  }),
252
252
  physicalPct > 0 || digitalPct > 0 ? /*#__PURE__*/ _jsx(Typography, {
253
253
  variant: "body2",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/payments-settings-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport * as Aglyn from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Alert, Button, Chip, Stack, Typography } from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { useCallback, useState } from 'react'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { useFirestoreDoc } from '@aglyn/tenant-feature-instance'\nimport { useOrgPlan } from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useCommerceEntitlement } from './entitlement-gate.component'\n\nexport interface PaymentsSettingsCardProps {\n hostId: string\n}\n\n/** The element id the Payments card carries, for a link on the same page that lands on it (AGL-3982). */\nexport const PAYMENTS_SETTINGS_ANCHOR = 'store-payments'\n\n/**\n * Merchant payments card (AGL-284): Stripe Connect Express onboarding\n * status for the org owner + the plan's transaction-fee ladder so the\n * \"upgrade to kill fees\" motion (AGL-278) is visible where it matters.\n */\nexport function PaymentsSettingsCard(props: PaymentsSettingsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [busy, setBusy] = useState(false)\n /**\n * A one-time Stripe Express dashboard link, minted by the connect route on\n * request. Not persisted: login links are single-use and short-lived, so a\n * stored one would be a button that fails the second time it is pressed.\n */\n const [dashboardUrl, setDashboardUrl] = useState<string | null>(null)\n const { org, ready: planReady } = useOrgPlan(hostId)\n /** Bumped by Retry to re-subscribe the profile listen (AGL-1380). */\n const [retryNonce, setRetryNonce] = useState(0)\n const { upgradeHref } = useCommerceEntitlement(hostId, 'commerce')\n /**\n * The OWNER's profile: the Stripe account every money route charges\n * against is the one on the workspace owner's profile. Reading the\n * signed-in member's instead told an admin who is not the owner that a\n * connected store was not set up.\n */\n const ownerUid =\n typeof org?.ownerUid === 'string' && org.ownerUid ? org.ownerUid : undefined\n const { data: profile, status: profileStatus } = useFirestoreDoc<any>(\n // Held at null rather than addressed as `profiles/-pending-` — that\n // sentinel issued a guaranteed-denied read on every pre-auth mount, and\n // a denial lands in `status: 'error'`, which now means something.\n () => (ownerUid ? doc(firestore, 'profiles', ownerUid) : null),\n [firestore, ownerUid, retryNonce],\n )\n const isOwner = Boolean(\n org?.ownerUid && (user as any)?.uid === org.ownerUid,\n )\n /**\n * Three outcomes, not two (AGL-1380). An absent profile doc is the value\n * BEFORE an answer as much as it is the value of a merchant who never\n * connected Stripe, so \"Not set up\" off a falsy `stripeChargesEnabled` is a\n * claim about this org's payment setup made without having heard back. It\n * is wrong in the direction that provokes action: the same falsy value\n * turns the button into \"Set up payments\", which sends a merchant who is\n * already taking money into Stripe onboarding.\n */\n const stripeState: 'pending' | 'error' | 'loaded' =\n !planReady || (ownerUid && profileStatus === 'loading')\n ? 'pending'\n : profileStatus === 'error'\n ? 'error'\n : 'loaded'\n /**\n * WHICH STRIPE WORLD THE STORED ACCOUNT BELONGS TO (AGL-2471).\n *\n * `stripeChargesEnabled: true` was the whole readiness claim, and a\n * production profile carrying it named a TEST-mode account: this card said\n * \"Charges enabled\" about three storefronts that could not take a single\n * payment. Only a literal boolean counts as recorded — the same\n * three-valued reading `merchantAccountIsReady` uses on the server, so the\n * chip and the checkout cannot disagree.\n */\n const modeVerified = typeof profile?.stripeAccountLivemode === 'boolean'\n const chargesConnected =\n stripeState === 'loaded' && Boolean(profile?.stripeChargesEnabled)\n const modeUnverified = chargesConnected && !modeVerified\n const chargesEnabled = chargesConnected && modeVerified\n const physicalPct = Aglyn.resolveTransactionFeePct(org, 'physical')\n const digitalPct = Aglyn.resolveTransactionFeePct(org, 'digital')\n const commerceEnabled = Aglyn.checkEntitlement(org, 'commerce')\n\n const handleConnect = useCallback(async () => {\n setBusy(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/connect', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId }),\n })\n const payload = await response.json()\n if (response.status === 501) {\n return void enqueueSnackbar(\n 'Payments are not configured on this deployment',\n { variant: 'info', persist: false },\n )\n }\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Payment setup failed', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n if (payload.chargesEnabled) {\n // \"% who connect Stripe\" — a GTM plan §6 activation metric\n // (AGL-1561). Gated on the TRANSITION, not the state: this handler\n // is a re-entrant create-or-resume, so it answers `chargesEnabled:\n // true` on every subsequent visit to a connected account, and a bare\n // event here would count one merchant once per click forever.\n // `chargesEnabled` is the state read from the profile BEFORE this\n // request, so the event fires only when onboarding actually completed.\n if (!chargesEnabled) trackEvent('stripe_connected', {})\n // CHARGES AND PAYOUTS ARE TWO FLAGS, AND ONLY ONE OF THEM IS THIS\n // SENTENCE (AGL-1997). `chargesEnabled` says Stripe will let the\n // account take money; whether the money can LEAVE is `payoutsEnabled`,\n // which the route answers alongside it. Charges-yes/payouts-no is an\n // ordinary Stripe state — verification pending or lapsed, no payout\n // method — and announcing \"Payments are enabled\" in it is false in the\n // direction that costs the merchant: they sell believing they are\n // paid, and the funds sit in a Connect account that cannot release\n // them. Read three-valued, so only a literal `false` from Stripe\n // downgrades the claim; an absent flag means unasked, not off.\n const payoutsBlocked = payload.payoutsEnabled === false\n // A WARNING THAT NAMES A PROBLEM MUST OFFER THE FIX.\n //\n // Stripe is the only place payouts can be released — an Express\n // account has no password and no direct login — so telling the\n // merchant their funds are stranded and then keeping them here is half\n // an answer. The route now mints the remediation link for exactly this\n // state; going there is the whole point of pressing the button.\n if (payoutsBlocked && payload.url) {\n return void window.location.assign(payload.url)\n }\n // Payouts are flowing, so the link is the Express dashboard: balance,\n // payout schedule, and the reason a payout failed. Held in state\n // rather than followed, because this click was a status check and\n // navigating away from one nobody asked to leave is its own defect.\n if (!payoutsBlocked && typeof payload.dashboardUrl === 'string') {\n setDashboardUrl(payload.dashboardUrl)\n }\n return void enqueueSnackbar(\n payoutsBlocked\n ? 'Connected — payouts are not released yet'\n : 'Payments are enabled',\n {\n variant: payoutsBlocked ? 'warning' : 'success',\n persist: false,\n },\n )\n }\n if (payload.url) window.location.assign(payload.url)\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setBusy(false)\n }\n }, [user, hostId, chargesEnabled, enqueueSnackbar])\n\n return (\n <CardDisplay\n id={PAYMENTS_SETTINGS_ANCHOR}\n header={'Payments'}\n help={pluginDocsHelp('commerceEndToEnd', {\n anchor: '#1-connect-payments',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }}>\n {'Stripe account'}\n </Typography>\n {/*\n No chip at all on error: both labels it could carry — \"Charges\n enabled\" and \"Not set up\" — assert something we failed to find\n out. Whatever Stripe is doing right now it carries on doing.\n */}\n {stripeState === 'error' ? null : (\n <Chip\n size=\"small\"\n label={\n stripeState === 'pending'\n ? 'Checking…'\n : chargesEnabled\n ? 'Charges enabled'\n : modeUnverified\n ? 'Not verified'\n : 'Not set up'\n }\n color={\n stripeState === 'pending'\n ? 'default'\n : chargesEnabled\n ? 'success'\n : modeUnverified\n ? 'error'\n : 'warning'\n }\n variant=\"outlined\"\n />\n )}\n </Stack>\n {stripeState === 'error' ? (\n <Alert\n severity=\"error\"\n action={\n <Button\n color=\"inherit\"\n size=\"small\"\n onClick={() => setRetryNonce((n) => n + 1)}\n >\n {'Retry'}\n </Button>\n }\n >\n {'We couldn’t load your payment setup. This says nothing about ' +\n 'whether payments are on — we could not reach the setting to ' +\n 'find out. Nothing has changed.'}\n </Alert>\n ) : null}\n {/*\n Every line below reads the plan, and an org doc still in flight\n resolves to the FREE tier (AGL-1064) — which would flash \"Selling\n requires a paid plan\" and the wrong fee percentages at a paying\n seller, then correct itself. Say nothing until it is known.\n */}\n {!planReady ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Checking your plan…'}\n </Typography>\n ) : (\n <>\n {!commerceEnabled ? (\n <PrerequisiteNotice href={upgradeHref} actionLabel=\"See plans\">\n {'Selling needs a paid plan. Choose one on Billing, then connect Stripe here.'}\n </PrerequisiteNotice>\n ) : null}\n {/*\n THE LEGAL NAME, not the org's resolved `productName`\n (AGL-2351). This sentence says who takes money off the\n merchant's own Stripe account, and the application fee lands in\n the platform Stripe account — held by the operating entity, not\n by a white-label agency reselling the console. Naming the\n agency here would assert a fee relationship that does not\n exist. `PLATFORM_BRAND_LEGAL_NAME` still configures cleanly for\n a self-host operator, who really is the entity collecting it.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Buyers pay on your own Stripe account; ' +\n `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} collects a platform fee ` +\n 'per sale based on your plan:'}\n </Typography>\n {/* The DIGITAL rate is not products-only (AGL-2315). A paid\n booking is a service sale and resolves through the same\n `'service'`/digital axis, so a bookings-only merchant pays this\n exact number — and this card was the one place they could read\n their own rate while naming only \"products\". Stated here rather\n than adding a third figure: it is one rate, not two. */}\n <Typography variant=\"body2\">\n {`Physical products: ${physicalPct}% · Digital products, ` +\n `services & bookings: ${digitalPct}%`}\n {physicalPct > 0 || digitalPct > 0 ? (\n <Typography\n component=\"span\"\n variant=\"caption\"\n color=\"text.secondary\"\n >\n {' — higher plans reduce fees to 0%'}\n </Typography>\n ) : null}\n </Typography>\n {/* CARD PROCESSING, PASSED THROUGH AT COST (AGL-2152).\n\n Unconditional, including on the 0% plans, because it is\n exactly those plans where the merchant would otherwise read\n \"0%\" and be surprised by a deduction. Their PLATFORM fee\n really is zero — the figure below is Stripe's own charge for\n taking the payment, which every storefront sale incurs and\n which used to be absorbed silently out of the platform's\n balance rather than passed through.\n\n Named as a range rather than one number because the buyer\n chooses the payment method after the session is created:\n cards settle at the low end, buy-now-pay-later at the high\n end, and the deduction is sized for the dearest so a sale can\n never cost more to process than it collects. */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Card processing is passed through at cost on top of that: ' +\n `${Aglyn.CARD_PROCESSING_PERCENT}–` +\n `${Aglyn.BNPL_PROCESSING_PERCENT}% + ` +\n `${Aglyn.PROCESSING_FIXED_CENTS}¢ per online ` +\n 'sale, what Stripe charges to take the payment. It is not a ' +\n `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} margin.`}\n </Typography>\n {/* WHICH REGISTER TENDERS CARRY THE FEE, AND HOW EACH IS\n COLLECTED (AGL-2111, AGL-4036).\n\n Card and room-charge payments at the register carry the fee;\n cash, gift cards and store credit carry none\n (`CommerceModel.paymentCarriesPlatformFee`). A room charge's\n fee leaves by a door the merchant has never seen money leave\n by, their monthly invoice, so it is said here BEFORE it\n appears there.\n\n Shown only when a rate actually applies: on a 0% plan there is\n nothing to collect either way, and the paragraph would be noise\n on the card of the merchants who upgraded to escape fees. */}\n {physicalPct > 0 || digitalPct > 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'At the register, cash, gift card and store credit payments ' +\n 'carry no fee. On card payments it is deducted from your ' +\n 'Stripe payout; on room-charge payments there is no payout to ' +\n 'deduct from, so it is added to your monthly ' +\n `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} invoice instead.`}\n </Typography>\n ) : null}\n </>\n )}\n {/*\n AGL-2471: connected, and refused by every money door because the\n account was never verified against this deployment's Stripe mode.\n \"Not set up\" would be a lie in the other direction — the merchant\n did set something up — so the card names what is actually wrong and\n what to do about it.\n */}\n {modeUnverified ? (\n <Alert severity=\"error\">\n {'Your Stripe account has not been verified for payments on ' +\n 'this site, so sales will be refused. Set up payments again ' +\n 'to verify it — if it was connected against Stripe test mode, ' +\n 'you will need to connect a live account.'}\n </Alert>\n ) : null}\n {/*\n The button's own label is a claim — \"Set up payments\" tells the\n owner they have none. Withheld until the answer is in, for the same\n reason as the chip (AGL-1380); on error the Retry above is the only\n action offered, because acting on a setup we could not read is how\n a connected merchant gets sent back through onboarding.\n */}\n {/*\n WHERE THE MONEY STOPPED. Mirrored onto this profile by the\n `payout.failed` handler and retired by the next successful payout, so\n it names a live problem rather than a scar. Without it a merchant sold\n into an account that could not release the funds and the card said\n \"Payments are enabled\" the whole time — the storefront looked healthy\n from every angle available to them.\n */}\n {stripeState === 'loaded' && profile?.lastPayoutFailureAtMs ? (\n <Alert severity=\"warning\" variant=\"outlined\">\n {`A payout of $${(\n Number(profile.lastPayoutFailureCents ?? 0) / 100\n ).toFixed(2)} did not reach your bank on ${new Date(\n Number(profile.lastPayoutFailureAtMs),\n ).toLocaleDateString()} — ${String(\n profile.lastPayoutFailureReason ?? 'Stripe did not say why',\n )} The money is still in your Stripe account. Open Stripe to fix your payout details.`}\n </Alert>\n ) : null}\n {!planReady || stripeState !== 'loaded' ? null : isOwner ? (\n <>\n <Button\n size=\"small\"\n variant={chargesEnabled ? 'text' : 'contained'}\n color=\"primary\"\n disabled={busy}\n onClick={handleConnect}\n sx={{ alignSelf: 'flex-start' }}\n >\n {chargesEnabled\n ? 'Refresh status'\n : busy\n ? 'Opening Stripe…'\n : 'Set up payments'}\n </Button>\n {/*\n Where the money actually is. Aglyn records none of it —\n no balance, no payout schedule, and no `payout.failed` handling\n anywhere — so a merchant whose payout bounced has no way to learn\n that from this console. An Express account has no direct login\n either, which leaves a link minted by the platform as the only\n route in. `target=\"_blank\"` because it leaves the app entirely.\n */}\n {dashboardUrl ? (\n <Button\n size=\"small\"\n variant=\"text\"\n color=\"primary\"\n href={dashboardUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n sx={{ alignSelf: 'flex-start' }}\n >\n {'View payouts in Stripe'}\n </Button>\n ) : null}\n </>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Only the organization owner can set up payments.'}\n </Typography>\n )}\n </Stack>\n </CardDisplay>\n )\n}\nPaymentsSettingsCard.displayName = 'PaymentsSettingsCard'\n\nexport default PaymentsSettingsCard\n"],"names":["trackEvent","Aglyn","CardDisplay","useSnackbar","Alert","Button","Chip","Stack","Typography","doc","useCallback","useState","useFirestore","useUser","useFirestoreDoc","useOrgPlan","pluginDocsHelp","authorizedFetch","PrerequisiteNotice","useCommerceEntitlement","PAYMENTS_SETTINGS_ANCHOR","PaymentsSettingsCard","props","profile","hostId","firestore","data","user","enqueueSnackbar","busy","setBusy","dashboardUrl","setDashboardUrl","org","ready","planReady","retryNonce","setRetryNonce","upgradeHref","ownerUid","undefined","status","profileStatus","isOwner","Boolean","uid","stripeState","modeVerified","stripeAccountLivemode","chargesConnected","stripeChargesEnabled","modeUnverified","chargesEnabled","physicalPct","resolveTransactionFeePct","digitalPct","commerceEnabled","checkEntitlement","handleConnect","response","method","headers","body","JSON","stringify","payload","json","variant","persist","ok","error","allowDuplicate","payoutsBlocked","payoutsEnabled","url","window","location","assign","console","id","header","help","anchor","contentGutterX","contentGutterY","spacing","direction","sx","alignItems","flex","size","label","color","severity","action","onClick","n","href","actionLabel","PLATFORM_BRAND_LEGAL_NAME","component","CARD_PROCESSING_PERCENT","BNPL_PROCESSING_PERCENT","PROCESSING_FIXED_CENTS","lastPayoutFailureAtMs","Number","lastPayoutFailureCents","toFixed","Date","toLocaleDateString","String","lastPayoutFailureReason","disabled","alignSelf","target","rel","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,UAAU,QAAQ,0CAAyC;AACpE,YAAYC,WAAW,eAAc;AACrC,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACtE,SAASC,GAAG,QAAQ,qBAAoB;AACxC,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAO;AAC7C,SAASC,YAAY,EAAEC,OAAO,QAAQ,iCAAgC;AACtE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,UAAU,QAAQ,iCAAgC;AAC3D,SAASC,c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BAEvD;;;gBAUPhD,+BACC,KAAC/C;oBAAMyF,UAAS;8BACb,+DACC,gEACA,kEACA;qBAEF;gBAgBH/C,gBAAgB,aAAYvB,2BAAAA,QAASiF,qBAAqB,kBACzD,KAACpG;oBAAMyF,UAAS;oBAAU1B,SAAQ;8BAC/B,CAAC,aAAa,EAAE,AACfsC,CAAAA,QAAOlF,kCAAAA,QAAQmF,sBAAsB,YAA9BnF,kCAAkC,KAAK,GAAE,EAChDoF,OAAO,CAAC,GAAG,4BAA4B,EAAE,IAAIC,KAC7CH,OAAOlF,QAAQiF,qBAAqB,GACpCK,kBAAkB,GAAG,GAAG,EAAEC,QAC1BvF,mCAAAA,QAAQwF,uBAAuB,YAA/BxF,mCAAmC,0BACnC,mFAAmF,CAAC;qBAEtF;gBACH,CAACY,aAAaW,gBAAgB,WAAW,OAAOH,wBAC/C;;sCACE,KAACtC;4BACCqF,MAAK;4BACLvB,SAASf,iBAAiB,SAAS;4BACnCwC,OAAM;4BACNoB,UAAUnF;4BACVkE,SAASrC;4BACT6B,IAAI;gCAAE0B,WAAW;4BAAa;sCAE7B7D,iBACG,mBACAvB,OACE,oBACA;;wBAUPE,6BACC,KAAC1B;4BACCqF,MAAK;4BACLvB,SAAQ;4BACRyB,OAAM;4BACNK,MAAMlE;4BACNmF,QAAO;4BACPC,KAAI;4BACJ5B,IAAI;gCAAE0B,WAAW;4BAAa;sCAE7B;6BAED;;mCAGN,KAACzG;oBAAW2D,SAAQ;oBAAUyB,OAAM;8BACjC;;;;;AAMb;AACAvE,qBAAqB+F,WAAW,GAAG;AAEnC,eAAe/F,qBAAoB"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/payments-settings-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport * as Aglyn from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { Alert, Button, Chip, Stack, Typography } from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { useCallback, useState } from 'react'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { useFirestoreDoc } from '@aglyn/tenant-feature-instance'\nimport { useOrgPlan } from '@aglyn/tenant-feature-instance'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { PrerequisiteNotice } from '@aglyn/shared-ui-jsx/components/prerequisite-notice.component'\nimport { useCommerceEntitlement } from './entitlement-gate.component'\n\nexport interface PaymentsSettingsCardProps {\n hostId: string\n}\n\n/** The element id the Payments card carries, for a link on the same page that lands on it (AGL-3982). */\nexport const PAYMENTS_SETTINGS_ANCHOR = 'store-payments'\n\n/**\n * Merchant payments card (AGL-284): Stripe Connect Express onboarding\n * status for the org owner + the plan's transaction-fee ladder so the\n * \"upgrade to kill fees\" motion (AGL-278) is visible where it matters.\n */\nexport function PaymentsSettingsCard(props: PaymentsSettingsCardProps) {\n const { hostId } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [busy, setBusy] = useState(false)\n /**\n * A one-time Stripe Express dashboard link, minted by the connect route on\n * request. Not persisted: login links are single-use and short-lived, so a\n * stored one would be a button that fails the second time it is pressed.\n */\n const [dashboardUrl, setDashboardUrl] = useState<string | null>(null)\n const { org, ready: planReady } = useOrgPlan(hostId)\n /** Bumped by Retry to re-subscribe the profile listen (AGL-1380). */\n const [retryNonce, setRetryNonce] = useState(0)\n const { upgradeHref } = useCommerceEntitlement(hostId, 'commerce')\n /**\n * The OWNER's profile: the Stripe account every money route charges\n * against is the one on the workspace owner's profile. Reading the\n * signed-in member's instead told an admin who is not the owner that a\n * connected store was not set up.\n */\n const ownerUid =\n typeof org?.ownerUid === 'string' && org.ownerUid ? org.ownerUid : undefined\n const { data: profile, status: profileStatus } = useFirestoreDoc<any>(\n // Held at null rather than addressed as `profiles/-pending-` — that\n // sentinel issued a guaranteed-denied read on every pre-auth mount, and\n // a denial lands in `status: 'error'`, which now means something.\n () => (ownerUid ? doc(firestore, 'profiles', ownerUid) : null),\n [firestore, ownerUid, retryNonce],\n )\n const isOwner = Boolean(\n org?.ownerUid && (user as any)?.uid === org.ownerUid,\n )\n /**\n * Three outcomes, not two (AGL-1380). An absent profile doc is the value\n * BEFORE an answer as much as it is the value of a merchant who never\n * connected Stripe, so \"Not set up\" off a falsy `stripeChargesEnabled` is a\n * claim about this org's payment setup made without having heard back. It\n * is wrong in the direction that provokes action: the same falsy value\n * turns the button into \"Set up payments\", which sends a merchant who is\n * already taking money into Stripe onboarding.\n */\n const stripeState: 'pending' | 'error' | 'loaded' =\n !planReady || (ownerUid && profileStatus === 'loading')\n ? 'pending'\n : profileStatus === 'error'\n ? 'error'\n : 'loaded'\n /**\n * WHICH STRIPE WORLD THE STORED ACCOUNT BELONGS TO (AGL-2471).\n *\n * `stripeChargesEnabled: true` was the whole readiness claim, and a\n * production profile carrying it named a TEST-mode account: this card said\n * \"Charges enabled\" about three storefronts that could not take a single\n * payment. Only a literal boolean counts as recorded — the same\n * three-valued reading `merchantAccountIsReady` uses on the server, so the\n * chip and the checkout cannot disagree.\n */\n const modeVerified = typeof profile?.stripeAccountLivemode === 'boolean'\n const chargesConnected =\n stripeState === 'loaded' && Boolean(profile?.stripeChargesEnabled)\n const modeUnverified = chargesConnected && !modeVerified\n const chargesEnabled = chargesConnected && modeVerified\n const physicalPct = Aglyn.resolveTransactionFeePct(org, 'physical')\n const digitalPct = Aglyn.resolveTransactionFeePct(org, 'digital')\n const commerceEnabled = Aglyn.checkEntitlement(org, 'commerce')\n\n const handleConnect = useCallback(async () => {\n setBusy(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/connect', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId }),\n })\n const payload = await response.json()\n if (response.status === 501) {\n return void enqueueSnackbar(\n 'Payments are not configured on this deployment',\n { variant: 'info', persist: false },\n )\n }\n if (!response.ok) {\n return void enqueueSnackbar(payload?.error ?? 'Payment setup failed', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n if (payload.chargesEnabled) {\n // \"% who connect Stripe\" — a GTM plan §6 activation metric\n // (AGL-1561). Gated on the TRANSITION, not the state: this handler\n // is a re-entrant create-or-resume, so it answers `chargesEnabled:\n // true` on every subsequent visit to a connected account, and a bare\n // event here would count one merchant once per click forever.\n // `chargesEnabled` is the state read from the profile BEFORE this\n // request, so the event fires only when onboarding actually completed.\n if (!chargesEnabled) trackEvent('stripe_connected', {})\n // CHARGES AND PAYOUTS ARE TWO FLAGS, AND ONLY ONE OF THEM IS THIS\n // SENTENCE (AGL-1997). `chargesEnabled` says Stripe will let the\n // account take money; whether the money can LEAVE is `payoutsEnabled`,\n // which the route answers alongside it. Charges-yes/payouts-no is an\n // ordinary Stripe state — verification pending or lapsed, no payout\n // method — and announcing \"Payments are enabled\" in it is false in the\n // direction that costs the merchant: they sell believing they are\n // paid, and the funds sit in a Connect account that cannot release\n // them. Read three-valued, so only a literal `false` from Stripe\n // downgrades the claim; an absent flag means unasked, not off.\n const payoutsBlocked = payload.payoutsEnabled === false\n // A WARNING THAT NAMES A PROBLEM MUST OFFER THE FIX.\n //\n // Stripe is the only place payouts can be released — an Express\n // account has no password and no direct login — so telling the\n // merchant their funds are stranded and then keeping them here is half\n // an answer. The route now mints the remediation link for exactly this\n // state; going there is the whole point of pressing the button.\n if (payoutsBlocked && payload.url) {\n return void window.location.assign(payload.url)\n }\n // Payouts are flowing, so the link is the Express dashboard: balance,\n // payout schedule, and the reason a payout failed. Held in state\n // rather than followed, because this click was a status check and\n // navigating away from one nobody asked to leave is its own defect.\n if (!payoutsBlocked && typeof payload.dashboardUrl === 'string') {\n setDashboardUrl(payload.dashboardUrl)\n }\n return void enqueueSnackbar(\n payoutsBlocked\n ? 'Connected — payouts are not released yet'\n : 'Payments are enabled',\n {\n variant: payoutsBlocked ? 'warning' : 'success',\n persist: false,\n },\n )\n }\n if (payload.url) window.location.assign(payload.url)\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setBusy(false)\n }\n }, [user, hostId, chargesEnabled, enqueueSnackbar])\n\n return (\n <CardDisplay\n id={PAYMENTS_SETTINGS_ANCHOR}\n header={'Payments'}\n help={pluginDocsHelp('commerceEndToEnd', {\n anchor: '#1-connect-payments',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }}>\n {'Stripe account'}\n </Typography>\n {/*\n No chip at all on error: both labels it could carry — \"Charges\n enabled\" and \"Not set up\" — assert something we failed to find\n out. Whatever Stripe is doing right now it carries on doing.\n */}\n {stripeState === 'error' ? null : (\n <Chip\n size=\"small\"\n label={\n stripeState === 'pending'\n ? 'Checking…'\n : chargesEnabled\n ? 'Charges enabled'\n : modeUnverified\n ? 'Not verified'\n : 'Not set up'\n }\n color={\n stripeState === 'pending'\n ? 'default'\n : chargesEnabled\n ? 'success'\n : modeUnverified\n ? 'error'\n : 'warning'\n }\n variant=\"outlined\"\n />\n )}\n </Stack>\n {stripeState === 'error' ? (\n <Alert\n severity=\"error\"\n action={\n <Button\n color=\"inherit\"\n size=\"small\"\n onClick={() => setRetryNonce((n) => n + 1)}\n >\n {'Retry'}\n </Button>\n }\n >\n {'We couldn’t load your payment setup. This says nothing about ' +\n 'whether payments are on — we could not reach the setting to ' +\n 'find out. Nothing has changed.'}\n </Alert>\n ) : null}\n {/*\n Every line below reads the plan, and an org doc still in flight\n resolves to the FREE tier (AGL-1064) — which would flash \"Selling\n requires a paid plan\" and the wrong fee percentages at a paying\n seller, then correct itself. Say nothing until it is known.\n */}\n {!planReady ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Checking your plan…'}\n </Typography>\n ) : (\n <>\n {!commerceEnabled ? (\n <PrerequisiteNotice href={upgradeHref} actionLabel=\"See plans\">\n {'Selling needs a paid plan. Choose one on Billing, then connect Stripe here.'}\n </PrerequisiteNotice>\n ) : null}\n {/*\n THE LEGAL NAME, not the org's resolved `productName`\n (AGL-2351). This sentence says who takes money off the\n merchant's own Stripe account, and the application fee lands in\n the platform Stripe account — held by the operating entity, not\n by a white-label agency reselling the console. Naming the\n agency here would assert a fee relationship that does not\n exist. `PLATFORM_BRAND_LEGAL_NAME` still configures cleanly for\n a self-host operator, who really is the entity collecting it.\n */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Buyers pay on your own Stripe account; ' +\n `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} collects a platform fee ` +\n 'per sale based on your plan:'}\n </Typography>\n {/* The DIGITAL rate is not products-only (AGL-2315). A paid\n booking is a service sale and resolves through the same\n `'service'`/digital axis, so a bookings-only merchant pays this\n exact number — and this card was the one place they could read\n their own rate while naming only \"products\". Stated here rather\n than adding a third figure: it is one rate, not two. */}\n <Typography variant=\"body2\">\n {`Physical products: ${physicalPct}% · Digital products, ` +\n `services & bookings: ${digitalPct}%`}\n {physicalPct > 0 || digitalPct > 0 ? (\n <Typography\n component=\"span\"\n variant=\"caption\"\n color=\"text.secondary\"\n >\n {' — higher plans reduce fees to 0%'}\n </Typography>\n ) : null}\n </Typography>\n {/* CARD PROCESSING, PASSED THROUGH AT COST (AGL-2152).\n\n Unconditional, including on the 0% plans, because it is\n exactly those plans where the merchant would otherwise read\n \"0%\" and be surprised by a deduction. Their PLATFORM fee\n really is zero — the figure below is Stripe's own charge for\n taking the payment, which every storefront sale incurs and\n which used to be absorbed silently out of the platform's\n balance rather than passed through.\n\n One rate, online and on a card reader (AGL-4198): no checkout\n on a site offers buy-now-pay-later. Stripe's payout charge and\n Stripe Tax come out of the platform fee first; a fee too small\n to cover them is topped up to what Stripe charges, never more. */}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Card processing is passed through at cost on top of that: ' +\n `${Aglyn.SALE_PROCESSING_PERCENT}% + ${Aglyn.SALE_PROCESSING_FIXED_CENTS}¢ per card sale, ` +\n 'online or on a card reader, what Stripe charges to take the payment. It is not a ' +\n `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} margin. Where the platform fee is smaller than ` +\n `what Stripe charges to pay you out (${Aglyn.CONNECT_PAYOUT_PERCENT}% + ` +\n `${Aglyn.CONNECT_PAYOUT_FIXED_CENTS}¢ a payout, and ${Aglyn.STRIPE_TAX_PERCENT}% where ` +\n 'Stripe Tax works out the tax), the fee is that cost instead.'}\n </Typography>\n {/* WHICH REGISTER TENDERS CARRY THE FEE, AND HOW EACH IS\n COLLECTED (AGL-2111, AGL-4036).\n\n Card and room-charge payments at the register carry the fee;\n cash, gift cards and store credit carry none\n (`CommerceModel.paymentCarriesPlatformFee`). A room charge's\n fee leaves by a door the merchant has never seen money leave\n by, their monthly invoice, so it is said here BEFORE it\n appears there.\n\n Shown only when a rate actually applies: on a 0% plan there is\n nothing to collect either way, and the paragraph would be noise\n on the card of the merchants who upgraded to escape fees. */}\n {physicalPct > 0 || digitalPct > 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'At the register, cash, gift card and store credit payments ' +\n 'carry no fee. On card payments it is deducted from your ' +\n 'Stripe payout; on room-charge payments there is no payout to ' +\n 'deduct from, so it is added to your monthly ' +\n `${Aglyn.PLATFORM_BRAND_LEGAL_NAME} invoice instead.`}\n </Typography>\n ) : null}\n </>\n )}\n {/*\n AGL-2471: connected, and refused by every money door because the\n account was never verified against this deployment's Stripe mode.\n \"Not set up\" would be a lie in the other direction — the merchant\n did set something up — so the card names what is actually wrong and\n what to do about it.\n */}\n {modeUnverified ? (\n <Alert severity=\"error\">\n {'Your Stripe account has not been verified for payments on ' +\n 'this site, so sales will be refused. Set up payments again ' +\n 'to verify it — if it was connected against Stripe test mode, ' +\n 'you will need to connect a live account.'}\n </Alert>\n ) : null}\n {/*\n The button's own label is a claim — \"Set up payments\" tells the\n owner they have none. Withheld until the answer is in, for the same\n reason as the chip (AGL-1380); on error the Retry above is the only\n action offered, because acting on a setup we could not read is how\n a connected merchant gets sent back through onboarding.\n */}\n {/*\n WHERE THE MONEY STOPPED. Mirrored onto this profile by the\n `payout.failed` handler and retired by the next successful payout, so\n it names a live problem rather than a scar. Without it a merchant sold\n into an account that could not release the funds and the card said\n \"Payments are enabled\" the whole time — the storefront looked healthy\n from every angle available to them.\n */}\n {stripeState === 'loaded' && profile?.lastPayoutFailureAtMs ? (\n <Alert severity=\"warning\" variant=\"outlined\">\n {`A payout of $${(\n Number(profile.lastPayoutFailureCents ?? 0) / 100\n ).toFixed(2)} did not reach your bank on ${new Date(\n Number(profile.lastPayoutFailureAtMs),\n ).toLocaleDateString()} — ${String(\n profile.lastPayoutFailureReason ?? 'Stripe did not say why',\n )} The money is still in your Stripe account. Open Stripe to fix your payout details.`}\n </Alert>\n ) : null}\n {!planReady || stripeState !== 'loaded' ? null : isOwner ? (\n <>\n <Button\n size=\"small\"\n variant={chargesEnabled ? 'text' : 'contained'}\n color=\"primary\"\n disabled={busy}\n onClick={handleConnect}\n sx={{ alignSelf: 'flex-start' }}\n >\n {chargesEnabled\n ? 'Refresh status'\n : busy\n ? 'Opening Stripe…'\n : 'Set up payments'}\n </Button>\n {/*\n Where the money actually is. Aglyn records none of it —\n no balance, no payout schedule, and no `payout.failed` handling\n anywhere — so a merchant whose payout bounced has no way to learn\n that from this console. An Express account has no direct login\n either, which leaves a link minted by the platform as the only\n route in. `target=\"_blank\"` because it leaves the app entirely.\n */}\n {dashboardUrl ? (\n <Button\n size=\"small\"\n variant=\"text\"\n color=\"primary\"\n href={dashboardUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n sx={{ alignSelf: 'flex-start' }}\n >\n {'View payouts in Stripe'}\n </Button>\n ) : null}\n </>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Only the organization owner can set up payments.'}\n </Typography>\n )}\n </Stack>\n </CardDisplay>\n )\n}\nPaymentsSettingsCard.displayName = 'PaymentsSettingsCard'\n\nexport default PaymentsSettingsCard\n"],"names":["trackEvent","Aglyn","CardDisplay","useSnackbar","Alert","Button","Chip","Stack","Typography","doc","useCallback","useState","useFirestore","useUser","useFirestoreDoc","useOrgPlan","pluginDocsHelp","authorizedFetch","PrerequisiteNotice","useCommerceEntitlement","PAYMENTS_SETTINGS_ANCHOR","PaymentsSettingsCard","props","profile","hostId","firestore","data","user","enqueueSnackbar","busy","setBusy","dashboardUrl","setDashboardUrl","org","ready","planReady","retryNonce","setRetryNonce","upgradeHref","ownerUid","undefined","status","profileStatus","isOwner","Boolean","uid","stripeState","modeVerified","stripeAccountLivemode","chargesConnected","stripeChargesEnabled","modeUnverified","chargesEnabled","physicalPct","resolveTransactionFeePct","digitalPct","commerceEnabled","checkEntitlement","handleConnect","response","method","headers","body","JSON","stringify","payload","json","variant","persist","ok","error","allowDuplicate","payoutsBlocked","payoutsEnabled","url","window","location","assign","console","id","header","help","anchor","contentGutterX","contentGutterY","spacing","direction","sx","alignItems","flex","size","label","color","severity","action","onClick","n","href","actionLabel","PLATFORM_BRAND_LEGAL_NAME","component","SALE_PROCESSING_PERCENT","SALE_PROCESSING_FIXED_CENTS","CONNECT_PAYOUT_PERCENT","CONNECT_PAYOUT_FIXED_CENTS","STRIPE_TAX_PERCENT","lastPayoutFailureAtMs","Number","lastPayoutFailureCents","toFixed","Date","toLocaleDateString","String","lastPayoutFailureReason","disabled","alignSelf","target","rel","displayName"],"mappings":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a;sCAE7B/D,iBACG,mBACAvB,OACE,oBACA;;wBAUPE,6BACC,KAAC1B;4BACCqF,MAAK;4BACLvB,SAAQ;4BACRyB,OAAM;4BACNK,MAAMlE;4BACNqF,QAAO;4BACPC,KAAI;4BACJ9B,IAAI;gCAAE4B,WAAW;4BAAa;sCAE7B;6BAED;;mCAGN,KAAC3G;oBAAW2D,SAAQ;oBAAUyB,OAAM;8BACjC;;;;;AAMb;AACAvE,qBAAqBiG,WAAW,GAAG;AAEnC,eAAejG,qBAAoB"}
@@ -82,6 +82,11 @@ export declare function posHardwareCheckout(user: User, attemptKey: string, body
82
82
  quantity: number;
83
83
  }>;
84
84
  shippingMethod: PosHardwareShippingMethod;
85
+ /** The terms of sale accepted and business use confirmed (AGL-4038); both required. */
86
+ hardwareTerms: {
87
+ accepted: boolean;
88
+ businessUse: boolean;
89
+ };
85
90
  }): Promise<{
86
91
  url: string;
87
92
  orderId: string;
@@ -164,7 +169,11 @@ export declare function staffHardwareOrders(user: User, filter: StaffHardwareFil
164
169
  canWrite: boolean;
165
170
  }>;
166
171
  export declare function staffHardwareOrderAction(user: User, body: {
167
- action: 'update' | 'cancel' | 'refund' | 'refund-return' | 'forget-buyer' | 'decline-return';
172
+ action: 'update' | 'cancel' | 'refund' | 'refund-return' | 'forget-buyer' | 'decline-return' | 'serials' | 'register-reader';
173
+ /** Setting the order up before it ships (AGL-4038): its readers' serial numbers, in reader order. */
174
+ serials?: string[];
175
+ /** The code a reader shows, to register it to the buyer's store (AGL-4038). */
176
+ registrationCode?: string;
168
177
  /** An online return's restocking fee, in cents (AGL-4038). */
169
178
  restockingFeeCents?: number;
170
179
  note?: string;