@photon-ai/pho-ui 4.7.1 → 4.9.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 (69) hide show
  1. package/dist/chunks/bar-chart-ht70KKj3.js +19 -0
  2. package/dist/chunks/bar-chart-ht70KKj3.js.map +1 -0
  3. package/dist/chunks/{basic-page-BUmntB7L.js → basic-page-DzT8yecB.js} +174 -173
  4. package/dist/chunks/basic-page-DzT8yecB.js.map +1 -0
  5. package/dist/chunks/chart-B5c8gmlj.js +1338 -0
  6. package/dist/chunks/chart-B5c8gmlj.js.map +1 -0
  7. package/dist/chunks/code-block-CbcE994O.js +516 -0
  8. package/dist/chunks/code-block-CbcE994O.js.map +1 -0
  9. package/dist/chunks/{data-table-Mog6m3d9.js → data-table-B1dmrN6r.js} +89 -94
  10. package/dist/chunks/data-table-B1dmrN6r.js.map +1 -0
  11. package/dist/chunks/ghost-search-CNVs9k1o.js +34 -0
  12. package/dist/chunks/ghost-search-CNVs9k1o.js.map +1 -0
  13. package/dist/chunks/line-chart-Cm_Ac7f4.js +22 -0
  14. package/dist/chunks/line-chart-Cm_Ac7f4.js.map +1 -0
  15. package/dist/chunks/{trace-CjOi3_IP.js → trace-D1fOFzJt.js} +633 -622
  16. package/dist/chunks/trace-D1fOFzJt.js.map +1 -0
  17. package/dist/components/bar-chart.js +1 -1
  18. package/dist/components/chart.js +8 -5
  19. package/dist/components/code-block.js +12 -3
  20. package/dist/components/data-table.js +8 -8
  21. package/dist/components/line-chart.js +1 -1
  22. package/dist/components/trace.js +1 -1
  23. package/dist/index.js +175 -162
  24. package/dist/motion.js +14 -13
  25. package/dist/motion.js.map +1 -1
  26. package/dist/primitives.js +1 -1
  27. package/dist/sections/basic-page.js +2 -2
  28. package/dist/src/components/bar-chart/bar-chart.d.ts +9 -1
  29. package/dist/src/components/chart/chart.d.ts +25 -0
  30. package/dist/src/components/chart/format.d.ts +9 -5
  31. package/dist/src/components/chart/index.d.ts +7 -4
  32. package/dist/src/components/chart/scale.d.ts +2 -2
  33. package/dist/src/components/chart/shell.d.ts +20 -13
  34. package/dist/src/components/chart/skeleton.d.ts +11 -0
  35. package/dist/src/components/chart/theme.d.ts +8 -0
  36. package/dist/src/components/chart/types.d.ts +39 -2
  37. package/dist/src/components/chart/use-measure.d.ts +2 -1
  38. package/dist/src/components/code-block/code-block.d.ts +23 -11
  39. package/dist/src/components/code-block/highlight.d.ts +24 -0
  40. package/dist/src/components/code-block/index.d.ts +4 -1
  41. package/dist/src/components/code-block/languages.d.ts +64 -0
  42. package/dist/src/components/code-block/pho-theme.d.ts +18 -0
  43. package/dist/src/components/code-block/tokens.d.ts +14 -0
  44. package/dist/src/components/data-table/chrome.d.ts +25 -0
  45. package/dist/src/components/data-table/data-table.d.ts +1 -2
  46. package/dist/src/components/line-chart/line-chart.d.ts +12 -3
  47. package/dist/src/components/trace/trace.d.ts +15 -4
  48. package/dist/src/motion/index.d.ts +6 -0
  49. package/dist/src/sections/basic-page/basic-page.d.ts +2 -0
  50. package/package.json +4 -1
  51. package/src/styles/theme.css +17 -4
  52. package/dist/chunks/IconArrowsMinimize-BfPUGuCB.js +0 -75
  53. package/dist/chunks/IconArrowsMinimize-BfPUGuCB.js.map +0 -1
  54. package/dist/chunks/bar-chart-DIALC2_z.js +0 -190
  55. package/dist/chunks/bar-chart-DIALC2_z.js.map +0 -1
  56. package/dist/chunks/basic-page-BUmntB7L.js.map +0 -1
  57. package/dist/chunks/code-block-BuFfh0zH.js +0 -197
  58. package/dist/chunks/code-block-BuFfh0zH.js.map +0 -1
  59. package/dist/chunks/data-table-Mog6m3d9.js.map +0 -1
  60. package/dist/chunks/ghost-search-AmVXd0zE.js +0 -25
  61. package/dist/chunks/ghost-search-AmVXd0zE.js.map +0 -1
  62. package/dist/chunks/legend-C0mU7dqd.js +0 -60
  63. package/dist/chunks/legend-C0mU7dqd.js.map +0 -1
  64. package/dist/chunks/line-chart-VuMYKzW3.js +0 -453
  65. package/dist/chunks/line-chart-VuMYKzW3.js.map +0 -1
  66. package/dist/chunks/trace-CjOi3_IP.js.map +0 -1
  67. package/dist/chunks/use-measure-C-i54AC6.js +0 -629
  68. package/dist/chunks/use-measure-C-i54AC6.js.map +0 -1
  69. package/dist/src/components/chart/axes.d.ts +0 -22
