@yuhuanowo/yunui 0.1.4

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.
@@ -0,0 +1,1031 @@
1
+ "use client";
2
+ import { Button, Card, Badge, Avatar, AvatarImage, AvatarFallback, IconButton, Spinner } from './chunk-OHIFY64L.js';
3
+ import { copyToClipboard } from './chunk-WASCOOVD.js';
4
+ import { cn } from './chunk-DRZ7UCRU.js';
5
+ import { useYunUI } from './chunk-XZGNL5A6.js';
6
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+ import React, { useState, useEffect, useCallback, useRef } from 'react';
8
+ import { AlertCircle, RefreshCw, Check, Copy, Plus, FileText, ExternalLink, Calendar, Clock, User, ChevronLeft, ChevronRight, PanelLeftClose, X, ArrowUpRight, ArrowDownRight, GraduationCap, Award, Waves, SlidersHorizontal, Layers, Fingerprint, Ban, Image, Brain, Eye, Code, MessageSquare, XCircle, Zap, CheckCircle, FileCode, EyeOff } from 'lucide-react';
9
+
10
+ function BackgroundEffects() {
11
+ return /* @__PURE__ */ jsx("div", { className: "absolute inset-0 -z-10 h-full w-full pointer-events-none select-none overflow-hidden bg-(--bg-base)", children: /* @__PURE__ */ jsx(
12
+ "div",
13
+ {
14
+ className: "absolute inset-0 h-full w-full",
15
+ style: {
16
+ backgroundImage: `radial-gradient(var(--text-secondary) 1px, transparent 1px)`,
17
+ backgroundSize: "32px 32px",
18
+ opacity: 0.12,
19
+ maskImage: "radial-gradient(ellipse at center, black 40%, transparent 80%)",
20
+ WebkitMaskImage: "radial-gradient(ellipse at center, black 40%, transparent 80%)"
21
+ }
22
+ }
23
+ ) });
24
+ }
25
+ function tokenizeLine(line) {
26
+ const tokens = [];
27
+ let remaining = line;
28
+ let pos = 0;
29
+ while (pos < line.length) {
30
+ if (/\s/.test(line[pos])) {
31
+ const match = line.slice(pos).match(/^\s+/);
32
+ if (match) {
33
+ tokens.push({ type: "text", value: match[0] });
34
+ pos += match[0].length;
35
+ remaining = line.slice(pos);
36
+ continue;
37
+ }
38
+ }
39
+ const stringMatch = remaining.match(/^("([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`)/);
40
+ if (stringMatch) {
41
+ tokens.push({ type: "string", value: stringMatch[0] });
42
+ pos += stringMatch[0].length;
43
+ remaining = line.slice(pos);
44
+ continue;
45
+ }
46
+ const commentMatch = remaining.match(/^(\/\/.*$|#.*$)/);
47
+ if (commentMatch) {
48
+ tokens.push({ type: "comment", value: commentMatch[0] });
49
+ break;
50
+ }
51
+ const keywords = ["import", "from", "const", "let", "var", "return", "print", "def", "class", "function", "if", "else", "for", "while", "async", "await"];
52
+ const keywordMatch = remaining.match(new RegExp(`^\\b(${keywords.join("|")})\\b`));
53
+ if (keywordMatch) {
54
+ tokens.push({ type: "keyword", value: keywordMatch[0] });
55
+ pos += keywordMatch[0].length;
56
+ remaining = line.slice(pos);
57
+ continue;
58
+ }
59
+ const constantMatch = remaining.match(/^\b(True|False|None|null|undefined|TRUE|FALSE)\b/);
60
+ if (constantMatch) {
61
+ tokens.push({ type: "constant", value: constantMatch[0] });
62
+ pos += constantMatch[0].length;
63
+ remaining = line.slice(pos);
64
+ continue;
65
+ }
66
+ const numberMatch = remaining.match(/^\b(\d+\.?\d*)\b/);
67
+ if (numberMatch) {
68
+ tokens.push({ type: "number", value: numberMatch[0] });
69
+ pos += numberMatch[0].length;
70
+ remaining = line.slice(pos);
71
+ continue;
72
+ }
73
+ const funcMatch = remaining.match(/^(\w+)(\s*\()/);
74
+ if (funcMatch) {
75
+ tokens.push({ type: "function", value: funcMatch[1] });
76
+ tokens.push({ type: "text", value: funcMatch[2] });
77
+ pos += funcMatch[0].length;
78
+ remaining = line.slice(pos);
79
+ continue;
80
+ }
81
+ const textMatch = remaining.match(/^[^\s"'`]/);
82
+ if (textMatch) {
83
+ const match = remaining.match(/^[^\s"'`\w]+|\w+/);
84
+ if (match) {
85
+ tokens.push({ type: "text", value: match[0] });
86
+ pos += match[0].length;
87
+ remaining = line.slice(pos);
88
+ continue;
89
+ }
90
+ }
91
+ pos++;
92
+ remaining = line.slice(pos);
93
+ }
94
+ return tokens;
95
+ }
96
+ function escapeHtml(text) {
97
+ const htmlEntities = {
98
+ "&": "&amp;",
99
+ "<": "&lt;",
100
+ ">": "&gt;",
101
+ '"': "&quot;",
102
+ "'": "&#39;",
103
+ "/": "&#x2F;",
104
+ "`": "&#x60;",
105
+ "=": "&#x3D;"
106
+ };
107
+ return text.replace(/[&<>"'`=/]/g, (char) => htmlEntities[char] || char);
108
+ }
109
+ function renderLine(line) {
110
+ const tokens = tokenizeLine(line);
111
+ return tokens.map((token) => {
112
+ const escaped = escapeHtml(token.value);
113
+ switch (token.type) {
114
+ case "keyword":
115
+ return `<span class="code-keyword">${escaped}</span>`;
116
+ case "string":
117
+ return `<span class="code-string">${escaped}</span>`;
118
+ case "comment":
119
+ return `<span class="code-comment">${escaped}</span>`;
120
+ case "number":
121
+ return `<span class="code-number">${escaped}</span>`;
122
+ case "function":
123
+ return `<span class="code-function">${escaped}</span>`;
124
+ case "constant":
125
+ return `<span class="code-constant">${escaped}</span>`;
126
+ default:
127
+ return escaped;
128
+ }
129
+ }).join("");
130
+ }
131
+ function highlightCode(code) {
132
+ const lines = code.split("\n");
133
+ return lines.map((line, i) => {
134
+ const rendered = renderLine(line) || "&nbsp;";
135
+ return `<div class="table-row group"><span class="table-cell select-none text-right pr-4 w-8 text-(--text-muted) text-xs opacity-0 group-hover:opacity-50 transition-opacity">${i + 1}</span><span class="table-cell">${rendered}</span></div>`;
136
+ }).join("");
137
+ }
138
+ function CodeBlock({
139
+ code,
140
+ language = "text",
141
+ filename,
142
+ showLineNumbers = true,
143
+ copyable = true,
144
+ className,
145
+ tabs
146
+ }) {
147
+ const t = useYunUI().useT("common");
148
+ const [copied, setCopied] = useState(false);
149
+ const [highlightedHtml, setHighlightedHtml] = useState("");
150
+ const [activeTab, setActiveTab] = useState(0);
151
+ const currentCode = tabs?.[activeTab]?.code || code;
152
+ const currentLanguage = tabs?.[activeTab]?.language || language;
153
+ useEffect(() => {
154
+ setHighlightedHtml(highlightCode(currentCode));
155
+ }, [currentCode]);
156
+ const handleCopy = async () => {
157
+ if (!await copyToClipboard(currentCode)) return;
158
+ setCopied(true);
159
+ setTimeout(() => setCopied(false), 2e3);
160
+ };
161
+ const handleTabChange = (index) => {
162
+ setActiveTab(index);
163
+ };
164
+ return /* @__PURE__ */ jsxs("div", { className: cn("card overflow-hidden", className), children: [
165
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2.5 border-b border-(--border-hairline) bg-(--bg-elevated)", children: [
166
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5", children: [
167
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
168
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-(--error) opacity-80" }),
169
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-(--warning) opacity-80" }),
170
+ /* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-(--success) opacity-80" })
171
+ ] }),
172
+ tabs && tabs.length > 0 ? /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: tabs.map((tab, index) => /* @__PURE__ */ jsx(
173
+ "button",
174
+ {
175
+ onClick: () => handleTabChange(index),
176
+ className: cn(
177
+ "px-3 py-1 rounded-md text-xs font-medium transition-all",
178
+ activeTab === index ? "bg-(--accent-subtle) text-(--text-primary)" : "text-(--text-tertiary) hover:text-(--text-secondary) hover:bg-(--accent-subtle)/50"
179
+ ),
180
+ children: tab.label
181
+ },
182
+ tab.id
183
+ )) }) : filename ? /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-(--text-secondary) font-mono", children: filename }) : /* @__PURE__ */ jsx("span", { className: "badge text-xs", children: currentLanguage })
184
+ ] }),
185
+ copyable && /* @__PURE__ */ jsx(
186
+ "button",
187
+ {
188
+ onClick: handleCopy,
189
+ className: "flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium transition-all hover:bg-(--accent-subtle)",
190
+ children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
191
+ /* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 text-(--success)" }),
192
+ /* @__PURE__ */ jsx("span", { className: "text-(--success)", children: t("copied") })
193
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
194
+ /* @__PURE__ */ jsx(Copy, { className: "w-3.5 h-3.5 text-(--text-tertiary)" }),
195
+ /* @__PURE__ */ jsx("span", { className: "text-(--text-tertiary)", children: t("copy") })
196
+ ] })
197
+ }
198
+ )
199
+ ] }),
200
+ /* @__PURE__ */ jsx("div", { className: "p-4 bg-(--bg-base)", children: /* @__PURE__ */ jsx("pre", { className: "text-sm overflow-x-auto", children: /* @__PURE__ */ jsx("code", { className: "font-mono", style: { color: "var(--text-primary)" }, children: showLineNumbers ? /* @__PURE__ */ jsx(
201
+ "div",
202
+ {
203
+ className: "table",
204
+ dangerouslySetInnerHTML: {
205
+ __html: highlightedHtml || code.split("\n").map(
206
+ (line, i) => `<div class="table-row group"><span class="table-cell select-none text-right pr-4 w-8 text-(--text-muted) text-xs opacity-0 group-hover:opacity-50 transition-opacity">${i + 1}</span><span class="table-cell">${escapeHtml(line) || "&nbsp;"}</span></div>`
207
+ ).join("")
208
+ }
209
+ }
210
+ ) : code }) }) })
211
+ ] });
212
+ }
213
+ var codeSnippets = {
214
+ python: `import openai
215
+
216
+ client = openai.OpenAI(
217
+ base_url="https://api.yunxin.ai/v1",
218
+ api_key="your_api_key"
219
+ )
220
+
221
+ response = client.chat.completions.create(
222
+ model="deepseek-r1",
223
+ messages=[{"role": "user", "content": "Hello!"}]
224
+ )
225
+
226
+ print(response.choices[0].message.content)`,
227
+ javascript: `import OpenAI from 'openai';
228
+
229
+ const client = new OpenAI({
230
+ baseURL: 'https://api.yunxin.ai/v1',
231
+ apiKey: 'your_api_key'
232
+ });
233
+
234
+ const response = await client.chat.completions.create({
235
+ model: 'deepseek-r1',
236
+ messages: [{ role: 'user', content: 'Hello!' }]
237
+ });
238
+
239
+ console.log(response.choices[0].message.content);`,
240
+ curl: `curl https://api.yunxin.ai/v1/chat/completions \\
241
+ -H "Authorization: Bearer your_api_key" \\
242
+ -H "Content-Type: application/json" \\
243
+ -d '{
244
+ "model": "deepseek-r1",
245
+ "messages": [{"role": "user", "content": "Hello!"}]
246
+ }'`
247
+ };
248
+ function CodeDemo() {
249
+ const tabs = [
250
+ { id: "python", label: "Python", code: codeSnippets.python, language: "python" },
251
+ { id: "javascript", label: "Node.js", code: codeSnippets.javascript, language: "javascript" },
252
+ { id: "curl", label: "cURL", code: codeSnippets.curl, language: "bash" }
253
+ ];
254
+ return /* @__PURE__ */ jsx("div", { className: "w-full max-w-2xl mx-auto", children: /* @__PURE__ */ jsx(
255
+ CodeBlock,
256
+ {
257
+ code: codeSnippets.python,
258
+ tabs
259
+ }
260
+ ) });
261
+ }
262
+ function FAQ({ items, defaultOpenIndex = 0 }) {
263
+ const [openIndex, setOpenIndex] = useState(defaultOpenIndex);
264
+ const faqs = items;
265
+ return /* @__PURE__ */ jsx("div", { className: "max-w-3xl mx-auto space-y-4", children: faqs.map((faq, i) => /* @__PURE__ */ jsxs(
266
+ "div",
267
+ {
268
+ className: cn(
269
+ "glass-card overflow-hidden transition-all duration-300",
270
+ openIndex === i ? "bg-card/60 ring-1 ring-accent-muted" : "hover:bg-card/50"
271
+ ),
272
+ children: [
273
+ /* @__PURE__ */ jsxs(
274
+ "button",
275
+ {
276
+ onClick: () => setOpenIndex(openIndex === i ? null : i),
277
+ className: "w-full flex items-center justify-between p-6 text-left gap-4",
278
+ children: [
279
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground flex-1 min-w-0", children: faq.question }),
280
+ /* @__PURE__ */ jsx("span", { className: cn("text-muted-foreground transition-transform duration-300 shrink-0", openIndex === i ? "rotate-45" : ""), children: /* @__PURE__ */ jsx(Plus, { className: "w-5 h-5" }) })
281
+ ]
282
+ }
283
+ ),
284
+ /* @__PURE__ */ jsx(
285
+ "div",
286
+ {
287
+ className: cn(
288
+ "px-6 text-muted-foreground text-sm leading-relaxed overflow-hidden transition-all duration-300",
289
+ openIndex === i ? "max-h-60 pb-6 opacity-100" : "max-h-0 opacity-0"
290
+ ),
291
+ children: faq.answer
292
+ }
293
+ )
294
+ ]
295
+ },
296
+ i
297
+ )) });
298
+ }
299
+ var actionClass = cn(
300
+ "inline-flex items-center gap-1.5 px-2 py-1 text-xs",
301
+ "text-fd-muted-foreground hover:text-fd-accent-foreground transition-colors rounded-md hover:bg-fd-accent"
302
+ );
303
+ function LLMCopyButton({ markdownUrl }) {
304
+ const [copied, setCopied] = useState(false);
305
+ const handleCopy = useCallback(async () => {
306
+ try {
307
+ const res = await fetch(markdownUrl);
308
+ const text = await res.text();
309
+ await navigator.clipboard.writeText(text);
310
+ setCopied(true);
311
+ setTimeout(() => setCopied(false), 2e3);
312
+ } catch {
313
+ await navigator.clipboard.writeText(window.location.origin + markdownUrl);
314
+ setCopied(true);
315
+ setTimeout(() => setCopied(false), 2e3);
316
+ }
317
+ }, [markdownUrl]);
318
+ return /* @__PURE__ */ jsxs("button", { type: "button", onClick: handleCopy, title: "Copy as Markdown for LLM", className: actionClass, children: [
319
+ copied ? /* @__PURE__ */ jsx(Check, { className: "size-3" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3" }),
320
+ copied ? "Copied" : "Copy"
321
+ ] });
322
+ }
323
+ function ViewOptions({
324
+ markdownUrl,
325
+ githubUrl
326
+ }) {
327
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
328
+ /* @__PURE__ */ jsxs(
329
+ "a",
330
+ {
331
+ href: markdownUrl,
332
+ target: "_blank",
333
+ rel: "noreferrer noopener",
334
+ className: cn(actionClass, "no-underline"),
335
+ title: "View as Markdown",
336
+ children: [
337
+ /* @__PURE__ */ jsx(FileText, { className: "size-3" }),
338
+ "Markdown"
339
+ ]
340
+ }
341
+ ),
342
+ githubUrl && /* @__PURE__ */ jsxs(
343
+ "a",
344
+ {
345
+ href: githubUrl,
346
+ target: "_blank",
347
+ rel: "noreferrer noopener",
348
+ className: cn(actionClass, "no-underline"),
349
+ title: "Edit on GitHub",
350
+ children: [
351
+ /* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
352
+ "GitHub"
353
+ ]
354
+ }
355
+ )
356
+ ] });
357
+ }
358
+
359
+ // src/lib/format-date.ts
360
+ var DEFAULT_LOCALE = "en-US";
361
+ function toDate(input) {
362
+ return input instanceof Date ? input : new Date(input);
363
+ }
364
+ function formatDate(input, locale = DEFAULT_LOCALE) {
365
+ return toDate(input).toLocaleDateString(locale, {
366
+ year: "numeric",
367
+ month: "short",
368
+ day: "numeric"
369
+ });
370
+ }
371
+ function formatLongDate(input, locale = DEFAULT_LOCALE) {
372
+ return toDate(input).toLocaleDateString(locale, {
373
+ year: "numeric",
374
+ month: "long",
375
+ day: "numeric"
376
+ });
377
+ }
378
+ function BlogCard({
379
+ title,
380
+ description,
381
+ date,
382
+ author,
383
+ category,
384
+ tags,
385
+ readingTime,
386
+ coverImage,
387
+ url,
388
+ variant = "default",
389
+ locale
390
+ }) {
391
+ const { Link } = useYunUI();
392
+ const formattedDate = date ? formatDate(date, locale) : null;
393
+ const isFeatured = variant === "featured";
394
+ return /* @__PURE__ */ jsx(Link, { href: url, className: "block h-full", children: /* @__PURE__ */ jsxs(Card, { hover: true, className: `overflow-hidden h-full flex flex-col ${isFeatured ? "md:col-span-2" : ""}`, children: [
395
+ /* @__PURE__ */ jsx("div", { className: "aspect-video w-full overflow-hidden bg-muted flex-shrink-0", children: coverImage ? /* @__PURE__ */ jsx(
396
+ "img",
397
+ {
398
+ src: coverImage,
399
+ alt: title,
400
+ className: "w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"
401
+ }
402
+ ) : /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-muted-foreground/30", children: /* @__PURE__ */ jsx("svg", { className: "w-12 h-12", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z" }) }) }) }),
403
+ /* @__PURE__ */ jsxs("div", { className: "p-5 flex flex-col flex-grow", children: [
404
+ category && /* @__PURE__ */ jsx(Badge, { variant: "info", className: "mb-3 self-start", children: category }),
405
+ /* @__PURE__ */ jsx("h2", { className: "font-semibold text-lg mb-2 line-clamp-2", children: title }),
406
+ description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4 line-clamp-2 flex-grow", children: description }),
407
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-4 text-xs text-muted-foreground mt-auto", children: [
408
+ formattedDate && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
409
+ /* @__PURE__ */ jsx(Calendar, { size: 12 }),
410
+ formattedDate
411
+ ] }),
412
+ readingTime && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
413
+ /* @__PURE__ */ jsx(Clock, { size: 12 }),
414
+ readingTime,
415
+ " min read"
416
+ ] }),
417
+ author?.name && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
418
+ /* @__PURE__ */ jsx(User, { size: 12 }),
419
+ author.name
420
+ ] })
421
+ ] }),
422
+ tags && tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1 mt-3", children: tags.slice(0, 3).map((tag) => /* @__PURE__ */ jsxs(
423
+ "button",
424
+ {
425
+ type: "button",
426
+ onClick: (e) => {
427
+ e.preventDefault();
428
+ e.stopPropagation();
429
+ window.location.href = `/blog?tag=${tag}`;
430
+ },
431
+ className: "text-xs bg-muted px-2 py-0.5 rounded hover:bg-muted/80 transition-colors cursor-pointer",
432
+ children: [
433
+ "#",
434
+ tag
435
+ ]
436
+ },
437
+ tag
438
+ )) })
439
+ ] })
440
+ ] }) });
441
+ }
442
+ function BlogPostHeader({
443
+ title,
444
+ description,
445
+ date,
446
+ author,
447
+ category,
448
+ tags,
449
+ readingTime,
450
+ coverImage
451
+ }) {
452
+ const formattedDate = date ? formatLongDate(date) : null;
453
+ return /* @__PURE__ */ jsxs("header", { className: "mb-12", children: [
454
+ category && /* @__PURE__ */ jsx(Badge, { variant: "info", className: "mb-4", children: category }),
455
+ /* @__PURE__ */ jsx("h1", { className: "heading-xl mb-4", children: title }),
456
+ description && /* @__PURE__ */ jsx("p", { className: "text-xl text-muted-foreground mb-6", children: description }),
457
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-6 text-sm text-muted-foreground mb-6", children: [
458
+ author?.name && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
459
+ /* @__PURE__ */ jsxs(Avatar, { className: "h-8 w-8", children: [
460
+ author.avatar && /* @__PURE__ */ jsx(AvatarImage, { src: author.avatar, alt: author.name }),
461
+ /* @__PURE__ */ jsx(AvatarFallback, { children: author.name[0] })
462
+ ] }),
463
+ /* @__PURE__ */ jsx("div", { children: author.url ? /* @__PURE__ */ jsx("a", { href: author.url, className: "hover:text-foreground font-medium", children: author.name }) : /* @__PURE__ */ jsx("span", { className: "font-medium", children: author.name }) })
464
+ ] }),
465
+ formattedDate && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
466
+ /* @__PURE__ */ jsx(Calendar, { size: 14 }),
467
+ formattedDate
468
+ ] }),
469
+ readingTime && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
470
+ /* @__PURE__ */ jsx(Clock, { size: 14 }),
471
+ readingTime,
472
+ " min read"
473
+ ] })
474
+ ] }),
475
+ coverImage && /* @__PURE__ */ jsx("div", { className: "aspect-video w-full overflow-hidden rounded-xl mb-8 bg-muted", children: /* @__PURE__ */ jsx("img", { src: coverImage, alt: title, className: "w-full h-full object-cover" }) }),
476
+ tags && tags.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: tags.map((tag) => /* @__PURE__ */ jsxs(
477
+ "a",
478
+ {
479
+ href: `/blog?tag=${tag}`,
480
+ className: "text-xs bg-muted px-2 py-1 rounded hover:bg-muted/80 transition-colors",
481
+ children: [
482
+ "#",
483
+ tag
484
+ ]
485
+ },
486
+ tag
487
+ )) })
488
+ ] });
489
+ }
490
+ function BlogPagination({
491
+ currentPage,
492
+ totalPages,
493
+ onPageChange,
494
+ labels
495
+ }) {
496
+ const handlePageChange = onPageChange;
497
+ const previousLabel = labels?.previous ?? "Previous";
498
+ const nextLabel = labels?.next ?? "Next";
499
+ if (totalPages <= 1) return null;
500
+ const maxVisible = 5;
501
+ let start = Math.max(1, currentPage - Math.floor(maxVisible / 2));
502
+ const end = Math.min(totalPages, start + maxVisible - 1);
503
+ start = Math.max(1, end - maxVisible + 1);
504
+ const pages = Array.from({ length: end - start + 1 }, (_, i) => start + i);
505
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-2", children: [
506
+ /* @__PURE__ */ jsxs(
507
+ Button,
508
+ {
509
+ variant: "ghost",
510
+ size: "sm",
511
+ onClick: () => handlePageChange(currentPage - 1),
512
+ disabled: currentPage === 1,
513
+ children: [
514
+ /* @__PURE__ */ jsx(ChevronLeft, { size: 16 }),
515
+ /* @__PURE__ */ jsx("span", { className: "ml-1", children: previousLabel })
516
+ ]
517
+ }
518
+ ),
519
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
520
+ start > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
521
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onClick: () => handlePageChange(1), className: "min-w-[36px]", children: "1" }),
522
+ start > 2 && /* @__PURE__ */ jsx("span", { className: "px-2 text-muted-foreground", children: "..." })
523
+ ] }),
524
+ pages.map((page) => /* @__PURE__ */ jsx(
525
+ Button,
526
+ {
527
+ variant: page === currentPage ? "primary" : "ghost",
528
+ size: "sm",
529
+ onClick: () => handlePageChange(page),
530
+ className: "min-w-[36px]",
531
+ children: page
532
+ },
533
+ page
534
+ )),
535
+ end < totalPages && /* @__PURE__ */ jsxs(Fragment, { children: [
536
+ end < totalPages - 1 && /* @__PURE__ */ jsx("span", { className: "px-2 text-muted-foreground", children: "..." }),
537
+ /* @__PURE__ */ jsx(
538
+ Button,
539
+ {
540
+ variant: "ghost",
541
+ size: "sm",
542
+ onClick: () => handlePageChange(totalPages),
543
+ className: "min-w-[36px]",
544
+ children: totalPages
545
+ }
546
+ )
547
+ ] })
548
+ ] }),
549
+ /* @__PURE__ */ jsxs(
550
+ Button,
551
+ {
552
+ variant: "ghost",
553
+ size: "sm",
554
+ onClick: () => handlePageChange(currentPage + 1),
555
+ disabled: currentPage === totalPages,
556
+ children: [
557
+ /* @__PURE__ */ jsx("span", { className: "mr-1", children: nextLabel }),
558
+ /* @__PURE__ */ jsx(ChevronRight, { size: 16 })
559
+ ]
560
+ }
561
+ )
562
+ ] });
563
+ }
564
+ function CategoryFilter({
565
+ categories,
566
+ selectedCategory,
567
+ onSelect,
568
+ allLabel = "All Posts"
569
+ }) {
570
+ const handleCategoryClick = onSelect;
571
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 mb-8", children: [
572
+ /* @__PURE__ */ jsx(
573
+ Button,
574
+ {
575
+ variant: selectedCategory ? "ghost" : "primary",
576
+ size: "sm",
577
+ onClick: () => handleCategoryClick(null),
578
+ children: allLabel
579
+ }
580
+ ),
581
+ categories.map((category) => /* @__PURE__ */ jsx(
582
+ Button,
583
+ {
584
+ variant: selectedCategory === category ? "primary" : "ghost",
585
+ size: "sm",
586
+ onClick: () => handleCategoryClick(category),
587
+ children: category
588
+ },
589
+ category
590
+ ))
591
+ ] });
592
+ }
593
+ function isItemActive(item, currentPath, homeHref) {
594
+ if (currentPath === item.href) return true;
595
+ if (item.href !== homeHref && currentPath.startsWith(item.href)) return true;
596
+ return item.match?.some((m) => currentPath.startsWith(m)) ?? false;
597
+ }
598
+ function Sidebar({
599
+ appName,
600
+ logoSrc = "/favicon.ico",
601
+ homeHref = "/",
602
+ sections,
603
+ currentPath = "",
604
+ isOpen = false,
605
+ onClose,
606
+ collapsed = false,
607
+ onToggleCollapse,
608
+ onNavigate,
609
+ footer,
610
+ closeLabel = "Close",
611
+ loading = false,
612
+ scrollStorageKey = "yunui-sidebar-scroll"
613
+ }) {
614
+ const { Link, Image } = useYunUI();
615
+ const navRef = useRef(null);
616
+ useEffect(() => {
617
+ const nav = navRef.current;
618
+ if (!nav) return;
619
+ const saved = sessionStorage.getItem(scrollStorageKey);
620
+ if (saved) nav.scrollTop = parseInt(saved, 10);
621
+ const onScroll = () => sessionStorage.setItem(scrollStorageKey, String(nav.scrollTop));
622
+ nav.addEventListener("scroll", onScroll);
623
+ return () => nav.removeEventListener("scroll", onScroll);
624
+ }, [scrollStorageKey]);
625
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
626
+ isOpen && /* @__PURE__ */ jsx(
627
+ "div",
628
+ {
629
+ className: "fixed inset-0 bg-black/20 backdrop-blur-sm z-40 lg:hidden",
630
+ onClick: onClose,
631
+ "aria-hidden": "true"
632
+ }
633
+ ),
634
+ /* @__PURE__ */ jsxs(
635
+ "aside",
636
+ {
637
+ role: "navigation",
638
+ "aria-label": "Main navigation",
639
+ className: `
640
+ fixed inset-y-0 left-0 z-50
641
+ min-w-64 w-64 bg-(--bg-base) border-r border-(--border-hairline)
642
+ flex flex-col h-dvh
643
+ transition-transform duration-200 ease-in-out
644
+ ${isOpen ? "translate-x-0" : collapsed ? "-translate-x-full" : "-translate-x-full lg:translate-x-0"}
645
+ `,
646
+ children: [
647
+ /* @__PURE__ */ jsx("div", { className: "py-3 px-3 shrink-0", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center py-2 pl-0 pr-1 gap-2", children: [
648
+ /* @__PURE__ */ jsxs(Link, { href: homeHref, className: "flex-1 min-w-0 flex items-center gap-2.5 rounded-lg pl-3 pr-3 py-1.5 hover:bg-foreground/5 transition-colors duration-200", children: [
649
+ /* @__PURE__ */ jsx(Image, { src: logoSrc, alt: appName, width: 36, height: 36, className: "shrink-0" }),
650
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-[18px] truncate", children: appName })
651
+ ] }),
652
+ onToggleCollapse && /* @__PURE__ */ jsxs(Fragment, { children: [
653
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-px bg-(--border-hairline) shrink-0" }),
654
+ /* @__PURE__ */ jsx(
655
+ "button",
656
+ {
657
+ onClick: onToggleCollapse,
658
+ className: "hidden lg:flex shrink-0 p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
659
+ "aria-label": closeLabel,
660
+ children: /* @__PURE__ */ jsx(PanelLeftClose, { size: 18 })
661
+ }
662
+ )
663
+ ] }),
664
+ onClose && /* @__PURE__ */ jsx(IconButton, { icon: /* @__PURE__ */ jsx(X, { size: 20 }), label: closeLabel, onClick: onClose, className: "lg:hidden" })
665
+ ] }) }),
666
+ /* @__PURE__ */ jsx("nav", { ref: navRef, className: "flex-1 overflow-y-auto py-3 px-3", children: loading ? /* @__PURE__ */ jsx("div", { className: "space-y-2 animate-pulse", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx("div", { className: "h-9 rounded-lg bg-foreground/5" }, i)) }) : sections.map((section, i) => /* @__PURE__ */ jsxs("div", { className: i > 0 ? "mt-4" : "", children: [
667
+ section.title && /* @__PURE__ */ jsx("div", { className: "nav-section", children: section.title }),
668
+ section.items.map((item) => {
669
+ const active = isItemActive(item, currentPath, homeHref);
670
+ const Icon = item.icon;
671
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
672
+ Icon && /* @__PURE__ */ jsx(Icon, { size: 18, strokeWidth: 1.75, className: "shrink-0" }),
673
+ /* @__PURE__ */ jsx("span", { className: "flex-1 min-w-0 truncate", children: item.label })
674
+ ] });
675
+ const className = `nav-item ${active ? "active" : ""}`;
676
+ return onNavigate ? /* @__PURE__ */ jsx(
677
+ "a",
678
+ {
679
+ href: item.href,
680
+ onClick: (e) => {
681
+ e.preventDefault();
682
+ onNavigate(item.href);
683
+ onClose?.();
684
+ },
685
+ className,
686
+ children: content
687
+ },
688
+ item.href
689
+ ) : /* @__PURE__ */ jsx(Link, { href: item.href, onClick: () => onClose?.(), className, children: content }, item.href);
690
+ })
691
+ ] }, i)) }),
692
+ footer && /* @__PURE__ */ jsx("div", { className: "p-3 shrink-0", children: footer })
693
+ ]
694
+ }
695
+ )
696
+ ] });
697
+ }
698
+ function PageHeader({ title, description, actions, className }) {
699
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center justify-between gap-4", className), children: [
700
+ /* @__PURE__ */ jsxs("div", { children: [
701
+ /* @__PURE__ */ jsx("h1", { className: "heading-xl", children: title }),
702
+ description && /* @__PURE__ */ jsx("p", { className: "text-body mt-1", children: description })
703
+ ] }),
704
+ actions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 shrink-0", children: actions })
705
+ ] });
706
+ }
707
+ function PageLoadingState({ message }) {
708
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-16", children: [
709
+ /* @__PURE__ */ jsx(Spinner, { size: "lg" }),
710
+ message && /* @__PURE__ */ jsx("span", { className: "ml-3 text-muted-foreground", children: message })
711
+ ] });
712
+ }
713
+ function PageErrorState({ message, onRetry, retryLabel = "Retry" }) {
714
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-16 text-center", children: [
715
+ /* @__PURE__ */ jsx("div", { className: "text-red-600 dark:text-red-400 font-medium mb-2", children: message }),
716
+ onRetry && /* @__PURE__ */ jsx(
717
+ "button",
718
+ {
719
+ onClick: onRetry,
720
+ className: "text-sm text-muted-foreground hover:text-foreground transition-colors underline",
721
+ children: retryLabel
722
+ }
723
+ )
724
+ ] });
725
+ }
726
+ function PageEmptyState({ icon: Icon, title, description, action }) {
727
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-16 text-center", children: [
728
+ Icon && /* @__PURE__ */ jsx(Icon, { size: 40, className: "text-muted-foreground/40 mb-3" }),
729
+ /* @__PURE__ */ jsx("div", { className: "font-medium mb-1", children: title }),
730
+ description && /* @__PURE__ */ jsx("div", { className: "text-caption", children: description }),
731
+ action && /* @__PURE__ */ jsx("div", { className: "mt-4", children: action })
732
+ ] });
733
+ }
734
+ var TONES = {
735
+ amber: { card: "border-amber-500/20 bg-amber-500/5", value: "text-amber-600 dark:text-amber-400" },
736
+ emerald: { card: "border-emerald-500/20 bg-emerald-500/5", value: "text-emerald-600 dark:text-emerald-400" },
737
+ blue: { card: "border-blue-500/20 bg-blue-500/5", value: "text-blue-600 dark:text-blue-400" },
738
+ red: { card: "border-red-500/20 bg-red-500/5", value: "text-red-600 dark:text-red-400" },
739
+ purple: { card: "border-purple-500/20 bg-purple-500/5", value: "text-purple-600 dark:text-purple-400" }
740
+ };
741
+ function StatCard({ icon: Icon, label, value, subtext, trend, tone, delay = 0, inline = false, valueFirst = false, className }) {
742
+ const toneCfg = tone ? TONES[tone] : void 0;
743
+ const showTopRow = Boolean(Icon || trend);
744
+ const topRow = showTopRow ? /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between mb-4", children: [
745
+ Icon ? /* @__PURE__ */ jsx("div", { className: "w-10 h-10 rounded-xl bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsx(Icon, { size: 20, strokeWidth: 1.5, className: "text-muted-foreground" }) }) : /* @__PURE__ */ jsx("span", {}),
746
+ trend && /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-1 text-xs font-medium", trend.positive ? "text-success" : "text-error"), children: [
747
+ trend.positive ? /* @__PURE__ */ jsx(ArrowUpRight, { size: 14 }) : /* @__PURE__ */ jsx(ArrowDownRight, { size: 14 }),
748
+ Math.abs(trend.value).toFixed(1),
749
+ "%"
750
+ ] })
751
+ ] }) : null;
752
+ if (inline) {
753
+ return /* @__PURE__ */ jsxs("div", { className: cn("card p-4", toneCfg?.card, className), children: [
754
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
755
+ Icon && /* @__PURE__ */ jsx(Icon, { size: 18 }),
756
+ /* @__PURE__ */ jsx("span", { children: label })
757
+ ] }),
758
+ /* @__PURE__ */ jsx("div", { className: cn("text-2xl font-semibold mt-2", toneCfg?.value ?? "text-foreground"), children: value })
759
+ ] });
760
+ }
761
+ if (valueFirst) {
762
+ return /* @__PURE__ */ jsxs(
763
+ "div",
764
+ {
765
+ className: cn("stat-card p-5 animate-enter", toneCfg?.card, className),
766
+ style: delay ? { animationDelay: `${delay}ms` } : void 0,
767
+ children: [
768
+ topRow,
769
+ /* @__PURE__ */ jsx("div", { className: cn("text-2xl font-semibold mb-1", toneCfg?.value), children: value }),
770
+ /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: label }),
771
+ subtext && /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground/60 mt-1", children: subtext })
772
+ ]
773
+ }
774
+ );
775
+ }
776
+ return /* @__PURE__ */ jsxs(
777
+ "div",
778
+ {
779
+ className: cn("stat-card p-5 animate-enter", toneCfg?.card, className),
780
+ style: delay ? { animationDelay: `${delay}ms` } : void 0,
781
+ children: [
782
+ topRow,
783
+ /* @__PURE__ */ jsx("div", { className: "text-label mb-1", children: label }),
784
+ /* @__PURE__ */ jsx("div", { className: cn("text-2xl font-semibold tracking-tight", toneCfg?.value), children: value }),
785
+ subtext && /* @__PURE__ */ jsx("div", { className: "text-caption mt-1", children: subtext })
786
+ ]
787
+ }
788
+ );
789
+ }
790
+ function FellowsBanner({
791
+ title,
792
+ description,
793
+ ctaText,
794
+ features = [],
795
+ href = "/fellows",
796
+ className = ""
797
+ }) {
798
+ const { Link } = useYunUI();
799
+ return /* @__PURE__ */ jsxs(
800
+ Link,
801
+ {
802
+ href,
803
+ className: `card p-5 flex items-center gap-4 border-2 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent hover:border-primary/40 transition-all group ${className}`,
804
+ children: [
805
+ /* @__PURE__ */ jsx("div", { className: "p-3 bg-primary/10 rounded-xl", children: /* @__PURE__ */ jsx(GraduationCap, { className: "w-6 h-6 text-primary" }) }),
806
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
807
+ /* @__PURE__ */ jsx("h3", { className: "font-semibold text-sm", children: title }),
808
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: description }),
809
+ features.length > 0 && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground/70 mt-1", children: features.join(" \xB7 ") })
810
+ ] }),
811
+ /* @__PURE__ */ jsxs("span", { className: "text-sm font-medium text-primary group-hover:underline whitespace-nowrap", children: [
812
+ ctaText,
813
+ " \u2192"
814
+ ] })
815
+ ]
816
+ }
817
+ );
818
+ }
819
+ function ErrorFallback({
820
+ error,
821
+ onRetry,
822
+ labels
823
+ }) {
824
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center min-h-100 p-8", children: [
825
+ /* @__PURE__ */ jsx("div", { className: "w-16 h-16 rounded-full bg-red-100 dark:bg-red-900/20 flex items-center justify-center mb-4", children: /* @__PURE__ */ jsx(AlertCircle, { size: 32, className: "text-red-500" }) }),
826
+ /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold mb-2", children: labels?.title ?? "Something went wrong" }),
827
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-center mb-4 max-w-md", children: error?.message || labels?.message || "An unexpected error occurred." }),
828
+ /* @__PURE__ */ jsxs(Button, { variant: "secondary", onClick: onRetry, className: "whitespace-nowrap", children: [
829
+ /* @__PURE__ */ jsx(RefreshCw, { size: 16 }),
830
+ labels?.retry ?? "Try again"
831
+ ] })
832
+ ] });
833
+ }
834
+ var ErrorBoundary = class extends React.Component {
835
+ constructor(props) {
836
+ super(props);
837
+ this.state = { hasError: false, error: null };
838
+ }
839
+ static getDerivedStateFromError(error) {
840
+ return { hasError: true, error };
841
+ }
842
+ componentDidCatch(error, errorInfo) {
843
+ console.error("ErrorBoundary caught an error:", error, errorInfo);
844
+ this.props.onError?.(error, errorInfo);
845
+ }
846
+ handleRetry = () => {
847
+ this.setState({ hasError: false, error: null });
848
+ };
849
+ render() {
850
+ if (this.state.hasError) {
851
+ if (this.props.fallback) return this.props.fallback;
852
+ return /* @__PURE__ */ jsx(ErrorFallback, { error: this.state.error, onRetry: this.handleRetry, labels: this.props.labels });
853
+ }
854
+ return this.props.children;
855
+ }
856
+ };
857
+ function AccountLockedCard({
858
+ appName,
859
+ logoSrc = "/favicon.ico",
860
+ icon,
861
+ title,
862
+ subtitle,
863
+ appeal,
864
+ backLabel,
865
+ onBack,
866
+ onMount,
867
+ loading = false,
868
+ children
869
+ }) {
870
+ const { Image } = useYunUI();
871
+ useEffect(() => {
872
+ onMount?.();
873
+ }, []);
874
+ return /* @__PURE__ */ jsx("div", { className: "min-h-dvh bg-background flex items-center justify-center px-6", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-sm", children: [
875
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-2.5 mb-8", children: [
876
+ /* @__PURE__ */ jsx(Image, { src: logoSrc, alt: appName, width: 32, height: 32 }),
877
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-[15px]", children: appName })
878
+ ] }),
879
+ /* @__PURE__ */ jsxs("div", { className: "p-6 bg-card border border-border rounded-xl", children: [
880
+ /* @__PURE__ */ jsx("div", { className: "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-error/10", children: icon }),
881
+ /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold mb-2 text-center", children: title }),
882
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-5 text-center", children: subtitle }),
883
+ children,
884
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-6 text-center", children: appeal }),
885
+ /* @__PURE__ */ jsx(
886
+ "button",
887
+ {
888
+ type: "button",
889
+ onClick: onBack,
890
+ disabled: loading,
891
+ className: "w-full h-10 rounded-lg bg-primary text-primary-foreground text-sm font-medium hover:opacity-90 transition-opacity disabled:opacity-60",
892
+ children: backLabel
893
+ }
894
+ )
895
+ ] })
896
+ ] }) });
897
+ }
898
+ function MediaPageHeader({ title, description, isSyncing, syncError, onSync, stats }) {
899
+ const t = useYunUI().useT("components.mediaPageHeader");
900
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
901
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
902
+ /* @__PURE__ */ jsxs("div", { children: [
903
+ /* @__PURE__ */ jsx("h1", { className: "heading-xl", children: title }),
904
+ /* @__PURE__ */ jsx("p", { className: "text-body mt-1", children: description })
905
+ ] }),
906
+ /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: onSync, disabled: isSyncing, className: "text-muted-foreground", children: [
907
+ /* @__PURE__ */ jsx(RefreshCw, { size: 16, className: isSyncing ? "animate-spin" : "" }),
908
+ /* @__PURE__ */ jsx("span", { className: "ml-2", children: isSyncing ? t("syncing") : t("sync") })
909
+ ] })
910
+ ] }),
911
+ syncError && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 text-red-700 dark:text-red-300 text-sm", children: [
912
+ /* @__PURE__ */ jsx(AlertCircle, { size: 16 }),
913
+ /* @__PURE__ */ jsx("span", { children: syncError })
914
+ ] }),
915
+ stats && stats.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex gap-4 text-sm text-muted-foreground", children: stats.map((stat, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
916
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: stat.value }),
917
+ /* @__PURE__ */ jsx("span", { children: stat.label })
918
+ ] }, index)) })
919
+ ] });
920
+ }
921
+ function MediaEmptyState({ icon: Icon, title, description, action }) {
922
+ return /* @__PURE__ */ jsxs("div", { className: "empty-state py-16", children: [
923
+ /* @__PURE__ */ jsx(Icon, { size: 40, className: "text-muted-foreground/40 mb-3" }),
924
+ /* @__PURE__ */ jsx("div", { className: "font-medium mb-1", children: title }),
925
+ /* @__PURE__ */ jsx("div", { className: "text-caption", children: description }),
926
+ action && /* @__PURE__ */ jsx("div", { className: "mt-4", children: action })
927
+ ] });
928
+ }
929
+ function MediaLoadingState({ message }) {
930
+ const t = useYunUI().useT("components.mediaPageHeader");
931
+ const displayMessage = message ?? t("loading");
932
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-16", children: [
933
+ /* @__PURE__ */ jsx(RefreshCw, { size: 24, className: "animate-spin text-muted-foreground" }),
934
+ /* @__PURE__ */ jsx("span", { className: "ml-3 text-muted-foreground", children: displayMessage })
935
+ ] });
936
+ }
937
+ function MediaErrorState({ message, onRetry }) {
938
+ const t = useYunUI().useT("components.mediaPageHeader");
939
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-16 text-center", children: [
940
+ /* @__PURE__ */ jsx(AlertCircle, { size: 40, className: "text-red-500/50 mb-3" }),
941
+ /* @__PURE__ */ jsx("div", { className: "font-medium text-red-600 dark:text-red-400 mb-1", children: t("error") }),
942
+ /* @__PURE__ */ jsx("div", { className: "text-caption mb-4", children: message }),
943
+ onRetry && /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: onRetry, children: [
944
+ /* @__PURE__ */ jsx(RefreshCw, { size: 14, className: "mr-2" }),
945
+ t("retry")
946
+ ] })
947
+ ] });
948
+ }
949
+ function FellowBadge({ variant = "inline", className = "" }) {
950
+ const t = useYunUI().useT("components.badges");
951
+ if (variant === "pill") {
952
+ return /* @__PURE__ */ jsxs("span", { className: `badge inline-flex items-center gap-1 text-xs bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20 ${className}`, children: [
953
+ /* @__PURE__ */ jsx(Award, { size: 11, className: "text-amber-500" }),
954
+ t("fellow")
955
+ ] });
956
+ }
957
+ return /* @__PURE__ */ jsxs("span", { className: `inline-flex items-center gap-1 text-xs font-medium text-amber-600 dark:text-amber-400 ${className}`, children: [
958
+ /* @__PURE__ */ jsx(Award, { size: 10, className: "text-amber-500" }),
959
+ t("fellow")
960
+ ] });
961
+ }
962
+ function CapabilityBadge({ capability, short = false }) {
963
+ const t = useYunUI().useT("components.badges");
964
+ const configs = {
965
+ chat: { icon: MessageSquare, iconColor: "text-blue-500", color: "bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20", labelKey: "chat" },
966
+ streaming: { icon: Waves, iconColor: "text-cyan-500", color: "bg-cyan-500/10 text-cyan-600 dark:text-cyan-400 border-cyan-500/20", labelKey: "streaming" },
967
+ function_calling: { icon: Code, iconColor: "text-purple-500", color: "bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20", labelKey: "functionCalling" },
968
+ vision: { icon: Eye, iconColor: "text-amber-500", color: "bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20", labelKey: "vision" },
969
+ thinking: { icon: Brain, iconColor: "text-pink-500", color: "bg-pink-500/10 text-pink-600 dark:text-pink-400 border-pink-500/20", labelKey: "thinking" },
970
+ image_edit: { icon: Image, iconColor: "text-orange-500", color: "bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20", labelKey: "imageEdit" },
971
+ negative_prompt: { icon: Ban, iconColor: "text-red-500", color: "bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20", labelKey: "negativePrompt" },
972
+ seed_control: { icon: Fingerprint, iconColor: "text-indigo-500", color: "bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20", labelKey: "seedControl" },
973
+ lora: { icon: Layers, iconColor: "text-teal-500", color: "bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/20", labelKey: "loraSupport" },
974
+ guidance_scale: { icon: SlidersHorizontal, iconColor: "text-yellow-500", color: "bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20", labelKey: "guidanceScale" },
975
+ strength: { icon: SlidersHorizontal, iconColor: "text-orange-500", color: "bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20", labelKey: "strength" },
976
+ batch: { icon: Waves, iconColor: "text-cyan-500", color: "bg-cyan-500/10 text-cyan-600 dark:text-cyan-400 border-cyan-500/20", labelKey: "batchGeneration" }
977
+ };
978
+ const config = configs[capability];
979
+ if (!config) return null;
980
+ const Icon = config.icon;
981
+ return /* @__PURE__ */ jsxs("span", { className: `badge inline-flex items-center gap-1 text-xs ${config.color}`, children: [
982
+ /* @__PURE__ */ jsx(Icon, { size: 10, className: config.iconColor }),
983
+ t(config.labelKey)
984
+ ] });
985
+ }
986
+ function StatusBadge({ status, size = "sm" }) {
987
+ const t = useYunUI().useT("components.badges");
988
+ const configs = {
989
+ pending: { icon: Clock, color: "badge-warning", labelKey: "pending" },
990
+ approved: { icon: CheckCircle, color: "badge-success", labelKey: "approved" },
991
+ auto_approved: { icon: Zap, color: "badge-info", labelKey: "autoApproved" },
992
+ rejected: { icon: XCircle, color: "badge-error", labelKey: "rejected" }
993
+ };
994
+ const config = configs[status];
995
+ if (!config) return null;
996
+ const Icon = config.icon;
997
+ return /* @__PURE__ */ jsxs("span", { className: `inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium ${config.color}`, children: [
998
+ /* @__PURE__ */ jsx(Icon, { size: size === "sm" ? 12 : 14 }),
999
+ t(config.labelKey)
1000
+ ] });
1001
+ }
1002
+ function SourceBadge({ source, showIcon = true }) {
1003
+ const t = useYunUI().useT("common.badge");
1004
+ const configs = {
1005
+ yaml: { icon: FileCode, color: "bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20", label: t("yaml") },
1006
+ api: { icon: FileText, color: "bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20", label: t("api") }
1007
+ };
1008
+ const config = configs[source.toLowerCase()];
1009
+ if (!config) return null;
1010
+ const Icon = config.icon;
1011
+ return /* @__PURE__ */ jsxs("span", { className: `badge flex items-center gap-1 ${config.color}`, children: [
1012
+ showIcon && /* @__PURE__ */ jsx(Icon, { size: 10 }),
1013
+ config.label
1014
+ ] });
1015
+ }
1016
+ function ActiveBadge({ isActive }) {
1017
+ const t = useYunUI().useT("components.badges");
1018
+ return /* @__PURE__ */ jsxs("span", { className: `badge flex items-center gap-1 ${isActive ? "badge-success" : ""}`, children: [
1019
+ isActive ? /* @__PURE__ */ jsx(Eye, { size: 10 }) : /* @__PURE__ */ jsx(EyeOff, { size: 10 }),
1020
+ isActive ? t("active") : t("inactive")
1021
+ ] });
1022
+ }
1023
+ function DeprecatedBadge({ isDeprecated }) {
1024
+ const t = useYunUI().useT("components.badges");
1025
+ if (!isDeprecated) return null;
1026
+ return /* @__PURE__ */ jsx("span", { className: "badge", children: t("deprecated") });
1027
+ }
1028
+
1029
+ export { AccountLockedCard, ActiveBadge, BackgroundEffects, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, DeprecatedBadge, ErrorBoundary, FAQ, FellowBadge, FellowsBanner, LLMCopyButton, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, PageEmptyState, PageErrorState, PageHeader, PageLoadingState, Sidebar, SourceBadge, StatCard, StatusBadge, ViewOptions };
1030
+ //# sourceMappingURL=patterns.js.map
1031
+ //# sourceMappingURL=patterns.js.map