@vvedantb/native-ui 0.17.2 → 0.18.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 (220) hide show
  1. package/dist/AlertDialog.jsx +123 -0
  2. package/dist/AmbientBackground.jsx +73 -0
  3. package/dist/ArtifactList.jsx +59 -0
  4. package/dist/Avatar.jsx +285 -0
  5. package/dist/Badge.jsx +154 -0
  6. package/dist/BottomSheetContainer.jsx +208 -0
  7. package/dist/BulkActionBar.jsx +717 -0
  8. package/dist/Button.jsx +344 -0
  9. package/dist/CaptureButton.jsx +104 -0
  10. package/dist/Card.jsx +371 -0
  11. package/dist/Checkbox.jsx +177 -0
  12. package/dist/Chip.jsx +79 -0
  13. package/dist/ColorSwatches.jsx +159 -0
  14. package/dist/ConfirmDialog.jsx +157 -0
  15. package/dist/DateTimeField.jsx +204 -0
  16. package/dist/Dialog.jsx +614 -0
  17. package/dist/DividedList.jsx +120 -0
  18. package/dist/DropdownMenu.jsx +849 -0
  19. package/dist/EmptyState.jsx +434 -0
  20. package/dist/ExpoWebRoot.jsx +134 -0
  21. package/dist/FloatingFAB.jsx +95 -0
  22. package/dist/FloatingSurface.jsx +226 -0
  23. package/dist/FloatingTabBar.jsx +403 -0
  24. package/dist/HeaderIconButton.jsx +53 -0
  25. package/dist/IconButton.jsx +157 -0
  26. package/dist/Input.jsx +96 -0
  27. package/dist/Label.jsx +96 -0
  28. package/dist/LabeledSwitchRow.jsx +170 -0
  29. package/dist/LiquidGlass.jsx +2 -0
  30. package/dist/ListRow.jsx +281 -0
  31. package/dist/LoadingState.jsx +205 -0
  32. package/dist/PageIndicator.jsx +128 -0
  33. package/dist/PageTitle.jsx +205 -0
  34. package/dist/Pager.jsx +105 -0
  35. package/dist/PasswordInput.jsx +120 -0
  36. package/dist/PillTabs.jsx +300 -0
  37. package/dist/PinnedBotTile.jsx +212 -0
  38. package/dist/Progress.jsx +147 -0
  39. package/dist/SafeAreaContainer.jsx +38 -0
  40. package/dist/ScreenContainer.jsx +117 -0
  41. package/dist/SearchInput.jsx +150 -0
  42. package/dist/SectionLabel.jsx +128 -0
  43. package/dist/Select.jsx +223 -0
  44. package/dist/Separator.jsx +95 -0
  45. package/dist/Sheet.jsx +343 -0
  46. package/dist/SheetRow.jsx +198 -0
  47. package/dist/Skeleton.jsx +311 -0
  48. package/dist/Spinner.jsx +195 -0
  49. package/dist/StackPageHeader.jsx +160 -0
  50. package/dist/StatGrid.jsx +74 -0
  51. package/dist/StatusDot.jsx +129 -0
  52. package/dist/SurfaceRow.jsx +143 -0
  53. package/dist/SwipeableRow.jsx +50 -0
  54. package/dist/Switch.jsx +130 -0
  55. package/dist/Tabs.jsx +385 -0
  56. package/dist/Textarea.jsx +103 -0
  57. package/dist/ThemeToggle.jsx +78 -0
  58. package/dist/Toast.jsx +396 -0
  59. package/dist/ai/activity-step-detail.jsx +179 -0
  60. package/dist/ai/activity-step-label.js +816 -0
  61. package/dist/ai/activity-step-types.js +14 -0
  62. package/dist/ai/activity-step.jsx +98 -0
  63. package/dist/ai/activity-tasks-utils.js +172 -0
  64. package/dist/ai/activity-timeline.js +47 -0
  65. package/dist/ai/attachments.jsx +258 -0
  66. package/dist/ai/card-button.jsx +188 -0
  67. package/dist/ai/chain-of-thought.jsx +459 -0
  68. package/dist/ai/chat-jump-rail.jsx +57 -0
  69. package/dist/ai/chat-text.js +44 -0
  70. package/dist/ai/chat-thread.jsx +135 -0
  71. package/dist/ai/choice-question.jsx +925 -0
  72. package/dist/ai/code-block.jsx +574 -0
  73. package/dist/ai/collapsible.jsx +275 -0
  74. package/dist/ai/conversation.jsx +723 -0
  75. package/dist/ai/file-chip.jsx +198 -0
  76. package/dist/ai/icon-button.jsx +179 -0
  77. package/dist/ai/index.js +37 -0
  78. package/dist/ai/message-action-sheet.jsx +408 -0
  79. package/dist/ai/message-quote.jsx +241 -0
  80. package/dist/ai/message.jsx +739 -0
  81. package/dist/ai/prompt-input-menu.jsx +365 -0
  82. package/dist/ai/prompt-input.jsx +626 -0
  83. package/dist/ai/reasoning.jsx +446 -0
  84. package/dist/ai/reply-quote-chip.jsx +278 -0
  85. package/dist/ai/response-text.jsx +130 -0
  86. package/dist/ai/shimmer.jsx +149 -0
  87. package/dist/ai/sources.jsx +260 -0
  88. package/dist/ai/subagent-cards.jsx +645 -0
  89. package/dist/ai/suggestion.jsx +186 -0
  90. package/dist/ai/tool-approval-card.jsx +359 -0
  91. package/dist/ai/trace.jsx +728 -0
  92. package/dist/ai/unified-diff.jsx +280 -0
  93. package/dist/ai/use-streaming-disclosure.js +70 -0
  94. package/dist/auth/AuthProviders.jsx +27 -0
  95. package/dist/auth/AuthScreen.jsx +292 -0
  96. package/dist/auth/GoogleSignInButton.jsx +188 -0
  97. package/dist/auth/SecondFactorScreen.jsx +133 -0
  98. package/dist/auth/SignInScreen.jsx +482 -0
  99. package/dist/auth/authErrors.js +131 -0
  100. package/dist/auth/index.js +11 -0
  101. package/dist/auth/totp.js +378 -0
  102. package/dist/blur.js +36 -0
  103. package/dist/brand/AppIcons.jsx +118 -0
  104. package/dist/brand/AppMark.jsx +128 -0
  105. package/dist/brand/AppWordmark.jsx +138 -0
  106. package/dist/brand/GoogleMark.jsx +71 -0
  107. package/dist/brand/ProviderIcon.jsx +192 -0
  108. package/dist/brand/familyApps.js +33 -0
  109. package/dist/brand/index.js +11 -0
  110. package/dist/brand/svg.js +252 -0
  111. package/dist/brand/vProAppBenefits.js +19 -0
  112. package/dist/cn.js +5 -0
  113. package/dist/colors.js +15 -0
  114. package/dist/configureTheme.js +72 -0
  115. package/dist/controlStyles.js +520 -0
  116. package/dist/definiteSize.js +12 -0
  117. package/dist/dialogLayout.js +18 -0
  118. package/dist/entries/ai.js +4 -0
  119. package/dist/entries/ambient.js +3 -0
  120. package/dist/entries/auth.js +5 -0
  121. package/dist/entries/bottom-sheet.js +2 -0
  122. package/dist/entries/brand.js +2 -0
  123. package/dist/entries/button.js +2 -0
  124. package/dist/entries/date-time.js +3 -0
  125. package/dist/entries/expo-router.js +4 -0
  126. package/dist/entries/expo-web-root.js +3 -0
  127. package/dist/entries/floating.js +7 -0
  128. package/dist/entries/gesture-handler.js +4 -0
  129. package/dist/entries/keyboard-controller.js +4 -0
  130. package/dist/entries/layout.js +16 -0
  131. package/dist/entries/markdown.js +4 -0
  132. package/dist/entries/marketing.js +3 -0
  133. package/dist/entries/page-title.js +7 -0
  134. package/dist/entries/password-input.js +3 -0
  135. package/dist/entries/primitives.js +57 -0
  136. package/dist/entries/search-input.js +3 -0
  137. package/dist/entries/tab-bar.js +4 -0
  138. package/dist/entries/theme.js +7 -0
  139. package/dist/entries/toast.js +5 -0
  140. package/dist/entries/video.js +3 -0
  141. package/dist/entries/webview.js +4 -0
  142. package/dist/examples/AiChatGallery.jsx +509 -0
  143. package/dist/examples/ParityGallery.jsx +1307 -0
  144. package/dist/floating.js +62 -0
  145. package/dist/glassBlur.jsx +145 -0
  146. package/dist/gradient.js +17 -0
  147. package/dist/haptics.js +44 -0
  148. package/dist/highlight.js +382 -0
  149. package/dist/index.js +85 -0
  150. package/dist/initials.js +4 -0
  151. package/dist/loadingGrid.js +81 -0
  152. package/dist/markdown/Markdown.jsx +515 -0
  153. package/dist/markdown/MarkdownTable.jsx +443 -0
  154. package/dist/markdown/tableText.js +68 -0
  155. package/dist/marketing/PricingModal.jsx +608 -0
  156. package/dist/marketing/UpgradeToProCard.jsx +164 -0
  157. package/dist/marketing/pricing.js +34 -0
  158. package/dist/media/ImageGallery.jsx +580 -0
  159. package/dist/media/MediaCard.jsx +162 -0
  160. package/dist/media/imageGrid.js +54 -0
  161. package/dist/motion.js +33 -0
  162. package/dist/pagerSwipe.js +104 -0
  163. package/dist/palette.js +104 -0
  164. package/dist/primitives/button.jsx +127 -0
  165. package/dist/primitives/card.jsx +249 -0
  166. package/dist/primitives/icon.jsx +37 -0
  167. package/dist/primitives/input.jsx +56 -0
  168. package/dist/primitives/keyboard-controller.jsx +207 -0
  169. package/dist/primitives/keyboard-parts.jsx +75 -0
  170. package/dist/primitives/native-only-animated-view.jsx +68 -0
  171. package/dist/primitives/overlay.jsx +391 -0
  172. package/dist/primitives/pager-gesture.jsx +131 -0
  173. package/dist/primitives/select-host.jsx +103 -0
  174. package/dist/primitives/select.jsx +555 -0
  175. package/dist/primitives/sheet-drag.jsx +420 -0
  176. package/dist/primitives/sheet-gesture.jsx +219 -0
  177. package/dist/primitives/swipe-row-gesture.jsx +341 -0
  178. package/dist/primitives/switch.jsx +105 -0
  179. package/dist/primitives/text.jsx +145 -0
  180. package/dist/primitives/toast-drag-gesture.jsx +94 -0
  181. package/dist/primitives/use-controllable-state.js +40 -0
  182. package/dist/primitives/web-click-guard.js +69 -0
  183. package/dist/push.js +166 -0
  184. package/dist/relativeTime.js +70 -0
  185. package/dist/router/RouterStackPageHeader.jsx +53 -0
  186. package/dist/selectA11y.js +32 -0
  187. package/dist/settings/MoreFromProjectV.jsx +168 -0
  188. package/dist/settings/SettingsEmptyState.jsx +102 -0
  189. package/dist/settings/SettingsField.jsx +49 -0
  190. package/dist/settings/SettingsSection.jsx +101 -0
  191. package/dist/settings/SettingsStack.jsx +17 -0
  192. package/dist/settings/SettingsToggleRow.jsx +163 -0
  193. package/dist/settings/projectVMobileApps.js +126 -0
  194. package/dist/settings/relaxedSizeStyle.js +11 -0
  195. package/dist/sheetDrag.js +76 -0
  196. package/dist/svgA11y.js +46 -0
  197. package/dist/swipeRow.js +161 -0
  198. package/dist/tabBarRoutes.js +41 -0
  199. package/dist/tabIndicator.js +139 -0
  200. package/dist/tailwind-preset.cjs +255 -0
  201. package/dist/tailwind-preset.d.cts +55 -0
  202. package/dist/theme.jsx +62 -0
  203. package/dist/toastChrome.js +110 -0
  204. package/dist/toastDrag.js +51 -0
  205. package/dist/toastStore.js +54 -0
  206. package/dist/tokens.js +70 -0
  207. package/dist/typography.js +40 -0
  208. package/dist/useReduceMotion.js +32 -0
  209. package/dist/useReduceTransparency.js +27 -0
  210. package/dist/useScheme.js +15 -0
  211. package/dist/video/InlineVideo.jsx +115 -0
  212. package/dist/webview/HtmlView.jsx +169 -0
  213. package/dist/webview/HtmlView.web.jsx +63 -0
  214. package/dist/webview/htmlView.js +43 -0
  215. package/package.json +70 -33
  216. package/src/DropdownMenu.tsx +28 -16
  217. package/src/FloatingTabBar.tsx +78 -41
  218. package/src/ai/conversation.tsx +12 -8
  219. package/src/glassBlur.tsx +47 -22
  220. package/src/primitives/swipe-row-gesture.tsx +11 -2
