@mechane-ai/elements 0.8.0 → 0.10.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 (94) hide show
  1. package/NOTICE +24 -0
  2. package/README.md +67 -40
  3. package/dist/ai.js +274 -209
  4. package/dist/{categorical-values-dGbaZ0tp.js → categorical-values-DLRE4EEW.js} +4 -4
  5. package/dist/{chart-frame-DgPdIguO.js → chart-frame-et6f6Vhg.js} +22 -14
  6. package/dist/{chart-input-Sac4StHN.js → chart-input-CdLkFomi.js} +2 -2
  7. package/dist/charts/cartesian.js +529 -450
  8. package/dist/charts/distribution.js +302 -261
  9. package/dist/charts/graph.js +137 -103
  10. package/dist/charts/hierarchy.js +7 -7
  11. package/dist/charts/matrix.js +187 -174
  12. package/dist/charts/timeline.js +118 -92
  13. package/dist/charts.js +1 -1
  14. package/dist/code-block-D77maJBB.js +180 -0
  15. package/dist/collections.js +388 -300
  16. package/dist/content/code.js +1 -1
  17. package/dist/content/diff.js +81 -63
  18. package/dist/content/link.js +1 -1
  19. package/dist/content/markdown.js +115 -96
  20. package/dist/content/tree.js +43 -38
  21. package/dist/{content-link-Dd8gapwc.js → content-link-BpSZeTNK.js} +6 -2
  22. package/dist/content.js +169 -150
  23. package/dist/{assets/stylex.css → elements.css} +862 -338
  24. package/dist/feedback.js +1 -1
  25. package/dist/forms/dates.js +31 -31
  26. package/dist/forms.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/layout.js +286 -187
  29. package/dist/navigation/commands.js +45 -42
  30. package/dist/{navigation-yxK3iQXo.js → navigation-D2_sGy3C.js} +2 -2
  31. package/dist/navigation.js +10 -10
  32. package/dist/overlays.js +1 -1
  33. package/dist/packages/ai/src/conversation.d.ts +2 -1
  34. package/dist/packages/ai/src/index.d.ts +4 -0
  35. package/dist/packages/ai/src/message-action.d.ts +10 -0
  36. package/dist/packages/ai/src/message-boundary.d.ts +6 -0
  37. package/dist/packages/ai/src/message.d.ts +2 -1
  38. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +5 -0
  39. package/dist/packages/charts/src/cartesian/index.d.ts +2 -2
  40. package/dist/packages/charts/src/chart-frame.d.ts +3 -0
  41. package/dist/packages/charts/src/chart-theme.d.ts +2 -1
  42. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +22 -2
  43. package/dist/packages/collections/src/collection-scroll.d.ts +2 -1
  44. package/dist/packages/collections/src/data-table.d.ts +6 -0
  45. package/dist/packages/collections/src/index.d.ts +2 -2
  46. package/dist/packages/collections/src/timeline.d.ts +10 -3
  47. package/dist/packages/content/src/diff/pierre-diff.d.ts +2 -1
  48. package/dist/packages/content/src/viewer-styles.d.ts +64 -0
  49. package/dist/packages/core/src/actions.d.ts +7 -0
  50. package/dist/packages/core/src/agent-avatar-glyphs.d.ts +5 -0
  51. package/dist/packages/core/src/agent-avatar.d.ts +17 -0
  52. package/dist/packages/core/src/copy-value.d.ts +2 -1
  53. package/dist/packages/core/src/index.d.ts +6 -2
  54. package/dist/packages/core/src/surfaces.d.ts +5 -0
  55. package/dist/packages/feedback/src/index.d.ts +4 -1
  56. package/dist/packages/feedback/src/toast.d.ts +5 -27
  57. package/dist/packages/forms/src/agent-avatar-picker.d.ts +8 -0
  58. package/dist/packages/forms/src/field-styles.d.ts +28 -0
  59. package/dist/packages/forms/src/forms.d.ts +2 -1
  60. package/dist/packages/forms/src/index.d.ts +2 -0
  61. package/dist/packages/forms/src/selection-styles.d.ts +18 -2
  62. package/dist/packages/foundations/src/overlay-styles.d.ts +3 -1
  63. package/dist/packages/foundations/src/popup-styles.d.ts +7 -0
  64. package/dist/packages/foundations/src/tokens.stylex.d.ts +61 -0
  65. package/dist/packages/layout/src/app-shell.d.ts +2 -1
  66. package/dist/packages/layout/src/frame.stylex.d.ts +1 -0
  67. package/dist/packages/layout/src/index.d.ts +2 -1
  68. package/dist/packages/layout/src/page-toolbar.d.ts +3 -1
  69. package/dist/packages/layout/src/sidebar.d.ts +7 -1
  70. package/dist/packages/layout/src/view-stack.d.ts +13 -0
  71. package/dist/packages/layout/src/workbench.d.ts +5 -2
  72. package/dist/packages/overlays/src/alert-dialog.d.ts +5 -2
  73. package/dist/packages/overlays/src/dialog.d.ts +7 -3
  74. package/dist/pierre-diff--zsiHCCB.js +71 -0
  75. package/dist/pierre-theme-D9hnHv3Z.js +126 -0
  76. package/dist/{pierre-tree-DdE1boiT.js → pierre-tree-BFxEuxwb.js} +3 -3
  77. package/dist/src-Be7NLG8c.js +1242 -0
  78. package/dist/src-CBspCKfO.js +969 -0
  79. package/dist/src-Cs0dRc4X.js +617 -0
  80. package/dist/src-sU9b0oZW.js +1168 -0
  81. package/dist/theme.js +1 -1
  82. package/dist/tokens.js +69 -10
  83. package/dist/viewer-styles-CpHqp5Qv.js +70 -0
  84. package/package.json +2 -1
  85. package/packages/foundations/src/tokens.stylex.ts +61 -0
  86. package/styles.css +1 -1
  87. package/dist/code-block-BRNdtTaP.js +0 -175
  88. package/dist/pierre-diff-CZdzgiYm.js +0 -66
  89. package/dist/pierre-theme-BpESNIsV.js +0 -96
  90. package/dist/popup-styles-CvtZDE2t.js +0 -135
  91. package/dist/src-Bc5sEhdO.js +0 -680
  92. package/dist/src-CfDf8TY8.js +0 -466
  93. package/dist/src-DV0BNk1M.js +0 -360
  94. package/dist/src-Eg_ytPjv.js +0 -1107
