@alfadocs/ui-kit-debug 0.45.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/_chunks/alia-sidebar-CVIPrdc9.js +1125 -0
  2. package/dist/_chunks/alia-sidebar-CVIPrdc9.js.map +1 -0
  3. package/dist/_chunks/{audio-recorder-C1rhKhSN.js → audio-recorder-DC-v9YFW.js} +81 -91
  4. package/dist/_chunks/audio-recorder-DC-v9YFW.js.map +1 -0
  5. package/dist/_chunks/{chat-input-CQe7nR_v.js → chat-input-CFwc7JxL.js} +2 -1
  6. package/dist/_chunks/{chat-input-CQe7nR_v.js.map → chat-input-CFwc7JxL.js.map} +1 -1
  7. package/dist/_chunks/{chat-message-ASgGtj-L.js → chat-message-B5JpFj0F.js} +79 -73
  8. package/dist/_chunks/chat-message-B5JpFj0F.js.map +1 -0
  9. package/dist/_chunks/code-block-HoddNOKJ.js +106 -0
  10. package/dist/_chunks/code-block-HoddNOKJ.js.map +1 -0
  11. package/dist/_chunks/download-CDF1sbL9.js +16 -0
  12. package/dist/_chunks/download-CDF1sbL9.js.map +1 -0
  13. package/dist/_chunks/{editable-currency-cell-renderer-BEBUQl9P.js → editable-currency-cell-renderer-CLil9B29.js} +283 -293
  14. package/dist/_chunks/editable-currency-cell-renderer-CLil9B29.js.map +1 -0
  15. package/dist/_chunks/{freemium-paywall-BYist2sJ.js → freemium-paywall-DzpD63WY.js} +2 -2
  16. package/dist/_chunks/{freemium-paywall-BYist2sJ.js.map → freemium-paywall-DzpD63WY.js.map} +1 -1
  17. package/dist/_chunks/mic-B4Gog3Gi.js +16 -0
  18. package/dist/_chunks/mic-B4Gog3Gi.js.map +1 -0
  19. package/dist/_chunks/{payment-form-DqEiEJRO.js → payment-form-BNTx4876.js} +225 -196
  20. package/dist/_chunks/payment-form-BNTx4876.js.map +1 -0
  21. package/dist/_chunks/pencil-CfQX-0Qc.js +21 -0
  22. package/dist/_chunks/pencil-CfQX-0Qc.js.map +1 -0
  23. package/dist/_chunks/{streaming-text-GH07yIYh.js → streaming-text-CfhDqtIT.js} +49 -45
  24. package/dist/_chunks/streaming-text-CfhDqtIT.js.map +1 -0
  25. package/dist/_chunks/{workflow-map-BFNpzTiw.js → workflow-map-Djn1QMJc.js} +135 -150
  26. package/dist/_chunks/workflow-map-Djn1QMJc.js.map +1 -0
  27. package/dist/agent-catalog.json +1 -1
  28. package/dist/components/_shared/code-block.d.ts +39 -0
  29. package/dist/components/_shared/code-block.d.ts.map +1 -0
  30. package/dist/components/audio-recorder/index.js +1 -1
  31. package/dist/components/chat-input/index.js +1 -1
  32. package/dist/components/chat-message/chat-message.d.ts +6 -0
  33. package/dist/components/chat-message/chat-message.d.ts.map +1 -1
  34. package/dist/components/chat-message/index.js +1 -1
  35. package/dist/components/data-table/index.js +1 -1
  36. package/dist/components/freemium-paywall/index.js +1 -1
  37. package/dist/components/payment-form/index.js +1 -1
  38. package/dist/components/payment-form/payment-form.d.ts +6 -0
  39. package/dist/components/payment-form/payment-form.d.ts.map +1 -1
  40. package/dist/components/streaming-text/index.js +1 -1
  41. package/dist/components/streaming-text/streaming-text.d.ts.map +1 -1
  42. package/dist/components/workflow/index.js +1 -1
  43. package/dist/i18n/locales/ar.d.ts +15 -0
  44. package/dist/i18n/locales/ar.d.ts.map +1 -1
  45. package/dist/i18n/locales/ar.js +16 -1
  46. package/dist/i18n/locales/ar.js.map +1 -1
  47. package/dist/i18n/locales/de.d.ts +15 -0
  48. package/dist/i18n/locales/de.d.ts.map +1 -1
  49. package/dist/i18n/locales/de.js +16 -1
  50. package/dist/i18n/locales/de.js.map +1 -1
  51. package/dist/i18n/locales/el.d.ts +15 -0
  52. package/dist/i18n/locales/el.d.ts.map +1 -1
  53. package/dist/i18n/locales/el.js +16 -1
  54. package/dist/i18n/locales/el.js.map +1 -1
  55. package/dist/i18n/locales/en.d.ts +15 -0
  56. package/dist/i18n/locales/en.d.ts.map +1 -1
  57. package/dist/i18n/locales/en.js +16 -1
  58. package/dist/i18n/locales/en.js.map +1 -1
  59. package/dist/i18n/locales/es.d.ts +15 -0
  60. package/dist/i18n/locales/es.d.ts.map +1 -1
  61. package/dist/i18n/locales/es.js +16 -1
  62. package/dist/i18n/locales/es.js.map +1 -1
  63. package/dist/i18n/locales/fr.d.ts +15 -0
  64. package/dist/i18n/locales/fr.d.ts.map +1 -1
  65. package/dist/i18n/locales/fr.js +16 -1
  66. package/dist/i18n/locales/fr.js.map +1 -1
  67. package/dist/i18n/locales/hi.d.ts +15 -0
  68. package/dist/i18n/locales/hi.d.ts.map +1 -1
  69. package/dist/i18n/locales/hi.js +16 -1
  70. package/dist/i18n/locales/hi.js.map +1 -1
  71. package/dist/i18n/locales/it.d.ts +15 -0
  72. package/dist/i18n/locales/it.d.ts.map +1 -1
  73. package/dist/i18n/locales/it.js +16 -1
  74. package/dist/i18n/locales/it.js.map +1 -1
  75. package/dist/i18n/locales/ja.d.ts +15 -0
  76. package/dist/i18n/locales/ja.d.ts.map +1 -1
  77. package/dist/i18n/locales/ja.js +16 -1
  78. package/dist/i18n/locales/ja.js.map +1 -1
  79. package/dist/i18n/locales/nl.d.ts +15 -0
  80. package/dist/i18n/locales/nl.d.ts.map +1 -1
  81. package/dist/i18n/locales/nl.js +16 -1
  82. package/dist/i18n/locales/nl.js.map +1 -1
  83. package/dist/i18n/locales/pl.d.ts +15 -0
  84. package/dist/i18n/locales/pl.d.ts.map +1 -1
  85. package/dist/i18n/locales/pl.js +16 -1
  86. package/dist/i18n/locales/pl.js.map +1 -1
  87. package/dist/i18n/locales/pt.d.ts +15 -0
  88. package/dist/i18n/locales/pt.d.ts.map +1 -1
  89. package/dist/i18n/locales/pt.js +16 -1
  90. package/dist/i18n/locales/pt.js.map +1 -1
  91. package/dist/i18n/locales/ro.d.ts +15 -0
  92. package/dist/i18n/locales/ro.d.ts.map +1 -1
  93. package/dist/i18n/locales/ro.js +16 -1
  94. package/dist/i18n/locales/ro.js.map +1 -1
  95. package/dist/i18n/locales/ru.d.ts +15 -0
  96. package/dist/i18n/locales/ru.d.ts.map +1 -1
  97. package/dist/i18n/locales/ru.js +16 -1
  98. package/dist/i18n/locales/ru.js.map +1 -1
  99. package/dist/i18n/locales/sq.d.ts +15 -0
  100. package/dist/i18n/locales/sq.d.ts.map +1 -1
  101. package/dist/i18n/locales/sq.js +16 -1
  102. package/dist/i18n/locales/sq.js.map +1 -1
  103. package/dist/i18n/locales/sv.d.ts +15 -0
  104. package/dist/i18n/locales/sv.d.ts.map +1 -1
  105. package/dist/i18n/locales/sv.js +16 -1
  106. package/dist/i18n/locales/sv.js.map +1 -1
  107. package/dist/i18n/locales/tr.d.ts +15 -0
  108. package/dist/i18n/locales/tr.d.ts.map +1 -1
  109. package/dist/i18n/locales/tr.js +16 -1
  110. package/dist/i18n/locales/tr.js.map +1 -1
  111. package/dist/i18n/locales/zh.d.ts +15 -0
  112. package/dist/i18n/locales/zh.d.ts.map +1 -1
  113. package/dist/i18n/locales/zh.js +16 -1
  114. package/dist/i18n/locales/zh.js.map +1 -1
  115. package/dist/index.js +9 -9
  116. package/dist/locales/ar.json +16 -1
  117. package/dist/locales/de.json +16 -1
  118. package/dist/locales/el.json +16 -1
  119. package/dist/locales/en.json +16 -1
  120. package/dist/locales/es.json +16 -1
  121. package/dist/locales/fr.json +16 -1
  122. package/dist/locales/hi.json +16 -1
  123. package/dist/locales/it.json +16 -1
  124. package/dist/locales/ja.json +16 -1
  125. package/dist/locales/nl.json +16 -1
  126. package/dist/locales/pl.json +16 -1
  127. package/dist/locales/pt.json +16 -1
  128. package/dist/locales/ro.json +16 -1
  129. package/dist/locales/ru.json +16 -1
  130. package/dist/locales/sq.json +16 -1
  131. package/dist/locales/sv.json +16 -1
  132. package/dist/locales/tr.json +16 -1
  133. package/dist/locales/zh.json +16 -1
  134. package/dist/patterns/alia-assistant/alia-chat-surface.d.ts.map +1 -1
  135. package/dist/patterns/alia-assistant/alia-types.d.ts +61 -0
  136. package/dist/patterns/alia-assistant/alia-types.d.ts.map +1 -1
  137. package/dist/patterns/alia-assistant/index.js +1 -1
  138. package/dist/tokens/themes/bridges/stripe-appearance.d.ts.map +1 -1
  139. package/dist/tokens.css +1 -1
  140. package/package.json +1 -1
  141. package/dist/_chunks/alia-sidebar-Be8FhKYd.js +0 -837
  142. package/dist/_chunks/alia-sidebar-Be8FhKYd.js.map +0 -1
  143. package/dist/_chunks/audio-recorder-C1rhKhSN.js.map +0 -1
  144. package/dist/_chunks/chat-message-ASgGtj-L.js.map +0 -1
  145. package/dist/_chunks/editable-currency-cell-renderer-BEBUQl9P.js.map +0 -1
  146. package/dist/_chunks/payment-form-DqEiEJRO.js.map +0 -1
  147. package/dist/_chunks/streaming-text-GH07yIYh.js.map +0 -1
  148. package/dist/_chunks/workflow-map-BFNpzTiw.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-form-DqEiEJRO.js","sources":["../../src/tokens/themes/bridges/stripe-appearance.ts","../../src/components/payment-form/payment-form.agent.ts","../../src/components/payment-form/payment-form.tsx"],"sourcesContent":["import type { Appearance } from '@stripe/stripe-js';\n\n/**\n * Reads the current design-system tokens from a theme-root element and maps\n * them to Stripe Elements' Appearance API. `root` defaults to\n * `document.documentElement` but consumers can pass a scoped theme wrapper\n * (e.g. a modal with its own `.theme-accessible` override) so that Stripe\n * iframes pick up the right token set.\n *\n * Tokens referenced: --primary, --background, --foreground, --muted,\n * --muted-foreground, --border, --destructive, --radius-md, --font-sans,\n * --font-size-base, --spacing-sm, --animation-duration, --focus-ring-width,\n * --ring.\n *\n * No hex / rgb / hsl literals — every value flows from the token layer.\n */\n\nfunction isBrowser(): boolean {\n return typeof document !== 'undefined' && typeof window !== 'undefined';\n}\n\nexport function getStripeAppearance(root?: HTMLElement): Appearance {\n if (!isBrowser()) {\n return { theme: 'stripe' };\n }\n\n const target = root ?? document.documentElement;\n const styles = getComputedStyle(target);\n const read = (token: string) => styles.getPropertyValue(token).trim();\n const isDark = target.classList.contains('theme-dark');\n\n return {\n theme: isDark ? 'night' : 'stripe',\n variables: {\n colorPrimary: read('--primary'),\n colorBackground: read('--background'),\n colorText: read('--foreground'),\n colorDanger: read('--destructive'),\n colorTextSecondary: read('--muted-foreground'),\n colorTextPlaceholder: read('--muted-foreground'),\n borderRadius: read('--radius-md'),\n fontFamily: read('--font-sans'),\n fontSizeBase: read('--font-size-base'),\n // Stripe multiplies spacingUnit throughout every Element; --spacing-sm\n // gives readable density. Keep this in sync with the JSDoc above.\n spacingUnit: read('--spacing-sm'),\n },\n rules: {\n '.Input': {\n backgroundColor: read('--background'),\n border: `1px solid ${read('--border')}`,\n color: read('--foreground'),\n padding: read('--spacing-sm'),\n transition: `border-color ${read('--animation-duration')} ease-out`,\n },\n '.Input:focus': {\n borderColor: read('--primary'),\n boxShadow: `0 0 0 ${read('--focus-ring-width')} ${read('--ring')}`,\n outline: 'none',\n },\n '.Input--invalid': {\n borderColor: read('--destructive'),\n color: read('--foreground'),\n },\n '.Label': {\n color: read('--foreground'),\n fontWeight: read('--font-weight-medium'),\n fontSize: read('--font-size-sm'),\n },\n '.Error': {\n color: read('--destructive'),\n fontSize: read('--font-size-sm'),\n },\n '.Tab': {\n border: `1px solid ${read('--border')}`,\n backgroundColor: read('--background'),\n color: read('--foreground'),\n },\n '.Tab--selected': {\n borderColor: read('--primary'),\n backgroundColor: read('--background'),\n color: read('--primary'),\n },\n },\n };\n}\n\n/**\n * Calls `onChange(getStripeAppearance(root))` whenever the theme root's\n * class list mutates (theme switch) or the user toggles\n * `prefers-color-scheme` / `prefers-reduced-motion`. Returns an\n * unsubscribe function.\n */\nexport function subscribeStripeAppearance(\n onChange: (next: Appearance) => void,\n root?: HTMLElement,\n): () => void {\n if (!isBrowser()) return () => undefined;\n\n const target = root ?? document.documentElement;\n const emit = () => onChange(getStripeAppearance(root));\n\n const observer = new MutationObserver(emit);\n observer.observe(target, {\n attributes: true,\n attributeFilter: ['class', 'dir', 'lang'],\n });\n\n const schemeMql = window.matchMedia('(prefers-color-scheme: dark)');\n const motionMql = window.matchMedia('(prefers-reduced-motion: reduce)');\n schemeMql.addEventListener('change', emit);\n motionMql.addEventListener('change', emit);\n\n return () => {\n observer.disconnect();\n schemeMql.removeEventListener('change', emit);\n motionMql.removeEventListener('change', emit);\n };\n}\n","import type { AgentAdapter } from '../../agent/types';\nimport type { PaymentFormHandle } from './payment-form';\n\nexport const paymentFormAgent: AgentAdapter<PaymentFormHandle> = {\n id: 'payment-form',\n capabilities: ['submit'],\n state: {},\n actions: {\n submit: {\n safety: 'destructive',\n description:\n 'Submit the payment. Charges the configured payment method — irreversible.',\n invoke: (handle) => handle.submit(),\n },\n reset: {\n safety: 'destructive',\n description:\n 'Reset the form to its initial state. Loses any in-progress input.',\n invoke: (handle) => {\n handle.reset();\n },\n },\n },\n domHooks: {\n root: { attr: 'data-component', value: 'payment-form' },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n","/* ------------------------------------------------------------------ */\n/* PaymentForm — Stripe Elements wrapper (PCI DSS SAQ-A). */\n/* */\n/* - Library: `@stripe/react-stripe-js` + `@stripe/stripe-js` (see */\n/* `src/docs/08-third-party.mdx §Payments`). Card number, expiry, */\n/* CVC, and postal code all live inside Stripe-hosted iframes on */\n/* `js.stripe.com` — raw PAN never touches our origin, keeping us */\n/* inside PCI DSS SAQ-A scope. */\n/* */\n/* - Theming: the `stripe-appearance` bridge snapshots our tokens into */\n/* Stripe's Appearance API (`variables`, `rules`). A */\n/* `MutationObserver` on `<html class>` re-runs the snapshot when */\n/* the user flips theme so the embedded iframes repaint. */\n/* */\n/* - Security invariants enforced in this file: */\n/* 1. No `<input type=\"tel\" name=\"card\">` anywhere. */\n/* 2. Error strings are sanitised via `stripCardLikeDigits` before */\n/* forwarding to `onError` (replaces any `\\b\\d{4,}\\b` with */\n/* `****`). */\n/* 3. Element change events are never logged; any dev-only logging */\n/* is gated behind `import.meta.env.DEV` — never runs in prod. */\n/* */\n/* TODO: */\n/* - Stripe's `direction: 'rtl'` is not part of the current */\n/* `Appearance` TypeScript type; we rely on CSS mirroring of our */\n/* chrome via logical properties and let Stripe lay out the iframe */\n/* ltr for now. Revisit when @stripe/stripe-js publishes the type. */\n/* - No `<CardNumberElement>` / split-fields story — `PaymentElement` */\n/* handles accordion + card-only modes via its own `layout` option.*/\n/* ------------------------------------------------------------------ */\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type FormEvent,\n type ReactElement,\n} from 'react';\nimport { cva } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { Spinner } from '../spinner';\nimport { Alert } from '../alert';\nimport {\n loadStripe,\n type Stripe,\n type Appearance,\n type StripeElementLocale,\n type StripeElementsOptions,\n} from '@stripe/stripe-js';\nimport {\n Elements,\n PaymentElement,\n AddressElement,\n useElements,\n useStripe,\n} from '@stripe/react-stripe-js';\n\nimport {\n getStripeAppearance,\n subscribeStripeAppearance,\n} from '../../tokens/themes/bridges/stripe-appearance';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { paymentFormAgent } from './payment-form.agent';\n\n/* ------------------------------------------------------------------ */\n/* Public types */\n/* ------------------------------------------------------------------ */\n\nexport type PaymentCurrency = string; // ISO-4217\n\nexport interface PaymentFormProps {\n /** Opaque instance id — emitted as `data-component-id` for the agent registry. */\n id?: string;\n /**\n * Client secret from your server, created via the PaymentIntents API.\n *\n * Omit to use **deferred-intent mode** — the Payment Element renders from\n * just the publishable key (no `clientSecret`, no backend round-trip up\n * front). In deferred mode supply `onCreatePaymentIntent` to actually\n * confirm: your server mints + returns the client secret at submit time.\n */\n clientSecret?: string;\n /**\n * Deferred-intent setup: `'payment'` collects a charge, `'setup'` saves a\n * method for later. Ignored when `clientSecret` is supplied (the secret's\n * own intent type wins). Defaults to `'payment'`.\n */\n mode?: 'payment' | 'setup';\n /**\n * Deferred-confirm callback. Called at submit time (after client-side\n * field validation succeeds) so your server can mint a PaymentIntent and\n * return its `client_secret`. The returned secret is used ONLY to confirm\n * and is never logged or sent to any third-party origin. When omitted in\n * deferred mode the form runs in PREVIEW: fields render + validate, but no\n * charge is attempted.\n */\n onCreatePaymentIntent?: () => Promise<string>;\n /** Stripe publishable key (`pk_test_…` / `pk_live_…`). */\n publishableKey: string;\n /** ISO-4217 currency code (e.g. 'EUR', 'USD', 'JPY'). */\n currency: PaymentCurrency;\n /** Amount in the currency's smallest unit (cents for EUR/USD, yen for JPY). */\n amount: number;\n /** Called with the PaymentIntent id on successful confirmation. */\n onSuccess?: (paymentIntentId: string) => void;\n /** Called with a sanitised error (no PAN digits, no Stripe English strings). */\n onError?: (error: { code: string; translatedMessage: string }) => void;\n /** Show the billing-address collector below the payment fields. */\n billingAddress?: boolean;\n /** Locale override — defaults to the active i18next locale. */\n locale?: string;\n /** Accessible label for the form. */\n ariaLabel?: string;\n /** URL Stripe redirects to when a payment method requires it. */\n returnUrl?: string;\n /** Pre-injected Stripe instance — used by tests + stories to bypass the network. */\n stripePromise?: Promise<Stripe | null> | null;\n className?: string;\n}\n\nexport interface PaymentFormHandle {\n /** Programmatically submit the form (same flow as the Pay button). */\n submit: () => Promise<void>;\n /** Reset the form to its initial state. */\n reset: () => void;\n}\n\n/* ------------------------------------------------------------------ */\n/* Currency helpers */\n/* ------------------------------------------------------------------ */\n\n/**\n * Currencies that Stripe bills in their base unit (no decimals). Source:\n * https://stripe.com/docs/currencies#zero-decimal — list pinned per\n * 08-third-party.mdx.\n */\nconst ZERO_DECIMAL_CURRENCIES = new Set<string>([\n 'BIF',\n 'CLP',\n 'DJF',\n 'GNF',\n 'IDR',\n 'JPY',\n 'KMF',\n 'KRW',\n 'MGA',\n 'PYG',\n 'RWF',\n 'UGX',\n 'VND',\n 'VUV',\n 'XAF',\n 'XOF',\n 'XPF',\n]);\n\nexport function formatPaymentAmount(\n amount: number,\n currency: string,\n locale: string,\n): string {\n const iso = currency.toUpperCase();\n const major = ZERO_DECIMAL_CURRENCIES.has(iso) ? amount : amount / 100;\n try {\n return new Intl.NumberFormat(locale, {\n style: 'currency',\n currency: iso,\n }).format(major);\n } catch {\n // Invalid locale/currency pair — fall back to a safe format so we\n // never leak raw amount integers into the UI.\n return new Intl.NumberFormat('en', {\n style: 'currency',\n currency: iso,\n }).format(major);\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Return URL validation */\n/* ------------------------------------------------------------------ */\n\n/**\n * Resolve `returnUrl` against the current origin. Accepts:\n * - absolute URLs on the same origin as `window.location`\n * - relative paths (resolved against the current origin)\n * Rejects (returns `null`):\n * - cross-origin URLs — would leak `payment_intent_client_secret`\n * - `javascript:` / `data:` / `file:` / `blob:` schemes\n * - SSR contexts (no `window`) — the submit path requires a browser\n * anyway, so rejecting here is the safer default.\n * See security-hardening.mdx.\n */\nexport function validateReturnUrl(\n returnUrl: string | undefined,\n): string | null {\n if (returnUrl === undefined) return null;\n const raw = returnUrl.trim();\n if (raw === '') return null;\n if (typeof window === 'undefined') return null;\n try {\n const resolved = new URL(raw, window.location.href);\n const allowedSchemes = new Set(['http:', 'https:']);\n if (!allowedSchemes.has(resolved.protocol)) return null;\n if (resolved.origin !== window.location.origin) return null;\n return resolved.toString();\n } catch {\n return null;\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Error sanitisation */\n/* ------------------------------------------------------------------ */\n\n/**\n * Replace any run of 4+ consecutive digits with `****`. Called before any\n * error text leaves the wrapper. Defensive: even though Stripe's error\n * strings don't normally contain PANs, a future SDK change could, and we\n * want a hard guarantee that `console` / analytics / Sentry breadcrumbs\n * stay clear of anything that looks like card data.\n */\nexport function stripCardLikeDigits(message: string): string {\n if (!message) return message;\n // Deliberately no word boundaries: a PAN run embedded between word\n // characters (e.g. \"CARD4242424242424242DECLINED\") must still be masked.\n return message.replace(/\\d{4,}/g, '****');\n}\n\n/**\n * Map a Stripe error code (e.g. `card_declined`, `incorrect_number`) to a\n * translation key under `payment.error.*`. Unknown codes fall through to\n * `payment.error.generic`.\n */\nexport function stripeErrorCodeToI18nKey(code: string | undefined): string {\n switch (code) {\n case 'incorrect_number':\n case 'invalid_number':\n return 'payment.error.cardNumber';\n case 'invalid_expiry_month':\n case 'invalid_expiry_year':\n case 'expired_card':\n return 'payment.error.expiry';\n case 'invalid_cvc':\n case 'incorrect_cvc':\n return 'payment.error.cvc';\n case 'incorrect_zip':\n case 'invalid_zip':\n return 'payment.error.postalCode';\n case 'card_declined':\n case 'do_not_honor':\n case 'generic_decline':\n return 'payment.error.declined';\n case 'network_error':\n case 'api_connection_error':\n return 'payment.error.network';\n default:\n return 'payment.error.generic';\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst formVariants = cva(\n [\n 'ds:payment-form-alfadocs ds:flex ds:flex-col',\n 'ds:gap-[var(--spacing-md)]',\n 'ds:bg-[var(--background)] ds:text-[var(--foreground)]',\n 'ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--card-border)] ds:shadow-[var(--shadow-card)] ds:[.theme-accessible_&]:border-2',\n 'ds:p-[var(--spacing-md)]',\n 'ds:aria-disabled:opacity-[var(--opacity-50)] ds:aria-disabled:cursor-not-allowed',\n ].join(' '),\n);\n\nconst fieldLabelVariants = cva(\n ['ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]'].join(' '),\n);\n\nconst labelTextVariants = cva(\n ['type-label', 'ds:text-[var(--foreground)]'].join(' '),\n);\n\nconst amountSummaryVariants = cva(\n [\n 'ds:flex ds:items-baseline ds:justify-between',\n 'ds:gap-[var(--spacing-sm)]',\n 'ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]',\n 'ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]',\n 'ds:bg-[var(--muted)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:text-[var(--foreground)]',\n ].join(' '),\n);\n\nconst submitButtonVariants = cva(\n [\n 'ds:inline-flex ds:items-center ds:justify-center ds:gap-[var(--spacing-xs)]',\n 'ds:[min-block-size:var(--min-target-size)]',\n 'ds:[min-inline-size:var(--min-target-size)]',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:bg-[var(--primary)] ds:text-[var(--primary-foreground)]',\n 'ds:text-[length:var(--font-size-base)] ds:font-medium',\n 'ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n 'ds:hover:bg-[var(--primary-hover)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)]',\n 'ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[var(--ring)]',\n 'ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n 'ds:aria-disabled:opacity-[var(--opacity-50)] ds:aria-disabled:cursor-not-allowed',\n 'ds:aria-busy:cursor-wait',\n ].join(' '),\n);\n\n/* ------------------------------------------------------------------ */\n/* Inner form — lives inside the <Elements> provider */\n/* ------------------------------------------------------------------ */\n\ninterface InnerPaymentFormProps {\n amount: number;\n currency: string;\n locale: string;\n billingAddress: boolean;\n returnUrl: string | undefined;\n /** Present in immediate mode; `undefined` in deferred mode. */\n clientSecret: string | undefined;\n /** Deferred-confirm callback; `undefined` → preview (validate-only). */\n onCreatePaymentIntent: PaymentFormProps['onCreatePaymentIntent'];\n onSuccess: PaymentFormProps['onSuccess'];\n onError: PaymentFormProps['onError'];\n}\n\nfunction InnerPaymentForm(props: InnerPaymentFormProps): ReactElement {\n const {\n amount,\n currency,\n locale,\n billingAddress,\n returnUrl,\n clientSecret,\n onCreatePaymentIntent,\n onSuccess,\n onError,\n } = props;\n\n const { t } = useTranslation();\n const stripe = useStripe();\n const elements = useElements();\n\n const rawId = useId();\n const idSafe = useMemo(\n () => `pay-${rawId.replace(/[^a-zA-Z0-9-_]/g, '')}`,\n [rawId],\n );\n const paymentFieldId = `${idSafe}-payment`;\n const addressFieldId = `${idSafe}-address`;\n const errorId = `${idSafe}-error`;\n\n const [processing, setProcessing] = useState(false);\n const [elementComplete, setElementComplete] = useState(false);\n const [errorKey, setErrorKey] = useState<string | null>(null);\n const [errorMessage, setErrorMessage] = useState<string>('');\n\n const onSuccessRef = useRef(onSuccess);\n const onErrorRef = useRef(onError);\n useEffect(() => {\n onSuccessRef.current = onSuccess;\n onErrorRef.current = onError;\n }, [onSuccess, onError]);\n\n const handleSubmit = useCallback(\n async (event?: FormEvent<HTMLFormElement>): Promise<void> => {\n if (event) event.preventDefault();\n if (!stripe || !elements) return;\n if (processing) return;\n\n setProcessing(true);\n setErrorKey(null);\n setErrorMessage('');\n\n // The single sanitise → map → setError → onError pipeline. Every error\n // surfaced by either path (immediate or deferred) flows through here so\n // raw Stripe English / PAN-like digit runs can never reach the UI or\n // `onError`. `rawMessage` is sanitised; the i18n key is mapped from\n // the Stripe error code.\n const reportError = (\n code: string,\n rawMessage: string | undefined,\n ): void => {\n const key = stripeErrorCodeToI18nKey(code);\n // CRITICAL: sanitise before storing OR forwarding.\n const safe = stripCardLikeDigits(rawMessage ?? '');\n setErrorKey(key);\n setErrorMessage(t(key));\n onErrorRef.current?.({\n code,\n translatedMessage: safe || t(key),\n });\n };\n\n // Validate returnUrl at the boundary so even a careless consumer\n // cannot leak payment_intent_client_secret to a third-party origin.\n const safeReturnUrl = validateReturnUrl(returnUrl);\n if (returnUrl !== undefined && safeReturnUrl === null) {\n setErrorKey('payment.error.invalidReturnUrl');\n setErrorMessage(t('payment.error.invalidReturnUrl'));\n onErrorRef.current?.({\n code: 'invalid_return_url',\n translatedMessage: t('payment.error.invalidReturnUrl'),\n });\n setProcessing(false);\n return;\n }\n\n const confirmParams = safeReturnUrl ? { return_url: safeReturnUrl } : {};\n\n try {\n if (clientSecret !== undefined) {\n // ----- Immediate mode: the consumer already minted the secret. ---\n const result = await stripe.confirmPayment({\n elements,\n confirmParams,\n redirect: 'if_required',\n });\n\n if (result.error) {\n reportError(result.error.code ?? 'generic', result.error.message);\n return;\n }\n\n // Success path — only the PaymentIntent id leaves the wrapper.\n if (result.paymentIntent) {\n onSuccessRef.current?.(result.paymentIntent.id);\n }\n return;\n }\n\n // ----- Deferred-intent mode: no secret up front. -----------------\n // Run client-side field validation first; on failure we run the\n // SAME sanitise/map/report pipeline and stop (no secret minted).\n const { error: submitError } = await elements.submit();\n if (submitError) {\n reportError(submitError.code ?? 'generic', submitError.message);\n return;\n }\n\n // No confirm callback → PREVIEW mode. The field validation above is\n // the end of the flow: no secret is minted, no charge is attempted,\n // and we surface no error — the fields simply validated.\n if (!onCreatePaymentIntent) {\n return;\n }\n\n // Mint the secret on the consumer's server, then confirm with it.\n // The minted secret is used ONLY here and is never logged or sent to\n // a third-party origin.\n const mintedSecret = await onCreatePaymentIntent();\n const result = await stripe.confirmPayment({\n elements,\n clientSecret: mintedSecret,\n confirmParams,\n redirect: 'if_required',\n });\n\n if (result.error) {\n reportError(result.error.code ?? 'generic', result.error.message);\n return;\n }\n\n if (result.paymentIntent) {\n onSuccessRef.current?.(result.paymentIntent.id);\n }\n } catch (err: unknown) {\n const raw = err instanceof Error ? err.message : '';\n // Generic, sanitised — covers a thrown onCreatePaymentIntent and any\n // unexpected SDK rejection. Never surface the raw thrown text.\n reportError('unexpected', raw);\n } finally {\n setProcessing(false);\n }\n },\n [\n stripe,\n elements,\n processing,\n returnUrl,\n clientSecret,\n onCreatePaymentIntent,\n t,\n ],\n );\n\n // Imperative submit hook used by the outer component's ref handle.\n useEffect(() => {\n const host = document.getElementById(idSafe);\n if (!host) return;\n const submitter = () => {\n void handleSubmit();\n };\n host.addEventListener('payment-form:submit', submitter);\n return () => host.removeEventListener('payment-form:submit', submitter);\n }, [idSafe, handleSubmit]);\n\n // Preview mode = deferred (no clientSecret) with no confirm callback. There\n // no charge happens, so we keep the button enabled even before the fields\n // report complete: clicking it triggers `elements.submit()` validation,\n // which is the entire point of the preview.\n const isPreview = clientSecret === undefined && !onCreatePaymentIntent;\n const submitDisabled =\n !stripe || !elements || processing || (!isPreview && !elementComplete);\n\n return (\n <form\n id={idSafe}\n onSubmit={handleSubmit}\n aria-label={t('payment.ariaLabel')}\n aria-busy={processing || undefined}\n noValidate\n >\n <div className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\">\n <div className={amountSummaryVariants()}>\n <span className={labelTextVariants()}>\n {t('payment.amountLabel')}\n </span>\n <span className=\"type-title-card\" data-testid=\"payment-amount\">\n {formatPaymentAmount(amount, currency, locale)}\n </span>\n </div>\n\n <label\n htmlFor={paymentFieldId}\n className={fieldLabelVariants()}\n data-testid=\"payment-field\"\n >\n <span className={labelTextVariants()}>\n {t('payment.fields.card')}\n </span>\n <PaymentElement\n id={paymentFieldId}\n options={{\n layout: { type: 'accordion', defaultCollapsed: false },\n }}\n onChange={(ev) => {\n // NOTE: never log `ev` — change events may include hints\n // about field contents. Keep only the boolean completeness.\n setElementComplete(ev.complete === true);\n if (ev.complete) {\n setErrorKey(null);\n setErrorMessage('');\n }\n }}\n />\n </label>\n\n {billingAddress ? (\n <label\n htmlFor={addressFieldId}\n className={fieldLabelVariants()}\n data-testid=\"payment-address\"\n >\n <span className={labelTextVariants()}>\n {t('payment.billingAddress')}\n </span>\n <AddressElement id={addressFieldId} options={{ mode: 'billing' }} />\n </label>\n ) : null}\n\n {errorKey ? (\n <Alert\n id={errorId}\n variant=\"error\"\n live=\"polite\"\n data-testid=\"payment-error\"\n >\n <Alert.Description>{errorMessage}</Alert.Description>\n </Alert>\n ) : null}\n\n <button\n type=\"submit\"\n aria-disabled={submitDisabled || undefined}\n aria-busy={processing || undefined}\n aria-describedby={errorKey ? errorId : undefined}\n className={submitButtonVariants()}\n data-testid=\"payment-submit\"\n >\n {processing ? (\n <>\n <Spinner size=\"sm\" label={t('payment.processing')} />\n <span>{t('payment.processing')}</span>\n </>\n ) : (\n <span>\n {t('payment.submit', {\n amount: formatPaymentAmount(amount, currency, locale),\n })}\n </span>\n )}\n </button>\n </div>\n </form>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* PaymentForm — outer wrapper */\n/* ------------------------------------------------------------------ */\n\n/**\n * Stripe ships a closed union of supported locales; anything outside it\n * must fall through to `'auto'` (Stripe picks the best match from the\n * browser). We also normalise the legacy `cn` code to `zh` per\n * `src/docs/06-i18n.mdx`.\n */\nconst STRIPE_LOCALES = new Set<StripeElementLocale>([\n 'auto',\n 'ar',\n 'bg',\n 'cs',\n 'da',\n 'de',\n 'el',\n 'en',\n 'en-AU',\n 'en-CA',\n 'en-NZ',\n 'en-GB',\n 'es',\n 'es-ES',\n 'es-419',\n 'et',\n 'fi',\n 'fil',\n 'fr',\n 'fr-CA',\n 'fr-FR',\n 'he',\n 'hu',\n 'hr',\n 'id',\n 'it',\n 'it-IT',\n 'ja',\n 'ko',\n 'lt',\n 'lv',\n 'ms',\n 'mt',\n 'nb',\n 'nl',\n 'no',\n 'pl',\n 'pt',\n 'pt-BR',\n 'ro',\n 'ru',\n 'sk',\n 'sl',\n 'sv',\n 'th',\n 'tr',\n 'vi',\n 'zh',\n 'zh-HK',\n 'zh-TW',\n]);\n\nfunction normaliseLocale(input: string): StripeElementLocale {\n if (!input) return 'auto';\n const candidate = input === 'cn' ? 'zh' : input;\n if ((STRIPE_LOCALES as Set<string>).has(candidate)) {\n return candidate as StripeElementLocale;\n }\n // Try stripping region (\"en-US\" → \"en\") before giving up.\n const base = candidate.split('-')[0];\n if ((STRIPE_LOCALES as Set<string>).has(base)) {\n return base as StripeElementLocale;\n }\n return 'auto';\n}\n\nexport const PaymentForm = forwardRef<HTMLDivElement, PaymentFormProps>(\n (\n {\n id,\n clientSecret,\n mode = 'payment',\n onCreatePaymentIntent,\n publishableKey,\n currency,\n amount,\n onSuccess,\n onError,\n billingAddress = false,\n locale,\n ariaLabel,\n returnUrl,\n stripePromise: injectedStripe,\n className,\n },\n ref,\n ) => {\n const { i18n } = useTranslation();\n const activeLocale = normaliseLocale(locale ?? i18n.language ?? 'en');\n\n // Stripe instance — pre-injected (tests/stories) or lazily loaded.\n const [stripeInstance, setStripeInstance] =\n useState<Promise<Stripe | null> | null>(injectedStripe ?? null);\n\n useEffect(() => {\n if (injectedStripe !== undefined) {\n setStripeInstance(injectedStripe);\n return;\n }\n if (!publishableKey) {\n setStripeInstance(null);\n return;\n }\n // `loadStripe` is cached by the SDK — safe to call per mount.\n setStripeInstance(loadStripe(publishableKey));\n }, [injectedStripe, publishableKey]);\n\n // Appearance bridge — snapshot + subscribe.\n const [appearance, setAppearance] = useState<Appearance>(() =>\n getStripeAppearance(),\n );\n useEffect(() => {\n setAppearance(getStripeAppearance());\n const unsubscribe = subscribeStripeAppearance(setAppearance);\n return unsubscribe;\n }, []);\n\n // Imperative handle — dispatch a custom event at the inner form so we\n // can trigger the same submit path as the button without leaking refs\n // through the Stripe `<Elements>` provider (which owns its own tree).\n const hostRef = useRef<HTMLDivElement>(null);\n\n const agentHandle = useMemo<PaymentFormHandle>(\n () => ({\n submit: async () => {\n const form = hostRef.current?.querySelector('form');\n if (form) {\n form.dispatchEvent(\n new CustomEvent('payment-form:submit', { bubbles: true }),\n );\n }\n },\n reset: () => {\n const form = hostRef.current?.querySelector('form');\n if (form instanceof HTMLFormElement) {\n form.reset();\n }\n },\n }),\n [],\n );\n useImperativeHandle(ref, () => hostRef.current as HTMLDivElement, []);\n useAgentRegistration(paymentFormAgent, agentHandle, id);\n\n const elementsOptions = useMemo<StripeElementsOptions>(\n () =>\n clientSecret !== undefined\n ? // Immediate mode — the consumer already created the intent.\n { clientSecret, appearance, locale: activeLocale }\n : // Deferred-intent mode — no secret yet; Stripe needs the intent\n // shape (mode + amount + currency) to render the Payment Element.\n // Stripe expects a lowercase ISO-4217 currency here.\n {\n mode,\n amount,\n currency: currency.toLowerCase(),\n appearance,\n locale: activeLocale,\n },\n [clientSecret, mode, amount, currency, appearance, activeLocale],\n );\n\n return (\n <div\n ref={hostRef}\n aria-label={ariaLabel}\n className={[formVariants(), className].filter(Boolean).join(' ')}\n data-component=\"payment-form\"\n data-component-id={id}\n data-testid=\"payment-form-root\"\n >\n {stripeInstance ? (\n // Render the real Payment Element whenever a Stripe instance is\n // available — in immediate mode (clientSecret present) AND in\n // deferred mode (no secret). The skeleton is reserved for the\n // no-Stripe case (missing publishableKey / injected null).\n <Elements\n stripe={stripeInstance}\n options={elementsOptions}\n key={clientSecret ?? 'deferred'}\n >\n <InnerPaymentForm\n amount={amount}\n currency={currency}\n locale={activeLocale}\n billingAddress={billingAddress}\n returnUrl={returnUrl}\n clientSecret={clientSecret}\n onCreatePaymentIntent={onCreatePaymentIntent}\n onSuccess={onSuccess}\n onError={onError}\n />\n </Elements>\n ) : (\n <PaymentFormSkeleton\n amount={amount}\n currency={currency}\n locale={activeLocale}\n billingAddress={billingAddress}\n />\n )}\n </div>\n );\n },\n);\n\nPaymentForm.displayName = 'PaymentForm';\n\n/* ------------------------------------------------------------------ */\n/* Skeleton — visual chrome when Stripe hasn't loaded yet */\n/* ------------------------------------------------------------------ */\n\ninterface PaymentFormSkeletonProps {\n amount: number;\n currency: string;\n locale: string;\n billingAddress: boolean;\n}\n\nfunction PaymentFormSkeleton(props: PaymentFormSkeletonProps): ReactElement {\n const { amount, currency, locale, billingAddress } = props;\n const { t } = useTranslation();\n\n return (\n <div\n className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-md)]\"\n data-testid=\"payment-skeleton\"\n aria-busy=\"true\"\n >\n <div className={amountSummaryVariants()}>\n <span className={labelTextVariants()}>{t('payment.amountLabel')}</span>\n <span className=\"type-title-card\">\n {formatPaymentAmount(amount, currency, locale)}\n </span>\n </div>\n <div className={fieldLabelVariants()}>\n <span className={labelTextVariants()}>{t('payment.fields.card')}</span>\n <div\n className=\"ds:[min-block-size:var(--min-target-size)] ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)] ds:bg-[var(--muted)]\"\n aria-hidden=\"true\"\n />\n </div>\n {billingAddress ? (\n <div className={fieldLabelVariants()} data-testid=\"payment-address\">\n <span className={labelTextVariants()}>\n {t('payment.billingAddress')}\n </span>\n <div\n className=\"ds:[min-block-size:calc(var(--min-target-size)*2)] ds:rounded-[var(--radius-sm)] ds:border ds:border-[color:var(--border)] ds:bg-[var(--muted)]\"\n aria-hidden=\"true\"\n />\n </div>\n ) : null}\n <button\n type=\"button\"\n aria-disabled=\"true\"\n className={submitButtonVariants()}\n disabled\n >\n <Spinner size=\"sm\" label={t('payment.processing')} />\n <span>{t('payment.processing')}</span>\n </button>\n </div>\n );\n}\n\nexport {\n formVariants as paymentFormVariants,\n submitButtonVariants as paymentSubmitButtonVariants,\n};\n"],"names":["isBrowser","getStripeAppearance","root","target","styles","read","token","subscribeStripeAppearance","onChange","emit","observer","schemeMql","motionMql","paymentFormAgent","handle","ZERO_DECIMAL_CURRENCIES","formatPaymentAmount","amount","currency","locale","iso","major","validateReturnUrl","returnUrl","raw","resolved","stripCardLikeDigits","message","stripeErrorCodeToI18nKey","code","formVariants","cva","fieldLabelVariants","labelTextVariants","amountSummaryVariants","submitButtonVariants","InnerPaymentForm","props","billingAddress","clientSecret","onCreatePaymentIntent","onSuccess","onError","t","useTranslation","stripe","useStripe","elements","useElements","rawId","useId","idSafe","useMemo","paymentFieldId","addressFieldId","errorId","processing","setProcessing","useState","elementComplete","setElementComplete","errorKey","setErrorKey","errorMessage","setErrorMessage","onSuccessRef","useRef","onErrorRef","useEffect","handleSubmit","useCallback","event","reportError","rawMessage","key","safe","_a","safeReturnUrl","confirmParams","result","_b","submitError","mintedSecret","_c","err","host","submitter","submitDisabled","jsx","jsxs","PaymentElement","ev","AddressElement","Alert","Fragment","Spinner","STRIPE_LOCALES","normaliseLocale","input","candidate","base","PaymentForm","forwardRef","id","mode","publishableKey","ariaLabel","injectedStripe","className","ref","i18n","activeLocale","stripeInstance","setStripeInstance","loadStripe","appearance","setAppearance","hostRef","agentHandle","form","useImperativeHandle","useAgentRegistration","elementsOptions","Elements","PaymentFormSkeleton"],"mappings":";;;;;;;;;AAiBA,SAASA,KAAqB;AAC5B,SAAO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;AAAA,UAAA;AAAA,QACd,GACF;AAAA,QACClD,IACC,gBAAAmD,EAAC,OAAA,EAAI,WAAWzD,KAAsB,eAAY,mBAChD,UAAA;AAAA,UAAA,gBAAAwD,EAAC,UAAK,WAAWvD,EAAA,GACd,UAAAU,EAAE,wBAAwB,GAC7B;AAAA,UACA,gBAAA6C;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAU;AAAA,cACV,eAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QACd,EAAA,CACF,IACE;AAAA,QACJ,gBAAAC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,iBAAc;AAAA,YACd,WAAWtD,GAAA;AAAA,YACX,UAAQ;AAAA,YAER,UAAA;AAAA,cAAA,gBAAAqD,EAACO,MAAQ,MAAK,MAAK,OAAOpD,EAAE,oBAAoB,GAAG;AAAA,cACnD,gBAAA6C,EAAC,QAAA,EAAM,UAAA7C,EAAE,oBAAoB,EAAA,CAAE;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACjC;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"streaming-text-GH07yIYh.js","sources":["../../src/components/streaming-text/streaming-text.tsx"],"sourcesContent":["import {\n forwardRef,\n Fragment,\n useEffect,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nconst containerVariants = cva(\n 'type-body ds:block ds:whitespace-pre-wrap ds:break-words',\n {\n variants: {\n // Family, weight, tracking, line-height all come from `.type-body` on the base.\n // Size variants override --type-body-size to shift the ramp step.\n size: {\n sm: 'ds:[--type-body-size:var(--font-size-sm)]',\n md: '',\n lg: 'ds:[--type-body-size:var(--font-size-lg)]',\n },\n density: {\n default: '',\n compact: 'ds:[--type-body-size:var(--font-size-sm)] ds:leading-snug',\n },\n },\n defaultVariants: { size: 'md', density: 'default' },\n },\n);\n\ntype NativeProps = Omit<\n HTMLAttributes<HTMLSpanElement>,\n 'children' | 'aria-busy' | 'aria-live'\n>;\n\nexport interface StreamingTextProps\n extends NativeProps, VariantProps<typeof containerVariants> {\n /** Accumulated plain-text content. Parent appends tokens as they arrive. */\n content: string;\n /** While true the blinking cursor is shown and aria-busy is set. */\n isStreaming: boolean;\n /** When true, parse a small, safe subset of markdown (bold, inline code, line-breaks).\n * No HTML passes through; no dangerouslySetInnerHTML is ever used. */\n renderMarkdown?: boolean;\n /** Announce updates more aggressively when the streamed content is primary\n * (not wrapped by a higher-level log region). Defaults to 'polite'; never\n * set to 'assertive' for streamed output. */\n ariaLive?: 'polite' | 'off';\n}\n\n/* ------------------------------------------------------------------ */\n/* Safe, dependency-free markdown-ish renderer. */\n/* Handles **bold**, `inline code`, and newlines. Anything that looks */\n/* like HTML stays as text — no dangerouslySetInnerHTML. */\n/* ------------------------------------------------------------------ */\n\ntype Token =\n | { type: 'text'; value: string }\n | { type: 'bold'; value: string }\n | { type: 'code'; value: string }\n | { type: 'br' };\n\nfunction tokenize(input: string): Token[] {\n // Single-pass O(n) scanner. Avoids regex backtracking on `***` triples.\n const tokens: Token[] = [];\n const len = input.length;\n const STAR = 42; // '*'\n const BACKTICK = 96; // '`'\n const LF = 10; // '\\n'\n let textStart = 0;\n let i = 0;\n\n const flushText = (end: number) => {\n if (end > textStart) {\n tokens.push({ type: 'text', value: input.slice(textStart, end) });\n }\n };\n\n while (i < len) {\n const c = input.charCodeAt(i);\n\n if (c === STAR && i + 1 < len && input.charCodeAt(i + 1) === STAR) {\n // Look for closing `**`; inner content must not contain `*`.\n let j = i + 2;\n while (j < len && input.charCodeAt(j) !== STAR) j++;\n if (j < len - 1 && input.charCodeAt(j + 1) === STAR && j > i + 2) {\n flushText(i);\n tokens.push({ type: 'bold', value: input.slice(i + 2, j) });\n i = j + 2;\n textStart = i;\n continue;\n }\n i += 2;\n continue;\n }\n\n if (c === BACKTICK) {\n let j = i + 1;\n while (j < len && input.charCodeAt(j) !== BACKTICK) j++;\n if (j < len && j > i + 1) {\n flushText(i);\n tokens.push({ type: 'code', value: input.slice(i + 1, j) });\n i = j + 1;\n textStart = i;\n continue;\n }\n i += 1;\n continue;\n }\n\n if (c === LF) {\n flushText(i);\n tokens.push({ type: 'br' });\n i += 1;\n textStart = i;\n continue;\n }\n\n i += 1;\n }\n\n flushText(len);\n return tokens;\n}\n\nfunction renderTokens(input: string): ReactNode {\n return tokenize(input).map((tok, i) => {\n if (tok.type === 'bold') return <strong key={i}>{tok.value}</strong>;\n if (tok.type === 'code') {\n return (\n <code\n key={i}\n dir=\"ltr\"\n className=\"ds:rounded-[var(--radius-sm)] ds:bg-muted/20 ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)] ds:font-[family-name:var(--font-mono)] ds:text-[length:0.95em]\"\n >\n {tok.value}\n </code>\n );\n }\n if (tok.type === 'br') return <br key={i} />;\n return <Fragment key={i}>{tok.value}</Fragment>;\n });\n}\n\nexport const StreamingText = forwardRef<HTMLSpanElement, StreamingTextProps>(\n (\n {\n content,\n isStreaming,\n renderMarkdown = false,\n ariaLive = 'polite',\n size = 'md',\n density = 'default',\n className,\n ...rest\n },\n ref,\n ) => {\n // Throttle visible content to at most ~10 updates per second so assistive\n // tech doesn't receive one announcement per token. We keep the full text in\n // a ref and push it to state on a timer.\n const [visible, setVisible] = useState<string>(content);\n\n useEffect(() => {\n if (!isStreaming) {\n // Streaming ended — flush immediately.\n setVisible(content);\n return;\n }\n // Global `setTimeout` works in both Node and browsers — avoid the\n // `window.` prefix so SSR (Next.js App Router, Remix) doesn't throw.\n const handle = setTimeout(() => setVisible(content), 100);\n return () => clearTimeout(handle);\n }, [content, isStreaming]);\n\n const body = renderMarkdown ? renderTokens(visible) : visible;\n\n return (\n <span\n ref={ref}\n aria-live={ariaLive}\n aria-busy={isStreaming ? true : false}\n data-component=\"streaming-text\"\n className={containerVariants({ size, density, className })}\n {...rest}\n >\n {body}\n {isStreaming ? (\n <span\n aria-hidden=\"true\"\n className={[\n 'ds:inline-block ds:align-baseline',\n 'ds:text-[color:var(--primary)]',\n 'ds:motion-safe:animate-[streaming-cursor-blink_1s_step-end_infinite]',\n 'ds:motion-reduce:opacity-100',\n 'ds:[.theme-accessible_&]:animate-none',\n 'ds:forced-colors:text-[CanvasText]',\n 'ds:ms-[1px]',\n ].join(' ')}\n >\n {'\\u258D'}\n </span>\n ) : null}\n </span>\n );\n },\n);\n\nStreamingText.displayName = 'StreamingText';\n"],"names":["containerVariants","cva","tokenize","input","tokens","len","STAR","BACKTICK","LF","textStart","i","flushText","end","c","j","renderTokens","tok","jsx","Fragment","StreamingText","forwardRef","content","isStreaming","renderMarkdown","ariaLive","size","density","className","rest","ref","visible","setVisible","useState","useEffect","handle","body","jsxs"],"mappings":";;;AAUA,MAAMA,IAAoBC;AAAA,EACxB;AAAA,EACA;AAAA,IACE,UAAU;AAAA;AAAA;AAAA,MAGR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,MAEN,SAAS;AAAA,QACP,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAAA,IACX;AAAA,IAEF,iBAAiB,EAAE,MAAM,MAAM,SAAS,UAAA;AAAA,EAAU;AAEtD;AAkCA,SAASC,EAASC,GAAwB;AAExC,QAAMC,IAAkB,CAAA,GAClBC,IAAMF,EAAM,QACZG,IAAO,IACPC,IAAW,IACXC,IAAK;AACX,MAAIC,IAAY,GACZC,IAAI;AAER,QAAMC,IAAY,CAACC,MAAgB;AACjC,IAAIA,IAAMH,KACRL,EAAO,KAAK,EAAE,MAAM,QAAQ,OAAOD,EAAM,MAAMM,GAAWG,CAAG,GAAG;AAAA,EAEpE;AAEA,SAAOF,IAAIL,KAAK;AACd,UAAMQ,IAAIV,EAAM,WAAWO,CAAC;AAE5B,QAAIG,MAAMP,KAAQI,IAAI,IAAIL,KAAOF,EAAM,WAAWO,IAAI,CAAC,MAAMJ,GAAM;AAEjE,UAAIQ,IAAIJ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A;AAAA,EAGV;AACF;AAEAE,EAAc,cAAc;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-map-BFNpzTiw.js","sources":["../../node_modules/lucide-react/dist/esm/icons/circle-dashed.js","../../node_modules/lucide-react/dist/esm/icons/circle-pause.js","../../node_modules/lucide-react/dist/esm/icons/list-checks.js","../../node_modules/lucide-react/dist/esm/icons/pencil.js","../../node_modules/lucide-react/dist/esm/icons/power-off.js","../../node_modules/lucide-react/dist/esm/icons/power.js","../../node_modules/lucide-react/dist/esm/icons/smartphone.js","../../node_modules/lucide-react/dist/esm/icons/trash-2.js","../../node_modules/lucide-react/dist/esm/icons/user-cog.js","../../src/components/workflow/workflow-card.tsx","../../src/components/workflow/workflow.agent.ts","../../src/components/workflow/workflow-types.ts","../../src/components/workflow/workflow-editor.tsx","../../src/components/workflow/workflow-map.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M10.1 2.182a10 10 0 0 1 3.8 0\", key: \"5ilxe3\" }],\n [\"path\", { d: \"M13.9 21.818a10 10 0 0 1-3.8 0\", key: \"11zvb9\" }],\n [\"path\", { d: \"M17.609 3.721a10 10 0 0 1 2.69 2.7\", key: \"1iw5b2\" }],\n [\"path\", { d: \"M2.182 13.9a10 10 0 0 1 0-3.8\", key: \"c0bmvh\" }],\n [\"path\", { d: \"M20.279 17.609a10 10 0 0 1-2.7 2.69\", key: \"1ruxm7\" }],\n [\"path\", { d: \"M21.818 10.1a10 10 0 0 1 0 3.8\", key: \"qkgqxc\" }],\n [\"path\", { d: \"M3.721 6.391a10 10 0 0 1 2.7-2.69\", key: \"1mcia2\" }],\n [\"path\", { d: \"M6.391 20.279a10 10 0 0 1-2.69-2.7\", key: \"1fvljs\" }]\n];\nconst CircleDashed = createLucideIcon(\"circle-dashed\", __iconNode);\n\nexport { __iconNode, CircleDashed as default };\n//# sourceMappingURL=circle-dashed.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"line\", { x1: \"10\", x2: \"10\", y1: \"15\", y2: \"9\", key: \"c1nkhi\" }],\n [\"line\", { x1: \"14\", x2: \"14\", y1: \"15\", y2: \"9\", key: \"h65svq\" }]\n];\nconst CirclePause = createLucideIcon(\"circle-pause\", __iconNode);\n\nexport { __iconNode, CirclePause as default };\n//# sourceMappingURL=circle-pause.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M13 5h8\", key: \"a7qcls\" }],\n [\"path\", { d: \"M13 12h8\", key: \"h98zly\" }],\n [\"path\", { d: \"M13 19h8\", key: \"c3s6r1\" }],\n [\"path\", { d: \"m3 17 2 2 4-4\", key: \"1jhpwq\" }],\n [\"path\", { d: \"m3 7 2 2 4-4\", key: \"1obspn\" }]\n];\nconst ListChecks = createLucideIcon(\"list-checks\", __iconNode);\n\nexport { __iconNode, ListChecks as default };\n//# sourceMappingURL=list-checks.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\",\n key: \"1a8usu\"\n }\n ],\n [\"path\", { d: \"m15 5 4 4\", key: \"1mk7zo\" }]\n];\nconst Pencil = createLucideIcon(\"pencil\", __iconNode);\n\nexport { __iconNode, Pencil as default };\n//# sourceMappingURL=pencil.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M18.36 6.64A9 9 0 0 1 20.77 15\", key: \"dxknvb\" }],\n [\"path\", { d: \"M6.16 6.16a9 9 0 1 0 12.68 12.68\", key: \"1x7qb5\" }],\n [\"path\", { d: \"M12 2v4\", key: \"3427ic\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }]\n];\nconst PowerOff = createLucideIcon(\"power-off\", __iconNode);\n\nexport { __iconNode, PowerOff as default };\n//# sourceMappingURL=power-off.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M12 2v10\", key: \"mnfbl\" }],\n [\"path\", { d: \"M18.4 6.6a9 9 0 1 1-12.77.04\", key: \"obofu9\" }]\n];\nconst Power = createLucideIcon(\"power\", __iconNode);\n\nexport { __iconNode, Power as default };\n//# sourceMappingURL=power.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"rect\", { width: \"14\", height: \"20\", x: \"5\", y: \"2\", rx: \"2\", ry: \"2\", key: \"1yt0o3\" }],\n [\"path\", { d: \"M12 18h.01\", key: \"mhygvu\" }]\n];\nconst Smartphone = createLucideIcon(\"smartphone\", __iconNode);\n\nexport { __iconNode, Smartphone as default };\n//# sourceMappingURL=smartphone.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M10 11v6\", key: \"nco0om\" }],\n [\"path\", { d: \"M14 11v6\", key: \"outv1u\" }],\n [\"path\", { d: \"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\", key: \"miytrc\" }],\n [\"path\", { d: \"M3 6h18\", key: \"d0wm0j\" }],\n [\"path\", { d: \"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\", key: \"e791ji\" }]\n];\nconst Trash2 = createLucideIcon(\"trash-2\", __iconNode);\n\nexport { __iconNode, Trash2 as default };\n//# sourceMappingURL=trash-2.js.map\n","/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\"path\", { d: \"M10 15H6a4 4 0 0 0-4 4v2\", key: \"1nfge6\" }],\n [\"path\", { d: \"m14.305 16.53.923-.382\", key: \"1itpsq\" }],\n [\"path\", { d: \"m15.228 13.852-.923-.383\", key: \"eplpkm\" }],\n [\"path\", { d: \"m16.852 12.228-.383-.923\", key: \"13v3q0\" }],\n [\"path\", { d: \"m16.852 17.772-.383.924\", key: \"1i8mnm\" }],\n [\"path\", { d: \"m19.148 12.228.383-.923\", key: \"1q8j1v\" }],\n [\"path\", { d: \"m19.53 18.696-.382-.924\", key: \"vk1qj3\" }],\n [\"path\", { d: \"m20.772 13.852.924-.383\", key: \"n880s0\" }],\n [\"path\", { d: \"m20.772 16.148.924.383\", key: \"1g6xey\" }],\n [\"circle\", { cx: \"18\", cy: \"15\", r: \"3\", key: \"gjjjvw\" }],\n [\"circle\", { cx: \"9\", cy: \"7\", r: \"4\", key: \"nufk8\" }]\n];\nconst UserCog = createLucideIcon(\"user-cog\", __iconNode);\n\nexport { __iconNode, UserCog as default };\n//# sourceMappingURL=user-cog.js.map\n","import { forwardRef, type MouseEvent, type ReactNode } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport {\n Circle,\n CircleDashed,\n CirclePause,\n Pencil,\n Power,\n PowerOff,\n Trash2,\n} from 'lucide-react';\nimport { Card } from '../card';\nimport { Badge } from '../badge';\nimport { KeyValuePair } from '../key-value-pair';\nimport { Timestamp } from '../timestamp';\nimport { IconButton } from '../button/icon-button';\nimport type { WorkflowStatus, WorkflowSummary } from './workflow-types';\n\n/* ------------------------------------------------------------------ */\n/* Variants */\n/* ------------------------------------------------------------------ */\n\nconst workflowCardVariants = cva('ds:relative ds:w-full', {\n variants: {\n density: {\n comfortable: '',\n compact: '',\n },\n },\n defaultVariants: {\n density: 'comfortable',\n },\n});\n\n/* ------------------------------------------------------------------ */\n/* Status → badge + icon mapping */\n/* ------------------------------------------------------------------ */\n\ntype BadgeVariant = 'neutral' | 'success' | 'warning';\n\ninterface StatusMeta {\n badgeVariant: BadgeVariant;\n icon: ReactNode;\n}\n\nfunction getStatusMeta(status: WorkflowStatus): StatusMeta {\n switch (status) {\n case 'active':\n // Filled dot for `active` — readable without hue (WCAG 1.4.1).\n return {\n badgeVariant: 'success',\n icon: <Circle className=\"ds:fill-current\" aria-hidden=\"true\" />,\n };\n case 'paused':\n return {\n badgeVariant: 'warning',\n icon: <CirclePause aria-hidden=\"true\" />,\n };\n case 'inactive':\n default:\n return {\n badgeVariant: 'neutral',\n icon: <CircleDashed aria-hidden=\"true\" />,\n };\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Props */\n/* ------------------------------------------------------------------ */\n\nexport interface WorkflowCardProps extends VariantProps<\n typeof workflowCardVariants\n> {\n workflow: WorkflowSummary;\n density?: 'comfortable' | 'compact';\n /** Fires when the card body is clicked. Absent → card is not interactive. */\n onView?: (id: string) => void;\n /** Fires when the edit IconButton is clicked. Absent → no edit button. */\n onEdit?: (id: string) => void;\n /** Fires when the delete IconButton is clicked. Absent → no delete button. */\n onDelete?: (id: string) => void;\n /**\n * Fires when the activate/deactivate IconButton is clicked. The second\n * argument is the TARGET state (the opposite of the current status), so the\n * consumer's handler is idempotent. Absent → no toggle button.\n */\n onToggleActive?: (id: string, active: boolean) => void;\n className?: string;\n}\n\n/* ------------------------------------------------------------------ */\n/* WorkflowCard */\n/* ------------------------------------------------------------------ */\n\nexport const WorkflowCard = forwardRef<HTMLElement, WorkflowCardProps>(\n function WorkflowCard(\n {\n workflow,\n density = 'comfortable',\n onView,\n onEdit,\n onDelete,\n onToggleActive,\n className,\n },\n ref,\n ) {\n const { t } = useTranslation();\n\n const statusMeta = getStatusMeta(workflow.status);\n const isActive = workflow.status === 'active';\n const isCompact = density === 'compact';\n\n // Icon-button clicks must not bubble up to the card body so that\n // `onView` doesn't fire along with edit / delete / toggle.\n const stop =\n (handler: (() => void) | undefined) =>\n (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n handler?.();\n };\n\n const statusBadge = (\n <Badge\n variant={statusMeta.badgeVariant}\n leading={statusMeta.icon}\n withDot={false}\n >\n {t(`workflow.status.${workflow.status}`)}\n </Badge>\n );\n\n const activeCountLabel = t('workflow.card.activeEnrollments');\n\n // When `onView` is provided we can't make the `<article>` itself a\n // role=\"button\" — that would violate both `aria-allowed-role`\n // (article forbids role=button) and `nested-interactive` (the\n // IconButtons in the footer would nest inside an outer button).\n // Instead we expose a single accessible-name-carrying `<button>`\n // on the title, styled to span the whole card via an inset ::after\n // pseudo-element so the hit target stays card-wide.\n return (\n <Card\n ref={ref}\n variant=\"default\"\n className={workflowCardVariants({ density, className })}\n data-component=\"workflow-card\"\n data-component-id={workflow.id}\n >\n <Card.Header>\n <div className=\"ds:flex ds:items-start ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-xs)]\">\n <h3 className=\"ds:m-0 type-title-card ds:text-[color:var(--foreground)] ds:[overflow-wrap:anywhere] ds:break-words\">\n {onView ? (\n <button\n type=\"button\"\n onClick={() => onView(workflow.id)}\n className={[\n 'ds:text-start ds:font-inherit ds:text-inherit',\n // Inset overlay that turns the whole card into a\n // click target without nesting buttons. The\n // IconButton cluster in the footer paints above\n // this pseudo via `position: relative` + z-10.\n 'ds:after:absolute ds:after:inset-0 ds:after:content-[\"\"]',\n 'ds:after:rounded-[var(--radius-lg)]',\n 'ds:focus-visible:outline-none',\n 'ds:focus-visible:after:outline-[length:var(--focus-ring-width)]',\n 'ds:focus-visible:after:outline-solid',\n 'ds:focus-visible:after:outline-[color:var(--ring)]',\n 'ds:focus-visible:after:outline-offset-[length:var(--focus-ring-offset)]',\n ].join(' ')}\n >\n {workflow.name}\n </button>\n ) : (\n workflow.name\n )}\n </h3>\n {isCompact && (\n <span className=\"ds:flex ds:items-baseline ds:gap-[var(--spacing-xs)] type-body-sm ds:text-[color:var(--muted-foreground)]\">\n <span>{activeCountLabel}</span>\n <span className=\"ds:font-medium ds:text-[color:var(--foreground)]\">\n {workflow.stats.activeEnrollments}\n </span>\n </span>\n )}\n </div>\n <div className=\"ds:shrink-0\">{statusBadge}</div>\n </div>\n </Card.Header>\n\n {!isCompact && (\n <Card.Body className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)]\">\n <KeyValuePair\n label={t('workflow.card.activeEnrollments')}\n value={workflow.stats.activeEnrollments}\n />\n <KeyValuePair\n label={t('workflow.card.totalEnrollments')}\n value={workflow.stats.totalEnrollments}\n />\n </Card.Body>\n )}\n\n <Card.Footer className=\"ds:flex-wrap ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:min-w-0 ds:flex-1 ds:flex-col ds:gap-[var(--spacing-xs)] type-body-sm ds:text-[color:var(--muted-foreground)]\">\n <span className=\"ds:truncate\" title={workflow.createdBy}>\n {t('workflow.createdBy', { name: workflow.createdBy })}\n </span>\n {workflow.updatedAt && (\n <Timestamp\n value={workflow.updatedAt}\n format=\"absolute\"\n shape=\"bare\"\n absoluteFormat={{ dateStyle: 'medium' }}\n className=\"ds:truncate\"\n />\n )}\n </div>\n\n <div className=\"ds:relative ds:z-10 ds:flex ds:shrink-0 ds:items-center ds:gap-[var(--spacing-xs)] ds:ms-auto\">\n {onEdit && (\n <IconButton\n icon={<Pencil />}\n size=\"sm\"\n intent=\"ghost\"\n aria-label={t('workflow.card.edit')}\n onClick={stop(() => onEdit(workflow.id))}\n />\n )}\n {onToggleActive && (\n <IconButton\n icon={isActive ? <PowerOff /> : <Power />}\n size=\"sm\"\n intent=\"ghost\"\n aria-label={t(\n isActive\n ? 'workflow.card.deactivate'\n : 'workflow.card.activate',\n )}\n onClick={stop(() => onToggleActive(workflow.id, !isActive))}\n />\n )}\n {onDelete && (\n <IconButton\n icon={<Trash2 />}\n size=\"sm\"\n intent=\"destructive\"\n aria-label={t('workflow.card.delete')}\n onClick={stop(() => onDelete(workflow.id))}\n />\n )}\n </div>\n </Card.Footer>\n </Card>\n );\n },\n);\n\nWorkflowCard.displayName = 'WorkflowCard';\n","/* -------------------------------------------------------------------- */\n/* Agent adapters — Workflow surfaces. */\n/* */\n/* The `workflow/` directory ships three distinct components — each with */\n/* its own `data-component` value (workflow-card, workflow-editor, */\n/* workflow-map). Three adapters are declared here, one per surface, so */\n/* the catalog reflects what's actually rendered in the DOM. The editor */\n/* is the only mutation surface; card and map are presentational and ship */\n/* root hooks only. */\n/* -------------------------------------------------------------------- */\n\nimport type { AgentAdapter } from '../../agent/types';\nimport type { WorkflowEditorHandle } from './workflow-editor';\n\nexport const workflowCardAgent: AgentAdapter = {\n id: 'workflow-card',\n capabilities: ['navigate'],\n state: {},\n actions: {},\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'workflow-card',\n description:\n 'Marks a Workflow summary card. Presentational — actions are owned by the host pattern.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n },\n};\n\nexport const workflowMapAgent: AgentAdapter = {\n id: 'workflow-map',\n capabilities: ['navigate'],\n state: {},\n actions: {},\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'workflow-map',\n description:\n 'Marks a Workflow map (linear visualisation). Presentational.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n item: {\n attr: 'data-node-id',\n description: 'Stable opaque workflow node id emitted on each step.',\n },\n },\n};\n\nexport const workflowEditorAgent: AgentAdapter<WorkflowEditorHandle> = {\n id: 'workflow-editor',\n capabilities: ['navigate', 'expand'],\n state: {\n totalSteps: {\n type: 'number',\n descriptionKey: 'ui.agent.workflowEditor.state.totalSteps',\n description: 'Total number of nodes currently in the workflow graph.',\n read: (handle) => handle.getTotalSteps(),\n },\n currentStep: {\n type: 'string | null',\n descriptionKey: 'ui.agent.workflowEditor.state.currentStep',\n description: 'Opaque node id of the currently-focused step, or null.',\n read: (handle) => handle.getCurrentStep(),\n },\n },\n actions: {\n goto_step: {\n safety: 'read',\n argsType: '{ id: string }',\n descriptionKey: 'ui.agent.workflowEditor.actions.gotoStep',\n description: 'Focus a node by its opaque id.',\n invoke: (handle, args: { id: string }) => {\n handle.gotoStep(args.id);\n },\n },\n },\n domHooks: {\n root: {\n attr: 'data-component',\n value: 'workflow-editor',\n description: 'Marks the WorkflowEditor surface.',\n },\n instanceId: {\n attr: 'data-component-id',\n sourceProp: 'id',\n description: 'Sourced from the id prop.',\n },\n item: {\n attr: 'data-node-id',\n description: 'Stable opaque workflow node id emitted on each node card.',\n },\n },\n};\n","/**\n * Shared types and helpers for the Workflow component suite\n * (WorkflowCard · WorkflowEditor · WorkflowMap).\n *\n * The prop surface is DAG-shaped from day one — { nodes, edges } —\n * even though v1 renders workflows linearly. A linear pipeline is a\n * degenerate DAG where every node has exactly one outgoing edge with\n * a null condition. This means v2 branching (if/else) can ship as an\n * additive change without breaking v1 consumers.\n *\n * Authoritative user story: src/user_stories/domain-specific/workflow.mdx\n */\n\n// ---------------------------------------------------------------\n// Node types\n// ---------------------------------------------------------------\n\nexport type WorkflowActionType =\n | 'add_delay'\n | 'send_email'\n | 'send_sms'\n | 'create_task'\n // v2 types accepted by the type system today; the editor renders a\n // generic card for these until bespoke summariser UI ships.\n | 'send_whatsapp'\n | 'update_patient_field'\n | 'webhook';\n\nexport type WorkflowStatus = 'active' | 'inactive' | 'paused';\n\n// ---------------------------------------------------------------\n// Discriminated settings — `kind` narrows `WorkflowNode['settings']`\n// without the consumer needing a cast.\n// ---------------------------------------------------------------\n\nexport interface DelaySettings {\n kind: 'add_delay';\n days?: number;\n hours?: number;\n minutes?: number;\n}\n\nexport interface EmailSettings {\n kind: 'send_email';\n subject: string;\n body?: string;\n templateId?: string;\n}\n\nexport interface SmsSettings {\n kind: 'send_sms';\n body: string;\n}\n\nexport interface TaskSettings {\n kind: 'create_task';\n title: string;\n description?: string;\n assigneeId?: string;\n}\n\nexport interface WhatsAppSettings {\n kind: 'send_whatsapp';\n templateName: string;\n body?: string;\n}\n\nexport interface UpdateFieldSettings {\n kind: 'update_patient_field';\n /** Custom ObjectField id — NEVER a core patient column. */\n fieldId: string;\n fieldLabel: string;\n value: string;\n}\n\nexport interface WebhookSettings {\n kind: 'webhook';\n url: string;\n method: 'POST' | 'PUT';\n headers?: Record<string, string>;\n}\n\nexport type WorkflowActionSettings =\n | DelaySettings\n | EmailSettings\n | SmsSettings\n | TaskSettings\n | WhatsAppSettings\n | UpdateFieldSettings\n | WebhookSettings;\n\n// ---------------------------------------------------------------\n// Graph shape\n// ---------------------------------------------------------------\n\nexport interface WorkflowNode {\n id: string;\n type: WorkflowActionType;\n settings: WorkflowActionSettings;\n}\n\nexport interface WorkflowEdge {\n from: string;\n to: string;\n /**\n * Edge condition label. Null / omitted for linear pipelines.\n * Reserved for v2 branching: 'true' | 'false' for if_else nodes.\n */\n condition?: string | null;\n}\n\nexport interface WorkflowGraph {\n nodes: WorkflowNode[];\n edges: WorkflowEdge[];\n}\n\n// ---------------------------------------------------------------\n// Summary & stats (WorkflowCard)\n// ---------------------------------------------------------------\n\nexport interface WorkflowStats {\n totalEnrollments: number;\n activeEnrollments: number;\n}\n\nexport interface WorkflowSummary {\n id: string;\n name: string;\n status: WorkflowStatus;\n stats: WorkflowStats;\n actionCount: number;\n createdBy: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface EnrollmentCriteria {\n ruleCount: number;\n summary?: string;\n}\n\n// ---------------------------------------------------------------\n// Pure graph helpers — never mutate their inputs.\n// ---------------------------------------------------------------\n\n/**\n * Walk the linear chain starting from the first node (the one that\n * has no incoming linear edge). Returns nodes in execution order.\n * Throws in dev if the graph has a cycle or a node with multiple\n * linear outgoing edges (reserved for v2 branching).\n */\nexport function linearOrder(graph: WorkflowGraph): WorkflowNode[] {\n if (graph.nodes.length === 0) return [];\n\n const linearEdges = graph.edges.filter((e) => e.condition == null);\n const targets = new Set(linearEdges.map((e) => e.to));\n const roots = graph.nodes.filter((n) => !targets.has(n.id));\n\n // Fall back to the first declared node if the edges don't identify\n // a root (e.g. a brand-new graph with a single node and no edges).\n const start = roots[0] ?? graph.nodes[0];\n const byId = new Map(graph.nodes.map((n) => [n.id, n]));\n const edgesFrom = new Map<string, WorkflowEdge[]>();\n for (const edge of linearEdges) {\n const bucket = edgesFrom.get(edge.from) ?? [];\n bucket.push(edge);\n edgesFrom.set(edge.from, bucket);\n }\n\n const seen = new Set<string>();\n const order: WorkflowNode[] = [];\n let cursor: WorkflowNode | undefined = start;\n while (cursor && !seen.has(cursor.id)) {\n seen.add(cursor.id);\n order.push(cursor);\n const outgoing: WorkflowEdge[] = edgesFrom.get(cursor.id) ?? [];\n if (outgoing.length > 1) {\n // v2 branching surface — v1 renderer should warn but not crash.\n if (typeof console !== 'undefined') {\n console.warn(\n `[workflow] node ${cursor.id} has ${outgoing.length} outgoing linear edges; v1 walks the first only.`,\n );\n }\n }\n cursor = outgoing[0] ? byId.get(outgoing[0].to) : undefined;\n }\n\n // Append any orphan nodes (not reachable from the root) so callers\n // still see them in the UI instead of silently dropping them.\n for (const node of graph.nodes) {\n if (!seen.has(node.id)) order.push(node);\n }\n return order;\n}\n\n/**\n * Insert a new node after `afterNodeId` (or at the head when null).\n * Rewrites edges so the linear chain stays singly-linked.\n */\nexport function addNodeAfter(\n graph: WorkflowGraph,\n afterNodeId: string | null,\n node: WorkflowNode,\n): WorkflowGraph {\n const nodes = [...graph.nodes, node];\n\n if (afterNodeId === null) {\n // Insert at head.\n const oldHead = graph.nodes[0];\n if (!oldHead) {\n return { nodes, edges: [] };\n }\n return {\n nodes,\n edges: [\n { from: node.id, to: oldHead.id, condition: null },\n ...graph.edges,\n ],\n };\n }\n\n const outgoing = graph.edges.find(\n (e) => e.from === afterNodeId && e.condition == null,\n );\n\n if (!outgoing) {\n // Append at tail.\n return {\n nodes,\n edges: [\n ...graph.edges,\n { from: afterNodeId, to: node.id, condition: null },\n ],\n };\n }\n\n // Splice into the middle.\n const otherEdges = graph.edges.filter((e) => e !== outgoing);\n return {\n nodes,\n edges: [\n ...otherEdges,\n { from: afterNodeId, to: node.id, condition: null },\n { from: node.id, to: outgoing.to, condition: null },\n ],\n };\n}\n\n/** Remove a node and reconnect its neighbours so the chain stays intact. */\nexport function removeNode(\n graph: WorkflowGraph,\n nodeId: string,\n): WorkflowGraph {\n const incoming = graph.edges.find(\n (e) => e.to === nodeId && e.condition == null,\n );\n const outgoing = graph.edges.find(\n (e) => e.from === nodeId && e.condition == null,\n );\n\n const kept = graph.edges.filter((e) => e.from !== nodeId && e.to !== nodeId);\n\n const bridged =\n incoming && outgoing\n ? [...kept, { from: incoming.from, to: outgoing.to, condition: null }]\n : kept;\n\n return {\n nodes: graph.nodes.filter((n) => n.id !== nodeId),\n edges: bridged,\n };\n}\n\n/** Swap a node with its neighbour in the linear chain. */\nexport function moveNode(\n graph: WorkflowGraph,\n nodeId: string,\n direction: 'up' | 'down',\n): WorkflowGraph {\n const order = linearOrder(graph);\n const index = order.findIndex((n) => n.id === nodeId);\n if (index === -1) return graph;\n\n const swapIndex = direction === 'up' ? index - 1 : index + 1;\n if (swapIndex < 0 || swapIndex >= order.length) return graph;\n\n const a = order[index];\n const b = order[swapIndex];\n if (!a || !b) return graph;\n\n // Remove both, then re-insert in swapped order via the helpers above.\n // This is O(n) but keeps the invariant maintenance in one place.\n const afterRemove = removeNode(removeNode(graph, a.id), b.id);\n\n const first = direction === 'up' ? a : b;\n const second = direction === 'up' ? b : a;\n\n // Identify the node that now precedes the swap pair (or null for head).\n const firstPredecessor = order[Math.min(index, swapIndex) - 1]?.id ?? null;\n\n const step1 = addNodeAfter(afterRemove, firstPredecessor, first);\n return addNodeAfter(step1, first.id, second);\n}\n\n// ---------------------------------------------------------------\n// Action-type registry — single source of truth for icons + labels.\n// Adding a new action type requires: (a) extending\n// `WorkflowActionType`, (b) adding an entry here, (c) adding i18n\n// keys under `ui.workflow.action.*`. Nothing else.\n// ---------------------------------------------------------------\n\nexport interface WorkflowActionMeta {\n /** i18n key for the type label — full path under `ui.*`. */\n labelKey: string;\n /** lucide-react icon name for dynamic lookup by consumers. */\n iconName:\n | 'Clock'\n | 'Mail'\n | 'Smartphone'\n | 'CheckSquare'\n | 'MessageCircle'\n | 'UserCog'\n | 'Globe';\n}\n\n/**\n * Core patient columns that a workflow MUST NOT overwrite. The\n * `update_patient_field` action is scoped to custom `ObjectField`\n * entries only; passing one of these ids is a misconfiguration and\n * the editor surfaces a warning strip.\n *\n * See `src/user_stories/domain-specific/workflow.mdx` — the\n * maintainability group pins this down with: \"a misconfigured\n * workflow can't overwrite a patient's legal name or contact info\".\n */\nexport const CORE_PATIENT_FIELDS: ReadonlySet<string> = new Set([\n 'dateOfBirth',\n 'date_of_birth',\n 'firstName',\n 'first_name',\n 'lastName',\n 'last_name',\n 'name',\n 'email',\n 'phone',\n 'phoneNumber',\n 'phone_number',\n 'fiscalCode',\n 'fiscal_code',\n 'taxId',\n 'tax_id',\n 'gender',\n 'address',\n 'id',\n]);\n\n/** True when the field id targets a core patient column (never allowed). */\nexport function isCorePatientField(fieldId: string): boolean {\n return CORE_PATIENT_FIELDS.has(fieldId);\n}\n\nexport const workflowActionRegistry: Record<\n WorkflowActionType,\n WorkflowActionMeta\n> = {\n add_delay: {\n labelKey: 'workflow.action.addDelay',\n iconName: 'Clock',\n },\n send_email: {\n labelKey: 'workflow.action.sendEmail',\n iconName: 'Mail',\n },\n send_sms: {\n labelKey: 'workflow.action.sendSms',\n iconName: 'Smartphone',\n },\n create_task: {\n labelKey: 'workflow.action.createTask',\n iconName: 'CheckSquare',\n },\n send_whatsapp: {\n labelKey: 'workflow.action.sendWhatsapp',\n iconName: 'MessageCircle',\n },\n update_patient_field: {\n labelKey: 'workflow.action.updateField',\n iconName: 'UserCog',\n },\n webhook: {\n labelKey: 'workflow.action.webhook',\n iconName: 'Globe',\n },\n};\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type KeyboardEvent as ReactKeyboardEvent,\n type MutableRefObject,\n type ReactNode,\n} from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useAgentRegistration } from '../../agent/registry';\nimport { workflowEditorAgent } from './workflow.agent';\nimport {\n CheckSquare,\n ChevronDown,\n ChevronUp,\n Clock,\n Globe,\n Mail,\n MessageCircle,\n Pencil,\n Plus,\n Smartphone,\n Trash2,\n UserCog,\n type LucideIcon,\n} from 'lucide-react';\nimport { Card } from '../card';\nimport { Alert } from '../alert';\nimport { Button } from '../button';\nimport { IconButton } from '../button/icon-button';\nimport { DropdownMenu } from '../dropdown-menu';\nimport { EmptyState } from '../empty-state';\nimport {\n addNodeAfter,\n isCorePatientField,\n linearOrder,\n moveNode,\n workflowActionRegistry,\n type EnrollmentCriteria,\n type WorkflowActionMeta,\n type WorkflowActionSettings,\n type WorkflowActionType,\n type WorkflowGraph,\n type WorkflowNode,\n} from './workflow-types';\n\n/* ------------------------------------------------------------------ */\n/* Icon map — explicit so the bundler can tree-shake lucide-react */\n/* properly. Driven by `iconName` from the action registry. */\n/* ------------------------------------------------------------------ */\n\nconst ACTION_ICONS: Record<WorkflowActionMeta['iconName'], LucideIcon> = {\n Clock,\n Mail,\n Smartphone,\n CheckSquare,\n MessageCircle,\n UserCog,\n Globe,\n};\n\nfunction ActionIcon({\n iconName,\n className,\n}: {\n iconName: WorkflowActionMeta['iconName'];\n className?: string;\n}) {\n const Glyph = ACTION_ICONS[iconName];\n return <Glyph aria-hidden=\"true\" className={className ?? 'ds:size-4'} />;\n}\n\n/* ------------------------------------------------------------------ */\n/* Settings summary helper — narrows on the discriminated-union */\n/* `kind` so every branch reads its type-specific fields safely. */\n/* ------------------------------------------------------------------ */\n\nconst TRUNCATE_EMAIL = 40;\nconst TRUNCATE_SMS = 60;\n\nfunction truncate(value: string, max: number): string {\n if (value.length <= max) return value;\n return `${value.slice(0, max - 1)}\\u2026`;\n}\n\ninterface SummaryResult {\n /** Displayed (possibly truncated) text. */\n text: string;\n /** Full, un-truncated text for `title` and `aria-label`. */\n full: string;\n}\n\nfunction summariseSettings(\n settings: WorkflowActionSettings,\n t: (key: string, options?: Record<string, unknown>) => string,\n): SummaryResult | null {\n switch (settings.kind) {\n case 'add_delay': {\n const days = settings.days ?? 0;\n const summary = t('workflow.delay.summary', { count: days });\n return { text: summary, full: summary };\n }\n case 'send_email': {\n const subject = settings.subject ?? '';\n const prefix = t('workflow.action.sendEmail');\n const full = `${prefix}: ${subject}`;\n return { text: truncate(full, TRUNCATE_EMAIL), full };\n }\n case 'send_sms': {\n const body = settings.body ?? '';\n return { text: truncate(body, TRUNCATE_SMS), full: body };\n }\n case 'create_task': {\n const title = settings.title ?? '';\n return { text: title, full: title };\n }\n // v2 types — generic fallback (no bespoke summariser yet).\n case 'send_whatsapp':\n case 'update_patient_field':\n case 'webhook':\n default:\n return null;\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Classes (no hardcoded colours / physical props / inline styles) */\n/* ------------------------------------------------------------------ */\n\nconst rootClasses = [\n 'ds:flex ds:flex-col',\n 'ds:w-full',\n 'ds:text-start',\n 'ds:gap-[var(--spacing-sm)]',\n].join(' ');\n\n// Connector line between items. Uses `border-inline-start` so the rule\n// automatically mirrors in RTL without any physical left/right reference.\nconst connectorClasses = [\n 'ds:block',\n 'ds:self-start',\n 'ds:h-[var(--spacing-md)]',\n 'ds:ms-[calc(var(--min-target-size)/2)]',\n 'ds:border-inline-start-[var(--border-width-hairline)]',\n 'ds:border-solid',\n 'ds:border-[color:var(--border)]',\n].join(' ');\n\nconst addButtonClasses = [\n 'ds:inline-flex ds:items-center ds:justify-center ds:gap-[var(--spacing-xs)]',\n 'ds:min-h-[var(--min-target-size)] ds:min-w-[var(--min-target-size)]',\n 'ds:rounded-[var(--radius-full)]',\n 'ds:border ds:border-dashed ds:border-[color:var(--border)]',\n 'ds:bg-[color:var(--background)]',\n 'ds:text-[color:var(--muted-foreground)]',\n 'ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]',\n 'ds:text-[length:var(--font-size-sm)]',\n 'ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none',\n 'ds:hover:bg-[color:var(--muted)]/20 ds:hover:text-[color:var(--foreground)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n 'ds:disabled:opacity-50 ds:disabled:cursor-not-allowed',\n].join(' ');\n\nconst nodeCardFocusableClasses = [\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n 'ds:rounded-[var(--radius-lg)]',\n].join(' ');\n\n/* ------------------------------------------------------------------ */\n/* Props */\n/* ------------------------------------------------------------------ */\n\n/** Curated imperative handle for agent / external automation. */\nexport interface WorkflowEditorHandle {\n getTotalSteps: () => number;\n getCurrentStep: () => string | null;\n gotoStep: (id: string) => void;\n}\n\nexport interface WorkflowEditorProps {\n /** DAG-shaped graph. v1 renders the linear chain via `linearOrder`. */\n graph: WorkflowGraph;\n /**\n * Fires for INTERNAL mutations only — add / reorder. Never fired for\n * edit or delete (those have their own callbacks). When `isActive`\n * is true the editor MUST NOT call this.\n */\n onChange: (graph: WorkflowGraph) => void;\n /** Optional enrollment-criteria summary rendered as a fixed header card. */\n enrollmentCriteria?: EnrollmentCriteria;\n /** Fires when the \"Edit criteria\" CTA in the criteria header is clicked. */\n onEditEnrollmentCriteria?: () => void;\n /** Locks ALL mutation controls and shows the active-lock banner. */\n isActive?: boolean;\n /**\n * Action types available in the add-action DropdownMenu.\n * Defaults to every key in `workflowActionRegistry`.\n */\n availableActions?: WorkflowActionType[];\n /** Fires when a node's edit IconButton is clicked. Consumer owns the form. */\n onEditNode?: (nodeId: string) => void;\n /** Fires when a node's delete IconButton is clicked. Consumer confirms. */\n onDeleteNode?: (nodeId: string) => void;\n className?: string;\n}\n\n/* ------------------------------------------------------------------ */\n/* Defaults */\n/* ------------------------------------------------------------------ */\n\nconst ALL_ACTION_TYPES = Object.keys(\n workflowActionRegistry,\n) as WorkflowActionType[];\n\nlet nodeIdCounter = 0;\nfunction generateNodeId(): string {\n nodeIdCounter += 1;\n const random = Math.random().toString(36).slice(2, 8);\n return `wf-node-${Date.now()}-${nodeIdCounter}-${random}`;\n}\n\nfunction defaultSettingsFor(type: WorkflowActionType): WorkflowActionSettings {\n switch (type) {\n case 'add_delay':\n return { kind: 'add_delay', days: 1 };\n case 'send_email':\n return { kind: 'send_email', subject: '' };\n case 'send_sms':\n return { kind: 'send_sms', body: '' };\n case 'create_task':\n return { kind: 'create_task', title: '' };\n case 'send_whatsapp':\n return { kind: 'send_whatsapp', templateName: '' };\n case 'update_patient_field':\n return {\n kind: 'update_patient_field',\n fieldId: '',\n fieldLabel: '',\n value: '',\n };\n case 'webhook':\n return { kind: 'webhook', url: '', method: 'POST' };\n }\n}\n\n/* ------------------------------------------------------------------ */\n/* Roving-tabindex helper: a `useRef`-backed mutable index without */\n/* re-rendering on every arrow keystroke. */\n/* ------------------------------------------------------------------ */\n\nfunction useMutableIndex(\n initial = 0,\n): [MutableRefObject<number>, (v: number) => void] {\n const ref = useRef(initial);\n const setter = useCallback((v: number) => {\n ref.current = v;\n }, []);\n return [ref, setter];\n}\n\n/* ------------------------------------------------------------------ */\n/* Action-node card */\n/* ------------------------------------------------------------------ */\n\ninterface ActionNodeCardProps {\n node: WorkflowNode;\n position: number;\n total: number;\n disabled: boolean;\n onEdit?: (id: string) => void;\n onDelete?: (id: string) => void;\n onMove: (id: string, direction: 'up' | 'down') => void;\n registerRef: (id: string, el: HTMLDivElement | null) => void;\n}\n\nfunction ActionNodeCard({\n node,\n position,\n total,\n disabled,\n onEdit,\n onDelete,\n onMove,\n registerRef,\n}: ActionNodeCardProps) {\n const { t } = useTranslation();\n const meta = workflowActionRegistry[node.type];\n\n // Roving tabindex: the card itself is tabbable; once focused, arrow\n // keys step through its internal controls.\n const controlsRef = useRef<HTMLDivElement | null>(null);\n const [activeControl, setActiveControl] = useMutableIndex(0);\n\n const focusControl = useCallback(\n (index: number) => {\n const controls = controlsRef.current?.querySelectorAll<HTMLButtonElement>(\n 'button[data-wf-control]:not([disabled])',\n );\n if (!controls || controls.length === 0) return;\n const clamped = Math.max(0, Math.min(index, controls.length - 1));\n controls[clamped]?.focus();\n setActiveControl(clamped);\n },\n [setActiveControl],\n );\n\n const handleCardKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n // Only intercept keystrokes landing on the card wrapper itself.\n if (event.target !== event.currentTarget) return;\n if (event.key === 'ArrowRight' || event.key === 'ArrowDown') {\n event.preventDefault();\n focusControl(0);\n }\n };\n\n const handleControlsKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'ArrowRight') {\n event.preventDefault();\n focusControl(activeControl.current + 1);\n } else if (event.key === 'ArrowLeft') {\n event.preventDefault();\n focusControl(activeControl.current - 1);\n } else if (event.key === 'Home') {\n event.preventDefault();\n focusControl(0);\n } else if (event.key === 'End') {\n event.preventDefault();\n focusControl(Number.POSITIVE_INFINITY);\n }\n };\n\n const summary = summariseSettings(node.settings, t);\n const typeLabel = t(meta.labelKey);\n const canMoveUp = position > 0;\n const canMoveDown = position < total - 1;\n\n const positionText = t('workflow.editor.position', {\n current: position + 1,\n total,\n });\n const nodeAriaLabel = t('workflow.editor.nodeAriaLabel', {\n type: typeLabel,\n current: position + 1,\n total,\n });\n\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- node card is keyboard-actionable via roving tabindex; pipeline keys handled in onKeyDown\n <div\n ref={(el) => registerRef(node.id, el)}\n tabIndex={disabled ? -1 : 0}\n onKeyDown={handleCardKeyDown}\n aria-label={nodeAriaLabel}\n data-node-id={node.id}\n className={nodeCardFocusableClasses}\n >\n <Card variant=\"outlined\">\n <Card.Header className=\"ds:pb-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <span\n aria-hidden=\"true\"\n className=\"ds:inline-flex ds:size-8 ds:shrink-0 ds:items-center ds:justify-center ds:rounded-[var(--radius-sm)] ds:bg-[color:var(--muted)]/20 ds:text-[color:var(--foreground)]\"\n >\n <ActionIcon iconName={meta.iconName} className=\"ds:size-4\" />\n </span>\n <div className=\"ds:flex ds:min-w-0 ds:flex-1 ds:flex-col\">\n <span className=\"ds:text-[length:var(--font-size-sm)] ds:font-[var(--font-weight-semibold)] ds:text-[color:var(--foreground)] ds:[overflow-wrap:anywhere] ds:break-words\">\n {typeLabel}\n </span>\n <span className=\"ds:text-[length:var(--font-size-xs)] ds:text-[color:var(--muted-foreground)]\">\n {positionText}\n </span>\n </div>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions -- inner controls subtree handles arrow-key navigation between edit/delete buttons */}\n <div\n ref={controlsRef}\n onKeyDown={handleControlsKeyDown}\n className=\"ds:flex ds:shrink-0 ds:items-center ds:gap-[var(--spacing-xs)] ds:ms-auto\"\n >\n {onEdit ? (\n <IconButton\n data-wf-control=\"edit\"\n icon={<Pencil />}\n size=\"sm\"\n intent=\"ghost\"\n disabled={disabled}\n tabIndex={-1}\n aria-label={t('workflow.editor.editAction')}\n onClick={() => onEdit(node.id)}\n />\n ) : null}\n <IconButton\n data-wf-control=\"up\"\n icon={<ChevronUp />}\n size=\"sm\"\n intent=\"ghost\"\n disabled={disabled || !canMoveUp}\n tabIndex={-1}\n aria-label={t('workflow.editor.moveUp')}\n onClick={() => onMove(node.id, 'up')}\n />\n <IconButton\n data-wf-control=\"down\"\n icon={<ChevronDown />}\n size=\"sm\"\n intent=\"ghost\"\n disabled={disabled || !canMoveDown}\n tabIndex={-1}\n aria-label={t('workflow.editor.moveDown')}\n onClick={() => onMove(node.id, 'down')}\n />\n {onDelete ? (\n <IconButton\n data-wf-control=\"delete\"\n icon={<Trash2 />}\n size=\"sm\"\n intent=\"destructive\"\n disabled={disabled}\n tabIndex={-1}\n aria-label={t('workflow.editor.deleteAction')}\n onClick={() => onDelete(node.id)}\n />\n ) : null}\n </div>\n </div>\n </Card.Header>\n {summary ? (\n <Card.Body className=\"ds:pt-0\">\n <p\n className=\"ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)] ds:[overflow-wrap:anywhere] ds:break-words\"\n title={summary.full}\n >\n {summary.text}\n </p>\n </Card.Body>\n ) : null}\n {node.settings.kind === 'update_patient_field' &&\n isCorePatientField(node.settings.fieldId) ? (\n <Card.Body className=\"ds:pt-0\">\n <Alert variant=\"error\" data-testid=\"workflow-editor-invalid-field\">\n {t('workflow.editor.invalidField')}\n </Alert>\n </Card.Body>\n ) : null}\n </Card>\n </div>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Add-action trigger + DropdownMenu */\n/* ------------------------------------------------------------------ */\n\ninterface AddActionMenuProps {\n availableActions: WorkflowActionType[];\n onSelect: (type: WorkflowActionType) => void;\n disabled: boolean;\n label: string;\n compact?: boolean;\n}\n\nfunction AddActionMenu({\n availableActions,\n onSelect,\n disabled,\n label,\n compact = true,\n}: AddActionMenuProps) {\n const { t } = useTranslation();\n\n return (\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <button\n type=\"button\"\n disabled={disabled}\n aria-label={label}\n className={addButtonClasses}\n >\n <Plus aria-hidden=\"true\" className=\"ds:size-4\" />\n {compact ? null : (\n <span className=\"ds:text-[length:var(--font-size-sm)]\">\n {label}\n </span>\n )}\n </button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"start\" sideOffset={6}>\n <DropdownMenu.Label>\n {t('workflow.editor.addAction')}\n </DropdownMenu.Label>\n {availableActions.map((type) => {\n const meta = workflowActionRegistry[type];\n return (\n <DropdownMenu.Item\n key={type}\n startIcon={<ActionIcon iconName={meta.iconName} />}\n onSelect={() => onSelect(type)}\n >\n {t(meta.labelKey)}\n </DropdownMenu.Item>\n );\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Criteria header */\n/* ------------------------------------------------------------------ */\n\ninterface CriteriaHeaderProps {\n criteria?: EnrollmentCriteria;\n onEdit?: () => void;\n disabled: boolean;\n}\n\nfunction CriteriaHeader({ criteria, onEdit, disabled }: CriteriaHeaderProps) {\n const { t } = useTranslation();\n const count = criteria?.ruleCount ?? 0;\n const summaryText =\n count > 0\n ? t('workflow.editor.criteriaCount', { count })\n : t('workflow.editor.noCriteria');\n\n return (\n <Card variant=\"outlined\">\n <Card.Header className=\"ds:pb-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n <div className=\"ds:flex ds:min-w-0 ds:flex-1 ds:flex-col\">\n <span className=\"ds:text-[length:var(--font-size-sm)] ds:font-[var(--font-weight-semibold)] ds:text-[color:var(--foreground)]\">\n {t('workflow.editor.enrollmentCriteria')}\n </span>\n <span className=\"ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--muted-foreground)] ds:[overflow-wrap:anywhere] ds:break-words\">\n {criteria?.summary ?? summaryText}\n </span>\n </div>\n {onEdit ? (\n <IconButton\n icon={<Pencil />}\n size=\"sm\"\n intent=\"ghost\"\n disabled={disabled}\n aria-label={t('workflow.editor.editCriteria')}\n onClick={onEdit}\n />\n ) : null}\n </div>\n </Card.Header>\n </Card>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* WorkflowEditor */\n/* ------------------------------------------------------------------ */\n\nexport const WorkflowEditor = forwardRef<HTMLDivElement, WorkflowEditorProps>(\n function WorkflowEditor(\n {\n graph,\n onChange,\n enrollmentCriteria,\n onEditEnrollmentCriteria,\n isActive = false,\n availableActions,\n onEditNode,\n onDeleteNode,\n className,\n },\n ref,\n ) {\n const { t } = useTranslation();\n const types = availableActions ?? ALL_ACTION_TYPES;\n const ordered = useMemo(() => linearOrder(graph), [graph]);\n const nodeRefs = useRef<Map<string, HTMLDivElement | null>>(new Map());\n const focusTargetRef = useRef<string | null>(null);\n\n // Dev-mode guard: `onChange` should never fire while the editor is\n // locked. We wrap the consumer-supplied handler so internal calls\n // cannot violate the contract even if disabled state leaks.\n const safeOnChange = useCallback(\n (next: WorkflowGraph) => {\n if (isActive) {\n if (import.meta.env.DEV) {\n console.warn(\n '[WorkflowEditor] onChange suppressed — editor is active-locked.',\n );\n }\n return;\n }\n onChange(next);\n },\n [isActive, onChange],\n );\n\n const registerRef = useCallback((id: string, el: HTMLDivElement | null) => {\n if (el) {\n nodeRefs.current.set(id, el);\n } else {\n nodeRefs.current.delete(id);\n }\n }, []);\n\n const [currentStep, setCurrentStep] = useState<string | null>(null);\n const currentStepRef = useRef<string | null>(null);\n currentStepRef.current = currentStep;\n\n const rootRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => rootRef.current as HTMLDivElement, []);\n\n const agentHandle = useMemo<WorkflowEditorHandle>(\n () => ({\n getTotalSteps: () => ordered.length,\n getCurrentStep: () => currentStepRef.current,\n gotoStep: (id: string) => {\n const el = nodeRefs.current.get(id);\n if (el) {\n el.focus();\n setCurrentStep(id);\n }\n },\n }),\n [ordered.length],\n );\n useAgentRegistration(workflowEditorAgent, agentHandle, undefined);\n\n // After a mutation, focus returns to the inserted / moved card.\n useEffect(() => {\n const id = focusTargetRef.current;\n if (!id) return;\n const el = nodeRefs.current.get(id);\n if (el) {\n el.focus();\n focusTargetRef.current = null;\n }\n });\n\n const handleAddAfter = (\n afterId: string | null,\n type: WorkflowActionType,\n ) => {\n if (isActive) return;\n const node: WorkflowNode = {\n id: generateNodeId(),\n type,\n settings: defaultSettingsFor(type),\n };\n focusTargetRef.current = node.id;\n safeOnChange(addNodeAfter(graph, afterId, node));\n };\n\n const handleMove = (id: string, direction: 'up' | 'down') => {\n if (isActive) return;\n focusTargetRef.current = id;\n safeOnChange(moveNode(graph, id, direction));\n };\n\n const handleEdit = (id: string) => {\n if (isActive || !onEditNode) return;\n onEditNode(id);\n };\n\n const handleDelete = (id: string) => {\n if (isActive || !onDeleteNode) return;\n onDeleteNode(id);\n };\n\n const renderBanner = (): ReactNode =>\n isActive ? (\n <Alert variant=\"warning\">\n <Alert.Title as=\"p\">{t('workflow.editor.activeLock')}</Alert.Title>\n </Alert>\n ) : null;\n\n const renderCriteria = (): ReactNode =>\n enrollmentCriteria || onEditEnrollmentCriteria ? (\n <>\n <CriteriaHeader\n criteria={enrollmentCriteria}\n onEdit={onEditEnrollmentCriteria}\n disabled={isActive}\n />\n <span aria-hidden=\"true\" className={connectorClasses} />\n </>\n ) : null;\n\n const total = ordered.length;\n\n if (total === 0) {\n return (\n <div\n ref={rootRef}\n className={[rootClasses, className].filter(Boolean).join(' ')}\n >\n {renderBanner()}\n {renderCriteria()}\n <EmptyState\n variant=\"first-use\"\n title={t('workflow.editor.addFirstAction')}\n description={t('workflow.editor.empty')}\n >\n <EmptyState.Illustration>\n <svg\n viewBox=\"0 0 120 120\"\n fill=\"none\"\n aria-hidden=\"true\"\n className=\"ds:w-full ds:h-full\"\n >\n <circle\n cx=\"60\"\n cy=\"60\"\n r=\"50\"\n fill=\"var(--muted)\"\n stroke=\"var(--border)\"\n strokeWidth=\"2\"\n />\n <rect\n x=\"55\"\n y=\"30\"\n width=\"10\"\n height=\"60\"\n rx=\"5\"\n fill=\"var(--primary)\"\n />\n <rect\n x=\"30\"\n y=\"55\"\n width=\"60\"\n height=\"10\"\n rx=\"5\"\n fill=\"var(--primary)\"\n />\n </svg>\n </EmptyState.Illustration>\n <EmptyState.Title>\n {t('workflow.editor.addFirstAction')}\n </EmptyState.Title>\n <EmptyState.Description>\n {t('workflow.editor.empty')}\n </EmptyState.Description>\n <EmptyState.Actions>\n <DropdownMenu.Root>\n <DropdownMenu.Trigger asChild>\n <Button intent=\"primary\" disabled={isActive}>\n <Plus aria-hidden=\"true\" className=\"ds:size-4\" />\n <span>{t('workflow.editor.addFirstAction')}</span>\n </Button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"center\" sideOffset={6}>\n <DropdownMenu.Label>\n {t('workflow.editor.addAction')}\n </DropdownMenu.Label>\n {types.map((type) => {\n const meta = workflowActionRegistry[type];\n return (\n <DropdownMenu.Item\n key={type}\n startIcon={<ActionIcon iconName={meta.iconName} />}\n onSelect={() => handleAddAfter(null, type)}\n >\n {t(meta.labelKey)}\n </DropdownMenu.Item>\n );\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n </EmptyState.Actions>\n </EmptyState>\n </div>\n );\n }\n\n // Non-empty: render the full pipeline.\n //\n // Structure:\n // [banner?]\n // [criteria header? + connector]\n // [leading ⊕]\n // <ol role=\"list\" aria-label=\"Workflow pipeline\">\n // <li> ← native role=\"listitem\"\n // connector + action-card + connector + trailing ⊕ (per-item)\n // </li>\n // …\n // </ol>\n //\n // The interleaved ⊕ buttons live inside each <li> — they are NOT\n // listitems themselves (they're <button>s), so the accessible tree\n // still reports \"list with N items\". The card-focus wrapper carries\n // `role=\"listitem\"` redundantly to keep the wrapper the single\n // focusable interactive surface; native <li> also implies listitem\n // but the browser already dedupes identical roles.\n return (\n <div\n ref={rootRef}\n data-component=\"workflow-editor\"\n className={[rootClasses, className].filter(Boolean).join(' ')}\n >\n {renderBanner()}\n {renderCriteria()}\n\n {/* Leading ⊕ button — OUTSIDE the list. */}\n <div>\n <AddActionMenu\n availableActions={types}\n disabled={isActive}\n label={t('workflow.editor.addAction')}\n onSelect={(type) => handleAddAfter(null, type)}\n />\n </div>\n\n {/* eslint-disable-next-line jsx-a11y/no-redundant-roles -- Safari strips the implicit list role on <ol> with list-style:none; this guard puts it back in the accessibility tree */}\n <ol\n role=\"list\"\n aria-label={t('workflow.editor.pipeline')}\n className=\"ds:list-none ds:m-0 ds:p-0 ds:flex ds:flex-col\"\n >\n {ordered.map((node, index) => (\n <li key={node.id} className=\"ds:list-none ds:flex ds:flex-col\">\n <span aria-hidden=\"true\" className={connectorClasses} />\n <ActionNodeCard\n node={node}\n position={index}\n total={total}\n disabled={isActive}\n onEdit={onEditNode ? handleEdit : undefined}\n onDelete={onDeleteNode ? handleDelete : undefined}\n onMove={handleMove}\n registerRef={registerRef}\n />\n <span aria-hidden=\"true\" className={connectorClasses} />\n <div>\n <AddActionMenu\n availableActions={types}\n disabled={isActive}\n label={t('workflow.editor.addActionAfter')}\n onSelect={(type) => handleAddAfter(node.id, type)}\n />\n </div>\n </li>\n ))}\n </ol>\n </div>\n );\n },\n);\n\nWorkflowEditor.displayName = 'WorkflowEditor';\n","import {\n forwardRef,\n useMemo,\n type ComponentType,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type SVGProps,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport {\n Check,\n CheckSquare,\n Clock,\n Globe,\n ListChecks,\n Mail,\n MessageCircle,\n Smartphone,\n UserCog,\n} from 'lucide-react';\nimport {\n linearOrder,\n workflowActionRegistry,\n type EnrollmentCriteria,\n type WorkflowActionMeta,\n type WorkflowActionSettings,\n type WorkflowGraph,\n type WorkflowNode,\n} from './workflow-types';\n\n/* ------------------------------------------------------------------ */\n/* Icon lookup — typed map over the registry's `iconName` union so we */\n/* get exhaustiveness + tree-shakeable named imports from lucide-react. */\n/* ------------------------------------------------------------------ */\n\ntype LucideIcon = ComponentType<SVGProps<SVGSVGElement>>;\n\nconst iconByName: Record<WorkflowActionMeta['iconName'], LucideIcon> = {\n Clock,\n Mail,\n Smartphone,\n CheckSquare,\n MessageCircle,\n UserCog,\n Globe,\n};\n\n/* ------------------------------------------------------------------ */\n/* CVA variants */\n/* ------------------------------------------------------------------ */\n\nconst rootVariants = cva(\n // The map is a list of steps — never a list of meaningful controls.\n // Layout via logical properties only; connectors are sibling spacers\n // styled with border-inline-start / border-block-end (see node/spacer).\n 'ds:flex ds:list-none ds:p-0 ds:m-0',\n {\n variants: {\n orientation: {\n vertical: 'ds:flex-col ds:items-stretch',\n horizontal: 'ds:flex-row ds:items-stretch ds:flex-wrap',\n },\n compact: {\n true: 'ds:gap-0',\n false: 'ds:gap-0',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n compact: false,\n },\n },\n);\n\n// Each node's <li> stacks the node card and the trailing connector along\n// the root's main axis so the chain reads continuously in either\n// orientation. Vertical root (flex-col) → li is flex-col; horizontal root\n// (flex-row) → li is flex-row.\nconst nodeWrapperVariants = cva('ds:flex', {\n variants: {\n orientation: {\n vertical: 'ds:flex-col ds:items-stretch',\n horizontal: 'ds:flex-row ds:items-center',\n },\n },\n});\n\nconst nodeCardVariants = cva(\n [\n 'ds:relative ds:flex ds:items-center',\n 'ds:gap-[var(--spacing-sm)]',\n 'ds:rounded-[var(--radius-md)]',\n // Flat-hairline: 1px card-border, no shadow; accessible theme bumps to 2px.\n 'ds:border ds:border-[color:var(--card-border)] ds:[.theme-accessible_&]:border-2',\n 'ds:bg-[var(--card)] ds:text-[var(--card-foreground)]',\n // Motion honours the accessible theme (--animation-duration → 0ms).\n 'ds:transition-[box-shadow,transform,opacity] ds:duration-[var(--animation-duration)]',\n 'ds:motion-reduce:transition-none',\n // Content wraps instead of pushing siblings off-screen (DE / CJK story contract).\n 'ds:[word-break:break-word] ds:[overflow-wrap:anywhere]',\n ].join(' '),\n {\n variants: {\n orientation: {\n vertical: 'ds:inline-size-full',\n horizontal: 'ds:block-size-full',\n },\n compact: {\n true: 'ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)] ds:py-[var(--spacing-xs)] ds:min-h-[var(--spacing-xl)]',\n false:\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:py-[var(--spacing-sm)]',\n },\n state: {\n completed: '',\n current:\n 'ds:ring-2 ds:ring-[color:var(--ring)] ds:font-[var(--font-weight-semibold)]',\n // Pending state uses a dashed border + muted foreground so the\n // step reads as \"upcoming\" without dropping text contrast below\n // the 4.5:1 AA floor in dark-accessible. Applying opacity to\n // text that is already on --muted-foreground fails axe on the\n // dark themes (contrast ~3.6:1 after a 50 % dim).\n pending:\n 'ds:border-dashed ds:text-[color:var(--muted-foreground)] ds:[&_[data-testid=workflow-map-summary]]:text-[color:var(--muted-foreground)]',\n neutral: '',\n },\n interactive: {\n true: [\n 'ds:cursor-pointer',\n 'ds:hover:shadow-[var(--shadow-sm)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n ].join(' '),\n false: '',\n },\n },\n },\n);\n\n/**\n * Connector spacer — a bare <span aria-hidden=\"true\"> that draws the\n * line between nodes via logical-property borders. Vertical maps get\n * `border-inline-start`; horizontal maps get `border-block-end`. No\n * physical direction properties, no SVG.\n */\nconst spacerVariants = cva(\n ['ds:block', 'ds:border-solid', 'ds:border-[color:var(--border)]'].join(' '),\n {\n variants: {\n orientation: {\n vertical: [\n // Single edge: `border-s-[length:…]` maps to\n // `border-inline-start-width` in Tailwind v4, so only the\n // inline-start side renders — the other three stay at 0.\n // `ms-[…]` aligns the line under the icon column.\n 'ds:ms-[calc(var(--spacing-md)+var(--spacing-sm))]',\n 'ds:border-s-[length:var(--border-width-hairline)]',\n 'ds:border-inline-start',\n ].join(' '),\n horizontal: [\n 'ds:self-center',\n 'ds:border-b-[length:var(--border-width-hairline)]',\n 'ds:border-block-end',\n ].join(' '),\n },\n compact: {\n true: '',\n false: '',\n },\n },\n compoundVariants: [\n {\n orientation: 'vertical',\n compact: false,\n class: 'ds:h-[var(--spacing-md)]',\n },\n {\n orientation: 'vertical',\n compact: true,\n class: 'ds:h-[var(--spacing-sm)]',\n },\n {\n orientation: 'horizontal',\n compact: false,\n class: 'ds:w-[var(--spacing-md)]',\n },\n {\n orientation: 'horizontal',\n compact: true,\n class: 'ds:w-[var(--spacing-sm)]',\n },\n ],\n },\n);\n\n/* ------------------------------------------------------------------ */\n/* Settings summariser — short, token-aware one-liner per action type. */\n/* The i18n key is resolved by the caller; this returns either a */\n/* {key, options} pair for pluralised strings or a plain string literal. */\n/* ------------------------------------------------------------------ */\n\ninterface SummaryKey {\n key: string;\n options?: Record<string, unknown>;\n}\n\nfunction summariseSettings(\n settings: WorkflowActionSettings,\n): SummaryKey | string | undefined {\n switch (settings.kind) {\n case 'add_delay': {\n if (typeof settings.days === 'number' && settings.days > 0) {\n return {\n key: 'workflow.delay.days',\n options: { count: settings.days },\n };\n }\n if (typeof settings.hours === 'number' && settings.hours > 0) {\n return {\n key: 'workflow.delay.hours',\n options: { count: settings.hours },\n };\n }\n if (typeof settings.minutes === 'number' && settings.minutes > 0) {\n return {\n key: 'workflow.delay.minutes',\n options: { count: settings.minutes },\n };\n }\n return undefined;\n }\n case 'send_email':\n return settings.subject || undefined;\n case 'send_sms':\n return settings.body || undefined;\n case 'create_task':\n return settings.title || undefined;\n case 'send_whatsapp':\n return settings.templateName || undefined;\n case 'update_patient_field':\n return settings.fieldLabel || undefined;\n case 'webhook':\n return settings.url || undefined;\n default:\n return undefined;\n }\n}\n\ntype TFn = (key: string, options?: Record<string, unknown>) => string;\n\nfunction resolveSummary(\n summary: SummaryKey | string | undefined,\n t: TFn,\n): string | undefined {\n if (summary === undefined) return undefined;\n if (typeof summary === 'string') return summary;\n return t(summary.key, summary.options);\n}\n\n/* ------------------------------------------------------------------ */\n/* Props */\n/* ------------------------------------------------------------------ */\n\nexport interface WorkflowMapProps extends VariantProps<typeof rootVariants> {\n /** Instance id surfaced as `data-component-id` on the root. */\n id?: string;\n /** Workflow graph (DAG-shaped, linear in v1). */\n graph: WorkflowGraph;\n /** Id of the currently active step. When unset, the map is structural. */\n activeNodeId?: string;\n /** When provided, nodes become focusable buttons. */\n onNodeClick?: (nodeId: string) => void;\n /** Optional leading criteria summary card — NOT part of the graph. */\n enrollmentCriteria?: EnrollmentCriteria;\n /** Orientation. @default 'vertical' */\n orientation?: 'vertical' | 'horizontal';\n /** Compact mode: smaller padding, hides settings summary text. */\n compact?: boolean;\n className?: string;\n /** Override the auto-generated aria-label on the list root. */\n 'aria-label'?: string;\n}\n\n/* ------------------------------------------------------------------ */\n/* Component */\n/* ------------------------------------------------------------------ */\n\ntype NodeState = 'completed' | 'current' | 'pending' | 'neutral';\n\nexport const WorkflowMap = forwardRef<HTMLOListElement, WorkflowMapProps>(\n function WorkflowMap(\n {\n graph,\n activeNodeId,\n onNodeClick,\n enrollmentCriteria,\n orientation = 'vertical',\n compact = false,\n className,\n 'aria-label': ariaLabelOverride,\n ...rest\n },\n ref,\n ) {\n const { t } = useTranslation();\n\n const ordered = useMemo(() => linearOrder(graph), [graph]);\n const activeIndex = useMemo(\n () =>\n activeNodeId ? ordered.findIndex((n) => n.id === activeNodeId) : -1,\n [ordered, activeNodeId],\n );\n\n const ariaLabel =\n ariaLabelOverride ?? t('workflow.map.label', { count: ordered.length });\n\n const nodeState = (index: number): NodeState => {\n if (activeIndex === -1) return 'neutral';\n if (index === activeIndex) return 'current';\n if (index < activeIndex) return 'completed';\n return 'pending';\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/no-redundant-roles -- Safari strips the implicit list role on <ol> with list-style:none; this guard puts it back in the accessibility tree\n <ol\n ref={ref}\n role=\"list\"\n aria-label={ariaLabel}\n data-component=\"workflow-map\"\n data-component-id={rest.id}\n className={rootVariants({ orientation, compact, className })}\n {...rest}\n >\n {enrollmentCriteria ? (\n <EnrollmentCriteriaHeader\n orientation={orientation}\n compact={compact}\n criteria={enrollmentCriteria}\n />\n ) : null}\n {ordered.map((node, index) => {\n const state = nodeState(index);\n const isLast = index === ordered.length - 1;\n return (\n <MapNode\n key={node.id}\n node={node}\n state={state}\n orientation={orientation}\n compact={compact}\n isLast={isLast}\n onNodeClick={onNodeClick}\n />\n );\n })}\n </ol>\n );\n },\n);\n\nWorkflowMap.displayName = 'WorkflowMap';\n\n/* ------------------------------------------------------------------ */\n/* Internal: MapNode */\n/* ------------------------------------------------------------------ */\n\ninterface MapNodeProps {\n node: WorkflowNode;\n state: NodeState;\n orientation: 'vertical' | 'horizontal';\n compact: boolean;\n isLast: boolean;\n onNodeClick?: (nodeId: string) => void;\n}\n\nfunction MapNode({\n node,\n state,\n orientation,\n compact,\n isLast,\n onNodeClick,\n}: MapNodeProps) {\n const { t } = useTranslation();\n const meta = workflowActionRegistry[node.type];\n const Icon = iconByName[meta.iconName];\n const typeLabel = t(meta.labelKey);\n const summary = resolveSummary(summariseSettings(node.settings), t);\n const isInteractive = typeof onNodeClick === 'function';\n\n const isCurrent = state === 'current';\n const isCompleted = state === 'completed';\n\n const handleClick = (event: ReactMouseEvent<HTMLDivElement>) => {\n if (!isInteractive) return;\n event.preventDefault();\n onNodeClick?.(node.id);\n };\n\n const handleKeyDown = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n if (!isInteractive) return;\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n onNodeClick?.(node.id);\n }\n };\n\n // sr-only state label so greyscale / colour-blind users get\n // an announceable state hint alongside the visual cue.\n const stateLabel = isCurrent\n ? t('workflow.map.current')\n : isCompleted\n ? t('workflow.map.completed')\n : state === 'pending'\n ? t('workflow.map.pending')\n : null;\n\n return (\n // `<li>` has implicit role=\"listitem\"; no explicit role needed.\n <li data-node-id={node.id} className={nodeWrapperVariants({ orientation })}>\n <div\n role={isInteractive ? 'button' : undefined}\n tabIndex={isInteractive ? 0 : undefined}\n aria-current={isCurrent ? 'step' : undefined}\n aria-label={\n isInteractive && compact\n ? summary\n ? t('workflow.map.nodeLabelWithSummary', {\n type: typeLabel,\n summary,\n })\n : t('workflow.map.nodeLabel', { type: typeLabel })\n : undefined\n }\n // Expose the full text on truncation (compact mode) so DE / CJK\n // long compound labels remain discoverable via tooltip.\n title={\n compact && summary\n ? t('workflow.map.nodeLabelWithSummary', {\n type: typeLabel,\n summary,\n })\n : undefined\n }\n onClick={isInteractive ? handleClick : undefined}\n onKeyDown={isInteractive ? handleKeyDown : undefined}\n className={nodeCardVariants({\n orientation,\n compact,\n state,\n interactive: isInteractive,\n })}\n data-node-id={node.id}\n data-state={state}\n >\n <span\n aria-hidden=\"true\"\n className=\"ds:flex ds:items-center ds:justify-center ds:shrink-0 ds:size-[var(--spacing-md)] ds:text-[var(--muted-foreground)]\"\n >\n {isCompleted ? (\n <Check\n className=\"ds:size-[var(--spacing-md)] ds:text-[color:var(--success)]\"\n data-testid=\"workflow-map-check\"\n />\n ) : (\n <Icon className=\"ds:size-[var(--spacing-md)]\" />\n )}\n </span>\n <span className=\"ds:flex ds:flex-col ds:min-w-0 ds:flex-1\">\n <span className={compact ? 'type-meta ds:truncate' : 'type-body-sm'}>\n {typeLabel}\n </span>\n {!compact && summary ? (\n <span\n className=\"type-meta ds:text-[var(--muted-foreground)]\"\n data-testid=\"workflow-map-summary\"\n >\n {summary}\n </span>\n ) : null}\n </span>\n {stateLabel ? <span className=\"ds:sr-only\">{stateLabel}</span> : null}\n </div>\n {!isLast ? (\n <span\n aria-hidden=\"true\"\n className={spacerVariants({ orientation, compact })}\n data-testid=\"workflow-map-connector\"\n />\n ) : null}\n </li>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Internal: Enrollment criteria header */\n/* ------------------------------------------------------------------ */\n\ninterface EnrollmentCriteriaHeaderProps {\n orientation: 'vertical' | 'horizontal';\n compact: boolean;\n criteria: EnrollmentCriteria;\n}\n\nfunction EnrollmentCriteriaHeader({\n orientation,\n compact,\n criteria,\n}: EnrollmentCriteriaHeaderProps) {\n const { t } = useTranslation();\n\n // Not part of the graph; rendered as a leading listitem. The root's\n // aria-label advertises the graph step count (not list-item count) so\n // the SR announcement stays accurate for the pipeline proper.\n return (\n <li className={nodeWrapperVariants({ orientation })}>\n <div\n className={nodeCardVariants({\n orientation,\n compact,\n state: 'neutral',\n interactive: false,\n })}\n data-testid=\"workflow-map-criteria\"\n >\n <span\n aria-hidden=\"true\"\n className=\"ds:flex ds:items-center ds:justify-center ds:shrink-0 ds:size-[var(--spacing-md)] ds:text-[var(--muted-foreground)]\"\n >\n <ListChecks className=\"ds:size-[var(--spacing-md)]\" />\n </span>\n <span className=\"ds:flex ds:flex-col ds:min-w-0 ds:flex-1\">\n <span className={compact ? 'type-meta ds:truncate' : 'type-body-sm'}>\n {t('workflow.editor.enrollmentCriteria')}\n </span>\n {!compact ? (\n <span className=\"type-meta ds:text-[var(--muted-foreground)]\">\n {criteria.summary ??\n t('workflow.editor.criteriaCount', {\n count: criteria.ruleCount,\n })}\n </span>\n ) : null}\n </span>\n </div>\n <span\n aria-hidden=\"true\"\n className={spacerVariants({ orientation, compact })}\n />\n </li>\n );\n}\n"],"names":["__iconNode","CircleDashed","createLucideIcon","CirclePause","ListChecks","Pencil","PowerOff","Power","Smartphone","Trash2","UserCog","workflowCardVariants","cva","getStatusMeta","status","jsx","Circle","WorkflowCard","forwardRef","workflow","density","onView","onEdit","onDelete","onToggleActive","className","ref","t","useTranslation","statusMeta","isActive","isCompact","stop","handler","event","statusBadge","Badge","activeCountLabel","jsxs","Card","KeyValuePair","Timestamp","IconButton","workflowCardAgent","workflowMapAgent","workflowEditorAgent","handle","args","linearOrder","graph","linearEdges","e","targets","start","n","byId","edgesFrom","edge","bucket","seen","order","cursor","outgoing","node","addNodeAfter","afterNodeId","nodes","oldHead","otherEdges","removeNode","nodeId","incoming","kept","bridged","moveNode","direction","index","swapIndex","b","afterRemove","first","second","firstPredecessor","_a","step1","CORE_PATIENT_FIELDS","isCorePatientField","fieldId","workflowActionRegistry","ACTION_ICONS","Clock","Mail","CheckSquare","MessageCircle","Globe","ActionIcon","iconName","Glyph","TRUNCATE_EMAIL","TRUNCATE_SMS","truncate","value","max","summariseSettings","settings","days","summary","subject","full","body","title","rootClasses","connectorClasses","addButtonClasses","nodeCardFocusableClasses","ALL_ACTION_TYPES","nodeIdCounter","generateNodeId","random","defaultSettingsFor","type","useMutableIndex","initial","useRef","setter","useCallback","v","ActionNodeCard","position","total","disabled","onMove","registerRef","meta","controlsRef","activeControl","setActiveControl","focusControl","controls","clamped","_b","handleCardKeyDown","handleControlsKeyDown","typeLabel","canMoveUp","canMoveDown","positionText","nodeAriaLabel","el","ChevronUp","ChevronDown","Alert","AddActionMenu","availableActions","onSelect","label","compact","DropdownMenu","Plus","CriteriaHeader","criteria","count","summaryText","WorkflowEditor","onChange","enrollmentCriteria","onEditEnrollmentCriteria","onEditNode","onDeleteNode","types","ordered","useMemo","nodeRefs","focusTargetRef","safeOnChange","next","id","currentStep","setCurrentStep","useState","currentStepRef","rootRef","useImperativeHandle","agentHandle","useAgentRegistration","useEffect","handleAddAfter","afterId","handleMove","handleEdit","handleDelete","renderBanner","renderCriteria","Fragment","EmptyState","Button","iconByName","rootVariants","nodeWrapperVariants","nodeCardVariants","spacerVariants","resolveSummary","WorkflowMap","activeNodeId","onNodeClick","orientation","ariaLabelOverride","rest","activeIndex","ariaLabel","nodeState","EnrollmentCriteriaHeader","state","isLast","MapNode","Icon","isInteractive","isCurrent","isCompleted","handleClick","handleKeyDown","stateLabel","Check"],"mappings":";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