@@ -0,0 +1,574 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Fragment, useEffect, useRef, useState } from "react";
3
+ import { ScrollView, Text, View } from "react-native";
4
+ import { IconCheck, IconCopy, IconTextWrap } from "@tabler/icons-react-native";
5
+ import { cn } from "../cn";
6
+ import { sizeStyle, textStyle } from "../controlStyles";
7
+ import { GITHUB_CODE_COLORS, SCRIPT_LANGUAGES, SHELL_LANGUAGES, codeTokenColor, loadPrismReactRenderer, scriptTokens, shellTokens } from "../highlight";
8
+ import { useLargerText } from "../theme";
9
+ import { tokens } from "../tokens";
10
+ import { useScheme } from "../useScheme";
11
+ import { MONO_FONT, chatTextSize } from "./chat-text";
12
+ import { ChatIconButton } from "./icon-button";
13
+
14
+ /**
15
+ * `variant="markdown"`, the web `.markdown-code` (`MarkdownCodeBlock`): the header is `0.25rem 0.3rem 0 0.9rem` around a 28
16
+ * line (32 high), the code `0.25rem 0.9rem 0.8rem` at 13 with line-height
17
+ * 1.55, and the header actions are `icon-xs` (28) buttons.
18
+ */
19
+ export const CODE_BLOCK_METRICS = {
20
+ header: {
21
+ minHeight: 32,
22
+ paddingTop: 4,
23
+ paddingLeft: 14,
24
+ paddingRight: 5
25
+ },
26
+ code: {
27
+ paddingTop: 4,
28
+ paddingHorizontal: 14,
29
+ paddingBottom: 13
30
+ },
31
+ text: {
32
+ fontSize: 13,
33
+ lineHeight: 13 * 1.55
34
+ }
35
+ };
36
+ /** Ghost copy button: the copy icon, then a check for `timeout` after a copy. */
37
+ export function CodeBlockCopyButton(t0) {
38
+ const $ = _c(15);
39
+ const {
40
+ code,
41
+ onCopy,
42
+ timeout: t1,
43
+ label: t2,
44
+ size,
45
+ slop
46
+ } = t0;
47
+ const timeout = t1 === undefined ? 2000 : t1;
48
+ const label = t2 === undefined ? "Copy code" : t2;
49
+ const [copied, setCopied] = useState(false);
50
+ const timer = useRef(undefined);
51
+ let t3;
52
+ let t4;
53
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
54
+ t3 = () => () => clearTimeout(timer.current);
55
+ t4 = [];
56
+ $[0] = t3;
57
+ $[1] = t4;
58
+ } else {
59
+ t3 = $[0];
60
+ t4 = $[1];
61
+ }
62
+ useEffect(t3, t4);
63
+ let t5;
64
+ if ($[2] !== code || $[3] !== copied || $[4] !== onCopy || $[5] !== timeout) {
65
+ t5 = async () => {
66
+ if (copied) {
67
+ return;
68
+ }
69
+ try {
70
+ await onCopy(code);
71
+ } catch {
72
+ return;
73
+ }
74
+ setCopied(true);
75
+ timer.current = setTimeout(() => setCopied(false), timeout);
76
+ };
77
+ $[2] = code;
78
+ $[3] = copied;
79
+ $[4] = onCopy;
80
+ $[5] = timeout;
81
+ $[6] = t5;
82
+ } else {
83
+ t5 = $[6];
84
+ }
85
+ const copy = t5;
86
+ const t6 = copied ? IconCheck : IconCopy;
87
+ const t7 = copied ? "Copied" : label;
88
+ let t8;
89
+ if ($[7] !== copy) {
90
+ t8 = () => void copy();
91
+ $[7] = copy;
92
+ $[8] = t8;
93
+ } else {
94
+ t8 = $[8];
95
+ }
96
+ let t9;
97
+ if ($[9] !== size || $[10] !== slop || $[11] !== t6 || $[12] !== t7 || $[13] !== t8) {
98
+ t9 = <ChatIconButton icon={t6} label={t7} size={size} slop={slop} onPress={t8} />;
99
+ $[9] = size;
100
+ $[10] = slop;
101
+ $[11] = t6;
102
+ $[12] = t7;
103
+ $[13] = t8;
104
+ $[14] = t9;
105
+ } else {
106
+ t9 = $[14];
107
+ }
108
+ return t9;
109
+ }
110
+ /**
111
+ * Code on the flat panel at radius 16, selectable, long lines scrolling
112
+ * sideways. With `prism-react-renderer` installed and a `language`, tokens
113
+ * take the GitHub colours of the scheme.
114
+ *
115
+ * `default` is the web `CodeBlock` (`ai-elements/code-block.tsx`): `text-sm`
116
+ * code in `p-4`, and a `px-3` header with the language and a copy button when
117
+ * either is given. `markdown` is the web `MarkdownCodeBlock`, which `Markdown`
118
+ * draws for fenced code: 13 / 20.15 code, a 32 header with `icon-xs` actions,
119
+ * a wrap toggle ("Wrap long lines", foreground while on) and then copy.
120
+ */
121
+ /**
122
+ * Android fades the code at a side with more to scroll (there is no scroll
123
+ * bar), so a cut line reads as "scroll sideways". iOS ignores it.
124
+ */
125
+ const CODE_FADING_EDGE = 24;
126
+ export function CodeBlock(t0) {
127
+ const $ = _c(21);
128
+ const {
129
+ code,
130
+ language,
131
+ highlight: t1,
132
+ onCopy,
133
+ variant: t2,
134
+ className
135
+ } = t0;
136
+ const highlight = t1 === undefined ? true : t1;
137
+ const variant = t2 === undefined ? "default" : t2;
138
+ const parts = useCodeParts(code, language, highlight, variant === "markdown");
139
+ if (variant === "markdown") {
140
+ let t3;
141
+ if ($[0] !== className || $[1] !== code || $[2] !== language || $[3] !== onCopy || $[4] !== parts) {
142
+ t3 = <MarkdownCodeBlock code={code} language={language} onCopy={onCopy} className={className} parts={parts} />;
143
+ $[0] = className;
144
+ $[1] = code;
145
+ $[2] = language;
146
+ $[3] = onCopy;
147
+ $[4] = parts;
148
+ $[5] = t3;
149
+ } else {
150
+ t3 = $[5];
151
+ }
152
+ return t3;
153
+ }
154
+ const header = Boolean(language || onCopy);
155
+ let t3;
156
+ if ($[6] !== className) {
157
+ t3 = cn("w-full overflow-hidden", className);
158
+ $[6] = className;
159
+ $[7] = t3;
160
+ } else {
161
+ t3 = $[7];
162
+ }
163
+ let t4;
164
+ if ($[8] !== code || $[9] !== header || $[10] !== onCopy || $[11] !== parts.label) {
165
+ t4 = header ? <View className="min-h-11 flex-row items-center justify-between pl-3 pr-1.5">{parts.label}{onCopy ? <CodeBlockCopyButton code={code} onCopy={onCopy} /> : null}</View> : null;
166
+ $[8] = code;
167
+ $[9] = header;
168
+ $[10] = onCopy;
169
+ $[11] = parts.label;
170
+ $[12] = t4;
171
+ } else {
172
+ t4 = $[12];
173
+ }
174
+ const t5 = header ? "px-4 pb-4" : "p-4";
175
+ let t6;
176
+ if ($[13] !== parts.text || $[14] !== t5) {
177
+ t6 = <ScrollView horizontal={true} showsHorizontalScrollIndicator={false} fadingEdgeLength={CODE_FADING_EDGE} contentContainerClassName={t5}>{parts.text}</ScrollView>;
178
+ $[13] = parts.text;
179
+ $[14] = t5;
180
+ $[15] = t6;
181
+ } else {
182
+ t6 = $[15];
183
+ }
184
+ let t7;
185
+ if ($[16] !== parts.panel || $[17] !== t3 || $[18] !== t4 || $[19] !== t6) {
186
+ t7 = <View className={t3} style={parts.panel}>{t4}{t6}</View>;
187
+ $[16] = parts.panel;
188
+ $[17] = t3;
189
+ $[18] = t4;
190
+ $[19] = t6;
191
+ $[20] = t7;
192
+ } else {
193
+ t7 = $[20];
194
+ }
195
+ return t7;
196
+ }
197
+
198
+ /** The web `MarkdownCodeBlock`: `CodeBlock` with `variant="markdown"`. A component of its own for the wrap state. */
199
+ function MarkdownCodeBlock(t0) {
200
+ const $ = _c(21);
201
+ const {
202
+ code,
203
+ language,
204
+ onCopy,
205
+ className,
206
+ parts
207
+ } = t0;
208
+ const scheme = useScheme();
209
+ const largerText = useLargerText();
210
+ const [wrap, setWrap] = useState(false);
211
+ const header = Boolean(language || onCopy);
212
+ const {
213
+ header: headerBox,
214
+ code: codeBox
215
+ } = CODE_BLOCK_METRICS;
216
+ let t1;
217
+ if ($[0] !== header) {
218
+ t1 = header ? codeBox : {
219
+ ...codeBox,
220
+ paddingTop: codeBox.paddingBottom
221
+ };
222
+ $[0] = header;
223
+ $[1] = t1;
224
+ } else {
225
+ t1 = $[1];
226
+ }
227
+ const padding = t1;
228
+ let t2;
229
+ if ($[2] !== className) {
230
+ t2 = cn("w-full overflow-hidden", className);
231
+ $[2] = className;
232
+ $[3] = t2;
233
+ } else {
234
+ t2 = $[3];
235
+ }
236
+ let t3;
237
+ if ($[4] !== code || $[5] !== header || $[6] !== largerText || $[7] !== onCopy || $[8] !== parts.label || $[9] !== scheme || $[10] !== wrap) {
238
+ t3 = header ? <View className={cn("flex-row items-center justify-between gap-2", largerText && "min-h-11")} style={largerText ? {
239
+ paddingLeft: headerBox.paddingLeft,
240
+ paddingRight: headerBox.paddingRight
241
+ } : headerBox}>{parts.label}<View className="flex-row items-center gap-0.5"><ChatIconButton icon={IconTextWrap} label={wrap ? "Scroll long lines" : "Wrap long lines"} size="xs" iconColor={wrap ? tokens.color.foreground[scheme] : tokens.color.muted[scheme]} accessibilityState={{
242
+ selected: wrap
243
+ }} slop={{
244
+ left: 8,
245
+ right: 0
246
+ }} onPress={() => setWrap(!wrap)} />{onCopy ? <CodeBlockCopyButton code={code} onCopy={onCopy} size="xs" slop={{
247
+ left: 0,
248
+ right: 5
249
+ }} /> : null}</View></View> : null;
250
+ $[4] = code;
251
+ $[5] = header;
252
+ $[6] = largerText;
253
+ $[7] = onCopy;
254
+ $[8] = parts.label;
255
+ $[9] = scheme;
256
+ $[10] = wrap;
257
+ $[11] = t3;
258
+ } else {
259
+ t3 = $[11];
260
+ }
261
+ let t4;
262
+ if ($[12] !== padding || $[13] !== parts.text || $[14] !== wrap) {
263
+ t4 = wrap ? <View style={padding}>{parts.text}</View> : <ScrollView horizontal={true} showsHorizontalScrollIndicator={false} fadingEdgeLength={CODE_FADING_EDGE} contentContainerStyle={padding}>{parts.text}</ScrollView>;
264
+ $[12] = padding;
265
+ $[13] = parts.text;
266
+ $[14] = wrap;
267
+ $[15] = t4;
268
+ } else {
269
+ t4 = $[15];
270
+ }
271
+ let t5;
272
+ if ($[16] !== parts.panel || $[17] !== t2 || $[18] !== t3 || $[19] !== t4) {
273
+ t5 = <View className={t2} style={parts.panel}>{t3}{t4}</View>;
274
+ $[16] = parts.panel;
275
+ $[17] = t2;
276
+ $[18] = t3;
277
+ $[19] = t4;
278
+ $[20] = t5;
279
+ } else {
280
+ t5 = $[20];
281
+ }
282
+ return t5;
283
+ }
284
+
285
+ /** The panel style, the language label and the code text both code blocks draw. */
286
+ function useCodeParts(code, language, highlight, markdown) {
287
+ const $ = _c(42);
288
+ const scheme = useScheme();
289
+ const largerText = useLargerText();
290
+ let T0;
291
+ let t0;
292
+ let t1;
293
+ let t2;
294
+ if ($[0] !== code || $[1] !== highlight || $[2] !== language || $[3] !== largerText || $[4] !== markdown || $[5] !== scheme) {
295
+ const size = chatTextSize("small", largerText);
296
+ const caption = chatTextSize("caption", largerText);
297
+ const t3 = markdown && !largerText ? CODE_BLOCK_METRICS.text : sizeStyle(size);
298
+ let t4;
299
+ if ($[10] !== scheme) {
300
+ t4 = textStyle("foreground", scheme);
301
+ $[10] = scheme;
302
+ $[11] = t4;
303
+ } else {
304
+ t4 = $[11];
305
+ }
306
+ let t5;
307
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
308
+ t5 = {
309
+ fontFamily: MONO_FONT
310
+ };
311
+ $[12] = t5;
312
+ } else {
313
+ t5 = $[12];
314
+ }
315
+ let t6;
316
+ if ($[13] !== t3 || $[14] !== t4) {
317
+ t6 = [t3, t4, t5];
318
+ $[13] = t3;
319
+ $[14] = t4;
320
+ $[15] = t6;
321
+ } else {
322
+ t6 = $[15];
323
+ }
324
+ let t7;
325
+ if ($[16] !== code || $[17] !== highlight || $[18] !== language || $[19] !== scheme) {
326
+ t7 = highlight && language ? <HighlightedCode code={code} language={language} scheme={scheme} /> : code;
327
+ $[16] = code;
328
+ $[17] = highlight;
329
+ $[18] = language;
330
+ $[19] = scheme;
331
+ $[20] = t7;
332
+ } else {
333
+ t7 = $[20];
334
+ }
335
+ let t8;
336
+ if ($[21] !== size || $[22] !== t6 || $[23] !== t7) {
337
+ t8 = <Text selectable={true} className={size} style={t6}>{t7}</Text>;
338
+ $[21] = size;
339
+ $[22] = t6;
340
+ $[23] = t7;
341
+ $[24] = t8;
342
+ } else {
343
+ t8 = $[24];
344
+ }
345
+ const text = t8;
346
+ t2 = text;
347
+ T0 = Text;
348
+ t1 = caption;
349
+ t0 = sizeStyle(caption);
350
+ $[0] = code;
351
+ $[1] = highlight;
352
+ $[2] = language;
353
+ $[3] = largerText;
354
+ $[4] = markdown;
355
+ $[5] = scheme;
356
+ $[6] = T0;
357
+ $[7] = t0;
358
+ $[8] = t1;
359
+ $[9] = t2;
360
+ } else {
361
+ T0 = $[6];
362
+ t0 = $[7];
363
+ t1 = $[8];
364
+ t2 = $[9];
365
+ }
366
+ let t3;
367
+ if ($[25] !== scheme) {
368
+ t3 = textStyle("muted", scheme);
369
+ $[25] = scheme;
370
+ $[26] = t3;
371
+ } else {
372
+ t3 = $[26];
373
+ }
374
+ let t4;
375
+ if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
376
+ t4 = {
377
+ fontFamily: MONO_FONT
378
+ };
379
+ $[27] = t4;
380
+ } else {
381
+ t4 = $[27];
382
+ }
383
+ let t5;
384
+ if ($[28] !== t0 || $[29] !== t3) {
385
+ t5 = [t0, t3, t4];
386
+ $[28] = t0;
387
+ $[29] = t3;
388
+ $[30] = t5;
389
+ } else {
390
+ t5 = $[30];
391
+ }
392
+ const t6 = language ?? "";
393
+ let t7;
394
+ if ($[31] !== T0 || $[32] !== t1 || $[33] !== t5 || $[34] !== t6) {
395
+ t7 = <T0 className={t1} style={t5}>{t6}</T0>;
396
+ $[31] = T0;
397
+ $[32] = t1;
398
+ $[33] = t5;
399
+ $[34] = t6;
400
+ $[35] = t7;
401
+ } else {
402
+ t7 = $[35];
403
+ }
404
+ const t8 = tokens.color.surfaceSecondary[scheme];
405
+ let t9;
406
+ if ($[36] !== t8) {
407
+ t9 = {
408
+ borderRadius: tokens.radius.lg,
409
+ backgroundColor: t8
410
+ };
411
+ $[36] = t8;
412
+ $[37] = t9;
413
+ } else {
414
+ t9 = $[37];
415
+ }
416
+ let t10;
417
+ if ($[38] !== t2 || $[39] !== t7 || $[40] !== t9) {
418
+ t10 = {
419
+ text: t2,
420
+ label: t7,
421
+ panel: t9
422
+ };
423
+ $[38] = t2;
424
+ $[39] = t7;
425
+ $[40] = t9;
426
+ $[41] = t10;
427
+ } else {
428
+ t10 = $[41];
429
+ }
430
+ return t10;
431
+ }
432
+
433
+ /**
434
+ * Coloured runs as nested `Text` spans, lines joined by newlines. They
435
+ * inherit the size and font of the code `Text` around them.
436
+ */
437
+ function CodeRuns(t0) {
438
+ const $ = _c(7);
439
+ const {
440
+ lines,
441
+ scheme
442
+ } = t0;
443
+ let t1;
444
+ if ($[0] !== lines || $[1] !== scheme) {
445
+ let t2;
446
+ if ($[3] !== scheme) {
447
+ t2 = (line, lineIndex) => <Fragment key={lineIndex}>{lineIndex > 0 ? "\n" : null}{line.map((token, tokenIndex) => <Text key={tokenIndex} style={{
448
+ color: GITHUB_CODE_COLORS[scheme][token.role]
449
+ }}>{token.content}</Text>)}</Fragment>;
450
+ $[3] = scheme;
451
+ $[4] = t2;
452
+ } else {
453
+ t2 = $[4];
454
+ }
455
+ t1 = lines.map(t2);
456
+ $[0] = lines;
457
+ $[1] = scheme;
458
+ $[2] = t1;
459
+ } else {
460
+ t1 = $[2];
461
+ }
462
+ let t2;
463
+ if ($[5] !== t1) {
464
+ t2 = <>{t1}</>;
465
+ $[5] = t1;
466
+ $[6] = t2;
467
+ } else {
468
+ t2 = $[6];
469
+ }
470
+ return t2;
471
+ }
472
+
473
+ /**
474
+ * The code in the web's Shiki colours: shell blocks through `shellTokens`
475
+ * (no peer needed), other languages through Prism, the JavaScript family
476
+ * recoloured where Prism and Shiki disagree (`scriptTokens`). Without
477
+ * `prism-react-renderer` a non-shell block is the plain code.
478
+ */
479
+ function HighlightedCode(t0) {
480
+ const $ = _c(19);
481
+ const {
482
+ code,
483
+ language,
484
+ scheme
485
+ } = t0;
486
+ let lang;
487
+ let source;
488
+ let t1;
489
+ if ($[0] !== code || $[1] !== language || $[2] !== scheme) {
490
+ t1 = Symbol.for("react.early_return_sentinel");
491
+ bb0: {
492
+ lang = language.toLowerCase();
493
+ source = code.replace(/\n$/, "");
494
+ if (SHELL_LANGUAGES.has(lang)) {
495
+ t1 = <CodeRuns lines={shellTokens(source)} scheme={scheme} />;
496
+ break bb0;
497
+ }
498
+ }
499
+ $[0] = code;
500
+ $[1] = language;
501
+ $[2] = scheme;
502
+ $[3] = lang;
503
+ $[4] = source;
504
+ $[5] = t1;
505
+ } else {
506
+ lang = $[3];
507
+ source = $[4];
508
+ t1 = $[5];
509
+ }
510
+ if (t1 !== Symbol.for("react.early_return_sentinel")) {
511
+ return t1;
512
+ }
513
+ const Highlight = loadPrismReactRenderer()?.Highlight;
514
+ if (!Highlight) {
515
+ return code;
516
+ }
517
+ const t2 = GITHUB_CODE_COLORS[scheme];
518
+ let t3;
519
+ if ($[6] !== t2.plain) {
520
+ t3 = {
521
+ color: t2.plain
522
+ };
523
+ $[6] = t2.plain;
524
+ $[7] = t3;
525
+ } else {
526
+ t3 = $[7];
527
+ }
528
+ let t4;
529
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
530
+ t4 = [];
531
+ $[8] = t4;
532
+ } else {
533
+ t4 = $[8];
534
+ }
535
+ let t5;
536
+ if ($[9] !== t3) {
537
+ t5 = {
538
+ plain: t3,
539
+ styles: t4
540
+ };
541
+ $[9] = t3;
542
+ $[10] = t5;
543
+ } else {
544
+ t5 = $[10];
545
+ }
546
+ let t6;
547
+ if ($[11] !== lang || $[12] !== scheme) {
548
+ t6 = t7 => {
549
+ const {
550
+ tokens
551
+ } = t7;
552
+ return SCRIPT_LANGUAGES.has(lang) ? <CodeRuns lines={scriptTokens(tokens)} scheme={scheme} /> : <>{tokens.map((line, lineIndex) => <Fragment key={lineIndex}>{lineIndex > 0 ? "\n" : null}{line.map((token, tokenIndex) => token.empty ? null : <Text key={tokenIndex} style={{
553
+ color: codeTokenColor(token.types, scheme)
554
+ }}>{token.content}</Text>)}</Fragment>)}</>;
555
+ };
556
+ $[11] = lang;
557
+ $[12] = scheme;
558
+ $[13] = t6;
559
+ } else {
560
+ t6 = $[13];
561
+ }
562
+ let t7;
563
+ if ($[14] !== lang || $[15] !== source || $[16] !== t5 || $[17] !== t6) {
564
+ t7 = <Highlight code={source} language={lang} theme={t5}>{t6}</Highlight>;
565
+ $[14] = lang;
566
+ $[15] = source;
567
+ $[16] = t5;
568
+ $[17] = t6;
569
+ $[18] = t7;
570
+ } else {
571
+ t7 = $[18];
572
+ }
573
+ return t7;
574
+ }