@@ -1,15 +1,16 @@
1
- import { c as e } from "../src-Bc5sEhdO.js";
2
- import * as t from "@stylexjs/stylex";
3
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
- import { scaleLinear as i } from "@visx/scale";
5
- import { Bar as a } from "@visx/shape";
1
+ import { c as e } from "../src-sU9b0oZW.js";
2
+ import { n as t, t as n } from "../chart-input-CdLkFomi.js";
3
+ import * as r from "@stylexjs/stylex";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
+ import { scaleLinear as o } from "@visx/scale";
6
+ import { Bar as s } from "@visx/shape";
6
7
  // packages/charts/src/timeline/waterfall.tsx
7
- var o = {
8
+ var c = {
8
9
  plot: {
9
10
  k7Eaqz: "xeuugli",
10
11
  kUOVxO: "xl4o6ss",
11
- kBCFzs: "x1npkx4u xp7zxbh",
12
- kbNqZ1: "x1ms6mhf xq5skvx",
12
+ kBCFzs: "x1npkx4u x1v577k8",
13
+ kbNqZ1: "x1ms6mhf x1aa6nly",
13
14
  $$css: !0
14
15
  },
15
16
  neutral: {
@@ -24,162 +25,187 @@ var o = {
24
25
  kMwMTN: "xr5kp14",
25
26
  $$css: !0
26
27
  }
27
- }, s = {
28
- neutral: o.neutral,
29
- positive: o.positive,
30
- negative: o.negative
31
- }, c = [
28
+ }, l = {
29
+ neutral: c.neutral,
30
+ positive: c.positive,
31
+ negative: c.negative
32
+ }, u = [
32
33
  0,
33
34
  .5,
34
35
  1
35
- ], l = 100;
36
- function u({ items: a, start: u, end: p, label: m, rowLabel: h, summaryLabel: g, emptyLabel: _, selectedId: v, onSelect: y, formatOffset: b }) {
37
- let x = p - u, S = i({
38
- domain: [u, p],
39
- range: [0, x === 0 ? 0 : l]
40
- }), C = x > 0 ? c : [0];
41
- return /* @__PURE__ */ r("div", {
36
+ ], d = 100;
37
+ function f({ items: t, start: s, end: f, label: g, rowLabel: _, summaryLabel: v, emptyLabel: y, selectedId: b, onSelect: x, formatOffset: S }) {
38
+ let C = p({
39
+ items: t,
40
+ start: s,
41
+ end: f
42
+ });
43
+ if (C !== void 0) return /* @__PURE__ */ i(n, {
44
+ title: g,
45
+ message: C
46
+ });
47
+ let w = f - s, T = o({
48
+ domain: [s, f],
49
+ range: [0, w === 0 ? 0 : d]
50
+ }), E = w > 0 ? u : [0];
51
+ return /* @__PURE__ */ a("div", {
42
52
  role: "group",
43
- "aria-label": m,
44
- className: "xeuugli x1hz01jw",
53
+ "aria-label": g,
54
+ className: "xeuugli x1hz01jw x12h1iku",
45
55
  children: [
46
- /* @__PURE__ */ r("div", {
47
- className: "xrvj5dj x13sfnbj xj8mwme x6s0dn4 x1mw73un xq5c7ks xh8yej3 x9f619 xqin4a2 xu0aao5 x153jb6y xy8obcc xso031l x1q0q8m5 x1qndepd",
56
+ /* @__PURE__ */ a("div", {
57
+ className: "xrvj5dj x13sfnbj x1prkh4w x6s0dn4 x1gkm1c7 x1y1mm1b xh8yej3 x9f619 x1doqdfy x1uey4wk x153jb6y xy8obcc xso031l x1q0q8m5 x1qndepd",
48
58
  children: [
49
- /* @__PURE__ */ n(e, {
59
+ /* @__PURE__ */ i(e, {
50
60
  variant: "caption",
51
61
  tone: "muted",
52
- children: h
62
+ children: _
53
63
  }),
54
- /* @__PURE__ */ n("div", {
55
- className: "xeuugli xl4o6ss x1npkx4u xp7zxbh x1ms6mhf xq5skvx x78zum5 x1qughib x6s0dn4 xy8obcc xas2l8k xss6m8b",
56
- children: C.map((e) => /* @__PURE__ */ n("span", { children: b(x * e) }, e))
64
+ /* @__PURE__ */ i("div", {
65
+ className: "xeuugli xl4o6ss x1npkx4u x1v577k8 x1ms6mhf x1aa6nly x78zum5 x1qughib x6s0dn4 xy8obcc xas2l8k xss6m8b",
66
+ children: E.map((e) => /* @__PURE__ */ i("span", { children: S(w * e) }, e))
57
67
  }),
58
- /* @__PURE__ */ n("span", {
59
- className: "xeuugli x1k3v4rp x1moszlt x1ms6mhf xp4054r xj0a0fe xss6m8b",
60
- children: /* @__PURE__ */ n(e, {
68
+ /* @__PURE__ */ i("span", {
69
+ className: "xrvj5dj xfko13i xeuugli x1k3v4rp x14r0xmm x1ms6mhf xp4054r xj0a0fe xss6m8b",
70
+ children: /* @__PURE__ */ i(e, {
61
71
  variant: "caption",
62
72
  tone: "muted",
63
- children: g
73
+ children: v
64
74
  })
65
75
  })
66
76
  ]
67
77
  }),
68
- a.length === 0 && /* @__PURE__ */ n("p", {
78
+ t.length === 0 && /* @__PURE__ */ i("p", {
69
79
  className: "x1ghz6dp x1c8xbx5",
70
- children: /* @__PURE__ */ n(e, {
80
+ children: /* @__PURE__ */ i(e, {
71
81
  tone: "muted",
72
- children: _
82
+ children: y
73
83
  })
74
84
  }),
75
- a.map((i) => {
76
- let a = f({
77
- geometry: i.geometry,
78
- start: u,
79
- formatOffset: b
85
+ t.map((t) => {
86
+ let n = h({
87
+ geometry: t.geometry,
88
+ start: s,
89
+ formatOffset: S
80
90
  });
81
- return /* @__PURE__ */ r("button", {
91
+ return /* @__PURE__ */ a("button", {
82
92
  type: "button",
83
- "aria-pressed": v === i.id,
84
- "aria-label": `${i.label} · ${i.detail} · ${i.summary} · ${a}`,
85
- onClick: () => y(i.id),
93
+ "aria-pressed": b === t.id,
94
+ "aria-label": `${t.label} · ${t.detail} · ${t.summary} · ${n}`,
95
+ onClick: () => x(t.id),
86
96
  ...{
87
- 0: { className: "xrvj5dj x13sfnbj xj8mwme x6s0dn4 x1mw73un xq5c7ks xh8yej3 x9f619 xqin4a2 xn9t2bk x1wiwyrm xc342km xso031l x1q0q8m5 x1qndepd xpvm0e4 xbixft x1hz01jw x1yc453h x1ypdohk xzro8vx x19rmrnh x9v5kkp x13qnu6 x1bqaal x1t1lzn6" },
88
- 1: { className: "xrvj5dj x13sfnbj xj8mwme x6s0dn4 x1mw73un xq5c7ks xh8yej3 x9f619 xqin4a2 xn9t2bk x1wiwyrm xc342km xso031l x1q0q8m5 x1qndepd xbixft x1hz01jw x1yc453h x1ypdohk xzro8vx x19rmrnh x9v5kkp x13qnu6 x1bqaal x1t1lzn6 x1r7kqkb x1jmj9dw" }
89
- }[v === i.id | 0],
97
+ 0: { className: "xrvj5dj x13sfnbj x1prkh4w x6s0dn4 x1gkm1c7 x1y1mm1b xh8yej3 x9f619 x1doqdfy xn9t2bk x1wiwyrm xc342km xso031l x1q0q8m5 x1qndepd xpvm0e4 xbixft x1hz01jw x1yc453h x1ypdohk x1t137rt xzro8vx x1ecmtor x19rmrnh x9v5kkp x13qnu6 x1bqaal x1t1lzn6" },
98
+ 1: { className: "xrvj5dj x13sfnbj x1prkh4w x6s0dn4 x1gkm1c7 x1y1mm1b xh8yej3 x9f619 x1doqdfy xn9t2bk x1wiwyrm xc342km xso031l x1q0q8m5 x1qndepd xbixft x1hz01jw x1yc453h x1ypdohk x1t137rt xzro8vx x1ecmtor x19rmrnh x9v5kkp x13qnu6 x1bqaal x1t1lzn6 x1r7kqkb x1jmj9dw" }
99
+ }[b === t.id | 0],
90
100
  children: [
91
- /* @__PURE__ */ r("span", {
101
+ /* @__PURE__ */ a("span", {
92
102
  className: "xeuugli xrvj5dj xfko13i",
93
- children: [/* @__PURE__ */ n("span", {
94
- className: "xk50ysn xj0a0fe",
95
- children: /* @__PURE__ */ n(e, { children: i.label })
96
- }), /* @__PURE__ */ n("span", {
97
- title: i.detail,
98
- className: "xb3r6kr xuxw1ft xlyipyv",
99
- children: /* @__PURE__ */ n(e, {
103
+ children: [/* @__PURE__ */ i(e, { children: t.label }), /* @__PURE__ */ i("span", {
104
+ title: t.detail,
105
+ ...{
106
+ 0: { className: "xb3r6kr xuxw1ft xlyipyv" },
107
+ 1: { className: "xb3r6kr xlyipyv xeaf4i8 xj0a0fe" }
108
+ }[b === t.id | 0],
109
+ children: /* @__PURE__ */ i(e, {
100
110
  variant: "caption",
101
111
  tone: "muted",
102
- children: i.detail
112
+ children: t.detail
103
113
  })
104
114
  })]
105
115
  }),
106
- /* @__PURE__ */ n("span", {
107
- title: a,
108
- ...t.props(o.plot, s[i.tone]),
109
- children: i.geometry.kind === "unavailable" ? /* @__PURE__ */ n(e, {
116
+ /* @__PURE__ */ i("span", {
117
+ title: n,
118
+ ...r.props(c.plot, l[t.tone]),
119
+ children: t.geometry.kind === "unavailable" ? /* @__PURE__ */ i(e, {
110
120
  variant: "caption",
111
121
  tone: "muted",
112
- children: a
113
- }) : /* @__PURE__ */ r("svg", {
122
+ children: n
123
+ }) : /* @__PURE__ */ a("svg", {
114
124
  "aria-hidden": !0,
115
125
  className: "x1lliihq xh8yej3 xmix8c7 x1rea2x4",
116
- children: [C.map((e) => /* @__PURE__ */ n("line", {
117
- x1: `${e * l}%`,
118
- x2: `${e * l}%`,
126
+ children: [E.map((e) => /* @__PURE__ */ i("line", {
127
+ x1: `${e * d}%`,
128
+ x2: `${e * d}%`,
119
129
  y1: "0",
120
130
  y2: "18",
121
131
  className: "x13hfdr1"
122
- }, e)), /* @__PURE__ */ n(d, {
123
- geometry: i.geometry,
124
- scale: S
132
+ }, e)), /* @__PURE__ */ i(m, {
133
+ geometry: t.geometry,
134
+ scale: T
125
135
  })]
126
136
  })
127
137
  }),
128
- /* @__PURE__ */ n("span", {
129
- className: "xeuugli x1k3v4rp x1moszlt x1ms6mhf xp4054r xj0a0fe xss6m8b",
130
- children: /* @__PURE__ */ n(e, {
138
+ /* @__PURE__ */ a("span", {
139
+ className: "xrvj5dj xfko13i xeuugli x1k3v4rp x14r0xmm x1ms6mhf xp4054r xj0a0fe xss6m8b",
140
+ children: [/* @__PURE__ */ i(e, {
131
141
  variant: "caption",
132
142
  tone: "muted",
133
- children: i.summary
134
- })
143
+ children: t.summary
144
+ }), b === t.id && /* @__PURE__ */ i(e, {
145
+ variant: "caption",
146
+ tone: "muted",
147
+ children: n
148
+ })]
135
149
  })
136
150
  ]
137
- }, i.id);
151
+ }, t.id);
138
152
  })
139
153
  ]
140
154
  });
141
155
  }
142
- function d({ geometry: e, scale: t }) {
156
+ function p({ items: e, start: n, end: r }) {
157
+ if (!Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(r - n) || r < n) return "The timing domain must have finite, ordered endpoints.";
158
+ if (!t(e)) return "Timing records must have unique identifiers.";
159
+ for (let t of e) {
160
+ let e = t.geometry;
161
+ if (e.kind === "interval") {
162
+ if (!Number.isFinite(e.start) || !Number.isFinite(e.end) || e.end < e.start) return "Timing intervals must have finite, ordered endpoints.";
163
+ if (e.start < n || e.end > r) return "Timing intervals must fit inside the supplied domain.";
164
+ }
165
+ if (e.kind === "point" && (!Number.isFinite(e.at) || e.at < n || e.at > r)) return "Timing points must be finite and fit inside the supplied domain.";
166
+ }
167
+ }
168
+ function m({ geometry: e, scale: t }) {
143
169
  switch (e.kind) {
144
170
  case "unavailable": return null;
145
171
  case "interval": {
146
- let r = t(e.start), i = t(e.end) - r;
147
- return i === 0 ? /* @__PURE__ */ n("circle", {
148
- cx: `${r}%`,
172
+ let n = t(e.start), r = t(e.end) - n;
173
+ return r === 0 ? /* @__PURE__ */ i("circle", {
174
+ cx: `${n}%`,
149
175
  cy: 9,
150
176
  r: 3,
151
177
  className: "x117rol3"
152
- }) : /* @__PURE__ */ n(a, {
153
- x: `${r}%`,
178
+ }) : /* @__PURE__ */ i(s, {
179
+ x: `${n}%`,
154
180
  y: 6,
155
- width: `${i}%`,
181
+ width: `${r}%`,
156
182
  height: 6,
157
183
  rx: 2,
158
184
  className: "x117rol3"
159
185
  });
160
186
  }
161
187
  case "point": {
162
- let r = t(e.at);
188
+ let n = t(e.at);
163
189
  switch (e.marker) {
164
- case "filled": return /* @__PURE__ */ n("circle", {
165
- cx: `${r}%`,
190
+ case "filled": return /* @__PURE__ */ i("circle", {
191
+ cx: `${n}%`,
166
192
  cy: 9,
167
193
  r: 3,
168
194
  className: "x117rol3"
169
195
  });
170
- case "hollow": return /* @__PURE__ */ n("circle", {
171
- cx: `${r}%`,
196
+ case "hollow": return /* @__PURE__ */ i("circle", {
197
+ cx: `${n}%`,
172
198
  cy: 9,
173
199
  r: 3.5,
174
200
  className: "x1fytgo2 x73je2i xvlca1e"
175
201
  });
176
- case "diamond": return /* @__PURE__ */ n("svg", {
177
- x: `${r}%`,
202
+ case "diamond": return /* @__PURE__ */ i("svg", {
203
+ x: `${n}%`,
178
204
  y: 9,
179
205
  width: 1,
180
206
  height: 1,
181
207
  overflow: "visible",
182
- children: /* @__PURE__ */ n("path", {
208
+ children: /* @__PURE__ */ i("path", {
183
209
  d: "M0 -5 5 0 0 5 -5 0Z",
184
210
  className: "x117rol3"
185
211
  })
@@ -188,11 +214,11 @@ function d({ geometry: e, scale: t }) {
188
214
  }
189
215
  }
190
216
  }
191
- function f({ geometry: e, start: t, formatOffset: n }) {
217
+ function h({ geometry: e, start: t, formatOffset: n }) {
192
218
  switch (e.kind) {
193
219
  case "interval": return `Start ${n(e.start - t)}, end ${n(e.end - t)}, duration ${n(e.end - e.start)}`;
194
220
  case "point": return `At ${n(e.at - t)}`;
195
221
  case "unavailable": return "Timing unavailable";
196
222
  }
197
223
  }
198
- export { u as Waterfall };
224
+ export { f as Waterfall };
package/dist/charts.js CHANGED
@@ -1 +1 @@
1
- export { r as ChartFrame, i as ChartLegend } from "./chart-frame-DgPdIguO.js";
1
+ export { r as ChartFrame, i as ChartLegend } from "./chart-frame-et6f6Vhg.js";
@@ -0,0 +1,180 @@
1
+ import { _ as e } from "./src-sU9b0oZW.js";
2
+ import { colors as t } from "./tokens.js";
3
+ import { t as n } from "./viewer-styles-CpHqp5Qv.js";
4
+ import { t as r } from "./pierre-theme-D9hnHv3Z.js";
5
+ import * as i from "@stylexjs/stylex";
6
+ import { useEffect as a, useRef as o, useState as s } from "react";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ // packages/content/src/code/use-highlighted-code.ts
9
+ var u = 2e5, d = 4096;
10
+ function f(e, t) {
11
+ let n = o(null), [i, c] = s();
12
+ return a(() => () => {
13
+ n.current !== null && (n.current.tokenizer.dispose(), n.current = null);
14
+ }, []), a(() => {
15
+ let i = !0;
16
+ async function a() {
17
+ try {
18
+ let a = await import("@pierre/highlights");
19
+ if (!i || e.length > u || !a.isSupportedLanguage(t)) return;
20
+ let o = n.current, s = o !== null && o.language === t, l = s ? o : {
21
+ language: t,
22
+ source: e,
23
+ tokenizer: new a.LiveTokenizer({
24
+ code: e,
25
+ lang: t,
26
+ theme: r,
27
+ tokenizeMaxLineLength: d
28
+ })
29
+ };
30
+ if (s) {
31
+ if (e.startsWith(o.source)) {
32
+ let t = l.tokenizer.lineCount - 1, n = {
33
+ line: t,
34
+ character: l.tokenizer.getLineLength(t)
35
+ };
36
+ l.tokenizer.applyEdits([{
37
+ range: {
38
+ start: n,
39
+ end: n
40
+ },
41
+ newText: e.slice(o.source.length)
42
+ }]);
43
+ } else l.tokenizer.reset(e);
44
+ } else o !== null && o.tokenizer.dispose();
45
+ n.current = {
46
+ ...l,
47
+ source: e
48
+ };
49
+ let f = l.tokenizer;
50
+ f.flush();
51
+ let p = Array.from({ length: f.lineCount }, (e, t) => f.getLineTokens(t).tokens);
52
+ c({
53
+ code: e,
54
+ language: t,
55
+ lines: p,
56
+ hasFailed: !1
57
+ });
58
+ } catch {
59
+ i && c({
60
+ code: e,
61
+ language: t,
62
+ lines: [],
63
+ hasFailed: !0
64
+ });
65
+ }
66
+ }
67
+ return a(), () => {
68
+ i = !1;
69
+ };
70
+ }, [e, t]), i !== void 0 && i.code === e && i.language === t ? i : void 0;
71
+ }
72
+ // packages/content/src/code/code-block.tsx
73
+ var p = {
74
+ kVQacm: "xysyzu8",
75
+ k9g6sI: "x12h1iku",
76
+ $$css: !0
77
+ }, m = {
78
+ viewport: (e) => [
79
+ p,
80
+ {
81
+ kskxy: e == null ? e : "x1jols5v",
82
+ $$css: !0
83
+ },
84
+ { "--x-maxHeight": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e) }
85
+ ],
86
+ token: (e) => [{
87
+ kMwMTN: e == null ? e : "x14rh7hd",
88
+ $$css: !0
89
+ }, { "--x-color": e ?? void 0 }],
90
+ italic: {
91
+ kKX8nH: "x1k4tb9n",
92
+ $$css: !0
93
+ },
94
+ bold: {
95
+ k63SB2: "x1b5ytql",
96
+ $$css: !0
97
+ }
98
+ }, h = 2e5;
99
+ function g({ token: e }) {
100
+ let n = e.fontStyle ?? 0, [r, a] = [!!(n & 1), !!(n & 2)];
101
+ return /* @__PURE__ */ c("span", {
102
+ ...i.props(m.token(e.color ?? t.ink), r && m.italic, a && m.bold),
103
+ children: e.content
104
+ });
105
+ }
106
+ function _({ code: t, language: r = "text", filename: a, streaming: o = !1, wrap: s = !1, lineNumbers: u = !0, selectedLines: d, annotations: p = [], maxHeight: _ = 400, maxLines: v = 2e3 }) {
107
+ let y = f(t, r), b = t.slice(0, h).split(/\r\n|\n|\r/u), x = b.slice(0, Math.max(1, v)).map((e, t) => ({
108
+ text: e,
109
+ line: t + 1
110
+ })), S = a ?? r;
111
+ return /* @__PURE__ */ l("section", {
112
+ "aria-label": a ?? "Code",
113
+ ...i.props(n.root),
114
+ children: [
115
+ /* @__PURE__ */ l("div", {
116
+ ...i.props(n.header),
117
+ children: [/* @__PURE__ */ l("span", {
118
+ ...i.props(n.label),
119
+ children: [S, o && " · streaming"]
120
+ }), /* @__PURE__ */ c(e, {
121
+ label: a ?? "code",
122
+ value: t,
123
+ children: "Copy"
124
+ })]
125
+ }),
126
+ /* @__PURE__ */ c("div", {
127
+ role: "region",
128
+ "aria-label": `${S} source`,
129
+ tabIndex: 0,
130
+ ...i.props(n.scrollRegion, m.viewport(_)),
131
+ children: /* @__PURE__ */ c("pre", {
132
+ ...{
133
+ 0: { className: "x1ghz6dp xn9t2bk xiard35 xy8obcc x1778rvt xeq4nuv xk8lq53" },
134
+ 1: { className: "x1ghz6dp xn9t2bk xiard35 xy8obcc x1778rvt xeq4nuv xeuugli x126k92a xj0a0fe" }
135
+ }[!!s | 0],
136
+ children: /* @__PURE__ */ c("code", {
137
+ className: "xjb2p0i",
138
+ children: x.map(({ text: e, line: t }) => {
139
+ let n = y === void 0 ? void 0 : y.lines[t - 1], r = d !== void 0 && t >= d.start && t <= (d.end ?? d.start), i = p.find((e) => e.line === t);
140
+ return /* @__PURE__ */ l("span", { children: [/* @__PURE__ */ l("span", {
141
+ ...{
142
+ 0: { className: "x78zum5 x16exltd" },
143
+ 1: { className: "x78zum5 x16exltd x1r8u7ye" }
144
+ }[!!r | 0],
145
+ children: [u && /* @__PURE__ */ c("span", {
146
+ "aria-hidden": !0,
147
+ className: "x1rg5ohu x2lah0s xl3ry0p x5g2kb4 xp4054r x153jb6y x87ps6o",
148
+ children: t
149
+ }), /* @__PURE__ */ l("span", {
150
+ className: "x1lliihq x12lumcd x1doqdfy xeuugli",
151
+ children: [n === void 0 ? e : n.map((e) => /* @__PURE__ */ c(g, { token: e }, e.offset)), e.length === 0 && "\n"]
152
+ })]
153
+ }), i !== void 0 && /* @__PURE__ */ c("span", {
154
+ className: "x1lliihq x9f619 x7wzq59 x1o0tod xzfn7dr x1mvvolr x1r7kqkb x1hz01jw xtqrqnz x1778rvt xeaf4i8 xj0a0fe",
155
+ children: i.content
156
+ })] }, t);
157
+ })
158
+ })
159
+ })
160
+ }),
161
+ b.length > x.length && /* @__PURE__ */ c("div", {
162
+ ...i.props(n.note),
163
+ children: "Additional lines omitted. Copy includes the complete source."
164
+ }),
165
+ t.length > h && /* @__PURE__ */ c("div", {
166
+ ...i.props(n.note),
167
+ children: "Preview limited to the first 200,000 characters. Copy includes the complete source."
168
+ }),
169
+ t.length === 0 && /* @__PURE__ */ c("div", {
170
+ ...i.props(n.note),
171
+ children: "No source text."
172
+ }),
173
+ y !== void 0 && y.hasFailed && /* @__PURE__ */ c("div", {
174
+ ...i.props(n.note),
175
+ children: "Syntax highlighting unavailable. The source is shown unchanged."
176
+ })
177
+ ]
178
+ });
179
+ }
180
+ export { _ as t };