@lincyaw/aegis-ui 0.11.0 → 0.12.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 (134) hide show
  1. package/dist/agent/ask/AskPanel.cjs +1 -1
  2. package/dist/agent/ask/AskPanel.cjs.map +1 -1
  3. package/dist/agent/ask/AskPanel.js +25 -25
  4. package/dist/agent/ask/AskPanel.js.map +1 -1
  5. package/dist/components/ui/Button.cjs.map +1 -1
  6. package/dist/components/ui/Button.d.ts +4 -2
  7. package/dist/components/ui/Button.js.map +1 -1
  8. package/dist/components/ui/CheckGrid.cjs +1 -1
  9. package/dist/components/ui/CheckGrid.cjs.map +1 -1
  10. package/dist/components/ui/CheckGrid.js +18 -17
  11. package/dist/components/ui/CheckGrid.js.map +1 -1
  12. package/dist/components/ui/CodeEditor.cjs +1 -1
  13. package/dist/components/ui/CodeEditor.cjs.map +1 -1
  14. package/dist/components/ui/CodeEditor.js +95 -87
  15. package/dist/components/ui/CodeEditor.js.map +1 -1
  16. package/dist/components/ui/CommandInvocationCard.cjs +1 -1
  17. package/dist/components/ui/CommandInvocationCard.cjs.map +1 -1
  18. package/dist/components/ui/CommandInvocationCard.js +10 -10
  19. package/dist/components/ui/CommandInvocationCard.js.map +1 -1
  20. package/dist/components/ui/DangerZone.cjs +1 -1
  21. package/dist/components/ui/DangerZone.cjs.map +1 -1
  22. package/dist/components/ui/DangerZone.js +12 -12
  23. package/dist/components/ui/DangerZone.js.map +1 -1
  24. package/dist/components/ui/DataList.cjs +1 -1
  25. package/dist/components/ui/DataList.cjs.map +1 -1
  26. package/dist/components/ui/DataList.js +4 -3
  27. package/dist/components/ui/DataList.js.map +1 -1
  28. package/dist/components/ui/DataTable.cjs +1 -1
  29. package/dist/components/ui/DataTable.cjs.map +1 -1
  30. package/dist/components/ui/DataTable.d.ts +2 -1
  31. package/dist/components/ui/DataTable.js +125 -108
  32. package/dist/components/ui/DataTable.js.map +1 -1
  33. package/dist/components/ui/DiffViewer.cjs +1 -1
  34. package/dist/components/ui/DiffViewer.cjs.map +1 -1
  35. package/dist/components/ui/DiffViewer.js +29 -25
  36. package/dist/components/ui/DiffViewer.js.map +1 -1
  37. package/dist/components/ui/DropdownMenu.cjs.map +1 -1
  38. package/dist/components/ui/DropdownMenu.d.ts +1 -0
  39. package/dist/components/ui/DropdownMenu.js.map +1 -1
  40. package/dist/components/ui/FileDropzone.cjs +1 -1
  41. package/dist/components/ui/FileDropzone.cjs.map +1 -1
  42. package/dist/components/ui/FileDropzone.js +12 -12
  43. package/dist/components/ui/FileDropzone.js.map +1 -1
  44. package/dist/components/ui/FilePreview.cjs +1 -1
  45. package/dist/components/ui/FilePreview.cjs.map +1 -1
  46. package/dist/components/ui/FilePreview.js +16 -13
  47. package/dist/components/ui/FilePreview.js.map +1 -1
  48. package/dist/components/ui/ParetoChart.cjs +1 -1
  49. package/dist/components/ui/ParetoChart.cjs.map +1 -1
  50. package/dist/components/ui/ParetoChart.js +247 -212
  51. package/dist/components/ui/ParetoChart.js.map +1 -1
  52. package/dist/components/ui/QueryAutocomplete.cjs +1 -1
  53. package/dist/components/ui/QueryAutocomplete.cjs.map +1 -1
  54. package/dist/components/ui/QueryAutocomplete.d.ts +4 -1
  55. package/dist/components/ui/QueryAutocomplete.js +136 -123
  56. package/dist/components/ui/QueryAutocomplete.js.map +1 -1
  57. package/dist/components/ui/RankBar.cjs +1 -1
  58. package/dist/components/ui/RankBar.cjs.map +1 -1
  59. package/dist/components/ui/RankBar.js +9 -9
  60. package/dist/components/ui/RankBar.js.map +1 -1
  61. package/dist/components/ui/ReplayStepStrip.cjs +1 -1
  62. package/dist/components/ui/ReplayStepStrip.cjs.map +1 -1
  63. package/dist/components/ui/ReplayStepStrip.d.ts +6 -3
  64. package/dist/components/ui/ReplayStepStrip.js +71 -61
  65. package/dist/components/ui/ReplayStepStrip.js.map +1 -1
  66. package/dist/components/ui/ServiceMap.cjs +1 -1
  67. package/dist/components/ui/ServiceMap.cjs.map +1 -1
  68. package/dist/components/ui/ServiceMap.d.ts +9 -1
  69. package/dist/components/ui/ServiceMap.js +333 -268
  70. package/dist/components/ui/ServiceMap.js.map +1 -1
  71. package/dist/components/ui/SparkLine.cjs +1 -1
  72. package/dist/components/ui/SparkLine.cjs.map +1 -1
  73. package/dist/components/ui/SparkLine.d.ts +5 -2
  74. package/dist/components/ui/SparkLine.js +33 -29
  75. package/dist/components/ui/SparkLine.js.map +1 -1
  76. package/dist/components/ui/TableOfContents.cjs +1 -1
  77. package/dist/components/ui/TableOfContents.cjs.map +1 -1
  78. package/dist/components/ui/TableOfContents.js +16 -19
  79. package/dist/components/ui/TableOfContents.js.map +1 -1
  80. package/dist/components/ui/Tabs.cjs +2 -2
  81. package/dist/components/ui/Tabs.cjs.map +1 -1
  82. package/dist/components/ui/Tabs.js +107 -87
  83. package/dist/components/ui/Tabs.js.map +1 -1
  84. package/dist/components/ui/TimeRangePicker.cjs +1 -1
  85. package/dist/components/ui/TimeRangePicker.cjs.map +1 -1
  86. package/dist/components/ui/TimeRangePicker.d.ts +12 -1
  87. package/dist/components/ui/TimeRangePicker.js +69 -63
  88. package/dist/components/ui/TimeRangePicker.js.map +1 -1
  89. package/dist/components/ui/Timeline.cjs.map +1 -1
  90. package/dist/components/ui/Timeline.d.ts +4 -4
  91. package/dist/components/ui/Timeline.js.map +1 -1
  92. package/dist/components/ui/TimelineChart.cjs +2 -2
  93. package/dist/components/ui/TimelineChart.cjs.map +1 -1
  94. package/dist/components/ui/TimelineChart.d.ts +1 -0
  95. package/dist/components/ui/TimelineChart.js +131 -137
  96. package/dist/components/ui/TimelineChart.js.map +1 -1
  97. package/dist/components/ui/TraceTree.cjs +1 -1
  98. package/dist/components/ui/TraceTree.cjs.map +1 -1
  99. package/dist/components/ui/TraceTree.d.ts +4 -0
  100. package/dist/components/ui/TraceTree.js +88 -87
  101. package/dist/components/ui/TraceTree.js.map +1 -1
  102. package/dist/components/ui/TrajectoryStep.cjs +2 -1
  103. package/dist/components/ui/TrajectoryStep.cjs.map +1 -1
  104. package/dist/components/ui/TrajectoryStep.js +64 -43
  105. package/dist/components/ui/TrajectoryStep.js.map +1 -1
  106. package/dist/components/ui/useColumnWidths.cjs +1 -1
  107. package/dist/components/ui/useColumnWidths.cjs.map +1 -1
  108. package/dist/components/ui/useColumnWidths.d.ts +6 -1
  109. package/dist/components/ui/useColumnWidths.js +139 -123
  110. package/dist/components/ui/useColumnWidths.js.map +1 -1
  111. package/dist/layouts/shell/AegisShell.cjs +1 -1
  112. package/dist/layouts/shell/AegisShell.cjs.map +1 -1
  113. package/dist/layouts/shell/AegisShell.js +33 -34
  114. package/dist/layouts/shell/AegisShell.js.map +1 -1
  115. package/dist/lib/breakAtSeparators.cjs +2 -0
  116. package/dist/lib/breakAtSeparators.cjs.map +1 -0
  117. package/dist/lib/breakAtSeparators.d.ts +6 -0
  118. package/dist/lib/breakAtSeparators.js +10 -0
  119. package/dist/lib/breakAtSeparators.js.map +1 -0
  120. package/dist/locale/strings.cjs +1 -1
  121. package/dist/locale/strings.cjs.map +1 -1
  122. package/dist/locale/strings.d.ts +6 -0
  123. package/dist/locale/strings.js +27 -19
  124. package/dist/locale/strings.js.map +1 -1
  125. package/dist/style.css +1 -1
  126. package/dist/theme/antdTheme.cjs +1 -1
  127. package/dist/theme/antdTheme.cjs.map +1 -1
  128. package/dist/theme/antdTheme.js +50 -29
  129. package/dist/theme/antdTheme.js.map +1 -1
  130. package/dist/transports/agentm/AgentmChannelProvider.cjs +1 -1
  131. package/dist/transports/agentm/AgentmChannelProvider.cjs.map +1 -1
  132. package/dist/transports/agentm/AgentmChannelProvider.js +66 -61
  133. package/dist/transports/agentm/AgentmChannelProvider.js.map +1 -1
  134. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"RankBar.js","sources":["../../../src/components/ui/RankBar.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\n\nimport {\n type ChartColor,\n chartColorValue,\n stageProgress,\n staggeredProgress,\n zeroAnchoredDomain,\n} from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './RankBar.css';\n\nexport interface RankBarItem {\n key: string;\n label: ReactNode;\n /**\n * `null` is a missing value: an em dash over an empty track, distinct\n * from a real 0, which keeps a visible endpoint.\n */\n value: number | null;\n /** The value's confidence interval, drawn as a line over the bar. */\n interval?: [number, number];\n /** Trailing slot for a per-row link, e.g. \"逐题表现\". */\n action?: ReactNode;\n /**\n * The bar's colour, e.g. the series colour of the model's vendor.\n * Defaults to `--rank-bar-fill`.\n */\n color?: ChartColor;\n}\n\ninterface RankBarProps {\n items: RankBarItem[];\n /**\n * Upper bound of the scale. Defaults to the largest value or interval\n * end, or 1 when all are 0; pass `1` for a share or a 0–1 score.\n */\n max?: number;\n /** Scale hint rendered at the bottom, e.g. \"越高越好\". */\n direction?: ReactNode;\n format?: (value: number) => string;\n /** `sm` is a thin bar, for rows that lead with their label. Defaults to `md`. */\n size?: 'md' | 'sm';\n /** Makes each row's label and bar track select that row. */\n onSelect?: (key: string) => void;\n /**\n * How far the bars are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, the bars draw in\n * once when they mount.\n */\n progress?: number;\n className?: string;\n}\n\nexport function RankBar({\n items,\n max,\n direction,\n format = (value) => value.toFixed(2),\n size = 'md',\n onSelect,\n progress,\n className,\n}: RankBarProps) {\n const strings = useStrings();\n const values = items.flatMap((item) => [\n ...(item.value === null ? [] : [item.value]),\n ...(item.interval ?? []),\n ]);\n const [, upperBound] = zeroAnchoredDomain(values, max);\n const cls = [\n 'aegis-rank-bar',\n size === 'sm' ? 'aegis-rank-bar--sm' : '',\n progress === undefined ? '' : 'aegis-rank-bar--scroll',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div className={cls}>\n {items.map((item, index) => {\n const { value, interval } = item;\n const share = (part: number): string =>\n `${(upperBound > 0 ? (part / upperBound) * 100 : 0).toString()}%`;\n const drawn =\n progress === undefined\n ? 1\n : staggeredProgress(progress, index, items.length);\n const intervalMark = interval && (\n <span\n className=\"aegis-rank-bar__interval\"\n style={{\n left: share(interval[0]),\n width: share(interval[1] - interval[0]),\n opacity: `calc(var(--chart-interval-opacity) * ${stageProgress(drawn, 0.8, 1).toString()})`,\n }}\n />\n );\n const fill =\n value === null ? null : (\n <div\n className={[\n 'aegis-rank-bar__fill',\n value === 0 ? 'aegis-rank-bar__fill--zero' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={\n {\n width: share(value),\n '--aegis-rank-bar-index': index,\n ...(item.color === undefined || value === 0\n ? {}\n : { background: chartColorValue(item.color) }),\n ...(progress === undefined\n ? {}\n : {\n '--aegis-rank-bar-progress': stageProgress(\n drawn,\n 0,\n interval ? 0.8 : 1,\n ),\n }),\n } as CSSProperties\n }\n >\n <span className=\"aegis-rank-bar__ink\" />\n </div>\n );\n return (\n <div className=\"aegis-rank-bar__row\" key={item.key}>\n {onSelect ? (\n <button\n type=\"button\"\n className=\"aegis-rank-bar__label aegis-rank-bar__label--link\"\n onClick={() => {\n onSelect(item.key);\n }}\n >\n {item.label}\n </button>\n ) : (\n <span className=\"aegis-rank-bar__label\">{item.label}</span>\n )}\n {onSelect ? (\n // The label button is the keyboard and screen-reader target;\n // the track only widens the pointer target.\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className=\"aegis-rank-bar__track aegis-rank-bar__track--link\"\n onClick={() => {\n onSelect(item.key);\n }}\n >\n {fill}\n {intervalMark}\n </button>\n ) : (\n <div\n className=\"aegis-rank-bar__track\"\n role=\"img\"\n aria-label={\n value === null\n ? strings.noValue\n : `${strings.barValue(format(value), format(upperBound))}${\n interval\n ? ` (${format(interval[0])}–${format(interval[1])})`\n : ''\n }`\n }\n >\n {fill}\n {intervalMark}\n </div>\n )}\n <span\n className={\n value === null\n ? 'aegis-rank-bar__value aegis-rank-bar__value--empty'\n : 'aegis-rank-bar__value'\n }\n >\n {value === null ? '—' : format(value)}\n </span>\n <span className=\"aegis-rank-bar__action\">{item.action}</span>\n </div>\n );\n })}\n <div className=\"aegis-rank-bar__scale\">\n <span className=\"aegis-rank-bar__spacer\" />\n <div className=\"aegis-rank-bar__ticks\">\n <span>0</span>\n {direction !== undefined && (\n <span className=\"aegis-rank-bar__direction\">{direction}</span>\n )}\n <span>{format(upperBound)}</span>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["RankBar","items","max","direction","format","value","size","onSelect","progress","className","strings","useStrings","values","item","upperBound","zeroAnchoredDomain","cls","jsxs","index","interval","share","part","drawn","staggeredProgress","intervalMark","jsx","stageProgress","fill","chartColorValue"],"mappings":";;;;AAsDO,SAASA,EAAQ;AAAA,EACtB,OAAAC;AAAA,EACA,KAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC,IAAS,CAACC,MAAUA,EAAM,QAAQ,CAAC;AAAA,EACnC,MAAAC,IAAO;AAAA,EACP,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,GAAiB;AACf,QAAMC,IAAUC,EAAA,GACVC,IAASX,EAAM,QAAQ,CAACY,MAAS;AAAA,IACrC,GAAIA,EAAK,UAAU,OAAO,CAAA,IAAK,CAACA,EAAK,KAAK;AAAA,IAC1C,GAAIA,EAAK,YAAY,CAAA;AAAA,EAAC,CACvB,GACK,CAAA,EAAGC,CAAU,IAAIC,EAAmBH,GAAQV,CAAG,GAC/Cc,IAAM;AAAA,IACV;AAAA,IACAV,MAAS,OAAO,uBAAuB;AAAA,IACvCE,MAAa,SAAY,KAAK;AAAA,IAC9BC,KAAa;AAAA,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG;AACX,SACE,gBAAAQ,EAAC,OAAA,EAAI,WAAWD,GACb,UAAA;AAAA,IAAAf,EAAM,IAAI,CAACY,GAAMK,MAAU;AAC1B,YAAM,EAAE,OAAAb,GAAO,UAAAc,EAAA,IAAaN,GACtBO,IAAQ,CAACC,MACb,IAAIP,IAAa,IAAKO,IAAOP,IAAc,MAAM,GAA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UACb,gBAAAsB,EAAC,QAAA,EAAK,WAAU,6BAA6B,UAAAtB,GAAU;AAAA,QAEzD,gBAAAsB,EAAC,QAAA,EAAM,UAAArB,EAAOU,CAAU,EAAA,CAAE;AAAA,MAAA,EAAA,CAC5B;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"RankBar.js","sources":["../../../src/components/ui/RankBar.tsx"],"sourcesContent":["import { type CSSProperties, type ReactNode } from 'react';\n\nimport {\n type ChartColor,\n chartColorValue,\n stageProgress,\n staggeredProgress,\n zeroAnchoredDomain,\n} from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './RankBar.css';\n\nexport interface RankBarItem {\n key: string;\n label: ReactNode;\n /**\n * `null` is a missing value: an em dash over an empty track, distinct\n * from a real 0, which keeps a visible endpoint.\n */\n value: number | null;\n /** The value's confidence interval, drawn as a line over the bar. */\n interval?: [number, number];\n /** Trailing slot for a per-row link, e.g. \"逐题表现\". */\n action?: ReactNode;\n /**\n * The bar's colour, e.g. the series colour of the model's vendor.\n * Defaults to `--rank-bar-fill`.\n */\n color?: ChartColor;\n}\n\ninterface RankBarProps {\n items: RankBarItem[];\n /**\n * Upper bound of the scale. Defaults to the largest value or interval\n * end, or 1 when all are 0; pass `1` for a share or a 0–1 score.\n */\n max?: number;\n /** Scale hint rendered at the bottom, e.g. \"越高越好\". */\n direction?: ReactNode;\n format?: (value: number) => string;\n /** `sm` is a thin bar, for rows that lead with their label. Defaults to `md`. */\n size?: 'md' | 'sm';\n /** Makes each row's label and bar track select that row. */\n onSelect?: (key: string) => void;\n /**\n * How far the bars are drawn, 0 to 1, for a chart that draws as its\n * section scrolls in (`useScrollProgress`). Omitted, the bars draw in\n * once when they mount.\n */\n progress?: number;\n className?: string;\n}\n\nexport function RankBar({\n items,\n max,\n direction,\n format = (value) => value.toFixed(2),\n size = 'md',\n onSelect,\n progress,\n className,\n}: RankBarProps) {\n const strings = useStrings();\n const values = items.flatMap((item) => [\n ...(item.value === null ? [] : [item.value]),\n ...(item.interval ?? []),\n ]);\n const [, upperBound] = zeroAnchoredDomain(values, max);\n const cls = [\n 'aegis-rank-bar',\n size === 'sm' ? 'aegis-rank-bar--sm' : '',\n progress === undefined ? '' : 'aegis-rank-bar--scroll',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div className={cls}>\n {items.map((item, index) => {\n const { value, interval } = item;\n const share = (part: number): string =>\n `${(upperBound > 0 ? (part / upperBound) * 100 : 0).toString()}%`;\n const drawn =\n progress === undefined\n ? 1\n : staggeredProgress(progress, index, items.length);\n const intervalMark = interval && (\n <span\n className=\"aegis-rank-bar__interval\"\n style={{\n left: share(interval[0]),\n width: share(interval[1] - interval[0]),\n opacity: stageProgress(drawn, 0.8, 1),\n }}\n />\n );\n const fill =\n value === null ? null : (\n <div\n className={[\n 'aegis-rank-bar__fill',\n value === 0 ? 'aegis-rank-bar__fill--zero' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={\n {\n width: share(value),\n '--aegis-rank-bar-index': index,\n ...(item.color === undefined || value === 0\n ? {}\n : { background: chartColorValue(item.color) }),\n ...(progress === undefined\n ? {}\n : {\n '--aegis-rank-bar-progress': stageProgress(\n drawn,\n 0,\n interval ? 0.8 : 1,\n ),\n }),\n } as CSSProperties\n }\n >\n <span className=\"aegis-rank-bar__ink\" />\n </div>\n );\n return (\n <div className=\"aegis-rank-bar__row\" key={item.key}>\n {onSelect ? (\n <button\n type=\"button\"\n className=\"aegis-rank-bar__label aegis-rank-bar__label--link\"\n onClick={() => {\n onSelect(item.key);\n }}\n >\n {item.label}\n </button>\n ) : (\n <span className=\"aegis-rank-bar__label\">{item.label}</span>\n )}\n {onSelect ? (\n // The label button is the keyboard and screen-reader target;\n // the track only widens the pointer target.\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden=\"true\"\n className=\"aegis-rank-bar__track aegis-rank-bar__track--link\"\n onClick={() => {\n onSelect(item.key);\n }}\n >\n {fill}\n {intervalMark}\n </button>\n ) : (\n <div\n className=\"aegis-rank-bar__track\"\n role=\"img\"\n aria-label={\n value === null\n ? strings.noValue\n : `${strings.barValue(format(value), format(upperBound))}${\n interval\n ? ` (${format(interval[0])}–${format(interval[1])})`\n : ''\n }`\n }\n >\n {fill}\n {intervalMark}\n </div>\n )}\n <span\n className={\n value === null\n ? 'aegis-rank-bar__value aegis-rank-bar__value--empty'\n : 'aegis-rank-bar__value'\n }\n >\n {value === null ? '—' : format(value)}\n </span>\n <span className=\"aegis-rank-bar__action\">{item.action}</span>\n </div>\n );\n })}\n <div className=\"aegis-rank-bar__scale\">\n <span className=\"aegis-rank-bar__spacer\" />\n <div className=\"aegis-rank-bar__ticks\">\n <span>0</span>\n {direction !== undefined && (\n <span className=\"aegis-rank-bar__direction\">{direction}</span>\n )}\n <span>{format(upperBound)}</span>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["RankBar","items","max","direction","format","value","size","onSelect","progress","className","strings","useStrings","values","item","upperBound","zeroAnchoredDomain","cls","jsxs","index","interval","share","part","drawn","staggeredProgress","intervalMark","jsx","stageProgress","fill","chartColorValue"],"mappings":";;;;AAsDO,SAASA,EAAQ;AAAA,EACtB,OAAAC;AAAA,EACA,KAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC,IAAS,CAACC,MAAUA,EAAM,QAAQ,CAAC;AAAA,EACnC,MAAAC,IAAO;AAAA,EACP,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AACF,GAAiB;AACf,QAAMC,IAAUC,EAAA,GACVC,IAASX,EAAM,QAAQ,CAACY,MAAS;AAAA,IACrC,GAAIA,EAAK,UAAU,OAAO,CAAA,IAAK,CAACA,EAAK,KAAK;AAAA,IAC1C,GAAIA,EAAK,YAAY,CAAA;AAAA,EAAC,CACvB,GACK,CAAA,EAAGC,CAAU,IAAIC,EAAmBH,GAAQV,CAAG,GAC/Cc,IAAM;AAAA,IACV;AAAA,IACAV,MAAS,OAAO,uBAAuB;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MAAA,EAAA,GAxDdZ,EAAK,GAyD/C;AAAA,IAEJ,CAAC;AAAA,IACD,gBAAAI,EAAC,OAAA,EAAI,WAAU,yBACb,UAAA;AAAA,MAAA,gBAAAQ,EAAC,QAAA,EAAK,WAAU,yBAAA,CAAyB;AAAA,MACzC,gBAAAR,EAAC,OAAA,EAAI,WAAU,yBACb,UAAA;AAAA,QAAA,gBAAAQ,EAAC,UAAK,UAAA,IAAA,CAAC;AAAA,QACNtB,MAAc,UACb,gBAAAsB,EAAC,QAAA,EAAK,WAAU,6BAA6B,UAAAtB,GAAU;AAAA,QAEzD,gBAAAsB,EAAC,QAAA,EAAM,UAAArB,EAAOU,CAAU,EAAA,CAAE;AAAA,MAAA,EAAA,CAC5B;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),j=require("react"),q=require("../../lib/chart.cjs");;/* empty css */const R=require("../../locale/useStrings.cjs");function $(p,r){const i=p-1,o=new Set(p>0?[0,i]:[]);for(let n=r-1;n<i;n+=r)i-n>=r/2&&o.add(n);return o}function A({steps:p,currentIndex:r,onSelect:i,keyMoments:o=[],formatStep:n=g=>`#${String(g+1)}`,tickEvery:k,size:y="md",playhead:c,className:S}){const g=R.useStrings(),h=j.useRef(null),a=p.length,v=k??Math.max(1,Math.ceil(a/20)*5),N=$(a,v),_=new Map(o.map((s,e)=>[s,e+1])),[w,d]=j.useState(0),u=Math.min(r??w,Math.max(a-1,0)),M=s=>{if(!i||a===0)return;const e={ArrowLeft:u-1,ArrowRight:u+1,Home:0,End:a-1};if(!(s.key in e))return;s.preventDefault();const l=Math.min(Math.max(e[s.key],0),a-1);d(l),i(l),h.current?.querySelectorAll(".aegis-replay-step-strip__step").item(l).focus()},x={"--aegis-replay-step-strip-count":Math.max(a,1),...c===void 0?{}:{"--aegis-replay-step-strip-head":c,"--aegis-replay-step-strip-head-step":c*a}};return t.jsxs("div",{className:["aegis-replay-step-strip",`aegis-replay-step-strip--${y}`,c===void 0?"":"aegis-replay-step-strip--playhead",S??""].filter(Boolean).join(" "),style:x,children:[o.length>0&&t.jsx("div",{className:"aegis-replay-step-strip__moments","aria-hidden":"true",children:p.map((s,e)=>{const l=_.get(e);return l===void 0?t.jsx("span",{},s.key):t.jsx("span",{className:["aegis-replay-step-strip__moment",e===r?"aegis-replay-step-strip__moment--current":""].filter(Boolean).join(" "),children:l},s.key)})}),t.jsxs("div",{ref:h,className:"aegis-replay-step-strip__bars",role:i?"toolbar":"list","aria-label":g.replaySteps,onKeyDown:M,children:[p.map((s,e)=>{const l=_.get(e),m=l===void 0?s.label:`${s.label} · ${g.replayKeyMoment(l)}`,f={"--aegis-replay-step-strip-color":q.chartColorValue(s.color),"--aegis-replay-step-strip-index":e,...s.weight===void 0?{}:{height:`${(s.weight*100).toString()}%`}},b=["aegis-replay-step-strip__step",s.emphasis?"aegis-replay-step-strip__step--emphasis":"",e===r?"aegis-replay-step-strip__step--current":""].filter(Boolean).join(" ");return i?t.jsx("button",{type:"button",className:b,style:f,title:m,"aria-label":m,"aria-current":e===r?"step":void 0,tabIndex:e===u?0:-1,onClick:()=>{d(e),i(e)}},s.key):t.jsx("span",{role:"listitem",className:b,style:f,title:m,"aria-label":m,"aria-current":e===r?"step":void 0},s.key)}),c!==void 0&&t.jsx("span",{className:"aegis-replay-step-strip__head-track","aria-hidden":"true",children:t.jsx("span",{className:"aegis-replay-step-strip__head"})})]}),y==="md"&&t.jsx("div",{className:"aegis-replay-step-strip__ticks","aria-hidden":"true",children:p.map((s,e)=>t.jsx("span",{className:e===a-1&&a>1?"aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last":"aegis-replay-step-strip__tick",children:N.has(e)?n(e):null},s.key))})]})}exports.ReplayStepStrip=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),m=require("react"),$=require("../../lib/chart.cjs");;/* empty css */const x=require("../../locale/useStrings.cjs");function C(o,a){const l=o-1,c=new Set(o>0?[0,l]:[]);for(let n=a-1;n<l;n+=a)l-n>=a/2&&c.add(n);return c}function A({steps:o,currentIndex:a,onSelect:l,keyMoments:c=[],formatStep:n=u=>`#${String(u+1)}`,tickEvery:w,size:d="md",playhead:g,className:N}){const u=x.useStrings(),_=m.useRef(null),y=m.useRef(null),r=o.length,S=w??Math.max(1,Math.ceil(r/20)*5),R=C(r,S),b=new Map(c.map((e,t)=>[e,t+1])),[M,j]=m.useState(0),h=Math.min(a??M,Math.max(r-1,0)),f=l!==void 0;m.useEffect(()=>{const e=_.current,t=a===void 0?null:y.current?.children.item(a);if(!f||!e||!t)return;const s=e.getBoundingClientRect(),p=t.getBoundingClientRect();(p.left<s.left||p.right>s.right)&&(e.scrollLeft+=p.left+p.width/2-(s.left+s.width/2))},[f,a,r]);const q=e=>{if(!l||r===0)return;const t={ArrowLeft:h-1,ArrowRight:h+1,Home:0,End:r-1};if(!(e.key in t))return;e.preventDefault();const s=Math.min(Math.max(t[e.key],0),r-1);j(s),l(s),y.current?.querySelectorAll(".aegis-replay-step-strip__step").item(s).focus()},B={"--aegis-replay-step-strip-count":Math.max(r,1),...g===void 0?{}:{"--aegis-replay-step-strip-head":g,"--aegis-replay-step-strip-head-step":g*r}};return i.jsxs("div",{ref:_,className:["aegis-replay-step-strip",`aegis-replay-step-strip--${d}`,f?"aegis-replay-step-strip--selectable":"",g===void 0?"":"aegis-replay-step-strip--playhead",N??""].filter(Boolean).join(" "),style:B,children:[c.length>0&&i.jsx("div",{className:"aegis-replay-step-strip__moments","aria-hidden":"true",children:o.map((e,t)=>{const s=b.get(t);return s===void 0?i.jsx("span",{},e.key):i.jsx("span",{className:["aegis-replay-step-strip__moment",t===a?"aegis-replay-step-strip__moment--current":""].filter(Boolean).join(" "),children:s},e.key)})}),i.jsxs("div",{ref:y,className:"aegis-replay-step-strip__bars",role:l?"toolbar":"list","aria-label":u.replaySteps,onKeyDown:q,children:[o.map((e,t)=>{const s=b.get(t),p=s===void 0?e.label:`${e.label} · ${u.replayKeyMoment(s)}`,k={"--aegis-replay-step-strip-color":$.chartColorValue(e.color),"--aegis-replay-step-strip-index":t,...e.weight===void 0?{}:{height:`${(e.weight*100).toString()}%`}},v=["aegis-replay-step-strip__step",e.emphasis?"aegis-replay-step-strip__step--emphasis":"",t===a?"aegis-replay-step-strip__step--current":""].filter(Boolean).join(" ");return l?i.jsx("button",{type:"button",className:v,style:k,title:p,"aria-label":p,"aria-current":t===a?"step":void 0,tabIndex:t===h?0:-1,onClick:()=>{j(t),l(t)}},e.key):i.jsx("span",{role:"listitem",className:v,style:k,title:p,"aria-label":p,"aria-current":t===a?"step":void 0},e.key)}),g!==void 0&&i.jsx("span",{className:"aegis-replay-step-strip__head-track","aria-hidden":"true",children:i.jsx("span",{className:"aegis-replay-step-strip__head"})})]}),d==="md"&&i.jsx("div",{className:"aegis-replay-step-strip__ticks","aria-hidden":"true",children:o.map((e,t)=>i.jsx("span",{className:t===r-1&&r>1?"aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last":"aegis-replay-step-strip__tick",children:R.has(t)?n(t):null},e.key))})]})}exports.ReplayStepStrip=A;
