@mechane-ai/elements 0.9.0 → 0.11.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 (78) hide show
  1. package/NOTICE +24 -0
  2. package/README.md +7 -1
  3. package/dist/ai.js +153 -133
  4. package/dist/{categorical-values-DYRiw5Qd.js → categorical-values-FYc43JCa.js} +4 -4
  5. package/dist/{chart-frame-RL1hCWBC.js → chart-frame-Bczk5sWj.js} +22 -14
  6. package/dist/{chart-input-Bm3ot1yD.js → chart-input-CbzVN76m.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 +119 -92
  13. package/dist/charts.js +1 -1
  14. package/dist/code-block-B7xzM3tD.js +180 -0
  15. package/dist/collections.js +319 -242
  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-BrPrpBof.js → content-link-CatGOrbo.js} +6 -2
  22. package/dist/content.js +172 -153
  23. package/dist/{assets/stylex.css → elements.css} +585 -229
  24. package/dist/feedback.js +1 -1
  25. package/dist/forms/dates.js +25 -25
  26. package/dist/forms.js +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/layout.js +239 -192
  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 +14 -2
  34. package/dist/packages/ai/src/index.d.ts +1 -1
  35. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +5 -0
  36. package/dist/packages/charts/src/cartesian/index.d.ts +2 -2
  37. package/dist/packages/charts/src/chart-frame.d.ts +3 -0
  38. package/dist/packages/charts/src/chart-theme.d.ts +2 -1
  39. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +22 -2
  40. package/dist/packages/charts/src/timeline/waterfall.d.ts +3 -2
  41. package/dist/packages/collections/src/collection-scroll.d.ts +2 -1
  42. package/dist/packages/collections/src/index.d.ts +1 -0
  43. package/dist/packages/collections/src/inspector.d.ts +6 -3
  44. package/dist/packages/content/src/diff/pierre-diff.d.ts +2 -1
  45. package/dist/packages/content/src/viewer-styles.d.ts +64 -0
  46. package/dist/packages/core/src/agent-avatar-glyphs.d.ts +1 -1
  47. package/dist/packages/core/src/index.d.ts +1 -1
  48. package/dist/packages/core/src/surfaces.d.ts +5 -0
  49. package/dist/packages/feedback/src/index.d.ts +4 -1
  50. package/dist/packages/feedback/src/toast.d.ts +5 -27
  51. package/dist/packages/forms/src/field-styles.d.ts +9 -0
  52. package/dist/packages/forms/src/selection-styles.d.ts +18 -2
  53. package/dist/packages/foundations/src/overlay-styles.d.ts +3 -1
  54. package/dist/packages/foundations/src/popup-styles.d.ts +7 -0
  55. package/dist/packages/foundations/src/tokens.stylex.d.ts +9 -0
  56. package/dist/packages/layout/src/frame.stylex.d.ts +1 -0
  57. package/dist/packages/layout/src/sidebar.d.ts +3 -1
  58. package/dist/packages/overlays/src/alert-dialog.d.ts +5 -2
  59. package/dist/packages/overlays/src/dialog.d.ts +7 -3
  60. package/dist/pierre-diff--zsiHCCB.js +71 -0
  61. package/dist/pierre-theme-D9hnHv3Z.js +126 -0
  62. package/dist/{pierre-tree-CRk09rx7.js → pierre-tree-D47uA7lb.js} +3 -3
  63. package/dist/{src-Cc0Sadzr.js → src-C_heP5kL.js} +295 -221
  64. package/dist/src-Cs0dRc4X.js +617 -0
  65. package/dist/src-D05isEh_.js +1652 -0
  66. package/dist/src-DXsGTJgv.js +969 -0
  67. package/dist/tokens.js +33 -25
  68. package/dist/viewer-styles-CpHqp5Qv.js +70 -0
  69. package/package.json +2 -1
  70. package/packages/foundations/src/tokens.stylex.ts +55 -48
  71. package/styles.css +1 -1
  72. package/dist/code-block-B30xQKqg.js +0 -175
  73. package/dist/pierre-diff-CZdzgiYm.js +0 -66
  74. package/dist/pierre-theme-BpESNIsV.js +0 -96
  75. package/dist/popup-styles-CvtZDE2t.js +0 -135
  76. package/dist/src-CfDf8TY8.js +0 -466
  77. package/dist/src-DuuAmS-c.js +0 -360
  78. package/dist/src-elMBQ2Dh.js +0 -1087
