@arbidocs/blocks 0.5.117 → 0.5.118

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 (100) hide show
  1. package/dist/{ConnectedCallDock-OZBTU3IT.cjs → ConnectedCallDock-E7RMQMMT.cjs} +15 -15
  2. package/dist/{ConnectedCallDock-OZBTU3IT.cjs.map → ConnectedCallDock-E7RMQMMT.cjs.map} +1 -1
  3. package/dist/{ConnectedCallRoom-VMZE2NFP.cjs → ConnectedCallRoom-FF7X6LQ2.cjs} +8 -8
  4. package/dist/{ConnectedCallRoom-VMZE2NFP.cjs.map → ConnectedCallRoom-FF7X6LQ2.cjs.map} +1 -1
  5. package/dist/{ConnectedNativeDocxComparison-7OUKTKYP.cjs → ConnectedNativeDocxComparison-PB2LXT5U.cjs} +16 -16
  6. package/dist/{ConnectedNativeDocxComparison-7OUKTKYP.cjs.map → ConnectedNativeDocxComparison-PB2LXT5U.cjs.map} +1 -1
  7. package/dist/{ConnectedProductionSetDialog-4EAY6KAZ.cjs → ConnectedProductionSetDialog-LHB4VQWC.cjs} +3 -3
  8. package/dist/{ConnectedProductionSetDialog-4EAY6KAZ.cjs.map → ConnectedProductionSetDialog-LHB4VQWC.cjs.map} +1 -1
  9. package/dist/{ConnectedStreamedWordArtifact-7V24ZDAC.cjs → ConnectedStreamedWordArtifact-S7ICDK5T.cjs} +16 -16
  10. package/dist/{ConnectedStreamedWordArtifact-7V24ZDAC.cjs.map → ConnectedStreamedWordArtifact-S7ICDK5T.cjs.map} +1 -1
  11. package/dist/{DocumentReviewCard-OCPFVMLD.cjs → DocumentReviewCard-L472OMQS.cjs} +15 -15
  12. package/dist/{DocumentReviewCard-OCPFVMLD.cjs.map → DocumentReviewCard-L472OMQS.cjs.map} +1 -1
  13. package/dist/{FilesViewerDialog-KLRDIYEH.cjs → FilesViewerDialog-JK25HKKF.cjs} +43 -43
  14. package/dist/{FilesViewerDialog-KLRDIYEH.cjs.map → FilesViewerDialog-JK25HKKF.cjs.map} +1 -1
  15. package/dist/{WorkspaceTableView-IMAZICIZ.cjs → WorkspaceTableView-JCTDEMIL.cjs} +8 -8
  16. package/dist/{WorkspaceTableView-IMAZICIZ.cjs.map → WorkspaceTableView-JCTDEMIL.cjs.map} +1 -1
  17. package/dist/agents/index.cjs +296 -296
  18. package/dist/{ai-7U4B4CVF.cjs → ai-OBS67QV4.cjs} +20 -20
  19. package/dist/ai-OBS67QV4.cjs.map +1 -0
  20. package/dist/calls/index.cjs +121 -121
  21. package/dist/chat/index.cjs +1 -1
  22. package/dist/{chunk-Q6DQGGP4.cjs → chunk-325GVZE6.cjs} +3 -3
  23. package/dist/{chunk-Q6DQGGP4.cjs.map → chunk-325GVZE6.cjs.map} +1 -1
  24. package/dist/{chunk-WW6LXQY6.cjs → chunk-3LNUQYAF.cjs} +11 -11
  25. package/dist/{chunk-WW6LXQY6.cjs.map → chunk-3LNUQYAF.cjs.map} +1 -1
  26. package/dist/{chunk-OZVDOAXG.cjs → chunk-5XAJ4N2S.cjs} +4 -4
  27. package/dist/{chunk-OZVDOAXG.cjs.map → chunk-5XAJ4N2S.cjs.map} +1 -1
  28. package/dist/{chunk-BW5MF464.cjs → chunk-6ULADDBW.cjs} +4 -4
  29. package/dist/{chunk-BW5MF464.cjs.map → chunk-6ULADDBW.cjs.map} +1 -1
  30. package/dist/{chunk-7XT5B2DZ.cjs → chunk-7IPIKMCY.cjs} +46 -46
  31. package/dist/{chunk-7XT5B2DZ.cjs.map → chunk-7IPIKMCY.cjs.map} +1 -1
  32. package/dist/{chunk-H5OLHP2U.cjs → chunk-7OPOPYV6.cjs} +3 -3
  33. package/dist/{chunk-H5OLHP2U.cjs.map → chunk-7OPOPYV6.cjs.map} +1 -1
  34. package/dist/{chunk-4VZZWYEC.cjs → chunk-BQ5RIWWT.cjs} +3 -3
  35. package/dist/{chunk-4VZZWYEC.cjs.map → chunk-BQ5RIWWT.cjs.map} +1 -1
  36. package/dist/{chunk-D7ICHGWM.cjs → chunk-CB3YYZAU.cjs} +58 -58
  37. package/dist/{chunk-D7ICHGWM.cjs.map → chunk-CB3YYZAU.cjs.map} +1 -1
  38. package/dist/{chunk-MC4F2URI.cjs → chunk-CPG7II4E.cjs} +28 -28
  39. package/dist/{chunk-MC4F2URI.cjs.map → chunk-CPG7II4E.cjs.map} +1 -1
  40. package/dist/{chunk-VTYJAZDU.cjs → chunk-K6AUKKUN.cjs} +10 -10
  41. package/dist/{chunk-VTYJAZDU.cjs.map → chunk-K6AUKKUN.cjs.map} +1 -1
  42. package/dist/{chunk-UNDQYTRF.cjs → chunk-KHAO7ZTO.cjs} +6 -6
  43. package/dist/{chunk-UNDQYTRF.cjs.map → chunk-KHAO7ZTO.cjs.map} +1 -1
  44. package/dist/{chunk-UUENH4BJ.cjs → chunk-KXIRVKCJ.cjs} +3 -3
  45. package/dist/{chunk-UUENH4BJ.cjs.map → chunk-KXIRVKCJ.cjs.map} +1 -1
  46. package/dist/{chunk-XKDUPU7B.cjs → chunk-L6APDO3Y.cjs} +3 -3
  47. package/dist/{chunk-XKDUPU7B.cjs.map → chunk-L6APDO3Y.cjs.map} +1 -1
  48. package/dist/{chunk-E4DUXU5K.cjs → chunk-MMVDVHKE.cjs} +7 -7
  49. package/dist/{chunk-E4DUXU5K.cjs.map → chunk-MMVDVHKE.cjs.map} +1 -1
  50. package/dist/{chunk-5QUL5BZO.cjs → chunk-NNUK5ZM7.cjs} +4 -4
  51. package/dist/{chunk-5QUL5BZO.cjs.map → chunk-NNUK5ZM7.cjs.map} +1 -1
  52. package/dist/{chunk-4NPCDS2X.cjs → chunk-NY3YUCOW.cjs} +3 -3
  53. package/dist/{chunk-4NPCDS2X.cjs.map → chunk-NY3YUCOW.cjs.map} +1 -1
  54. package/dist/{chunk-E4BLRF2L.cjs → chunk-O4F77VSO.cjs} +5 -5
  55. package/dist/{chunk-E4BLRF2L.cjs.map → chunk-O4F77VSO.cjs.map} +1 -1
  56. package/dist/{chunk-6DCIZA3X.cjs → chunk-OPH4UZQN.cjs} +71 -71
  57. package/dist/{chunk-6DCIZA3X.cjs.map → chunk-OPH4UZQN.cjs.map} +1 -1
  58. package/dist/{chunk-TDN33HSK.cjs → chunk-P2MOLUFO.cjs} +6 -6
  59. package/dist/{chunk-TDN33HSK.cjs.map → chunk-P2MOLUFO.cjs.map} +1 -1
  60. package/dist/{chunk-3ODEWSRO.cjs → chunk-P77YTTJ3.cjs} +4 -4
  61. package/dist/{chunk-3ODEWSRO.cjs.map → chunk-P77YTTJ3.cjs.map} +1 -1
  62. package/dist/{chunk-3U36VYMD.cjs → chunk-PVPRVI54.cjs} +26 -26
  63. package/dist/{chunk-3U36VYMD.cjs.map → chunk-PVPRVI54.cjs.map} +1 -1
  64. package/dist/{chunk-LFRNBT2I.cjs → chunk-QOXK5O6M.cjs} +10 -10
  65. package/dist/{chunk-LFRNBT2I.cjs.map → chunk-QOXK5O6M.cjs.map} +1 -1
  66. package/dist/{chunk-2W5E62EY.cjs → chunk-SGYSDABK.cjs} +6 -6
  67. package/dist/{chunk-2W5E62EY.cjs.map → chunk-SGYSDABK.cjs.map} +1 -1
  68. package/dist/{chunk-57EE6CMW.cjs → chunk-SUYPXUE6.cjs} +13 -13
  69. package/dist/{chunk-57EE6CMW.cjs.map → chunk-SUYPXUE6.cjs.map} +1 -1
  70. package/dist/{chunk-4IOYQLKG.cjs → chunk-TP5PGWIO.cjs} +3 -3
  71. package/dist/{chunk-4IOYQLKG.cjs.map → chunk-TP5PGWIO.cjs.map} +1 -1
  72. package/dist/{chunk-7X3FS5HQ.cjs → chunk-TT4IF52H.cjs} +35 -35
  73. package/dist/{chunk-7X3FS5HQ.cjs.map → chunk-TT4IF52H.cjs.map} +1 -1
  74. package/dist/{chunk-GQXPNIRE.cjs → chunk-WAV762GP.cjs} +6 -6
  75. package/dist/{chunk-GQXPNIRE.cjs.map → chunk-WAV762GP.cjs.map} +1 -1
  76. package/dist/{chunk-MZ2KZXNU.cjs → chunk-WXUU3COI.cjs} +3 -3
  77. package/dist/{chunk-MZ2KZXNU.cjs.map → chunk-WXUU3COI.cjs.map} +1 -1
  78. package/dist/{chunk-LYTIQQQ2.cjs → chunk-XZYIS2JZ.cjs} +3 -3
  79. package/dist/{chunk-LYTIQQQ2.cjs.map → chunk-XZYIS2JZ.cjs.map} +1 -1
  80. package/dist/{chunk-BKY2LAV2.cjs → chunk-YDPLSXHB.cjs} +4 -4
  81. package/dist/{chunk-BKY2LAV2.cjs.map → chunk-YDPLSXHB.cjs.map} +1 -1
  82. package/dist/{chunk-7TEUGFIL.cjs → chunk-YGXOKB5Z.cjs} +4 -4
  83. package/dist/{chunk-7TEUGFIL.cjs.map → chunk-YGXOKB5Z.cjs.map} +1 -1
  84. package/dist/{chunk-VBL3SHWX.cjs → chunk-ZCIQBHH5.cjs} +45 -45
  85. package/dist/{chunk-VBL3SHWX.cjs.map → chunk-ZCIQBHH5.cjs.map} +1 -1
  86. package/dist/connect/docx.cjs +19 -19
  87. package/dist/connect/index.cjs +965 -965
  88. package/dist/connect/viewer.cjs +33 -33
  89. package/dist/embed/index.cjs +37 -37
  90. package/dist/files/index.cjs +224 -224
  91. package/dist/index.cjs +1581 -1581
  92. package/dist/settings/index.cjs +147 -147
  93. package/dist/shell/index.cjs +80 -80
  94. package/dist/studio/index.cjs +23 -23
  95. package/dist/workflow-canvas/index.cjs +52 -52
  96. package/node_modules/@arbidocs/coedit/package.json +1 -1
  97. package/node_modules/@docx-editor.dev/core/dist/chunk-T6K2QYNZ.cjs +1 -1
  98. package/node_modules/@docx-editor.dev/core/dist/chunk-U4JZVSOE.js +1 -1
  99. package/package.json +5 -5
  100. package/dist/ai-7U4B4CVF.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  'use strict';
3
3
 
4
- var chunkKQF7POTG_cjs = require('./chunk-KQF7POTG.cjs');
5
4
  var chunkJV5TVUOU_cjs = require('./chunk-JV5TVUOU.cjs');
5
+ var chunkKQF7POTG_cjs = require('./chunk-KQF7POTG.cjs');
6
6
  var chunkPLIF5CUV_cjs = require('./chunk-PLIF5CUV.cjs');
7
7
  var lucideReact = require('lucide-react');
8
8
  var ui = require('@arbidocs/react/ui');
@@ -555,5 +555,5 @@ exports.prefetchChunk = prefetchChunk;
555
555
  exports.requestReload = requestReload;
556
556
  exports.workspaceKindColor = workspaceKindColor;
557
557
  exports.workspaceKindMeta = workspaceKindMeta;