2
2
  //# sourceMappingURL=ReplayStepStrip.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReplayStepStrip.cjs","sources":["../../../src/components/ui/ReplayStepStrip.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n useRef,\n useState,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayStepStrip.css';\n\nexport interface ReplayStepStripItem {\n key: string;\n /** The step kind's colour, e.g. thinking, tool call, failure. */\n color: ChartColor;\n /** Names the step for screen readers and its tooltip, e.g. \"#12 · 验证\". */\n label: string;\n /** A step that changes the course (a check, a failure, the goal): taller. */\n emphasis?: boolean;\n /**\n * The bar's height as a share of the strip, 0 to 1, for a host that\n * grades its kinds more finely than `emphasis`; it wins over `emphasis`.\n */\n weight?: number;\n}\n\nexport interface ReplayStepStripProps {\n steps: ReplayStepStripItem[];\n /** The step shown elsewhere on the page; outlined. */\n currentIndex?: number;\n /** Makes each step a button that selects it. */\n onSelect?: (index: number) => void;\n /** Step indices of the key moments, numbered above the strip in order. */\n keyMoments?: number[];\n /** The tick label of a step under the strip. Defaults to `#n`. */\n formatStep?: (index: number) => ReactNode;\n /** A tick every this many steps; defaults to about five ticks. */\n tickEvery?: number;\n /** `sm` is a shorter strip without ticks, for a card or a list row. Defaults to `md`. */\n size?: 'md' | 'sm';\n /**\n * Draws a playhead this share of the way along the strip, 0 to 1, and\n * dims the steps past it, e.g. for a strip that plays as the page scrolls.\n */\n playhead?: number;\n className?: string;\n}\n\n/**\n * The steps that get a tick: the first, the last, and every `every`\n * steps between, leaving out one that would crowd the last.\n */\nfunction tickedSteps(count: number, every: number): Set<number> {\n const last = count - 1;\n const ticks = new Set<number>(count > 0 ? [0, last] : []);\n for (let index = every - 1; index < last; index += every) {\n if (last - index >= every / 2) {\n ticks.add(index);\n }\n }\n return ticks;\n}\n\n/**\n * Every step of a run as a bar coloured by its kind, with the key\n * moments numbered above it and step ticks below. With `onSelect`, a bar\n * selects its step; arrow keys move between steps with one tab stop.\n * The gap between bars narrows as steps are added, so a long run still\n * draws every step.\n */\nexport function ReplayStepStrip({\n steps,\n currentIndex,\n onSelect,\n keyMoments = [],\n formatStep = (index) => `#${String(index + 1)}`,\n tickEvery,\n size = 'md',\n playhead,\n className,\n}: ReplayStepStripProps): ReactElement {\n const strings = useStrings();\n const barsRef = useRef<HTMLDivElement>(null);\n const count = steps.length;\n const every = tickEvery ?? Math.max(1, Math.ceil(count / 20) * 5);\n const ticks = tickedSteps(count, every);\n const momentNumber = new Map(keyMoments.map((step, n) => [step, n + 1]));\n\n // The roving tab stop follows the current step, or the last step the\n // keyboard reached when the host does not mark one.\n const [ownFocus, setOwnFocus] = useState(0);\n const focusIndex = Math.min(currentIndex ?? ownFocus, Math.max(count - 1, 0));\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (!onSelect || count === 0) {\n return;\n }\n const target: Record<string, number> = {\n ArrowLeft: focusIndex - 1,\n ArrowRight: focusIndex + 1,\n Home: 0,\n End: count - 1,\n };\n if (!(event.key in target)) {\n return;\n }\n event.preventDefault();\n const next = Math.min(Math.max(target[event.key], 0), count - 1);\n setOwnFocus(next);\n onSelect(next);\n barsRef.current\n ?.querySelectorAll<HTMLButtonElement>('.aegis-replay-step-strip__step')\n .item(next)\n .focus();\n };\n\n const style = {\n '--aegis-replay-step-strip-count': Math.max(count, 1),\n ...(playhead === undefined\n ? {}\n : {\n '--aegis-replay-step-strip-head': playhead,\n '--aegis-replay-step-strip-head-step': playhead * count,\n }),\n } as CSSProperties;\n return (\n <div\n className={[\n 'aegis-replay-step-strip',\n `aegis-replay-step-strip--${size}`,\n playhead === undefined ? '' : 'aegis-replay-step-strip--playhead',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {keyMoments.length > 0 && (\n <div className=\"aegis-replay-step-strip__moments\" aria-hidden=\"true\">\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n return n === undefined ? (\n <span key={step.key} />\n ) : (\n <span\n key={step.key}\n className={[\n 'aegis-replay-step-strip__moment',\n index === currentIndex\n ? 'aegis-replay-step-strip__moment--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {n}\n </span>\n );\n })}\n </div>\n )}\n <div\n ref={barsRef}\n className=\"aegis-replay-step-strip__bars\"\n role={onSelect ? 'toolbar' : 'list'}\n aria-label={strings.replaySteps}\n onKeyDown={onKeyDown}\n >\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n const label =\n n === undefined\n ? step.label\n : `${step.label} · ${strings.replayKeyMoment(n)}`;\n const barStyle = {\n '--aegis-replay-step-strip-color': chartColorValue(step.color),\n '--aegis-replay-step-strip-index': index,\n ...(step.weight === undefined\n ? {}\n : { height: `${(step.weight * 100).toString()}%` }),\n } as CSSProperties;\n const cls = [\n 'aegis-replay-step-strip__step',\n step.emphasis ? 'aegis-replay-step-strip__step--emphasis' : '',\n index === currentIndex\n ? 'aegis-replay-step-strip__step--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n return onSelect ? (\n <button\n key={step.key}\n type=\"button\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n tabIndex={index === focusIndex ? 0 : -1}\n onClick={() => {\n setOwnFocus(index);\n onSelect(index);\n }}\n />\n ) : (\n <span\n key={step.key}\n role=\"listitem\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n />\n );\n })}\n {playhead !== undefined && (\n <span\n className=\"aegis-replay-step-strip__head-track\"\n aria-hidden=\"true\"\n >\n <span className=\"aegis-replay-step-strip__head\" />\n </span>\n )}\n </div>\n {size === 'md' && (\n <div className=\"aegis-replay-step-strip__ticks\" aria-hidden=\"true\">\n {steps.map((step, index) => (\n <span\n key={step.key}\n className={\n index === count - 1 && count > 1\n ? 'aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last'\n : 'aegis-replay-step-strip__tick'\n }\n >\n {ticks.has(index) ? formatStep(index) : null}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["tickedSteps","count","every","last","ticks","index","ReplayStepStrip","steps","currentIndex","onSelect","keyMoments","formatStep","tickEvery","size","playhead","className","strings","useStrings","barsRef","useRef","momentNumber","step","n","ownFocus","setOwnFocus","useState","focusIndex","onKeyDown","event","target","next","style","jsxs","jsx","label","barStyle","chartColorValue","cls"],"mappings":"6PAsDA,SAASA,EAAYC,EAAeC,EAA4B,CAC9D,MAAMC,EAAOF,EAAQ,EACfG,EAAQ,IAAI,IAAYH,EAAQ,EAAI,CAAC,EAAGE,CAAI,EAAI,EAAE,EACxD,QAASE,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,OAAO,OAAO,EACd,KAAK,GAAG,EACX,OAAOC,EACLwB,EAAAA,IAAC,SAAA,CAEC,KAAK,SACL,UAAWI,EACX,MAAOF,EACP,MAAOD,EACP,aAAYA,EACZ,eAAc7B,IAAUG,EAAe,OAAS,OAChD,SAAUH,IAAUqB,EAAa,EAAI,GACrC,QAAS,IAAM,CACbF,EAAYnB,CAAK,EACjBI,EAASJ,CAAK,CAChB,CAAA,EAXKgB,EAAK,GAAA,EAcZY,EAAAA,IAAC,OAAA,CAEC,KAAK,WACL,UAAWI,EACX,MAAOF,EACP,MAAOD,EACP,aAAYA,EACZ,eAAc7B,IAAUG,EAAe,OAAS,MAAA,EAN3Ca,EAAK,GAAA,CAShB,CAAC,EACAP,IAAa,QACZmB,EAAAA,IAAC,OAAA,CACC,UAAU,sCACV,cAAY,OAEZ,SAAAA,EAAAA,IAAC,OAAA,CAAK,UAAU,+BAAA,CAAgC,CAAA,CAAA,CAClD,CAAA,CAAA,EAGHpB,IAAS,MACRoB,EAAAA,IAAC,MAAA,CAAI,UAAU,iCAAiC,cAAY,OACzD,SAAA1B,EAAM,IAAI,CAACc,EAAMhB,IAChB4B,EAAAA,IAAC,OAAA,CAEC,UACE5B,IAAUJ,EAAQ,GAAKA,EAAQ,EAC3B,oEACA,gCAGL,WAAM,IAAII,CAAK,EAAIM,EAAWN,CAAK,EAAI,IAAA,EAPnCgB,EAAK,GAAA,CASb,CAAA,CACH,CAAA,CAAA,CAAA,CAIR"}