@@ -1,15 +1,16 @@
1
- import { c as e } from "../src-elMBQ2Dh.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-D05isEh_.js";
2
+ import { n as t, t as n } from "../chart-input-CbzVN76m.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,188 @@ 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, selectedRef: x, onSelect: S, formatOffset: C }) {
38
+ let w = p({
39
+ items: t,
40
+ start: s,
41
+ end: f
42
+ });
43
+ if (w !== void 0) return /* @__PURE__ */ i(n, {
44
+ title: g,
45
+ message: w
46
+ });
47
+ let T = f - s, E = o({
48
+ domain: [s, f],
49
+ range: [0, T === 0 ? 0 : d]
50
+ }), D = T > 0 ? u : [0], O = t.some((e) => e.geometry.kind !== "unavailable");
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: O ? D.map((e) => /* @__PURE__ */ i("span", { children: C(T * e) }, e)) : /* @__PURE__ */ i("span", { children: "Timing unavailable" })
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: C
80
90
  });
81
- return /* @__PURE__ */ r("button", {
91
+ return /* @__PURE__ */ a("button", {
92
+ ref: b === t.id ? x : void 0,
82
93
  type: "button",
83
- "aria-pressed": v === i.id,
84
- "aria-label": `${i.label} · ${i.detail} · ${i.summary} · ${a}`,
85
- onClick: () => y(i.id),
94
+ "aria-pressed": b === t.id,
95
+ "aria-label": `${t.label} · ${t.detail} · ${t.summary} · ${n}`,
96
+ onClick: () => S(t.id),
86
97
  ...{
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],
98
+ 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" },
99
+ 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" }
100
+ }[b === t.id | 0],
90
101
  children: [
91
- /* @__PURE__ */ r("span", {
102
+ /* @__PURE__ */ a("span", {
92
103
  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, {
104
+ children: [/* @__PURE__ */ i(e, { children: t.label }), /* @__PURE__ */ i("span", {
105
+ title: t.detail,
106
+ ...{
107
+ 0: { className: "xb3r6kr xuxw1ft xlyipyv" },
108
+ 1: { className: "xb3r6kr xlyipyv xeaf4i8 xj0a0fe" }
109
+ }[b === t.id | 0],
110
+ children: /* @__PURE__ */ i(e, {
100
111
  variant: "caption",
101
112
  tone: "muted",
102
- children: i.detail
113
+ children: t.detail
103
114
  })
104
115
  })]
105
116
  }),
106
- /* @__PURE__ */ n("span", {
107
- title: a,
108
- ...t.props(o.plot, s[i.tone]),
109
- children: i.geometry.kind === "unavailable" ? /* @__PURE__ */ n(e, {
117
+ /* @__PURE__ */ i("span", {
118
+ title: n,
119
+ ...r.props(c.plot, l[t.tone]),
120
+ children: t.geometry.kind === "unavailable" ? /* @__PURE__ */ i(e, {
110
121
  variant: "caption",
111
122
  tone: "muted",
112
- children: a
113
- }) : /* @__PURE__ */ r("svg", {
123
+ children: n
124
+ }) : /* @__PURE__ */ a("svg", {
114
125
  "aria-hidden": !0,
115
126
  className: "x1lliihq xh8yej3 xmix8c7 x1rea2x4",
116
- children: [C.map((e) => /* @__PURE__ */ n("line", {
117
- x1: `${e * l}%`,
118
- x2: `${e * l}%`,
127
+ children: [D.map((e) => /* @__PURE__ */ i("line", {
128
+ x1: `${e * d}%`,
129
+ x2: `${e * d}%`,
119
130
  y1: "0",
120
131
  y2: "18",
121
132
  className: "x13hfdr1"
122
- }, e)), /* @__PURE__ */ n(d, {
123
- geometry: i.geometry,
124
- scale: S
133
+ }, e)), /* @__PURE__ */ i(m, {
134
+ geometry: t.geometry,
135
+ scale: E
125
136
  })]
126
137
  })
127
138
  }),
128
- /* @__PURE__ */ n("span", {
129
- className: "xeuugli x1k3v4rp x1moszlt x1ms6mhf xp4054r xj0a0fe xss6m8b",
130
- children: /* @__PURE__ */ n(e, {
139
+ /* @__PURE__ */ a("span", {
140
+ className: "xrvj5dj xfko13i xeuugli x1k3v4rp x14r0xmm x1ms6mhf xp4054r xj0a0fe xss6m8b",
141
+ children: [/* @__PURE__ */ i(e, {
131
142
  variant: "caption",
132
143
  tone: "muted",
133
- children: i.summary
134
- })
144
+ children: t.summary
145
+ }), b === t.id && /* @__PURE__ */ i(e, {
146
+ variant: "caption",
147
+ tone: "muted",
148
+ children: n
149
+ })]
135
150
  })
136
151
  ]
137
- }, i.id);
152
+ }, t.id);
138
153
  })
139
154
  ]
140
155
  });
141
156
  }
142
- function d({ geometry: e, scale: t }) {
157
+ function p({ items: e, start: n, end: r }) {
158
+ if (!Number.isFinite(n) || !Number.isFinite(r) || !Number.isFinite(r - n) || r < n) return "The timing domain must have finite, ordered endpoints.";
159
+ if (!t(e)) return "Timing records must have unique identifiers.";
160
+ for (let t of e) {
161
+ let e = t.geometry;
162
+ if (e.kind === "interval") {
163
+ if (!Number.isFinite(e.start) || !Number.isFinite(e.end) || e.end < e.start) return "Timing intervals must have finite, ordered endpoints.";
164
+ if (e.start < n || e.end > r) return "Timing intervals must fit inside the supplied domain.";
165
+ }
166
+ 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.";
167
+ }
168
+ }
169
+ function m({ geometry: e, scale: t }) {
143
170
  switch (e.kind) {
144
171
  case "unavailable": return null;
145
172
  case "interval": {
146
- let r = t(e.start), i = t(e.end) - r;
147
- return i === 0 ? /* @__PURE__ */ n("circle", {
148
- cx: `${r}%`,
173
+ let n = t(e.start), r = t(e.end) - n;
174
+ return r === 0 ? /* @__PURE__ */ i("circle", {
175
+ cx: `${n}%`,
149
176
  cy: 9,
150
177
  r: 3,
151
178
  className: "x117rol3"
152
- }) : /* @__PURE__ */ n(a, {
153
- x: `${r}%`,
179
+ }) : /* @__PURE__ */ i(s, {
180
+ x: `${n}%`,
154
181
  y: 6,
155
- width: `${i}%`,
182
+ width: `${r}%`,
156
183
  height: 6,
157
184
  rx: 2,
158
185
  className: "x117rol3"
159
186
  });
160
187
  }
161
188
  case "point": {
162
- let r = t(e.at);
189
+ let n = t(e.at);
163
190
  switch (e.marker) {
164
- case "filled": return /* @__PURE__ */ n("circle", {
165
- cx: `${r}%`,
191
+ case "filled": return /* @__PURE__ */ i("circle", {
192
+ cx: `${n}%`,
166
193
  cy: 9,
167
194
  r: 3,
168
195
  className: "x117rol3"
169
196
  });
170
- case "hollow": return /* @__PURE__ */ n("circle", {
171
- cx: `${r}%`,
197
+ case "hollow": return /* @__PURE__ */ i("circle", {
198
+ cx: `${n}%`,
172
199
  cy: 9,
173
200
  r: 3.5,
174
201
  className: "x1fytgo2 x73je2i xvlca1e"
175
202
  });
176
- case "diamond": return /* @__PURE__ */ n("svg", {
177
- x: `${r}%`,
203
+ case "diamond": return /* @__PURE__ */ i("svg", {
204
+ x: `${n}%`,
178
205
  y: 9,
179
206
  width: 1,
180
207
  height: 1,
181
208
  overflow: "visible",
182
- children: /* @__PURE__ */ n("path", {
209
+ children: /* @__PURE__ */ i("path", {
183
210
  d: "M0 -5 5 0 0 5 -5 0Z",
184
211
  className: "x117rol3"
185
212
  })
@@ -188,11 +215,11 @@ function d({ geometry: e, scale: t }) {
188
215
  }
189
216
  }
190
217
  }
191
- function f({ geometry: e, start: t, formatOffset: n }) {
218
+ function h({ geometry: e, start: t, formatOffset: n }) {
192
219
  switch (e.kind) {
193
220
  case "interval": return `Start ${n(e.start - t)}, end ${n(e.end - t)}, duration ${n(e.end - e.start)}`;
194
221
  case "point": return `At ${n(e.at - t)}`;
195
222
  case "unavailable": return "Timing unavailable";
196
223
  }
197
224
  }
198
- export { u as Waterfall };
225
+ export { f as Waterfall };
package/dist/charts.js CHANGED
@@ -1 +1 @@
1
- export { r as ChartFrame, i as ChartLegend } from "./chart-frame-RL1hCWBC.js";
1
+ export { r as ChartFrame, i as ChartLegend } from "./chart-frame-Bczk5sWj.js";
@@ -0,0 +1,180 @@
1
+ import { _ as e } from "./src-D05isEh_.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 };