558
- //# sourceMappingURL=chunk-4NPCDS2X.cjs.map
559
- //# sourceMappingURL=chunk-4NPCDS2X.cjs.map
558
+ //# sourceMappingURL=chunk-NY3YUCOW.cjs.map
559
+ //# sourceMappingURL=chunk-NY3YUCOW.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shell/Workspace.tsx","../src/shell/MobileBars.tsx","../src/shell/reload-policy.ts"],"names":["Globe","Users","Lock","jsxs","jsx","testIdOr","cn","Fragment","DropdownMenu","DropdownMenuTrigger","ChevronDown","DropdownMenuContent","DropdownMenuItem","LayoutGrid","Plus","DropdownMenuSeparator","DropdownMenuLabel","prefixedTestId","Menu","useRef","useShellBottomInset","ActionLink","notify"],"mappings":";;;;;;;;;;;AAqBO,IAAM,6BAAA,GAAqD;AAAA,EAChE,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS;AACX;AAQO,SAAS,iBAAA,CACd,MACA,MAAA,EAKA;AACA,EAAA,MAAM,CAAA,GAAI,EAAE,GAAG,6BAAA,EAA+B,GAAG,MAAA,EAAO;AACxD,EAAA,IAAI,IAAA,KAAS,QAAA;AACX,IAAA,OAAO,EAAE,IAAA,EAAMA,iBAAA,EAAO,OAAO,CAAA,CAAE,MAAA,EAAQ,MAAM,gCAAA,EAAiC;AAChF,EAAA,IAAI,IAAA,KAAS,QAAA;AACX,IAAA,OAAO,EAAE,IAAA,EAAMC,iBAAA,EAAO,OAAO,CAAA,CAAE,MAAA,EAAQ,MAAM,wCAAA,EAAyC;AACxF,EAAA,OAAO,EA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AAK,GAAA,EAAI;AACxB,EAAA,MAAA,CAAO,gBAAA,CAAiB,qBAAqB,oBAAoB,CAAA;AACjE,EAAA,KAAA,MAAW,QAAQ,eAAA,EAAiB;AAClC,IAAA,QAAA,CAAS,gBAAA,CAAiB,MAAM,UAAA,EAAY,EAAE,SAAS,IAAA,EAAM,OAAA,EAAS,MAAM,CAAA;AAAA,EAC9E;AACF","file":"chunk-4NPCDS2X.cjs","sourcesContent":["import type { ComponentType } from 'react'\nimport { ChevronDown, Globe, LayoutGrid, Lock, Plus, Users } from 'lucide-react'\nimport {\n cn,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '@arbidocs/react/ui'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport type { ShellRecentWorkspace, ShellWorkspace, ShellWorkspaceKind } from './types'\n\n/** The three workspace-kind names (badge title, type glyph name, subtitle). */\nexport interface WorkspaceKindLabels {\n common: string\n shared: string\n private: string\n}\n\nexport const DEFAULT_WORKSPACE_KIND_LABELS: WorkspaceKindLabels = {\n common: 'Common',\n shared: 'Shared',\n private: 'Private',\n}\n\n/**\n * Workspace type drives the initial-badge fill and a quiet secondary glyph:\n * private (just you) -> navy, lock shared (several) -> selection tint, people\n * common (public) -> neutral, globe\n * Navy is identity and cyan is reserved for ARBI/AI, so \"shared\" is the selection tint.\n */\nexport function workspaceKindMeta(\n kind: ShellWorkspaceKind,\n labels?: Partial<WorkspaceKindLabels>\n): {\n Icon: ComponentType<{ className?: string; 'aria-label'?: string; 'data-testid'?: string }>\n label: string\n fill: string\n} {\n const l = { ...DEFAULT_WORKSPACE_KIND_LABELS, ...labels }\n if (kind === 'common')\n return { Icon: Globe, label: l.common, fill: 'bg-muted text-muted-foreground' }\n if (kind === 'shared')\n return { Icon: Users, label: l.shared, fill: 'bg-secondary text-secondary-foreground' }\n return { Icon: Lock, label: l.private, fill: 'bg-primary text-primary-foreground' }\n}\n\n/** The kind's hue as a CSS colour, for glyphs painted by SVG fill (the workspace shield). */\nexport function workspaceKindColor(kind: ShellWorkspaceKind): string {\n if (kind === 'common') return 'var(--color-muted-foreground)'\n if (kind === 'shared') return 'var(--color-secondary)'\n return 'var(--color-primary)'\n}\n\n/** Overridable ids of the workspace identity; defaults are the current ids. */\ntype WorkspaceIdentityTestIds = Partial<Record<'initial' | 'type' | 'projectName', string>>\n\nexport interface WorkspaceIdentityProps {\n workspace: ShellWorkspace\n /** Show name + type/project line beside the badge; otherwise the badge alone. */\n expanded: boolean\n /** Selected (nav-row) styling of the name. */\n isActive?: boolean\n /** Reword the kind names. */\n labels?: Partial<WorkspaceKindLabels>\n /** Part ids; defaults are the current ids. */\n testIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * Non-interactive guts of the workspace head: the initial badge (with a tiny type glyph) and,\n * when expanded, the name and the project/type line. Hosted by the switcher trigger and by the\n * workspace settings header, so it never nests a button.\n */\nexport function WorkspaceIdentity({\n workspace,\n expanded,\n isActive = false,\n labels,\n testIds,\n}: WorkspaceIdentityProps) {\n const kind = workspaceKindMeta(workspace.kind, labels)\n const badge = (\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n data-testid={testIdOr(testIds?.initial, { testId: 'sidebar-workspace-card-initial' })}\n className={cn(\n 'flex size-7 flex-shrink-0 items-center justify-center rounded-md text-sm font-semibold leading-none',\n kind.fill\n )}\n >\n {workspace.name.charAt(0).toUpperCase()}\n </span>\n {/* Type as a tiny overlay on the badge: status reads at the icon, not after the name. */}\n <span className=\"absolute -bottom-1 -right-1 flex size-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={testIdOr(testIds?.type, { testId: 'sidebar-workspace-card-type' })}\n className=\"size-2.5 text-muted-foreground\"\n />\n </span>\n </span>\n )\n\n if (!expanded)\n return <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n\n return (\n <>\n <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n <div className=\"ml-2.5 flex min-w-0 flex-1 flex-col text-left\">\n <span\n // 600: the name of the thing you are inside, above a lighter project line.\n className={cn(\n 'min-w-0 truncate text-left text-sm font-semibold capitalize leading-tight transition-colors duration-100',\n isActive ? 'text-accent-foreground' : 'text-foreground'\n )}\n >\n {workspace.name}\n </span>\n {!workspace.projectName && (\n <span className=\"mt-0.5 truncate text-xs text-muted-foreground\">{kind.label}</span>\n )}\n {workspace.projectName && (\n <span\n className=\"mt-0.5 flex min-w-0\"\n data-testid={testIdOr(testIds?.projectName, {\n testId: 'sidebar-workspace-card-project-name',\n })}\n >\n {workspace.projectLine ?? (\n <span className=\"truncate text-xs text-muted-foreground\">\n {workspace.projectName}\n </span>\n )}\n </span>\n )}\n </div>\n </>\n )\n}\n\n/**\n * Entity nouns plus the switcher's strings. `plural` arrives lowercased and `singular`\n * capitalized in the functions below.\n */\nexport interface WorkspaceSwitcherLabels extends WorkspaceKindLabels {\n /** Entity nouns, e.g. { plural: 'workspaces', singular: 'workspace' }. */\n plural: string\n singular: string\n /** The trigger's accessible name. */\n switchWorkspace: (name: string, plural: string) => string\n allWorkspaces: (plural: string) => string\n newWorkspace: (singular: string) => string\n recentWorkspaces: (plural: string) => string\n}\n\nexport const DEFAULT_WORKSPACE_SWITCHER_LABELS: WorkspaceSwitcherLabels = {\n ...DEFAULT_WORKSPACE_KIND_LABELS,\n plural: 'workspaces',\n singular: 'workspace',\n switchWorkspace: (name, plural) => `${name} — switch ${plural}`,\n allWorkspaces: (plural) => `All ${plural}`,\n newWorkspace: (singular) => `New ${singular}`,\n recentWorkspaces: (plural) => `Recent ${plural}`,\n}\n\nexport interface WorkspaceSwitcherProps {\n workspace: ShellWorkspace\n /** Other workspaces to jump to (the app orders and caps them). */\n recent?: ShellRecentWorkspace[]\n /** Icon-only trigger (the sidebar rail). */\n compact?: boolean\n /** `appbar`: the phone app bar's title, name + chevron on one line. */\n variant?: 'sidebar' | 'appbar'\n onSwitch: (workspace: ShellWorkspace) => void\n /** Return to the workspaces list; leaves the workspace open. */\n onGoToList: () => void\n onNewWorkspace: () => void\n /**\n * When set, \"New workspace\" is shown disabled with this explanation under it (e.g. the user may\n * not create workspaces on this deployment).\n */\n newWorkspaceDisabledReason?: string\n /** Entity nouns and menu strings; any subset (the nouns default to workspace(s)). */\n labels?: Partial<WorkspaceSwitcherLabels>\n className?: string\n /** Trigger id (default `workspace-switcher-trigger`). */\n testId?: string\n /**\n * Part ids; defaults are the current ids. `switchItem`, `type` and `lastSeen` are prefixes\n * (`<prefix>-<workspace id>`).\n */\n testIds?: Partial<Record<'menu' | 'all' | 'new' | 'switchItem' | 'type' | 'lastSeen', string>>\n /** Ids forwarded to the trigger's workspace identity. */\n identityTestIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * The current-workspace control as a dropdown: \"All workspaces\", \"New workspace\", then the\n * recent workspaces to jump straight into.\n */\nexport function WorkspaceSwitcher({\n workspace,\n recent = [],\n compact = false,\n variant = 'sidebar',\n onSwitch,\n onGoToList,\n onNewWorkspace,\n newWorkspaceDisabledReason,\n labels,\n className,\n testId,\n testIds,\n identityTestIds,\n}: WorkspaceSwitcherProps) {\n const l = { ...DEFAULT_WORKSPACE_SWITCHER_LABELS, ...labels }\n const plural = l.plural.toLowerCase()\n const singular = l.singular.charAt(0).toUpperCase() + l.singular.slice(1)\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n data-slot=\"workspace-switcher\"\n data-testid={testIdOr(testId, { testId: 'workspace-switcher-trigger' })}\n aria-label={l.switchWorkspace(workspace.name, plural)}\n className={cn(\n 'group flex min-w-0 items-center rounded-md transition-colors duration-100 hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',\n variant === 'appbar'\n ? 'h-11 max-w-full gap-1 px-2'\n : compact\n ? 'h-12 w-12 justify-center'\n : 'h-12 w-full px-2',\n className\n )}\n >\n {variant === 'appbar' ? (\n <span className=\"min-w-0 truncate text-base font-semibold text-foreground\">\n {workspace.name}\n </span>\n ) : (\n <WorkspaceIdentity\n workspace={workspace}\n expanded={!compact}\n labels={l}\n testIds={identityTestIds}\n />\n )}\n {!(compact && variant === 'sidebar') && (\n <ChevronDown\n aria-hidden=\"true\"\n className=\"ml-auto size-4 flex-shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180\"\n />\n )}\n </button>\n </DropdownMenuTrigger>\n {/* Expanded menus follow the trigger width so they stay inside the sidebar. */}\n <DropdownMenuContent\n align=\"start\"\n className={cn(\n 'border-0 max-w-[calc(100vw-1.5rem)]',\n variant === 'sidebar' && !compact\n ? 'w-[var(--radix-dropdown-menu-trigger-width)]'\n : 'w-60'\n )}\n data-testid={testIdOr(testIds?.menu, { testId: 'workspace-switcher-menu' })}\n >\n <DropdownMenuItem\n onClick={onGoToList}\n data-testid={testIdOr(testIds?.all, { testId: 'workspace-switcher-all' })}\n className=\"gap-2\"\n >\n <LayoutGrid className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n {l.allWorkspaces(plural)}\n </DropdownMenuItem>\n <DropdownMenuItem\n onClick={newWorkspaceDisabledReason ? undefined : onNewWorkspace}\n disabled={!!newWorkspaceDisabledReason}\n title={newWorkspaceDisabledReason}\n data-testid={testIdOr(testIds?.new, { testId: 'workspace-switcher-new' })}\n className=\"gap-2\"\n >\n <Plus className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n <span className=\"flex min-w-0 flex-col\">\n {l.newWorkspace(singular)}\n {newWorkspaceDisabledReason && (\n <span className=\"text-xs text-muted-foreground\">{newWorkspaceDisabledReason}</span>\n )}\n </span>\n </DropdownMenuItem>\n {recent.length > 0 && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuLabel className=\"text-xs font-normal text-muted-foreground\">\n {l.recentWorkspaces(plural)}\n </DropdownMenuLabel>\n {recent.map((w) => {\n const kind = workspaceKindMeta(w.kind, l)\n return (\n <DropdownMenuItem\n key={w.id}\n onClick={() => onSwitch(w)}\n data-testid={prefixedTestId(testIds?.switchItem, w.id, {\n testId: `workspace-switch-${w.id}`,\n })}\n className=\"gap-2\"\n >\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n className={cn(\n 'flex size-6 flex-shrink-0 items-center justify-center rounded text-xs font-semibold leading-none',\n kind.fill\n )}\n >\n {w.name.charAt(0).toUpperCase()}\n </span>\n <span className=\"absolute -bottom-1 -right-1 flex size-3 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={prefixedTestId(testIds?.type, w.id, {\n testId: `workspace-type-${w.id}`,\n })}\n className=\"size-2 text-muted-foreground\"\n />\n </span>\n </span>\n <span className=\"min-w-0 flex-1 truncate capitalize\">{w.name}</span>\n {w.lastSeen && (\n <span\n className=\"ml-2 flex-shrink-0 text-xs tabular-nums text-muted-foreground\"\n data-testid={prefixedTestId(testIds?.lastSeen, w.id, {\n testId: `workspace-last-seen-${w.id}`,\n })}\n >\n {w.lastSeen}\n </span>\n )}\n </DropdownMenuItem>\n )\n })}\n </>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n","import { useRef, type ReactNode } from 'react'\nimport { Menu } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ActionLink } from '../components/ActionLink'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport { useShellBottomInset } from '../lib/bottom-inset'\nimport type { NavItem } from './types'\n\n/** Fixed strings of the phone bars. */\nexport interface MobileBarsLabels {\n /** The menu button (the `menuLabel` prop wins). */\n openNavigationMenu: string\n /** The tab bar's accessible name (the `label` prop wins). */\n workspaceSections: string\n}\n\nexport const DEFAULT_MOBILE_BARS_LABELS: MobileBarsLabels = {\n openNavigationMenu: 'Open navigation menu',\n workspaceSections: 'Workspace sections',\n}\n\nexport interface MobileAppBarProps {\n /** Show the menu button that opens the drawer (nothing to open on a list page with no sidebar). */\n showMenu?: boolean\n onMenu?: () => void\n /** Replaces the brand mark (e.g. the workspace switcher). */\n title?: ReactNode\n /** Brand mark shown when there is no `title`. */\n logo?: ReactNode\n /** Right-aligned controls that fit (ask, offline pill, bell, account). */\n actions?: ReactNode\n menuLabel?: string\n labels?: Partial<Pick<MobileBarsLabels, 'openNavigationMenu'>>\n className?: string\n 'data-testid'?: string\n /** Menu button id (default `mobile-nav-toggle`). */\n menuTestId?: string\n}\n\n/**\n * The slim phone app bar (56px): menu button, a title slot and an actions slot. The app mounts\n * it only on small screens; the controls that do not fit live in the drawer.\n */\nexport function MobileAppBar({\n showMenu = true,\n onMenu,\n title,\n logo,\n actions,\n menuLabel,\n labels,\n className,\n 'data-testid': testId,\n menuTestId,\n}: MobileAppBarProps) {\n return (\n <div\n data-slot=\"mobile-app-bar\"\n data-testid={testId}\n className={cn(\n 'sm:hidden flex h-14 flex-shrink-0 items-center gap-1 bg-background pl-1 pr-2 pt-safe',\n className\n )}\n >\n {showMenu && (\n <button\n type=\"button\"\n onClick={onMenu}\n className=\"flex size-11 shrink-0 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted\"\n aria-label={\n menuLabel ?? labels?.openNavigationMenu ?? DEFAULT_MOBILE_BARS_LABELS.openNavigationMenu\n }\n data-testid={testIdOr(menuTestId, { testId: 'mobile-nav-toggle' })}\n >\n <Menu className=\"size-5\" />\n </button>\n )}\n <div className={cn('flex min-w-0 flex-1 items-center', !showMenu && 'pl-3')}>\n {title ?? logo}\n </div>\n {actions && <div className=\"flex shrink-0 items-center gap-0.5\">{actions}</div>}\n </div>\n )\n}\n\n/**\n * A tab's label. It wraps at word boundaries and is never clipped or cut with an ellipsis; a tab\n * narrower than 4.5rem sets it one size smaller so a long single word still fits, and an item with\n * a `shortLabel` shows that one while its tab is narrower than 5.5rem.\n */\nfunction TabLabel({ item }: { item: NavItem }) {\n const wrap =\n 'max-w-full text-balance px-0.5 text-center [overflow-wrap:normal] @max-[4.5rem]:text-[10px]'\n if (!item.shortLabel) return <span className={wrap}>{item.label}</span>\n return (\n <>\n <span data-slot=\"tab-short-label\" aria-hidden=\"true\" className={cn(wrap, '@[5.5rem]:hidden')}>\n {item.shortLabel}\n </span>\n <span className={cn(wrap, 'hidden @[5.5rem]:block')}>{item.label}</span>\n <span className=\"sr-only @[5.5rem]:hidden\">{item.label}</span>\n </>\n )\n}\n\nexport interface MobileTabBarProps {\n /** The workspace's main areas; test ids are `{testIdPrefix}-{id}` (prefix default `mobile-tab`). */\n items: NavItem[]\n label?: string\n labels?: Partial<Pick<MobileBarsLabels, 'workspaceSections'>>\n testIdPrefix?: string\n className?: string\n 'data-testid'?: string\n}\n\n/**\n * Phone bottom navigation: a 64px tinted bar of the main areas. The drawer carries the same\n * destinations with counts, so nothing is reachable only here. The app mounts it on small\n * screens only.\n */\nexport function MobileTabBar({\n items,\n label,\n labels,\n testIdPrefix,\n className,\n 'data-testid': testId,\n}: MobileTabBarProps) {\n const navRef = useRef<HTMLElement>(null)\n // Floating elements (install prompt, toasts) read the bar's height from `--shell-bottom-inset`.\n useShellBottomInset(navRef)\n return (\n <nav\n ref={navRef}\n aria-label={\n label ?? labels?.workspaceSections ?? DEFAULT_MOBILE_BARS_LABELS.workspaceSections\n }\n data-slot=\"mobile-tab-bar\"\n data-testid={testIdOr(testId, { testId: 'mobile-tab-bar' })}\n className={cn(\n 'flex min-h-16 flex-shrink-0 items-stretch bg-sidebar px-2 pb-safe sm:hidden',\n className\n )}\n >\n {items.map((item) => (\n <ActionLink\n key={item.id}\n href={item.href}\n external={item.external}\n onSelect={item.onSelect}\n disabled={item.disabled}\n aria-current={item.active ? 'page' : undefined}\n className={cn(\n // Each tab is a size container: a `shortLabel` replaces the label when it is narrow.\n '@container flex min-h-12 min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-md text-[11px] leading-tight transition-colors',\n item.active\n ? 'font-semibold text-primary'\n : 'font-medium text-muted-foreground hover:text-foreground'\n )}\n data-testid={prefixedTestId(testIdPrefix, item.id, { testId: `mobile-tab-${item.id}` })}\n >\n {item.icon}\n <TabLabel item={item} />\n </ActionLink>\n ))}\n </nav>\n )\n}\n","/**\n * One policy for every automatic reload: when the running build is out of date, pick a moment\n * that costs the user nothing.\n *\n * After a deploy (or mid-rollout, while old and new pods both serve) the previous build's hashed\n * chunks can 404. Vite reports that as `vite:preloadError`. Reloading fetches the current\n * index.html (served no-cache) and its chunks, but reloading at once throws away whatever the\n * user is typing, so:\n *\n * - A failed prefetch (`prefetchChunk`) never reloads. Nothing on screen depends on it.\n * - A failed chunk the user is waiting for reloads at once, unless the user is on a sign-in form\n * or has unsaved input (a focused or edited field, or a `[data-reload-guard]` region).\n * - Otherwise the reload waits: the next route navigation becomes a full page load of its target,\n * or the page reloads once the user is idle with nothing unsaved.\n * - Per tab, at most one policy reload a minute. A second failure right after one is not a stale\n * build (a genuinely missing chunk, say), so it surfaces to the error boundary instead of looping.\n */\n\nimport { notify } from '@arbidocs/react/shell'\n\nexport const CHUNK_RELOAD_KEY = 'arbi_chunk_reload_at'\n\n/** A second failure within this window after a reload is not a stale build: let it surface. */\nconst RELOAD_GUARD_MS = 60_000\n/** A deferred reload waits until the user has done nothing for this long. */\nconst IDLE_MS = 10_000\nconst IDLE_CHECK_MS = 2_000\n\n/** Sign-in pages, and regions a host marks as holding unsaved work. */\nconst GUARD_SELECTOR =\n '[data-slot=\"auth-layout\"], input[type=\"password\"], input[autocomplete=\"one-time-code\"], [data-reload-guard]'\nconst NON_TEXT_INPUTS = new Set([\n 'button',\n 'submit',\n 'reset',\n 'checkbox',\n 'radio',\n 'hidden',\n 'range',\n 'color',\n 'file',\n 'image',\n])\n\nexport interface ReloadPolicyDeps {\n /** Reload the current page. */\n reload: () => void\n /** Full page load of `url` (instead of a client-side navigation). */\n load: (url: string, replace: boolean) => void\n now: () => number\n}\n\nconst browserDeps: ReloadPolicyDeps = {\n reload: () => window.location.reload(),\n load: (url, replace) => (replace ? window.location.replace(url) : window.location.assign(url)),\n now: () => Date.now(),\n}\n\nlet deps = browserDeps\nlet installed = false\n/** The build is out of date: the next route navigation loads the page fresh. */\nlet stale = false\n/** A chunk the user needed failed: reload as soon as nothing would be lost. */\nlet reloadWanted = false\nlet lastActivity = 0\nlet idleTimer: ReturnType<typeof setInterval> | undefined\nlet restoreNavigation: (() => void) | null = null\n/** Fields the user typed into. */\nconst edited = new Set<Element>()\n/** Errors from `prefetchChunk` loads, so the preload-error handler can tell them apart. */\nconst prefetchFailures = new WeakSet<object>()\n\nfunction isTextField(el: Element): boolean {\n if (el instanceof HTMLInputElement) return !NON_TEXT_INPUTS.has(el.type)\n return el instanceof HTMLTextAreaElement || (el as HTMLElement).isContentEditable === true\n}\n\nfunction hasText(el: Element): boolean {\n if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {\n return el.value.trim() !== ''\n }\n return (el.textContent ?? '').trim() !== ''\n}\n\n/**\n * Whether reloading now could cost the user something: a sign-in form, a `[data-reload-guard]`\n * region, a focused text field, or a field they typed into that still holds text.\n */\nexport function hasUnsavedInput(doc: Document = document): boolean {\n if (doc.querySelector(GUARD_SELECTOR)) return true\n const active = doc.activeElement\n if (active && active !== doc.body && isTextField(active)) return true\n for (const el of edited) {\n if (!el.isConnected) edited.delete(el)\n else if (hasText(el)) return true\n }\n return false\n}\n\n/** Take this tab's reload slot. False within the guard window, or when storage can't record it. */\nfunction claimReload(): boolean {\n const now = deps.now()\n let last = 0\n try {\n last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n } catch {\n // Unreadable: treat as never reloaded. Writing below decides.\n }\n if (last && now - last < RELOAD_GUARD_MS) return false\n try {\n sessionStorage.setItem(CHUNK_RELOAD_KEY, String(now))\n } catch {\n // Without the guard we can't tell a loop from a stale build: don't risk one.\n return false\n }\n return true\n}\n\nfunction guardHot(): boolean {\n try {\n const last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n return !!last && deps.now() - last < RELOAD_GUARD_MS\n } catch {\n return false\n }\n}\n\nfunction settle(): void {\n stale = false\n reloadWanted = false\n if (idleTimer !== undefined) clearInterval(idleTimer)\n idleTimer = undefined\n restoreNavigation?.()\n restoreNavigation = null\n}\n\nfunction reloadNow(): boolean {\n if (!claimReload()) {\n settle()\n return false\n }\n settle()\n deps.reload()\n return true\n}\n\n/** A client-side navigation to `url` becomes a full page load of it while the build is stale. */\nfunction loadsFresh(url: string | URL | null | undefined): string | null {\n if (!stale || url == null) return null\n const target = new URL(String(url), window.location.href)\n if (target.pathname === window.location.pathname) return null\n // Leaving a sign-in page establishes the session: a full load there races its persistence.\n if (document.querySelector(GUARD_SELECTOR)) return null\n return target.href\n}\n\nfunction interceptNavigation(): void {\n if (restoreNavigation) return\n const history = window.history\n const push = history.pushState\n const replace = history.replaceState\n let shownPath = window.location.pathname\n const wrap = (original: History['pushState'], replaceEntry: boolean): History['pushState'] =>\n function (this: History, data, unused, url) {\n const target = loadsFresh(url)\n if (target && claimReload()) {\n settle()\n deps.load(target, replaceEntry)\n return\n }\n original.call(this, data, unused, url)\n shownPath = window.location.pathname\n }\n history.pushState = wrap(push, false)\n history.replaceState = wrap(replace, true)\n // Back/forward already changed the address: reloading loads that target.\n const onPopState = () => {\n if (window.location.pathname === shownPath) return\n shownPath = window.location.pathname\n if (!document.querySelector(GUARD_SELECTOR)) reloadNow()\n }\n window.addEventListener('popstate', onPopState)\n restoreNavigation = () => {\n history.pushState = push\n history.replaceState = replace\n window.removeEventListener('popstate', onPopState)\n }\n}\n\nfunction watchForIdle(): void {\n if (idleTimer !== undefined) return\n idleTimer = setInterval(() => {\n if (!reloadWanted) return\n const idle = document.visibilityState === 'hidden' || deps.now() - lastActivity >= IDLE_MS\n if (idle && !hasUnsavedInput()) reloadNow()\n }, IDLE_CHECK_MS)\n}\n\n/**\n * The running build is out of date (a chunk 404'd, or a new service worker took over): the next\n * route navigation loads its target fresh instead of rendering it client-side.\n */\nexport function markBuildStale(): void {\n stale = true\n interceptNavigation()\n}\n\nexport type ReloadOutcome = 'reloaded' | 'deferred' | 'guarded'\n\n/**\n * Reload onto the current build when nothing would be lost; otherwise defer to the next route\n * navigation or to the moment the user is idle with nothing unsaved. `guarded` means a policy\n * reload just happened in this tab, so the failure should surface instead.\n */\nexport function requestReload(): ReloadOutcome {\n if (guardHot()) return 'guarded'\n if (!hasUnsavedInput()) return reloadNow() ? 'reloaded' : 'guarded'\n reloadWanted = true\n markBuildStale()\n watchForIdle()\n return 'deferred'\n}\n\n/**\n * Load a chunk ahead of need (warming a route the user may open next). Never rejects, and a\n * failure never reloads the page: it only marks the build stale so the next navigation loads\n * fresh.\n */\nexport function prefetchChunk(load: () => Promise<unknown>): Promise<void> {\n let loading: Promise<unknown>\n try {\n loading = load()\n } catch (error) {\n loading = Promise.reject(error)\n }\n return loading.then(\n () => undefined,\n (error: unknown) => {\n if (typeof error === 'object' && error !== null) prefetchFailures.add(error)\n }\n )\n}\n\nfunction decide(payload: unknown): void {\n const prefetch = typeof payload === 'object' && payload !== null && prefetchFailures.has(payload)\n // Offline the chunk simply couldn't be downloaded (it isn't cached yet). Reloading can't fix\n // that and would throw away what's on screen; say what happened instead, and let the failed\n // import reach the nearest error boundary as usual.\n if (typeof navigator !== 'undefined' && navigator.onLine === false) {\n if (!prefetch) {\n notify.warning(\"This part of ARBI isn't available offline yet\", {\n description: 'Reconnect to open it. Once you have, it will work offline too.',\n })\n }\n return\n }\n markBuildStale()\n if (prefetch) return\n const outcome = requestReload()\n console.warn(`[chunk] A code chunk failed to load (stale build?): ${outcome}`, payload)\n}\n\n/**\n * The `vite:preloadError` handler. Decides once the failed import's own handlers have run, so a\n * `prefetchChunk` failure is known as one. Never cancels the event: the import rejects as usual\n * and, if a reload follows, the page is replaced anyway.\n */\nexport function handleChunkLoadError(event: Event): void {\n const payload = (event as Event & { payload?: unknown }).payload\n setTimeout(() => decide(payload), 0)\n}\n\nfunction onActivity(event: Event): void {\n lastActivity = deps.now()\n if (event.type === 'input' && event.target instanceof Element && isTextField(event.target)) {\n edited.add(event.target)\n }\n}\n\nconst ACTIVITY_EVENTS = ['input', 'keydown', 'pointerdown', 'wheel', 'touchstart'] as const\n\n/** Install the reload policy. Call once at startup; later calls are no-ops. */\nexport function installReloadPolicy(overrides: Partial<ReloadPolicyDeps> = {}): void {\n deps = { ...browserDeps, ...overrides }\n if (installed || typeof window === 'undefined') return\n installed = true\n lastActivity = deps.now()\n window.addEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) {\n document.addEventListener(type, onActivity, { capture: true, passive: true })\n }\n}\n\n/** Undo `installReloadPolicy` and forget all state (tests). */\nexport function resetReloadPolicy(): void {\n settle()\n edited.clear()\n if (installed) {\n window.removeEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) document.removeEventListener(type, onActivity, true)\n }\n installed = false\n deps = browserDeps\n}\n"]}
1
+ {"version":3,"sources":["../src/shell/Workspace.tsx","../src/shell/MobileBars.tsx","../src/shell/reload-policy.ts"],"names":["Globe","Users","Lock","jsxs","jsx","testIdOr","cn","Fragment","DropdownMenu","DropdownMenuTrigger","ChevronDown","DropdownMenuContent","DropdownMenuItem","LayoutGrid","Plus","DropdownMenuSeparator","DropdownMenuLabel","prefixedTestId","Menu","useRef","useShellBottomInset","ActionLink","notify"],"mappings":";;;;;;;;;;;AAqBO,IAAM,6BAAA,GAAqD;AAAA,EAChE,MAAA,EAAQ,QAAA;AAAA,EACR,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS;AACX;AAQO,SAAS,iBAAA,CACd,MACA,MAAA,EAKA;AACA,EAAA,MAAM,CAAA,GAAI,EAAE,GAAG,6BAAA,EAA+B,GAAG,MAAA,EAAO;AACxD,EAAA,IAAI,IAAA,KAAS,QAAA;AACX,IAAA,OAAO,EAAE,IAAA,EAAMA,iBAAA,EAAO,OAAO,CAAA,CAAE,MAAA,EAAQ,MAAM,gCAAA,EAAiC;AAChF,EAAA,IAAI,IAAA,KAAS,QAAA;AACX,IAAA,OAAO,EAA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AI,SAAA,IAAa,OAAO,MAAA,KAAW,WAAA,EAAa;AAChD,EAAA,SAAA,GAAY,IAAA;AACZ,EAAA,YAAA,GAAe,KAAK,GAAA,EAAI;AACxB,EAAA,MAAA,CAAO,gBAAA,CAAiB,qBAAqB,oBAAoB,CAAA;AACjE,EAAA,KAAA,MAAW,QAAQ,eAAA,EAAiB;AAClC,IAAA,QAAA,CAAS,gBAAA,CAAiB,MAAM,UAAA,EAAY,EAAE,SAAS,IAAA,EAAM,OAAA,EAAS,MAAM,CAAA;AAAA,EAC9E;AACF","file":"chunk-NY3YUCOW.cjs","sourcesContent":["import type { ComponentType } from 'react'\nimport { ChevronDown, Globe, LayoutGrid, Lock, Plus, Users } from 'lucide-react'\nimport {\n cn,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from '@arbidocs/react/ui'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport type { ShellRecentWorkspace, ShellWorkspace, ShellWorkspaceKind } from './types'\n\n/** The three workspace-kind names (badge title, type glyph name, subtitle). */\nexport interface WorkspaceKindLabels {\n common: string\n shared: string\n private: string\n}\n\nexport const DEFAULT_WORKSPACE_KIND_LABELS: WorkspaceKindLabels = {\n common: 'Common',\n shared: 'Shared',\n private: 'Private',\n}\n\n/**\n * Workspace type drives the initial-badge fill and a quiet secondary glyph:\n * private (just you) -> navy, lock shared (several) -> selection tint, people\n * common (public) -> neutral, globe\n * Navy is identity and cyan is reserved for ARBI/AI, so \"shared\" is the selection tint.\n */\nexport function workspaceKindMeta(\n kind: ShellWorkspaceKind,\n labels?: Partial<WorkspaceKindLabels>\n): {\n Icon: ComponentType<{ className?: string; 'aria-label'?: string; 'data-testid'?: string }>\n label: string\n fill: string\n} {\n const l = { ...DEFAULT_WORKSPACE_KIND_LABELS, ...labels }\n if (kind === 'common')\n return { Icon: Globe, label: l.common, fill: 'bg-muted text-muted-foreground' }\n if (kind === 'shared')\n return { Icon: Users, label: l.shared, fill: 'bg-secondary text-secondary-foreground' }\n return { Icon: Lock, label: l.private, fill: 'bg-primary text-primary-foreground' }\n}\n\n/** The kind's hue as a CSS colour, for glyphs painted by SVG fill (the workspace shield). */\nexport function workspaceKindColor(kind: ShellWorkspaceKind): string {\n if (kind === 'common') return 'var(--color-muted-foreground)'\n if (kind === 'shared') return 'var(--color-secondary)'\n return 'var(--color-primary)'\n}\n\n/** Overridable ids of the workspace identity; defaults are the current ids. */\ntype WorkspaceIdentityTestIds = Partial<Record<'initial' | 'type' | 'projectName', string>>\n\nexport interface WorkspaceIdentityProps {\n workspace: ShellWorkspace\n /** Show name + type/project line beside the badge; otherwise the badge alone. */\n expanded: boolean\n /** Selected (nav-row) styling of the name. */\n isActive?: boolean\n /** Reword the kind names. */\n labels?: Partial<WorkspaceKindLabels>\n /** Part ids; defaults are the current ids. */\n testIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * Non-interactive guts of the workspace head: the initial badge (with a tiny type glyph) and,\n * when expanded, the name and the project/type line. Hosted by the switcher trigger and by the\n * workspace settings header, so it never nests a button.\n */\nexport function WorkspaceIdentity({\n workspace,\n expanded,\n isActive = false,\n labels,\n testIds,\n}: WorkspaceIdentityProps) {\n const kind = workspaceKindMeta(workspace.kind, labels)\n const badge = (\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n data-testid={testIdOr(testIds?.initial, { testId: 'sidebar-workspace-card-initial' })}\n className={cn(\n 'flex size-7 flex-shrink-0 items-center justify-center rounded-md text-sm font-semibold leading-none',\n kind.fill\n )}\n >\n {workspace.name.charAt(0).toUpperCase()}\n </span>\n {/* Type as a tiny overlay on the badge: status reads at the icon, not after the name. */}\n <span className=\"absolute -bottom-1 -right-1 flex size-3.5 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={testIdOr(testIds?.type, { testId: 'sidebar-workspace-card-type' })}\n className=\"size-2.5 text-muted-foreground\"\n />\n </span>\n </span>\n )\n\n if (!expanded)\n return <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n\n return (\n <>\n <div className=\"flex flex-shrink-0 items-center justify-center\">{badge}</div>\n <div className=\"ml-2.5 flex min-w-0 flex-1 flex-col text-left\">\n <span\n // 600: the name of the thing you are inside, above a lighter project line.\n className={cn(\n 'min-w-0 truncate text-left text-sm font-semibold capitalize leading-tight transition-colors duration-100',\n isActive ? 'text-accent-foreground' : 'text-foreground'\n )}\n >\n {workspace.name}\n </span>\n {!workspace.projectName && (\n <span className=\"mt-0.5 truncate text-xs text-muted-foreground\">{kind.label}</span>\n )}\n {workspace.projectName && (\n <span\n className=\"mt-0.5 flex min-w-0\"\n data-testid={testIdOr(testIds?.projectName, {\n testId: 'sidebar-workspace-card-project-name',\n })}\n >\n {workspace.projectLine ?? (\n <span className=\"truncate text-xs text-muted-foreground\">\n {workspace.projectName}\n </span>\n )}\n </span>\n )}\n </div>\n </>\n )\n}\n\n/**\n * Entity nouns plus the switcher's strings. `plural` arrives lowercased and `singular`\n * capitalized in the functions below.\n */\nexport interface WorkspaceSwitcherLabels extends WorkspaceKindLabels {\n /** Entity nouns, e.g. { plural: 'workspaces', singular: 'workspace' }. */\n plural: string\n singular: string\n /** The trigger's accessible name. */\n switchWorkspace: (name: string, plural: string) => string\n allWorkspaces: (plural: string) => string\n newWorkspace: (singular: string) => string\n recentWorkspaces: (plural: string) => string\n}\n\nexport const DEFAULT_WORKSPACE_SWITCHER_LABELS: WorkspaceSwitcherLabels = {\n ...DEFAULT_WORKSPACE_KIND_LABELS,\n plural: 'workspaces',\n singular: 'workspace',\n switchWorkspace: (name, plural) => `${name} — switch ${plural}`,\n allWorkspaces: (plural) => `All ${plural}`,\n newWorkspace: (singular) => `New ${singular}`,\n recentWorkspaces: (plural) => `Recent ${plural}`,\n}\n\nexport interface WorkspaceSwitcherProps {\n workspace: ShellWorkspace\n /** Other workspaces to jump to (the app orders and caps them). */\n recent?: ShellRecentWorkspace[]\n /** Icon-only trigger (the sidebar rail). */\n compact?: boolean\n /** `appbar`: the phone app bar's title, name + chevron on one line. */\n variant?: 'sidebar' | 'appbar'\n onSwitch: (workspace: ShellWorkspace) => void\n /** Return to the workspaces list; leaves the workspace open. */\n onGoToList: () => void\n onNewWorkspace: () => void\n /**\n * When set, \"New workspace\" is shown disabled with this explanation under it (e.g. the user may\n * not create workspaces on this deployment).\n */\n newWorkspaceDisabledReason?: string\n /** Entity nouns and menu strings; any subset (the nouns default to workspace(s)). */\n labels?: Partial<WorkspaceSwitcherLabels>\n className?: string\n /** Trigger id (default `workspace-switcher-trigger`). */\n testId?: string\n /**\n * Part ids; defaults are the current ids. `switchItem`, `type` and `lastSeen` are prefixes\n * (`<prefix>-<workspace id>`).\n */\n testIds?: Partial<Record<'menu' | 'all' | 'new' | 'switchItem' | 'type' | 'lastSeen', string>>\n /** Ids forwarded to the trigger's workspace identity. */\n identityTestIds?: WorkspaceIdentityTestIds\n}\n\n/**\n * The current-workspace control as a dropdown: \"All workspaces\", \"New workspace\", then the\n * recent workspaces to jump straight into.\n */\nexport function WorkspaceSwitcher({\n workspace,\n recent = [],\n compact = false,\n variant = 'sidebar',\n onSwitch,\n onGoToList,\n onNewWorkspace,\n newWorkspaceDisabledReason,\n labels,\n className,\n testId,\n testIds,\n identityTestIds,\n}: WorkspaceSwitcherProps) {\n const l = { ...DEFAULT_WORKSPACE_SWITCHER_LABELS, ...labels }\n const plural = l.plural.toLowerCase()\n const singular = l.singular.charAt(0).toUpperCase() + l.singular.slice(1)\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n data-slot=\"workspace-switcher\"\n data-testid={testIdOr(testId, { testId: 'workspace-switcher-trigger' })}\n aria-label={l.switchWorkspace(workspace.name, plural)}\n className={cn(\n 'group flex min-w-0 items-center rounded-md transition-colors duration-100 hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',\n variant === 'appbar'\n ? 'h-11 max-w-full gap-1 px-2'\n : compact\n ? 'h-12 w-12 justify-center'\n : 'h-12 w-full px-2',\n className\n )}\n >\n {variant === 'appbar' ? (\n <span className=\"min-w-0 truncate text-base font-semibold text-foreground\">\n {workspace.name}\n </span>\n ) : (\n <WorkspaceIdentity\n workspace={workspace}\n expanded={!compact}\n labels={l}\n testIds={identityTestIds}\n />\n )}\n {!(compact && variant === 'sidebar') && (\n <ChevronDown\n aria-hidden=\"true\"\n className=\"ml-auto size-4 flex-shrink-0 text-muted-foreground transition-transform duration-150 group-data-[state=open]:rotate-180\"\n />\n )}\n </button>\n </DropdownMenuTrigger>\n {/* Expanded menus follow the trigger width so they stay inside the sidebar. */}\n <DropdownMenuContent\n align=\"start\"\n className={cn(\n 'border-0 max-w-[calc(100vw-1.5rem)]',\n variant === 'sidebar' && !compact\n ? 'w-[var(--radix-dropdown-menu-trigger-width)]'\n : 'w-60'\n )}\n data-testid={testIdOr(testIds?.menu, { testId: 'workspace-switcher-menu' })}\n >\n <DropdownMenuItem\n onClick={onGoToList}\n data-testid={testIdOr(testIds?.all, { testId: 'workspace-switcher-all' })}\n className=\"gap-2\"\n >\n <LayoutGrid className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n {l.allWorkspaces(plural)}\n </DropdownMenuItem>\n <DropdownMenuItem\n onClick={newWorkspaceDisabledReason ? undefined : onNewWorkspace}\n disabled={!!newWorkspaceDisabledReason}\n title={newWorkspaceDisabledReason}\n data-testid={testIdOr(testIds?.new, { testId: 'workspace-switcher-new' })}\n className=\"gap-2\"\n >\n <Plus className=\"size-4 flex-shrink-0 text-muted-foreground\" />\n <span className=\"flex min-w-0 flex-col\">\n {l.newWorkspace(singular)}\n {newWorkspaceDisabledReason && (\n <span className=\"text-xs text-muted-foreground\">{newWorkspaceDisabledReason}</span>\n )}\n </span>\n </DropdownMenuItem>\n {recent.length > 0 && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuLabel className=\"text-xs font-normal text-muted-foreground\">\n {l.recentWorkspaces(plural)}\n </DropdownMenuLabel>\n {recent.map((w) => {\n const kind = workspaceKindMeta(w.kind, l)\n return (\n <DropdownMenuItem\n key={w.id}\n onClick={() => onSwitch(w)}\n data-testid={prefixedTestId(testIds?.switchItem, w.id, {\n testId: `workspace-switch-${w.id}`,\n })}\n className=\"gap-2\"\n >\n <span className=\"relative flex flex-shrink-0\" title={kind.label}>\n <span\n aria-hidden=\"true\"\n className={cn(\n 'flex size-6 flex-shrink-0 items-center justify-center rounded text-xs font-semibold leading-none',\n kind.fill\n )}\n >\n {w.name.charAt(0).toUpperCase()}\n </span>\n <span className=\"absolute -bottom-1 -right-1 flex size-3 items-center justify-center rounded-full bg-background ring-1 ring-border\">\n <kind.Icon\n aria-label={kind.label}\n data-testid={prefixedTestId(testIds?.type, w.id, {\n testId: `workspace-type-${w.id}`,\n })}\n className=\"size-2 text-muted-foreground\"\n />\n </span>\n </span>\n <span className=\"min-w-0 flex-1 truncate capitalize\">{w.name}</span>\n {w.lastSeen && (\n <span\n className=\"ml-2 flex-shrink-0 text-xs tabular-nums text-muted-foreground\"\n data-testid={prefixedTestId(testIds?.lastSeen, w.id, {\n testId: `workspace-last-seen-${w.id}`,\n })}\n >\n {w.lastSeen}\n </span>\n )}\n </DropdownMenuItem>\n )\n })}\n </>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n","import { useRef, type ReactNode } from 'react'\nimport { Menu } from 'lucide-react'\nimport { cn } from '@arbidocs/react/ui'\nimport { ActionLink } from '../components/ActionLink'\nimport { prefixedTestId, testIdOr } from '../chat/test-id'\nimport { useShellBottomInset } from '../lib/bottom-inset'\nimport type { NavItem } from './types'\n\n/** Fixed strings of the phone bars. */\nexport interface MobileBarsLabels {\n /** The menu button (the `menuLabel` prop wins). */\n openNavigationMenu: string\n /** The tab bar's accessible name (the `label` prop wins). */\n workspaceSections: string\n}\n\nexport const DEFAULT_MOBILE_BARS_LABELS: MobileBarsLabels = {\n openNavigationMenu: 'Open navigation menu',\n workspaceSections: 'Workspace sections',\n}\n\nexport interface MobileAppBarProps {\n /** Show the menu button that opens the drawer (nothing to open on a list page with no sidebar). */\n showMenu?: boolean\n onMenu?: () => void\n /** Replaces the brand mark (e.g. the workspace switcher). */\n title?: ReactNode\n /** Brand mark shown when there is no `title`. */\n logo?: ReactNode\n /** Right-aligned controls that fit (ask, offline pill, bell, account). */\n actions?: ReactNode\n menuLabel?: string\n labels?: Partial<Pick<MobileBarsLabels, 'openNavigationMenu'>>\n className?: string\n 'data-testid'?: string\n /** Menu button id (default `mobile-nav-toggle`). */\n menuTestId?: string\n}\n\n/**\n * The slim phone app bar (56px): menu button, a title slot and an actions slot. The app mounts\n * it only on small screens; the controls that do not fit live in the drawer.\n */\nexport function MobileAppBar({\n showMenu = true,\n onMenu,\n title,\n logo,\n actions,\n menuLabel,\n labels,\n className,\n 'data-testid': testId,\n menuTestId,\n}: MobileAppBarProps) {\n return (\n <div\n data-slot=\"mobile-app-bar\"\n data-testid={testId}\n className={cn(\n 'sm:hidden flex h-14 flex-shrink-0 items-center gap-1 bg-background pl-1 pr-2 pt-safe',\n className\n )}\n >\n {showMenu && (\n <button\n type=\"button\"\n onClick={onMenu}\n className=\"flex size-11 shrink-0 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted\"\n aria-label={\n menuLabel ?? labels?.openNavigationMenu ?? DEFAULT_MOBILE_BARS_LABELS.openNavigationMenu\n }\n data-testid={testIdOr(menuTestId, { testId: 'mobile-nav-toggle' })}\n >\n <Menu className=\"size-5\" />\n </button>\n )}\n <div className={cn('flex min-w-0 flex-1 items-center', !showMenu && 'pl-3')}>\n {title ?? logo}\n </div>\n {actions && <div className=\"flex shrink-0 items-center gap-0.5\">{actions}</div>}\n </div>\n )\n}\n\n/**\n * A tab's label. It wraps at word boundaries and is never clipped or cut with an ellipsis; a tab\n * narrower than 4.5rem sets it one size smaller so a long single word still fits, and an item with\n * a `shortLabel` shows that one while its tab is narrower than 5.5rem.\n */\nfunction TabLabel({ item }: { item: NavItem }) {\n const wrap =\n 'max-w-full text-balance px-0.5 text-center [overflow-wrap:normal] @max-[4.5rem]:text-[10px]'\n if (!item.shortLabel) return <span className={wrap}>{item.label}</span>\n return (\n <>\n <span data-slot=\"tab-short-label\" aria-hidden=\"true\" className={cn(wrap, '@[5.5rem]:hidden')}>\n {item.shortLabel}\n </span>\n <span className={cn(wrap, 'hidden @[5.5rem]:block')}>{item.label}</span>\n <span className=\"sr-only @[5.5rem]:hidden\">{item.label}</span>\n </>\n )\n}\n\nexport interface MobileTabBarProps {\n /** The workspace's main areas; test ids are `{testIdPrefix}-{id}` (prefix default `mobile-tab`). */\n items: NavItem[]\n label?: string\n labels?: Partial<Pick<MobileBarsLabels, 'workspaceSections'>>\n testIdPrefix?: string\n className?: string\n 'data-testid'?: string\n}\n\n/**\n * Phone bottom navigation: a 64px tinted bar of the main areas. The drawer carries the same\n * destinations with counts, so nothing is reachable only here. The app mounts it on small\n * screens only.\n */\nexport function MobileTabBar({\n items,\n label,\n labels,\n testIdPrefix,\n className,\n 'data-testid': testId,\n}: MobileTabBarProps) {\n const navRef = useRef<HTMLElement>(null)\n // Floating elements (install prompt, toasts) read the bar's height from `--shell-bottom-inset`.\n useShellBottomInset(navRef)\n return (\n <nav\n ref={navRef}\n aria-label={\n label ?? labels?.workspaceSections ?? DEFAULT_MOBILE_BARS_LABELS.workspaceSections\n }\n data-slot=\"mobile-tab-bar\"\n data-testid={testIdOr(testId, { testId: 'mobile-tab-bar' })}\n className={cn(\n 'flex min-h-16 flex-shrink-0 items-stretch bg-sidebar px-2 pb-safe sm:hidden',\n className\n )}\n >\n {items.map((item) => (\n <ActionLink\n key={item.id}\n href={item.href}\n external={item.external}\n onSelect={item.onSelect}\n disabled={item.disabled}\n aria-current={item.active ? 'page' : undefined}\n className={cn(\n // Each tab is a size container: a `shortLabel` replaces the label when it is narrow.\n '@container flex min-h-12 min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-md text-[11px] leading-tight transition-colors',\n item.active\n ? 'font-semibold text-primary'\n : 'font-medium text-muted-foreground hover:text-foreground'\n )}\n data-testid={prefixedTestId(testIdPrefix, item.id, { testId: `mobile-tab-${item.id}` })}\n >\n {item.icon}\n <TabLabel item={item} />\n </ActionLink>\n ))}\n </nav>\n )\n}\n","/**\n * One policy for every automatic reload: when the running build is out of date, pick a moment\n * that costs the user nothing.\n *\n * After a deploy (or mid-rollout, while old and new pods both serve) the previous build's hashed\n * chunks can 404. Vite reports that as `vite:preloadError`. Reloading fetches the current\n * index.html (served no-cache) and its chunks, but reloading at once throws away whatever the\n * user is typing, so:\n *\n * - A failed prefetch (`prefetchChunk`) never reloads. Nothing on screen depends on it.\n * - A failed chunk the user is waiting for reloads at once, unless the user is on a sign-in form\n * or has unsaved input (a focused or edited field, or a `[data-reload-guard]` region).\n * - Otherwise the reload waits: the next route navigation becomes a full page load of its target,\n * or the page reloads once the user is idle with nothing unsaved.\n * - Per tab, at most one policy reload a minute. A second failure right after one is not a stale\n * build (a genuinely missing chunk, say), so it surfaces to the error boundary instead of looping.\n */\n\nimport { notify } from '@arbidocs/react/shell'\n\nexport const CHUNK_RELOAD_KEY = 'arbi_chunk_reload_at'\n\n/** A second failure within this window after a reload is not a stale build: let it surface. */\nconst RELOAD_GUARD_MS = 60_000\n/** A deferred reload waits until the user has done nothing for this long. */\nconst IDLE_MS = 10_000\nconst IDLE_CHECK_MS = 2_000\n\n/** Sign-in pages, and regions a host marks as holding unsaved work. */\nconst GUARD_SELECTOR =\n '[data-slot=\"auth-layout\"], input[type=\"password\"], input[autocomplete=\"one-time-code\"], [data-reload-guard]'\nconst NON_TEXT_INPUTS = new Set([\n 'button',\n 'submit',\n 'reset',\n 'checkbox',\n 'radio',\n 'hidden',\n 'range',\n 'color',\n 'file',\n 'image',\n])\n\nexport interface ReloadPolicyDeps {\n /** Reload the current page. */\n reload: () => void\n /** Full page load of `url` (instead of a client-side navigation). */\n load: (url: string, replace: boolean) => void\n now: () => number\n}\n\nconst browserDeps: ReloadPolicyDeps = {\n reload: () => window.location.reload(),\n load: (url, replace) => (replace ? window.location.replace(url) : window.location.assign(url)),\n now: () => Date.now(),\n}\n\nlet deps = browserDeps\nlet installed = false\n/** The build is out of date: the next route navigation loads the page fresh. */\nlet stale = false\n/** A chunk the user needed failed: reload as soon as nothing would be lost. */\nlet reloadWanted = false\nlet lastActivity = 0\nlet idleTimer: ReturnType<typeof setInterval> | undefined\nlet restoreNavigation: (() => void) | null = null\n/** Fields the user typed into. */\nconst edited = new Set<Element>()\n/** Errors from `prefetchChunk` loads, so the preload-error handler can tell them apart. */\nconst prefetchFailures = new WeakSet<object>()\n\nfunction isTextField(el: Element): boolean {\n if (el instanceof HTMLInputElement) return !NON_TEXT_INPUTS.has(el.type)\n return el instanceof HTMLTextAreaElement || (el as HTMLElement).isContentEditable === true\n}\n\nfunction hasText(el: Element): boolean {\n if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {\n return el.value.trim() !== ''\n }\n return (el.textContent ?? '').trim() !== ''\n}\n\n/**\n * Whether reloading now could cost the user something: a sign-in form, a `[data-reload-guard]`\n * region, a focused text field, or a field they typed into that still holds text.\n */\nexport function hasUnsavedInput(doc: Document = document): boolean {\n if (doc.querySelector(GUARD_SELECTOR)) return true\n const active = doc.activeElement\n if (active && active !== doc.body && isTextField(active)) return true\n for (const el of edited) {\n if (!el.isConnected) edited.delete(el)\n else if (hasText(el)) return true\n }\n return false\n}\n\n/** Take this tab's reload slot. False within the guard window, or when storage can't record it. */\nfunction claimReload(): boolean {\n const now = deps.now()\n let last = 0\n try {\n last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n } catch {\n // Unreadable: treat as never reloaded. Writing below decides.\n }\n if (last && now - last < RELOAD_GUARD_MS) return false\n try {\n sessionStorage.setItem(CHUNK_RELOAD_KEY, String(now))\n } catch {\n // Without the guard we can't tell a loop from a stale build: don't risk one.\n return false\n }\n return true\n}\n\nfunction guardHot(): boolean {\n try {\n const last = Number(sessionStorage.getItem(CHUNK_RELOAD_KEY)) || 0\n return !!last && deps.now() - last < RELOAD_GUARD_MS\n } catch {\n return false\n }\n}\n\nfunction settle(): void {\n stale = false\n reloadWanted = false\n if (idleTimer !== undefined) clearInterval(idleTimer)\n idleTimer = undefined\n restoreNavigation?.()\n restoreNavigation = null\n}\n\nfunction reloadNow(): boolean {\n if (!claimReload()) {\n settle()\n return false\n }\n settle()\n deps.reload()\n return true\n}\n\n/** A client-side navigation to `url` becomes a full page load of it while the build is stale. */\nfunction loadsFresh(url: string | URL | null | undefined): string | null {\n if (!stale || url == null) return null\n const target = new URL(String(url), window.location.href)\n if (target.pathname === window.location.pathname) return null\n // Leaving a sign-in page establishes the session: a full load there races its persistence.\n if (document.querySelector(GUARD_SELECTOR)) return null\n return target.href\n}\n\nfunction interceptNavigation(): void {\n if (restoreNavigation) return\n const history = window.history\n const push = history.pushState\n const replace = history.replaceState\n let shownPath = window.location.pathname\n const wrap = (original: History['pushState'], replaceEntry: boolean): History['pushState'] =>\n function (this: History, data, unused, url) {\n const target = loadsFresh(url)\n if (target && claimReload()) {\n settle()\n deps.load(target, replaceEntry)\n return\n }\n original.call(this, data, unused, url)\n shownPath = window.location.pathname\n }\n history.pushState = wrap(push, false)\n history.replaceState = wrap(replace, true)\n // Back/forward already changed the address: reloading loads that target.\n const onPopState = () => {\n if (window.location.pathname === shownPath) return\n shownPath = window.location.pathname\n if (!document.querySelector(GUARD_SELECTOR)) reloadNow()\n }\n window.addEventListener('popstate', onPopState)\n restoreNavigation = () => {\n history.pushState = push\n history.replaceState = replace\n window.removeEventListener('popstate', onPopState)\n }\n}\n\nfunction watchForIdle(): void {\n if (idleTimer !== undefined) return\n idleTimer = setInterval(() => {\n if (!reloadWanted) return\n const idle = document.visibilityState === 'hidden' || deps.now() - lastActivity >= IDLE_MS\n if (idle && !hasUnsavedInput()) reloadNow()\n }, IDLE_CHECK_MS)\n}\n\n/**\n * The running build is out of date (a chunk 404'd, or a new service worker took over): the next\n * route navigation loads its target fresh instead of rendering it client-side.\n */\nexport function markBuildStale(): void {\n stale = true\n interceptNavigation()\n}\n\nexport type ReloadOutcome = 'reloaded' | 'deferred' | 'guarded'\n\n/**\n * Reload onto the current build when nothing would be lost; otherwise defer to the next route\n * navigation or to the moment the user is idle with nothing unsaved. `guarded` means a policy\n * reload just happened in this tab, so the failure should surface instead.\n */\nexport function requestReload(): ReloadOutcome {\n if (guardHot()) return 'guarded'\n if (!hasUnsavedInput()) return reloadNow() ? 'reloaded' : 'guarded'\n reloadWanted = true\n markBuildStale()\n watchForIdle()\n return 'deferred'\n}\n\n/**\n * Load a chunk ahead of need (warming a route the user may open next). Never rejects, and a\n * failure never reloads the page: it only marks the build stale so the next navigation loads\n * fresh.\n */\nexport function prefetchChunk(load: () => Promise<unknown>): Promise<void> {\n let loading: Promise<unknown>\n try {\n loading = load()\n } catch (error) {\n loading = Promise.reject(error)\n }\n return loading.then(\n () => undefined,\n (error: unknown) => {\n if (typeof error === 'object' && error !== null) prefetchFailures.add(error)\n }\n )\n}\n\nfunction decide(payload: unknown): void {\n const prefetch = typeof payload === 'object' && payload !== null && prefetchFailures.has(payload)\n // Offline the chunk simply couldn't be downloaded (it isn't cached yet). Reloading can't fix\n // that and would throw away what's on screen; say what happened instead, and let the failed\n // import reach the nearest error boundary as usual.\n if (typeof navigator !== 'undefined' && navigator.onLine === false) {\n if (!prefetch) {\n notify.warning(\"This part of ARBI isn't available offline yet\", {\n description: 'Reconnect to open it. Once you have, it will work offline too.',\n })\n }\n return\n }\n markBuildStale()\n if (prefetch) return\n const outcome = requestReload()\n console.warn(`[chunk] A code chunk failed to load (stale build?): ${outcome}`, payload)\n}\n\n/**\n * The `vite:preloadError` handler. Decides once the failed import's own handlers have run, so a\n * `prefetchChunk` failure is known as one. Never cancels the event: the import rejects as usual\n * and, if a reload follows, the page is replaced anyway.\n */\nexport function handleChunkLoadError(event: Event): void {\n const payload = (event as Event & { payload?: unknown }).payload\n setTimeout(() => decide(payload), 0)\n}\n\nfunction onActivity(event: Event): void {\n lastActivity = deps.now()\n if (event.type === 'input' && event.target instanceof Element && isTextField(event.target)) {\n edited.add(event.target)\n }\n}\n\nconst ACTIVITY_EVENTS = ['input', 'keydown', 'pointerdown', 'wheel', 'touchstart'] as const\n\n/** Install the reload policy. Call once at startup; later calls are no-ops. */\nexport function installReloadPolicy(overrides: Partial<ReloadPolicyDeps> = {}): void {\n deps = { ...browserDeps, ...overrides }\n if (installed || typeof window === 'undefined') return\n installed = true\n lastActivity = deps.now()\n window.addEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) {\n document.addEventListener(type, onActivity, { capture: true, passive: true })\n }\n}\n\n/** Undo `installReloadPolicy` and forget all state (tests). */\nexport function resetReloadPolicy(): void {\n settle()\n edited.clear()\n if (installed) {\n window.removeEventListener('vite:preloadError', handleChunkLoadError)\n for (const type of ACTIVITY_EVENTS) document.removeEventListener(type, onActivity, true)\n }\n installed = false\n deps = browserDeps\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var chunkE5TPRRAW_cjs = require('./chunk-E5TPRRAW.cjs');
5
- var chunkXKDUPU7B_cjs = require('./chunk-XKDUPU7B.cjs');
5
+ var chunkL6APDO3Y_cjs = require('./chunk-L6APDO3Y.cjs');
6
6
  var chunkORELHENJ_cjs = require('./chunk-ORELHENJ.cjs');
7
7
  var chunk3YZKDCWY_cjs = require('./chunk-3YZKDCWY.cjs');
8
8
  var react = require('@arbidocs/react');
@@ -350,7 +350,7 @@ function planBadgeView(project) {
350
350
  }
351
351
  function projectGroupBilling(project, { isOwned, stripeEnabled }) {
352
352
  if (!project) return {};
353
- const planBadge = isOwned && stripeEnabled ? /* @__PURE__ */ jsxRuntime.jsx(chunkXKDUPU7B_cjs.PlanBadge, { ...planBadgeView(project) }) : void 0;
353
+ const planBadge = isOwned && stripeEnabled ? /* @__PURE__ */ jsxRuntime.jsx(chunkL6APDO3Y_cjs.PlanBadge, { ...planBadgeView(project) }) : void 0;
354
354
  const quotaItems = project.quotas ? getQuotaItems(project.quotas) : [];
355
355
  const readout = project.quotas ? /* @__PURE__ */ jsxRuntime.jsx(
356
356
  chunkE5TPRRAW_cjs.ProjectReadout,
@@ -360,7 +360,7 @@ function projectGroupBilling(project, { isOwned, stripeEnabled }) {
360
360
  testId: `project-usage-${project.external_id}`,
361
361
  // Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.
362
362
  node: /* @__PURE__ */ jsxRuntime.jsx(
363
- chunkXKDUPU7B_cjs.QuotaMeter,
363
+ chunkL6APDO3Y_cjs.QuotaMeter,
364
364
  {
365
365
  items: quotaItems,
366
366
  size: "sm",
@@ -451,5 +451,5 @@ exports.totalWithTaxWord = totalWithTaxWord;
451
451
  exports.useBillingSupport = useBillingSupport;
452
452
  exports.useRewardBalance = useRewardBalance;
453
453
  exports.useSelfExtId = useSelfExtId;
454
- //# sourceMappingURL=chunk-E4BLRF2L.cjs.map
455
- //# sourceMappingURL=chunk-E4BLRF2L.cjs.map
454
+ //# sourceMappingURL=chunk-O4F77VSO.cjs.map
455
+ //# sourceMappingURL=chunk-O4F77VSO.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/connection/billing/reward-balance.ts","../src/connection/billing/support.ts","../src/connection/billing/addon-pricing.ts","../src/connection/billing/plan-constants.ts","../src/connection/billing/quota-items.ts","../src/connection/billing/api-error.ts","../src/connection/billing/tax-quote.ts","../src/connection/billing/plan-pricing.ts","../src/connection/billing/plan-badge.ts","../src/connection/workspace-list/projectBilling.tsx"],"names":["useUserSettings","useHost","useArbi","formatGbp","PoundSterling","HardDrive","Users","gbp","jsx","PlanBadge","ProjectReadout","QuotaMeter","ProjectBreakdown","UsageMeter"],"mappings":";;;;;;;;;;AAoBO,SAAS,gBAAA,GAAyC;AACvD,EAAA,MAAM,EAAE,IAAA,EAAK,GAAIA,sBAAgB,EAAE,cAAA,EAAgB,UAAU,CAAA;AAE7D,EAAA,MAA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,GAAA,EAAI,qBACnDJ,cAAA;AAAA,QAACK,4BAAA;AAAA,QAAA;AAAA,UAEC,IAAA;AAAA,UACA,KAAA;AAAA,UACA,KAAA,EAAO,WAAA;AAAA,UACP;AAAA,SAAA;AAAA,QAJK;AAAA,OAMR,CAAA,GACD,MAAA;AAAA,MAEN,QAAA,EAAU;AAAA,QACR,KAAA,EAAO,WAAA;AAAA,QACP,KAAA,EACE,QAAQ,kBAAA,IAAsB,IAAA,GAC1B,aACA,OAAA,CAAQ,kBAAA,CAAmB,eAAe,OAAO;AAAA;AACzD;AAAA,GACF;AAEF,EAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,SAAA,EAAU;AACzC","file":"chunk-E4BLRF2L.cjs","sourcesContent":["/**\n * Reward-balance logic (hook + money formatter).\n *\n * A user's reward balance is their available account balance — a single GLOBAL per-user\n * number, the Stripe customer account balance mirrored read-only into\n * `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n *\n * \"Rewards\" is the broad concept: the balance can be fed by several sources (referral\n * reward is just one). The referral pricing surfaces of the billing kit\n * speak to the referral source specifically; this module owns the balance itself.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\n\nexport interface RewardBalance {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The user's available reward balance (all sources), or null if none. */\nexport function useRewardBalance(): RewardBalance | null {\n const { data } = useUserSettings({ refetchOnMount: 'always' })\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/** Format minor units as a localized money string, e.g. `£20` (whole) or `£29.99`. */\nexport function formatMoney(cents: number, currency = 'gbp'): string {\n const value = cents / 100\n const isWhole = Number.isInteger(value)\n const c = currency.toLowerCase()\n const symbol =\n c === 'usd' ? '$' : c === 'gbp' ? '£' : c === 'eur' ? '€' : currency.toUpperCase() + ' '\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: isWhole ? 0 : 2,\n maximumFractionDigits: isWhole ? 0 : 2,\n })}`\n}\n","/**\n * What a host adds to the billing kit. Selling plans needs Stripe, which stays the host's: whether\n * this deployment sells plans (a publishable key is configured), and its embedded checkout. It is the\n * host configuration's `billing`; without it nothing is for sale: projects show their limits and\n * usage only.\n */\nimport type { ReactNode } from 'react'\nimport { useArbi } from '@arbidocs/react'\nimport { useHost } from '../../provider/host'\n\nexport interface BillingCheckoutSupport {\n /** Load the host's Stripe (lazily, when a checkout opens); `null` when it cannot. */\n load(): Promise<unknown> | null\n /** Stripe's embedded checkout for a session, on the loaded Stripe. */\n render(stripe: unknown, session: { clientSecret: string; onComplete: () => void }): ReactNode\n}\n\nexport interface BillingSupport {\n /** This deployment sells plans (Stripe is configured). */\n stripeEnabled: boolean\n checkout?: BillingCheckoutSupport\n}\n\nconst NOT_FOR_SALE: BillingSupport = { stripeEnabled: false }\n\nexport function useBillingSupport(): BillingSupport {\n return useHost().billing ?? NOT_FOR_SALE\n}\n\n/** The signed-in user's id (`usr-…`), to tell the projects they own from the others. */\nexport function useSelfExtId(): string | undefined {\n const arbi = useArbi()\n return arbi.isLoggedIn ? (arbi.user.identity()?.externalId ?? undefined) : undefined\n}\n","/** Add-on block price helpers (VAT-inclusive pence from `project.addons`). */\n\nimport { formatGbp } from '@arbidocs/react'\nimport type { components } from '@arbidocs/client'\nimport type { AddonKind } from './useAddonPurchase'\nimport { formatMoney } from './reward-balance'\n\ntype ProjectAddons = components['schemas']['ProjectAddons']\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** \"3 Nov 2026\". */\nexport function formatPeriodEnd(unix: number | null | undefined): string | null {\n if (!unix) return null\n return new Date(unix * 1000).toLocaleDateString('en-GB', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n}\n\n/** What one more block of this kind costs right now, incl. UK VAT. */\nexport function addonPricePence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage' ? addons.ai_block_price_pence : addons.storage_block_price_pence\n}\n\n/** The same price ex VAT. */\nfunction addonPriceExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_price_ex_vat_pence\n : addons.storage_block_price_ex_vat_pence\n}\n\n/**\n * The PUT /addons/settings body (the monthly usage cap and the automatic add-on trigger) from the current add-on\n * state with the given changes applied.\n */\nexport function addonSettingsBody(\n addons: ProjectAddons,\n change: Partial<{\n spend_cap_pence: number | null\n auto_topup_threshold_gbp: number\n }> = {}\n) {\n return {\n spend_cap_pence: addons.spend_cap_pence ?? null,\n auto_topup_threshold_gbp: addons.auto_topup_threshold_gbp,\n ...change,\n }\n}\n\n/**\n * Of `count` blocks of a kind, how many are on an earlier catalogue's price (legacy, at their old size: £10 of AI\n * usage or 10 GB) and how many on today's. A reduction removes today's blocks first, so the legacy ones are the\n * last kept.\n */\nexport function splitBlocks(\n kind: AddonKind,\n count: number,\n addons: ProjectAddons\n): { legacy: number; current: number } {\n const granted =\n (kind === 'ai_usage' ? addons.legacy_ai_blocks : addons.legacy_storage_blocks) ?? 0\n const legacy = Math.max(0, Math.min(granted, count))\n return { legacy, current: count - legacy }\n}\n\n/** One block's size: \"£25 of AI credits\" / \"25 GB\" (legacy: \"£10\" / \"10 GB\"). */\nfunction blockSize(kind: AddonKind, addons: ProjectAddons, legacy: boolean): string {\n if (kind === 'ai_usage') {\n return formatGbp(legacy ? (addons.legacy_block_ai_gbp ?? 10) : addons.block_ai_gbp)\n }\n return `${legacy ? (addons.legacy_block_storage_gb ?? 10) : addons.block_storage_gb} GB`\n}\n\n/**\n * \"2 × £25 of AI credits\", \"1 × £10 + 1 × £25 of AI credits\", \"1 × 10 GB + 2 × 25 GB\": `count` blocks of a kind, the\n * legacy ones (kept last on a reduction) at their old size.\n */\nexport function blocksLabel(kind: AddonKind, count: number, addons: ProjectAddons): string {\n const { legacy, current } = splitBlocks(kind, count, addons)\n const parts = [\n ...(legacy > 0 ? [`${legacy} × ${blockSize(kind, addons, true)}`] : []),\n ...(current > 0 || legacy === 0 ? [`${current} × ${blockSize(kind, addons, false)}`] : []),\n ]\n return `${parts.join(' + ')}${kind === 'ai_usage' ? ' of AI credits' : ''}`\n}\n\n/**\n * Bounds for \"Reduce from next period\": keep `min`..`current` blocks. `next` is what renews\n * now (a pending reduction, or the current count). Storage can't go below what usage needs.\n */\nexport function reduceBounds(\n kind: AddonKind,\n addons: ProjectAddons\n): { min: number; current: number; next: number } {\n const current = kind === 'ai_usage' ? addons.ai_blocks : addons.storage_blocks\n const pending = kind === 'ai_usage' ? addons.ai_blocks_next : addons.storage_blocks_next\n const min = 0\n return { min, current, next: pending ?? current }\n}\n\n/** One block's monthly-equivalent price ex VAT: AI credits and storage are priced separately. */\nfunction blockMonthlyExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_monthly_ex_vat_pence\n : addons.storage_block_monthly_ex_vat_pence\n}\n\n/** What one block renews at per billing period, ex VAT (annual: 12 × the monthly price). */\nfunction blockPeriodExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_period_ex_vat_pence\n : addons.storage_block_period_ex_vat_pence\n}\n\n/** What one add-on renews at: \"£25/month ex VAT\" or \"£225/year ex VAT\". */\nfunction blockRenewalShort(kind: AddonKind, addons: ProjectAddons, isAnnual: boolean): string {\n return `${gbp(blockPeriodExVatPence(kind, addons))}/${isAnnual ? 'year' : 'month'} ex VAT`\n}\n\n/** The extra line annual plans show beside an AI credits add-on or upgrade price. */\nexport const ANNUAL_PREMIUM_AI_NOTE = 'No markup on Premium AI on annual plans'\n\n/** The confirm dialog's figures: charged now (incl. / ex VAT), what it covers until, then what renews. */\nexport function addonCharge(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean,\n periodEnd: number | null | undefined\n): { now: string; nowExVat: string; nowVat: string; until: string | null; then: string } {\n return {\n now: gbp(addonPricePence(kind, addons)),\n nowExVat: gbp(addonPriceExVatPence(kind, addons)),\n nowVat: gbp(addonPricePence(kind, addons) - addonPriceExVatPence(kind, addons)),\n until: isAnnual ? formatPeriodEnd(periodEnd) : null,\n then: blockRenewalShort(kind, addons, isAnnual),\n }\n}\n\n/** Why automatic top-ups stopped (one line; the price of a step is on the Add button). */\nexport const CAP_REACHED_MESSAGE = 'Usage cap reached: no more automatic top-ups this month.'\n\n/** The £0 usage cap: no automatic top-ups (adding by hand still works). */\nexport const ZERO_BUDGET_MESSAGE = 'Automatic top-ups are off (£0 usage cap).'\n\n/** The usage cap's heading wherever it is edited or shown. */\nexport const USAGE_CAP_LABEL = 'Auto-upgrade limit'\n\n/** Automatic-upgrade spending is separate from explicitly selected allowances. */\nexport const USAGE_CAP_HELP =\n 'Your auto-upgrade limit covers extra monthly spend beyond your selected plan and add-ons. ' +\n '£0 turns automatic upgrades off. You can adjust usage add-ons with + and −. ' +\n 'Additions show the charge before you confirm; reductions apply next billing period, ' +\n 'provided your storage and collaborators fit. Prices are ex VAT.'\n\n/** A £0 cap turns automatic top-ups off (manual adds still work). */\nexport function isAddonBudgetZero(addons: Pick<ProjectAddons, 'spend_cap_pence'>): boolean {\n return addons.spend_cap_pence === 0\n}\n\n/**\n * How much more of a resource automatic top-ups may add this month before the usage cap stops them, in the\n * resource's unit (£ of AI credits / GB): the whole blocks the cap left pays for at today's ex-VAT price. `null` =\n * no limit; 0 with a £0 cap or when not even one block fits.\n */\nexport function autoRoom(kind: AddonKind, addons: ProjectAddons): number | null {\n const left = addons.cap_left_pence\n if (left == null) return addons.spend_cap_pence === 0 ? 0 : null\n const price = blockMonthlyExVatPence(kind, addons)\n if (price <= 0) return 0\n const blocks = Math.floor(left / price)\n return blocks * (kind === 'ai_usage' ? addons.block_ai_gbp : addons.block_storage_gb)\n}\n\n/** The size of the block a one-step reduction removes from what renews (today's blocks go first). */\nexport function nextRemovedBlockSize(kind: AddonKind, addons: ProjectAddons): number {\n const { next } = reduceBounds(kind, addons)\n const { current } = splitBlocks(kind, next, addons)\n if (kind === 'ai_usage') {\n return current > 0 ? addons.block_ai_gbp : (addons.legacy_block_ai_gbp ?? 10)\n }\n return current > 0 ? addons.block_storage_gb : (addons.legacy_block_storage_gb ?? 10)\n}\n\n/**\n * Pounds typed into a usage cap field → pence. '' → the default (null); invalid → undefined.\n * Equal to the default is also sent as null (\"keep the default\").\n */\nexport function parseBudgetPounds(value: string): number | null | undefined {\n if (value.trim() === '') return null\n const n = Number(value)\n if (!Number.isFinite(n) || n < 0) return undefined\n return Math.round(n * 100)\n}\n\n/** Toast after saving the usage cap. */\nexport function budgetSavedMessage(capPence: number | null): string {\n if (capPence == null) return 'Usage cap: no limit'\n if (capPence === 0) return 'Usage cap: £0 (no automatic top-ups)'\n return `Usage cap: ${gbp(capPence)} a month`\n}\n\nconst gbText = (n: number) => `${Math.round(n * 10) / 10} GB`\n\n/** \"£25 of AI credits\" / \"25 GB\". */\nexport function stepLabel(kind: AddonKind, size: number): string {\n return kind === 'ai_usage' ? `${formatGbp(size)} of AI credits` : gbText(size)\n}\n\n/** The PUT /addons/next-period body that renews `keep` blocks of `kind` (the other kind unchanged). */\nexport function nextPeriodBody(kind: AddonKind, keep: number) {\n return kind === 'ai_usage'\n ? { ai_blocks: keep, storage_blocks: null }\n : { ai_blocks: null, storage_blocks: keep }\n}\n\n/**\n * The \"+\" step's price line, ex VAT: \"£25/month · today £25\" (annual: \"£18.75/month · today £150\");\n * storage, charged for the rest of the period: \"£25/month · prorated today £8.33\".\n */\nexport function addStepCaption(kind: AddonKind, addons: ProjectAddons): string {\n const now = gbp(addonPriceExVatPence(kind, addons))\n const today = kind === 'storage' ? `prorated today ${now}` : `today ${now}`\n return `${gbp(blockMonthlyExVatPence(kind, addons))}/month · ${today}`\n}\n","/** Pro's allowance per month (one licence) — must match the backend. Legacy multi-pack plans get it per pack.\n * The live numbers for an existing project come from `project.addons`; these are only for\n * describing the plan before a project exists (new-project dialog, upgrade picker). */\nexport const PRO_AI_GBP = 10\nexport const PRO_STORAGE_GB = 5\nexport const PRO_COLLABORATORS = 1\nexport const COLLABORATOR_BLOCK_SIZE = 5\n\n/**\n * Add-on block sizes (£25 of AI credits or 25 GB), the same on every plan. Their prices come from the\n * products API (`addon_prices`) before a project exists, and from `project.addons` after.\n */\nexport const ADDON_BLOCK_AI_GBP = 25\nexport const STORAGE_BLOCK_GB = 25\n\n/** Default monthly usage cap for a new Pro project (pence); it limits automatic top-ups only. 0 = no automatic\n * top-ups, null = no limit. */\nexport const DEFAULT_SPEND_CAP_PENCE = 10000\n\n/** The automatic add-on triggers when less than this much AI credits (£) remains; the backend minimum. */\nexport const MIN_AUTO_TOPUP_THRESHOLD_GBP = 1\n\n/** Free-tier quotas — must match backend FREE_* constants in src/constants.py\n * (FREE_AI_GBP=1, FREE_STORAGE_GB=0.05 → 50 MB, FREE_COLLABORATORS=0). */\nexport const FREE_AI_GBP = 1\nexport const FREE_STORAGE_MB = 50\nexport const FREE_COLLABORATORS = 0\n\n/** Collaborator limits at or above this are \"unlimited\" (the backend reports 999 for dev). */\nexport const UNLIMITED_COLLABORATORS = 999\n\n/**\n * Suggested initial daily per-user AI credits cap (£), pre-filled when creating\n * a new project. The user can clear it to create a project with no cap.\n * Backend treats null as \"no enforcement\" — there is no server-side default.\n */\nexport const SUGGESTED_DAILY_CAP_PER_USER = 10\n","/**\n * Quota display — single source of truth.\n *\n * Builds the icon / label / formatted used-of-limit strings for a project's\n * quotas (AI credits in £, storage, collaborators). Shared by QuotaBadges and the\n * project tooltip so the numbers and units can never disagree (storage in GB on\n * plans of 1 GB or more, MB below).\n */\n\nimport { HardDrive, PoundSterling, Users } from 'lucide-react'\nimport { formatGbp } from '@arbidocs/react'\nimport type { QuotaMeterItem } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { UNLIMITED_COLLABORATORS } from './plan-constants'\n\ntype Quotas = components['schemas']['ProjectResponse']['quotas']\n\nconst fmt = (v: number) => Math.round(v).toLocaleString('en-US')\n\n/** \"May 31, 2025\" — the one format every AI-usage-reset mention uses. */\nexport function formatResetDate(unixTimestamp: number | null | undefined): string | null {\n if (!unixTimestamp) return null\n const date = new Date(unixTimestamp * 1000)\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\n/**\n * When the project's AI credits allowance next resets, as a unix timestamp.\n * Pro projects report it directly (`addons.ai_usage_reset_at` — monthly, even on an\n * annual plan); monthly subscriptions otherwise reset with the billing period\n * (`current_period_end`); free projects reset on the backend-stamped signup\n * anniversary (`quotas.budget_reset_at`). Only a FUTURE date is returned — a stale\n * past stamp would read as a bug, not a promise.\n */\nexport function aiUsageResetTimestamp(project: {\n quotas?: { budget_reset_at?: number | null } | null\n current_period_end?: number | null\n plan_interval?: string | null\n addons?: { ai_usage_reset_at?: number | null } | null\n}): number | null {\n // An annual period end is a year away — never a monthly AI credits reset.\n const periodEnd = project.plan_interval === 'year' ? null : project.current_period_end\n const ts =\n project.addons?.ai_usage_reset_at ?? periodEnd ?? project.quotas?.budget_reset_at ?? null\n return ts && ts * 1000 > Date.now() ? ts : null\n}\n\n// Defensive: a quota field may be missing on partial/empty payloads — treat it\n// as 0 / 0 rather than crashing the whole row.\nconst quota = (q?: { used?: number; limit?: number }) => ({\n used: q?.used ?? 0,\n limit: q?.limit ?? 0,\n})\n/** GB from 1 GB plans up (\"2.4 GB\", \"5 GB\"), MB below (\"50 MB\"); `unit: false` drops the unit. */\nfunction storageText(gbValue: number, limitGb: number, unit = true): string {\n if (limitGb >= 1) {\n const n = Math.round(gbValue * 10) / 10\n return `${n.toLocaleString('en-US')}${unit ? ' GB' : ''}`\n }\n return `${fmt(gbValue * 1000)}${unit ? ' MB' : ''}`\n}\nconst pctOf = (used: number, limit: number) => (limit > 0 ? (used / limit) * 100 : 0)\n\nexport function getQuotaItems(quotas: Quotas): QuotaMeterItem[] {\n const aiUsage = quota(quotas?.ai_usage)\n const storage = quota(quotas?.storage_gb)\n const collaborators = quota(quotas?.collaborators)\n const unlimitedCollaborators = collaborators.limit === UNLIMITED_COLLABORATORS\n return [\n {\n key: 'ai-usage',\n icon: PoundSterling,\n label: 'AI credits',\n used: formatGbp(aiUsage.used),\n usedOfLimit: `${formatGbp(aiUsage.used)} / ${formatGbp(aiUsage.limit)}`,\n pct: pctOf(aiUsage.used, aiUsage.limit),\n },\n {\n key: 'storage',\n icon: HardDrive,\n label: 'Storage',\n used: storageText(storage.used, storage.limit),\n usedOfLimit: `${storageText(storage.used, storage.limit, false)} / ${storageText(\n storage.limit,\n storage.limit\n )}`,\n pct: pctOf(storage.used, storage.limit),\n },\n {\n key: 'collaborators',\n icon: Users,\n label: 'Collaborators',\n used: fmt(collaborators.used),\n usedOfLimit: unlimitedCollaborators\n ? `${fmt(collaborators.used)} / Unlimited`\n : `${fmt(collaborators.used)} / ${fmt(collaborators.limit)}`,\n // Zero seats (Free) IS the cap: 0 / 0 shows a full destructive bar,\n // because you can't add anyone — the truth the upgrade door answers.\n // (Only when the quota is actually present; a missing field on a\n // partial payload stays an empty bar, not a false alarm.)\n pct: unlimitedCollaborators\n ? 0\n : quotas?.collaborators && collaborators.limit === 0\n ? 100\n : pctOf(collaborators.used, collaborators.limit),\n },\n ]\n}\n","/**\n * The `detail` of a refused billing call: the response body's `detail` (a string, or the\n * `{code, message}` of a payment refusal), whether the error is an SDK `ArbiApiError` (body in\n * `apiError`) or the body itself.\n */\nexport function apiErrorDetail(error: unknown): unknown {\n const body = (error as { apiError?: unknown } | null)?.apiError ?? error\n return (body as { detail?: unknown } | null)?.detail\n}\n","/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT\n * (reverse charge)\", \"£40.00 · no tax\".\n */\n\nimport type { components } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = components['schemas']['TaxQuoteResponse']\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"£42.00\" — always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '£', usd: '$', eur: '€' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (£40.00 + £8.00 VAT 20%)\", \"· no VAT (reverse charge)\", \"· no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '· no VAT (reverse charge)'\n if (tax <= 0) return '· no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT (reverse charge)\", \"£40.00 · no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"£21.00 incl. VAT\" / \"£17.50\" — a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today £48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n","/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (£10 of AI credits + 5 GB a month). Each price lists\n * `pack_prices` for that one licence — `amount` incl. UK VAT and `amount_ex_vat` — and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"£40 ex VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} ex VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro ×N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro ×${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today £42.00 incl. VAT (£35.00 + £7.00 VAT 20%)\" (\"Pay today £0\" for a change that waits)\n * - \"From 16 Nov 2026: £210.00 incl. VAT (£175.00 + £35.00 VAT 20%) a month\"\n * - \"Current plan until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current plan until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual plans: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 × £25 of AI credits + 1 × 25 GB\". */\nexport function checkoutItemsLabel(\n aiBlocks: number,\n storageBlocks: number,\n collaboratorBlocks = 0,\n price?: ProductPrice\n): string {\n const ai = addonPrice(price, 'ai_usage')?.ai_gbp\n const storage = addonPrice(price, 'storage')?.storage_gb\n const collaborators = price?.addon_prices?.find((p) => p.kind === 'collaborators')?.collaborators\n return [\n 'Pro',\n aiBlocks > 0 &&\n (ai != null\n ? `${aiBlocks} × ${formatGbp(ai)} of AI credits`\n : `${aiBlocks} AI credits add-ons`),\n storageBlocks > 0 &&\n (storage != null ? `${storageBlocks} × ${storage} GB` : `${storageBlocks} storage add-ons`),\n collaboratorBlocks > 0 &&\n (collaborators != null\n ? `${collaboratorBlocks * collaborators} extra collaborators`\n : `${collaboratorBlocks} collaborator add-ons`),\n ]\n .filter(Boolean)\n .join(' + ')\n}\n\n/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */\nexport function packPrice(\n price: ProductPrice | undefined,\n packs: number = PRO_PACKS\n): PackPrice | undefined {\n return price?.pack_prices?.find((p) => p.packs === packs)\n}\n\nexport interface ProPrices {\n monthly?: ProductPrice\n annual?: ProductPrice\n}\n\n/** The Pro product's monthly and annual prices (default price per interval wins). */\nexport function findProPrices(products: ProductResponse[] | undefined): ProPrices {\n const prices = products?.[0]?.prices ?? []\n const pick = (interval: PlanInterval) =>\n prices.find((p) => p.interval === interval && p.default_price) ??\n prices.find((p) => p.interval === interval)\n return { monthly: pick('month'), annual: pick('year') }\n}\n\n/** Annual savings vs 12 × monthly, as a whole percent (e.g. £360 vs £480 → 25). */\nexport function calcSavingsPercent(\n monthlyPrice: ProductPrice | undefined,\n annualPrice: ProductPrice | undefined\n): number | null {\n const monthly = packPrice(monthlyPrice)?.amount ?? monthlyPrice?.amount\n const annual = packPrice(annualPrice)?.amount ?? annualPrice?.amount\n if (monthly == null || annual == null || monthly === 0) return null\n const savings = Math.round(((monthly * 12 - annual) / (monthly * 12)) * 100)\n return savings > 0 ? savings : null\n}\n\n/** Most add-on blocks of each kind a checkout may include (the backend's limit). */\nexport const MAX_CHECKOUT_BLOCKS = 100\n\n/** \"£25/month ex VAT each\", annual: \"£225/year ex VAT each\": one block on the chosen interval. */\nexport function checkoutBlockPriceText(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage'\n): string | null {\n const block = addonPrice(price, kind)\n if (!block) return null\n const currency = price?.currency ?? 'gbp'\n return price?.interval === 'year'\n ? `${formatMoney(block.amount_ex_vat, currency)}/year ex VAT each`\n : `${formatMoney(block.amount_ex_vat, currency)}/month ex VAT each`\n}\n","import type { PlanBadgeProps } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { planNameForPacks } from './plan-pricing'\n\ntype ProjectBillingFields = Pick<\n components['schemas']['ProjectResponse'],\n 'subscription' | 'plan_interval'\n> &\n Partial<Pick<components['schemas']['ProjectResponse'], 'packs' | 'addons'>>\n\n/** A project is on Pro when it has a billing interval (null = Free or checkout pending). */\nexport function isProProject(project: Pick<ProjectBillingFields, 'plan_interval'>): boolean {\n return project.plan_interval != null\n}\n\n/** \"Pro\", or a legacy multi-pack plan's name (\"Pro ×N\") — the API's name when it sends one (owner view). */\nexport function proTierName(project: ProjectBillingFields): string {\n return project.addons?.plan_name || planNameForPacks(Math.max(project.packs ?? 1, 1))\n}\n\n/** \"Free\", \"Pro monthly\", \"Pro annual\", \"Pro ×3 monthly\" (legacy) or \"Dev\" — the full plan name. */\nexport function planName(project: ProjectBillingFields): string {\n if (project.subscription === 'dev') return 'Dev'\n if (project.subscription === 'suspended') return 'Subscription ended'\n if (!isProProject(project)) return 'Free'\n return `${proTierName(project)} ${project.plan_interval === 'year' ? 'annual' : 'monthly'}`\n}\n\n/**\n * Maps a project's billing state to the `PlanBadge` block's label + tone.\n * Pro reads as accent, Free/dev as neutral, payment trouble or cancelling as pending.\n */\nexport function planBadgeView(\n project: ProjectBillingFields\n): Pick<PlanBadgeProps, 'label' | 'tone'> {\n const { subscription } = project\n const label =\n subscription === 'suspended'\n ? 'Subscription ended'\n : subscription === 'canceled'\n ? 'Cancelling'\n : subscription === 'dev'\n ? 'Dev'\n : isProProject(project)\n ? proTierName(project)\n : 'Free'\n\n const tone =\n subscription === 'dev'\n ? 'dev'\n : subscription === 'suspended' || subscription === 'canceled' || subscription === 'past_due'\n ? 'pending'\n : isProProject(project)\n ? 'paid'\n : 'free'\n\n return { label, tone }\n}\n","/**\n * What a project's group in the workspace list says about the project itself: its plan badge (own\n * projects, where plans are sold), the usage readout beside its name, and the plan and limits\n * breakdown behind the name. One source for the cards' bands and the table's headings.\n */\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport type { components } from '@arbidocs/client'\nimport { UsageMeter } from '../../components/UsageMeter'\nimport { PlanBadge, QuotaMeter } from '../../settings'\nimport { ProjectBreakdown, ProjectReadout } from '../../home/ProjectBandParts'\nimport { planBadgeView } from '../billing/plan-badge'\nimport { getQuotaItems } from '../billing/quota-items'\n\ntype Project = components['schemas']['ProjectResponse']\n\nexport interface ProjectGroupBilling {\n /** The plan badge: own projects only, where plans are sold. */\n planBadge?: ReactNode\n /** Plan and usage, right after the name (projects with quotas). */\n readout?: ReactNode\n /** The plan and limits panel behind the name; meters for own projects only. */\n breakdown?: ReactNode\n}\n\nexport function projectGroupBilling(\n project: Project | undefined,\n { isOwned, stripeEnabled }: { isOwned: boolean; stripeEnabled: boolean }\n): ProjectGroupBilling {\n if (!project) return {}\n const planBadge = isOwned && stripeEnabled ? <PlanBadge {...planBadgeView(project)} /> : undefined\n const quotaItems = project.quotas ? getQuotaItems(project.quotas) : []\n const readout = project.quotas ? (\n <ProjectReadout\n plan={\n planBadge ? { badge: planBadge, testId: `project-tier-${project.external_id}` } : undefined\n }\n usage={{\n testId: `project-usage-${project.external_id}`,\n // Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.\n node: (\n <QuotaMeter\n items={quotaItems}\n size=\"sm\"\n showTooltips={false}\n showBars={stripeEnabled}\n showPercent={false}\n />\n ),\n }}\n />\n ) : (\n planBadge\n )\n const breakdown = (\n <ProjectBreakdown\n name={project.name}\n badge={planBadge}\n meters={\n isOwned\n ? quotaItems.map(({ key, icon, label, usedOfLimit, pct }) => (\n <UsageMeter\n key={key}\n icon={icon as LucideIcon}\n label={label}\n value={usedOfLimit}\n pct={pct}\n />\n ))\n : undefined\n }\n dailyCap={{\n label: 'Daily cap',\n value:\n project.daily_cap_per_user == null\n ? 'No limit'\n : project.daily_cap_per_user.toLocaleString('en-US'),\n }}\n />\n )\n return { planBadge, readout, breakdown }\n}\n"]}
1
+ {"version":3,"sources":["../src/connection/billing/reward-balance.ts","../src/connection/billing/support.ts","../src/connection/billing/addon-pricing.ts","../src/connection/billing/plan-constants.ts","../src/connection/billing/quota-items.ts","../src/connection/billing/api-error.ts","../src/connection/billing/tax-quote.ts","../src/connection/billing/plan-pricing.ts","../src/connection/billing/plan-badge.ts","../src/connection/workspace-list/projectBilling.tsx"],"names":["useUserSettings","useHost","useArbi","formatGbp","PoundSterling","HardDrive","Users","gbp","jsx","PlanBadge","ProjectReadout","QuotaMeter","ProjectBreakdown","UsageMeter"],"mappings":";;;;;;;;;;AAoBO,SAAS,gBAAA,GAAyC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A,EACE,OAAA,GACI,UAAA,CAAW,GAAA,CAAI,CAAC,EAAE,GAAA,EAAK,IAAA,EAAM,KAAA,EAAO,WAAA,EAAa,GAAA,EAAI,qBACnDJ,cAAA;AAAA,QAACK,4BAAA;AAAA,QAAA;AAAA,UAEC,IAAA;AAAA,UACA,KAAA;AAAA,UACA,KAAA,EAAO,WAAA;AAAA,UACP;AAAA,SAAA;AAAA,QAJK;AAAA,OAMR,CAAA,GACD,MAAA;AAAA,MAEN,QAAA,EAAU;AAAA,QACR,KAAA,EAAO,WAAA;AAAA,QACP,KAAA,EACE,QAAQ,kBAAA,IAAsB,IAAA,GAC1B,aACA,OAAA,CAAQ,kBAAA,CAAmB,eAAe,OAAO;AAAA;AACzD;AAAA,GACF;AAEF,EAAA,OAAO,EAAE,SAAA,EAAW,OAAA,EAAS,SAAA,EAAU;AACzC","file":"chunk-O4F77VSO.cjs","sourcesContent":["/**\n * Reward-balance logic (hook + money formatter).\n *\n * A user's reward balance is their available account balance — a single GLOBAL per-user\n * number, the Stripe customer account balance mirrored read-only into\n * `settings.extra_discount`. It auto-applies to the user's NEXT invoice.\n *\n * \"Rewards\" is the broad concept: the balance can be fed by several sources (referral\n * reward is just one). The referral pricing surfaces of the billing kit\n * speak to the referral source specifically; this module owns the balance itself.\n */\n\nimport { useUserSettings } from '@arbidocs/react'\n\nexport interface RewardBalance {\n amount: number // minor units (e.g. pennies) of available account balance\n currency: string\n}\n\n/** The user's available reward balance (all sources), or null if none. */\nexport function useRewardBalance(): RewardBalance | null {\n const { data } = useUserSettings({ refetchOnMount: 'always' })\n // Backend mirrors this read-only as { amount, currency }; schema types it as a loose object.\n const ed = data?.extra_discount as { amount?: number; currency?: string } | null | undefined\n if (!ed || !ed.amount || ed.amount <= 0) return null\n return { amount: ed.amount, currency: ed.currency || 'gbp' }\n}\n\n/** Format minor units as a localized money string, e.g. `£20` (whole) or `£29.99`. */\nexport function formatMoney(cents: number, currency = 'gbp'): string {\n const value = cents / 100\n const isWhole = Number.isInteger(value)\n const c = currency.toLowerCase()\n const symbol =\n c === 'usd' ? '$' : c === 'gbp' ? '£' : c === 'eur' ? '€' : currency.toUpperCase() + ' '\n return `${symbol}${value.toLocaleString('en-US', {\n minimumFractionDigits: isWhole ? 0 : 2,\n maximumFractionDigits: isWhole ? 0 : 2,\n })}`\n}\n","/**\n * What a host adds to the billing kit. Selling plans needs Stripe, which stays the host's: whether\n * this deployment sells plans (a publishable key is configured), and its embedded checkout. It is the\n * host configuration's `billing`; without it nothing is for sale: projects show their limits and\n * usage only.\n */\nimport type { ReactNode } from 'react'\nimport { useArbi } from '@arbidocs/react'\nimport { useHost } from '../../provider/host'\n\nexport interface BillingCheckoutSupport {\n /** Load the host's Stripe (lazily, when a checkout opens); `null` when it cannot. */\n load(): Promise<unknown> | null\n /** Stripe's embedded checkout for a session, on the loaded Stripe. */\n render(stripe: unknown, session: { clientSecret: string; onComplete: () => void }): ReactNode\n}\n\nexport interface BillingSupport {\n /** This deployment sells plans (Stripe is configured). */\n stripeEnabled: boolean\n checkout?: BillingCheckoutSupport\n}\n\nconst NOT_FOR_SALE: BillingSupport = { stripeEnabled: false }\n\nexport function useBillingSupport(): BillingSupport {\n return useHost().billing ?? NOT_FOR_SALE\n}\n\n/** The signed-in user's id (`usr-…`), to tell the projects they own from the others. */\nexport function useSelfExtId(): string | undefined {\n const arbi = useArbi()\n return arbi.isLoggedIn ? (arbi.user.identity()?.externalId ?? undefined) : undefined\n}\n","/** Add-on block price helpers (VAT-inclusive pence from `project.addons`). */\n\nimport { formatGbp } from '@arbidocs/react'\nimport type { components } from '@arbidocs/client'\nimport type { AddonKind } from './useAddonPurchase'\nimport { formatMoney } from './reward-balance'\n\ntype ProjectAddons = components['schemas']['ProjectAddons']\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** \"3 Nov 2026\". */\nexport function formatPeriodEnd(unix: number | null | undefined): string | null {\n if (!unix) return null\n return new Date(unix * 1000).toLocaleDateString('en-GB', {\n day: 'numeric',\n month: 'short',\n year: 'numeric',\n })\n}\n\n/** What one more block of this kind costs right now, incl. UK VAT. */\nexport function addonPricePence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage' ? addons.ai_block_price_pence : addons.storage_block_price_pence\n}\n\n/** The same price ex VAT. */\nfunction addonPriceExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_price_ex_vat_pence\n : addons.storage_block_price_ex_vat_pence\n}\n\n/**\n * The PUT /addons/settings body (the monthly usage cap and the automatic add-on trigger) from the current add-on\n * state with the given changes applied.\n */\nexport function addonSettingsBody(\n addons: ProjectAddons,\n change: Partial<{\n spend_cap_pence: number | null\n auto_topup_threshold_gbp: number\n }> = {}\n) {\n return {\n spend_cap_pence: addons.spend_cap_pence ?? null,\n auto_topup_threshold_gbp: addons.auto_topup_threshold_gbp,\n ...change,\n }\n}\n\n/**\n * Of `count` blocks of a kind, how many are on an earlier catalogue's price (legacy, at their old size: £10 of AI\n * usage or 10 GB) and how many on today's. A reduction removes today's blocks first, so the legacy ones are the\n * last kept.\n */\nexport function splitBlocks(\n kind: AddonKind,\n count: number,\n addons: ProjectAddons\n): { legacy: number; current: number } {\n const granted =\n (kind === 'ai_usage' ? addons.legacy_ai_blocks : addons.legacy_storage_blocks) ?? 0\n const legacy = Math.max(0, Math.min(granted, count))\n return { legacy, current: count - legacy }\n}\n\n/** One block's size: \"£25 of AI credits\" / \"25 GB\" (legacy: \"£10\" / \"10 GB\"). */\nfunction blockSize(kind: AddonKind, addons: ProjectAddons, legacy: boolean): string {\n if (kind === 'ai_usage') {\n return formatGbp(legacy ? (addons.legacy_block_ai_gbp ?? 10) : addons.block_ai_gbp)\n }\n return `${legacy ? (addons.legacy_block_storage_gb ?? 10) : addons.block_storage_gb} GB`\n}\n\n/**\n * \"2 × £25 of AI credits\", \"1 × £10 + 1 × £25 of AI credits\", \"1 × 10 GB + 2 × 25 GB\": `count` blocks of a kind, the\n * legacy ones (kept last on a reduction) at their old size.\n */\nexport function blocksLabel(kind: AddonKind, count: number, addons: ProjectAddons): string {\n const { legacy, current } = splitBlocks(kind, count, addons)\n const parts = [\n ...(legacy > 0 ? [`${legacy} × ${blockSize(kind, addons, true)}`] : []),\n ...(current > 0 || legacy === 0 ? [`${current} × ${blockSize(kind, addons, false)}`] : []),\n ]\n return `${parts.join(' + ')}${kind === 'ai_usage' ? ' of AI credits' : ''}`\n}\n\n/**\n * Bounds for \"Reduce from next period\": keep `min`..`current` blocks. `next` is what renews\n * now (a pending reduction, or the current count). Storage can't go below what usage needs.\n */\nexport function reduceBounds(\n kind: AddonKind,\n addons: ProjectAddons\n): { min: number; current: number; next: number } {\n const current = kind === 'ai_usage' ? addons.ai_blocks : addons.storage_blocks\n const pending = kind === 'ai_usage' ? addons.ai_blocks_next : addons.storage_blocks_next\n const min = 0\n return { min, current, next: pending ?? current }\n}\n\n/** One block's monthly-equivalent price ex VAT: AI credits and storage are priced separately. */\nfunction blockMonthlyExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_monthly_ex_vat_pence\n : addons.storage_block_monthly_ex_vat_pence\n}\n\n/** What one block renews at per billing period, ex VAT (annual: 12 × the monthly price). */\nfunction blockPeriodExVatPence(kind: AddonKind, addons: ProjectAddons): number {\n return kind === 'ai_usage'\n ? addons.ai_block_period_ex_vat_pence\n : addons.storage_block_period_ex_vat_pence\n}\n\n/** What one add-on renews at: \"£25/month ex VAT\" or \"£225/year ex VAT\". */\nfunction blockRenewalShort(kind: AddonKind, addons: ProjectAddons, isAnnual: boolean): string {\n return `${gbp(blockPeriodExVatPence(kind, addons))}/${isAnnual ? 'year' : 'month'} ex VAT`\n}\n\n/** The extra line annual plans show beside an AI credits add-on or upgrade price. */\nexport const ANNUAL_PREMIUM_AI_NOTE = 'No markup on Premium AI on annual plans'\n\n/** The confirm dialog's figures: charged now (incl. / ex VAT), what it covers until, then what renews. */\nexport function addonCharge(\n kind: AddonKind,\n addons: ProjectAddons,\n isAnnual: boolean,\n periodEnd: number | null | undefined\n): { now: string; nowExVat: string; nowVat: string; until: string | null; then: string } {\n return {\n now: gbp(addonPricePence(kind, addons)),\n nowExVat: gbp(addonPriceExVatPence(kind, addons)),\n nowVat: gbp(addonPricePence(kind, addons) - addonPriceExVatPence(kind, addons)),\n until: isAnnual ? formatPeriodEnd(periodEnd) : null,\n then: blockRenewalShort(kind, addons, isAnnual),\n }\n}\n\n/** Why automatic top-ups stopped (one line; the price of a step is on the Add button). */\nexport const CAP_REACHED_MESSAGE = 'Usage cap reached: no more automatic top-ups this month.'\n\n/** The £0 usage cap: no automatic top-ups (adding by hand still works). */\nexport const ZERO_BUDGET_MESSAGE = 'Automatic top-ups are off (£0 usage cap).'\n\n/** The usage cap's heading wherever it is edited or shown. */\nexport const USAGE_CAP_LABEL = 'Auto-upgrade limit'\n\n/** Automatic-upgrade spending is separate from explicitly selected allowances. */\nexport const USAGE_CAP_HELP =\n 'Your auto-upgrade limit covers extra monthly spend beyond your selected plan and add-ons. ' +\n '£0 turns automatic upgrades off. You can adjust usage add-ons with + and −. ' +\n 'Additions show the charge before you confirm; reductions apply next billing period, ' +\n 'provided your storage and collaborators fit. Prices are ex VAT.'\n\n/** A £0 cap turns automatic top-ups off (manual adds still work). */\nexport function isAddonBudgetZero(addons: Pick<ProjectAddons, 'spend_cap_pence'>): boolean {\n return addons.spend_cap_pence === 0\n}\n\n/**\n * How much more of a resource automatic top-ups may add this month before the usage cap stops them, in the\n * resource's unit (£ of AI credits / GB): the whole blocks the cap left pays for at today's ex-VAT price. `null` =\n * no limit; 0 with a £0 cap or when not even one block fits.\n */\nexport function autoRoom(kind: AddonKind, addons: ProjectAddons): number | null {\n const left = addons.cap_left_pence\n if (left == null) return addons.spend_cap_pence === 0 ? 0 : null\n const price = blockMonthlyExVatPence(kind, addons)\n if (price <= 0) return 0\n const blocks = Math.floor(left / price)\n return blocks * (kind === 'ai_usage' ? addons.block_ai_gbp : addons.block_storage_gb)\n}\n\n/** The size of the block a one-step reduction removes from what renews (today's blocks go first). */\nexport function nextRemovedBlockSize(kind: AddonKind, addons: ProjectAddons): number {\n const { next } = reduceBounds(kind, addons)\n const { current } = splitBlocks(kind, next, addons)\n if (kind === 'ai_usage') {\n return current > 0 ? addons.block_ai_gbp : (addons.legacy_block_ai_gbp ?? 10)\n }\n return current > 0 ? addons.block_storage_gb : (addons.legacy_block_storage_gb ?? 10)\n}\n\n/**\n * Pounds typed into a usage cap field → pence. '' → the default (null); invalid → undefined.\n * Equal to the default is also sent as null (\"keep the default\").\n */\nexport function parseBudgetPounds(value: string): number | null | undefined {\n if (value.trim() === '') return null\n const n = Number(value)\n if (!Number.isFinite(n) || n < 0) return undefined\n return Math.round(n * 100)\n}\n\n/** Toast after saving the usage cap. */\nexport function budgetSavedMessage(capPence: number | null): string {\n if (capPence == null) return 'Usage cap: no limit'\n if (capPence === 0) return 'Usage cap: £0 (no automatic top-ups)'\n return `Usage cap: ${gbp(capPence)} a month`\n}\n\nconst gbText = (n: number) => `${Math.round(n * 10) / 10} GB`\n\n/** \"£25 of AI credits\" / \"25 GB\". */\nexport function stepLabel(kind: AddonKind, size: number): string {\n return kind === 'ai_usage' ? `${formatGbp(size)} of AI credits` : gbText(size)\n}\n\n/** The PUT /addons/next-period body that renews `keep` blocks of `kind` (the other kind unchanged). */\nexport function nextPeriodBody(kind: AddonKind, keep: number) {\n return kind === 'ai_usage'\n ? { ai_blocks: keep, storage_blocks: null }\n : { ai_blocks: null, storage_blocks: keep }\n}\n\n/**\n * The \"+\" step's price line, ex VAT: \"£25/month · today £25\" (annual: \"£18.75/month · today £150\");\n * storage, charged for the rest of the period: \"£25/month · prorated today £8.33\".\n */\nexport function addStepCaption(kind: AddonKind, addons: ProjectAddons): string {\n const now = gbp(addonPriceExVatPence(kind, addons))\n const today = kind === 'storage' ? `prorated today ${now}` : `today ${now}`\n return `${gbp(blockMonthlyExVatPence(kind, addons))}/month · ${today}`\n}\n","/** Pro's allowance per month (one licence) — must match the backend. Legacy multi-pack plans get it per pack.\n * The live numbers for an existing project come from `project.addons`; these are only for\n * describing the plan before a project exists (new-project dialog, upgrade picker). */\nexport const PRO_AI_GBP = 10\nexport const PRO_STORAGE_GB = 5\nexport const PRO_COLLABORATORS = 1\nexport const COLLABORATOR_BLOCK_SIZE = 5\n\n/**\n * Add-on block sizes (£25 of AI credits or 25 GB), the same on every plan. Their prices come from the\n * products API (`addon_prices`) before a project exists, and from `project.addons` after.\n */\nexport const ADDON_BLOCK_AI_GBP = 25\nexport const STORAGE_BLOCK_GB = 25\n\n/** Default monthly usage cap for a new Pro project (pence); it limits automatic top-ups only. 0 = no automatic\n * top-ups, null = no limit. */\nexport const DEFAULT_SPEND_CAP_PENCE = 10000\n\n/** The automatic add-on triggers when less than this much AI credits (£) remains; the backend minimum. */\nexport const MIN_AUTO_TOPUP_THRESHOLD_GBP = 1\n\n/** Free-tier quotas — must match backend FREE_* constants in src/constants.py\n * (FREE_AI_GBP=1, FREE_STORAGE_GB=0.05 → 50 MB, FREE_COLLABORATORS=0). */\nexport const FREE_AI_GBP = 1\nexport const FREE_STORAGE_MB = 50\nexport const FREE_COLLABORATORS = 0\n\n/** Collaborator limits at or above this are \"unlimited\" (the backend reports 999 for dev). */\nexport const UNLIMITED_COLLABORATORS = 999\n\n/**\n * Suggested initial daily per-user AI credits cap (£), pre-filled when creating\n * a new project. The user can clear it to create a project with no cap.\n * Backend treats null as \"no enforcement\" — there is no server-side default.\n */\nexport const SUGGESTED_DAILY_CAP_PER_USER = 10\n","/**\n * Quota display — single source of truth.\n *\n * Builds the icon / label / formatted used-of-limit strings for a project's\n * quotas (AI credits in £, storage, collaborators). Shared by QuotaBadges and the\n * project tooltip so the numbers and units can never disagree (storage in GB on\n * plans of 1 GB or more, MB below).\n */\n\nimport { HardDrive, PoundSterling, Users } from 'lucide-react'\nimport { formatGbp } from '@arbidocs/react'\nimport type { QuotaMeterItem } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { UNLIMITED_COLLABORATORS } from './plan-constants'\n\ntype Quotas = components['schemas']['ProjectResponse']['quotas']\n\nconst fmt = (v: number) => Math.round(v).toLocaleString('en-US')\n\n/** \"May 31, 2025\" — the one format every AI-usage-reset mention uses. */\nexport function formatResetDate(unixTimestamp: number | null | undefined): string | null {\n if (!unixTimestamp) return null\n const date = new Date(unixTimestamp * 1000)\n return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })\n}\n\n/**\n * When the project's AI credits allowance next resets, as a unix timestamp.\n * Pro projects report it directly (`addons.ai_usage_reset_at` — monthly, even on an\n * annual plan); monthly subscriptions otherwise reset with the billing period\n * (`current_period_end`); free projects reset on the backend-stamped signup\n * anniversary (`quotas.budget_reset_at`). Only a FUTURE date is returned — a stale\n * past stamp would read as a bug, not a promise.\n */\nexport function aiUsageResetTimestamp(project: {\n quotas?: { budget_reset_at?: number | null } | null\n current_period_end?: number | null\n plan_interval?: string | null\n addons?: { ai_usage_reset_at?: number | null } | null\n}): number | null {\n // An annual period end is a year away — never a monthly AI credits reset.\n const periodEnd = project.plan_interval === 'year' ? null : project.current_period_end\n const ts =\n project.addons?.ai_usage_reset_at ?? periodEnd ?? project.quotas?.budget_reset_at ?? null\n return ts && ts * 1000 > Date.now() ? ts : null\n}\n\n// Defensive: a quota field may be missing on partial/empty payloads — treat it\n// as 0 / 0 rather than crashing the whole row.\nconst quota = (q?: { used?: number; limit?: number }) => ({\n used: q?.used ?? 0,\n limit: q?.limit ?? 0,\n})\n/** GB from 1 GB plans up (\"2.4 GB\", \"5 GB\"), MB below (\"50 MB\"); `unit: false` drops the unit. */\nfunction storageText(gbValue: number, limitGb: number, unit = true): string {\n if (limitGb >= 1) {\n const n = Math.round(gbValue * 10) / 10\n return `${n.toLocaleString('en-US')}${unit ? ' GB' : ''}`\n }\n return `${fmt(gbValue * 1000)}${unit ? ' MB' : ''}`\n}\nconst pctOf = (used: number, limit: number) => (limit > 0 ? (used / limit) * 100 : 0)\n\nexport function getQuotaItems(quotas: Quotas): QuotaMeterItem[] {\n const aiUsage = quota(quotas?.ai_usage)\n const storage = quota(quotas?.storage_gb)\n const collaborators = quota(quotas?.collaborators)\n const unlimitedCollaborators = collaborators.limit === UNLIMITED_COLLABORATORS\n return [\n {\n key: 'ai-usage',\n icon: PoundSterling,\n label: 'AI credits',\n used: formatGbp(aiUsage.used),\n usedOfLimit: `${formatGbp(aiUsage.used)} / ${formatGbp(aiUsage.limit)}`,\n pct: pctOf(aiUsage.used, aiUsage.limit),\n },\n {\n key: 'storage',\n icon: HardDrive,\n label: 'Storage',\n used: storageText(storage.used, storage.limit),\n usedOfLimit: `${storageText(storage.used, storage.limit, false)} / ${storageText(\n storage.limit,\n storage.limit\n )}`,\n pct: pctOf(storage.used, storage.limit),\n },\n {\n key: 'collaborators',\n icon: Users,\n label: 'Collaborators',\n used: fmt(collaborators.used),\n usedOfLimit: unlimitedCollaborators\n ? `${fmt(collaborators.used)} / Unlimited`\n : `${fmt(collaborators.used)} / ${fmt(collaborators.limit)}`,\n // Zero seats (Free) IS the cap: 0 / 0 shows a full destructive bar,\n // because you can't add anyone — the truth the upgrade door answers.\n // (Only when the quota is actually present; a missing field on a\n // partial payload stays an empty bar, not a false alarm.)\n pct: unlimitedCollaborators\n ? 0\n : quotas?.collaborators && collaborators.limit === 0\n ? 100\n : pctOf(collaborators.used, collaborators.limit),\n },\n ]\n}\n","/**\n * The `detail` of a refused billing call: the response body's `detail` (a string, or the\n * `{code, message}` of a payment refusal), whether the error is an SDK `ArbiApiError` (body in\n * `apiError`) or the body itself.\n */\nexport function apiErrorDetail(error: unknown): unknown {\n const body = (error as { apiError?: unknown } | null)?.apiError ?? error\n return (body as { detail?: unknown } | null)?.detail\n}\n","/**\n * Tax-inclusive totals from the backend's Stripe Tax quotes (`TaxQuoteResponse`, plan-change\n * previews, add-on quotes): \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT\n * (reverse charge)\", \"£40.00 · no tax\".\n */\n\nimport type { components } from '@arbidocs/client'\nimport { apiErrorDetail } from './api-error'\n\nexport type TaxQuote = components['schemas']['TaxQuoteResponse']\n\n/** Countries whose tax depends on the postcode: the field is shown up front. */\nexport const POSTCODE_COUNTRIES: readonly string[] = ['US', 'CA']\n\n/** The quote error that asks for a ZIP / postal code. */\nexport const TAX_LOCATION_INVALID = 'TAX_LOCATION_INVALID'\n\n/** \"£42.00\" — always pence, so the parts of a total add up on screen. */\nexport function money2(pence: number, currency = 'gbp'): string {\n const symbol = { gbp: '£', usd: '$', eur: '€' }[currency.toLowerCase()] ?? `${currency} `\n return `${symbol}${(pence / 100).toLocaleString('en-GB', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}`\n}\n\nexport interface TaxParts {\n subtotal: number\n tax: number\n total: number\n /** \"VAT 20%\"; null when no tax is due. */\n label?: string | null\n reverseCharge?: boolean\n}\n\n/** \"VAT\" for a VAT label, else \"tax\". */\nfunction taxKind(label: string | null | undefined): string {\n return /^vat\\b/i.test(label ?? '') ? 'VAT' : 'tax'\n}\n\n/** What follows the total: \"incl. VAT (£40.00 + £8.00 VAT 20%)\", \"· no VAT (reverse charge)\", \"· no tax\". */\nexport function taxDetail({ subtotal, tax, label, reverseCharge }: TaxParts): string {\n if (reverseCharge) return '· no VAT (reverse charge)'\n if (tax <= 0) return '· no tax'\n return `incl. ${taxKind(label)} (${money2(subtotal)} + ${money2(tax)} ${label ?? 'tax'})`\n}\n\n/** \"£48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\", \"£40.00 · no VAT (reverse charge)\", \"£40.00 · no tax\". */\nexport function taxSummary(parts: TaxParts): string {\n return `${money2(parts.total)} ${taxDetail(parts)}`\n}\n\n/** \"£21.00 incl. VAT\" / \"£17.50\" — a total with only the word for its tax. */\nexport function totalWithTaxWord({ total, tax, label }: TaxParts): string {\n return tax > 0 ? `${money2(total)} incl. ${taxKind(label)}` : money2(total)\n}\n\n/** The parts of a quote response. */\nexport function quoteParts(quote: TaxQuote): TaxParts {\n return {\n subtotal: quote.subtotal_pence,\n tax: quote.tax_pence,\n total: quote.total_pence,\n label: quote.tax_label,\n reverseCharge: quote.reverse_charge,\n }\n}\n\n/** \"Total today £48.00 incl. VAT (£40.00 + £8.00 VAT 20%)\". */\nexport function quoteTotalLine(quote: TaxQuote): string {\n return `Total today ${taxSummary(quoteParts(quote))}`\n}\n\n/** The API error code (`detail.code`) and message, if any. */\nexport function quoteError(error: unknown): { code?: string; message?: string } {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: unknown; message?: unknown }\n return {\n code: typeof code === 'string' ? code : undefined,\n message: typeof message === 'string' ? message : undefined,\n }\n }\n return { message: typeof detail === 'string' ? detail : undefined }\n}\n","/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (£10 of AI credits + 5 GB a month). Each price lists\n * `pack_prices` for that one licence — `amount` incl. UK VAT and `amount_ex_vat` — and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"£40 ex VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} ex VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro ×N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro ×${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today £42.00 incl. VAT (£35.00 + £7.00 VAT 20%)\" (\"Pay today £0\" for a change that waits)\n * - \"From 16 Nov 2026: £210.00 incl. VAT (£175.00 + £35.00 VAT 20%) a month\"\n * - \"Current plan until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current plan until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual plans: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 × £25 of AI credits + 1 × 25 GB\". */\nexport function checkoutItemsLabel(\n aiBlocks: number,\n storageBlocks: number,\n collaboratorBlocks = 0,\n price?: ProductPrice\n): string {\n const ai = addonPrice(price, 'ai_usage')?.ai_gbp\n const storage = addonPrice(price, 'storage')?.storage_gb\n const collaborators = price?.addon_prices?.find((p) => p.kind === 'collaborators')?.collaborators\n return [\n 'Pro',\n aiBlocks > 0 &&\n (ai != null\n ? `${aiBlocks} × ${formatGbp(ai)} of AI credits`\n : `${aiBlocks} AI credits add-ons`),\n storageBlocks > 0 &&\n (storage != null ? `${storageBlocks} × ${storage} GB` : `${storageBlocks} storage add-ons`),\n collaboratorBlocks > 0 &&\n (collaborators != null\n ? `${collaboratorBlocks * collaborators} extra collaborators`\n : `${collaboratorBlocks} collaborator add-ons`),\n ]\n .filter(Boolean)\n .join(' + ')\n}\n\n/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */\nexport function packPrice(\n price: ProductPrice | undefined,\n packs: number = PRO_PACKS\n): PackPrice | undefined {\n return price?.pack_prices?.find((p) => p.packs === packs)\n}\n\nexport interface ProPrices {\n monthly?: ProductPrice\n annual?: ProductPrice\n}\n\n/** The Pro product's monthly and annual prices (default price per interval wins). */\nexport function findProPrices(products: ProductResponse[] | undefined): ProPrices {\n const prices = products?.[0]?.prices ?? []\n const pick = (interval: PlanInterval) =>\n prices.find((p) => p.interval === interval && p.default_price) ??\n prices.find((p) => p.interval === interval)\n return { monthly: pick('month'), annual: pick('year') }\n}\n\n/** Annual savings vs 12 × monthly, as a whole percent (e.g. £360 vs £480 → 25). */\nexport function calcSavingsPercent(\n monthlyPrice: ProductPrice | undefined,\n annualPrice: ProductPrice | undefined\n): number | null {\n const monthly = packPrice(monthlyPrice)?.amount ?? monthlyPrice?.amount\n const annual = packPrice(annualPrice)?.amount ?? annualPrice?.amount\n if (monthly == null || annual == null || monthly === 0) return null\n const savings = Math.round(((monthly * 12 - annual) / (monthly * 12)) * 100)\n return savings > 0 ? savings : null\n}\n\n/** Most add-on blocks of each kind a checkout may include (the backend's limit). */\nexport const MAX_CHECKOUT_BLOCKS = 100\n\n/** \"£25/month ex VAT each\", annual: \"£225/year ex VAT each\": one block on the chosen interval. */\nexport function checkoutBlockPriceText(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage'\n): string | null {\n const block = addonPrice(price, kind)\n if (!block) return null\n const currency = price?.currency ?? 'gbp'\n return price?.interval === 'year'\n ? `${formatMoney(block.amount_ex_vat, currency)}/year ex VAT each`\n : `${formatMoney(block.amount_ex_vat, currency)}/month ex VAT each`\n}\n","import type { PlanBadgeProps } from '../../settings'\nimport type { components } from '@arbidocs/client'\nimport { planNameForPacks } from './plan-pricing'\n\ntype ProjectBillingFields = Pick<\n components['schemas']['ProjectResponse'],\n 'subscription' | 'plan_interval'\n> &\n Partial<Pick<components['schemas']['ProjectResponse'], 'packs' | 'addons'>>\n\n/** A project is on Pro when it has a billing interval (null = Free or checkout pending). */\nexport function isProProject(project: Pick<ProjectBillingFields, 'plan_interval'>): boolean {\n return project.plan_interval != null\n}\n\n/** \"Pro\", or a legacy multi-pack plan's name (\"Pro ×N\") — the API's name when it sends one (owner view). */\nexport function proTierName(project: ProjectBillingFields): string {\n return project.addons?.plan_name || planNameForPacks(Math.max(project.packs ?? 1, 1))\n}\n\n/** \"Free\", \"Pro monthly\", \"Pro annual\", \"Pro ×3 monthly\" (legacy) or \"Dev\" — the full plan name. */\nexport function planName(project: ProjectBillingFields): string {\n if (project.subscription === 'dev') return 'Dev'\n if (project.subscription === 'suspended') return 'Subscription ended'\n if (!isProProject(project)) return 'Free'\n return `${proTierName(project)} ${project.plan_interval === 'year' ? 'annual' : 'monthly'}`\n}\n\n/**\n * Maps a project's billing state to the `PlanBadge` block's label + tone.\n * Pro reads as accent, Free/dev as neutral, payment trouble or cancelling as pending.\n */\nexport function planBadgeView(\n project: ProjectBillingFields\n): Pick<PlanBadgeProps, 'label' | 'tone'> {\n const { subscription } = project\n const label =\n subscription === 'suspended'\n ? 'Subscription ended'\n : subscription === 'canceled'\n ? 'Cancelling'\n : subscription === 'dev'\n ? 'Dev'\n : isProProject(project)\n ? proTierName(project)\n : 'Free'\n\n const tone =\n subscription === 'dev'\n ? 'dev'\n : subscription === 'suspended' || subscription === 'canceled' || subscription === 'past_due'\n ? 'pending'\n : isProProject(project)\n ? 'paid'\n : 'free'\n\n return { label, tone }\n}\n","/**\n * What a project's group in the workspace list says about the project itself: its plan badge (own\n * projects, where plans are sold), the usage readout beside its name, and the plan and limits\n * breakdown behind the name. One source for the cards' bands and the table's headings.\n */\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport type { components } from '@arbidocs/client'\nimport { UsageMeter } from '../../components/UsageMeter'\nimport { PlanBadge, QuotaMeter } from '../../settings'\nimport { ProjectBreakdown, ProjectReadout } from '../../home/ProjectBandParts'\nimport { planBadgeView } from '../billing/plan-badge'\nimport { getQuotaItems } from '../billing/quota-items'\n\ntype Project = components['schemas']['ProjectResponse']\n\nexport interface ProjectGroupBilling {\n /** The plan badge: own projects only, where plans are sold. */\n planBadge?: ReactNode\n /** Plan and usage, right after the name (projects with quotas). */\n readout?: ReactNode\n /** The plan and limits panel behind the name; meters for own projects only. */\n breakdown?: ReactNode\n}\n\nexport function projectGroupBilling(\n project: Project | undefined,\n { isOwned, stripeEnabled }: { isOwned: boolean; stripeEnabled: boolean }\n): ProjectGroupBilling {\n if (!project) return {}\n const planBadge = isOwned && stripeEnabled ? <PlanBadge {...planBadgeView(project)} /> : undefined\n const quotaItems = project.quotas ? getQuotaItems(project.quotas) : []\n const readout = project.quotas ? (\n <ProjectReadout\n plan={\n planBadge ? { badge: planBadge, testId: `project-tier-${project.external_id}` } : undefined\n }\n usage={{\n testId: `project-usage-${project.external_id}`,\n // Bare numbers without plans for sale: a glance beside the name, not the Plan & Usage detail.\n node: (\n <QuotaMeter\n items={quotaItems}\n size=\"sm\"\n showTooltips={false}\n showBars={stripeEnabled}\n showPercent={false}\n />\n ),\n }}\n />\n ) : (\n planBadge\n )\n const breakdown = (\n <ProjectBreakdown\n name={project.name}\n badge={planBadge}\n meters={\n isOwned\n ? quotaItems.map(({ key, icon, label, usedOfLimit, pct }) => (\n <UsageMeter\n key={key}\n icon={icon as LucideIcon}\n label={label}\n value={usedOfLimit}\n pct={pct}\n />\n ))\n : undefined\n }\n dailyCap={{\n label: 'Daily cap',\n value:\n project.daily_cap_per_user == null\n ? 'No limit'\n : project.daily_cap_per_user.toLocaleString('en-US'),\n }}\n />\n )\n return { planBadge, readout, breakdown }\n}\n"]}