1
+ {"version":3,"file":"ReplayStepStrip.cjs","sources":["../../../src/components/ui/ReplayStepStrip.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayStepStrip.css';\n\nexport interface ReplayStepStripItem {\n key: string;\n /** The step kind's colour, e.g. thinking, tool call, failure. */\n color: ChartColor;\n /** Names the step for screen readers and its tooltip, e.g. \"#12 · 验证\". */\n label: string;\n /** A step that changes the course (a check, a failure, the goal): taller. */\n emphasis?: boolean;\n /**\n * The bar's height as a share of the strip, 0 to 1, for a host that\n * grades its kinds more finely than `emphasis`; it wins over `emphasis`.\n */\n weight?: number;\n}\n\nexport interface ReplayStepStripProps {\n steps: ReplayStepStripItem[];\n /** The step shown elsewhere on the page; outlined. */\n currentIndex?: number;\n /**\n * Makes each step a button that selects it. Each step then stays wide\n * enough to tap, and a run too long for the width scrolls sideways.\n */\n onSelect?: (index: number) => void;\n /** Step indices of the key moments, numbered above the strip in order. */\n keyMoments?: number[];\n /** The tick label of a step under the strip. Defaults to `#n`. */\n formatStep?: (index: number) => ReactNode;\n /** A tick every this many steps; defaults to about five ticks. */\n tickEvery?: number;\n /** `sm` is a shorter strip without ticks, for a card or a list row. Defaults to `md`. */\n size?: 'md' | 'sm';\n /**\n * Draws a playhead this share of the way along the strip, 0 to 1, and\n * dims the steps past it, e.g. for a strip that plays as the page scrolls.\n */\n playhead?: number;\n className?: string;\n}\n\n/**\n * The steps that get a tick: the first, the last, and every `every`\n * steps between, leaving out one that would crowd the last.\n */\nfunction tickedSteps(count: number, every: number): Set<number> {\n const last = count - 1;\n const ticks = new Set<number>(count > 0 ? [0, last] : []);\n for (let index = every - 1; index < last; index += every) {\n if (last - index >= every / 2) {\n ticks.add(index);\n }\n }\n return ticks;\n}\n\n/**\n * Every step of a run as a bar coloured by its kind, with the key\n * moments numbered above it and step ticks below. With `onSelect`, a bar\n * selects its step; arrow keys move between steps with one tab stop.\n * Without `onSelect`, the gap between bars narrows as steps are added, so a\n * long run still draws every step in the width.\n */\nexport function ReplayStepStrip({\n steps,\n currentIndex,\n onSelect,\n keyMoments = [],\n formatStep = (index) => `#${String(index + 1)}`,\n tickEvery,\n size = 'md',\n playhead,\n className,\n}: ReplayStepStripProps): ReactElement {\n const strings = useStrings();\n const rootRef = useRef<HTMLDivElement>(null);\n const barsRef = useRef<HTMLDivElement>(null);\n const count = steps.length;\n const every = tickEvery ?? Math.max(1, Math.ceil(count / 20) * 5);\n const ticks = tickedSteps(count, every);\n const momentNumber = new Map(keyMoments.map((step, n) => [step, n + 1]));\n\n // The roving tab stop follows the current step, or the last step the\n // keyboard reached when the host does not mark one.\n const [ownFocus, setOwnFocus] = useState(0);\n const focusIndex = Math.min(currentIndex ?? ownFocus, Math.max(count - 1, 0));\n\n // A selectable strip may scroll; bring a current step the host moved out\n // of view back to the middle, without scrolling the page.\n const selectable = onSelect !== undefined;\n useEffect(() => {\n const root = rootRef.current;\n const bar =\n currentIndex === undefined\n ? null\n : barsRef.current?.children.item(currentIndex);\n if (!selectable || !root || !bar) {\n return;\n }\n const view = root.getBoundingClientRect();\n const step = bar.getBoundingClientRect();\n if (step.left < view.left || step.right > view.right) {\n root.scrollLeft +=\n step.left + step.width / 2 - (view.left + view.width / 2);\n }\n }, [selectable, currentIndex, count]);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (!onSelect || count === 0) {\n return;\n }\n const target: Record<string, number> = {\n ArrowLeft: focusIndex - 1,\n ArrowRight: focusIndex + 1,\n Home: 0,\n End: count - 1,\n };\n if (!(event.key in target)) {\n return;\n }\n event.preventDefault();\n const next = Math.min(Math.max(target[event.key], 0), count - 1);\n setOwnFocus(next);\n onSelect(next);\n barsRef.current\n ?.querySelectorAll<HTMLButtonElement>('.aegis-replay-step-strip__step')\n .item(next)\n .focus();\n };\n\n const style = {\n '--aegis-replay-step-strip-count': Math.max(count, 1),\n ...(playhead === undefined\n ? {}\n : {\n '--aegis-replay-step-strip-head': playhead,\n '--aegis-replay-step-strip-head-step': playhead * count,\n }),\n } as CSSProperties;\n return (\n <div\n ref={rootRef}\n className={[\n 'aegis-replay-step-strip',\n `aegis-replay-step-strip--${size}`,\n selectable ? 'aegis-replay-step-strip--selectable' : '',\n playhead === undefined ? '' : 'aegis-replay-step-strip--playhead',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {keyMoments.length > 0 && (\n <div className=\"aegis-replay-step-strip__moments\" aria-hidden=\"true\">\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n return n === undefined ? (\n <span key={step.key} />\n ) : (\n <span\n key={step.key}\n className={[\n 'aegis-replay-step-strip__moment',\n index === currentIndex\n ? 'aegis-replay-step-strip__moment--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {n}\n </span>\n );\n })}\n </div>\n )}\n <div\n ref={barsRef}\n className=\"aegis-replay-step-strip__bars\"\n role={onSelect ? 'toolbar' : 'list'}\n aria-label={strings.replaySteps}\n onKeyDown={onKeyDown}\n >\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n const label =\n n === undefined\n ? step.label\n : `${step.label} · ${strings.replayKeyMoment(n)}`;\n const barStyle = {\n '--aegis-replay-step-strip-color': chartColorValue(step.color),\n '--aegis-replay-step-strip-index': index,\n ...(step.weight === undefined\n ? {}\n : { height: `${(step.weight * 100).toString()}%` }),\n } as CSSProperties;\n const cls = [\n 'aegis-replay-step-strip__step',\n step.emphasis ? 'aegis-replay-step-strip__step--emphasis' : '',\n index === currentIndex\n ? 'aegis-replay-step-strip__step--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n return onSelect ? (\n <button\n key={step.key}\n type=\"button\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n tabIndex={index === focusIndex ? 0 : -1}\n onClick={() => {\n setOwnFocus(index);\n onSelect(index);\n }}\n />\n ) : (\n <span\n key={step.key}\n role=\"listitem\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n />\n );\n })}\n {playhead !== undefined && (\n <span\n className=\"aegis-replay-step-strip__head-track\"\n aria-hidden=\"true\"\n >\n <span className=\"aegis-replay-step-strip__head\" />\n </span>\n )}\n </div>\n {size === 'md' && (\n <div className=\"aegis-replay-step-strip__ticks\" aria-hidden=\"true\">\n {steps.map((step, index) => (\n <span\n key={step.key}\n className={\n index === count - 1 && count > 1\n ? 'aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last'\n : 'aegis-replay-step-strip__tick'\n }\n >\n {ticks.has(index) ? formatStep(index) : null}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["tickedSteps","count","every","last","ticks","index","ReplayStepStrip","steps","currentIndex","onSelect","keyMoments","formatStep","tickEvery","size","playhead","className","strings","useStrings","rootRef","useRef","barsRef","momentNumber","step","n","ownFocus","setOwnFocus","useState","focusIndex","selectable","useEffect","root","bar","view","onKeyDown","event","target","next","style","jsxs","jsx","label","barStyle","chartColorValue","cls"],"mappings":"6PA0DA,SAASA,EAAYC,EAAeC,EAA4B,CAC9D,MAAMC,EAAOF,EAAQ,EACfG,EAAQ,IAAI,IAAYH,EAAQ,EAAI,CAAC,EAAGE,CAAI,EAAI,EAAE,EACxD,QAASE,EAAQH,EAAQ,EAAGG,EAAQF,EAAME,GAASH,EAC7CC,EAAOE,GAASH,EAAQ,GAC1BE,EAAM,IAAIC,CAAK,EAGnB,OAAOD,CACT,CASO,SAASE,EAAgB,CAC9B,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,WAAAC,EAAa,CAAA,EACb,WAAAC,EAAcN,GAAU,IAAI,OAAOA,EAAQ,CAAC,CAAC,GAC7C,UAAAO,EACA,KAAAC,EAAO,KACP,SAAAC,EACA,UAAAC,CACF,EAAuC,CACrC,MAAMC,EAAUC,EAAAA,WAAA,EACVC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAUD,EAAAA,OAAuB,IAAI,EACrClB,EAAQM,EAAM,OACdL,EAAQU,GAAa,KAAK,IAAI,EAAG,KAAK,KAAKX,EAAQ,EAAE,EAAI,CAAC,EAC1DG,EAAQJ,EAAYC,EAAOC,CAAK,EAChCmB,EAAe,IAAI,IAAIX,EAAW,IAAI,CAACY,EAAMC,IAAM,CAACD,EAAMC,EAAI,CAAC,C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P,aAAYA,EACZ,eAAcnC,IAAUG,EAAe,OAAS,OAChD,SAAUH,IAAUsB,EAAa,EAAI,GACrC,QAAS,IAAM,CACbF,EAAYpB,CAAK,EACjBI,EAASJ,CAAK,CAChB,CAAA,EAXKiB,EAAK,GAAA,EAcZiB,EAAAA,IAAC,OAAA,CAEC,KAAK,WACL,UAAWI,EACX,MAAOF,EACP,MAAOD,EACP,aAAYA,EACZ,eAAcnC,IAAUG,EAAe,OAAS,MAAA,EAN3Cc,EAAK,GAAA,CAShB,CAAC,EACAR,IAAa,QACZyB,EAAAA,IAAC,OAAA,CACC,UAAU,sCACV,cAAY,OAEZ,SAAAA,EAAAA,IAAC,OAAA,CAAK,UAAU,+BAAA,CAAgC,CAAA,CAAA,CAClD,CAAA,CAAA,EAGH1B,IAAS,MACR0B,EAAAA,IAAC,MAAA,CAAI,UAAU,iCAAiC,cAAY,OACzD,SAAAhC,EAAM,IAAI,CAACe,EAAMjB,IAChBkC,EAAAA,IAAC,OAAA,CAEC,UACElC,IAAUJ,EAAQ,GAAKA,EAAQ,EAC3B,oEACA,gCAGL,WAAM,IAAII,CAAK,EAAIM,EAAWN,CAAK,EAAI,IAAA,EAPnCiB,EAAK,GAAA,CASb,CAAA,CACH,CAAA,CAAA,CAAA,CAIR"}
@@ -18,7 +18,10 @@ export interface ReplayStepStripProps {
18
18
  steps: ReplayStepStripItem[];
19
19
  /** The step shown elsewhere on the page; outlined. */
20
20
  currentIndex?: number;
21
- /** Makes each step a button that selects it. */
21
+ /**
22
+ * Makes each step a button that selects it. Each step then stays wide
23
+ * enough to tap, and a run too long for the width scrolls sideways.
24
+ */
22
25
  onSelect?: (index: number) => void;
23
26
  /** Step indices of the key moments, numbered above the strip in order. */
24
27
  keyMoments?: number[];
@@ -39,7 +42,7 @@ export interface ReplayStepStripProps {
39
42
  * Every step of a run as a bar coloured by its kind, with the key
40
43
  * moments numbered above it and step ticks below. With `onSelect`, a bar
41
44
  * selects its step; arrow keys move between steps with one tab stop.
42
- * The gap between bars narrows as steps are added, so a long run still
43
- * draws every step.
45
+ * Without `onSelect`, the gap between bars narrows as steps are added, so a
46
+ * long run still draws every step in the width.
44
47
  */
45
48
  export declare function ReplayStepStrip({ steps, currentIndex, onSelect, keyMoments, formatStep, tickEvery, size, playhead, className, }: ReplayStepStripProps): ReactElement;
@@ -1,86 +1,96 @@
1
- import { jsxs as b, jsx as p } from "react/jsx-runtime";
2
- import { useRef as R, useState as A } from "react";
3
- import { chartColorValue as B } from "../../lib/chart.js";
1
+ import { jsxs as w, jsx as p } from "react/jsx-runtime";
2
+ import { useRef as N, useState as A, useEffect as D } from "react";
3
+ import { chartColorValue as E } from "../../lib/chart.js";
4
4
  /* empty css */
5
- import { useStrings as C } from "../../locale/useStrings.js";
6
- function D(l, a) {
7
- const r = l - 1, n = new Set(l > 0 ? [0, r] : []);
8
- for (let o = a - 1; o < r; o += a)
9
- r - o >= a / 2 && n.add(o);
10
- return n;
5
+ import { useStrings as F } from "../../locale/useStrings.js";
6
+ function K(o, a) {
7
+ const r = o - 1, c = new Set(o > 0 ? [0, r] : []);
8
+ for (let n = a - 1; n < r; n += a)
9
+ r - n >= a / 2 && c.add(n);
10
+ return c;
11
11
  }
12
- function L({
13
- steps: l,
12
+ function G({
13
+ steps: o,
14
14
  currentIndex: a,
15
15
  onSelect: r,
16
- keyMoments: n = [],
17
- formatStep: o = (m) => `#${String(m + 1)}`,
18
- tickEvery: N,
19
- size: h = "md",
20
- playhead: c,
21
- className: v
16
+ keyMoments: c = [],
17
+ formatStep: n = (g) => `#${String(g + 1)}`,
18
+ tickEvery: M,
19
+ size: f = "md",
20
+ playhead: m,
21
+ className: R
22
22
  }) {
23
- const m = C(), u = R(null), s = l.length, w = N ?? Math.max(1, Math.ceil(s / 20) * 5), M = D(s, w), _ = new Map(n.map((t, e) => [t, e + 1])), [S, d] = A(0), y = Math.min(a ?? S, Math.max(s - 1, 0)), j = (t) => {
24
- if (!r || s === 0)
23
+ const g = F(), _ = N(null), y = N(null), i = o.length, S = M ?? Math.max(1, Math.ceil(i / 20) * 5), j = K(i, S), d = new Map(c.map((t, e) => [t, e + 1])), [B, b] = A(0), h = Math.min(a ?? B, Math.max(i - 1, 0)), u = r !== void 0;
24
+ D(() => {
25
+ const t = _.current, e = a === void 0 ? null : y.current?.children.item(a);
26
+ if (!u || !t || !e)
27
+ return;
28
+ const s = t.getBoundingClientRect(), l = e.getBoundingClientRect();
29
+ (l.left < s.left || l.right > s.right) && (t.scrollLeft += l.left + l.width / 2 - (s.left + s.width / 2));
30
+ }, [u, a, i]);
31
+ const $ = (t) => {
32
+ if (!r || i === 0)
25
33
  return;
26
34
  const e = {
27
- ArrowLeft: y - 1,
28
- ArrowRight: y + 1,
35
+ ArrowLeft: h - 1,
36
+ ArrowRight: h + 1,
29
37
  Home: 0,
30
- End: s - 1
38
+ End: i - 1
31
39
  };
32
40
  if (!(t.key in e))
33
41
  return;
34
42
  t.preventDefault();
35
- const i = Math.min(Math.max(e[t.key], 0), s - 1);
36
- d(i), r(i), u.current?.querySelectorAll(".aegis-replay-step-strip__step").item(i).focus();
37
- }, $ = {
38
- "--aegis-replay-step-strip-count": Math.max(s, 1),
39
- ...c === void 0 ? {} : {
40
- "--aegis-replay-step-strip-head": c,
41
- "--aegis-replay-step-strip-head-step": c * s
43
+ const s = Math.min(Math.max(e[t.key], 0), i - 1);
44
+ b(s), r(s), y.current?.querySelectorAll(".aegis-replay-step-strip__step").item(s).focus();
45
+ }, C = {
46
+ "--aegis-replay-step-strip-count": Math.max(i, 1),
47
+ ...m === void 0 ? {} : {
48
+ "--aegis-replay-step-strip-head": m,
49
+ "--aegis-replay-step-strip-head-step": m * i
42
50
  }
43
51
  };
44
- return /* @__PURE__ */ b(
52
+ return /* @__PURE__ */ w(
45
53
  "div",
46
54
  {
55
+ ref: _,
47
56
  className: [
48
57
  "aegis-replay-step-strip",
49
- `aegis-replay-step-strip--${h}`,
50
- c === void 0 ? "" : "aegis-replay-step-strip--playhead",
51
- v ?? ""
58
+ `aegis-replay-step-strip--${f}`,
59
+ u ? "aegis-replay-step-strip--selectable" : "",
60
+ m === void 0 ? "" : "aegis-replay-step-strip--playhead",
61
+ R ?? ""
52
62
  ].filter(Boolean).join(" "),
53
- style: $,
63
+ style: C,
54
64
  children: [
55
- n.length > 0 && /* @__PURE__ */ p("div", { className: "aegis-replay-step-strip__moments", "aria-hidden": "true", children: l.map((t, e) => {
56
- const i = _.get(e);
57
- return i === void 0 ? /* @__PURE__ */ p("span", {}, t.key) : /* @__PURE__ */ p(
65
+ c.length > 0 && /* @__PURE__ */ p("div", { className: "aegis-replay-step-strip__moments", "aria-hidden": "true", children: o.map((t, e) => {
66
+ const s = d.get(e);
67
+ return s === void 0 ? /* @__PURE__ */ p("span", {}, t.key) : /* @__PURE__ */ p(
58
68
  "span",
59
69
  {
60
70
  className: [
61
71
  "aegis-replay-step-strip__moment",
62
72
  e === a ? "aegis-replay-step-strip__moment--current" : ""
63
73
  ].filter(Boolean).join(" "),
64
- children: i
74
+ children: s
65
75
  },
66
76
  t.key
67
77
  );
68
78
  }) }),
69
- /* @__PURE__ */ b(
79
+ /* @__PURE__ */ w(
70
80
  "div",
71
81
  {
72
- ref: u,
82
+ ref: y,
73
83
  className: "aegis-replay-step-strip__bars",
74
84
  role: r ? "toolbar" : "list",
75
- "aria-label": m.replaySteps,
76
- onKeyDown: j,
85
+ "aria-label": g.replaySteps,
86
+ onKeyDown: $,
77
87
  children: [
78
- l.map((t, e) => {
79
- const i = _.get(e), g = i === void 0 ? t.label : `${t.label} · ${m.replayKeyMoment(i)}`, f = {
80
- "--aegis-replay-step-strip-color": B(t.color),
88
+ o.map((t, e) => {
89
+ const s = d.get(e), l = s === void 0 ? t.label : `${t.label} · ${g.replayKeyMoment(s)}`, k = {
90
+ "--aegis-replay-step-strip-color": E(t.color),
81
91
  "--aegis-replay-step-strip-index": e,
82
92
  ...t.weight === void 0 ? {} : { height: `${(t.weight * 100).toString()}%` }
83
- }, k = [
93
+ }, v = [
84
94
  "aegis-replay-step-strip__step",
85
95
  t.emphasis ? "aegis-replay-step-strip__step--emphasis" : "",
86
96
  e === a ? "aegis-replay-step-strip__step--current" : ""
@@ -89,14 +99,14 @@ function L({
89
99
  "button",
90
100
  {
91
101
  type: "button",
92
- className: k,
93
- style: f,
94
- title: g,
95
- "aria-label": g,
102
+ className: v,
103
+ style: k,
104
+ title: l,
105
+ "aria-label": l,
96
106
  "aria-current": e === a ? "step" : void 0,
97
- tabIndex: e === y ? 0 : -1,
107
+ tabIndex: e === h ? 0 : -1,
98
108
  onClick: () => {
99
- d(e), r(e);
109
+ b(e), r(e);
100
110
  }
101
111
  },
102
112
  t.key
@@ -104,16 +114,16 @@ function L({
104
114
  "span",
105
115
  {
106
116
  role: "listitem",
107
- className: k,
108
- style: f,
109
- title: g,
110
- "aria-label": g,
117
+ className: v,
118
+ style: k,
119
+ title: l,
120
+ "aria-label": l,
111
121
  "aria-current": e === a ? "step" : void 0
112
122
  },
113
123
  t.key
114
124
  );
115
125
  }),
116
- c !== void 0 && /* @__PURE__ */ p(
126
+ m !== void 0 && /* @__PURE__ */ p(
117
127
  "span",
118
128
  {
119
129
  className: "aegis-replay-step-strip__head-track",
@@ -124,11 +134,11 @@ function L({
124
134
  ]
125
135
  }
126
136
  ),
127
- h === "md" && /* @__PURE__ */ p("div", { className: "aegis-replay-step-strip__ticks", "aria-hidden": "true", children: l.map((t, e) => /* @__PURE__ */ p(
137
+ f === "md" && /* @__PURE__ */ p("div", { className: "aegis-replay-step-strip__ticks", "aria-hidden": "true", children: o.map((t, e) => /* @__PURE__ */ p(
128
138
  "span",
129
139
  {
130
- className: e === s - 1 && s > 1 ? "aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last" : "aegis-replay-step-strip__tick",
131
- children: M.has(e) ? o(e) : null
140
+ className: e === i - 1 && i > 1 ? "aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last" : "aegis-replay-step-strip__tick",
141
+ children: j.has(e) ? n(e) : null
132
142
  },
133
143
  t.key
134
144
  )) })
@@ -137,6 +147,6 @@ function L({
137
147
  );
138
148
  }
139
149
  export {
140
- L as ReplayStepStrip
150
+ G as ReplayStepStrip
141
151
  };
142
152
  //# sourceMappingURL=ReplayStepStrip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReplayStepStrip.js","sources":["../../../src/components/ui/ReplayStepStrip.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n useRef,\n useState,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayStepStrip.css';\n\nexport interface ReplayStepStripItem {\n key: string;\n /** The step kind's colour, e.g. thinking, tool call, failure. */\n color: ChartColor;\n /** Names the step for screen readers and its tooltip, e.g. \"#12 · 验证\". */\n label: string;\n /** A step that changes the course (a check, a failure, the goal): taller. */\n emphasis?: boolean;\n /**\n * The bar's height as a share of the strip, 0 to 1, for a host that\n * grades its kinds more finely than `emphasis`; it wins over `emphasis`.\n */\n weight?: number;\n}\n\nexport interface ReplayStepStripProps {\n steps: ReplayStepStripItem[];\n /** The step shown elsewhere on the page; outlined. */\n currentIndex?: number;\n /** Makes each step a button that selects it. */\n onSelect?: (index: number) => void;\n /** Step indices of the key moments, numbered above the strip in order. */\n keyMoments?: number[];\n /** The tick label of a step under the strip. Defaults to `#n`. */\n formatStep?: (index: number) => ReactNode;\n /** A tick every this many steps; defaults to about five ticks. */\n tickEvery?: number;\n /** `sm` is a shorter strip without ticks, for a card or a list row. Defaults to `md`. */\n size?: 'md' | 'sm';\n /**\n * Draws a playhead this share of the way along the strip, 0 to 1, and\n * dims the steps past it, e.g. for a strip that plays as the page scrolls.\n */\n playhead?: number;\n className?: string;\n}\n\n/**\n * The steps that get a tick: the first, the last, and every `every`\n * steps between, leaving out one that would crowd the last.\n */\nfunction tickedSteps(count: number, every: number): Set<number> {\n const last = count - 1;\n const ticks = new Set<number>(count > 0 ? [0, last] : []);\n for (let index = every - 1; index < last; index += every) {\n if (last - index >= every / 2) {\n ticks.add(index);\n }\n }\n return ticks;\n}\n\n/**\n * Every step of a run as a bar coloured by its kind, with the key\n * moments numbered above it and step ticks below. With `onSelect`, a bar\n * selects its step; arrow keys move between steps with one tab stop.\n * The gap between bars narrows as steps are added, so a long run still\n * draws every step.\n */\nexport function ReplayStepStrip({\n steps,\n currentIndex,\n onSelect,\n keyMoments = [],\n formatStep = (index) => `#${String(index + 1)}`,\n tickEvery,\n size = 'md',\n playhead,\n className,\n}: ReplayStepStripProps): ReactElement {\n const strings = useStrings();\n const barsRef = useRef<HTMLDivElement>(null);\n const count = steps.length;\n const every = tickEvery ?? Math.max(1, Math.ceil(count / 20) * 5);\n const ticks = tickedSteps(count, every);\n const momentNumber = new Map(keyMoments.map((step, n) => [step, n + 1]));\n\n // The roving tab stop follows the current step, or the last step the\n // keyboard reached when the host does not mark one.\n const [ownFocus, setOwnFocus] = useState(0);\n const focusIndex = Math.min(currentIndex ?? ownFocus, Math.max(count - 1, 0));\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (!onSelect || count === 0) {\n return;\n }\n const target: Record<string, number> = {\n ArrowLeft: focusIndex - 1,\n ArrowRight: focusIndex + 1,\n Home: 0,\n End: count - 1,\n };\n if (!(event.key in target)) {\n return;\n }\n event.preventDefault();\n const next = Math.min(Math.max(target[event.key], 0), count - 1);\n setOwnFocus(next);\n onSelect(next);\n barsRef.current\n ?.querySelectorAll<HTMLButtonElement>('.aegis-replay-step-strip__step')\n .item(next)\n .focus();\n };\n\n const style = {\n '--aegis-replay-step-strip-count': Math.max(count, 1),\n ...(playhead === undefined\n ? {}\n : {\n '--aegis-replay-step-strip-head': playhead,\n '--aegis-replay-step-strip-head-step': playhead * count,\n }),\n } as CSSProperties;\n return (\n <div\n className={[\n 'aegis-replay-step-strip',\n `aegis-replay-step-strip--${size}`,\n playhead === undefined ? '' : 'aegis-replay-step-strip--playhead',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {keyMoments.length > 0 && (\n <div className=\"aegis-replay-step-strip__moments\" aria-hidden=\"true\">\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n return n === undefined ? (\n <span key={step.key} />\n ) : (\n <span\n key={step.key}\n className={[\n 'aegis-replay-step-strip__moment',\n index === currentIndex\n ? 'aegis-replay-step-strip__moment--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {n}\n </span>\n );\n })}\n </div>\n )}\n <div\n ref={barsRef}\n className=\"aegis-replay-step-strip__bars\"\n role={onSelect ? 'toolbar' : 'list'}\n aria-label={strings.replaySteps}\n onKeyDown={onKeyDown}\n >\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n const label =\n n === undefined\n ? step.label\n : `${step.label} · ${strings.replayKeyMoment(n)}`;\n const barStyle = {\n '--aegis-replay-step-strip-color': chartColorValue(step.color),\n '--aegis-replay-step-strip-index': index,\n ...(step.weight === undefined\n ? {}\n : { height: `${(step.weight * 100).toString()}%` }),\n } as CSSProperties;\n const cls = [\n 'aegis-replay-step-strip__step',\n step.emphasis ? 'aegis-replay-step-strip__step--emphasis' : '',\n index === currentIndex\n ? 'aegis-replay-step-strip__step--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n return onSelect ? (\n <button\n key={step.key}\n type=\"button\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n tabIndex={index === focusIndex ? 0 : -1}\n onClick={() => {\n setOwnFocus(index);\n onSelect(index);\n }}\n />\n ) : (\n <span\n key={step.key}\n role=\"listitem\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n />\n );\n })}\n {playhead !== undefined && (\n <span\n className=\"aegis-replay-step-strip__head-track\"\n aria-hidden=\"true\"\n >\n <span className=\"aegis-replay-step-strip__head\" />\n </span>\n )}\n </div>\n {size === 'md' && (\n <div className=\"aegis-replay-step-strip__ticks\" aria-hidden=\"true\">\n {steps.map((step, index) => (\n <span\n key={step.key}\n className={\n index === count - 1 && count > 1\n ? 'aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last'\n : 'aegis-replay-step-strip__tick'\n }\n >\n {ticks.has(index) ? formatStep(index) : null}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["tickedSteps","count","every","last","ticks","index","ReplayStepStrip","steps","currentIndex","onSelect","keyMoments","formatStep","tickEvery","size","playhead","className","strings","useStrings","barsRef","useRef","momentNumber","step","n","ownFocus","setOwnFocus","useState","focusIndex","onKeyDown","event","target","next","style","jsxs","jsx","label","barStyle","chartColorValue","cls"],"mappings":";;;;;AAsDA,SAASA,EAAYC,GAAeC,GAA4B;AAC9D,QAAMC,IAAOF,IAAQ,GACfG,IAAQ,IAAI,IAAYH,IAAQ,IAAI,CAAC,GAAGE,CAAI,IAAI,EAAE;AACxD,WAASE,IAAQH,IAAQ,GAAGG,IAAQF,GAAME,KAASH;AACjD,IAAIC,IAAOE,KAASH,IAAQ,KAC1BE,EAAM,IAAIC,CAAK;AAGnB,SAAOD;AACT;AASO,SAASE,EAAgB;AAAA,EAC9B,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,YAAAC,IAAa,CAACN,MAAU,IAAI,OAAOA,IAAQ,CAAC,CAAC;AAAA,EAC7C,WAAAO;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,UAAAC;AAAA,EACA,WAAAC;AACF,GAAuC;AACrC,QAAMC,IAAUC,EAAA,GACVC,IAAUC,EAAuB,IAAI,GACrClB,IAAQM,EAAM,QACdL,IAAQU,KAAa,KAAK,IAAI,GAAG,KAAK,KAAKX,IAAQ,EAAE,IAAI,CAAC,GAC1DG,IAAQJ,EAAYC,GAAOC,CAAK,GAChCkB,IAAe,IAAI,IAAIV,EAAW,IAAI,CAACW,GAAMC,MAAM,CAACD,GAAMC,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AA,oBACrC,SAAS,MAAM;AACb,sBAAAF,EAAYnB,CAAK,GACjBI,EAASJ,CAAK;AAAA,oBAChB;AAAA,kBAAA;AAAA,kBAXKgB,EAAK;AAAA,gBAAA,IAcZ,gBAAAY;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBAEC,MAAK;AAAA,oBACL,WAAWI;AAAA,oBACX,OAAOF;AAAA,oBACP,OAAOD;AAAA,oBACP,cAAYA;AAAA,oBACZ,gBAAc7B,MAAUG,IAAe,SAAS;AAAA,kBAAA;AAAA,kBAN3Ca,EAAK;AAAA,gBAAA;AAAA,cAShB,CAAC;AAAA,cACAP,MAAa,UACZ,gBAAAmB;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAU;AAAA,kBACV,eAAY;AAAA,kBAEZ,UAAA,gBAAAA,EAAC,QAAA,EAAK,WAAU,gCAAA,CAAgC;AAAA,gBAAA;AAAA,cAAA;AAAA,YAClD;AAAA,UAAA;AAAA,QAAA;AAAA,QAGHpB,MAAS,QACR,gBAAAoB,EAAC,OAAA,EAAI,WAAU,kCAAiC,eAAY,QACzD,UAAA1B,EAAM,IAAI,CAACc,GAAMhB,MAChB,gBAAA4B;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,WACE5B,MAAUJ,IAAQ,KAAKA,IAAQ,IAC3B,sEACA;AAAA,YAGL,YAAM,IAAII,CAAK,IAAIM,EAAWN,CAAK,IAAI;AAAA,UAAA;AAAA,UAPnCgB,EAAK;AAAA,QAAA,CASb,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
1
+ {"version":3,"file":"ReplayStepStrip.js","sources":["../../../src/components/ui/ReplayStepStrip.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport { type ChartColor, chartColorValue } from '../../lib/chart';\nimport { useStrings } from '../../locale';\nimport './ReplayStepStrip.css';\n\nexport interface ReplayStepStripItem {\n key: string;\n /** The step kind's colour, e.g. thinking, tool call, failure. */\n color: ChartColor;\n /** Names the step for screen readers and its tooltip, e.g. \"#12 · 验证\". */\n label: string;\n /** A step that changes the course (a check, a failure, the goal): taller. */\n emphasis?: boolean;\n /**\n * The bar's height as a share of the strip, 0 to 1, for a host that\n * grades its kinds more finely than `emphasis`; it wins over `emphasis`.\n */\n weight?: number;\n}\n\nexport interface ReplayStepStripProps {\n steps: ReplayStepStripItem[];\n /** The step shown elsewhere on the page; outlined. */\n currentIndex?: number;\n /**\n * Makes each step a button that selects it. Each step then stays wide\n * enough to tap, and a run too long for the width scrolls sideways.\n */\n onSelect?: (index: number) => void;\n /** Step indices of the key moments, numbered above the strip in order. */\n keyMoments?: number[];\n /** The tick label of a step under the strip. Defaults to `#n`. */\n formatStep?: (index: number) => ReactNode;\n /** A tick every this many steps; defaults to about five ticks. */\n tickEvery?: number;\n /** `sm` is a shorter strip without ticks, for a card or a list row. Defaults to `md`. */\n size?: 'md' | 'sm';\n /**\n * Draws a playhead this share of the way along the strip, 0 to 1, and\n * dims the steps past it, e.g. for a strip that plays as the page scrolls.\n */\n playhead?: number;\n className?: string;\n}\n\n/**\n * The steps that get a tick: the first, the last, and every `every`\n * steps between, leaving out one that would crowd the last.\n */\nfunction tickedSteps(count: number, every: number): Set<number> {\n const last = count - 1;\n const ticks = new Set<number>(count > 0 ? [0, last] : []);\n for (let index = every - 1; index < last; index += every) {\n if (last - index >= every / 2) {\n ticks.add(index);\n }\n }\n return ticks;\n}\n\n/**\n * Every step of a run as a bar coloured by its kind, with the key\n * moments numbered above it and step ticks below. With `onSelect`, a bar\n * selects its step; arrow keys move between steps with one tab stop.\n * Without `onSelect`, the gap between bars narrows as steps are added, so a\n * long run still draws every step in the width.\n */\nexport function ReplayStepStrip({\n steps,\n currentIndex,\n onSelect,\n keyMoments = [],\n formatStep = (index) => `#${String(index + 1)}`,\n tickEvery,\n size = 'md',\n playhead,\n className,\n}: ReplayStepStripProps): ReactElement {\n const strings = useStrings();\n const rootRef = useRef<HTMLDivElement>(null);\n const barsRef = useRef<HTMLDivElement>(null);\n const count = steps.length;\n const every = tickEvery ?? Math.max(1, Math.ceil(count / 20) * 5);\n const ticks = tickedSteps(count, every);\n const momentNumber = new Map(keyMoments.map((step, n) => [step, n + 1]));\n\n // The roving tab stop follows the current step, or the last step the\n // keyboard reached when the host does not mark one.\n const [ownFocus, setOwnFocus] = useState(0);\n const focusIndex = Math.min(currentIndex ?? ownFocus, Math.max(count - 1, 0));\n\n // A selectable strip may scroll; bring a current step the host moved out\n // of view back to the middle, without scrolling the page.\n const selectable = onSelect !== undefined;\n useEffect(() => {\n const root = rootRef.current;\n const bar =\n currentIndex === undefined\n ? null\n : barsRef.current?.children.item(currentIndex);\n if (!selectable || !root || !bar) {\n return;\n }\n const view = root.getBoundingClientRect();\n const step = bar.getBoundingClientRect();\n if (step.left < view.left || step.right > view.right) {\n root.scrollLeft +=\n step.left + step.width / 2 - (view.left + view.width / 2);\n }\n }, [selectable, currentIndex, count]);\n\n const onKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {\n if (!onSelect || count === 0) {\n return;\n }\n const target: Record<string, number> = {\n ArrowLeft: focusIndex - 1,\n ArrowRight: focusIndex + 1,\n Home: 0,\n End: count - 1,\n };\n if (!(event.key in target)) {\n return;\n }\n event.preventDefault();\n const next = Math.min(Math.max(target[event.key], 0), count - 1);\n setOwnFocus(next);\n onSelect(next);\n barsRef.current\n ?.querySelectorAll<HTMLButtonElement>('.aegis-replay-step-strip__step')\n .item(next)\n .focus();\n };\n\n const style = {\n '--aegis-replay-step-strip-count': Math.max(count, 1),\n ...(playhead === undefined\n ? {}\n : {\n '--aegis-replay-step-strip-head': playhead,\n '--aegis-replay-step-strip-head-step': playhead * count,\n }),\n } as CSSProperties;\n return (\n <div\n ref={rootRef}\n className={[\n 'aegis-replay-step-strip',\n `aegis-replay-step-strip--${size}`,\n selectable ? 'aegis-replay-step-strip--selectable' : '',\n playhead === undefined ? '' : 'aegis-replay-step-strip--playhead',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n style={style}\n >\n {keyMoments.length > 0 && (\n <div className=\"aegis-replay-step-strip__moments\" aria-hidden=\"true\">\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n return n === undefined ? (\n <span key={step.key} />\n ) : (\n <span\n key={step.key}\n className={[\n 'aegis-replay-step-strip__moment',\n index === currentIndex\n ? 'aegis-replay-step-strip__moment--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {n}\n </span>\n );\n })}\n </div>\n )}\n <div\n ref={barsRef}\n className=\"aegis-replay-step-strip__bars\"\n role={onSelect ? 'toolbar' : 'list'}\n aria-label={strings.replaySteps}\n onKeyDown={onKeyDown}\n >\n {steps.map((step, index) => {\n const n = momentNumber.get(index);\n const label =\n n === undefined\n ? step.label\n : `${step.label} · ${strings.replayKeyMoment(n)}`;\n const barStyle = {\n '--aegis-replay-step-strip-color': chartColorValue(step.color),\n '--aegis-replay-step-strip-index': index,\n ...(step.weight === undefined\n ? {}\n : { height: `${(step.weight * 100).toString()}%` }),\n } as CSSProperties;\n const cls = [\n 'aegis-replay-step-strip__step',\n step.emphasis ? 'aegis-replay-step-strip__step--emphasis' : '',\n index === currentIndex\n ? 'aegis-replay-step-strip__step--current'\n : '',\n ]\n .filter(Boolean)\n .join(' ');\n return onSelect ? (\n <button\n key={step.key}\n type=\"button\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n tabIndex={index === focusIndex ? 0 : -1}\n onClick={() => {\n setOwnFocus(index);\n onSelect(index);\n }}\n />\n ) : (\n <span\n key={step.key}\n role=\"listitem\"\n className={cls}\n style={barStyle}\n title={label}\n aria-label={label}\n aria-current={index === currentIndex ? 'step' : undefined}\n />\n );\n })}\n {playhead !== undefined && (\n <span\n className=\"aegis-replay-step-strip__head-track\"\n aria-hidden=\"true\"\n >\n <span className=\"aegis-replay-step-strip__head\" />\n </span>\n )}\n </div>\n {size === 'md' && (\n <div className=\"aegis-replay-step-strip__ticks\" aria-hidden=\"true\">\n {steps.map((step, index) => (\n <span\n key={step.key}\n className={\n index === count - 1 && count > 1\n ? 'aegis-replay-step-strip__tick aegis-replay-step-strip__tick--last'\n : 'aegis-replay-step-strip__tick'\n }\n >\n {ticks.has(index) ? formatStep(index) : null}\n </span>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["tickedSteps","count","every","last","ticks","index","ReplayStepStrip","steps","currentIndex","onSelect","keyMoments","formatStep","tickEvery","size","playhead","className","strings","useStrings","rootRef","useRef","barsRef","momentNumber","step","n","ownFocus","setOwnFocus","useState","focusIndex","selectable","useEffect","root","bar","view","onKeyDown","event","target","next","style","jsxs","jsx","label","barStyle","chartColorValue","cls"],"mappings":";;;;;AA0DA,SAASA,EAAYC,GAAeC,GAA4B;AAC9D,QAAMC,IAAOF,IAAQ,GACfG,IAAQ,IAAI,IAAYH,IAAQ,IAAI,CAAC,GAAGE,CAAI,IAAI,EAAE;AACxD,WAASE,IAAQH,IAAQ,GAAGG,IAAQF,GAAME,KAASH;AACjD,IAAIC,IAAOE,KAASH,IAAQ,KAC1BE,EAAM,IAAIC,CAAK;AAGnB,SAAOD;AACT;AASO,SAASE,EAAgB;AAAA,EAC9B,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,YAAAC,IAAa,CAACN,MAAU,IAAI,OAAOA,IAAQ,CAAC,CAAC;AAAA,EAC7C,WAAAO;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,UAAAC;AAAA,EACA,WAAAC;AACF,GAAuC;AACrC,QAAMC,IAAUC,EAAA,GACVC,IAAUC,EAAuB,IAAI,GACrCC,IAAUD,EAAuB,IAAI,GACrClB,IAAQM,EAAM,QACdL,IAAQU,KAAa,KAAK,IAAI,GAAG,KAAK,KAAKX,IAAQ,EAAE,IAAI,CAAC,GAC1DG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GH1B,MAAS,QACR,gBAAA0B,EAAC,OAAA,EAAI,WAAU,kCAAiC,eAAY,QACzD,UAAAhC,EAAM,IAAI,CAACe,GAAMjB,MAChB,gBAAAkC;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,WACElC,MAAUJ,IAAQ,KAAKA,IAAQ,IAC3B,sEACA;AAAA,YAGL,YAAM,IAAII,CAAK,IAAIM,EAAWN,CAAK,IAAI;AAAA,UAAA;AAAA,UAPnCiB,EAAK;AAAA,QAAA,CASb,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),b=require("react"),I=require("@dagrejs/dagre"),p=require("@xyflow/react"),Q=require("../../hooks/useMediaQuery.cjs");;/* empty css */const K=require("./StatusDot.cjs"),ee=require("../../locale/useStrings.cjs"),G=180,F=64,se=320,k=28,te=64,ie={"--aegis-service-map-node-w":`${String(G)}px`,"--aegis-service-map-node-h":`${String(F)}px`,"--aegis-service-map-node-max-w":`${String(se)}px`,"--aegis-service-map-group-label-h":`${String(k)}px`},ae={width:G,height:F};function oe(s,i,n,o){const r=s.map(t=>t.id),m=new Set(r);return{direction:o,ids:r,links:i.filter(t=>m.has(t.source)&&m.has(t.target)).map(t=>[t.source,t.target]),groups:n}}function ne(s,i){const n=new Set(s),o=new Set,r=i.map(t=>{const u=[...new Set(t.nodeIds)].filter(c=>n.has(c)&&!o.has(c));return u.forEach(c=>o.add(c)),{group:t,ids:u}}),m=s.filter(t=>!o.has(t));return[...r,{ids:m}].filter(t=>t.ids.length>0)}function re(s,i,n,o){const r=new I.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:n,nodesep:40,ranksep:80,marginx:16,marginy:16});for(const c of s)r.setNode(c,{...o(c)});for(const[c,e]of i)r.hasNode(c)&&r.hasNode(e)&&r.setEdge(c,e);I.layout(r);const m=new Map(s.map(c=>{const{x:e=0,y:g=0}=r.node(c),h=o(c);return[c,{x:e-h.width/2,y:g-h.height/2}]})),{width:t=0,height:u=0}=r.graph();return{positions:m,width:t,height:u}}function ce(s,i,n){const o=e=>`${n}-group-${String(s.groups.indexOf(e))}`,r=s.direction==="LR",m=ne(s.ids,s.groups).map(e=>{const g=re(e.ids,s.links,s.direction,w=>i.get(w)??ae),h=e.group===void 0?0:k;return{...e,...g,labelHeight:h,boxHeight:g.height+h}}),t=Math.max(0,...m.map(e=>r?e.boxHeight:e.width));let u=0;const c=m.map(e=>{const g=r?{x:u,y:(t-e.boxHeight)/2}:{x:(t-e.width)/2,y:u};return u+=(r?e.width:e.boxHeight)+te,{...e,origin:g}});return{groups:c.flatMap(e=>e.group===void 0?[]:[{id:`group:${e.group.id}`,type:"serviceGroup",position:e.origin,width:e.width,height:e.boxHeight,data:{label:e.group.label,labelId:o(e.group)},domAttributes:{"aria-roledescription":void 0,"aria-describedby":void 0},zIndex:-1,style:{pointerEvents:"none"},draggable:!1,connectable:!1,selectable:!1,focusable:!1}]),positions:new Map(c.flatMap(e=>[...e.positions].map(([g,h])=>[g,{x:e.origin.x+h.x,y:e.origin.y+e.labelHeight+h.y}]))),groupLabels:new Map(c.flatMap(e=>{const{group:g}=e;return g===void 0?[]:e.ids.map(h=>[h,o(g)])}))}}function le({data:s}){return d.jsx("div",{className:"aegis-service-map__group",children:d.jsx("span",{id:s.labelId,className:"aegis-service-map__group-label",children:s.label})})}function de({data:s}){const{node:i,selected:n}=s,o=i.status??"ok";return d.jsxs("div",{className:["aegis-service-map__node",`aegis-service-map__node--${o}`,n?"aegis-service-map__node--selected":""].filter(Boolean).join(" "),children:[d.jsx(p.Handle,{type:"target",position:p.Position.Left,className:"aegis-service-map__handle"}),d.jsx("span",{className:"aegis-service-map__node-stripe","aria-hidden":"true"}),d.jsxs("div",{className:"aegis-service-map__node-body",children:[d.jsxs("div",{className:"aegis-service-map__node-label",children:[o==="active"&&d.jsx(K.StatusDot,{pulse:!0,tone:n?"inverted":"ink"}),d.jsx("span",{className:"aegis-service-map__node-label-text",children:i.label})]}),i.sublabel!==void 0&&d.jsx("div",{className:"aegis-service-map__node-sublabel",children:i.sublabel})]}),i.badge!==void 0&&i.badge!==""&&d.jsx("span",{className:`aegis-service-map__node-badge aegis-service-map__node-badge--${o}`,children:i.badge}),d.jsx(p.Handle,{type:"source",position:p.Position.Right,className:"aegis-service-map__handle"})]})}function ge(s){const{sourceX:i,sourceY:n,targetX:o,targetY:r,id:m,label:t,markerEnd:u,style:c}=s,e=(i+o)/2,g=`M${i},${n} C${e},${n} ${e},${r} ${o},${r}`;return d.jsxs(d.Fragment,{children:[d.jsx("path",{id:m,d:g,className:"aegis-service-map__edge-path",markerEnd:u,style:c,fill:"none"}),t!==void 0&&t!==""&&d.jsx("text",{className:"aegis-service-map__edge-label",children:d.jsx("textPath",{href:`#${m}`,startOffset:"50%",textAnchor:"middle",children:t})})]})}const ue={service:de,serviceGroup:le},pe={service:ge},me="(max-width: 768px)",N=24,B=.1,O=1,T=15,he=28,q=200,$=s=>`${s}px`;function fe(s,i){return[...new Set([s,...i.filter(([n])=>n===s).map(([,n])=>n),...i.filter(([,n])=>n===s).map(([n])=>n)])]}function be(s){return s.type==="serviceGroup"?"aegis-service-map__minimap-group":""}function ve(s,i,n,o,r){const{fitView:m,getNodesBounds:t}=p.useReactFlow(),u=p.useStoreApi(),c=p.useStore(g=>g.width>0&&g.height>0),e=b.useMemo(()=>o!==void 0&&s.ids.includes(o)?{id:o,near:fe(o,s.links)}:void 0,[o,s]);b.useEffect(()=>{if(c&&n){const g={top:$(N),bottom:$(N),left:$(T+he+N),right:$(r?T+q+N:N)};if(e===void 0)m({maxZoom:1,padding:g});else{const{width:h,height:w}=u.getState(),v=p.getViewportForBounds(t(e.near),h,w,B,O,g).zoom>=O;m({nodes:(v?e.near:[e.id]).map(j=>({id:j})),minZoom:O,maxZoom:O,padding:g})}}},[c,n,i,e,r,u,m,t])}function _e({nodes:s,edges:i,groups:n=[],direction:o="LR",height:r,fillViewport:m=!1,onNodeClick:t,onEdgeClick:u,selectedNodeId:c,focusNodeId:e,minimap:g=e===void 0,ariaLabel:h,className:w}){const v=ee.useStrings(),j=b.useId(),L=p.useStore(l=>l.rfId),y=t!==void 0,E=u!==void 0,[S,z]=b.useState(()=>new Map),P=b.useMemo(()=>JSON.stringify(oe(s,i,n,o)),[s,i,n,o]),R=b.useMemo(()=>JSON.parse(P),[P]),M=b.useMemo(()=>ce(R,S,j),[R,S,j]),D=o==="LR",C=b.useMemo(()=>[...M.groups,...s.map(l=>{const a=[M.groupLabels.get(l.id),y?`react-flow__node-desc-${L}`:void 0].filter(Boolean).join(" ");return{id:l.id,type:"service",position:M.positions.get(l.id)??{x:0,y:0},measured:S.get(l.id),ariaLabel:l.label,ariaRole:"group",domAttributes:{"aria-roledescription":v.serviceMapNodeRole,"aria-current":c===l.id?!0:void 0,"aria-describedby":a===""?void 0:a},data:{node:l,selected:c===l.id},sourcePosition:D?p.Position.Right:p.Position.Bottom,targetPosition:D?p.Position.Left:p.Position.Top,draggable:!1,connectable:!1,selectable:y,focusable:y}})],[M,s,S,c,D,y,L,v]),Z=b.useMemo(()=>{const l=new Map(s.map(a=>[a.id,a.label]));return i.map(a=>({id:a.id,source:a.source,target:a.target,ariaLabel:v.serviceMapEdgeName(l.get(a.source)??a.source,l.get(a.target)??a.target),domAttributes:{"aria-roledescription":v.serviceMapEdgeRole},type:"service",data:{edge:a},label:a.label,selectable:E,focusable:E,className:`aegis-service-map__edge aegis-service-map__edge--${a.status??"ok"}`}))},[s,i,E,v]),{getNode:H}=p.useReactFlow(),U=b.useCallback(l=>{const a=l.flatMap(f=>f.type==="dimensions"&&f.dimensions!==void 0&&H(f.id)?.type==="service"?[[f.id,f.dimensions]]:[]);z(f=>a.every(([_,x])=>f.get(_)?.width===x.width&&f.get(_)?.height===x.height)?f:new Map([...f,...a]))},[H]),W=Q.useMediaQuery(me),A=g&&!W;ve(R,M,s.every(l=>S.has(l.id)),e,A);const Y=b.useCallback((l,a)=>{a.type==="service"&&t?.(a.data.node)},[t]),V=b.useCallback((l,a)=>{a.data&&u?.(a.data.edge)},[u]),X=b.useCallback(l=>{if(l.key!=="Enter"&&l.key!==" "||l.repeat)return;const a=l.target;if(!(a instanceof Element))return;const f=a.getAttribute("data-id");if(a.classList.contains("react-flow__node")){const _=s.find(x=>x.id===f);_&&t&&(l.preventDefault(),t(_))}else if(a.classList.contains("react-flow__edge")){const _=i.find(x=>x.id===f);_&&u&&(l.preventDefault(),u(_))}},[s,i,t,u]),J={...ie,height:r===void 0?void 0:`${String(r)}px`};return d.jsx("div",{className:["aegis-service-map",m?"aegis-service-map--fill-viewport":"",w].filter(Boolean).join(" "),style:J,children:d.jsx("div",{className:"aegis-service-map__pane",children:d.jsxs(p.ReactFlow,{"aria-label":h,nodes:C,edges:Z,nodeTypes:ue,edgeTypes:pe,minZoom:B,nodesDraggable:!1,nodesConnectable:!1,panOnDrag:!0,zoomOnScroll:!0,proOptions:{hideAttribution:!0},ariaLabelConfig:v.serviceMapAriaLabels,onNodesChange:U,onNodeClick:y?Y:void 0,onEdgeClick:E?V:void 0,onKeyDown:X,children:[d.jsx(p.Background,{variant:p.BackgroundVariant.Dots,gap:16,size:1}),d.jsx(p.Controls,{showInteractive:!1,position:"top-left"}),A&&d.jsx(p.MiniMap,{pannable:!0,zoomable:!0,position:"bottom-right",style:{width:q},nodeClassName:be})]})})})}function xe(s){return d.jsx(p.ReactFlowProvider,{children:d.jsx(_e,{...s})})}exports.ServiceMap=xe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),f=require("react"),Z=require("@dagrejs/dagre"),p=require("@xyflow/react"),te=require("../../hooks/useMediaQuery.cjs");;/* empty css */const se=require("./StatusDot.cjs"),oe=require("../../locale/useStrings.cjs"),B=180,G=64,ie=320,U=28,ae=64,ne={"--aegis-service-map-node-w":`${String(B)}px`,"--aegis-service-map-node-h":`${String(G)}px`,"--aegis-service-map-node-max-w":`${String(ie)}px`,"--aegis-service-map-group-label-h":`${String(U)}px`},re={width:B,height:G};function ce(e,o,r,i){const n=e.map(s=>s.id),m=new Set(n);return{direction:i,ids:n,links:o.filter(s=>m.has(s.source)&&m.has(s.target)).map(s=>[s.source,s.target]),groups:r}}function le(e,o){const r=new Set(e),i=new Set,n=o.map(s=>{const l=[...new Set(s.nodeIds)].filter(a=>r.has(a)&&!i.has(a));return l.forEach(a=>i.add(a)),{group:s,ids:l}}),m=e.filter(s=>!i.has(s));return[...n,{ids:m}].filter(s=>s.ids.length>0)}function de(e,o,r,i){const n=new Z.graphlib.Graph;n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:r,nodesep:40,ranksep:80,marginx:16,marginy:16});for(const a of e)n.setNode(a,{...i(a)});for(const[a,t]of o)n.hasNode(a)&&n.hasNode(t)&&n.setEdge(a,t);Z.layout(n);const m=new Map(e.map(a=>{const{x:t=0,y:u=0}=n.node(a),h=i(a);return[a,{x:t-h.width/2,y:u-h.height/2}]})),{width:s=0,height:l=0}=n.graph();return{positions:m,width:s,height:l}}function ge(e,o,r){const i=t=>`${r}-group-${String(e.groups.indexOf(t))}`,n=e.direction==="LR",m=le(e.ids,e.groups).map(t=>{const u=de(t.ids,e.links,e.direction,_=>o.get(_)??re),h=t.group===void 0?0:U;return{...t,...u,labelHeight:h,boxHeight:u.height+h}}),s=Math.max(0,...m.map(t=>n?t.boxHeight:t.width));let l=0;const a=m.map(t=>{const u=n?{x:l,y:(s-t.boxHeight)/2}:{x:(s-t.width)/2,y:l};return l+=(n?t.width:t.boxHeight)+ae,{...t,origin:u}});return{groups:a.flatMap(t=>t.group===void 0?[]:[{id:`group:${t.group.id}`,type:"serviceGroup",position:t.origin,width:t.width,height:t.boxHeight,data:{label:t.group.label,labelId:i(t.group)},domAttributes:{"aria-roledescription":void 0,"aria-describedby":void 0},zIndex:-1,style:{pointerEvents:"none"},draggable:!1,connectable:!1,selectable:!1,focusable:!1}]),positions:new Map(a.flatMap(t=>[...t.positions].map(([u,h])=>[u,{x:t.origin.x+h.x,y:t.origin.y+t.labelHeight+h.y}]))),groupLabels:new Map(a.flatMap(t=>{const{group:u}=t;return u===void 0?[]:t.ids.map(h=>[h,i(u)])}))}}function ue({data:e}){return d.jsx("div",{className:"aegis-service-map__group",children:d.jsx("span",{id:e.labelId,className:"aegis-service-map__group-label",children:e.label})})}const pe={ok:"ink",active:"ink",warn:"caution",error:"warning",muted:"muted"};function me({data:e}){const{node:o,selected:r}=e,i=o.status??"ok",n=pe[i];return d.jsxs("div",{className:["aegis-service-map__node",`aegis-service-map__node--${i}`,r?"aegis-service-map__node--selected":""].filter(Boolean).join(" "),children:[d.jsx(p.Handle,{type:"target",position:p.Position.Left,className:"aegis-service-map__handle"}),d.jsxs("div",{className:"aegis-service-map__node-body",children:[d.jsxs("div",{className:"aegis-service-map__node-label",children:[d.jsx(se.StatusDot,{pulse:i==="active",tone:r&&n==="ink"?"inverted":n}),d.jsx("span",{className:"aegis-service-map__node-label-text",children:o.label})]}),o.sublabel!==void 0&&d.jsx("div",{className:"aegis-service-map__node-sublabel",children:o.sublabel})]}),o.badge!==void 0&&o.badge!==""&&d.jsx("span",{className:`aegis-service-map__node-badge aegis-service-map__node-badge--${i}`,children:o.badge}),d.jsx(p.Handle,{type:"source",position:p.Position.Right,className:"aegis-service-map__handle"})]})}function he(e){const{sourceX:o,sourceY:r,targetX:i,targetY:n,label:m,markerEnd:s,style:l}=e,a=f.useId(),t=(o+i)/2,u=`M${o},${r} C${t},${r} ${t},${n} ${i},${n}`;return d.jsxs(d.Fragment,{children:[d.jsx("path",{d:u,className:"aegis-service-map__edge-focus",fill:"none"}),d.jsx("path",{id:a,d:u,className:"aegis-service-map__edge-path",markerEnd:s,style:l,fill:"none"}),m!==void 0&&m!==""&&d.jsx("text",{className:"aegis-service-map__edge-label",children:d.jsx("textPath",{href:`#${a}`,startOffset:"50%",textAnchor:"middle",children:m})})]})}const fe={service:me,serviceGroup:ue},be={service:he},ve="(max-width: 768px)",R=24,k=.1,A=1,q=11/13,F=15,V=28,W=200,H=e=>`${e}px`;function _e(e,o){return[...new Set([e,...o.filter(([r])=>r===e).map(([,r])=>r),...o.filter(([,r])=>r===e).map(([r])=>r)])]}function xe(e){return e.type==="serviceGroup"?"aegis-service-map__minimap-group":""}function we(e,o,r,i,n,m){const{fitView:s,getNodes:l,getNodesBounds:a,setViewport:t}=p.useReactFlow(),u=p.useStoreApi(),h=p.useStore(b=>b.width>0&&b.height>0),_=f.useMemo(()=>i!==void 0&&e.ids.includes(i)?{id:i,near:_e(i,e.links)}:void 0,[i,e]);f.useEffect(()=>{if(h&&r){const b={top:H(R),bottom:H(R),left:H(F+V+R),right:H(n?F+W+R:R)},{width:E,height:j}=u.getState();if(_===void 0){const x=l(),w=a(x),O=p.getViewportForBounds(w,E,j,k,1,b);if(m&&O.zoom<q){const M=q,D=e.direction==="LR",$=S=>D?S.position.x:S.position.y,y=x.filter(S=>S.type==="service").reduce((S,T)=>$(T)<$(S)?T:S),{width:P=B,height:I=G}=y.measured??{};t(D?{x:F+V+R-w.x*M,y:j/2-(y.position.y+I/2)*M,zoom:M}:{x:E/2-(y.position.x+P/2)*M,y:R-w.y*M,zoom:M})}else s({maxZoom:1,padding:b})}else{const x=p.getViewportForBounds(a(_.near),E,j,k,A,b).zoom>=A;s({nodes:(x?_.near:[_.id]).map(w=>({id:w})),minZoom:A,maxZoom:A,padding:b})}}},[h,r,o,_,n,m,e.direction,u,s,l,a,t])}function ye(){const{getViewport:e,setViewport:o}=p.useReactFlow();return f.useCallback(r=>{const i=r.target;if(!(i instanceof Element)||!i.matches(".react-flow__node:focus-visible, .react-flow__edge:focus-visible"))return;const{scrollLeft:n,scrollTop:m}=r.currentTarget,s=r.currentTarget.getBoundingClientRect(),l=i.getBoundingClientRect(),a=l.left-s.left+n,t=l.top-s.top+m;if(a>=0&&t>=0&&a+l.width<=s.width&&t+l.height<=s.height)return;const{x:u,y:h,zoom:_}=e();o({x:u+s.width/2-(a+l.width/2),y:h+s.height/2-(t+l.height/2),zoom:_})},[e,o])}function Se({nodes:e,edges:o,groups:r=[],direction:i="LR",height:n,fillViewport:m=!1,onNodeClick:s,onEdgeClick:l,selectedNodeId:a,focusNodeId:t,minimap:u=t===void 0,ariaLabel:h,className:_}){const b=oe.useStrings(),E=f.useId(),j=`aegis-service-map${E.replace(/:/g,"-")}`,x=s!==void 0,w=l!==void 0,[O,M]=f.useState(()=>new Map),D=f.useMemo(()=>JSON.stringify(ce(e,o,r,i)),[e,o,r,i]),$=f.useMemo(()=>JSON.parse(D),[D]),y=f.useMemo(()=>ge($,O,E),[$,O,E]),P=i==="LR",I=f.useMemo(()=>[...y.groups,...e.map(g=>{const c=[y.groupLabels.get(g.id),x?`react-flow__node-desc-${j}`:void 0].filter(Boolean).join(" ");return{id:g.id,type:"service",position:y.positions.get(g.id)??{x:0,y:0},measured:O.get(g.id),ariaLabel:g.label,ariaRole:"group",domAttributes:{"aria-roledescription":b.serviceMapNodeRole,"aria-current":a===g.id?!0:void 0,"aria-describedby":c===""?void 0:c},data:{node:g,selected:a===g.id},sourcePosition:P?p.Position.Right:p.Position.Bottom,targetPosition:P?p.Position.Left:p.Position.Top,draggable:!1,connectable:!1,selectable:x,focusable:x}})],[y,e,O,a,P,x,j,b]),S=f.useMemo(()=>{const g=new Map(e.map(c=>[c.id,c.label]));return o.map(c=>({id:c.id,source:c.source,target:c.target,ariaLabel:b.serviceMapEdgeName(g.get(c.source)??c.source,g.get(c.target)??c.target),domAttributes:{"aria-roledescription":b.serviceMapEdgeRole},type:"service",data:{edge:c},label:c.label,selectable:w,focusable:w,className:`aegis-service-map__edge aegis-service-map__edge--${c.status??"ok"}`}))},[e,o,w,b]),{getNode:T}=p.useReactFlow(),Y=f.useCallback(g=>{const c=g.flatMap(v=>v.type==="dimensions"&&v.dimensions!==void 0&&T(v.id)?.type==="service"?[[v.id,v.dimensions]]:[]);M(v=>c.every(([N,L])=>v.get(N)?.width===L.width&&v.get(N)?.height===L.height)?v:new Map([...v,...c]))},[T]),z=te.useMediaQuery(ve),C=u&&!z;we($,y,e.every(g=>O.has(g.id)),t,C,z);const X=ye(),J=f.useCallback((g,c)=>{c.type==="service"&&s?.(c.data.node)},[s]),Q=f.useCallback((g,c)=>{c.data&&l?.(c.data.edge)},[l]),K=f.useCallback(g=>{if(g.key!=="Enter"&&g.key!==" "||g.repeat)return;const c=g.target;if(!(c instanceof Element))return;const v=c.getAttribute("data-id");if(c.classList.contains("react-flow__node")){const N=e.find(L=>L.id===v);N&&s&&(g.preventDefault(),s(N))}else if(c.classList.contains("react-flow__edge")){const N=o.find(L=>L.id===v);N&&l&&(g.preventDefault(),l(N))}},[e,o,s,l]),ee={...ne,height:n===void 0?void 0:`${String(n)}px`};return d.jsx("div",{className:["aegis-service-map",m?"aegis-service-map--fill-viewport":"",_].filter(Boolean).join(" "),style:ee,children:d.jsx("div",{className:"aegis-service-map__pane",children:d.jsxs(p.ReactFlow,{id:j,"aria-label":h,nodes:I,edges:S,nodeTypes:fe,edgeTypes:be,minZoom:k,nodesDraggable:!1,nodesConnectable:!1,autoPanOnNodeFocus:!1,panOnDrag:!0,zoomOnScroll:!0,proOptions:{hideAttribution:!0},ariaLabelConfig:b.serviceMapAriaLabels,onNodesChange:Y,onNodeClick:x?J:void 0,onEdgeClick:w?Q:void 0,onKeyDown:K,onFocus:X,children:[d.jsx(p.Background,{variant:p.BackgroundVariant.Dots,gap:16,size:1}),d.jsx(p.Controls,{showInteractive:!1,position:"top-left"}),C&&d.jsx(p.MiniMap,{pannable:!0,zoomable:!0,position:"bottom-right",style:{width:W},nodeClassName:xe})]})})})}function Me(e){return d.jsx(p.ReactFlowProvider,{children:d.jsx(Se,{...e})})}exports.ServiceMap=Me;
2
2
  //# sourceMappingURL=ServiceMap.cjs.map