@aglyn/plugins-commerce 1.12.0 → 1.14.0

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 (79) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/console/catalog-organization-card.component.js +1 -1
  3. package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
  4. package/src/lib/components/console/host-quotes-card.component.js +3 -2
  5. package/src/lib/components/console/host-quotes-card.component.js.map +1 -1
  6. package/src/lib/components/console/order-detail-dialog.component.js +1 -1
  7. package/src/lib/components/console/order-detail-dialog.component.js.map +1 -1
  8. package/src/lib/components/console/pay-link-readiness-notice.component.d.ts +1 -1
  9. package/src/lib/components/console/pay-link-readiness-notice.component.js.map +1 -1
  10. package/src/lib/components/console/pos-devices-card.component.js +2 -2
  11. package/src/lib/components/console/pos-devices-card.component.js.map +1 -1
  12. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js +1 -1
  13. package/src/lib/components/console/pos-ops/pos-check-ins-card.component.js.map +1 -1
  14. package/src/lib/components/console/pos-ops/pos-day-totals-card.component.js +1 -1
  15. package/src/lib/components/console/pos-ops/pos-day-totals-card.component.js.map +1 -1
  16. package/src/lib/components/console/pos-reader-splash-setting.component.js +1 -1
  17. package/src/lib/components/console/pos-reader-splash-setting.component.js.map +1 -1
  18. package/src/lib/components/console/quote-editor-dialog.component.d.ts +5 -0
  19. package/src/lib/components/console/quote-editor-dialog.component.js +104 -16
  20. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  21. package/src/lib/components/console/quote-pay-link.component.d.ts +4 -1
  22. package/src/lib/components/console/quote-pay-link.component.js +23 -12
  23. package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
  24. package/src/lib/components/console/quote-proofs.component.d.ts +3 -2
  25. package/src/lib/components/console/quote-proofs.component.js +73 -5
  26. package/src/lib/components/console/quote-proofs.component.js.map +1 -1
  27. package/src/lib/components/console/quote-send.component.js +9 -6
  28. package/src/lib/components/console/quote-send.component.js.map +1 -1
  29. package/src/lib/components/console/site-member-purchases.component.js +1 -1
  30. package/src/lib/components/console/site-member-purchases.component.js.map +1 -1
  31. package/src/lib/components/quote-page-body.js +14 -8
  32. package/src/lib/components/quote-page-body.js.map +1 -1
  33. package/src/lib/model/commerce-invoices.d.ts +1 -1
  34. package/src/lib/model/commerce-invoices.js +4 -1
  35. package/src/lib/model/commerce-invoices.js.map +1 -1
  36. package/src/lib/model/commerce-quote-email.d.ts +7 -6
  37. package/src/lib/model/commerce-quote-email.js +11 -6
  38. package/src/lib/model/commerce-quote-email.js.map +1 -1
  39. package/src/lib/model/commerce-quote-pay.d.ts +6 -1
  40. package/src/lib/model/commerce-quote-pay.js +18 -8
  41. package/src/lib/model/commerce-quote-pay.js.map +1 -1
  42. package/src/lib/model/commerce-quote-proofs.d.ts +28 -1
  43. package/src/lib/model/commerce-quote-proofs.js +58 -2
  44. package/src/lib/model/commerce-quote-proofs.js.map +1 -1
  45. package/src/lib/model/commerce-quotes.d.ts +22 -1
  46. package/src/lib/model/commerce-quotes.js +25 -5
  47. package/src/lib/model/commerce-quotes.js.map +1 -1
  48. package/src/lib/model/plugin-permissions.d.ts +1 -1
  49. package/src/lib/model/plugin-permissions.js +10 -0
  50. package/src/lib/model/plugin-permissions.js.map +1 -1
  51. package/src/lib/server/commerce-pdf.d.ts +1 -1
  52. package/src/lib/server/commerce-pdf.js +1 -1
  53. package/src/lib/server/commerce-pdf.js.map +1 -1
  54. package/src/lib/server/paid-media-delivery.js +1 -1
  55. package/src/lib/server/paid-media-delivery.js.map +1 -1
  56. package/src/lib/server/quote-email.js +29 -25
  57. package/src/lib/server/quote-email.js.map +1 -1
  58. package/src/lib/server/quote-pay.js +6 -2
  59. package/src/lib/server/quote-pay.js.map +1 -1
  60. package/src/lib/server/quote-proof-media.d.ts +63 -0
  61. package/src/lib/server/quote-proof-media.js +96 -0
  62. package/src/lib/server/quote-proof-media.js.map +1 -0
  63. package/src/lib/server/quote-proofs.js +9 -5
  64. package/src/lib/server/quote-proofs.js.map +1 -1
  65. package/src/lib/server/quote-uploads.d.ts +3 -1
  66. package/src/lib/server/quote-uploads.js +2 -1
  67. package/src/lib/server/quote-uploads.js.map +1 -1
  68. package/src/lib/server/quote.d.ts +3 -0
  69. package/src/lib/server/quote.js +127 -20
  70. package/src/lib/server/quote.js.map +1 -1
  71. package/src/lib/tenant-emails.js +16 -9
  72. package/src/lib/tenant-emails.js.map +1 -1
  73. package/src/lib/transfer/gift-cards.server.js +9 -11
  74. package/src/lib/transfer/gift-cards.server.js.map +1 -1
  75. package/src/lib/utils/commerce-document-pdf.js +12 -9
  76. package/src/lib/utils/commerce-document-pdf.js.map +1 -1
  77. package/src/lib/utils/quote-email-content.d.ts +2 -0
  78. package/src/lib/utils/quote-email-content.js +20 -10
  79. package/src/lib/utils/quote-email-content.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/site-member-purchases.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 type { ConsoleSiteMemberZoneProps } from '@aglyn/aglyn'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport {\n ceilingedWindow,\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { Chip, Divider, Stack, Typography } from '@mui/material'\nimport {\n collection,\n documentId,\n limit,\n orderBy,\n query,\n where,\n} from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport { splitOrderReversal } from '../../model/commerce-dispute'\nimport { computeLifetimePurchaseCents } from '../../model/site-member-purchases'\n\nconst usd = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n/**\n * How many order documents this reads for one member.\n *\n * A CEILING, not a page size: the lifetime-purchase figure above the list is\n * summed from these rows, so every one it intends to count has to be held. A\n * server page would make that headline number the total of ten orders and\n * print it as a lifetime.\n */\nconst ORDER_CEILING = 100\n/** The same, for the subscriptions this member holds. */\nconst SUBSCRIPTION_CEILING = 25\n\n/**\n * The reversal suffix on one order row, split by the door the money left\n * through (AGL-1810). `refundedCents` carries a lost chargeback as well as a\n * refund (AGL-1787 puts both there deliberately), so rendering the whole\n * figure as \"refunded\" told the merchant they chose a reversal a bank took.\n * `computeLifetimePurchaseCents` keeps netting the total; only the label\n * splits.\n */\nconst reversalSuffix = (order: any) => {\n const { refundedCents, chargedBackCents } = splitOrderReversal(order)\n return (\n (refundedCents ? ` · refunded ${usd(refundedCents)}` : '') +\n (chargedBackCents ? ` · charged back ${usd(chargedBackCents)}` : '')\n )\n}\n\n/** Display order number: v1 sequential `#1042`, else a doc-id stub. */\nconst orderNumber = (order: any) =>\n order.number != null\n ? `#${order.number}`\n : `#${String(order.$id ?? '').slice(-6).toUpperCase()}`\n\nconst orderCreatedMs = (order: any) =>\n Number(order.createdAtMs ?? (order.createdAt?.seconds ?? 0) * 1000) || 0\n\n/**\n * What a site user bought (AGL-546): the lifetime purchase total, the order\n * history (the payment records — Stripe intent id and refunds included) and\n * storefront subscriptions — the `siteMember` zone of the account's drawer.\n *\n * Orders match by email (mirrors membership-account, AGL-294) and sort\n * client-side. The QUERY orders on the document name: `orderBy('createdAt')`\n * would want a composite index and, worse, would drop every order missing the\n * field, while an equality filter plus `orderBy(documentId())` rides the\n * automatic single-field index and can drop nothing — a document's name\n * cannot be absent. That makes the window total rather than a pseudo-random\n * hundred, which is what the newest-first sort below was quietly disguising.\n * `orders` reads are admin/editor-only in rules (AGL-502), so viewers get a\n * note instead of history.\n *\n * One section per element, as a fragment: the zone is `bare`, and the drawer's\n * own column spaces what it holds.\n */\nexport function SiteMemberPurchases(props: ConsoleSiteMemberZoneProps) {\n const { hostId, member } = props\n const firestore = useFirestore()\n const memberId = String(member.$id ?? '')\n const email = String(member['email'] ?? '')\n\n const { data: orderDocs, status: ordersStatus } = useFirestoreCollection<any>(\n () =>\n email\n ? query(\n collection(firestore, 'hosts', hostId, 'orders'),\n where('customerEmail', '==', email),\n orderBy(documentId()),\n // One document past the ceiling, so \"this member has more\" is a\n // fact. `length === 100` cannot tell a member with exactly a\n // hundred orders from one with a thousand, and the difference is\n // whether the lifetime figure above is a total or a floor.\n limit(ORDER_CEILING + 1),\n )\n : null,\n [firestore, hostId, email],\n { idField: '$id' },\n )\n const { rows: readOrders, truncated: ordersTruncated } = ceilingedWindow<any>(\n orderDocs,\n ORDER_CEILING,\n )\n const orders = useMemo(\n () =>\n [...readOrders].sort((a, b) => orderCreatedMs(b) - orderCreatedMs(a)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [orderDocs],\n )\n const lifetimeCents = useMemo(\n () => computeLifetimePurchaseCents(orders),\n [orders],\n )\n /**\n * The order query failed AND nothing came back with it (AGL-1066).\n *\n * The copy this gates blames the reader's ROLE, which is the right\n * explanation for the denial this was written for — orders are\n * admin/editor-only in rules. It is the wrong explanation once a stale\n * SESSION can push a listen to `'error'` too, and flatly wrong when\n * `persistentLocalCache` is still serving the rows: telling someone their\n * role is insufficient while their orders sit right there is a support\n * ticket about permissions that was never about permissions.\n */\n const ordersUnreadable = ordersStatus === 'error' && orders.length === 0\n\n const { data: subscriptionDocs } = useFirestoreCollection<any>(\n () =>\n email\n ? query(\n collection(firestore, 'hosts', hostId, 'subscriptions'),\n where('customerEmail', '==', email),\n // The same decision as the orders above, for the same reason: a\n // subscription written without `createdAt` would be hidden by a\n // field ordering rather than mis-sorted by it.\n orderBy(documentId()),\n limit(SUBSCRIPTION_CEILING + 1),\n )\n : null,\n [firestore, hostId, email],\n { idField: '$id' },\n )\n const { rows: subscriptions, truncated: subscriptionsTruncated } =\n ceilingedWindow<any>(subscriptionDocs, SUBSCRIPTION_CEILING)\n // Product names for subscriptions, loaded only when any exist.\n const { data: productDocs } = useFirestoreCollection<any>(\n () =>\n email && (subscriptionDocs?.length ?? 0) > 0\n ? query(\n collection(firestore, 'hosts', hostId, 'products'),\n // A LOOKUP, not a list — but the same ordering decision, so the\n // hundred it reads is a reachable hundred rather than a sample,\n // and a product past it degrades a subscription's label to its\n // id rather than hiding the subscription.\n orderBy(documentId()),\n limit(100),\n )\n : null,\n [firestore, hostId, email, (subscriptionDocs?.length ?? 0) > 0],\n { idField: '$id' },\n )\n /*==========================================\n * BOTH LISTS PAGE IN MEMORY.\n *\n * Each ceiling is held whole, which is what lets the orders sort\n * newest-first and the lifetime figure sum over all of them. A server page\n * would have made both about ten rows instead of about this member.\n *=========================================*/\n const [orderPage, setOrderPage] = useState(0)\n const [orderPageSize, setOrderPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n const visibleOrders = useMemo(\n () =>\n orders.slice(\n orderPage * orderPageSize,\n orderPage * orderPageSize + orderPageSize,\n ),\n [orders, orderPage, orderPageSize],\n )\n const [subscriptionPage, setSubscriptionPage] = useState(0)\n const [subscriptionPageSize, setSubscriptionPageSize] = useState(\n TABLE_PAGE_SIZE_DEFAULT,\n )\n const visibleSubscriptions = useMemo(\n () =>\n subscriptions.slice(\n subscriptionPage * subscriptionPageSize,\n subscriptionPage * subscriptionPageSize + subscriptionPageSize,\n ),\n [subscriptions, subscriptionPage, subscriptionPageSize],\n )\n /*\n * A different member starts at page one. The drawer is reused for whoever\n * is selected, so without this the next member opens three pages into a\n * history they may not have — which renders as an empty list and reads as\n * \"this person never bought anything\".\n */\n useEffect(() => {\n setOrderPage(0)\n setSubscriptionPage(0)\n }, [memberId])\n\n const productNames = useMemo(() => {\n const map: Record<string, string> = {}\n for (const product of productDocs ?? []) {\n map[product.$id] = product.name ?? product.$id\n }\n return map\n }, [productDocs])\n\n return (\n <>\n <Divider textAlign=\"left\">{'Lifetime purchases'}</Divider>\n <Typography variant=\"h6\">\n {/*\n \"at least\", or nothing at all. This figure is summed over the order\n WINDOW, so once the probe finds an order past the ceiling it is a\n lower bound — and a lower bound printed as a lifetime is the number\n a support agent quotes back to the customer.\n */}\n {ordersUnreadable\n ? '—'\n : `${ordersTruncated ? 'at least ' : ''}${usd(lifetimeCents)}`}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Charged order totals minus refunds; pending and canceled ' +\n 'orders excluded.'}\n {ordersTruncated\n ? ` Summed over the ${ORDER_CEILING} orders read here; this ` +\n 'member has more.'\n : ''}\n </Typography>\n\n <Divider textAlign=\"left\">{'Orders'}</Divider>\n {ordersUnreadable ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Order history needs the editor or admin role on this site.'}\n </Typography>\n ) : orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No orders yet.'}\n </Typography>\n ) : (\n visibleOrders.map((order: any) => (\n <Stack key={order.$id} spacing={0}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {`${orderNumber(order)} · ${usd(\n Number(order.totals?.totalCents ?? order.amountCents ?? 0) ||\n 0,\n )}`}\n </Typography>\n <Chip\n label={String(order.status ?? 'paid').replace('_', ' ')}\n size=\"small\"\n variant=\"outlined\"\n />\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {orderCreatedMs(order)\n ? new Date(orderCreatedMs(order)).toLocaleDateString()\n : '—'}\n {reversalSuffix(order)}\n </Typography>\n {order.paymentIntentId ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ fontFamily: 'monospace' }}\n noWrap\n >\n {order.paymentIntentId}\n </Typography>\n ) : null}\n </Stack>\n ))\n )}\n {ordersUnreadable || orders.length === 0 ? null : (\n <ListPagination\n page={orderPage}\n pageSize={orderPageSize}\n rowCount={visibleOrders.length}\n // The orders held here — a slice of rows already read, so the\n // total is exact for the window. The lifetime caption above is\n // where the window's own shortfall is stated.\n count={orders.length}\n onPageChange={setOrderPage}\n onPageSizeChange={setOrderPageSize}\n />\n )}\n\n {subscriptions.length > 0 ? (\n <>\n <Divider textAlign=\"left\">{'Subscriptions'}</Divider>\n {visibleSubscriptions.map((subscription: any) => (\n <Stack\n key={subscription.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {/*\n * The amount (AGL-1732). This row named the product and the\n * renewal date and stopped, and no other console surface\n * carried the figure either — orders, analytics and the CSV\n * all read `orders`, which a subscription sale does not\n * create. Subscriptions written before that fix have no\n * `totals`, so the amount is omitted rather than shown as\n * $0.00.\n */}\n {productNames[subscription.productId] ??\n subscription.productId ??\n 'Subscription'}\n {subscription.totals?.totalCents != null\n ? ` · ${usd(Number(subscription.totals.totalCents) || 0)}${\n subscription.interval ? `/${subscription.interval}` : ''\n }`\n : ''}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {subscription.currentPeriodEndMs\n ? `Renews ${new Date(\n Number(subscription.currentPeriodEndMs),\n ).toLocaleDateString()}`\n : '—'}\n {/*\n * What this subscriber has actually paid, across every cycle\n * (AGL-1743). Omitted, not shown as 0, for subscriptions\n * whose cycles all predate `invoice.payment_succeeded`\n * being handled: those invoices are recoverable only from\n * Stripe.\n */}\n {Number(subscription.invoicesCount ?? 0) > 0\n ? ` · ${usd(Number(subscription.paidCents) || 0)} paid over ${\n Number(subscription.invoicesCount) === 1\n ? '1 invoice'\n : `${Number(subscription.invoicesCount)} invoices`\n }`\n : ''}\n </Typography>\n </Stack>\n <Chip\n label={String(subscription.status ?? 'active')}\n size=\"small\"\n variant=\"outlined\"\n color={subscription.status === 'active' ? 'success' : 'default'}\n />\n </Stack>\n ))}\n <ListPagination\n page={subscriptionPage}\n pageSize={subscriptionPageSize}\n rowCount={visibleSubscriptions.length}\n // This member's subscriptions, in full for the window.\n count={subscriptions.length}\n onPageChange={setSubscriptionPage}\n onPageSizeChange={setSubscriptionPageSize}\n />\n {subscriptionsTruncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Showing ${SUBSCRIPTION_CEILING} subscriptions; this ` +\n 'member has more.'}\n </Typography>\n ) : null}\n </>\n ) : null}\n </>\n )\n}\nSiteMemberPurchases.displayName = 'SiteMemberPurchases'\n\nexport default SiteMemberPurchases\n"],"names":["ListPagination","TABLE_PAGE_SIZE_DEFAULT","ceilingedWindow","useFirestore","useFirestoreCollection","Chip","Divider","Stack","Typography","collection","documentId","limit","orderBy","query","where","useEffect","useMemo","useState","splitOrderReversal","computeLifetimePurchaseCents","usd","cents","toFixed","ORDER_CEILING","SUBSCRIPTION_CEILING","reversalSuffix","order","refundedCents","chargedBackCents","orderNumber","number","String","$id","slice","toUpperCase","orderCreatedMs","Number","createdAtMs","createdAt","seconds","SiteMemberPurchases","props","member","hostId","firestore","memberId","email","data","orderDocs","status","ordersStatus","idField","rows","readOrders","truncated","ordersTruncated","orders","sort","a","b","lifetimeCents","ordersUnreadable","length","subscriptionDocs","subscriptions","subscriptionsTruncated","productDocs","orderPage","setOrderPage","orderPageSize","setOrderPageSize","visibleOrders","subscriptionPage","setSubscriptionPage","subscriptionPageSize","setSubscriptionPageSize","visibleSubscriptions","productNames","map","product","name","textAlign","variant","color","spacing","direction","sx","alignItems","flex","noWrap","totals","totalCents","amountCents","label","replace","size","Date","toLocaleDateString","paymentIntentId","fontFamily","page","pageSize","rowCount","count","onPageChange","onPageSizeChange","subscription","minWidth","productId","interval","currentPeriodEndMs","invoicesCount","paidCents","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SAASA,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,uBAAuB,Q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,aAAaI,kBAAkB,GAC5B,CAAC,OAAO,EAAE,IAAId,KACZ5D,OAAOsE,aAAaI,kBAAkB,GACtCb,kBAAkB,IAAI,GACxB;gDAQH7D,QAAOsE,8BAAAA,aAAaK,aAAa,YAA1BL,8BAA8B,KAAK,IACvC,CAAC,GAAG,EAAEtF,IAAIgB,OAAOsE,aAAaM,SAAS,KAAK,GAAG,WAAW,EACxD5E,OAAOsE,aAAaK,aAAa,MAAM,IACnC,cACA,GAAG3E,OAAOsE,aAAaK,aAAa,EAAE,SAAS,CAAC,EACpD,GACF;;;;;8CAGR,KAAC1G;oCACCwF,OAAO9D,QAAO2E,uBAAAA,aAAazD,MAAM,YAAnByD,uBAAuB;oCACrCX,MAAK;oCACLb,SAAQ;oCACRC,OAAOuB,aAAazD,MAAM,KAAK,WAAW,YAAY;;;2BAnDnDyD,aAAa1E,GAAG;;kCAuDzB,KAAChC;wBACCoG,MAAM5B;wBACN6B,UAAU3B;wBACV4B,UAAU1B,qBAAqBd,MAAM;wBACrC,uDAAuD;wBACvDyC,OAAOvC,cAAcF,MAAM;wBAC3B0C,cAAc/B;wBACdgC,kBAAkB9B;;oBAEnBV,uCACC,KAACzD;wBAAW0E,SAAQ;wBAAUC,OAAM;kCACjC,CAAC,QAAQ,EAAE3D,qBAAqB,qBAAqB,CAAC,GACrD;yBAEF;;iBAEJ;;;AAGV;AACAgB,oBAAoByE,WAAW,GAAG;AAElC,eAAezE,oBAAmB"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/site-member-purchases.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 type { ConsoleSiteMemberZoneProps } from '@aglyn/aglyn'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { TABLE_PAGE_SIZE_DEFAULT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport {\n ceilingedWindow,\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { Chip, Divider, Stack, Typography } from '@mui/material'\nimport {\n collection,\n documentId,\n limit,\n orderBy,\n query,\n where,\n} from 'firebase/firestore'\nimport { useEffect, useMemo, useState } from 'react'\nimport { splitOrderReversal } from '../../model/commerce-dispute'\nimport { computeLifetimePurchaseCents } from '../../model/site-member-purchases'\n\nconst usd = (cents: number) => `$${(cents / 100).toFixed(2)}`\n\n/**\n * How many order documents this reads for one member.\n *\n * A CEILING, not a page size: the lifetime-purchase figure above the list is\n * summed from these rows, so every one it intends to count has to be held. A\n * server page would make that headline number the total of ten orders and\n * print it as a lifetime.\n */\nconst ORDER_CEILING = 100\n/** The same, for the subscriptions this member holds. */\nconst SUBSCRIPTION_CEILING = 25\n\n/**\n * The reversal suffix on one order row, split by the door the money left\n * through (AGL-1810). `refundedCents` carries a lost chargeback as well as a\n * refund (AGL-1787 puts both there deliberately), so rendering the whole\n * figure as \"refunded\" told the merchant they chose a reversal a bank took.\n * `computeLifetimePurchaseCents` keeps netting the total; only the label\n * splits.\n */\nconst reversalSuffix = (order: any) => {\n const { refundedCents, chargedBackCents } = splitOrderReversal(order)\n return (\n (refundedCents ? ` · refunded ${usd(refundedCents)}` : '') +\n (chargedBackCents ? ` · charged back ${usd(chargedBackCents)}` : '')\n )\n}\n\n/** Display order number: v1 sequential `#1042`, else a doc-id stub. */\nconst orderNumber = (order: any) =>\n order.number != null\n ? `#${order.number}`\n : `#${String(order.$id ?? '').slice(-6).toUpperCase()}`\n\nconst orderCreatedMs = (order: any) =>\n Number(order.createdAtMs ?? (order.createdAt?.seconds ?? 0) * 1000) || 0\n\n/**\n * What a site user bought (AGL-546): the lifetime purchase total, the order\n * history (the payment records — Stripe intent id and refunds included) and\n * storefront subscriptions — the `siteMember` zone of the account's drawer.\n *\n * Orders match by email (mirrors membership-account, AGL-294) and sort\n * client-side. The QUERY orders on the document name: `orderBy('createdAt')`\n * would want a composite index and, worse, would drop every order missing the\n * field, while an equality filter plus `orderBy(documentId())` rides the\n * automatic single-field index and can drop nothing — a document's name\n * cannot be absent. That makes the window total rather than a pseudo-random\n * hundred, which is what the newest-first sort below was quietly disguising.\n * `orders` reads are admin/editor-only in rules (AGL-502), so viewers get a\n * note instead of history.\n *\n * One section per element, as a fragment: the zone is `bare`, and the drawer's\n * own column spaces what it holds.\n */\nexport function SiteMemberPurchases(props: ConsoleSiteMemberZoneProps) {\n const { hostId, member } = props\n const firestore = useFirestore()\n const memberId = String(member.$id ?? '')\n const email = String(member['email'] ?? '')\n\n const { data: orderDocs, status: ordersStatus } = useFirestoreCollection<any>(\n () =>\n email\n ? query(\n collection(firestore, 'hosts', hostId, 'orders'),\n where('customerEmail', '==', email),\n orderBy(documentId()),\n // One document past the ceiling, so \"this member has more\" is a\n // fact. `length === 100` cannot tell a member with exactly a\n // hundred orders from one with a thousand, and the difference is\n // whether the lifetime figure above is a total or a floor.\n limit(ORDER_CEILING + 1),\n )\n : null,\n [firestore, hostId, email],\n { idField: '$id' },\n )\n const { rows: readOrders, truncated: ordersTruncated } = ceilingedWindow<any>(\n orderDocs,\n ORDER_CEILING,\n )\n const orders = useMemo(\n () =>\n [...readOrders].sort((a, b) => orderCreatedMs(b) - orderCreatedMs(a)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [orderDocs],\n )\n const lifetimeCents = useMemo(\n () => computeLifetimePurchaseCents(orders),\n [orders],\n )\n /**\n * The order query failed AND nothing came back with it (AGL-1066).\n *\n * The copy this gates blames the reader's ROLE, which is the right\n * explanation for the denial this was written for — orders are\n * admin/editor-only in rules. It is the wrong explanation once a stale\n * SESSION can push a listen to `'error'` too, and flatly wrong when\n * `persistentLocalCache` is still serving the rows: telling someone their\n * role is insufficient while their orders sit right there is a support\n * ticket about permissions that was never about permissions.\n */\n const ordersUnreadable = ordersStatus === 'error' && orders.length === 0\n\n const { data: subscriptionDocs } = useFirestoreCollection<any>(\n () =>\n email\n ? query(\n collection(firestore, 'hosts', hostId, 'subscriptions'),\n where('customerEmail', '==', email),\n // The same decision as the orders above, for the same reason: a\n // subscription written without `createdAt` would be hidden by a\n // field ordering rather than mis-sorted by it.\n orderBy(documentId()),\n limit(SUBSCRIPTION_CEILING + 1),\n )\n : null,\n [firestore, hostId, email],\n { idField: '$id' },\n )\n const { rows: subscriptions, truncated: subscriptionsTruncated } =\n ceilingedWindow<any>(subscriptionDocs, SUBSCRIPTION_CEILING)\n // Product names for subscriptions, loaded only when any exist.\n const { data: productDocs } = useFirestoreCollection<any>(\n () =>\n email && (subscriptionDocs?.length ?? 0) > 0\n ? query(\n collection(firestore, 'hosts', hostId, 'products'),\n // A LOOKUP, not a list — but the same ordering decision, so the\n // hundred it reads is a reachable hundred rather than a sample,\n // and a product past it degrades a subscription's label to its\n // id rather than hiding the subscription.\n orderBy(documentId()),\n limit(100),\n )\n : null,\n [firestore, hostId, email, (subscriptionDocs?.length ?? 0) > 0],\n { idField: '$id' },\n )\n /*==========================================\n * BOTH LISTS PAGE IN MEMORY.\n *\n * Each ceiling is held whole, which is what lets the orders sort\n * newest-first and the lifetime figure sum over all of them. A server page\n * would have made both about ten rows instead of about this member.\n *=========================================*/\n const [orderPage, setOrderPage] = useState(0)\n const [orderPageSize, setOrderPageSize] = useState(TABLE_PAGE_SIZE_DEFAULT)\n const visibleOrders = useMemo(\n () =>\n orders.slice(\n orderPage * orderPageSize,\n orderPage * orderPageSize + orderPageSize,\n ),\n [orders, orderPage, orderPageSize],\n )\n const [subscriptionPage, setSubscriptionPage] = useState(0)\n const [subscriptionPageSize, setSubscriptionPageSize] = useState(\n TABLE_PAGE_SIZE_DEFAULT,\n )\n const visibleSubscriptions = useMemo(\n () =>\n subscriptions.slice(\n subscriptionPage * subscriptionPageSize,\n subscriptionPage * subscriptionPageSize + subscriptionPageSize,\n ),\n [subscriptions, subscriptionPage, subscriptionPageSize],\n )\n /*\n * A different member starts at page one. The drawer is reused for whoever\n * is selected, so without this the next member opens three pages into a\n * history they may not have — which renders as an empty list and reads as\n * \"this person never bought anything\".\n */\n useEffect(() => {\n setOrderPage(0)\n setSubscriptionPage(0)\n }, [memberId])\n\n const productNames = useMemo(() => {\n const map: Record<string, string> = {}\n for (const product of productDocs ?? []) {\n map[product.$id] = product.name ?? product.$id\n }\n return map\n }, [productDocs])\n\n return (\n <>\n <Divider textAlign=\"left\">{'Lifetime purchases'}</Divider>\n <Typography variant=\"h6\">\n {/*\n \"at least\", or nothing at all. This figure is summed over the order\n WINDOW, so once the probe finds an order past the ceiling it is a\n lower bound — and a lower bound printed as a lifetime is the number\n a support agent quotes back to the customer.\n */}\n {ordersUnreadable\n ? '—'\n : `${ordersTruncated ? 'at least ' : ''}${usd(lifetimeCents)}`}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Charged order totals minus refunds; pending and canceled ' +\n 'orders excluded.'}\n {ordersTruncated\n ? ` Summed over the ${ORDER_CEILING} orders read here; this ` +\n 'member has more.'\n : ''}\n </Typography>\n\n <Divider textAlign=\"left\">{'Orders'}</Divider>\n {ordersUnreadable ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Order history takes the \"See orders and webhooks\" permission on this site.'}\n </Typography>\n ) : orders.length === 0 ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No orders yet.'}\n </Typography>\n ) : (\n visibleOrders.map((order: any) => (\n <Stack key={order.$id} spacing={0}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1 }} noWrap>\n {`${orderNumber(order)} · ${usd(\n Number(order.totals?.totalCents ?? order.amountCents ?? 0) ||\n 0,\n )}`}\n </Typography>\n <Chip\n label={String(order.status ?? 'paid').replace('_', ' ')}\n size=\"small\"\n variant=\"outlined\"\n />\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {orderCreatedMs(order)\n ? new Date(orderCreatedMs(order)).toLocaleDateString()\n : '—'}\n {reversalSuffix(order)}\n </Typography>\n {order.paymentIntentId ? (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n sx={{ fontFamily: 'monospace' }}\n noWrap\n >\n {order.paymentIntentId}\n </Typography>\n ) : null}\n </Stack>\n ))\n )}\n {ordersUnreadable || orders.length === 0 ? null : (\n <ListPagination\n page={orderPage}\n pageSize={orderPageSize}\n rowCount={visibleOrders.length}\n // The orders held here — a slice of rows already read, so the\n // total is exact for the window. The lifetime caption above is\n // where the window's own shortfall is stated.\n count={orders.length}\n onPageChange={setOrderPage}\n onPageSizeChange={setOrderPageSize}\n />\n )}\n\n {subscriptions.length > 0 ? (\n <>\n <Divider textAlign=\"left\">{'Subscriptions'}</Divider>\n {visibleSubscriptions.map((subscription: any) => (\n <Stack\n key={subscription.$id}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {/*\n * The amount (AGL-1732). This row named the product and the\n * renewal date and stopped, and no other console surface\n * carried the figure either — orders, analytics and the CSV\n * all read `orders`, which a subscription sale does not\n * create. Subscriptions written before that fix have no\n * `totals`, so the amount is omitted rather than shown as\n * $0.00.\n */}\n {productNames[subscription.productId] ??\n subscription.productId ??\n 'Subscription'}\n {subscription.totals?.totalCents != null\n ? ` · ${usd(Number(subscription.totals.totalCents) || 0)}${\n subscription.interval ? `/${subscription.interval}` : ''\n }`\n : ''}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {subscription.currentPeriodEndMs\n ? `Renews ${new Date(\n Number(subscription.currentPeriodEndMs),\n ).toLocaleDateString()}`\n : '—'}\n {/*\n * What this subscriber has actually paid, across every cycle\n * (AGL-1743). Omitted, not shown as 0, for subscriptions\n * whose cycles all predate `invoice.payment_succeeded`\n * being handled: those invoices are recoverable only from\n * Stripe.\n */}\n {Number(subscription.invoicesCount ?? 0) > 0\n ? ` · ${usd(Number(subscription.paidCents) || 0)} paid over ${\n Number(subscription.invoicesCount) === 1\n ? '1 invoice'\n : `${Number(subscription.invoicesCount)} invoices`\n }`\n : ''}\n </Typography>\n </Stack>\n <Chip\n label={String(subscription.status ?? 'active')}\n size=\"small\"\n variant=\"outlined\"\n color={subscription.status === 'active' ? 'success' : 'default'}\n />\n </Stack>\n ))}\n <ListPagination\n page={subscriptionPage}\n pageSize={subscriptionPageSize}\n rowCount={visibleSubscriptions.length}\n // This member's subscriptions, in full for the window.\n count={subscriptions.length}\n onPageChange={setSubscriptionPage}\n onPageSizeChange={setSubscriptionPageSize}\n />\n {subscriptionsTruncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Showing ${SUBSCRIPTION_CEILING} subscriptions; this ` +\n 'member has more.'}\n </Typography>\n ) : null}\n </>\n ) : null}\n </>\n )\n}\nSiteMemberPurchases.displayName = 'SiteMemberPurchases'\n\nexport default SiteMemberPurchases\n"],"names":["ListPagination","TABLE_PAGE_SIZE_DEFAULT","ceilingedWindow","useFirestore","useFirestoreCollection","Chip","Divider","Stack","Typography","collection","documentId","limit","orderBy","query","where","useEffect","useMemo","useState","splitOrderReversal","computeLifetimePurchaseCents","usd","cents","toFixed","ORDER_CEILING","SUBSCRIPTION_CEILING","reversalSuffix","order","refundedCents","chargedBackCents","orderNumber","number","String","$id","slice","toUpperCase","orderCreatedMs","Number","createdAtMs","createdAt","seconds","SiteMemberPurchases","props","member","hostId","firestore","memberId","email","data","orderDocs","status","ordersStatus","idField","rows","readOrders","truncated","ordersTruncated","orders","sort","a","b","lifetimeCents","ordersUnreadable","length","subscriptionDocs","subscriptions","subscriptionsTruncated","productDocs","orderPage","setOrderPage","orderPageSize","setOrderPageSize","visibleOrders","subscriptionPage","setSubscriptionPage","subscriptionPageSize","setSubscriptionPageSize","visibleSubscriptions","productNames","map","product","name","textAlign","variant","color","spacing","direction","sx","alignItems","flex","noWrap","totals","totalCents","amountCents","label","replace","size","Date","toLocaleDateString","paymentIntentId","fontFamily","page","pageSize","rowCount","count","onPageChange","onPageSizeChange","subscription","minWidth","productId","interval","currentPeriodEndMs","invoicesCount","paidCents","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SAASA,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SACEC,eAAe,EACfC,YAAY,EACZC,sBAAsB,QACjB,iCAAgC;AACvC,SAASC,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AAChE,SACEC,UAAU,EACVC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,qBAAoB;AAC3B,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACpD,SAASC,kBAAkB,QAAQ,kCAA8B;AACjE,SAASC,4BAA4B,QAAQ,uCAAmC;AAEhF,MAAMC,MAAM,CAACC,QAAkB,CAAC,CAAC,EAAE,AAACA,CAAAA,QAAQ,GAAE,EAAGC,OAAO,CAAC,IAAI;AAE7D;;;;;;;CAOC,GACD,MAAMC,gBAAgB;AACtB,uDAAuD,GACvD,MAAMC,uBAAuB;AAE7B;;;;;;;CAOC,GACD,MAAMC,iBAAiB,CAACC;IACtB,MAAM,EAAEC,aAAa,EAAEC,gBAAgB,EAAE,GAAGV,mBAAmBQ;IAC/D,OACE,AAACC,CAAAA,gBAAgB,CAAC,YAAY,EAAEP,IAAIO,gBAAgB,GAAG,EAAC,IACvDC,CAAAA,mBAAmB,CAAC,gBAAgB,EAAER,IAAIQ,mBAAmB,GAAG,EAAC;AAEtE;AAEA,qEAAqE,GACrE,MAAMC,cAAc,CAACH;QAGJA;WA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GAAG;AAElC,eAAezE,oBAAmB"}
@@ -167,11 +167,11 @@ function TotalRow({ label, value, strong }) {
167
167
  };
168
168
  }
169
169
  if ((payload == null ? void 0 : payload.state) === 'replaced') {
170
- var _payload_storeName;
170
+ var _payload_storeName, _payload_noun;
171
171
  return {
172
172
  kind: 'replaced',
173
173
  storeName: String((_payload_storeName = payload.storeName) != null ? _payload_storeName : ''),
174
- noun: nounOf(payload.kind)
174
+ noun: String((_payload_noun = payload.noun) != null ? _payload_noun : nounOf(payload.kind))
175
175
  };
176
176
  }
177
177
  return {
@@ -400,7 +400,9 @@ function TotalRow({ label, value, strong }) {
400
400
  // The same signed link as the page's data; the server makes the PDF from the same view.
401
401
  const pdfHref = `/api/commerce/quote-pdf?hostId=${encodeURIComponent(hostId)}` + `&q=${encodeURIComponent(link.current.quoteId)}&t=${encodeURIComponent(link.current.token)}`;
402
402
  const unpaid = quote.status === 'unpaid';
403
- const noun = nounOf(quote.kind);
403
+ // A proof with no price yet (AGL-4184): the proof and its answer, and nothing about money.
404
+ const proofOnly = quote.proofOnly === true;
405
+ const noun = proofOnly ? 'proof' : nounOf(quote.kind);
404
406
  const later = addedAtPayment(quote);
405
407
  const addresses = [
406
408
  quote.customerName || quote.company ? {
@@ -480,9 +482,9 @@ function TotalRow({ label, value, strong }) {
480
482
  /*#__PURE__*/ _jsx(Typography, {
481
483
  variant: "h4",
482
484
  component: "h1",
483
- children: quote.kind !== 'invoice' && heading || quote.number
485
+ children: quote.kind !== 'invoice' && !proofOnly && heading || quote.number
484
486
  }),
485
- /*#__PURE__*/ _jsx(Chip, {
487
+ proofOnly ? null : /*#__PURE__*/ _jsx(Chip, {
486
488
  label: quote.statusLabel,
487
489
  color: quote.status === 'paid' ? 'success' : unpaid ? 'primary' : 'default',
488
490
  size: "small"
@@ -494,7 +496,7 @@ function TotalRow({ label, value, strong }) {
494
496
  color: "text.secondary",
495
497
  children: `Dated ${dateLabel(quote.dateMs)}`
496
498
  }) : null,
497
- /*#__PURE__*/ _jsx(Box, {
499
+ proofOnly ? null : /*#__PURE__*/ _jsx(Box, {
498
500
  children: /*#__PURE__*/ _jsx(Button, {
499
501
  variant: "outlined",
500
502
  size: "small",
@@ -519,7 +521,7 @@ function TotalRow({ label, value, strong }) {
519
521
  lines: block.lines
520
522
  }, block.label))
521
523
  }) : null,
522
- /*#__PURE__*/ _jsxs(Stack, {
524
+ proofOnly ? null : /*#__PURE__*/ _jsxs(Stack, {
523
525
  spacing: 1.5,
524
526
  children: [
525
527
  /*#__PURE__*/ _jsx(Typography, {
@@ -621,6 +623,10 @@ function TotalRow({ label, value, strong }) {
621
623
  })
622
624
  ]
623
625
  }) : null,
626
+ proofOnly && !quote.proofs.length ? /*#__PURE__*/ _jsx(Alert, {
627
+ severity: "info",
628
+ children: `${quote.storeName || 'The business'} is working on the next version of your proof, and will send it when it’s ready.`
629
+ }) : null,
624
630
  /*#__PURE__*/ _jsx(QuoteProofPanel, {
625
631
  view: quote,
626
632
  hostId: hostId,
@@ -638,7 +644,7 @@ function TotalRow({ label, value, strong }) {
638
644
  noun
639
645
  })
640
646
  }),
641
- unpaid ? /*#__PURE__*/ _jsx(Paper, {
647
+ proofOnly ? null : unpaid ? /*#__PURE__*/ _jsx(Paper, {
642
648
  variant: "outlined",
643
649
  sx: {
644
650
  p: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/quote-page-body.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\nimport * as Aglyn from '@aglyn/aglyn'\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Chip from '@mui/material/Chip'\nimport CircularProgress from '@mui/material/CircularProgress'\nimport Divider from '@mui/material/Divider'\nimport Paper from '@mui/material/Paper'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport type { StripeCheckoutContact } from '@stripe/stripe-js'\nimport { forwardRef, lazy, Suspense, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n formatOrderMoney,\n readStorefrontCheckoutWallets,\n type QuotePageAddress,\n type QuotePageView,\n type StorefrontCheckoutWallets,\n} from '../model'\nimport type { QuotePageProps } from './quote-page'\nimport { QuoteProofPanel } from './quote-proof-panel'\nimport { StorefrontPaymentElementFallback } from './storefront-payment-element-fallback'\n\n/** The Payment Element, lazily: Stripe.js loads only when a customer presses Pay. */\nconst StorefrontPaymentElement = lazy(() =>\n import('./storefront-payment-element').then((module) => ({\n default: module.StorefrontPaymentElement,\n })),\n)\n\ntype LoadState =\n | { kind: 'loading' }\n | { kind: 'missing'; message: string }\n | { kind: 'replaced'; storeName: string; noun: string }\n | { kind: 'ready'; view: QuotePageView }\n\n/** `quote` or `invoice`, as the page says it (AGL-4099). */\nconst nounOf = (kind: unknown) => (kind === 'invoice' ? 'invoice' : 'quote')\n\n/** What is added when the customer pays: `shipping`, `tax`, `shipping and tax`, or nothing. */\nfunction addedAtPayment(view: Pick<QuotePageView, 'shippingAtPayment' | 'taxAtPayment'>): string {\n if (view.shippingAtPayment && view.taxAtPayment) return 'shipping and tax'\n if (view.shippingAtPayment) return 'shipping'\n return view.taxAtPayment ? 'tax' : ''\n}\n\n/** After a payment returns here, how often and how long the page asks whether it landed. */\nconst CONFIRM_POLL_MS = 2_000\nconst CONFIRM_POLLS = 15\n\nfunction dateLabel(atMs: number | null): string {\n if (!atMs) return ''\n return new Date(atMs).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\nfunction addressLines(address: QuotePageAddress): string[] {\n const cityLine = [address.city, [address.state, address.postalCode].filter(Boolean).join(' ')]\n .filter(Boolean)\n .join(', ')\n return [address.name, address.line1, address.line2, cityLine, address.country].filter(\n (line): line is string => Boolean(line),\n )\n}\n\nfunction stripeContact(address: QuotePageAddress | null): StripeCheckoutContact | undefined {\n if (!address?.country) return undefined\n return {\n name: address.name,\n address: {\n country: address.country,\n line1: address.line1,\n line2: address.line2,\n city: address.city,\n state: address.state,\n postal_code: address.postalCode,\n },\n }\n}\n\nfunction AddressBlock({ label, lines }: { label: string; lines: string[] }) {\n return (\n <Stack spacing={0.25} sx={{ minWidth: 0, flex: 1 }}>\n <Typography variant=\"overline\" color=\"text.secondary\">\n {label}\n </Typography>\n {lines.map((line, index) => (\n <Typography key={index} variant=\"body2\">\n {line}\n </Typography>\n ))}\n </Stack>\n )\n}\n\nfunction TotalRow({ label, value, strong }: { label: string; value: string; strong?: boolean }) {\n return (\n <Stack direction=\"row\" spacing={2} sx={{ justifyContent: 'space-between' }}>\n <Typography variant={strong ? 'subtitle1' : 'body2'} color={strong ? 'text.primary' : 'text.secondary'}>\n {label}\n </Typography>\n <Typography variant={strong ? 'subtitle1' : 'body2'} color={strong ? 'text.primary' : 'text.secondary'}>\n {value}\n </Typography>\n </Stack>\n )\n}\n\n/**\n * The customer's quote page (AGL-4094), loaded when the page draws it (see\n * `quote-page.tsx`): what a customer sees when they open\n * the pay link a business sent them. The commerce page resolver serves it at\n * `/pay-quote` inside the site's own header and footer; a business can also\n * place it on a page of their own design at that address.\n *\n * The quote is read AFTER hydration from `?q=&t=`, so the page itself is the\n * same for every customer and may be cached, and the quote never is. Pay asks\n * the server for a fresh payment for the quote as the page shows it: Stripe's\n * own page, or the payment form here when in-page payments are on. Nothing\n * here decides a quote is paid; after paying, the page reads that from the\n * server like any other visit.\n */\nconst QuotePageBody = forwardRef<HTMLDivElement, QuotePageProps>((props, ref) => {\n const { heading, ...rest } = props\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const { hostId } = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const [state, setState] = useState<LoadState>({ kind: 'loading' })\n const [paying, setPaying] = useState(false)\n const [payError, setPayError] = useState('')\n const [nativeCheckout, setNativeCheckout] = useState<{\n clientSecret: string\n publishableKey: string\n wallets?: StorefrontCheckoutWallets\n } | null>(null)\n /** What a return from paying turned out to be: still being confirmed, or not paid. */\n const [returned, setReturned] = useState<'confirming' | 'unconfirmed' | 'failed' | null>(null)\n const link = useRef({ quoteId: '', token: '', sessionId: '' })\n\n const load = useCallback(async (): Promise<LoadState> => {\n const { quoteId, token } = link.current\n try {\n const response = await siteFetch(\n `/api/commerce/quote-view?hostId=${encodeURIComponent(hostId ?? '')}` +\n `&q=${encodeURIComponent(quoteId)}&t=${encodeURIComponent(token)}`,\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return { kind: 'missing', message: String(payload?.error ?? 'We could not find that quote or invoice.') }\n }\n if (payload?.state === 'replaced') {\n return { kind: 'replaced', storeName: String(payload.storeName ?? ''), noun: nounOf(payload.kind) }\n }\n return { kind: 'ready', view: payload as QuotePageView }\n } catch {\n return { kind: 'missing', message: 'This page could not be loaded. Check your connection and try again.' }\n }\n }, [hostId, siteFetch])\n\n useEffect(() => {\n if (!hostId) return\n const params = new URLSearchParams(window.location.search)\n link.current = {\n quoteId: params.get('q') ?? '',\n token: params.get('t') ?? '',\n sessionId: params.get('session_id') ?? '',\n }\n if (!link.current.quoteId || !link.current.token) {\n setState({ kind: 'missing', message: 'Open this page from the link you were sent with your quote or invoice.' })\n return\n }\n let live = true\n void (async () => {\n const first = await load()\n if (!live) return\n setState(first)\n const sessionId = link.current.sessionId\n if (first.kind !== 'ready' || first.view.status !== 'unpaid' || !sessionId) return\n // Back from paying: the payment may have landed before the record of it.\n const status = await siteFetch(\n `/api/commerce/checkout-status?hostId=${encodeURIComponent(hostId)}` +\n `&sessionId=${encodeURIComponent(sessionId)}`,\n )\n .then((response) => (response.ok ? response.json() : null))\n .catch(() => null)\n if (!live) return\n if (status?.status === 'open') {\n setReturned('failed')\n return\n }\n if (status?.status !== 'complete') return\n setReturned('confirming')\n for (let poll = 0; poll < CONFIRM_POLLS && live; poll++) {\n await new Promise((resolve) => setTimeout(resolve, CONFIRM_POLL_MS))\n if (!live) return\n const next = await load()\n if (!live) return\n if (next.kind === 'ready' && next.view.status !== 'unpaid') {\n setState(next)\n setReturned(null)\n return\n }\n }\n if (live) setReturned('unconfirmed')\n })()\n return () => {\n live = false\n }\n }, [hostId, load, siteFetch])\n\n const view = state.kind === 'ready' ? state.view : null\n\n const pay = useCallback(async () => {\n if (!view || paying) return\n setPaying(true)\n setPayError('')\n setReturned(null)\n // One key per press: a press is one attempt, and a retry after a failure is a new one.\n const attemptKey =\n globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n try {\n const response = await siteFetch('/api/commerce/quote-pay', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey },\n body: JSON.stringify({\n hostId,\n q: link.current.quoteId,\n t: link.current.token,\n v: view.version,\n // The tax the page priced it under; a quote whose tax moved since is shown again.\n ...(view.taxKey ? { tax: view.taxKey } : {}),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n // A session with a client secret is the in-page form; checked before the\n // redirect, so a form is never navigated away from.\n if (response.ok && payload?.clientSecret && payload?.publishableKey) {\n setNativeCheckout({\n clientSecret: String(payload.clientSecret),\n publishableKey: String(payload.publishableKey),\n wallets: readStorefrontCheckoutWallets(payload.wallets),\n })\n setPaying(false)\n return\n }\n if (response.ok && payload?.url) {\n window.location.assign(String(payload.url))\n return\n }\n if (payload?.replaced) {\n setState({ kind: 'replaced', storeName: view.storeName, noun: nounOf(view.kind) })\n return\n }\n if (payload?.reason === 'paid' || payload?.reason === 'updated') {\n const next = await load()\n setState(next)\n }\n setPayError(String(payload?.error ?? 'Your payment could not be set up. Try again.'))\n setPaying(false)\n } catch {\n setPayError('Your payment could not be set up. Check your connection and try again.')\n setPaying(false)\n }\n }, [view, paying, siteFetch, hostId, load])\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[{ p: 3, border: '1px dashed', borderColor: 'divider', borderRadius: 1 }, ...nodeSx]}\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Quote — a customer’s quote and its Pay button render here'}\n </Typography>\n </Box>\n )\n }\n\n if (state.kind === 'loading') {\n return (\n <Box ref={ref} {...rest} sx={[{ py: 6, textAlign: 'center' }, ...nodeSx]}>\n <CircularProgress size={28} aria-label=\"Loading\" />\n </Box>\n )\n }\n\n if (state.kind === 'missing') {\n return (\n <Box ref={ref} {...rest} sx={nodeSx}>\n <Stack spacing={2}>\n <Typography variant=\"h4\" component=\"h1\">\n {heading || 'Your quote or invoice'}\n </Typography>\n <Alert severity=\"info\">{state.message}</Alert>\n </Stack>\n </Box>\n )\n }\n\n if (state.kind === 'replaced') {\n const business = state.storeName || 'The business'\n return (\n <Box ref={ref} {...rest} sx={nodeSx}>\n <Stack spacing={2}>\n {state.storeName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {state.storeName}\n </Typography>\n ) : null}\n <Typography variant=\"h4\" component=\"h1\">\n {`This ${state.noun} was updated`}\n </Typography>\n <Typography variant=\"body1\" color=\"text.secondary\">\n {`${business} updated this ${state.noun} and sent you a newer link. Open their most recent message to see it.`}\n </Typography>\n </Stack>\n </Box>\n )\n }\n\n const quote = state.view\n const money = (cents: number) => formatOrderMoney(cents, quote.currency)\n // The same signed link as the page's data; the server makes the PDF from the same view.\n const pdfHref =\n `/api/commerce/quote-pdf?hostId=${encodeURIComponent(hostId)}` +\n `&q=${encodeURIComponent(link.current.quoteId)}&t=${encodeURIComponent(link.current.token)}`\n const unpaid = quote.status === 'unpaid'\n const noun = nounOf(quote.kind)\n const later = addedAtPayment(quote)\n const addresses = [\n quote.customerName || quote.company\n ? { label: 'Prepared for', lines: [quote.customerName, quote.company].filter((line): line is string => Boolean(line)) }\n : null,\n quote.billTo ? { label: 'Bill to', lines: addressLines(quote.billTo) } : null,\n quote.shipTo ? { label: 'Ship to', lines: addressLines(quote.shipTo) } : null,\n ].filter((block): block is { label: string; lines: string[] } => Boolean(block && block.lines.length))\n const totalRows = (\n [\n ['Subtotal', money(quote.totals.itemsCents), true],\n [\n quote.discountLabel ? `Discount (${quote.discountLabel})` : 'Discount',\n `−${money(quote.totals.discountCents)}`,\n quote.totals.discountCents > 0,\n ],\n ['Shipping', money(quote.totals.shippingCents), quote.totals.shippingCents > 0],\n [quote.taxLabel, money(quote.totals.taxCents), quote.totals.taxCents > 0],\n // The rate an invoiced draft's customer picks when they pay (AGL-4099).\n ['Shipping is chosen when you pay', '', quote.shippingAtPayment === true],\n // `Tax is added at payment`, with no figure: Stripe works it out from the address.\n [quote.taxLabel, '', quote.taxAtPayment],\n ] as Array<[string, string, boolean]>\n ).filter(([, , shown]) => shown)\n\n return (\n <Box ref={ref} {...rest} sx={nodeSx}>\n <Stack spacing={3}>\n <Stack spacing={1}>\n {quote.storeName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {quote.storeName}\n </Typography>\n ) : null}\n <Stack direction=\"row\" spacing={1.5} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <Typography variant=\"h4\" component=\"h1\">\n {/* The element's own heading is a quote's; an invoice always says its number. */}\n {(quote.kind !== 'invoice' && heading) || quote.number}\n </Typography>\n <Chip\n label={quote.statusLabel}\n color={quote.status === 'paid' ? 'success' : unpaid ? 'primary' : 'default'}\n size=\"small\"\n />\n </Stack>\n {quote.dateMs ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Dated ${dateLabel(quote.dateMs)}`}\n </Typography>\n ) : null}\n <Box>\n <Button variant=\"outlined\" size=\"small\" href={pdfHref} download>\n {'Download PDF'}\n </Button>\n </Box>\n </Stack>\n\n {addresses.length ? (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={{ xs: 2, sm: 3 }}>\n {addresses.map((block) => (\n <AddressBlock key={block.label} label={block.label} lines={block.lines} />\n ))}\n </Stack>\n ) : null}\n\n <Stack spacing={1.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {'Items'}\n </Typography>\n {quote.lines.map((line, index) => (\n <Stack key={index} direction=\"row\" spacing={2} sx={{ justifyContent: 'space-between' }}>\n <Stack spacing={0.25} sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\">\n {line.name}\n {line.variantLabel ? ` (${line.variantLabel})` : ''}\n </Typography>\n {line.description ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ whiteSpace: 'pre-line' }}>\n {line.description}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {[\n line.included ? `${line.quantity} included` : `${line.quantity} × ${money(line.unitAmountCents)}`,\n line.sku ? `SKU ${line.sku}` : '',\n ]\n .filter(Boolean)\n .join(' · ')}\n </Typography>\n </Stack>\n <Typography variant=\"body2\" sx={{ flexShrink: 0 }}>\n {line.included ? 'Included' : money(line.amountCents)}\n </Typography>\n </Stack>\n ))}\n <Divider />\n {totalRows.map(([label, value]) => (\n <TotalRow key={`${label}-${value}`} label={label} value={value} />\n ))}\n <TotalRow label=\"Total\" value={money(quote.totals.totalCents)} strong />\n </Stack>\n\n {quote.notes ? (\n <Stack spacing={0.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {'Notes'}\n </Typography>\n <Typography variant=\"body2\" sx={{ whiteSpace: 'pre-line' }}>\n {quote.notes}\n </Typography>\n </Stack>\n ) : null}\n {quote.terms ? (\n <Stack spacing={0.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {'Terms'}\n </Typography>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ whiteSpace: 'pre-line' }}>\n {quote.terms}\n </Typography>\n </Stack>\n ) : null}\n\n <QuoteProofPanel\n view={quote}\n hostId={hostId}\n quoteId={link.current.quoteId}\n token={link.current.token}\n siteFetch={siteFetch}\n onView={(next) => setState({ kind: 'ready', view: next })}\n onReload={() => void load().then(setState)}\n onReplaced={() => setState({ kind: 'replaced', storeName: quote.storeName, noun })}\n />\n\n {unpaid ? (\n <Paper variant=\"outlined\" sx={{ p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {returned === 'confirming' ? (\n <Alert severity=\"info\" icon={<CircularProgress size={20} />}>\n {'Thank you. We’re confirming your payment.'}\n </Alert>\n ) : returned === 'unconfirmed' ? (\n <Alert severity=\"info\">\n {'Your payment is still being confirmed. Your receipt will arrive by email.'}\n </Alert>\n ) : quote.approvalRequired ? (\n <Alert severity=\"info\">\n {`${quote.storeName || 'The business'} asks you to approve the proof before you pay.`}\n </Alert>\n ) : quote.payable ? (\n <>\n {returned === 'failed' ? (\n <Alert severity=\"warning\">{'Your payment did not go through. Nothing was charged.'}</Alert>\n ) : null}\n {nativeCheckout ? (\n <Suspense fallback={<StorefrontPaymentElementFallback />}>\n <StorefrontPaymentElement\n clientSecret={nativeCheckout.clientSecret}\n publishableKey={nativeCheckout.publishableKey}\n wallets={nativeCheckout.wallets}\n payLabel={later ? 'Pay now' : `Pay ${money(quote.totals.totalCents)}`}\n defaultShippingAddress={stripeContact(quote.shipTo)}\n // An expired or unloadable session is replaced by a new press.\n onRestart={() => {\n setNativeCheckout(null)\n void pay()\n }}\n onCancel={() => setNativeCheckout(null)}\n />\n </Suspense>\n ) : (\n <Button\n variant=\"contained\"\n size=\"large\"\n onClick={() => void pay()}\n disabled={paying}\n sx={{ alignSelf: { xs: 'stretch', sm: 'flex-start' } }}\n >\n {paying\n ? 'Opening…'\n : later\n ? `Pay ${money(quote.totals.totalCents)} plus ${later}`\n : `Pay ${money(quote.totals.totalCents)}`}\n </Button>\n )}\n {payError ? <Alert severity=\"error\">{payError}</Alert> : null}\n </>\n ) : (\n <Alert severity=\"info\">\n {quote.notPayableMessage || `Contact ${quote.storeName || 'the business'} to pay this ${noun}.`}\n </Alert>\n )}\n </Stack>\n </Paper>\n ) : (\n <Paper variant=\"outlined\" sx={{ p: { xs: 2, sm: 3 } }}>\n <Stack spacing={1.5} sx={{ alignItems: 'flex-start' }}>\n <Typography variant=\"body1\">\n {quote.status === 'paid'\n ? quote.paidAtMs\n ? `Paid ${dateLabel(quote.paidAtMs)}. Thank you.`\n : 'Paid. Thank you.'\n : `This ${noun} is ${quote.statusLabel.toLowerCase()}.`}\n </Typography>\n {quote.receiptUrl ? (\n <Button variant=\"outlined\" href={quote.receiptUrl}>\n {'View your order'}\n </Button>\n ) : null}\n </Stack>\n </Paper>\n )}\n\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Questions about this ${noun}? Contact ${quote.storeName || 'the business'}.`}\n </Typography>\n </Stack>\n </Box>\n )\n})\nQuotePageBody.displayName = 'QuotePageBody'\n\nexport default QuotePageBody\n\n"],"names":["Aglyn","Alert","Box","Button","Chip","CircularProgress","Divider","Paper","Stack","Typography","forwardRef","lazy","Suspense","useCallback","useEffect","useRef","useState","formatOrderMoney","readStorefrontCheckoutWallets","QuoteProofPanel","StorefrontPaymentElementFallback","StorefrontPaymentElement","then","module","default","nounOf","kind","addedAtPayment","view","shippingAtPayment","taxAtPayment","CONFIRM_POLL_MS","CONFIRM_POLLS","dateLabel","atMs","Date","toLocaleDateString","undefined","month","day","year","addressLines","address","cityLine","city","state","postalCode","filter","Boolean","join","name","line1","line2","country","line","stripeContact","postal_code","AddressBlock","label","lines","spacing","sx","minWidth","flex","variant","color","map","index","TotalRow","value","strong","direction","justifyContent","QuotePageBody","props","ref","heading","rest","nodeSx","Array","isArray","hostId","useSite","siteFetch","useSiteFetch","setState","paying","setPaying","payError","setPayError","nativeCheckout","setNativeCheckout","returned","setReturned","link","quoteId","token","sessionId","load","current","response","encodeURIComponent","payload","json","catch","ok","message","String","error","storeName","noun","params","URLSearchParams","window","location","search","get","live","first","status","poll","Promise","resolve","setTimeout","next","pay","globalThis","attemptKey","crypto","randomUUID","now","Math","random","toString","slice","method","headers","body","JSON","stringify","q","t","v","version","taxKey","tax","clientSecret","publishableKey","wallets","url","assign","replaced","reason","p","border","borderColor","borderRadius","py","textAlign","size","aria-label","component","severity","business","quote","money","cents","currency","pdfHref","unpaid","later","addresses","customerName","company","billTo","shipTo","block","length","totalRows","totals","itemsCents","discountLabel","discountCents","shippingCents","taxLabel","taxCents","shown","alignItems","flexWrap","rowGap","number","statusLabel","dateMs","href","download","xs","sm","variantLabel","description","whiteSpace","included","quantity","unitAmountCents","sku","flexShrink","amountCents","totalCents","notes","terms","onView","onReload","onReplaced","icon","approvalRequired","payable","fallback","payLabel","defaultShippingAddress","onRestart","onCancel","onClick","disabled","alignSelf","notPayableMessage","paidAtMs","toLowerCase","receiptUrl","displayName"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,sBAAsB,iCAAgC;AAC7D,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,gBAAgB,2BAA0B;AAEjD,SAASC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAC5F,SACEC,gBAAgB,EAChBC,6BAA6B,QAIxB,oBAAU;AAEjB,SAASC,eAAe,QAAQ,yBAAqB;AACrD,SAASC,gCAAgC,QAAQ,2CAAuC;AAExF,mFAAmF,GACnF,MAAMC,yCAA2BV,KAAK,IACpC,MAAM,CAAC,mCAAgCW,IAAI,CAAC,CAACC,SAAY,CAAA;YACvDC,SAASD,OAAOF,wBAAwB;QAC1C,CAAA;AASF,0DAA0D,GAC1D,MAAMI,SAAS,CAACC,OAAmBA,SAAS,YAAY,YAAY;AAEpE,6FAA6F,GAC7F,SAASC,eAAeC,IAA+D;IACrF,IAAIA,KAA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,SAAS,IAAI,eAAe,CAAC,CAAC;;;;;AAKxF;AACApC,cAAc0J,WAAW,GAAG;AAE5B,eAAe1J,cAAa"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/components/quote-page-body.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\nimport * as Aglyn from '@aglyn/aglyn'\nimport Alert from '@mui/material/Alert'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Chip from '@mui/material/Chip'\nimport CircularProgress from '@mui/material/CircularProgress'\nimport Divider from '@mui/material/Divider'\nimport Paper from '@mui/material/Paper'\nimport Stack from '@mui/material/Stack'\nimport Typography from '@mui/material/Typography'\nimport type { StripeCheckoutContact } from '@stripe/stripe-js'\nimport { forwardRef, lazy, Suspense, useCallback, useEffect, useRef, useState } from 'react'\nimport {\n formatOrderMoney,\n readStorefrontCheckoutWallets,\n type QuotePageAddress,\n type QuotePageView,\n type StorefrontCheckoutWallets,\n} from '../model'\nimport type { QuotePageProps } from './quote-page'\nimport { QuoteProofPanel } from './quote-proof-panel'\nimport { StorefrontPaymentElementFallback } from './storefront-payment-element-fallback'\n\n/** The Payment Element, lazily: Stripe.js loads only when a customer presses Pay. */\nconst StorefrontPaymentElement = lazy(() =>\n import('./storefront-payment-element').then((module) => ({\n default: module.StorefrontPaymentElement,\n })),\n)\n\ntype LoadState =\n | { kind: 'loading' }\n | { kind: 'missing'; message: string }\n | { kind: 'replaced'; storeName: string; noun: string }\n | { kind: 'ready'; view: QuotePageView }\n\n/** `quote` or `invoice`, as the page says it (AGL-4099). */\nconst nounOf = (kind: unknown) => (kind === 'invoice' ? 'invoice' : 'quote')\n\n/** What is added when the customer pays: `shipping`, `tax`, `shipping and tax`, or nothing. */\nfunction addedAtPayment(view: Pick<QuotePageView, 'shippingAtPayment' | 'taxAtPayment'>): string {\n if (view.shippingAtPayment && view.taxAtPayment) return 'shipping and tax'\n if (view.shippingAtPayment) return 'shipping'\n return view.taxAtPayment ? 'tax' : ''\n}\n\n/** After a payment returns here, how often and how long the page asks whether it landed. */\nconst CONFIRM_POLL_MS = 2_000\nconst CONFIRM_POLLS = 15\n\nfunction dateLabel(atMs: number | null): string {\n if (!atMs) return ''\n return new Date(atMs).toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\nfunction addressLines(address: QuotePageAddress): string[] {\n const cityLine = [address.city, [address.state, address.postalCode].filter(Boolean).join(' ')]\n .filter(Boolean)\n .join(', ')\n return [address.name, address.line1, address.line2, cityLine, address.country].filter(\n (line): line is string => Boolean(line),\n )\n}\n\nfunction stripeContact(address: QuotePageAddress | null): StripeCheckoutContact | undefined {\n if (!address?.country) return undefined\n return {\n name: address.name,\n address: {\n country: address.country,\n line1: address.line1,\n line2: address.line2,\n city: address.city,\n state: address.state,\n postal_code: address.postalCode,\n },\n }\n}\n\nfunction AddressBlock({ label, lines }: { label: string; lines: string[] }) {\n return (\n <Stack spacing={0.25} sx={{ minWidth: 0, flex: 1 }}>\n <Typography variant=\"overline\" color=\"text.secondary\">\n {label}\n </Typography>\n {lines.map((line, index) => (\n <Typography key={index} variant=\"body2\">\n {line}\n </Typography>\n ))}\n </Stack>\n )\n}\n\nfunction TotalRow({ label, value, strong }: { label: string; value: string; strong?: boolean }) {\n return (\n <Stack direction=\"row\" spacing={2} sx={{ justifyContent: 'space-between' }}>\n <Typography variant={strong ? 'subtitle1' : 'body2'} color={strong ? 'text.primary' : 'text.secondary'}>\n {label}\n </Typography>\n <Typography variant={strong ? 'subtitle1' : 'body2'} color={strong ? 'text.primary' : 'text.secondary'}>\n {value}\n </Typography>\n </Stack>\n )\n}\n\n/**\n * The customer's quote page (AGL-4094), loaded when the page draws it (see\n * `quote-page.tsx`): what a customer sees when they open\n * the pay link a business sent them. The commerce page resolver serves it at\n * `/pay-quote` inside the site's own header and footer; a business can also\n * place it on a page of their own design at that address.\n *\n * The quote is read AFTER hydration from `?q=&t=`, so the page itself is the\n * same for every customer and may be cached, and the quote never is. Pay asks\n * the server for a fresh payment for the quote as the page shows it: Stripe's\n * own page, or the payment form here when in-page payments are on. Nothing\n * here decides a quote is paid; after paying, the page reads that from the\n * server like any other visit.\n */\nconst QuotePageBody = forwardRef<HTMLDivElement, QuotePageProps>((props, ref) => {\n const { heading, ...rest } = props\n const nodeSx = Array.isArray(props['sx']) ? props['sx'] : [props['sx']]\n const { hostId } = Aglyn.useSite()\n const siteFetch = Aglyn.useSiteFetch()\n const [state, setState] = useState<LoadState>({ kind: 'loading' })\n const [paying, setPaying] = useState(false)\n const [payError, setPayError] = useState('')\n const [nativeCheckout, setNativeCheckout] = useState<{\n clientSecret: string\n publishableKey: string\n wallets?: StorefrontCheckoutWallets\n } | null>(null)\n /** What a return from paying turned out to be: still being confirmed, or not paid. */\n const [returned, setReturned] = useState<'confirming' | 'unconfirmed' | 'failed' | null>(null)\n const link = useRef({ quoteId: '', token: '', sessionId: '' })\n\n const load = useCallback(async (): Promise<LoadState> => {\n const { quoteId, token } = link.current\n try {\n const response = await siteFetch(\n `/api/commerce/quote-view?hostId=${encodeURIComponent(hostId ?? '')}` +\n `&q=${encodeURIComponent(quoteId)}&t=${encodeURIComponent(token)}`,\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n return { kind: 'missing', message: String(payload?.error ?? 'We could not find that quote or invoice.') }\n }\n if (payload?.state === 'replaced') {\n return { kind: 'replaced', storeName: String(payload.storeName ?? ''), noun: String(payload.noun ?? nounOf(payload.kind)) }\n }\n return { kind: 'ready', view: payload as QuotePageView }\n } catch {\n return { kind: 'missing', message: 'This page could not be loaded. Check your connection and try again.' }\n }\n }, [hostId, siteFetch])\n\n useEffect(() => {\n if (!hostId) return\n const params = new URLSearchParams(window.location.search)\n link.current = {\n quoteId: params.get('q') ?? '',\n token: params.get('t') ?? '',\n sessionId: params.get('session_id') ?? '',\n }\n if (!link.current.quoteId || !link.current.token) {\n setState({ kind: 'missing', message: 'Open this page from the link you were sent with your quote or invoice.' })\n return\n }\n let live = true\n void (async () => {\n const first = await load()\n if (!live) return\n setState(first)\n const sessionId = link.current.sessionId\n if (first.kind !== 'ready' || first.view.status !== 'unpaid' || !sessionId) return\n // Back from paying: the payment may have landed before the record of it.\n const status = await siteFetch(\n `/api/commerce/checkout-status?hostId=${encodeURIComponent(hostId)}` +\n `&sessionId=${encodeURIComponent(sessionId)}`,\n )\n .then((response) => (response.ok ? response.json() : null))\n .catch(() => null)\n if (!live) return\n if (status?.status === 'open') {\n setReturned('failed')\n return\n }\n if (status?.status !== 'complete') return\n setReturned('confirming')\n for (let poll = 0; poll < CONFIRM_POLLS && live; poll++) {\n await new Promise((resolve) => setTimeout(resolve, CONFIRM_POLL_MS))\n if (!live) return\n const next = await load()\n if (!live) return\n if (next.kind === 'ready' && next.view.status !== 'unpaid') {\n setState(next)\n setReturned(null)\n return\n }\n }\n if (live) setReturned('unconfirmed')\n })()\n return () => {\n live = false\n }\n }, [hostId, load, siteFetch])\n\n const view = state.kind === 'ready' ? state.view : null\n\n const pay = useCallback(async () => {\n if (!view || paying) return\n setPaying(true)\n setPayError('')\n setReturned(null)\n // One key per press: a press is one attempt, and a retry after a failure is a new one.\n const attemptKey =\n globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n try {\n const response = await siteFetch('/api/commerce/quote-pay', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'Idempotency-Key': attemptKey },\n body: JSON.stringify({\n hostId,\n q: link.current.quoteId,\n t: link.current.token,\n v: view.version,\n // The tax the page priced it under; a quote whose tax moved since is shown again.\n ...(view.taxKey ? { tax: view.taxKey } : {}),\n }),\n })\n const payload = await response.json().catch(() => ({}))\n // A session with a client secret is the in-page form; checked before the\n // redirect, so a form is never navigated away from.\n if (response.ok && payload?.clientSecret && payload?.publishableKey) {\n setNativeCheckout({\n clientSecret: String(payload.clientSecret),\n publishableKey: String(payload.publishableKey),\n wallets: readStorefrontCheckoutWallets(payload.wallets),\n })\n setPaying(false)\n return\n }\n if (response.ok && payload?.url) {\n window.location.assign(String(payload.url))\n return\n }\n if (payload?.replaced) {\n setState({ kind: 'replaced', storeName: view.storeName, noun: nounOf(view.kind) })\n return\n }\n if (payload?.reason === 'paid' || payload?.reason === 'updated') {\n const next = await load()\n setState(next)\n }\n setPayError(String(payload?.error ?? 'Your payment could not be set up. Try again.'))\n setPaying(false)\n } catch {\n setPayError('Your payment could not be set up. Check your connection and try again.')\n setPaying(false)\n }\n }, [view, paying, siteFetch, hostId, load])\n\n if (!hostId) {\n return (\n <Box\n ref={ref}\n {...rest}\n sx={[{ p: 3, border: '1px dashed', borderColor: 'divider', borderRadius: 1 }, ...nodeSx]}\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Quote — a customer’s quote and its Pay button render here'}\n </Typography>\n </Box>\n )\n }\n\n if (state.kind === 'loading') {\n return (\n <Box ref={ref} {...rest} sx={[{ py: 6, textAlign: 'center' }, ...nodeSx]}>\n <CircularProgress size={28} aria-label=\"Loading\" />\n </Box>\n )\n }\n\n if (state.kind === 'missing') {\n return (\n <Box ref={ref} {...rest} sx={nodeSx}>\n <Stack spacing={2}>\n <Typography variant=\"h4\" component=\"h1\">\n {heading || 'Your quote or invoice'}\n </Typography>\n <Alert severity=\"info\">{state.message}</Alert>\n </Stack>\n </Box>\n )\n }\n\n if (state.kind === 'replaced') {\n const business = state.storeName || 'The business'\n return (\n <Box ref={ref} {...rest} sx={nodeSx}>\n <Stack spacing={2}>\n {state.storeName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {state.storeName}\n </Typography>\n ) : null}\n <Typography variant=\"h4\" component=\"h1\">\n {`This ${state.noun} was updated`}\n </Typography>\n <Typography variant=\"body1\" color=\"text.secondary\">\n {`${business} updated this ${state.noun} and sent you a newer link. Open their most recent message to see it.`}\n </Typography>\n </Stack>\n </Box>\n )\n }\n\n const quote = state.view\n const money = (cents: number) => formatOrderMoney(cents, quote.currency)\n // The same signed link as the page's data; the server makes the PDF from the same view.\n const pdfHref =\n `/api/commerce/quote-pdf?hostId=${encodeURIComponent(hostId)}` +\n `&q=${encodeURIComponent(link.current.quoteId)}&t=${encodeURIComponent(link.current.token)}`\n const unpaid = quote.status === 'unpaid'\n // A proof with no price yet (AGL-4184): the proof and its answer, and nothing about money.\n const proofOnly = quote.proofOnly === true\n const noun = proofOnly ? 'proof' : nounOf(quote.kind)\n const later = addedAtPayment(quote)\n const addresses = [\n quote.customerName || quote.company\n ? { label: 'Prepared for', lines: [quote.customerName, quote.company].filter((line): line is string => Boolean(line)) }\n : null,\n quote.billTo ? { label: 'Bill to', lines: addressLines(quote.billTo) } : null,\n quote.shipTo ? { label: 'Ship to', lines: addressLines(quote.shipTo) } : null,\n ].filter((block): block is { label: string; lines: string[] } => Boolean(block && block.lines.length))\n const totalRows = (\n [\n ['Subtotal', money(quote.totals.itemsCents), true],\n [\n quote.discountLabel ? `Discount (${quote.discountLabel})` : 'Discount',\n `−${money(quote.totals.discountCents)}`,\n quote.totals.discountCents > 0,\n ],\n ['Shipping', money(quote.totals.shippingCents), quote.totals.shippingCents > 0],\n [quote.taxLabel, money(quote.totals.taxCents), quote.totals.taxCents > 0],\n // The rate an invoiced draft's customer picks when they pay (AGL-4099).\n ['Shipping is chosen when you pay', '', quote.shippingAtPayment === true],\n // `Tax is added at payment`, with no figure: Stripe works it out from the address.\n [quote.taxLabel, '', quote.taxAtPayment],\n ] as Array<[string, string, boolean]>\n ).filter(([, , shown]) => shown)\n\n return (\n <Box ref={ref} {...rest} sx={nodeSx}>\n <Stack spacing={3}>\n <Stack spacing={1}>\n {quote.storeName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {quote.storeName}\n </Typography>\n ) : null}\n <Stack direction=\"row\" spacing={1.5} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <Typography variant=\"h4\" component=\"h1\">\n {/* The element's own heading is a quote's; an invoice or a proof always says its number. */}\n {(quote.kind !== 'invoice' && !proofOnly && heading) || quote.number}\n </Typography>\n {proofOnly ? null : (\n <Chip\n label={quote.statusLabel}\n color={quote.status === 'paid' ? 'success' : unpaid ? 'primary' : 'default'}\n size=\"small\"\n />\n )}\n </Stack>\n {quote.dateMs ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Dated ${dateLabel(quote.dateMs)}`}\n </Typography>\n ) : null}\n {proofOnly ? null : (\n <Box>\n <Button variant=\"outlined\" size=\"small\" href={pdfHref} download>\n {'Download PDF'}\n </Button>\n </Box>\n )}\n </Stack>\n\n {addresses.length ? (\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={{ xs: 2, sm: 3 }}>\n {addresses.map((block) => (\n <AddressBlock key={block.label} label={block.label} lines={block.lines} />\n ))}\n </Stack>\n ) : null}\n\n {proofOnly ? null : (\n <Stack spacing={1.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {'Items'}\n </Typography>\n {quote.lines.map((line, index) => (\n <Stack key={index} direction=\"row\" spacing={2} sx={{ justifyContent: 'space-between' }}>\n <Stack spacing={0.25} sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\">\n {line.name}\n {line.variantLabel ? ` (${line.variantLabel})` : ''}\n </Typography>\n {line.description ? (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ whiteSpace: 'pre-line' }}>\n {line.description}\n </Typography>\n ) : null}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {[\n line.included ? `${line.quantity} included` : `${line.quantity} × ${money(line.unitAmountCents)}`,\n line.sku ? `SKU ${line.sku}` : '',\n ]\n .filter(Boolean)\n .join(' · ')}\n </Typography>\n </Stack>\n <Typography variant=\"body2\" sx={{ flexShrink: 0 }}>\n {line.included ? 'Included' : money(line.amountCents)}\n </Typography>\n </Stack>\n ))}\n <Divider />\n {totalRows.map(([label, value]) => (\n <TotalRow key={`${label}-${value}`} label={label} value={value} />\n ))}\n <TotalRow label=\"Total\" value={money(quote.totals.totalCents)} strong />\n </Stack>\n )}\n\n {quote.notes ? (\n <Stack spacing={0.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {'Notes'}\n </Typography>\n <Typography variant=\"body2\" sx={{ whiteSpace: 'pre-line' }}>\n {quote.notes}\n </Typography>\n </Stack>\n ) : null}\n {quote.terms ? (\n <Stack spacing={0.5}>\n <Typography variant=\"h6\" component=\"h2\">\n {'Terms'}\n </Typography>\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ whiteSpace: 'pre-line' }}>\n {quote.terms}\n </Typography>\n </Stack>\n ) : null}\n\n {proofOnly && !quote.proofs.length ? (\n <Alert severity=\"info\">\n {`${quote.storeName || 'The business'} is working on the next version of your proof, and will send it when it’s ready.`}\n </Alert>\n ) : null}\n\n <QuoteProofPanel\n view={quote}\n hostId={hostId}\n quoteId={link.current.quoteId}\n token={link.current.token}\n siteFetch={siteFetch}\n onView={(next) => setState({ kind: 'ready', view: next })}\n onReload={() => void load().then(setState)}\n onReplaced={() => setState({ kind: 'replaced', storeName: quote.storeName, noun })}\n />\n\n {proofOnly ? null : unpaid ? (\n <Paper variant=\"outlined\" sx={{ p: { xs: 2, sm: 3 } }}>\n <Stack spacing={2}>\n {returned === 'confirming' ? (\n <Alert severity=\"info\" icon={<CircularProgress size={20} />}>\n {'Thank you. We’re confirming your payment.'}\n </Alert>\n ) : returned === 'unconfirmed' ? (\n <Alert severity=\"info\">\n {'Your payment is still being confirmed. Your receipt will arrive by email.'}\n </Alert>\n ) : quote.approvalRequired ? (\n <Alert severity=\"info\">\n {`${quote.storeName || 'The business'} asks you to approve the proof before you pay.`}\n </Alert>\n ) : quote.payable ? (\n <>\n {returned === 'failed' ? (\n <Alert severity=\"warning\">{'Your payment did not go through. Nothing was charged.'}</Alert>\n ) : null}\n {nativeCheckout ? (\n <Suspense fallback={<StorefrontPaymentElementFallback />}>\n <StorefrontPaymentElement\n clientSecret={nativeCheckout.clientSecret}\n publishableKey={nativeCheckout.publishableKey}\n wallets={nativeCheckout.wallets}\n payLabel={later ? 'Pay now' : `Pay ${money(quote.totals.totalCents)}`}\n defaultShippingAddress={stripeContact(quote.shipTo)}\n // An expired or unloadable session is replaced by a new press.\n onRestart={() => {\n setNativeCheckout(null)\n void pay()\n }}\n onCancel={() => setNativeCheckout(null)}\n />\n </Suspense>\n ) : (\n <Button\n variant=\"contained\"\n size=\"large\"\n onClick={() => void pay()}\n disabled={paying}\n sx={{ alignSelf: { xs: 'stretch', sm: 'flex-start' } }}\n >\n {paying\n ? 'Opening…'\n : later\n ? `Pay ${money(quote.totals.totalCents)} plus ${later}`\n : `Pay ${money(quote.totals.totalCents)}`}\n </Button>\n )}\n {payError ? <Alert severity=\"error\">{payError}</Alert> : null}\n </>\n ) : (\n <Alert severity=\"info\">\n {quote.notPayableMessage || `Contact ${quote.storeName || 'the business'} to pay this ${noun}.`}\n </Alert>\n )}\n </Stack>\n </Paper>\n ) : (\n <Paper variant=\"outlined\" sx={{ p: { xs: 2, sm: 3 } }}>\n <Stack spacing={1.5} sx={{ alignItems: 'flex-start' }}>\n <Typography variant=\"body1\">\n {quote.status === 'paid'\n ? quote.paidAtMs\n ? `Paid ${dateLabel(quote.paidAtMs)}. Thank you.`\n : 'Paid. Thank you.'\n : `This ${noun} is ${quote.statusLabel.toLowerCase()}.`}\n </Typography>\n {quote.receiptUrl ? (\n <Button variant=\"outlined\" href={quote.receiptUrl}>\n {'View your order'}\n </Button>\n ) : null}\n </Stack>\n </Paper>\n )}\n\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Questions about this ${noun}? Contact ${quote.storeName || 'the business'}.`}\n </Typography>\n </Stack>\n </Box>\n )\n})\nQuotePageBody.displayName = 'QuotePageBody'\n\nexport default QuotePageBody\n\n"],"names":["Aglyn","Alert","Box","Button","Chip","CircularProgress","Divider","Paper","Stack","Typography","forwardRef","lazy","Suspense","useCallback","useEffect","useRef","useState","formatOrderMoney","readStorefrontCheckoutWallets","QuoteProofPanel","StorefrontPaymentElementFallback","StorefrontPaymentElement","then","module","default","nounOf","kind","addedAtPayment","view","shippingAtPayment","taxAtPayment","CONFIRM_POLL_MS","CONFIRM_POLLS","dateLabel","atMs","Date","toLocaleDateString","undefined","month","day","year","addressLines","address","cityLine","city","state","postalCode","filter","Boolean","join","name","line1","line2","country","line","stripeContact","postal_code","AddressBlock","label","lines","spacing","sx","minWidth","flex","variant","color","map","index","TotalRow","value","strong","direction","justifyContent","QuotePageBody","props","ref","heading","rest","nodeSx","Array","isArray","hostId","useSite","siteFetch","useSiteFetch","setState","paying","setPaying","payError","setPayError","nativeCheckout","setNativeCheckout","returned","setReturned","link","quoteId","token","sessionId","load","current","response","encodeURIComponent","payload","json","catch","ok","message","String","error","storeName","noun","params","URLSearchParams","window","location","search","get","live","first","status","poll","Promise","resolve","setTimeout","next","pay","globalThis","attemptKey","crypto","randomUUID","now","Math","random","toString","slice","method","headers","body","JSON","stringify","q","t","v","version","taxKey","tax","clientSecret","publishableKey","wallets","url","assign","replaced","reason","p","border","borderColor","borderRadius","py","textAlign","size","aria-label","component","severity","business","quote","money","cents","currency","pdfHref","unpaid","proofOnly","later","addresses","customerName","company","billTo","shipTo","block","length","totalRows","totals","itemsCents","discountLabel","discountCents","shippingCents","taxLabel","taxCents","shown","alignItems","flexWrap","rowGap","number","statusLabel","dateMs","href","download","xs","sm","variantLabel","description","whiteSpace","included","quantity","unitAmountCents","sku","flexShrink","amountCents","totalCents","notes","terms","proofs","onView","onReload","onReplaced","icon","approvalRequired","payable","fallback","payLabel","defaultShippingAddress","onRestart","onCancel","onClick","disabled","alignSelf","notPayableMessage","paidAtMs","toLowerCase","receiptUrl","displayName"],"mappings":";;;AAAA;;;;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AAE5B,eAAe5J,cAAa"}
@@ -99,7 +99,7 @@ export type PayLinkGap = 'payments' | 'tax-undecided' | 'tax-save';
99
99
  * is said where it is decided, not here.
100
100
  */
101
101
  export declare function payLinkGaps(input: {
102
- order: (Pick<HostOrder, 'status' | 'channel'> & Partial<Pick<HostOrder, 'quote'>>) | null;
102
+ order: (Pick<HostOrder, 'status' | 'channel'> & Partial<Pick<HostOrder, 'quote' | 'lineItems'>>) | null;
103
103
  /** The workspace can take card payments; null while that is unknown. */
104
104
  paymentsReady: boolean | null;
105
105
  /** The store's sales tax choice; undefined while it is being read. */
@@ -17,7 +17,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
17
17
  */ import { appendOrderEvent, formatOrderNumber, orderCreatedAtMs } from "./commerce-orders.js";
18
18
  import { QUOTE_MIN_CHARGE_CENTS, payLinkCheckoutCharge, payLinkPaymentsUnavailableMessage, payLinkRefusalWithPayments, quoteCheckoutCharge, quotePageAddress, quotePageLines, quotePageStatus, quotePayRefusal, quotePayRefusalMessage, quotePayTax } from "./commerce-quote-pay.js";
19
19
  import { lastQuoteSend } from "./commerce-quote-email.js";
20
- import { isQuote } from "./commerce-quotes.js";
20
+ import { isQuote, quoteIsProofOnly } from "./commerce-quotes.js";
21
21
  import { storefrontTaxDecision } from "./commerce-tax-decision.js";
22
22
  import { lineRequiresShipping } from "./order-fulfillment.js";
23
23
  /** The most invoice sends an order keeps on record; the oldest go first. */ export const INVOICE_MAX_SENDS = 50;
@@ -182,6 +182,8 @@ export function invoicePayRefusal(order, orderId, /** The store's sales tax choi
182
182
  const { order, store } = input;
183
183
  if (input.paymentsReady === null || store === undefined) return null;
184
184
  if (order && (order.status !== 'pending' || orderPayLinkKind(order) === null)) return [];
185
+ // A proof only quote charges nothing until it has lines (AGL-4184).
186
+ if ((order == null ? void 0 : order.quote) && quoteIsProofOnly(order)) return [];
185
187
  const gaps = [];
186
188
  if (!input.paymentsReady) gaps.push('payments');
187
189
  if (storefrontTaxDecision({
@@ -224,6 +226,7 @@ export function invoicePayRefusal(order, orderId, /** The store's sales tax choi
224
226
  return {
225
227
  state: 'quote',
226
228
  kind: 'invoice',
229
+ proofOnly: false,
227
230
  storeName: input.storeName,
228
231
  number: formatInvoiceNumber(order, input.orderId),
229
232
  dateMs: created > 0 ? created : null,