@@ -1 +0,0 @@
1
- {"version":3,"file":"trace-CjOi3_IP.js","names":["__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode","__iconNode"],"sources":["../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowNarrowRight.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconArrowsExchange.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronsDown.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconChevronsUp.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconDatabase.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconFileSearch.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconMessage.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconRobot.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconSparkles.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconTool.mjs","../../../../node_modules/.pnpm/@tabler+icons-react@3.46.0_react@19.2.8/node_modules/@tabler/icons-react/dist/esm/icons/IconWorld.mjs","../../src/components/trace/span-tree.ts","../../src/components/trace/span-primitive.tsx","../../src/components/trace/decorations.ts","../../src/components/trace/layout.ts","../../src/components/trace/trace.tsx"],"sourcesContent":["/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M5 12l14 0\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M15 16l4 -4\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M15 8l4 4\", \"key\": \"svg-2\" }]];\nconst IconArrowNarrowRight = createReactComponent(\"outline\", \"arrow-narrow-right\", \"ArrowNarrowRight\", __iconNode);\n\nexport { __iconNode, IconArrowNarrowRight as default };\n//# sourceMappingURL=IconArrowNarrowRight.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M7 10h14l-4 -4\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M17 14h-14l4 4\", \"key\": \"svg-1\" }]];\nconst IconArrowsExchange = createReactComponent(\"outline\", \"arrows-exchange\", \"ArrowsExchange\", __iconNode);\n\nexport { __iconNode, IconArrowsExchange as default };\n//# sourceMappingURL=IconArrowsExchange.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M7 7l5 5l5 -5\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M7 13l5 5l5 -5\", \"key\": \"svg-1\" }]];\nconst IconChevronsDown = createReactComponent(\"outline\", \"chevrons-down\", \"ChevronsDown\", __iconNode);\n\nexport { __iconNode, IconChevronsDown as default };\n//# sourceMappingURL=IconChevronsDown.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M7 11l5 -5l5 5\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M7 17l5 -5l5 5\", \"key\": \"svg-1\" }]];\nconst IconChevronsUp = createReactComponent(\"outline\", \"chevrons-up\", \"ChevronsUp\", __iconNode);\n\nexport { __iconNode, IconChevronsUp as default };\n//# sourceMappingURL=IconChevronsUp.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M4 6v6a8 3 0 0 0 16 0v-6\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M4 12v6a8 3 0 0 0 16 0v-6\", \"key\": \"svg-2\" }]];\nconst IconDatabase = createReactComponent(\"outline\", \"database\", \"Database\", __iconNode);\n\nexport { __iconNode, IconDatabase as default };\n//# sourceMappingURL=IconDatabase.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M14 3v4a1 1 0 0 0 1 1h4\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M12 21h-5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v4.5\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M14 17.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M18.5 19.5l2.5 2.5\", \"key\": \"svg-3\" }]];\nconst IconFileSearch = createReactComponent(\"outline\", \"file-search\", \"FileSearch\", __iconNode);\n\nexport { __iconNode, IconFileSearch as default };\n//# sourceMappingURL=IconFileSearch.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M8 9h8\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M8 13h6\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12\", \"key\": \"svg-2\" }]];\nconst IconMessage = createReactComponent(\"outline\", \"message\", \"Message\", __iconNode);\n\nexport { __iconNode, IconMessage as default };\n//# sourceMappingURL=IconMessage.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M6 6a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -4\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M12 2v2\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M9 12v9\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M15 12v9\", \"key\": \"svg-3\" }], [\"path\", { \"d\": \"M5 16l4 -2\", \"key\": \"svg-4\" }], [\"path\", { \"d\": \"M15 14l4 2\", \"key\": \"svg-5\" }], [\"path\", { \"d\": \"M9 18h6\", \"key\": \"svg-6\" }], [\"path\", { \"d\": \"M10 8v.01\", \"key\": \"svg-7\" }], [\"path\", { \"d\": \"M14 8v.01\", \"key\": \"svg-8\" }]];\nconst IconRobot = createReactComponent(\"outline\", \"robot\", \"Robot\", __iconNode);\n\nexport { __iconNode, IconRobot as default };\n//# sourceMappingURL=IconRobot.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6\", \"key\": \"svg-0\" }]];\nconst IconSparkles = createReactComponent(\"outline\", \"sparkles\", \"Sparkles\", __iconNode);\n\nexport { __iconNode, IconSparkles as default };\n//# sourceMappingURL=IconSparkles.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M7 10h3v-3l-3.5 -3.5a6 6 0 0 1 8 8l6 6a2 2 0 0 1 -3 3l-6 -6a6 6 0 0 1 -8 -8l3.5 3.5\", \"key\": \"svg-0\" }]];\nconst IconTool = createReactComponent(\"outline\", \"tool\", \"Tool\", __iconNode);\n\nexport { __iconNode, IconTool as default };\n//# sourceMappingURL=IconTool.mjs.map\n","/**\n * @license @tabler/icons-react v3.46.0 - MIT\n *\n * This source code is licensed under the MIT license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createReactComponent from '../createReactComponent.mjs';\n\nconst __iconNode = [[\"path\", { \"d\": \"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0\", \"key\": \"svg-0\" }], [\"path\", { \"d\": \"M3.6 9h16.8\", \"key\": \"svg-1\" }], [\"path\", { \"d\": \"M3.6 15h16.8\", \"key\": \"svg-2\" }], [\"path\", { \"d\": \"M11.5 3a17 17 0 0 0 0 18\", \"key\": \"svg-3\" }], [\"path\", { \"d\": \"M12.5 3a17 17 0 0 1 0 18\", \"key\": \"svg-4\" }]];\nconst IconWorld = createReactComponent(\"outline\", \"world\", \"World\", __iconNode);\n\nexport { __iconNode, IconWorld as default };\n//# sourceMappingURL=IconWorld.mjs.map\n","/**\n * The span tree, apart from React: the shape a waterfall needs from a flat\n * list of spans, and the arithmetic on it. Everything here is pure and\n * runs the same on the server.\n *\n * The edge cases follow Jaeger UI's trace model (Apache-2.0, reimplemented\n * from its behaviour, not its code): a parent the trace does not have makes\n * an orphan, not a crash; a cycle is broken where it closes; a span with no\n * usable start inherits its parent's instead of dragging the axis to the\n * epoch; an error under a folded parent stays countable; a client span\n * remembers its server child so a fold can still name the peer.\n */\n\nexport type SpanStatus = \"running\" | \"completed\" | \"failed\" | \"skipped\";\n\n/** OpenTelemetry's span kinds, lower-cased. */\nexport type SpanKind =\n \"client\" | \"server\" | \"producer\" | \"consumer\" | \"internal\";\n\nexport interface SpanData {\n id: string;\n /** The span this one runs inside; `null` for a root. */\n parentSpanId: string | null;\n name: string;\n /** The category — http, db, llm, tool. */\n type: string;\n status: SpanStatus;\n /** Start, in ms, on any shared clock — only the differences matter. */\n startedAt: number;\n /** End, in ms; `null` while the span still runs. */\n endedAt: number | null;\n /** The measured duration, when the tracer reports one. */\n latencyMs: number | null;\n /** OpenTelemetry kind, when known — a `client` fold can name its server. */\n kind?: SpanKind;\n /** The service (resource) the span ran in. */\n service?: string;\n /** Flat OpenTelemetry attributes — `http.response.status_code`, `db.system`. */\n attributes?: Readonly<Record<string, unknown>>;\n}\n\n/** A span as the tree knows it: its data plus its place in the tree. */\nexport interface SpanItemState extends SpanData {\n depth: number;\n hasChildren: boolean;\n isCollapsed: boolean;\n /** Every span beneath this one, at any depth, folded or not. */\n descendants: number;\n /** How many of those failed. */\n descendantErrors: number;\n /** Named a parent the trace does not have (or one in a cycle); shown as a root. */\n orphan: boolean;\n /** Its start or end was missing or not a number and was repaired. */\n repaired: boolean;\n /** For a `client` span: the first direct child that is a `server` span. */\n serverChildId: string | null;\n}\n\nexport interface SpanTimelineRange {\n min: number;\n max: number;\n}\n\n/** A zoom window, as fractions of the trace's range. `[0, 1]` is all of it. */\nexport type SpanView = readonly [start: number, end: number];\n\nexport const FULL_VIEW: SpanView = [0, 1];\n\n/** The narrowest a zoom window goes, as a fraction of the trace. */\nexport const MIN_VIEW_WIDTH = 0.001;\n\nexport interface SpanTree {\n /** Every span, root first, each parent before its children, siblings by start. */\n spans: readonly SpanItemState[];\n byId: ReadonlyMap<string, SpanItemState>;\n /** Spans whose parent the trace does not have. */\n orphans: number;\n /** Spans whose start or end had to be repaired. */\n repaired: number;\n}\n\nconst finite = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value);\n\n/* --------------------------------- tree --------------------------------- */\n\n/**\n * Each span's parent, made safe: a parent not in the list becomes none,\n * and a cycle is broken at the span where it closes. The second set is\n * every span whose parent link had to be dropped.\n */\nfunction normalizeParents(byId: ReadonlyMap<string, SpanData>): {\n parents: Map<string, string | null>;\n orphans: Set<string>;\n} {\n const parents = new Map<string, string | null>();\n const orphans = new Set<string>();\n for (const span of byId.values()) {\n if (span.parentSpanId != null && byId.has(span.parentSpanId)) {\n parents.set(span.id, span.parentSpanId);\n } else {\n parents.set(span.id, null);\n if (span.parentSpanId != null) orphans.add(span.id);\n }\n }\n const resolved = new Set<string>();\n for (const id of byId.keys()) {\n if (resolved.has(id)) continue;\n const path: string[] = [];\n const onPath = new Set<string>();\n let current: string | null = id;\n while (current !== null && !resolved.has(current)) {\n if (onPath.has(current)) {\n parents.set(current, null);\n orphans.add(current);\n break;\n }\n path.push(current);\n onPath.add(current);\n current = parents.get(current) ?? null;\n }\n for (const seen of path) resolved.add(seen);\n }\n return { parents, orphans };\n}\n\n/**\n * Derive the tree once from the flat list: depth, order, descendants and\n * their errors, orphans, repaired times, and each client's server child.\n * Nothing here depends on folding; see `visibleSpans` for that.\n */\nexport function deriveSpanTree(spans: readonly SpanData[]): SpanTree {\n const source = new Map(spans.map((span) => [span.id, span]));\n const { parents, orphans } = normalizeParents(source);\n const children = new Map<string | null, SpanData[]>();\n for (const span of source.values()) {\n const parent = parents.get(span.id) ?? null;\n const list = children.get(parent) ?? [];\n list.push(span);\n children.set(parent, list);\n }\n // A root with no usable start takes the earliest real one in the trace,\n // not the epoch, so one bad span never stretches the axis.\n let fallbackStart = Infinity;\n for (const span of source.values()) {\n if (finite(span.startedAt) && span.startedAt < fallbackStart) {\n fallbackStart = span.startedAt;\n }\n }\n if (fallbackStart === Infinity) fallbackStart = 0;\n\n const repair = (span: SpanData, parentStart: number | null) => {\n let repaired = false;\n let startedAt = span.startedAt;\n if (!finite(startedAt)) {\n startedAt = parentStart ?? fallbackStart;\n repaired = true;\n }\n let endedAt = span.endedAt;\n if (endedAt != null && (!finite(endedAt) || endedAt < startedAt)) {\n endedAt = startedAt;\n repaired = true;\n }\n const latencyMs =\n finite(span.latencyMs) && span.latencyMs >= 0 ? span.latencyMs : null;\n return { startedAt, endedAt, latencyMs, repaired };\n };\n\n const out: SpanItemState[] = [];\n const byId = new Map<string, SpanItemState>();\n let repairedCount = 0;\n const visit = (\n span: SpanData,\n depth: number,\n parentStart: number | null,\n ): SpanItemState => {\n const fixed = repair(span, parentStart);\n const kids = children.get(span.id) ?? [];\n const item: SpanItemState = {\n ...span,\n parentSpanId: parents.get(span.id) ?? null,\n startedAt: fixed.startedAt,\n endedAt: fixed.endedAt,\n latencyMs: fixed.latencyMs,\n depth,\n hasChildren: kids.length > 0,\n isCollapsed: false,\n descendants: 0,\n descendantErrors: 0,\n orphan: orphans.has(span.id),\n repaired: fixed.repaired,\n serverChildId: null,\n };\n if (fixed.repaired) repairedCount += 1;\n out.push(item);\n byId.set(item.id, item);\n // Children repair against this span's fixed start, then sort — so the\n // comparator never sees NaN and the order is the same on every engine.\n const fixedKids = kids.map((kid) => ({\n kid,\n start: finite(kid.startedAt) ? kid.startedAt : fixed.startedAt,\n }));\n fixedKids.sort((a, b) => a.start - b.start);\n let descendants = 0;\n let descendantErrors = 0;\n for (const { kid } of fixedKids) {\n const child = visit(kid, depth + 1, fixed.startedAt);\n descendants += 1 + child.descendants;\n descendantErrors +=\n (child.status === \"failed\" ? 1 : 0) + child.descendantErrors;\n if (\n item.kind === \"client\" &&\n item.serverChildId == null &&\n child.kind === \"server\"\n ) {\n item.serverChildId = child.id;\n }\n }\n item.descendants = descendants;\n item.descendantErrors = descendantErrors;\n return item;\n };\n const roots = (children.get(null) ?? []).map((root) => ({\n root,\n start: finite(root.startedAt) ? root.startedAt : fallbackStart,\n }));\n roots.sort((a, b) => a.start - b.start);\n for (const { root } of roots) visit(root, 0, null);\n return { spans: out, byId, orphans: orphans.size, repaired: repairedCount };\n}\n\n/**\n * The visible rows: the tree in reading order with every folded parent's\n * subtree left out. Untouched items keep their identity; a folded parent\n * is a copy with `isCollapsed` set.\n */\nexport function visibleSpans(\n tree: SpanTree,\n collapsed: ReadonlySet<string>,\n): SpanItemState[] {\n const out: SpanItemState[] = [];\n let hideDeeperThan: number | null = null;\n for (const span of tree.spans) {\n if (hideDeeperThan != null) {\n if (span.depth > hideDeeperThan) continue;\n hideDeeperThan = null;\n }\n if (collapsed.has(span.id)) {\n out.push({ ...span, isCollapsed: true });\n if (span.hasChildren) hideDeeperThan = span.depth;\n } else {\n out.push(span);\n }\n }\n return out;\n}\n\n/** Derive and fold in one step — `visibleSpans(deriveSpanTree(spans), collapsed)`. */\nexport function buildSpanTree(\n spans: readonly SpanData[],\n collapsed: ReadonlySet<string> = new Set(),\n): SpanItemState[] {\n return visibleSpans(deriveSpanTree(spans), collapsed);\n}\n\n/** The ids above a span, nearest parent first. */\nexport function ancestorIds(\n byId: ReadonlyMap<string, Pick<SpanItemState, \"parentSpanId\">>,\n id: string,\n): string[] {\n const out: string[] = [];\n let current = byId.get(id)?.parentSpanId ?? null;\n while (current != null && !out.includes(current)) {\n out.push(current);\n current = byId.get(current)?.parentSpanId ?? null;\n }\n return out;\n}\n\n/* -------------------------------- folding ------------------------------- */\n\n/** Every parent — the fold state after \"collapse all\". */\nexport function collapseAllIds(spans: readonly SpanItemState[]): string[] {\n return spans.filter((span) => span.hasChildren).map((span) => span.id);\n}\n\n/** True when every parent is already folded, so \"collapse\" has nothing to do. */\nexport function allCollapsed(\n spans: readonly SpanItemState[],\n collapsed: ReadonlySet<string>,\n): boolean {\n return spans\n .filter((span) => span.hasChildren)\n .every((span) => collapsed.has(span.id));\n}\n\n/**\n * Fold one level: the deepest open parent on every branch closes. Pressed\n * again, the level above; and so on up to the roots.\n */\nexport function collapseOneLevel(\n spans: readonly SpanItemState[],\n collapsed: ReadonlySet<string>,\n): string[] {\n const next = new Set(collapsed);\n let nearest: SpanItemState | undefined;\n for (const span of spans) {\n if (nearest && span.depth <= nearest.depth) {\n next.add(nearest.id);\n nearest = span.hasChildren && !next.has(span.id) ? span : undefined;\n } else if (span.hasChildren && !next.has(span.id)) {\n nearest = span;\n }\n }\n if (nearest) next.add(nearest.id);\n return Array.from(next);\n}\n\n/**\n * Open one level: the shallowest folded parent on every branch opens.\n * The inverse of `collapseOneLevel`.\n */\nexport function expandOneLevel(\n spans: readonly SpanItemState[],\n collapsed: ReadonlySet<string>,\n): string[] {\n const next = new Set(collapsed);\n let openedDepth = -1;\n let openNext = true;\n for (const span of spans) {\n if (span.depth <= openedDepth) openNext = true;\n if (openNext && next.has(span.id)) {\n next.delete(span.id);\n openNext = false;\n openedDepth = span.depth;\n }\n }\n return Array.from(next);\n}\n\n/* --------------------------------- range -------------------------------- */\n\n/**\n * The trace runs from the earliest start to the latest end. A running\n * span ends at `now` when there is one; otherwise it counts only its\n * start, and its bar stretches to whatever the rest of the trace spans.\n */\nexport function traceRange(\n spans: readonly Pick<SpanData, \"startedAt\" | \"endedAt\">[],\n now?: number,\n): SpanTimelineRange {\n let min = Infinity;\n let max = -Infinity;\n for (const span of spans) {\n if (!finite(span.startedAt)) continue;\n if (span.startedAt < min) min = span.startedAt;\n const end = finite(span.endedAt) ? span.endedAt : (now ?? span.startedAt);\n if (end > max) max = end;\n }\n if (min === Infinity) return { min: 0, max: 0 };\n return { min, max: Math.max(max, min) };\n}\n\nconst clamp01 = (value: number) => Math.min(1, Math.max(0, value));\n\n/** A zoom window made sane: ordered, inside `[0, 1]`, never thinner than the minimum. */\nexport function clampView(view: SpanView): SpanView {\n let [start, end] = view;\n if (!finite(start)) start = 0;\n if (!finite(end)) end = 1;\n if (end < start) [start, end] = [end, start];\n start = clamp01(start);\n end = clamp01(end);\n if (end - start < MIN_VIEW_WIDTH) {\n const mid = (start + end) / 2;\n start = clamp01(mid - MIN_VIEW_WIDTH / 2);\n end = clamp01(start + MIN_VIEW_WIDTH);\n start = end - MIN_VIEW_WIDTH;\n }\n return [start, end];\n}\n\n/** The window's part of the range, in the range's units. */\nexport function viewToRange(\n range: SpanTimelineRange,\n view: SpanView,\n): SpanTimelineRange {\n const length = range.max - range.min;\n return {\n min: range.min + view[0] * length,\n max: range.min + view[1] * length,\n };\n}\n\n/**\n * Scale the window by `factor` (below 1 zooms in) around `anchor`, a\n * fraction of the *window*; the point under the anchor stays put.\n */\nexport function zoomView(\n view: SpanView,\n factor: number,\n anchor = 0.5,\n): SpanView {\n const [start, end] = view;\n const width = end - start;\n const nextWidth = Math.min(1, Math.max(MIN_VIEW_WIDTH, width * factor));\n const pivot = start + anchor * width;\n let nextStart = pivot - anchor * nextWidth;\n nextStart = Math.min(Math.max(nextStart, 0), 1 - nextWidth);\n return clampView([nextStart, nextStart + nextWidth]);\n}\n\n/** Slide the window by `delta` of its own width; it stops at either end. */\nexport function panView(view: SpanView, delta: number): SpanView {\n const [start, end] = view;\n const width = end - start;\n let nextStart = start + delta * width;\n nextStart = Math.min(Math.max(nextStart, 0), 1 - width);\n return clampView([nextStart, nextStart + width]);\n}\n\n/** Map a window-relative fraction (a pointer on the axis) to a trace fraction. */\nexport function viewFraction(view: SpanView, at: number): number {\n return view[0] + at * (view[1] - view[0]);\n}\n\nexport function isFullView(view: SpanView): boolean {\n return view[0] <= 0 && view[1] >= 1;\n}\n\n/**\n * Where a span's bar sits along a range, in percent. A running span ends\n * at `now`, or at the range's end without one; everything clamps to the\n * range so a bar never leaves the track, and the clipped flags say when\n * it did.\n */\nexport function spanTimelineBarVars({\n startedAt,\n endedAt,\n timeRange,\n now,\n}: {\n startedAt: number;\n endedAt: number | null;\n timeRange: SpanTimelineRange;\n now?: number;\n}) {\n const rangeMs = Math.max(1, timeRange.max - timeRange.min);\n const effectiveEnd = endedAt ?? now ?? timeRange.max;\n const rawLeft = ((startedAt - timeRange.min) / rangeMs) * 100;\n const rawEnd = ((effectiveEnd - timeRange.min) / rangeMs) * 100;\n const leftPercent = Math.min(100, Math.max(0, rawLeft));\n const endPercent = Math.min(100, Math.max(leftPercent, rawEnd));\n return {\n leftPercent,\n endPercent,\n widthPercent: endPercent - leftPercent,\n durationMs: Math.max(0, effectiveEnd - startedAt),\n effectiveEnd,\n clippedStart: rawLeft < 0 && rawEnd > 0,\n clippedEnd: rawEnd > 100 && rawLeft < 100,\n };\n}\n\n/* -------------------------------- search -------------------------------- */\n\nfunction stringify(value: unknown): string {\n if (value == null) return \"\";\n if (typeof value === \"object\") {\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n }\n return String(value);\n}\n\n/**\n * Which spans a query names. Space-separated terms, any of which may\n * match; `\"a phrase\"` keeps its spaces; `-key` leaves an attribute out\n * of the matching. A term matches the name, the service, the type, the\n * kind, the exact id, or an attribute's key, value, or `key=value`.\n * `null` for a blank query.\n */\nexport function filterSpans(\n query: string | null | undefined,\n spans: readonly SpanData[],\n): Set<string> | null {\n if (query == null || query.trim() === \"\") return null;\n const include: string[] = [];\n const exclude: string[] = [];\n for (const raw of query.match(/[^\\s\"]+|\"([^\"]*)\"/g) ?? []) {\n const term = raw.replace(/^\"(.*)\"$/, \"$1\").toLowerCase();\n if (!term) continue;\n if (term.startsWith(\"-\") && term.length > 1) exclude.push(term.slice(1));\n else include.push(term);\n }\n if (include.length === 0) return new Set();\n const hit = (text: string) => {\n const lower = text.toLowerCase();\n return include.some((term) => lower.includes(term));\n };\n const excluded = (key: string) => {\n const lower = key.toLowerCase();\n return exclude.some((term) => lower.includes(term));\n };\n const out = new Set<string>();\n for (const span of spans) {\n if (\n hit(span.name) ||\n (span.service != null && hit(span.service)) ||\n (span.type !== \"\" && hit(span.type)) ||\n (span.kind != null && hit(span.kind)) ||\n include.some((term) => term === span.id.toLowerCase())\n ) {\n out.add(span.id);\n continue;\n }\n const attributes = span.attributes;\n if (attributes == null) continue;\n for (const key of Object.keys(attributes)) {\n if (excluded(key)) continue;\n const value = stringify(attributes[key]);\n if (value === \"\") continue;\n if (hit(key) || hit(value) || hit(`${key}=${value}`)) {\n out.add(span.id);\n break;\n }\n }\n }\n return out;\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type CSSProperties,\n type MouseEvent,\n type ReactNode,\n} from \"react\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport {\n FULL_VIEW,\n allCollapsed,\n ancestorIds,\n clampView,\n collapseAllIds,\n collapseOneLevel,\n deriveSpanTree,\n expandOneLevel,\n filterSpans,\n isFullView,\n panView,\n spanTimelineBarVars,\n traceRange,\n viewToRange,\n visibleSpans,\n zoomView,\n type SpanData,\n type SpanItemState,\n type SpanTimelineRange,\n type SpanView,\n} from \"./span-tree\";\n\n/**\n * SpanPrimitive — headless parts for a tree of spans: the pieces a\n * waterfall, a timeline, or a run inspector is composed from, with no\n * styling of their own.\n *\n * Modelled on `@assistant-ui/react-o11y`'s `SpanPrimitive` (same data\n * attributes, same CSS variables, same part names) so a host that knows\n * that shape can style either — but with no store behind it: the tree is\n * derived once per change and shared through plain context, folding is\n * controllable, and every part takes Base UI's `render` prop in place of\n * Radix's `asChild`. The tree's edge cases and the fold, search, and\n * zoom arithmetic come from Jaeger UI's trace view; see `span-tree.ts`.\n *\n * - `Provider` takes the flat `SpanData[]`, derives the tree (depth,\n * order, descendants and their errors, orphans, repaired times) and\n * the time range, and owns the fold, the search matches, and the zoom\n * window — each uncontrolled by default, controlled with a prop.\n * - `Children` renders each visible span in turn, root first, parents\n * before their children, siblings by start; a folded parent hides its\n * subtree. Inside it, `useSpan()` is the current span and\n * `useSpanTree()` the whole tree with its actions.\n * - `Root`, `Indent`, `CollapseToggle`, `StatusIndicator`, `TypeBadge`,\n * `Name` are the row's parts; `Timeline` supplies the (zoomed) range\n * as CSS variables and `TimelineBar` places the current span along it.\n */\n\nexport interface SpanTreeContextValue {\n /** The visible rows, in reading order. */\n spans: readonly SpanItemState[];\n /** Every span, folded or not, in reading order. */\n all: readonly SpanItemState[];\n byId: ReadonlyMap<string, SpanItemState>;\n /** Spans whose parent the trace does not have. */\n orphans: number;\n /** Spans whose start or end had to be repaired. */\n repaired: number;\n /** The whole trace. */\n range: SpanTimelineRange;\n /** The zoom window, as fractions of the trace. */\n view: SpanView;\n /** The part of the range the window shows. */\n viewRange: SpanTimelineRange;\n zoomed: boolean;\n now: number | undefined;\n collapsed: ReadonlySet<string>;\n toggle: (id: string) => void;\n setCollapsed: (ids: readonly string[]) => void;\n expandAll: () => void;\n collapseAll: () => void;\n /** Open the shallowest folded parent on every branch. */\n expandOne: () => void;\n /** Fold the deepest open parent on every branch. */\n collapseOne: () => void;\n canExpand: boolean;\n canCollapse: boolean;\n query: string;\n /** The spans the query names; `null` with no query. */\n matches: ReadonlySet<string> | null;\n setView: (view: SpanView) => void;\n /** Scale the window; below 1 zooms in. `anchor` is a fraction of the window. */\n zoom: (factor: number, anchor?: number) => void;\n /** Slide the window by a fraction of its own width. */\n pan: (delta: number) => void;\n resetView: () => void;\n}\n\nconst SpanTreeContext = createContext<SpanTreeContextValue | null>(null);\nconst SpanContext = createContext<SpanItemState | null>(null);\nconst SpanTimelineContext = createContext<SpanTimelineRange | null>(null);\n\n/** The whole tree: visible spans, the ranges, and the fold / search / zoom actions. */\nexport function useSpanTree(): SpanTreeContextValue {\n const value = useContext(SpanTreeContext);\n if (value == null) {\n throw new Error(\n \"SpanPrimitive parts render inside SpanPrimitive.Provider.\",\n );\n }\n return value;\n}\n\n/** The span this part belongs to — set by `SpanPrimitive.Children`. */\nexport function useSpan(): SpanItemState {\n const value = useContext(SpanContext);\n if (value == null) {\n throw new Error(\n \"SpanPrimitive parts render inside SpanPrimitive.Children.\",\n );\n }\n return value;\n}\n\n/* ------------------------------- provider ------------------------------- */\n\nexport interface SpanProviderProps {\n spans: readonly SpanData[];\n /** Spans folded at first (uncontrolled). */\n defaultCollapsed?: readonly string[];\n /** Spans folded (controlled). */\n collapsed?: readonly string[];\n onCollapsedChange?: (ids: string[]) => void;\n /** The current time on the spans' clock — where a running span ends. */\n now?: number;\n /**\n * A search over the spans (see `filterSpans`). Matching spans are\n * `matches`; their folded ancestors open so every match is in view.\n */\n query?: string;\n /** Leave folded ancestors of matches folded. */\n keepFoldsOnMatch?: boolean;\n /** The zoom window at first (uncontrolled). */\n defaultView?: SpanView;\n /** The zoom window (controlled). */\n view?: SpanView;\n onViewChange?: (view: SpanView) => void;\n children: ReactNode;\n}\n\nconst EMPTY: readonly string[] = [];\n\nfunction Provider({\n spans,\n defaultCollapsed,\n collapsed: collapsedProp,\n onCollapsedChange,\n now,\n query = \"\",\n keepFoldsOnMatch = false,\n defaultView,\n view: viewProp,\n onViewChange,\n children,\n}: SpanProviderProps) {\n const tree = useMemo(() => deriveSpanTree(spans), [spans]);\n\n const [ownCollapsed, setOwnCollapsed] = useState<readonly string[]>(\n () => defaultCollapsed ?? EMPTY,\n );\n const collapsedList = collapsedProp ?? ownCollapsed;\n const collapsed = useMemo(() => new Set(collapsedList), [collapsedList]);\n const setCollapsed = useCallback(\n (ids: readonly string[]) => {\n const list = Array.from(new Set(ids));\n if (collapsedProp == null) setOwnCollapsed(list);\n onCollapsedChange?.(list);\n },\n [collapsedProp, onCollapsedChange],\n );\n const toggle = useCallback(\n (id: string) => {\n const next = new Set(collapsed);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n setCollapsed(Array.from(next));\n },\n [collapsed, setCollapsed],\n );\n const { spans: all, byId } = tree;\n const expandAll = useCallback(() => setCollapsed(EMPTY), [setCollapsed]);\n const collapseAll = useCallback(\n () => setCollapsed(collapseAllIds(all)),\n [all, setCollapsed],\n );\n const expandOne = useCallback(\n () => setCollapsed(expandOneLevel(all, collapsed)),\n [all, collapsed, setCollapsed],\n );\n const collapseOne = useCallback(\n () => setCollapsed(collapseOneLevel(all, collapsed)),\n [all, collapsed, setCollapsed],\n );\n const canCollapse = !allCollapsed(all, collapsed);\n const canExpand = all.some(\n (span) => span.hasChildren && collapsed.has(span.id),\n );\n\n const matches = useMemo(() => filterSpans(query, all), [query, all]);\n // A match under a folded parent would be invisible: open its ancestors.\n useEffect(() => {\n if (keepFoldsOnMatch || matches == null || matches.size === 0) return;\n const open = new Set<string>();\n for (const id of matches) {\n for (const ancestor of ancestorIds(byId, id)) {\n if (collapsed.has(ancestor)) open.add(ancestor);\n }\n }\n if (open.size === 0) return;\n setCollapsed(collapsedList.filter((id) => !open.has(id)));\n }, [matches, keepFoldsOnMatch, byId, collapsed, collapsedList, setCollapsed]);\n\n const rows = useMemo(() => visibleSpans(tree, collapsed), [tree, collapsed]);\n const range = useMemo(() => traceRange(all, now), [all, now]);\n\n const [ownView, setOwnView] = useState<SpanView>(() =>\n clampView(defaultView ?? FULL_VIEW),\n );\n const view = useMemo(\n () => clampView(viewProp ?? ownView),\n [viewProp, ownView],\n );\n const setView = useCallback(\n (next: SpanView) => {\n const safe = clampView(next);\n if (viewProp == null) setOwnView(safe);\n onViewChange?.(safe);\n },\n [viewProp, onViewChange],\n );\n const zoom = useCallback(\n (factor: number, anchor?: number) =>\n setView(zoomView(view, factor, anchor)),\n [view, setView],\n );\n const pan = useCallback(\n (delta: number) => setView(panView(view, delta)),\n [view, setView],\n );\n const resetView = useCallback(() => setView(FULL_VIEW), [setView]);\n const viewRange = useMemo(() => viewToRange(range, view), [range, view]);\n\n const value = useMemo<SpanTreeContextValue>(\n () => ({\n spans: rows,\n all,\n byId,\n orphans: tree.orphans,\n repaired: tree.repaired,\n range,\n view,\n viewRange,\n zoomed: !isFullView(view),\n now,\n collapsed,\n toggle,\n setCollapsed,\n expandAll,\n collapseAll,\n expandOne,\n collapseOne,\n canExpand,\n canCollapse,\n query,\n matches,\n setView,\n zoom,\n pan,\n resetView,\n }),\n [\n rows,\n all,\n byId,\n tree.orphans,\n tree.repaired,\n range,\n view,\n viewRange,\n now,\n collapsed,\n toggle,\n setCollapsed,\n expandAll,\n collapseAll,\n expandOne,\n collapseOne,\n canExpand,\n canCollapse,\n query,\n matches,\n setView,\n zoom,\n pan,\n resetView,\n ],\n );\n return (\n <SpanTreeContext.Provider value={value}>\n {children}\n </SpanTreeContext.Provider>\n );\n}\n\n/* ------------------------------- children ------------------------------- */\n\nexport interface SpanChildrenProps {\n /** Rendered once per visible span; `useSpan()` inside reads that span. */\n children: (span: SpanItemState) => ReactNode;\n}\n\nfunction Children({ children }: SpanChildrenProps) {\n const { spans } = useSpanTree();\n return spans.map((span) => (\n <SpanContext.Provider key={span.id} value={span}>\n {children(span)}\n </SpanContext.Provider>\n ));\n}\n\n/* --------------------------------- parts -------------------------------- */\n\nexport type SpanRootProps = useRender.ComponentProps<\"div\">;\n\n/**\n * The row: a div carrying the span's state as data attributes —\n * `data-span-id`, `-status`, `-type`, `-depth`, `-kind`, `data-collapsed`,\n * `data-match` while the search names it, `data-orphan` for a span\n * whose parent the trace lacks.\n */\nfunction Root({ render, ref, ...props }: SpanRootProps) {\n const span = useSpan();\n const { matches } = useSpanTree();\n return useRender({\n render,\n ref,\n defaultTagName: \"div\",\n props: {\n ...props,\n \"data-span-id\": span.id,\n \"data-span-status\": span.status,\n \"data-span-type\": span.type,\n \"data-span-depth\": span.depth,\n \"data-span-kind\": span.kind,\n \"data-collapsed\": span.isCollapsed ? \"\" : undefined,\n \"data-match\": matches?.has(span.id) ? \"\" : undefined,\n \"data-orphan\": span.orphan ? \"\" : undefined,\n },\n });\n}\n\nexport type SpanIndentProps = useRender.ComponentProps<\"div\"> & {\n /** Padding at depth 0, in px. @default 8 */\n baseIndent?: number;\n /** Padding added per level, in px. @default 12 */\n indentPerLevel?: number;\n};\n\n/** A div padded on the left for the span's depth. */\nfunction Indent({\n render,\n ref,\n baseIndent = 8,\n indentPerLevel = 12,\n style,\n ...props\n}: SpanIndentProps) {\n const span = useSpan();\n return useRender({\n render,\n ref,\n defaultTagName: \"div\",\n props: {\n ...props,\n style: {\n ...style,\n paddingLeft: baseIndent + span.depth * indentPerLevel,\n },\n \"data-span-depth\": span.depth,\n },\n });\n}\n\nexport type SpanCollapseToggleProps = useRender.ComponentProps<\"button\">;\n\n/** The fold button; renders nothing for a span with no children. */\nfunction CollapseToggle({\n render,\n ref,\n onClick,\n ...props\n}: SpanCollapseToggleProps) {\n const span = useSpan();\n const { toggle } = useSpanTree();\n return useRender({\n render,\n ref,\n enabled: span.hasChildren,\n defaultTagName: \"button\",\n props: {\n type: \"button\",\n ...props,\n \"data-collapsed\": span.isCollapsed ? \"\" : undefined,\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n event.stopPropagation();\n toggle(span.id);\n onClick?.(event);\n },\n },\n });\n}\n\nexport type SpanStatusIndicatorProps = useRender.ComponentProps<\"span\">;\n\n/**\n * A span carrying `data-span-status`, for a dot or an icon — and\n * `data-descendant-errors` while a fold hides failed spans beneath it.\n */\nfunction StatusIndicator({ render, ref, ...props }: SpanStatusIndicatorProps) {\n const span = useSpan();\n return useRender({\n render,\n ref,\n defaultTagName: \"span\",\n props: {\n ...props,\n \"data-span-status\": span.status,\n \"data-descendant-errors\":\n span.isCollapsed && span.descendantErrors > 0\n ? span.descendantErrors\n : undefined,\n },\n });\n}\n\nexport type SpanTypeBadgeProps = useRender.ComponentProps<\"span\">;\n\n/** The span's type as text, unless given children. */\nfunction TypeBadge({ render, ref, children, ...props }: SpanTypeBadgeProps) {\n const span = useSpan();\n return useRender({\n render,\n ref,\n defaultTagName: \"span\",\n props: {\n ...props,\n \"data-span-type\": span.type,\n children: children ?? span.type,\n },\n });\n}\n\nexport type SpanNameProps = useRender.ComponentProps<\"span\">;\n\n/** The span's name as text, unless given children. */\nfunction Name({ render, ref, children, ...props }: SpanNameProps) {\n const span = useSpan();\n return useRender({\n render,\n ref,\n defaultTagName: \"span\",\n props: { ...props, children: children ?? span.name },\n });\n}\n\n/* ------------------------------- timeline ------------------------------- */\n\ntype TimelineStyle = CSSProperties & {\n \"--span-timeline-min-ms\"?: number;\n \"--span-timeline-max-ms\"?: number;\n \"--span-timeline-range-ms\"?: number;\n \"--span-timeline-left\"?: string;\n \"--span-timeline-end\"?: string;\n \"--span-timeline-width\"?: string;\n \"--span-timeline-duration-ms\"?: number;\n \"--span-timeline-min-width\"?: string | number;\n};\n\nexport type SpanTimelineProps = useRender.ComponentProps<\"div\"> & {\n /** The range to draw against. @default the tree's zoom window */\n timeRange?: SpanTimelineRange;\n /** Room after the end, as a fraction of the range. @default 0 */\n paddingEnd?: number;\n};\n\n/**\n * The track every bar inside it is placed along. Exposes the range as\n * `--span-timeline-min-ms` / `-max-ms` / `-range-ms`.\n */\nfunction Timeline({\n render,\n ref,\n timeRange,\n paddingEnd = 0,\n style,\n ...props\n}: SpanTimelineProps) {\n const tree = useSpanTree();\n const range = useMemo(() => {\n const base = timeRange ?? tree.viewRange;\n const length = Math.max(1, base.max - base.min);\n return { min: base.min, max: base.max + length * Math.max(0, paddingEnd) };\n }, [timeRange, tree.viewRange, paddingEnd]);\n const rangeMs = Math.max(1, range.max - range.min);\n const vars: TimelineStyle = {\n ...style,\n \"--span-timeline-min-ms\": range.min,\n \"--span-timeline-max-ms\": range.max,\n \"--span-timeline-range-ms\": rangeMs,\n };\n const element = useRender({\n render,\n ref,\n defaultTagName: \"div\",\n props: { ...props, style: vars, \"data-span-timeline\": \"\" },\n });\n return (\n <SpanTimelineContext.Provider value={range}>\n {element}\n </SpanTimelineContext.Provider>\n );\n}\n\nexport type SpanTimelineBarProps = useRender.ComponentProps<\"div\"> & {\n /** Where a running span ends. @default the tree's `now`, else the range's end */\n now?: number;\n /** @default the nearest Timeline's range */\n timeRange?: SpanTimelineRange;\n};\n\n/**\n * The current span's bar, positioned absolutely from\n * `--span-timeline-left` and sized from `--span-timeline-width` (never\n * under `--span-timeline-min-width`, when the host sets one). Carries\n * `data-clipped-start` / `data-clipped-end` when the range cuts it off.\n */\nfunction TimelineBar({\n render,\n ref,\n now,\n timeRange,\n style,\n ...props\n}: SpanTimelineBarProps) {\n const span = useSpan();\n const tree = useSpanTree();\n const contextRange = useContext(SpanTimelineContext);\n const vars = spanTimelineBarVars({\n startedAt: span.startedAt,\n endedAt: span.endedAt,\n timeRange: timeRange ?? contextRange ?? tree.viewRange,\n now: now ?? tree.now,\n });\n const merged: TimelineStyle = {\n ...style,\n position: \"absolute\",\n insetInlineStart: \"var(--span-timeline-left)\",\n inlineSize:\n \"max(var(--span-timeline-width), var(--span-timeline-min-width, 0px))\",\n \"--span-timeline-left\": `${vars.leftPercent}%`,\n \"--span-timeline-end\": `${vars.endPercent}%`,\n \"--span-timeline-width\": `${vars.widthPercent}%`,\n \"--span-timeline-duration-ms\": vars.durationMs,\n };\n return useRender({\n render,\n ref,\n defaultTagName: \"div\",\n props: {\n ...props,\n style: merged,\n \"data-span-status\": span.status,\n \"data-span-type\": span.type,\n \"data-span-running\": span.endedAt === null ? \"\" : undefined,\n \"data-clipped-start\": vars.clippedStart ? \"\" : undefined,\n \"data-clipped-end\": vars.clippedEnd ? \"\" : undefined,\n },\n });\n}\n\nexport const SpanPrimitive = {\n Provider,\n Children,\n Root,\n Indent,\n CollapseToggle,\n StatusIndicator,\n TypeBadge,\n Name,\n Timeline,\n TimelineBar,\n};\n","/**\n * What a span's attributes say at a glance: one icon for its kind of work\n * and a pill or two for the facts worth reading in the row — the HTTP\n * status, the database, the model. The registry follows Jaeger UI's\n * span decorations (its behaviour, not its code): one entry per attribute\n * namespace, list order is precedence, a GenAI kind beats a namespace\n * icon so a row never carries two glyphs.\n */\n\nimport {\n IconArrowsExchange,\n IconDatabase,\n IconFileSearch,\n IconMessage,\n IconRobot,\n IconSparkles,\n IconTool,\n IconWorld,\n type Icon,\n} from \"@tabler/icons-react\";\n\nexport interface SpanPill {\n /** The attribute the value came from — the tooltip and the label for readers. */\n label: string;\n value: string;\n /** The value is a failure (a 5xx status). */\n error?: boolean;\n}\n\nexport interface SpanDecorationIcon {\n icon: Icon;\n /** What the icon means, for readers and the tooltip; absent for a plain namespace icon. */\n label?: string;\n}\n\nexport type GenAIKind = \"agent\" | \"llm\" | \"tool\" | \"retrieval\" | \"generic\";\n\ntype Attributes = Readonly<Record<string, unknown>> | undefined;\n\ninterface PillSource {\n label: string;\n keys: readonly string[];\n error?: (value: string) => boolean;\n}\n\ninterface Decoration {\n namespace: string;\n icon?: Icon;\n pills?: readonly PillSource[];\n}\n\nconst is5xx = (value: string) => {\n const code = Number(value.trim());\n return code >= 500 && code < 600;\n};\n\nconst DECORATIONS: readonly Decoration[] = [\n {\n namespace: \"db\",\n icon: IconDatabase,\n pills: [{ label: \"db.system\", keys: [\"db.system.name\", \"db.system\"] }],\n },\n {\n namespace: \"http\",\n icon: IconWorld,\n pills: [\n {\n label: \"http.status_code\",\n keys: [\"http.response.status_code\", \"http.status_code\"],\n error: is5xx,\n },\n { label: \"http.method\", keys: [\"http.request.method\", \"http.method\"] },\n ],\n },\n { namespace: \"messaging\", icon: IconMessage },\n {\n namespace: \"rpc\",\n icon: IconArrowsExchange,\n pills: [{ label: \"rpc.system\", keys: [\"rpc.system.name\", \"rpc.system\"] }],\n },\n {\n namespace: \"gen_ai\",\n pills: [{ label: \"gen_ai.request.model\", keys: [\"gen_ai.request.model\"] }],\n },\n];\n\nexport const GEN_AI_KINDS: Record<GenAIKind, { icon: Icon; label: string }> = {\n agent: { icon: IconRobot, label: \"Agent\" },\n llm: { icon: IconSparkles, label: \"LLM call\" },\n tool: { icon: IconTool, label: \"Tool call\" },\n retrieval: { icon: IconFileSearch, label: \"Retrieval\" },\n generic: { icon: IconSparkles, label: \"GenAI span\" },\n};\n\nconst GEN_AI_OPERATIONS: Record<string, GenAIKind> = {\n chat: \"llm\",\n text_completion: \"llm\",\n generate_content: \"llm\",\n execute_tool: \"tool\",\n invoke_agent: \"agent\",\n create_agent: \"agent\",\n embeddings: \"retrieval\",\n retrieve: \"retrieval\",\n};\n\n/** An attribute's value as text; objects as JSON, nothing for null. */\nexport function attributeText(value: unknown): string {\n if (value == null) return \"\";\n if (value instanceof Uint8Array) return JSON.stringify(Array.from(value));\n if (typeof value === \"object\") {\n try {\n return JSON.stringify(value);\n } catch {\n return \"[unserializable]\";\n }\n }\n return String(value).trim();\n}\n\n/** The first of `keys` with a non-empty value, as text. */\nexport function attribute(\n attributes: Attributes,\n keys: readonly string[],\n): string | null {\n if (attributes == null) return null;\n for (const key of keys) {\n if (!(key in attributes)) continue;\n const text = attributeText(attributes[key]);\n if (text !== \"\") return text;\n }\n return null;\n}\n\n/** The GenAI kind of a span, from `gen_ai.operation.name`; `generic` for any other `gen_ai.*`. */\nexport function genAIKind(attributes: Attributes): GenAIKind | null {\n if (attributes == null) return null;\n const operation = attribute(attributes, [\"gen_ai.operation.name\"]);\n if (operation != null) {\n return GEN_AI_OPERATIONS[operation.toLowerCase()] ?? \"generic\";\n }\n return Object.keys(attributes).some((key) => key.startsWith(\"gen_ai.\"))\n ? \"generic\"\n : null;\n}\n\n/** The one icon for a span, GenAI kind first, then the first namespace with one. */\nexport function spanDecorationIcon(\n attributes: Attributes,\n): SpanDecorationIcon | null {\n const kind = genAIKind(attributes);\n if (kind != null) return GEN_AI_KINDS[kind];\n if (attributes == null) return null;\n const namespaces = new Set<string>();\n for (const key of Object.keys(attributes)) {\n const dot = key.indexOf(\".\");\n if (dot > 0) namespaces.add(key.slice(0, dot));\n }\n for (const entry of DECORATIONS) {\n if (entry.icon && namespaces.has(entry.namespace))\n return { icon: entry.icon };\n }\n return null;\n}\n\n/** The pills for a span, in registry order. */\nexport function spanPills(attributes: Attributes): SpanPill[] {\n const out: SpanPill[] = [];\n if (attributes == null) return out;\n for (const entry of DECORATIONS) {\n for (const source of entry.pills ?? []) {\n const value = attribute(attributes, source.keys);\n if (value == null) continue;\n const pill: SpanPill = { label: source.label, value };\n if (source.error?.(value)) pill.error = true;\n out.push(pill);\n }\n }\n return out;\n}\n\n/** `peer.service` — the service a client span called, when it named one. */\nexport function peerService(attributes: Attributes): string | null {\n return attribute(attributes, [\"peer.service\", \"server.address\"]);\n}\n","/**\n * The waterfall's arithmetic, apart from the drawing. The tree itself —\n * depth, order, folding, the time range, the zoom window — is\n * `span-tree`'s; this file owns what that leaves out: the input shape's\n * defaults, a bar's place along a range as fractions, the axis ticks, and\n * the number formats.\n */\n\nimport type {\n SpanData,\n SpanKind,\n SpanStatus,\n SpanTimelineRange,\n} from \"./span-tree\";\n\nexport type TraceSpanStatus = SpanStatus;\nexport type TraceSpanKind = SpanKind;\nexport type TraceRange = SpanTimelineRange;\n\n/**\n * A span as the waterfall takes it — `SpanData` with its derivable\n * fields optional. A `SpanData` passes through unchanged.\n */\nexport interface TraceWaterfallSpan {\n id: string;\n /** The span this one runs inside. Absent (or unknown) means a root. */\n parentSpanId?: string | null;\n name: string;\n /** The category — http, db, llm, tool. Shows after the service as a hint. */\n type?: string;\n /** `completed` with an end, `running` without, unless told otherwise. */\n status?: TraceSpanStatus;\n /** OpenTelemetry kind. A folded `client` names its `server` child. */\n kind?: TraceSpanKind;\n /** Start, in ms, on any shared clock — only the differences matter. */\n startedAt: number;\n /** End, in ms; `null` (or absent) while the span still runs. */\n endedAt?: number | null;\n /** The measured duration; `endedAt - startedAt` when absent. */\n latencyMs?: number | null;\n /** A hint after the name — the service, the host. */\n service?: string;\n /**\n * Flat OpenTelemetry attributes. `http.response.status_code`,\n * `db.system`, `gen_ai.request.model` become pills; the namespace\n * picks the icon; `peer.service` names an uninstrumented callee; all\n * of them are searchable.\n */\n attributes?: Readonly<Record<string, unknown>>;\n}\n\n/** Fill in what the tree requires and the input left implicit. */\nexport function normalizeSpans(\n spans: readonly TraceWaterfallSpan[],\n): SpanData[] {\n return spans.map((span) => {\n const endedAt = span.endedAt ?? null;\n const data: SpanData = {\n id: span.id,\n parentSpanId: span.parentSpanId ?? null,\n name: span.name,\n type: span.type ?? \"\",\n status: span.status ?? (endedAt == null ? \"running\" : \"completed\"),\n startedAt: span.startedAt,\n endedAt,\n latencyMs:\n span.latencyMs ??\n (endedAt == null ? null : Math.max(0, endedAt - span.startedAt)),\n };\n if (span.kind != null) data.kind = span.kind;\n if (span.service != null) data.service = span.service;\n if (span.attributes != null) data.attributes = span.attributes;\n return data;\n });\n}\n\n/** How long a span took — or has taken so far, given `now`. */\nexport function spanDuration(\n span: Pick<SpanData, \"startedAt\" | \"endedAt\" | \"latencyMs\">,\n now?: number,\n): number | null {\n if (span.latencyMs != null) return Math.max(0, span.latencyMs);\n if (span.endedAt != null) return Math.max(0, span.endedAt - span.startedAt);\n if (now != null) return Math.max(0, now - span.startedAt);\n return null;\n}\n\nconst clamp01 = (value: number) => Math.min(1, Math.max(0, value));\n\n/**\n * A bar's start and length as fractions of the range — the same numbers\n * `SpanPrimitive.TimelineBar` draws with, for placing the label beside it.\n */\nexport function barGeometry(\n span: Pick<SpanData, \"startedAt\" | \"endedAt\">,\n range: TraceRange,\n now?: number,\n): { left: number; width: number } {\n const length = Math.max(1, range.max - range.min);\n const end = span.endedAt ?? now ?? range.max;\n const left = clamp01((span.startedAt - range.min) / length);\n const right = clamp01(Math.max(left, (end - range.min) / length));\n return { left, width: right - left };\n}\n\n/** A tick step from the 1 / 2 / 5 ladder so the axis has at most `max` ticks. */\nexport function niceStep(durationMs: number, max = 6): number {\n if (durationMs <= 0) return 1;\n const rough = durationMs / max;\n const power = 10 ** Math.floor(Math.log10(rough));\n for (const unit of [1, 2, 5, 10]) {\n if (unit * power >= rough) return unit * power;\n }\n return 10 * power;\n}\n\nexport interface AxisTick {\n /** Where along the track, as a fraction. */\n at: number;\n /** The time it marks, in ms from the trace's start. */\n ms: number;\n}\n\n/**\n * Tick marks for the window `[startMs, endMs]` of a trace, in ms from\n * the trace's start: round multiples of a nice step, so a zoomed axis\n * still reads `20 ms, 25 ms, 30 ms`. `[{ at: 0, ms: startMs }]` for a\n * window with no length.\n */\nexport function axisTicks(startMs: number, endMs: number): AxisTick[] {\n const length = endMs - startMs;\n if (!(length > 0)) return [{ at: 0, ms: startMs }];\n const step = niceStep(length);\n const ticks: AxisTick[] = [];\n const first = Math.ceil(startMs / step - 1e-9) * step;\n for (let ms = first; ms <= endMs + 1e-9; ms += step) {\n const rounded = Number(ms.toFixed(6));\n ticks.push({ at: (rounded - startMs) / length, ms: rounded });\n }\n return ticks;\n}\n\n/** \"0.42 ms\", \"59.2 ms\", \"1.25 s\" — the precision follows the size. */\nexport function formatDuration(ms: number): string {\n if (!Number.isFinite(ms)) return \"\";\n const abs = Math.abs(ms);\n if (abs < 10) return `${ms.toFixed(2)} ms`;\n if (abs < 100) return `${ms.toFixed(1)} ms`;\n if (abs < 1000) return `${Math.round(ms)} ms`;\n if (abs < 60_000) return `${(ms / 1000).toFixed(2)} s`;\n return `${(ms / 60_000).toFixed(1)} min`;\n}\n\n/** An axis tick's label: whole numbers where the step allows, \"2 s\" past a second. */\nexport function formatTick(ms: number): string {\n if (ms === 0) return \"0\";\n if (ms >= 1000) return `${Number((ms / 1000).toFixed(2))} s`;\n return `${Number(ms.toFixed(2))} ms`;\n}\n\n/** Approx width of one character of a 12px tabular-nums tick label. */\nconst TICK_CHAR_PX = 7.5;\n/** `left-1` / `right-1` on the label, plus a breath between neighbours. */\nconst TICK_PAD_PX = 4;\nconst TICK_GAP_PX = 4;\n\nexport interface TickLabel extends AxisTick {\n /** Which side of the mark the label sits: after it, or ending at it. */\n align: \"start\" | \"end\";\n}\n\n/**\n * Which tick marks get a label at this track width, and on which side.\n * Marks themselves always draw; a label hides when it would overlap the\n * previous one. A label that would run past the track's end ends at its\n * mark instead, and the label before it yields if the two would touch\n * (`40 ms` next to `50 ms` on a ~335px track).\n */\nexport function layoutTickLabels(\n ticks: readonly AxisTick[],\n trackPx: number,\n): TickLabel[] {\n if (ticks.length === 0 || trackPx <= 0) return [];\n const shown: {\n tick: AxisTick;\n align: \"start\" | \"end\";\n left: number;\n right: number;\n }[] = [];\n for (const tick of ticks) {\n const text = formatTick(tick.ms);\n const widthPx = Math.max(text.length * TICK_CHAR_PX, 8);\n const mark = tick.at * trackPx;\n const overflows = mark + TICK_PAD_PX + widthPx > trackPx;\n const align = overflows ? \"end\" : \"start\";\n const leftPx = overflows\n ? mark - TICK_PAD_PX - widthPx\n : mark + TICK_PAD_PX;\n const rightPx = overflows\n ? mark - TICK_PAD_PX\n : mark + TICK_PAD_PX + widthPx;\n // The later label wins at the track's end; elsewhere the earlier one.\n // At the end it has to clear every survivor, not just the nearest: popping\n // one can leave it overlapping the label behind that.\n let clash = false;\n while (shown.length > 0) {\n const prev = shown[shown.length - 1]!;\n if (leftPx >= prev.right + TICK_GAP_PX) break;\n if (!overflows) {\n clash = true;\n break;\n }\n shown.pop();\n }\n if (clash) continue;\n shown.push({ tick, align, left: leftPx, right: rightPx });\n }\n return shown.map(({ tick, align }) => ({ ...tick, align }));\n}\n\n/** The ticks that get a label, in ms — `layoutTickLabels` without the sides. */\nexport function labeledTicks(\n ticks: readonly AxisTick[],\n trackPx: number,\n): number[] {\n return layoutTickLabels(ticks, trackPx).map((tick) => tick.ms);\n}\n\n/** A fraction as a CSS percentage, rounded so floats never leak into styles. */\nexport function percent(fraction: number): string {\n return `${Number((fraction * 100).toFixed(4))}%`;\n}\n","import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ComponentProps,\n type CSSProperties,\n type PointerEvent as ReactPointerEvent,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport {\n IconArrowNarrowRight,\n IconChevronDown,\n IconChevronRight,\n IconChevronUp,\n IconChevronsDown,\n IconChevronsUp,\n IconX,\n} from \"@tabler/icons-react\";\nimport { Badge, badgeVariants } from \"../badge\";\nimport { Collapsible } from \"../collapsible\";\nimport { cn } from \"../../utils/cn\";\nimport { GhostSearch } from \"../../utils/ghost-search\";\nimport { SpanPrimitive, useSpan, useSpanTree } from \"./span-primitive\";\nimport { MIN_VIEW_WIDTH, type SpanView } from \"./span-tree\";\nimport { peerService, spanDecorationIcon, spanPills } from \"./decorations\";\nimport {\n axisTicks,\n barGeometry,\n formatDuration,\n formatTick,\n layoutTickLabels,\n normalizeSpans,\n percent,\n spanDuration,\n type TraceSpanStatus,\n type TraceWaterfallSpan,\n} from \"./layout\";\n\n/**\n * Trace — one request's spans as a waterfall: each row a span, nested\n * under its parent by indentation, its bar placed along the trace's\n * length from where it started to where it ended.\n *\n * The tree is `SpanPrimitive`'s: its Provider derives depth, order,\n * folding, search matches, and the zoom window from\n * `{ id, parentSpanId, startedAt, endedAt }`, and the row is composed\n * from its headless parts (Root, Indent, CollapseToggle, StatusIndicator,\n * Name, Timeline, TimelineBar). This file supplies the look, the time\n * axis, selection, and the detail panel. No fetching, no clock of its own\n * unless a span is still running.\n *\n * Design notes:\n * - Two columns, half and half: the names on the left, the bars on the\n * right under a time axis. Bars and tick labels share one inset track\n * (`left-5` / `right-5`) so a full-width span sits off the `border-l`\n * and the card edge. A completed bar uses the inverse chip at 25% so it\n * reads against the white row; a failed span's bar and dot are the\n * error ink; a running bar is lighter and pulses, growing with `now`;\n * a skipped one is a dashed outline. A short bar's duration sits beside\n * it; a long one's sits inside, right-aligned.\n * - A fold keeps its facts: a folded parent with failed descendants gets\n * a hollow error dot and `(3, 1 error)`; a folded `client` names the\n * `server` it called and shows that span's stretch on its own bar. A\n * leaf `client` with `peer.service` names the callee the same way.\n * - Attributes decorate the row: one icon for the namespace (`db.`,\n * `http.`, `rpc.`, `messaging.`) or the GenAI kind, and pills for the\n * status code (5xx in error ink), the method, the database, the model.\n * - The fold controls (one level / all) and the axis share one 40px\n * header row: controls on the left, ticks on the right.\n * The axis is the overview of the whole trace. Drag across it to zoom\n * to that stretch: the rest of the axis steps back, the range lights up\n * between two grips with its span, the bars glide into place — and the\n * picture stays: the window keeps its place on the axis while zoomed,\n * a chip in the header names it. Drag a grip to resize, drag\n * anywhere to choose again; double-click, `Esc`, or the chip to come back. A bar the\n * window cuts off fades at the cut edge; a span wholly outside it\n * loses its bar and keeps a quiet `‹ 1.10 ms` at the edge it lies\n * beyond. A tick label hides when it would overlap the\n * previous one; the last tick right-aligns.\n * - `search` adds a toolbar band: a ghost search over names, services,\n * ids, and attributes (`\"a phrase\"`, `-key` to leave a key out,\n * `key=value`). Matches take a wash, their folded ancestors open, and\n * Enter / the arrows step through them.\n * - Keyboard, while focus is inside the card (`shortcuts=\"focus\"`, the\n * default) or anywhere on the page (`\"global\"`): `[` / `]` expand /\n * collapse all, `o` / `p` one level, `↑` / `↓` zoom, `←` / `→` pan\n * (Shift for more), `/` to the search, `f` / `b` next / previous\n * match, `Esc` clears the search, then the zoom, then the selection.\n * - A footer row holds the legend (Span / Error) and the totals as\n * spaced items (`6 spans`, `1 error`, `62.4 ms total`), missing\n * parents when a span named one the trace lacks.\n * Hide it with `footer={null}`.\n * - A parent folds its children on its chevron; the row itself selects\n * (`selectedId` / `onSelect`) and the selected row keeps the wash.\n * `renderSpanDetail` expands a full-width panel under that row.\n * - `Trace.Logs` lists the log lines that belong to the trace, each at\n * its offset from the start. With no lines it renders nothing.\n */\n\nconst TRACE_SURFACE =\n \"rounded-base border border-pho-secondary bg-pho-primary overflow-hidden\";\n\n/** The two columns every row and the axis share. */\nconst COLUMNS = \"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)]\";\n\n/**\n * The time column's drawing area. Bars and tick labels are percentages of\n * this track, not of the column: `left-5` / `right-5` keep them off the\n * `border-l` and the card's edge so a full-width span still breathes.\n */\nconst TRACK_INSET = \"absolute inset-y-0 left-5 right-5\";\n\n/**\n * Name-column inset: `20px` plus `16px` per depth — the row's padding.\n * The card's inset is `DataTable`'s `px-5`: text starts and ends where a\n * table's would, in the header, the rows, the footer, and the logs.\n */\nconst TRACE_NAME_PAD_PX = 20;\nconst TRACE_DEPTH_STEP_PX = 16;\n/** Chevron / spacer (`size-5`) plus the `gap-1.5` before the bullet. */\nconst TRACE_BULLET_GUTTER_PX = 20 + 6;\n\n/**\n * Left edge of a row's bullet, in px, from the card. The detail panel\n * uses this so its content starts under that dot at any depth.\n */\nexport function traceBulletInset(depth: number): string {\n return `${TRACE_NAME_PAD_PX + depth * TRACE_DEPTH_STEP_PX + TRACE_BULLET_GUTTER_PX}px`;\n}\n\n/** How often a running trace redraws when it keeps its own clock. */\nconst CLOCK_TICK_MS = 250;\n\n/** The zoom a keypress takes; Shift takes the larger one. */\nconst ZOOM_IN = 0.8;\nconst ZOOM_IN_FAST = 0.5;\nconst PAN = 0.1;\nconst PAN_FAST = 0.3;\n/** A drag shorter than this, as a fraction of the axis, was a click. */\nconst MIN_DRAG = 0.005;\n\nconst BAR_INK: Record<TraceSpanStatus, string> = {\n completed: \"bg-pho-inverse/25\",\n failed: \"bg-pho-error-ink\",\n running: \"bg-pho-inverse/15 motion-safe:animate-pulse\",\n skipped: \"border-pho-secondary border border-dashed bg-transparent\",\n};\n\nconst DOT_INK: Record<TraceSpanStatus, string> = {\n completed: \"bg-pho-inverse\",\n failed: \"bg-pho-error-ink\",\n running: \"bg-pho-inverse/40\",\n skipped: \"border-pho-secondary border bg-transparent\",\n};\n\n/** The dot of a folded parent hiding failed spans: the error ink, hollow. */\nconst DOT_HIDDEN_ERROR = \"border-pho-error-ink border bg-transparent\";\n\n/** What a reader hears after the name; nothing for the ordinary case. */\nconst STATUS_WORD: Record<TraceSpanStatus, string | null> = {\n completed: null,\n failed: \"Failed.\",\n running: \"Running.\",\n skipped: \"Skipped.\",\n};\n\nconst ICON_BUTTON =\n \"text-pho-secondary outline-pho-brand hover:bg-pho-ghost-hover hover:text-pho-secondary-hover flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm transition-colors duration-100 ease-linear focus-visible:outline-2 disabled:pointer-events-none disabled:opacity-40\";\n\n/** The fade where the window cuts a bar off. */\nconst CLIP_FADE = (side: \"left\" | \"right\"): CSSProperties => ({\n backgroundImage: `linear-gradient(to ${side === \"left\" ? \"right\" : \"left\"}, color-mix(in srgb, var(--background-color-pho-inverse) 18%, transparent), transparent)`,\n});\n\nconst plural = (count: number, one: string, many = `${one}s`) =>\n `${count} ${count === 1 ? one : many}`;\n\nfunction TimelineTrack({\n className,\n clippedStart,\n clippedEnd,\n children,\n}: {\n className?: string;\n clippedStart?: boolean;\n clippedEnd?: boolean;\n children: ReactNode;\n}) {\n return (\n <div className={cn(\"border-pho-secondary relative border-l\", className)}>\n <div data-trace-track=\"\" className={TRACK_INSET}>\n {children}\n </div>\n {clippedStart ? (\n <span\n aria-hidden\n data-trace-clipped=\"start\"\n className=\"pointer-events-none absolute top-1/2 left-0 h-4 w-2 -translate-y-1/2\"\n style={CLIP_FADE(\"left\")}\n />\n ) : null}\n {clippedEnd ? (\n <span\n aria-hidden\n data-trace-clipped=\"end\"\n className=\"pointer-events-none absolute top-1/2 right-0 h-4 w-2 -translate-y-1/2\"\n style={CLIP_FADE(\"right\")}\n />\n ) : null}\n </div>\n );\n}\n\n/** Where a bar's duration label goes, given the bar's place. */\nfunction labelPlacement(\n left: number,\n width: number,\n): \"inside\" | \"before\" | \"after\" {\n if (width > 0.5) return \"inside\";\n if (left + width > 0.8) return \"before\";\n return \"after\";\n}\n\n/** Is the key event typing into a field? Shortcuts stay out of those. */\nfunction isTypingTarget(target: EventTarget | null): boolean {\n if (!(target instanceof HTMLElement)) return false;\n const tag = target.tagName;\n return (\n tag === \"INPUT\" ||\n tag === \"TEXTAREA\" ||\n tag === \"SELECT\" ||\n target.isContentEditable\n );\n}\n\n/* ------------------------------ waterfall ------------------------------- */\n\ninterface WaterfallContextValue {\n /** The spans as given, for `renderSpanDetail`. */\n spans: ReadonlyMap<string, TraceWaterfallSpan>;\n selectedId: string | null | undefined;\n onSelect?: (id: string | null) => void;\n renderSpanDetail?: (span: TraceWaterfallSpan) => ReactNode;\n /** Prefix for the detail panels' ids. */\n idBase: string;\n /** For the footer's totals. */\n spanCount: number;\n errorCount: number;\n /** The match Enter / the arrows stopped on. */\n activeMatchId: string | null;\n}\n\nconst WaterfallContext = createContext<WaterfallContextValue | null>(null);\n\nfunction useWaterfall(): WaterfallContextValue {\n const value = useContext(WaterfallContext);\n if (value == null) {\n throw new Error(\"Trace rows render inside Trace.Waterfall only.\");\n }\n return value;\n}\n\n/** One span: the row, then its detail panel when it is the selected one. */\nfunction WaterfallRow() {\n const ctx = useWaterfall();\n const span = useSpan();\n const { viewRange, now, byId, matches } = useSpanTree();\n const { id, name, type, status, depth, isCollapsed, hasChildren } = span;\n\n const source = ctx.spans.get(id);\n const selected = ctx.selectedId != null && ctx.selectedId === id;\n const detail =\n selected && source != null\n ? (ctx.renderSpanDetail?.(source) ?? null)\n : null;\n const detailId =\n ctx.renderSpanDetail != null ? `${ctx.idBase}-span-${id}` : undefined;\n const onSelect = ctx.onSelect\n ? () => ctx.onSelect?.(selected ? null : id)\n : undefined;\n\n const { left, width } = barGeometry(span, viewRange, now);\n const end = span.endedAt ?? now ?? viewRange.max;\n const clippedStart = span.startedAt < viewRange.min && end > viewRange.min;\n const clippedEnd = end > viewRange.max && span.startedAt < viewRange.max;\n // Entirely past the window: no bar, a quiet label at the edge it lies beyond.\n // A span that only touches an edge overlaps by nothing, and the bar has a\n // 2px floor — so `<` would draw it a sliver instead of the label.\n const before = end <= viewRange.min;\n const outside = before || span.startedAt >= viewRange.max;\n const outsideSide = before ? \"before\" : \"after\";\n const placement = labelPlacement(left, width);\n const duration = spanDuration(span, now);\n const label = duration == null ? null : formatDuration(duration);\n const hint = [span.service, type].filter(Boolean).join(\", \");\n const hidden = isCollapsed ? span.descendants : 0;\n const hiddenErrors = isCollapsed ? span.descendantErrors : 0;\n const statusWord = STATUS_WORD[status];\n const failed = status === \"failed\";\n\n const decoration = spanDecorationIcon(span.attributes);\n const pills = spanPills(span.attributes);\n const rpc =\n isCollapsed && span.kind === \"client\" && span.serverChildId != null\n ? byId.get(span.serverChildId)\n : undefined;\n const callee =\n rpc != null\n ? (rpc.service ?? rpc.name)\n : !hasChildren && (span.kind === \"client\" || span.kind === \"producer\")\n ? peerService(span.attributes)\n : null;\n const rpcGeometry = rpc ? barGeometry(rpc, viewRange, now) : null;\n const isMatch = matches?.has(id) ?? false;\n const isActiveMatch = ctx.activeMatchId === id;\n\n // Beside the bar, on `side`, and never past the track's edge.\n const besideBar = (side: \"before\" | \"after\"): CSSProperties =>\n side === \"after\"\n ? {\n left: `calc(${percent(left + width)} + 0.375rem)`,\n maxWidth: `calc(${percent(1 - left - width)} - 0.375rem)`,\n }\n : {\n right: `calc(${percent(1 - left)} + 0.375rem)`,\n maxWidth: `calc(${percent(left)} - 0.375rem)`,\n };\n\n return (\n <li\n className=\"m-0\"\n style={{ \"--trace-indent\": traceBulletInset(depth) } as CSSProperties}\n >\n <SpanPrimitive.Root\n data-trace-row=\"\"\n data-selected={selected || undefined}\n data-active-match={isActiveMatch || undefined}\n className={cn(\n COLUMNS,\n \"relative min-h-9 items-center transition-colors\",\n \"has-[[data-trace-select]:focus-visible]:outline-pho-brand has-[[data-trace-select]:focus-visible]:outline-2 has-[[data-trace-select]:focus-visible]:-outline-offset-2\",\n onSelect != null && \"hover:bg-pho-primary-hover\",\n isMatch && \"bg-pho-brand-secondary\",\n isActiveMatch && \"ring-pho-brand ring-1 ring-inset\",\n selected && \"bg-pho-primary-hover\",\n )}\n >\n <SpanPrimitive.Indent\n baseIndent={TRACE_NAME_PAD_PX}\n indentPerLevel={TRACE_DEPTH_STEP_PX}\n className=\"flex min-w-0 items-center gap-1.5 py-1.5 pr-5\"\n >\n {hasChildren ? (\n <SpanPrimitive.CollapseToggle\n aria-expanded={!isCollapsed}\n aria-label={`${isCollapsed ? \"Expand\" : \"Collapse\"} ${name}`}\n className=\"text-pho-secondary outline-pho-brand hover:bg-pho-ghost-hover hover:text-pho-secondary-hover relative z-10 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm transition-[color,background-color,transform] duration-100 ease-linear focus-visible:outline-2\"\n >\n <IconChevronRight\n aria-hidden\n className={cn(\n \"size-4 transition-transform duration-150 ease-out\",\n !isCollapsed && \"rotate-90\",\n )}\n />\n </SpanPrimitive.CollapseToggle>\n ) : (\n <span aria-hidden className=\"size-5 shrink-0\" />\n )}\n <SpanPrimitive.StatusIndicator\n aria-hidden\n className={cn(\n \"size-1.5 shrink-0 rounded-full\",\n failed\n ? DOT_INK.failed\n : hiddenErrors > 0\n ? DOT_HIDDEN_ERROR\n : DOT_INK[status],\n )}\n />\n {decoration ? (\n <decoration.icon\n data-trace-icon=\"\"\n role={decoration.label ? \"img\" : undefined}\n aria-label={decoration.label}\n aria-hidden={decoration.label ? undefined : true}\n className=\"text-pho-description size-3.5 shrink-0\"\n />\n ) : null}\n <SelectTarget\n selected={selected}\n expanded={ctx.renderSpanDetail != null ? detail != null : undefined}\n controls={detail != null ? detailId : undefined}\n onSelect={onSelect}\n >\n <SpanPrimitive.Name className=\"text-pho-primary truncate text-base\" />\n {callee ? (\n <span\n data-trace-callee=\"\"\n className=\"text-pho-description flex shrink-0 items-center gap-0.5 text-xs\"\n >\n <IconArrowNarrowRight aria-hidden className=\"size-3\" />\n <span className=\"sr-only\">calls </span>\n {callee}\n </span>\n ) : null}\n {hint ? (\n <span className=\"text-pho-description shrink-[3] truncate text-xs\">\n {hint}\n </span>\n ) : null}\n {pills.map((pill) => (\n <Badge\n key={pill.label}\n size=\"xs\"\n contrast=\"low\"\n color={pill.error ? \"error\" : \"gray\"}\n title={`${pill.label}: ${pill.value}`}\n aria-label={`${pill.label}: ${pill.value}`}\n data-trace-pill={pill.label}\n data-error={pill.error || undefined}\n className=\"max-w-32 shrink-0 truncate\"\n >\n {pill.value}\n </Badge>\n ))}\n {hidden > 0 ? (\n <span className=\"text-pho-description shrink-0 text-xs tabular-nums\">\n ({hidden}\n {hiddenErrors > 0 ? `, ${plural(hiddenErrors, \"error\")}` : \"\"})\n </span>\n ) : null}\n {statusWord ? <span className=\"sr-only\">{statusWord}</span> : null}\n {hiddenErrors > 0 ? (\n <span className=\"sr-only\">\n {plural(hiddenErrors, \"error\")} hidden.\n </span>\n ) : null}\n </SelectTarget>\n </SpanPrimitive.Indent>\n <TimelineTrack\n className=\"h-9\"\n clippedStart={clippedStart}\n clippedEnd={clippedEnd}\n >\n <SpanPrimitive.TimelineBar\n aria-hidden\n data-trace-bar=\"\"\n className={cn(\n \"top-1/2 h-4 -translate-y-1/2 rounded-sm transition-[inset-inline-start,inline-size] duration-200 ease-out motion-reduce:transition-none\",\n BAR_INK[status],\n // Cut by the window: run flush to the column's edge, square\n // at the cut, so the bar reads as continuing past it.\n clippedStart && \"-ml-5 box-content rounded-l-none pl-5\",\n clippedEnd && \"box-content rounded-r-none pr-5\",\n outside && \"invisible\",\n )}\n style={{ \"--span-timeline-min-width\": \"2px\" } as CSSProperties}\n >\n {placement === \"inside\" && label ? (\n <span\n data-trace-label=\"short\"\n className={cn(\n \"absolute inset-y-0 flex items-center text-xs whitespace-nowrap tabular-nums\",\n clippedEnd ? \"right-[1.625rem]\" : \"right-1.5\",\n failed ? \"text-pho-on-brand\" : \"text-pho-primary\",\n )}\n >\n {label}\n </span>\n ) : null}\n </SpanPrimitive.TimelineBar>\n {rpc && rpcGeometry ? (\n <span\n aria-hidden\n data-trace-rpc=\"\"\n className=\"bg-pho-inverse/45 absolute top-1/2 h-2 -translate-y-1/2 rounded-sm\"\n style={{\n left: percent(rpcGeometry.left),\n width: percent(rpcGeometry.width),\n minWidth: \"2px\",\n }}\n />\n ) : null}\n {outside && label ? (\n <span\n aria-hidden\n data-trace-label=\"outside\"\n data-side={outsideSide}\n className={cn(\n \"text-pho-description absolute top-1/2 -translate-y-1/2 text-xs whitespace-nowrap tabular-nums opacity-60\",\n outsideSide === \"before\" ? \"left-0\" : \"right-0\",\n )}\n >\n {outsideSide === \"before\" ? `‹ ${label}` : `${label} ›`}\n </span>\n ) : null}\n {!outside && placement !== \"inside\" && label ? (\n <span\n aria-hidden\n data-trace-label=\"short\"\n className=\"text-pho-description absolute top-1/2 -translate-y-1/2 truncate text-xs tabular-nums\"\n style={besideBar(placement)}\n >\n {label}\n </span>\n ) : null}\n {label ? <span className=\"sr-only\">{label}</span> : null}\n </TimelineTrack>\n </SpanPrimitive.Root>\n {detail != null ? (\n <Collapsible.Root open>\n <Collapsible.Panel className=\"motion-reduce:transition-none\">\n <section\n id={detailId}\n data-trace-detail=\"\"\n className=\"border-pho-secondary bg-pho-page border-t py-3 pr-5\"\n style={{ paddingLeft: \"var(--trace-indent)\" }}\n >\n {detail}\n </section>\n </Collapsible.Panel>\n </Collapsible.Root>\n ) : null}\n </li>\n );\n}\n\n/** The row's selectable part — a button when the trace takes a selection. */\nfunction SelectTarget({\n selected,\n expanded,\n controls,\n onSelect,\n children,\n}: {\n selected: boolean;\n expanded?: boolean;\n controls?: string;\n onSelect?: () => void;\n children: ReactNode;\n}) {\n const className = \"flex min-w-0 flex-1 items-baseline gap-2 text-left\";\n if (onSelect == null) {\n return <span className={className}>{children}</span>;\n }\n return (\n <button\n type=\"button\"\n data-trace-select=\"\"\n aria-current={selected ? \"true\" : undefined}\n aria-expanded={expanded}\n aria-controls={controls}\n onClick={onSelect}\n // The one target, stretched over the row; the ring is the row's.\n className={cn(\n className,\n \"cursor-pointer outline-none after:absolute after:inset-0 after:content-['']\",\n )}\n >\n {children}\n </button>\n );\n}\n\n/** A coarse clock while a span still runs and the host gave no `now`. */\nfunction useOwnClock(active: boolean): number | undefined {\n const [now, setNow] = useState<number | undefined>(undefined);\n useEffect(() => {\n if (!active) return;\n setNow(Date.now());\n const timer = setInterval(() => setNow(Date.now()), CLOCK_TICK_MS);\n return () => clearInterval(timer);\n }, [active]);\n return active ? now : undefined;\n}\n\nexport type TraceWaterfallShortcuts = \"focus\" | \"global\" | false;\n\nexport interface TraceWaterfallProps extends Omit<\n ComponentProps<\"section\">,\n \"children\" | \"onSelect\"\n> {\n spans: readonly TraceWaterfallSpan[];\n /**\n * The current time on the spans' clock, for running spans: their bars\n * and durations grow to it. Omit and the waterfall ticks on its own\n * while any span runs; pass it to drive the redraw yourself.\n */\n now?: number;\n /** The span whose details are open — it keeps the wash. */\n selectedId?: string | null;\n /**\n * Rows select on click when given. A second click on the selected\n * row, or Escape, passes `null` so the host can close the detail.\n */\n onSelect?: (id: string | null) => void;\n /**\n * Facts for the selected span, drawn as a full-width panel under that\n * row. Omit (or return `null`) for selection without a panel.\n */\n renderSpanDetail?: (span: TraceWaterfallSpan) => ReactNode;\n /** Spans folded at first (uncontrolled). */\n defaultCollapsed?: readonly string[];\n /** Spans folded (controlled). */\n collapsed?: readonly string[];\n onCollapsedChange?: (ids: string[]) => void;\n /**\n * The fold controls in the header — one level and all, each way.\n * Shown while the trace has a parent to fold. @default true\n */\n foldControls?: boolean;\n /**\n * A search box in a toolbar band above the header — `true`, or the\n * placeholder it should show. Terms are space-separated and any may\n * match; `\"a phrase\"` keeps its spaces; `-key` leaves an attribute out;\n * `key=value` matches exactly. Matches take a wash and their folded\n * ancestors open. Pass `query` with `onQueryChange` to own the text.\n */\n search?: boolean | string;\n query?: string;\n onQueryChange?: (query: string) => void;\n /** The zoom window at first (uncontrolled), as fractions of the trace. */\n defaultView?: SpanView;\n /** The zoom window (controlled). */\n view?: SpanView;\n onViewChange?: (view: SpanView) => void;\n /**\n * Where the keyboard shortcuts listen: `\"focus\"` while focus is inside\n * the card (click it, or tab to a row), `\"global\"` anywhere on the page\n * outside a field, `false` for none. @default \"focus\"\n */\n shortcuts?: TraceWaterfallShortcuts;\n /**\n * The legend and totals under the rows. Default when there are\n * spans; pass `null` to hide it, or a node (`<Trace.Waterfall.Footer />`)\n * to replace it.\n */\n footer?: ReactNode;\n ref?: Ref<HTMLElement>;\n}\n\nfunction Waterfall({\n spans,\n now: nowProp,\n selectedId,\n onSelect,\n renderSpanDetail,\n defaultCollapsed,\n collapsed,\n onCollapsedChange,\n foldControls = true,\n search,\n query: queryProp,\n onQueryChange,\n defaultView,\n view,\n onViewChange,\n shortcuts = \"focus\",\n footer,\n className,\n ...props\n}: TraceWaterfallProps) {\n const data = useMemo(() => normalizeSpans(spans), [spans]);\n const byId = useMemo(\n () => new Map(spans.map((span) => [span.id, span])),\n [spans],\n );\n const running = data.some((span) => span.endedAt == null);\n const ownNow = useOwnClock(running && nowProp === undefined);\n const now = nowProp ?? ownNow;\n const [ownQuery, setOwnQuery] = useState(\"\");\n const query = queryProp ?? ownQuery;\n const setQuery = useCallback(\n (next: string) => {\n if (queryProp == null) setOwnQuery(next);\n onQueryChange?.(next);\n },\n [queryProp, onQueryChange],\n );\n const errorCount = useMemo(\n () => data.filter((span) => span.status === \"failed\").length,\n [data],\n );\n\n return (\n <SpanPrimitive.Provider\n spans={data}\n now={now}\n defaultCollapsed={defaultCollapsed}\n collapsed={collapsed}\n onCollapsedChange={onCollapsedChange}\n query={query}\n defaultView={defaultView}\n view={view}\n onViewChange={onViewChange}\n >\n <WaterfallFrame\n sources={byId}\n spanCount={data.length}\n errorCount={errorCount}\n selectedId={selectedId}\n onSelect={onSelect}\n renderSpanDetail={renderSpanDetail}\n foldControls={foldControls}\n search={search}\n query={query}\n setQuery={setQuery}\n shortcuts={shortcuts}\n footer={footer}\n className={className}\n {...props}\n />\n </SpanPrimitive.Provider>\n );\n}\n\ninterface WaterfallFrameProps extends Omit<\n ComponentProps<\"section\">,\n \"onSelect\"\n> {\n sources: ReadonlyMap<string, TraceWaterfallSpan>;\n spanCount: number;\n errorCount: number;\n selectedId?: string | null;\n onSelect?: (id: string | null) => void;\n renderSpanDetail?: (span: TraceWaterfallSpan) => ReactNode;\n foldControls: boolean;\n search?: boolean | string;\n query: string;\n setQuery: (query: string) => void;\n shortcuts: TraceWaterfallShortcuts;\n footer?: ReactNode;\n ref?: Ref<HTMLElement>;\n}\n\n/** The card: the toolbar, the header row with the axis, the rows, the footer — inside the tree. */\nfunction WaterfallFrame({\n sources,\n spanCount,\n errorCount,\n selectedId,\n onSelect,\n renderSpanDetail,\n foldControls,\n search,\n query,\n setQuery,\n shortcuts,\n footer,\n className,\n ref,\n ...props\n}: WaterfallFrameProps) {\n const tree = useSpanTree();\n const {\n all,\n matches,\n zoomed,\n zoom,\n pan,\n resetView,\n expandAll,\n collapseAll,\n expandOne,\n collapseOne,\n } = tree;\n const idBase = useId();\n const rootRef = useRef<HTMLElement | null>(null);\n const searchRef = useRef<HTMLInputElement | null>(null);\n const setRoot = useCallback(\n (node: HTMLElement | null) => {\n rootRef.current = node;\n if (typeof ref === \"function\") ref(node);\n else if (ref != null) ref.current = node;\n },\n [ref],\n );\n\n // The matches in reading order, and the one the arrows stopped on.\n const matchIds = useMemo(\n () =>\n matches == null\n ? []\n : all.filter((span) => matches.has(span.id)).map((span) => span.id),\n [all, matches],\n );\n const [activeIndex, setActiveIndex] = useState(0);\n useEffect(() => setActiveIndex(0), [query]);\n const activeMatchId =\n matchIds.length > 0\n ? (matchIds[activeIndex % matchIds.length] ?? null)\n : null;\n const stepMatch = useCallback(\n (direction: 1 | -1) => {\n if (matchIds.length === 0) return;\n setActiveIndex(\n (index) => (index + direction + matchIds.length) % matchIds.length,\n );\n },\n [matchIds.length],\n );\n useEffect(() => {\n if (activeMatchId == null) return;\n const escaped =\n typeof CSS !== \"undefined\" && typeof CSS.escape === \"function\"\n ? CSS.escape(activeMatchId)\n : activeMatchId.replace(/\"/g, '\\\\\"');\n const row = rootRef.current?.querySelector<HTMLElement>(\n `[data-trace-row][data-span-id=\"${escaped}\"]`,\n );\n row?.scrollIntoView?.({ block: \"nearest\" });\n }, [activeMatchId]);\n\n // Escape dismisses the nearest thing: the search, then the zoom, then\n // the selection. It follows `shortcuts` the same way the letter keys do\n // — off when they are, and only inside the card in focus mode — so a\n // waterfall in a dialog does not swallow that dialog's Escape.\n const hasQuery = query !== \"\";\n const hasSelection = selectedId != null && onSelect != null;\n useEffect(() => {\n if (!hasQuery && !zoomed && !hasSelection) return;\n if (shortcuts === false) return;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\") return;\n if (\n shortcuts === \"focus\" &&\n !(\n event.target instanceof Node &&\n rootRef.current?.contains(event.target)\n )\n ) {\n return;\n }\n event.preventDefault();\n event.stopPropagation();\n if (hasQuery) setQuery(\"\");\n else if (zoomed) resetView();\n else onSelect?.(null);\n };\n document.addEventListener(\"keydown\", onKeyDown, true);\n return () => document.removeEventListener(\"keydown\", onKeyDown, true);\n }, [\n hasQuery,\n zoomed,\n hasSelection,\n shortcuts,\n setQuery,\n resetView,\n onSelect,\n ]);\n\n const handleShortcut = useCallback(\n (event: KeyboardEvent): boolean => {\n if (event.metaKey || event.ctrlKey || event.altKey) return false;\n if (isTypingTarget(event.target)) return false;\n switch (event.key) {\n case \"[\":\n expandAll();\n return true;\n case \"]\":\n collapseAll();\n return true;\n case \"o\":\n expandOne();\n return true;\n case \"p\":\n collapseOne();\n return true;\n case \"ArrowUp\":\n zoom(event.shiftKey ? ZOOM_IN_FAST : ZOOM_IN);\n return true;\n case \"ArrowDown\":\n if (!zoomed) return false;\n zoom(event.shiftKey ? 1 / ZOOM_IN_FAST : 1 / ZOOM_IN);\n return true;\n case \"ArrowLeft\":\n if (!zoomed) return false;\n pan(event.shiftKey ? -PAN_FAST : -PAN);\n return true;\n case \"ArrowRight\":\n if (!zoomed) return false;\n pan(event.shiftKey ? PAN_FAST : PAN);\n return true;\n case \"/\":\n if (searchRef.current == null) return false;\n searchRef.current.focus();\n return true;\n case \"f\":\n if (matchIds.length === 0) return false;\n stepMatch(1);\n return true;\n case \"b\":\n if (matchIds.length === 0) return false;\n stepMatch(-1);\n return true;\n default:\n return false;\n }\n },\n [\n expandAll,\n collapseAll,\n expandOne,\n collapseOne,\n zoom,\n pan,\n zoomed,\n matchIds.length,\n stepMatch,\n ],\n );\n // One listener on the document for both modes: in focus mode it only\n // answers keys pressed inside the card, so a focused row or the card\n // itself (it takes focus on click) is enough and the page keeps its keys.\n useEffect(() => {\n if (shortcuts === false) return;\n const onKeyDown = (event: KeyboardEvent) => {\n if (\n shortcuts === \"focus\" &&\n !(\n event.target instanceof Node &&\n rootRef.current?.contains(event.target)\n )\n ) {\n return;\n }\n if (handleShortcut(event)) event.preventDefault();\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [shortcuts, handleShortcut]);\n\n const context = useMemo<WaterfallContextValue>(\n () => ({\n spans: sources,\n selectedId,\n onSelect,\n renderSpanDetail,\n idBase,\n spanCount,\n errorCount,\n activeMatchId,\n }),\n [\n sources,\n selectedId,\n onSelect,\n renderSpanDetail,\n idBase,\n spanCount,\n errorCount,\n activeMatchId,\n ],\n );\n\n const hasParents = all.some((span) => span.hasChildren);\n const searching = search === true || typeof search === \"string\";\n const placeholder = typeof search === \"string\" ? search : \"Search spans\";\n const resolvedFooter =\n footer === undefined ? spanCount > 0 ? <WaterfallFooter /> : null : footer;\n\n return (\n <WaterfallContext.Provider value={context}>\n <section\n ref={setRoot}\n data-trace=\"\"\n data-zoomed={zoomed || undefined}\n aria-label=\"Trace\"\n tabIndex={shortcuts === \"focus\" ? -1 : undefined}\n className={cn(TRACE_SURFACE, \"min-w-0 outline-none\", className)}\n {...props}\n >\n {searching ? (\n <div\n data-trace-toolbar=\"\"\n className=\"border-pho-secondary flex min-h-10 items-center gap-3 border-b px-5\"\n >\n <GhostSearch\n ref={searchRef}\n value={query}\n onChange={setQuery}\n placeholder={placeholder}\n aria-label={placeholder}\n onKeyDown={(event) => {\n if (event.key === \"Enter\") {\n event.preventDefault();\n stepMatch(event.shiftKey ? -1 : 1);\n } else if (event.key === \"Escape\" && query !== \"\") {\n event.preventDefault();\n setQuery(\"\");\n }\n }}\n />\n {hasQuery ? (\n <>\n <span\n data-trace-match-count=\"\"\n aria-live=\"polite\"\n className=\"text-pho-description shrink-0 text-xs tabular-nums\"\n >\n {matchIds.length === 0\n ? \"No matches\"\n : `${(activeIndex % matchIds.length) + 1} of ${matchIds.length}`}\n </span>\n <span className=\"flex shrink-0 items-center\">\n <button\n type=\"button\"\n aria-label=\"Previous match\"\n title=\"Previous match (b)\"\n disabled={matchIds.length === 0}\n onClick={() => stepMatch(-1)}\n className={ICON_BUTTON}\n >\n <IconChevronUp aria-hidden className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n aria-label=\"Next match\"\n title=\"Next match (f)\"\n disabled={matchIds.length === 0}\n onClick={() => stepMatch(1)}\n className={ICON_BUTTON}\n >\n <IconChevronDown aria-hidden className=\"size-4\" />\n </button>\n </span>\n </>\n ) : null}\n </div>\n ) : null}\n <div\n data-trace-axis=\"\"\n className={cn(COLUMNS, \"border-pho-secondary h-10 border-b\")}\n >\n <div className=\"flex h-10 min-w-0 items-center gap-2 px-5\">\n {zoomed ? <ZoomChip /> : null}\n {foldControls && hasParents ? <FoldControls /> : null}\n </div>\n <AxisTrack />\n </div>\n <SpanPrimitive.Timeline\n render={<ol aria-label=\"Spans\" className=\"m-0 list-none p-0\" />}\n >\n <SpanPrimitive.Children>\n {() => <WaterfallRow />}\n </SpanPrimitive.Children>\n </SpanPrimitive.Timeline>\n {resolvedFooter}\n </section>\n </WaterfallContext.Provider>\n );\n}\n\n/**\n * The window, as a chip in the header while zoomed — the one sign\n * that stays put after the drag — and the way back on a click.\n */\nfunction ZoomChip() {\n const { range, viewRange, resetView } = useSpanTree();\n const window = `${formatDuration(viewRange.min - range.min)} – ${formatDuration(viewRange.max - range.min)}`;\n return (\n <button\n type=\"button\"\n data-trace-zoom-chip=\"\"\n onClick={resetView}\n title=\"Reset zoom (Esc)\"\n aria-label={`Zoomed to ${window}. Reset zoom`}\n className={cn(\n badgeVariants({ size: \"xs\", contrast: \"low\", color: \"brand\" }),\n \"outline-pho-brand shrink-0 cursor-pointer focus-visible:outline-2\",\n )}\n >\n <span aria-hidden>{window}</span>\n <IconX aria-hidden className=\"size-3\" />\n </button>\n );\n}\n\n/** Open or fold one level, or everything — at the end of the header cell. */\nfunction FoldControls() {\n const {\n canExpand,\n canCollapse,\n expandAll,\n collapseAll,\n expandOne,\n collapseOne,\n } = useSpanTree();\n return (\n <fieldset\n data-trace-fold-controls=\"\"\n className=\"m-0 ml-auto flex min-w-0 shrink-0 items-center border-0 p-0\"\n >\n <legend className=\"sr-only\">Fold</legend>\n <button\n type=\"button\"\n aria-label=\"Expand one level\"\n title=\"Expand one level (o)\"\n disabled={!canExpand}\n onClick={expandOne}\n className={ICON_BUTTON}\n >\n <IconChevronDown aria-hidden className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n aria-label=\"Collapse one level\"\n title=\"Collapse one level (p)\"\n disabled={!canCollapse}\n onClick={collapseOne}\n className={ICON_BUTTON}\n >\n <IconChevronUp aria-hidden className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n aria-label=\"Expand all\"\n title=\"Expand all ([)\"\n disabled={!canExpand}\n onClick={expandAll}\n className={ICON_BUTTON}\n >\n <IconChevronsDown aria-hidden className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n aria-label=\"Collapse all\"\n title=\"Collapse all (])\"\n disabled={!canCollapse}\n onClick={collapseAll}\n className={ICON_BUTTON}\n >\n <IconChevronsUp aria-hidden className=\"size-4\" />\n </button>\n </fieldset>\n );\n}\n\n/**\n * The time axis: tick marks for the window, a guide under the pointer,\n * and the zoom gesture — drag across a stretch to zoom to it, double-click\n * to come back.\n */\ntype AxisDrag =\n /** Sweeping out a window; fractions of the trace. */\n | { kind: \"select\"; from: number; to: number }\n /** Dragging one grip of the window. */\n | { kind: \"resize\"; edge: \"start\" | \"end\" };\n\n/**\n * The time axis is the overview of the whole trace: tick marks for its\n * length and a guide under the pointer. Drag across it to zoom to that\n * stretch — the rest of the axis steps back and the range lights up\n * between two grips with its span — and the picture stays once the\n * pointer lifts: the window keeps its place on the axis while the rows\n * stretch to it. Drag a grip to resize the window, drag anywhere to\n * choose again, double-click to come back.\n */\nfunction AxisTrack() {\n const { range, view, zoomed, setView, resetView } = useSpanTree();\n const totalMs = range.max - range.min;\n const ticks = useMemo(() => axisTicks(0, totalMs), [totalMs]);\n const [trackPx, setTrackPx] = useState(280);\n const trackRef = useRef<HTMLDivElement | null>(null);\n useEffect(() => {\n const node = trackRef.current;\n if (node == null) return;\n const update = () => {\n const width = node.clientWidth;\n if (width > 0) setTrackPx(width);\n };\n update();\n const observer = new ResizeObserver(update);\n observer.observe(node);\n return () => observer.disconnect();\n }, []);\n const labels = new Map(\n layoutTickLabels(ticks, trackPx).map((tick) => [tick.ms, tick.align]),\n );\n\n const [cursor, setCursor] = useState<number | null>(null);\n const [drag, setDrag] = useState<AxisDrag | null>(null);\n /** Where along the axis the pointer is, 0–1, whatever it is over. */\n const fractionAt = (event: ReactPointerEvent<HTMLElement>) => {\n const rect = trackRef.current?.getBoundingClientRect();\n if (rect == null || rect.width <= 0) return 0;\n return Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width));\n };\n const begin = (event: ReactPointerEvent<HTMLElement>, next: AxisDrag) => {\n trackRef.current?.setPointerCapture?.(event.pointerId);\n setDrag(next);\n };\n const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (event.button !== 0) return;\n const at = fractionAt(event);\n begin(event, { kind: \"select\", from: at, to: at });\n };\n /** A press on a grip resizes that end instead of starting a selection. */\n const resize =\n (edge: \"start\" | \"end\") => (event: ReactPointerEvent<HTMLElement>) => {\n if (event.button !== 0) return;\n event.stopPropagation();\n begin(event, { kind: \"resize\", edge });\n };\n const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const at = fractionAt(event);\n if (drag == null) {\n setCursor(at);\n return;\n }\n if (drag.kind === \"select\") {\n setDrag({ ...drag, to: at });\n } else {\n setView(\n drag.edge === \"start\"\n ? [Math.min(at, view[1] - MIN_VIEW_WIDTH), view[1]]\n : [view[0], Math.max(at, view[0] + MIN_VIEW_WIDTH)],\n );\n }\n };\n const onPointerUp = (event: ReactPointerEvent<HTMLDivElement>) => {\n if (drag == null) return;\n const at = fractionAt(event);\n setDrag(null);\n if (drag.kind !== \"select\") {\n // Where the pointer was let go is the answer. The last move may have\n // been reported somewhere else, and dropping this left the edge a\n // frame behind the release.\n setView(\n drag.edge === \"start\"\n ? [Math.min(at, view[1] - MIN_VIEW_WIDTH), view[1]]\n : [view[0], Math.max(at, view[0] + MIN_VIEW_WIDTH)],\n );\n return;\n }\n const [a, b] = drag.from < at ? [drag.from, at] : [at, drag.from];\n if (b - a < MIN_DRAG) return;\n setView([a, b]);\n };\n const onPointerCancel = () => {\n setCursor(null);\n setDrag(null);\n };\n const onPointerLeave = () => {\n setCursor(null);\n if (drag?.kind === \"select\") setDrag(null);\n };\n // The window on show: the one being swept out, else the zoom.\n const selecting = drag?.kind === \"select\" ? drag : null;\n const window =\n selecting != null\n ? selecting.from < selecting.to\n ? { left: selecting.from, width: selecting.to - selecting.from }\n : { left: selecting.to, width: selecting.from - selecting.to }\n : zoomed\n ? { left: view[0], width: view[1] - view[0] }\n : null;\n\n const atMs = (fraction: number) => fraction * totalMs;\n\n return (\n <TimelineTrack className=\"h-10\">\n <div\n ref={trackRef}\n aria-hidden\n role=\"presentation\"\n data-trace-axis-track=\"\"\n title=\"Drag to zoom, double-click to reset\"\n className=\"absolute inset-0 cursor-crosshair touch-none select-none\"\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerCancel}\n onPointerLeave={onPointerLeave}\n onDoubleClick={resetView}\n >\n {ticks.map((tick) => {\n const align = labels.get(tick.ms);\n return (\n <span\n key={tick.ms}\n data-trace-tick=\"\"\n data-labeled={align != null || undefined}\n className=\"text-pho-description absolute inset-y-0 text-xs tabular-nums\"\n style={{ left: percent(tick.at) }}\n >\n <span className=\"bg-pho-secondary absolute bottom-0 left-0 h-1.5 w-px\" />\n {align != null ? (\n <span\n className={cn(\n \"absolute inset-y-0 flex items-center whitespace-nowrap\",\n align === \"end\" ? \"right-1\" : \"left-1\",\n )}\n >\n {formatTick(tick.ms)}\n </span>\n ) : null}\n </span>\n );\n })}\n {cursor != null && drag == null ? (\n <span\n data-trace-cursor=\"\"\n className=\"bg-pho-inverse/40 pointer-events-none absolute inset-y-0 w-px\"\n style={{ left: percent(cursor) }}\n >\n <span\n className={cn(\n \"bg-pho-primary text-pho-secondary absolute top-1/2 z-10 -translate-y-1/2 rounded-sm px-1 text-[10px] whitespace-nowrap tabular-nums\",\n cursor > 0.8 ? \"right-1\" : \"left-1\",\n )}\n >\n {formatDuration(atMs(cursor))}\n </span>\n </span>\n ) : null}\n {window ? (\n <>\n {/* The rest of the axis steps back so the window reads as lit. */}\n <span\n data-trace-selection-shade=\"start\"\n className=\"bg-pho-inverse/10 pointer-events-none absolute inset-y-0 left-0\"\n style={{ width: percent(window.left) }}\n />\n <span\n data-trace-selection-shade=\"end\"\n className=\"bg-pho-inverse/10 pointer-events-none absolute inset-y-0 right-0\"\n style={{ width: percent(1 - window.left - window.width) }}\n />\n <span\n data-trace-selection=\"\"\n data-selecting={selecting != null || undefined}\n className=\"border-pho-ink bg-pho-primary pointer-events-none absolute inset-y-0 flex items-center justify-center border-x-2\"\n style={{\n left: percent(window.left),\n width: percent(window.width),\n }}\n >\n <span className=\"bg-pho-primary text-pho-primary z-10 rounded-sm px-1 text-[10px] whitespace-nowrap tabular-nums\">\n {formatDuration(atMs(window.left))} –{\" \"}\n {formatDuration(atMs(window.left + window.width))}\n </span>\n </span>\n <Grip\n at={window.left}\n data-trace-selection-handle=\"start\"\n className={cn(selecting == null && \"cursor-ew-resize\")}\n onPointerDown={selecting == null ? resize(\"start\") : undefined}\n />\n <Grip\n at={window.left + window.width}\n data-trace-selection-handle=\"end\"\n className={cn(selecting == null && \"cursor-ew-resize\")}\n onPointerDown={selecting == null ? resize(\"end\") : undefined}\n />\n </>\n ) : null}\n </div>\n </TimelineTrack>\n );\n}\n\n/** A range grip — two ink lines in a small outlined pill — centred on `at`. */\nfunction Grip({\n at,\n className,\n ...props\n}: ComponentProps<\"span\"> & { at: number }) {\n return (\n <span\n aria-hidden\n className={cn(\n \"border-pho-ink bg-pho-primary absolute top-1/2 z-10 flex h-5 w-2.5 -translate-x-1/2 -translate-y-1/2 items-center justify-center gap-0.5 rounded-sm border shadow-sm\",\n className,\n )}\n style={{ left: percent(at) }}\n {...props}\n >\n <span className=\"bg-pho-inverse h-2.5 w-px\" />\n <span className=\"bg-pho-inverse h-2.5 w-px\" />\n </span>\n );\n}\n\n/* -------------------------------- footer -------------------------------- */\n\nexport function footerTotals({\n spanCount,\n errorCount,\n orphanCount = 0,\n durationMs,\n}: {\n spanCount: number;\n errorCount: number;\n orphanCount?: number;\n durationMs: number;\n}): string[] {\n const parts = [plural(spanCount, \"span\")];\n if (errorCount > 0) parts.push(plural(errorCount, \"error\"));\n if (orphanCount > 0)\n parts.push(\n `${orphanCount} missing ${orphanCount === 1 ? \"parent\" : \"parents\"}`,\n );\n parts.push(`${formatDuration(durationMs)} total`);\n return parts;\n}\n\nexport type WaterfallFooterProps = ComponentProps<\"div\">;\n\n/**\n * The waterfall's legend and totals. Renders inside `Trace.Waterfall`\n * so it can read the spans; pass it as `footer` to keep the default\n * chrome when replacing the slot.\n */\nfunction WaterfallFooter({ className, ...props }: WaterfallFooterProps) {\n const { spanCount, errorCount } = useWaterfall();\n const { range, orphans } = useSpanTree();\n const totals = footerTotals({\n spanCount,\n errorCount,\n orphanCount: orphans,\n durationMs: range.max - range.min,\n });\n return (\n <div\n data-trace-footer=\"\"\n className={cn(\n // Its own container: the legend needs room a narrow card lacks.\n \"border-pho-secondary text-pho-description @container flex h-10 items-center justify-between gap-3 border-t px-5 text-xs\",\n className,\n )}\n {...props}\n >\n <ul\n data-trace-legend=\"\"\n className=\"hidden shrink-0 items-center gap-3 @2xl:flex\"\n >\n <LegendSwatch className=\"bg-pho-inverse/25\" label=\"Span\" />\n <LegendSwatch className=\"bg-pho-error-ink\" label=\"Error\" />\n </ul>\n <ul className=\"flex min-w-0 items-center gap-3 overflow-hidden tabular-nums\">\n {totals.map((part) => (\n <li key={part} className=\"shrink-0 last:min-w-0 last:truncate\">\n {part}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n\nfunction LegendSwatch({\n className,\n label,\n}: {\n className: string;\n label: string;\n}) {\n return (\n <li className=\"flex items-center gap-1.5\">\n <span\n aria-hidden\n className={cn(\"size-2.5 shrink-0 rounded-sm\", className)}\n />\n {label}\n </li>\n );\n}\n\n/* --------------------------------- logs --------------------------------- */\n\nexport type TraceLogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport interface TraceLog {\n id?: string;\n /** When, in ms after the trace's start. */\n offsetMs: number;\n level?: TraceLogLevel;\n message: string;\n /** The span it was written in, when known — its name shows after. */\n spanId?: string;\n}\n\nconst LEVEL_INK: Record<TraceLogLevel, string> = {\n debug: \"text-pho-description\",\n info: \"text-pho-secondary\",\n warn: \"text-pho-warning\",\n error: \"text-pho-error\",\n};\n\nexport interface TraceLogsProps extends Omit<\n ComponentProps<\"section\">,\n \"children\" | \"title\"\n> {\n logs?: readonly TraceLog[] | null;\n /** The spans, to name the one each line was written in. */\n spans?: readonly Pick<TraceWaterfallSpan, \"id\" | \"name\">[];\n /** @default \"Logs\" */\n title?: ReactNode;\n ref?: Ref<HTMLElement>;\n}\n\n/**\n * The log lines that belong to the trace, each at its offset from the\n * start, in the mono face. Renders nothing when there are none — a\n * trace with no logs shows no empty block.\n */\nfunction Logs({\n logs,\n spans,\n title = \"Logs\",\n className,\n ...props\n}: TraceLogsProps) {\n const names = useMemo(\n () => new Map((spans ?? []).map((span) => [span.id, span.name])),\n [spans],\n );\n if (logs == null || logs.length === 0) return null;\n return (\n <section\n data-trace-logs=\"\"\n className={cn(TRACE_SURFACE, \"min-w-0\", className)}\n {...props}\n >\n <div className=\"border-pho-secondary flex min-h-10 items-center justify-between gap-3 border-b px-5\">\n <div className=\"text-pho-secondary min-w-0 truncate text-xs font-medium\">\n {title}\n </div>\n <div className=\"text-pho-description shrink-0 text-xs tabular-nums\">\n {logs.length} {logs.length === 1 ? \"line\" : \"lines\"}\n </div>\n </div>\n <ol className=\"divide-pho-secondary m-0 list-none divide-y p-0 font-mono text-xs\">\n {logs.map((log, index) => {\n const level = log.level ?? \"info\";\n const spanName = log.spanId ? names.get(log.spanId) : undefined;\n return (\n <li\n key={log.id ?? index}\n className=\"grid grid-cols-[5rem_3.5rem_minmax(0,1fr)] items-baseline gap-3 px-5 py-1.5\"\n >\n <span className=\"text-pho-description tabular-nums\">\n +{formatDuration(log.offsetMs)}\n </span>\n <span className={cn(\"truncate\", LEVEL_INK[level])}>\n {level.charAt(0).toUpperCase() + level.slice(1)}\n </span>\n <span className=\"text-pho-primary [overflow-wrap:anywhere] whitespace-pre-wrap\">\n {log.message}\n {spanName ? (\n <span className=\"text-pho-description\"> {spanName}</span>\n ) : null}\n </span>\n </li>\n );\n })}\n </ol>\n </section>\n );\n}\n\n/**\n * ```tsx\n * <Trace.Waterfall\n * spans={spans}\n * selectedId={id}\n * onSelect={setId}\n * renderSpanDetail={(span) => <SpanFacts span={span} />}\n * search\n * />\n * <Trace.Logs logs={logs} spans={spans} />\n * ```\n */\nconst WaterfallWithFooter = Object.assign(Waterfall, {\n Footer: WaterfallFooter,\n});\n\nexport const Trace = { Waterfall: WaterfallWithFooter, Logs };\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10],"mappings":";;;;;;;;;;;;;AASA,IAAMA,KAAa;AAAA,EAAC,CAAC,QAAQ;AAAA,IAAE,GAAK;AAAA,IAAc,KAAO;AAAA,EAAQ,CAAC;AAAA,EAAG,CAAC,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