@aglyn/plugins-commerce 1.29.3 → 1.31.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 (72) hide show
  1. package/package.json +13 -13
  2. package/src/lib/components/cart.js +11 -5
  3. package/src/lib/components/cart.js.map +1 -1
  4. package/src/lib/components/console/pos/pos-item-dialog.component.js +12 -0
  5. package/src/lib/components/console/pos/pos-item-dialog.component.js.map +1 -1
  6. package/src/lib/components/console/pos-kiosk-page.component.js +3 -5
  7. package/src/lib/components/console/pos-kiosk-page.component.js.map +1 -1
  8. package/src/lib/components/console/product-add-ons-fields.component.d.ts +11 -0
  9. package/src/lib/components/console/product-add-ons-fields.component.js +229 -13
  10. package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
  11. package/src/lib/components/console/product-editor-dialog.component.js +5 -0
  12. package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
  13. package/src/lib/components/console/product-traffic-card.component.d.ts +24 -0
  14. package/src/lib/components/console/product-traffic-card.component.js +172 -0
  15. package/src/lib/components/console/product-traffic-card.component.js.map +1 -0
  16. package/src/lib/components/console/products-hub-card.component.js +181 -59
  17. package/src/lib/components/console/products-hub-card.component.js.map +1 -1
  18. package/src/lib/components/console/quote-editor-dialog.component.js +38 -0
  19. package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
  20. package/src/lib/components/console/shipping-settings-card.component.js +31 -9
  21. package/src/lib/components/console/shipping-settings-card.component.js.map +1 -1
  22. package/src/lib/components/product-add-ons.d.ts +21 -0
  23. package/src/lib/components/product-add-ons.js +77 -1
  24. package/src/lib/components/product-add-ons.js.map +1 -1
  25. package/src/lib/components/product-builder-mockup.d.ts +1 -1
  26. package/src/lib/components/product-builder-mockup.js +17 -5
  27. package/src/lib/components/product-builder-mockup.js.map +1 -1
  28. package/src/lib/components/product-choice-cards.js +14 -2
  29. package/src/lib/components/product-choice-cards.js.map +1 -1
  30. package/src/lib/model/commerce-pos-kiosk.js +8 -2
  31. package/src/lib/model/commerce-pos-kiosk.js.map +1 -1
  32. package/src/lib/model/commerce-pos-offline.d.ts +1 -1
  33. package/src/lib/model/commerce-pos-offline.js +8 -2
  34. package/src/lib/model/commerce-pos-offline.js.map +1 -1
  35. package/src/lib/model/commerce-quote-request.d.ts +1 -0
  36. package/src/lib/model/commerce-quote-request.js +6 -2
  37. package/src/lib/model/commerce-quote-request.js.map +1 -1
  38. package/src/lib/model/commerce-quotes.js +10 -5
  39. package/src/lib/model/commerce-quotes.js.map +1 -1
  40. package/src/lib/model/commerce-record-routes.js +31 -0
  41. package/src/lib/model/commerce-record-routes.js.map +1 -1
  42. package/src/lib/model/commerce-shipping.d.ts +39 -16
  43. package/src/lib/model/commerce-shipping.js +315 -30
  44. package/src/lib/model/commerce-shipping.js.map +1 -1
  45. package/src/lib/model/commerce.js +1 -1
  46. package/src/lib/model/commerce.js.map +1 -1
  47. package/src/lib/model/product-modifiers.d.ts +53 -2
  48. package/src/lib/model/product-modifiers.js +127 -27
  49. package/src/lib/model/product-modifiers.js.map +1 -1
  50. package/src/lib/model/product-write.d.ts +10 -1
  51. package/src/lib/model/product-write.js +13 -2
  52. package/src/lib/model/product-write.js.map +1 -1
  53. package/src/lib/server/carrier-shipping.js +3 -2
  54. package/src/lib/server/carrier-shipping.js.map +1 -1
  55. package/src/lib/server/cart-checkout.js +10 -4
  56. package/src/lib/server/cart-checkout.js.map +1 -1
  57. package/src/lib/server/cart.js +2 -2
  58. package/src/lib/server/cart.js.map +1 -1
  59. package/src/lib/server/checkout.js +6 -4
  60. package/src/lib/server/checkout.js.map +1 -1
  61. package/src/lib/server/draft-order.js +3 -3
  62. package/src/lib/server/draft-order.js.map +1 -1
  63. package/src/lib/server/pos-kiosk.js +1 -4
  64. package/src/lib/server/pos-kiosk.js.map +1 -1
  65. package/src/lib/server/product.d.ts +5 -0
  66. package/src/lib/server/product.js +10 -2
  67. package/src/lib/server/product.js.map +1 -1
  68. package/src/lib/server/products-write.js +10 -2
  69. package/src/lib/server/products-write.js.map +1 -1
  70. package/src/lib/transfer/product-register-cells.d.ts +7 -0
  71. package/src/lib/transfer/product-register-cells.js +88 -10
  72. package/src/lib/transfer/product-register-cells.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/product-add-ons-fields.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 {\n Box,\n Button,\n Collapse,\n FormControlLabel,\n IconButton,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { memo, useCallback, useId, useState } from 'react'\nimport * as CommerceModel from '../../model'\nimport { PRODUCT_CHOICE_NOTE_MAX, PRODUCT_COMBO_ITEM_MAX, PRODUCT_COMBO_MAX_ITEMS } from '../../model/product-card-rules'\nimport { CardPictureField, type ProductMediaPick } from './product-builder-fields.component'\n\ntype Patch = Partial<CommerceModel.HostProduct>\n\nexport interface ProductAddOnsFieldsProps {\n modifierGroups: readonly CommerceModel.ProductModifierGroup[]\n /** The product's options, to name what a choice is priced by. */\n options: readonly CommerceModel.ProductOption[]\n /** The product's variants, each of which a choice may be priced on. */\n variants: readonly Pick<CommerceModel.ProductVariant, 'id' | 'options'>[]\n update: (patch: Patch) => void\n /** Opens the media browser for a choice's picture (AGL-4205); without it, no picture is chosen. */\n pick?: ProductMediaPick\n}\n\nfunction newId(prefix: string): string {\n return `${prefix}${Math.random().toString(36).slice(2, 10)}`\n}\n\n/** Dollars as typed, to whole cents; blank is free. */\nfunction centsFromDollars(value: string): number {\n const number = Math.round(Number(String(value).replace(/[^0-9.]/g, '')) * 100)\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/** Cents as the price field shows them; blank for free. */\nfunction dollarsFromCents(cents: number | undefined): string {\n return cents ? (cents / 100).toFixed(2) : ''\n}\n\n/**\n * What a choice's per-variant prices are called (AGL-4100): by the one\n * option a product varies by (\"Price by size\"), else by variant.\n */\nexport function priceByLabel(options: readonly Pick<CommerceModel.ProductOption, 'name'>[]): string {\n const named = options.filter((option) => option.name?.trim())\n return named.length === 1 ? `Price by ${named[0].name.trim().toLowerCase()}` : 'Price by variant'\n}\n\n/** A new group, as the console makes it from now on: shown on the website (AGL-4100). */\nexport function newAddOnGroup(): CommerceModel.ProductModifierGroup {\n return {\n id: newId('g'),\n name: '',\n min: 0,\n max: 1,\n online: true,\n options: [{ id: newId('o'), name: '', priceCents: 0 }],\n }\n}\n\n/**\n * A choice's prices by variant with one variant's price set or cleared. A\n * cleared price follows the choice's own; with none left the field is\n * dropped, never stored as `undefined` (the save is a client-direct write,\n * which refuses one).\n */\nexport function withVariantPrice(\n option: CommerceModel.ProductModifierOption,\n variantId: string,\n raw: string,\n): CommerceModel.ProductModifierOption {\n const { priceCentsByVariant, ...rest } = option\n const next = { ...(priceCentsByVariant ?? {}) }\n if (raw.trim() === '') delete next[variantId]\n else next[variantId] = centsFromDollars(raw)\n return Object.keys(next).length ? { ...rest, priceCentsByVariant: next } : rest\n}\n\n/**\n * A choice with its card changed (AGL-4205): its picture, its note, or what\n * it includes as a combo, typed one item per line. A cleared field is\n * dropped, never stored as `undefined`.\n */\nexport function withChoiceCard(\n option: CommerceModel.ProductModifierOption,\n patch: { imageUrl?: string | null; note?: string | null; includes?: string | null },\n): CommerceModel.ProductModifierOption {\n const next: CommerceModel.ProductModifierOption = { ...option }\n if ('imageUrl' in patch) {\n const url = String(patch.imageUrl ?? '').trim()\n if (url) next.imageUrl = url\n else delete next.imageUrl\n }\n if ('note' in patch) {\n const note = String(patch.note ?? '').trim().slice(0, PRODUCT_CHOICE_NOTE_MAX)\n if (note) next.note = note\n else delete next.note\n }\n if ('includes' in patch) {\n const items = String(patch.includes ?? '')\n .split('\\n')\n .map((item) => item.trim().slice(0, PRODUCT_COMBO_ITEM_MAX))\n .filter(Boolean)\n .slice(0, PRODUCT_COMBO_MAX_ITEMS)\n if (items.length) next.includes = items\n else delete next.includes\n }\n return next\n}\n\n/**\n * The product's add-ons (AGL-4100, from the register's modifiers of\n * AGL-3607): choices added to the item that are not stocked variants — walls\n * and printing on a canopy, a milk in a latte — each free or adding to the\n * price, and able to cost more on one variant than another. A group with a\n * minimum of 1 or more must be answered before the item is added. Each group\n * says whether the website's product page offers it; the register always\n * does.\n *\n * Offered on every store, with or without the point of sale, and saved with\n * the product, so editing it takes exactly what editing the product takes.\n * Memoized on its own props like every section of this editor (AGL-3423).\n */\nexport const ProductAddOnsFields = memo(function ProductAddOnsFields(\n props: ProductAddOnsFieldsProps,\n) {\n const { modifierGroups, options, variants, update, pick } = props\n const helpId = useId()\n const [pricedByVariant, setPricedByVariant] = useState<Record<string, boolean>>({})\n const [cardOpen, setCardOpen] = useState<Record<string, boolean>>({})\n const setGroups = useCallback(\n (groups: CommerceModel.ProductModifierGroup[]) => update({ modifierGroups: groups }),\n [update],\n )\n const editGroup = (index: number, patch: Partial<CommerceModel.ProductModifierGroup>) =>\n setGroups(modifierGroups.map((group, at) => (at === index ? { ...group, ...patch } : group)))\n const replaceOption = (\n groupIndex: number,\n optionIndex: number,\n next: CommerceModel.ProductModifierOption,\n ) => {\n const group = modifierGroups[groupIndex]\n editGroup(groupIndex, {\n options: group.options.map((option, at) => (at === optionIndex ? next : option)),\n })\n }\n const editOption = (\n groupIndex: number,\n optionIndex: number,\n patch: Partial<CommerceModel.ProductModifierOption>,\n ) => replaceOption(groupIndex, optionIndex, { ...modifierGroups[groupIndex].options[optionIndex], ...patch })\n const problem = CommerceModel.modifierGroupsProblem(modifierGroups)\n const variesByVariant = variants.length > 1\n const byLabel = priceByLabel(options)\n\n return (\n <Stack spacing={2}>\n <Typography id={helpId} variant=\"body2\" color=\"text.secondary\">\n {'Add-ons are choices added to the item that don’t need their own stock, such as walls or ' +\n 'printing on a canopy, or a milk in a latte. Each can be free or add to the price, and can ' +\n 'cost more on a larger size. Show a group on the website to offer it on the product’s page; ' +\n 'the register offers every group.'}\n </Typography>\n {modifierGroups.map((group, groupIndex) => (\n <Box\n key={group.id}\n role=\"group\"\n aria-label={group.name || 'Add-on group'}\n sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 2 }}\n >\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Group name\"\n size=\"small\"\n value={group.name}\n onChange={(event) => editGroup(groupIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"At least\"\n size=\"small\"\n value={group.min}\n onChange={(event) =>\n editGroup(groupIndex, { min: Math.max(0, Math.round(Number(event.target.value) || 0)) })\n }\n helperText={group.min > 0 ? 'Required' : 'Optional'}\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <TextField\n label=\"At most\"\n size=\"small\"\n value={group.max}\n onChange={(event) =>\n editGroup(groupIndex, { max: Math.max(1, Math.round(Number(event.target.value) || 1)) })\n }\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n color=\"error\"\n onClick={() => setGroups(modifierGroups.filter((_group, at) => at !== groupIndex))}\n >\n {'Remove group'}\n </Button>\n </Stack>\n <FormControlLabel\n control={\n <Switch\n checked={group.online === true}\n onChange={(event) => editGroup(groupIndex, { online: event.target.checked })}\n />\n }\n label=\"Show on the website\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {group.online === true\n ? 'Offered on the product’s page and at the register.'\n : 'Offered at the register only.'}\n </Typography>\n {group.options.map((option, optionIndex) => {\n const optionKey = `${group.id}:${option.id}`\n const byVariantOpen =\n pricedByVariant[optionKey] ?? Object.keys(option.priceCentsByVariant ?? {}).length > 0\n const hasCard = Boolean(option.imageUrl || option.note || option.includes?.length)\n const cardShown = cardOpen[optionKey] ?? hasCard\n const choiceLabel = option.name || 'this choice'\n return (\n <Box key={option.id}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Choice\"\n size=\"small\"\n value={option.name}\n onChange={(event) => editOption(groupIndex, optionIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"Adds ($)\"\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCents)}\n placeholder=\"0.00\"\n onBlur={(event) =>\n editOption(groupIndex, optionIndex, { priceCents: centsFromDollars(event.target.value) })\n }\n sx={{ width: (theme) => theme.spacing(15) }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n {variesByVariant ? (\n <Button\n size=\"small\"\n aria-expanded={byVariantOpen}\n onClick={() =>\n setPricedByVariant((open) => ({ ...open, [optionKey]: !byVariantOpen }))\n }\n >\n {byLabel}\n </Button>\n ) : null}\n <Button\n size=\"small\"\n aria-expanded={cardShown}\n onClick={() => setCardOpen((open) => ({ ...open, [optionKey]: !cardShown }))}\n >\n {'Picture & combo'}\n </Button>\n <IconButton\n aria-label={`Remove ${option.name || 'choice'}`}\n onClick={() =>\n editGroup(groupIndex, {\n options: group.options.filter((_option, at) => at !== optionIndex),\n max: Math.max(1, Math.min(group.max, group.options.length - 1)),\n })\n }\n >\n {'✕'}\n </IconButton>\n </Stack>\n {variesByVariant ? (\n <Collapse in={byVariantOpen} unmountOnExit>\n <Stack spacing={1} sx={{ pl: 2, pt: 1.5 }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`What “${option.name || 'this choice'}” adds on each. Leave one blank to use ` +\n 'the price above.'}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, minmax(0, 1fr))' },\n gap: 1,\n }}\n >\n {variants.map((variant) => (\n <TextField\n key={variant.id}\n label={CommerceModel.variantPriceLabel(variant)}\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCentsByVariant?.[variant.id])}\n placeholder={dollarsFromCents(option.priceCents) || '0.00'}\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withVariantPrice(\n modifierGroups[groupIndex].options[optionIndex],\n variant.id,\n event.target.value,\n ),\n )\n }\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n ))}\n </Box>\n </Stack>\n </Collapse>\n ) : null}\n <Collapse in={cardShown} unmountOnExit>\n <Stack spacing={1} sx={{ pl: 2, pt: 1.5 }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`What “${choiceLabel}” shows on its picture card. List what it includes to make it ` +\n 'a combo: shoppers can open the list on its card.'}\n </Typography>\n <CardPictureField\n imageUrl={option.imageUrl}\n label={choiceLabel}\n pick={pick}\n onChange={(imageUrl) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withChoiceCard(modifierGroups[groupIndex].options[optionIndex], { imageUrl }),\n )\n }\n />\n <TextField\n label=\"Note\"\n size=\"small\"\n defaultValue={option.note ?? ''}\n placeholder=\"Blocks wind on one side\"\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withChoiceCard(modifierGroups[groupIndex].options[optionIndex], {\n note: event.target.value,\n }),\n )\n }\n slotProps={{ htmlInput: { maxLength: PRODUCT_CHOICE_NOTE_MAX } }}\n />\n <TextField\n label=\"Combo: what it includes\"\n size=\"small\"\n multiline\n minRows={2}\n defaultValue={Array.isArray(option.includes) ? option.includes.join('\\n') : ''}\n placeholder={'Full wall ×2\\nSteel weights ×4\\nRoller bag'}\n helperText={`One item per line, up to ${PRODUCT_COMBO_MAX_ITEMS}. Leave it empty for a single choice.`}\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withChoiceCard(modifierGroups[groupIndex].options[optionIndex], {\n includes: event.target.value,\n }),\n )\n }\n />\n </Stack>\n </Collapse>\n </Box>\n )\n })}\n <Box>\n <Button\n onClick={() =>\n editGroup(groupIndex, {\n options: [...group.options, { id: newId('o'), name: '', priceCents: 0 }],\n })\n }\n disabled={group.options.length >= CommerceModel.POS_MAX_MODIFIER_OPTIONS}\n >\n {'Add choice'}\n </Button>\n </Box>\n </Stack>\n </Box>\n ))}\n <Box>\n <Button\n variant=\"outlined\"\n aria-describedby={helpId}\n onClick={() => setGroups([...modifierGroups, newAddOnGroup()])}\n disabled={modifierGroups.length >= CommerceModel.POS_MAX_MODIFIER_GROUPS}\n >\n {'New add-on group'}\n </Button>\n </Box>\n {problem && modifierGroups.length ? (\n <Typography variant=\"body2\" color=\"warning.main\">\n {problem}\n </Typography>\n ) : null}\n </Stack>\n )\n})\n"],"names":["Box","Button","Collapse","FormControlLabel","IconButton","Stack","Switch","TextField","Typography","memo","useCallback","useId","useState","CommerceModel","PRODUCT_CHOICE_NOTE_MAX","PRODUCT_COMBO_ITEM_MAX","PRODUCT_COMBO_MAX_ITEMS","CardPictureField","newId","prefix","Math","random","toString","slice","centsFromDollars","value","number","round","Number","String","replace","isFinite","dollarsFromCents","cents","toFixed","priceByLabel","options","named","filter","option","name","trim","length","toLowerCase","newAddOnGroup","id","min","max","online","priceCents","withVariantPrice","variantId","raw","priceCentsByVariant","rest","next","Object","keys","withChoiceCard","patch","url","imageUrl","note","items","includes","split","map","item","Boolean","ProductAddOnsFields","props","modifierGroups","variants","update","pick","helpId","pricedByVariant","setPricedByVariant","cardOpen","setCardOpen","setGroups","groups","editGroup","index","group","at","replaceOption","groupIndex","optionIndex","editOption","problem","modifierGroupsProblem","variesByVariant","byLabel","spacing","variant","color","role","aria-label","sx","border","borderColor","borderRadius","p","direction","alignItems","flexWrap","rowGap","label","size","onChange","event","target","flex","minWidth","theme","helperText","width","slotProps","htmlInput","inputMode","onClick","_group","control","checked","optionKey","byVariantOpen","hasCard","cardShown","choiceLabel","defaultValue","placeholder","onBlur","aria-expanded","open","_option","in","unmountOnExit","pl","pt","display","gridTemplateColumns","xs","sm","gap","variantPriceLabel","maxLength","multiline","minRows","Array","isArray","join","disabled","POS_MAX_MODIFIER_OPTIONS","aria-describedby","POS_MAX_MODIFIER_GROUPS"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;;AAEA,SACEA,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,IAAI,EAAEC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,QAAO;AAC1D,YAAYC,mBAAmB,uBAAa;AAC5C,SAASC,uBAAuB,EAAEC,sBAAsB,EAAEC,uBAAuB,QAAQ,oCAAgC;AACzH,SAASC,gBAAgB,QAA+B,wCAAoC;AAe5F,SAASC,MAAMC,MAAc;IAC3B,OAAO,GAAGA,SAASC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG,KAAK;AAC9D;AAEA,qDAAqD,GACrD,SAASC,iBAAiBC,KAAa;IACrC,MAAMC,SAASN,KAAKO,KAAK,CAACC,OAAOC,OAAOJ,OAAOK,OAAO,CAAC,YAAY,OAAO;IAC1E,OAAOF,OAAOG,QAAQ,CAACL,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAEA,yDAAyD,GACzD,SAASM,iBAAiBC,KAAyB;IACjD,OAAOA,QAAQ,AAACA,CAAAA,QAAQ,GAAE,EAAGC,OAAO,CAAC,KAAK;AAC5C;AAEA;;;CAGC,GACD,OAAO,SAASC,aAAaC,OAA6D;IACxF,MAAMC,QAAQD,QAAQE,MAAM,CAAC,CAACC;YAAWA;gBAAAA,eAAAA,OAAOC,IAAI,qBAAXD,aAAaE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CwH,SAAS,IACPvC,UAAUK,YAAY;4CACpBnD,SAAS;mDAAIgD,MAAMhD,OAAO;gDAAE;oDAAES,IAAI3B,MAAM;oDAAMsB,MAAM;oDAAIS,YAAY;gDAAE;6CAAE;wCAC1E;oCAEFuG,UAAUpE,MAAMhD,OAAO,CAACM,MAAM,IAAI7B,cAAc4I,wBAAwB;8CAEvE;;;;;mBA3NFrE,MAAMvC,EAAE;0BAiOjB,KAAC7C;0BACC,cAAA,KAACC;oBACC8F,SAAQ;oBACR2D,oBAAkB/E;oBAClB8C,SAAS,IAAMzC,UAAU;+BAAIT;4BAAgB3B;yBAAgB;oBAC7D4G,UAAUjF,eAAe7B,MAAM,IAAI7B,cAAc8I,uBAAuB;8BAEvE;;;YAGJjE,WAAWnB,eAAe7B,MAAM,iBAC/B,KAAClC;gBAAWuF,SAAQ;gBAAQC,OAAM;0BAC/BN;iBAED;;;AAGV,GAAE"}
1
+ {"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/product-add-ons-fields.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 {\n Box,\n Button,\n Collapse,\n FormControlLabel,\n IconButton,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { memo, useCallback, useId, useState } from 'react'\nimport * as CommerceModel from '../../model'\nimport { PRODUCT_CHOICE_NOTE_MAX, PRODUCT_COMBO_ITEM_MAX, PRODUCT_COMBO_MAX_ITEMS } from '../../model/product-card-rules'\nimport { CardPictureField, type ProductMediaPick } from './product-builder-fields.component'\n\ntype Patch = Partial<CommerceModel.HostProduct>\n\nexport interface ProductAddOnsFieldsProps {\n modifierGroups: readonly CommerceModel.ProductModifierGroup[]\n /** The product's options, to name what a choice is priced by. */\n options: readonly CommerceModel.ProductOption[]\n /** The product's variants, each of which a choice may be priced on. */\n variants: readonly Pick<CommerceModel.ProductVariant, 'id' | 'options'>[]\n update: (patch: Patch) => void\n /** Opens the media browser for a choice's picture (AGL-4205); without it, no picture is chosen. */\n pick?: ProductMediaPick\n}\n\nfunction newId(prefix: string): string {\n return `${prefix}${Math.random().toString(36).slice(2, 10)}`\n}\n\n/** Dollars as typed, to whole cents; blank is free. */\nfunction centsFromDollars(value: string): number {\n const number = Math.round(Number(String(value).replace(/[^0-9.]/g, '')) * 100)\n return Number.isFinite(number) && number > 0 ? number : 0\n}\n\n/** Cents as the price field shows them; blank for free. */\nfunction dollarsFromCents(cents: number | undefined): string {\n return cents ? (cents / 100).toFixed(2) : ''\n}\n\n/**\n * What a choice's per-variant prices are called (AGL-4100): by the one\n * option a product varies by (\"Price by size\"), else by variant.\n */\nexport function priceByLabel(options: readonly Pick<CommerceModel.ProductOption, 'name'>[]): string {\n const named = options.filter((option) => option.name?.trim())\n return named.length === 1 ? `Price by ${named[0].name.trim().toLowerCase()}` : 'Price by variant'\n}\n\n/** A new group, as the console makes it from now on: shown on the website (AGL-4100). */\nexport function newAddOnGroup(): CommerceModel.ProductModifierGroup {\n return {\n id: newId('g'),\n name: '',\n min: 0,\n max: 1,\n online: true,\n options: [{ id: newId('o'), name: '', priceCents: 0 }],\n }\n}\n\n/**\n * A new write-in (write-ins): one field the shopper types into,\n * such as a name to print or an engraving. Required, shown on the website,\n * free until the merchant sets what it adds.\n */\nexport function newWriteInGroup(): CommerceModel.ProductModifierGroup {\n return {\n id: newId('g'),\n name: '',\n kind: 'text',\n min: 1,\n max: 1,\n maxLength: CommerceModel.DEFAULT_WRITE_IN_LENGTH,\n online: true,\n options: [{ id: newId('o'), name: '', priceCents: 0 }],\n }\n}\n\n/**\n * A write-in renamed: its one option carries the same name, so every reader\n * that names a pick by its option names the field.\n */\nexport function withWriteInName(\n group: CommerceModel.ProductModifierGroup,\n name: string,\n): Partial<CommerceModel.ProductModifierGroup> {\n return { name, options: group.options.map((option, at) => (at === 0 ? { ...option, name } : option)) }\n}\n\n/**\n * A choice's prices by variant with one variant's price set or cleared. A\n * cleared price follows the choice's own; with none left the field is\n * dropped, never stored as `undefined` (the save is a client-direct write,\n * which refuses one).\n */\nexport function withVariantPrice(\n option: CommerceModel.ProductModifierOption,\n variantId: string,\n raw: string,\n): CommerceModel.ProductModifierOption {\n const { priceCentsByVariant, ...rest } = option\n const next = { ...(priceCentsByVariant ?? {}) }\n if (raw.trim() === '') delete next[variantId]\n else next[variantId] = centsFromDollars(raw)\n return Object.keys(next).length ? { ...rest, priceCentsByVariant: next } : rest\n}\n\n/**\n * A choice with its card changed (AGL-4205): its picture, its note, or what\n * it includes as a combo, typed one item per line. A cleared field is\n * dropped, never stored as `undefined`.\n */\nexport function withChoiceCard(\n option: CommerceModel.ProductModifierOption,\n patch: { imageUrl?: string | null; note?: string | null; includes?: string | null },\n): CommerceModel.ProductModifierOption {\n const next: CommerceModel.ProductModifierOption = { ...option }\n if ('imageUrl' in patch) {\n const url = String(patch.imageUrl ?? '').trim()\n if (url) next.imageUrl = url\n else delete next.imageUrl\n }\n if ('note' in patch) {\n const note = String(patch.note ?? '').trim().slice(0, PRODUCT_CHOICE_NOTE_MAX)\n if (note) next.note = note\n else delete next.note\n }\n if ('includes' in patch) {\n const items = String(patch.includes ?? '')\n .split('\\n')\n .map((item) => item.trim().slice(0, PRODUCT_COMBO_ITEM_MAX))\n .filter(Boolean)\n .slice(0, PRODUCT_COMBO_MAX_ITEMS)\n if (items.length) next.includes = items\n else delete next.includes\n }\n return next\n}\n\ninterface WriteInFieldsProps {\n group: CommerceModel.ProductModifierGroup\n edit: (patch: Partial<CommerceModel.ProductModifierGroup>) => void\n remove: () => void\n}\n\n/**\n * One write-in in the editor (write-ins): what the field is\n * called, how long an answer can be, what a filled one adds, the note under\n * it, and whether it is required, numbers only and asked on the website.\n */\nfunction WriteInFields(props: WriteInFieldsProps) {\n const { group, edit, remove } = props\n const option = group.options[0]\n const editOption = (next: CommerceModel.ProductModifierOption) =>\n edit({ options: group.options.map((entry, at) => (at === 0 ? next : entry)) })\n const example = `${group.name || 'Engraving'}: ${group.digitsOnly ? '27' : 'For Sam'}`\n return (\n <Stack spacing={1.5}>\n <Typography variant=\"overline\" color=\"text.secondary\">\n {'Write-in'}\n </Typography>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Field name\"\n size=\"small\"\n value={group.name}\n placeholder=\"Engraving\"\n onChange={(event) => edit(withWriteInName(group, event.target.value))}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"Longest answer\"\n size=\"small\"\n value={group.maxLength ?? CommerceModel.DEFAULT_WRITE_IN_LENGTH}\n onChange={(event) =>\n edit({\n maxLength: Math.min(\n CommerceModel.MAX_WRITE_IN_LENGTH,\n Math.max(1, Math.round(Number(event.target.value) || 1)),\n ),\n })\n }\n helperText=\"Characters\"\n sx={{ width: (theme) => theme.spacing(15) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <TextField\n label=\"Adds ($)\"\n size=\"small\"\n defaultValue={dollarsFromCents(option?.priceCents)}\n placeholder=\"0.00\"\n onBlur={(event) => option && editOption({ ...option, priceCents: centsFromDollars(event.target.value) })}\n helperText=\"When filled in\"\n sx={{ width: (theme) => theme.spacing(15) }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n <Button color=\"error\" onClick={remove}>\n {'Remove write-in'}\n </Button>\n </Stack>\n <TextField\n label=\"Note\"\n size=\"small\"\n defaultValue={option?.note ?? ''}\n placeholder=\"Exactly as it should read\"\n onBlur={(event) => option && editOption(withChoiceCard(option, { note: event.target.value }))}\n helperText=\"Shown under the field on the product’s page.\"\n slotProps={{ htmlInput: { maxLength: PRODUCT_CHOICE_NOTE_MAX } }}\n />\n <Stack direction=\"row\" spacing={2} sx={{ flexWrap: 'wrap', rowGap: 0.5 }}>\n <FormControlLabel\n control={<Switch checked={group.min > 0} onChange={(event) => edit({ min: event.target.checked ? 1 : 0 })} />}\n label=\"Required\"\n />\n <FormControlLabel\n control={\n <Switch checked={group.digitsOnly === true} onChange={(event) => edit({ digitsOnly: event.target.checked })} />\n }\n label=\"Numbers only\"\n />\n <FormControlLabel\n control={<Switch checked={group.online === true} onChange={(event) => edit({ online: event.target.checked })} />}\n label=\"Show on the website\"\n />\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`The answer goes on the order, the receipt and your order emails, like “${example}”.` +\n (group.online === true ? '' : ' Asked at the register only.')}\n </Typography>\n </Stack>\n )\n}\n\n/**\n * The product's add-ons (AGL-4100, from the register's modifiers of\n * AGL-3607): choices added to the item that are not stocked variants — walls\n * and printing on a canopy, a milk in a latte — each free or adding to the\n * price, and able to cost more on one variant than another. A group with a\n * minimum of 1 or more must be answered before the item is added. Each group\n * says whether the website's product page offers it; the register always\n * does.\n *\n * Offered on every store, with or without the point of sale, and saved with\n * the product, so editing it takes exactly what editing the product takes.\n * Memoized on its own props like every section of this editor (AGL-3423).\n */\nexport const ProductAddOnsFields = memo(function ProductAddOnsFields(\n props: ProductAddOnsFieldsProps,\n) {\n const { modifierGroups, options, variants, update, pick } = props\n const helpId = useId()\n const [pricedByVariant, setPricedByVariant] = useState<Record<string, boolean>>({})\n const [cardOpen, setCardOpen] = useState<Record<string, boolean>>({})\n const setGroups = useCallback(\n (groups: CommerceModel.ProductModifierGroup[]) => update({ modifierGroups: groups }),\n [update],\n )\n const editGroup = (index: number, patch: Partial<CommerceModel.ProductModifierGroup>) =>\n setGroups(modifierGroups.map((group, at) => (at === index ? { ...group, ...patch } : group)))\n const replaceOption = (\n groupIndex: number,\n optionIndex: number,\n next: CommerceModel.ProductModifierOption,\n ) => {\n const group = modifierGroups[groupIndex]\n editGroup(groupIndex, {\n options: group.options.map((option, at) => (at === optionIndex ? next : option)),\n })\n }\n const editOption = (\n groupIndex: number,\n optionIndex: number,\n patch: Partial<CommerceModel.ProductModifierOption>,\n ) => replaceOption(groupIndex, optionIndex, { ...modifierGroups[groupIndex].options[optionIndex], ...patch })\n const problem = CommerceModel.modifierGroupsProblem(modifierGroups)\n const variesByVariant = variants.length > 1\n const byLabel = priceByLabel(options)\n\n return (\n <Stack spacing={2}>\n <Typography id={helpId} variant=\"body2\" color=\"text.secondary\">\n {'Add-ons are choices added to the item that don’t need their own stock, such as walls or ' +\n 'printing on a canopy, or a milk in a latte. Each can be free or add to the price, and can ' +\n 'cost more on a larger size. Show a group on the website to offer it on the product’s page; ' +\n 'the register offers every group. A write-in asks the customer to type an answer, such as ' +\n 'a name to print, an engraving or a cake message, and puts it on the order.'}\n </Typography>\n {modifierGroups.map((group, groupIndex) => (\n <Box\n key={group.id}\n role=\"group\"\n aria-label={group.name || 'Add-on group'}\n sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 2 }}\n >\n {CommerceModel.modifierGroupIsWriteIn(group) ? (\n <WriteInFields\n group={group}\n edit={(patch) => editGroup(groupIndex, patch)}\n remove={() => setGroups(modifierGroups.filter((_group, at) => at !== groupIndex))}\n />\n ) : (\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'flex-start', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Group name\"\n size=\"small\"\n value={group.name}\n onChange={(event) => editGroup(groupIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"At least\"\n size=\"small\"\n value={group.min}\n onChange={(event) =>\n editGroup(groupIndex, { min: Math.max(0, Math.round(Number(event.target.value) || 0)) })\n }\n helperText={group.min > 0 ? 'Required' : 'Optional'}\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <TextField\n label=\"At most\"\n size=\"small\"\n value={group.max}\n onChange={(event) =>\n editGroup(groupIndex, { max: Math.max(1, Math.round(Number(event.target.value) || 1)) })\n }\n sx={{ width: (theme) => theme.spacing(12) }}\n slotProps={{ htmlInput: { inputMode: 'numeric' } }}\n />\n <Button\n color=\"error\"\n onClick={() => setGroups(modifierGroups.filter((_group, at) => at !== groupIndex))}\n >\n {'Remove group'}\n </Button>\n </Stack>\n <FormControlLabel\n control={\n <Switch\n checked={group.online === true}\n onChange={(event) => editGroup(groupIndex, { online: event.target.checked })}\n />\n }\n label=\"Show on the website\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {group.online === true\n ? 'Offered on the product’s page and at the register.'\n : 'Offered at the register only.'}\n </Typography>\n <FormControlLabel\n control={\n <Switch\n checked={group.nameOnOrder === true}\n onChange={(event) => editGroup(groupIndex, { nameOnOrder: event.target.checked })}\n />\n }\n label=\"Name the group on the order\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {group.nameOnOrder === true\n ? `The order says “${group.name || 'Size'}: ${group.options[0]?.name || 'M'}”.`\n : `The order says “${group.options[0]?.name || 'M'}”. Turn this on when a choice ` +\n 'doesn’t say what it is on its own, like a size.'}\n </Typography>\n {group.options.map((option, optionIndex) => {\n const optionKey = `${group.id}:${option.id}`\n const byVariantOpen =\n pricedByVariant[optionKey] ?? Object.keys(option.priceCentsByVariant ?? {}).length > 0\n const hasCard = Boolean(option.imageUrl || option.note || option.includes?.length)\n const cardShown = cardOpen[optionKey] ?? hasCard\n const choiceLabel = option.name || 'this choice'\n return (\n <Box key={option.id}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 1 }}>\n <TextField\n label=\"Choice\"\n size=\"small\"\n value={option.name}\n onChange={(event) => editOption(groupIndex, optionIndex, { name: event.target.value })}\n sx={{ flex: 1, minWidth: (theme) => theme.spacing(20) }}\n />\n <TextField\n label=\"Adds ($)\"\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCents)}\n placeholder=\"0.00\"\n onBlur={(event) =>\n editOption(groupIndex, optionIndex, { priceCents: centsFromDollars(event.target.value) })\n }\n sx={{ width: (theme) => theme.spacing(15) }}\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n {variesByVariant ? (\n <Button\n size=\"small\"\n aria-expanded={byVariantOpen}\n onClick={() =>\n setPricedByVariant((open) => ({ ...open, [optionKey]: !byVariantOpen }))\n }\n >\n {byLabel}\n </Button>\n ) : null}\n <Button\n size=\"small\"\n aria-expanded={cardShown}\n onClick={() => setCardOpen((open) => ({ ...open, [optionKey]: !cardShown }))}\n >\n {'Picture & combo'}\n </Button>\n <IconButton\n aria-label={`Remove ${option.name || 'choice'}`}\n onClick={() =>\n editGroup(groupIndex, {\n options: group.options.filter((_option, at) => at !== optionIndex),\n max: Math.max(1, Math.min(group.max, group.options.length - 1)),\n })\n }\n >\n {'✕'}\n </IconButton>\n </Stack>\n {variesByVariant ? (\n <Collapse in={byVariantOpen} unmountOnExit>\n <Stack spacing={1} sx={{ pl: 2, pt: 1.5 }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`What “${option.name || 'this choice'}” adds on each. Leave one blank to use ` +\n 'the price above.'}\n </Typography>\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, minmax(0, 1fr))' },\n gap: 1,\n }}\n >\n {variants.map((variant) => (\n <TextField\n key={variant.id}\n label={CommerceModel.variantPriceLabel(variant)}\n size=\"small\"\n defaultValue={dollarsFromCents(option.priceCentsByVariant?.[variant.id])}\n placeholder={dollarsFromCents(option.priceCents) || '0.00'}\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withVariantPrice(\n modifierGroups[groupIndex].options[optionIndex],\n variant.id,\n event.target.value,\n ),\n )\n }\n slotProps={{ htmlInput: { inputMode: 'decimal' } }}\n />\n ))}\n </Box>\n </Stack>\n </Collapse>\n ) : null}\n <Collapse in={cardShown} unmountOnExit>\n <Stack spacing={1} sx={{ pl: 2, pt: 1.5 }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`What “${choiceLabel}” shows on its picture card. List what it includes to make it ` +\n 'a combo: shoppers can open the list on its card.'}\n </Typography>\n <CardPictureField\n imageUrl={option.imageUrl}\n label={choiceLabel}\n pick={pick}\n onChange={(imageUrl) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withChoiceCard(modifierGroups[groupIndex].options[optionIndex], { imageUrl }),\n )\n }\n />\n <TextField\n label=\"Note\"\n size=\"small\"\n defaultValue={option.note ?? ''}\n placeholder=\"Blocks wind on one side\"\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withChoiceCard(modifierGroups[groupIndex].options[optionIndex], {\n note: event.target.value,\n }),\n )\n }\n slotProps={{ htmlInput: { maxLength: PRODUCT_CHOICE_NOTE_MAX } }}\n />\n <TextField\n label=\"Combo: what it includes\"\n size=\"small\"\n multiline\n minRows={2}\n defaultValue={Array.isArray(option.includes) ? option.includes.join('\\n') : ''}\n placeholder={'Full wall ×2\\nSteel weights ×4\\nRoller bag'}\n helperText={`One item per line, up to ${PRODUCT_COMBO_MAX_ITEMS}. Leave it empty for a single choice.`}\n onBlur={(event) =>\n replaceOption(\n groupIndex,\n optionIndex,\n withChoiceCard(modifierGroups[groupIndex].options[optionIndex], {\n includes: event.target.value,\n }),\n )\n }\n />\n </Stack>\n </Collapse>\n </Box>\n )\n })}\n <Box>\n <Button\n onClick={() =>\n editGroup(groupIndex, {\n options: [...group.options, { id: newId('o'), name: '', priceCents: 0 }],\n })\n }\n disabled={group.options.length >= CommerceModel.POS_MAX_MODIFIER_OPTIONS}\n >\n {'Add choice'}\n </Button>\n </Box>\n </Stack>\n )}\n </Box>\n ))}\n <Box>\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n <Button\n variant=\"outlined\"\n aria-describedby={helpId}\n onClick={() => setGroups([...modifierGroups, newAddOnGroup()])}\n disabled={modifierGroups.length >= CommerceModel.POS_MAX_MODIFIER_GROUPS}\n >\n {'New add-on group'}\n </Button>\n <Button\n variant=\"outlined\"\n aria-describedby={helpId}\n onClick={() => setGroups([...modifierGroups, newWriteInGroup()])}\n disabled={modifierGroups.length >= CommerceModel.POS_MAX_MODIFIER_GROUPS}\n >\n {'New write-in'}\n </Button>\n </Stack>\n </Box>\n {problem && modifierGroups.length ? (\n <Typography variant=\"body2\" color=\"warning.main\">\n {problem}\n </Typography>\n ) : null}\n </Stack>\n )\n})\n"],"names":["Box","Button","Collapse","FormControlLabel","IconButton","Stack","Switch","TextField","Typography","memo","useCallback","useId","useState","CommerceModel","PRODUCT_CHOICE_NOTE_MAX","PRODUCT_COMBO_ITEM_MAX","PRODUCT_COMBO_MAX_ITEMS","CardPictureField","newId","prefix","Math","random","toString","slice","centsFromDollars","value","number","round","Number","String","replace","isFinite","dollarsFromCents","cents","toFixed","priceByLabel","options","named","filter","option","name","trim","length","toLowerCase","newAddOnGroup","id","min","max","online","priceCents","newWriteInGroup","kind","maxLength","DEFAULT_WRITE_IN_LENGTH","withWriteInName","group","map","at","withVariantPrice","variantId","raw","priceCentsByVariant","rest","next","Object","keys","withChoiceCard","patch","url","imageUrl","note","items","includes","split","item","Boolean","WriteInFields","props","edit","remove","editOption","entry","example","digitsOnly","spacing","variant","color","direction","sx","alignItems","flexWrap","rowGap","label","size","placeholder","onChange","event","target","flex","minWidth","theme","MAX_WRITE_IN_LENGTH","helperText","width","slotProps","htmlInput","inputMode","defaultValue","onBlur","onClick","control","checked","ProductAddOnsFields","modifierGroups","variants","update","pick","helpId","pricedByVariant","setPricedByVariant","cardOpen","setCardOpen","setGroups","groups","editGroup","index","replaceOption","groupIndex","optionIndex","problem","modifierGroupsProblem","variesByVariant","byLabel","role","aria-label","border","borderColor","borderRadius","p","modifierGroupIsWriteIn","_group","nameOnOrder","optionKey","byVariantOpen","hasCard","cardShown","choiceLabel","aria-expanded","open","_option","in","unmountOnExit","pl","pt","display","gridTemplateColumns","xs","sm","gap","variantPriceLabel","multiline","minRows","Array","isArray","join","disabled","POS_MAX_MODIFIER_OPTIONS","aria-describedby","POS_MAX_MODIFIER_GROUPS"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;;AAEA,SACEA,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,gBAAgB,EAChBC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,IAAI,EAAEC,WAAW,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,QAAO;AAC1D,YAAYC,mBAAmB,uBAAa;AAC5C,SAASC,uBAAuB,EAAEC,sBAAsB,EAAEC,uBAAuB,QAAQ,oCAAgC;AACzH,SAASC,gBAAgB,QAA+B,wCAAoC;AAe5F,SAASC,MAAMC,MAAc;IAC3B,OAAO,GAAGA,SAASC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG,KAAK;AAC9D;AAEA,qDAAqD,GACrD,SAASC,iBAAiBC,KAAa;IACrC,MAAMC,SAASN,KAAKO,KAAK,CAACC,OAAOC,OAAOJ,OAAOK,OAAO,CAAC,YAAY,OAAO;IAC1E,OAAOF,OAAOG,QAAQ,CAACL,WAAWA,SAAS,IAAIA,SAAS;AAC1D;AAEA,yDAAyD,GACzD,SAASM,iBAAiBC,KAAyB;IACjD,OAAOA,QAAQ,AAACA,CAAAA,QAAQ,GAAE,EAAGC,OAAO,CAAC,KAAK;AAC5C;AAEA;;;CAGC,GACD,OAAO,SAASC,aAAaC,OAA6D;IACxF,MAAMC,QAAQD,QAAQE,MAAM,CAAC,CAACC;YAAWA;gBAAAA,eAAAA,OAAOC,IAAI,qBAAXD,aAAaE,IAAI;;IAC1D,OAAOJ,MAAMK,MAAM,KAAK,IAAI,CAAC,SAAS,EAAEL,KAAK,CAAC,EAAE,CAACG,IAA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scroll-table.compon
39
39
  import { useContentStable } from "@aglyn/shared-ui-jsx/hooks/use-content-stable";
40
40
  import { EntitlementUpsell, useCommerceEntitlement } from "./entitlement-gate.component.js";
41
41
  import { PRODUCT_EDITOR_ZONE } from "./product-zones.js";
42
+ import ProductTrafficCard from "./product-traffic-card.component.js";
42
43
  import { MembersVideosField, PaidDownloadAddButton, PaidMediaProtection } from "./paid-media.js";
43
44
  import { ProductCheckInFields } from "./product-check-in-fields.component.js";
44
45
  import { ProductRegisterFields, ProductSellOnlineField } from "./product-register-fields.component.js";
@@ -1878,6 +1879,10 @@ const MemoPaidDownloadAddButton = /*#__PURE__*/ memo(PaidDownloadAddButton);
1878
1879
  hasImage: Boolean((_current_seo7 = current.seo) == null ? void 0 : _current_seo7.imageUrl),
1879
1880
  proposeValues: proposeSeoValues
1880
1881
  }) : null,
1882
+ (product == null ? void 0 : product.$id) ? /*#__PURE__*/ _jsx(ProductTrafficCard, {
1883
+ hostId: hostId,
1884
+ slug: product.slug
1885
+ }) : null,
1881
1886
  error && error !== matrixProblem ? /*#__PURE__*/ _jsx(Alert, {
1882
1887
  severity: "warning",
1883
1888
  children: error