@yuhuanowo/yunui 0.2.13 → 0.2.15

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.
package/dist/ai.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { copyToClipboard } from './chunk-N53PNMPJ.js';
3
3
  export { DiscordIcon, Footer, GithubIcon, InstagramIcon } from './chunk-N53PNMPJ.js';
4
- import { cn, ThemeToggle } from './chunk-TFZKMJGF.js';
4
+ import { cn, useAnchoredPosition, ThemeToggle } from './chunk-LLNTUA5K.js';
5
5
  import { useYunUI } from './chunk-U2LNRVMI.js';
6
6
  import { memo, useState, useRef, useMemo, useEffect } from 'react';
7
7
  import { AnimatePresence, motion } from 'framer-motion';
@@ -17,7 +17,8 @@ function ThinkingBlock({ content, isStreaming, defaultOpen = false, renderConten
17
17
  "button",
18
18
  {
19
19
  onClick: () => setIsOpen(!isOpen),
20
- className: "w-full flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/50 transition-colors",
20
+ "aria-expanded": isOpen,
21
+ className: "w-full flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/50 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
21
22
  children: [
22
23
  /* @__PURE__ */ jsx("div", { className: cn(
23
24
  "flex items-center justify-center w-5 h-5 rounded-md bg-muted text-muted-foreground",
@@ -62,12 +63,13 @@ function IDBadge({ text, truncate = true }) {
62
63
  setTimeout(() => setCopied(false), 1500);
63
64
  };
64
65
  return /* @__PURE__ */ jsxs(
65
- "div",
66
+ "button",
66
67
  {
67
- onMouseDown: handleCopy,
68
+ type: "button",
68
69
  onClick: handleCopy,
69
- className: `group/badge relative inline-flex items-center rounded-md bg-muted border border-border hover:bg-muted/70 cursor-pointer transition-colors duration-200 overflow-hidden ${truncate ? "max-w-full min-w-0" : ""}`,
70
+ className: `group/badge relative inline-flex items-center rounded-md bg-muted border border-border hover:bg-muted/70 cursor-pointer transition-colors duration-200 overflow-hidden outline-none focus-visible:ring-2 focus-visible:ring-ring ${truncate ? "max-w-full min-w-0" : ""}`,
70
71
  title: t("clickToCopy", { text }),
72
+ "aria-label": t("clickToCopy", { text }),
71
73
  children: [
72
74
  /* @__PURE__ */ jsx("span", { className: `px-2 py-0.5 text-xs font-mono block ${truncate ? "truncate max-w-full min-w-0" : "whitespace-nowrap"}`, children: text }),
73
75
  /* @__PURE__ */ jsx("span", { className: "opacity-0 group-hover/badge:opacity-100 absolute right-0 inset-y-0 w-5 flex items-center justify-center rounded-r-md bg-muted/90 backdrop-blur-sm transition-opacity duration-200", children: copied ? /* @__PURE__ */ jsx(Check, { size: 10 }) : /* @__PURE__ */ jsx(Copy, { size: 10 }) })
@@ -118,7 +120,7 @@ function ModelCard({
118
120
  onClick();
119
121
  }
120
122
  },
121
- className: `card card-interactive p-4 text-left w-full group cursor-pointer flex flex-col ${className}`,
123
+ className: `card card-interactive p-4 text-left w-full group cursor-pointer flex flex-col outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background ${className}`,
122
124
  children: [
123
125
  /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between mb-3", children: [
124
126
  icon,
@@ -130,7 +132,7 @@ function ModelCard({
130
132
  /* @__PURE__ */ jsx("div", { className: "mb-2", children: /* @__PURE__ */ jsxs("div", { className: "font-medium text-sm group-hover:text-foreground flex items-center gap-1.5", children: [
131
133
  /* @__PURE__ */ jsx("span", { className: "truncate", children: name }),
132
134
  nonofficial && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[10px] px-1.5 py-0.5 rounded badge-warning font-medium whitespace-nowrap", children: labels?.nonofficial ?? "Unofficial" }),
133
- suspended && /* @__PURE__ */ jsxs("span", { className: "shrink-0 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded font-medium whitespace-nowrap bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20", children: [
135
+ suspended && /* @__PURE__ */ jsxs("span", { className: "shrink-0 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded badge-warning font-medium whitespace-nowrap", children: [
134
136
  /* @__PURE__ */ jsx(PauseCircle, { size: 10 }),
135
137
  labels?.suspended ?? "Suspended"
136
138
  ] })
@@ -139,8 +141,8 @@ function ModelCard({
139
141
  /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground line-clamp-2 mb-3 min-h-[2.5em]", children: description || /* @__PURE__ */ jsx("span", { className: "opacity-40", children: labels?.noDescription ?? "No description" }) }),
140
142
  /* @__PURE__ */ jsxs("div", { className: "mt-auto flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5 text-[11px] text-muted-foreground pt-3 border-t border-border", children: [
141
143
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 min-w-0", children: [
142
- developer?.iconUrl && /* @__PURE__ */ jsx("div", { className: "rounded-md overflow-hidden bg-linear-to-br from-black/2 to-black/5", style: { width: 12, height: 12 }, children: /* @__PURE__ */ jsx(Image, { src: developer.iconUrl, alt: developer.label, width: 12, height: 12, className: "object-cover" }) }),
143
- developer?.label && /* @__PURE__ */ jsx("span", { children: developer.label })
144
+ developer?.iconUrl && /* @__PURE__ */ jsx("div", { className: "rounded-md overflow-hidden bg-muted", style: { width: 12, height: 12 }, children: /* @__PURE__ */ jsx(Image, { src: developer.iconUrl, alt: developer.label, width: 12, height: 12, className: "object-cover" }) }),
145
+ developer?.label && /* @__PURE__ */ jsx("span", { className: "truncate min-w-0", children: developer.label })
144
146
  ] }),
145
147
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
146
148
  context && /* @__PURE__ */ jsx("span", { className: "bg-muted px-1.5 py-0.5 rounded-sm font-medium", children: context }),
@@ -180,6 +182,8 @@ function ModelSelect({
180
182
  const rootRef = useRef(null);
181
183
  const inputRef = useRef(null);
182
184
  const listRef = useRef(null);
185
+ const panelRef = useRef(null);
186
+ const { shift, maxHeight } = useAnchoredPosition(isOpen, panelRef);
183
187
  const pinnedSet = useMemo(() => new Set(pinned ?? []), [pinned]);
184
188
  useEffect(() => {
185
189
  const onDown = (e) => {
@@ -253,6 +257,39 @@ function ModelSelect({
253
257
  onChange(id);
254
258
  setIsOpen(false);
255
259
  };
260
+ const flatOptions = useMemo(() => {
261
+ const out = [...pinnedList];
262
+ for (const opts of Object.values(grouped)) out.push(...opts);
263
+ return out;
264
+ }, [pinnedList, grouped]);
265
+ const [activeIndex, setActiveIndex] = useState(-1);
266
+ useEffect(() => {
267
+ setActiveIndex(-1);
268
+ }, [isOpen, search, activeGroup, activeFilters]);
269
+ const clearActiveOnPointer = () => setActiveIndex((i) => i === -1 ? i : -1);
270
+ useEffect(() => {
271
+ const id = flatOptions[activeIndex]?.id;
272
+ if (!isOpen || !id || !listRef.current) return;
273
+ listRef.current.querySelector(`[data-model-id="${CSS.escape(id)}"]`)?.scrollIntoView({ block: "nearest" });
274
+ }, [activeIndex, isOpen, flatOptions]);
275
+ const activeId = flatOptions[activeIndex]?.id;
276
+ const rowDomId = (id) => `yunui-ms-opt-${id.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
277
+ const onSearchKeyDown = (e) => {
278
+ if (e.key === "ArrowDown") {
279
+ e.preventDefault();
280
+ setActiveIndex((i) => Math.min(i + 1, flatOptions.length - 1));
281
+ } else if (e.key === "ArrowUp") {
282
+ e.preventDefault();
283
+ setActiveIndex((i) => i < 0 ? flatOptions.length - 1 : Math.max(i - 1, 0));
284
+ } else if (e.key === "Enter") {
285
+ e.preventDefault();
286
+ const o = flatOptions[activeIndex] ?? flatOptions[0];
287
+ if (o) select(o.id);
288
+ } else if (e.key === "Escape") {
289
+ e.preventDefault();
290
+ setIsOpen(false);
291
+ }
292
+ };
256
293
  return (
257
294
  // Fixed-width root so the trigger doesn't grow/shrink as the selected
258
295
  // label changes; override the width via `className`.
@@ -262,8 +299,10 @@ function ModelSelect({
262
299
  {
263
300
  type: "button",
264
301
  onClick: () => setIsOpen((o) => !o),
302
+ "aria-expanded": isOpen,
303
+ "aria-haspopup": "listbox",
265
304
  className: cn(
266
- "flex items-center gap-2 px-3 py-2 bg-card border rounded-xl text-left group transition-all w-full shadow-sm hover:shadow-md",
305
+ "flex items-center gap-2 px-3 py-2 bg-card border rounded-xl text-left group transition-all w-full shadow-sm hover:shadow-md outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
267
306
  isOpen ? "border-ring/60 ring-2 ring-ring/25" : "border-border hover:border-ring"
268
307
  ),
269
308
  children: [
@@ -278,11 +317,12 @@ function ModelSelect({
278
317
  isOpen && /* @__PURE__ */ jsxs(
279
318
  motion.div,
280
319
  {
320
+ ref: panelRef,
281
321
  initial: { opacity: 0, y: -8, scale: 0.96 },
282
322
  animate: { opacity: 1, y: 0, scale: 1 },
283
323
  transition: { duration: 0.16, ease: "easeOut" },
284
- style: { maxWidth: "calc(100vw - 1rem)" },
285
- className: "origin-top absolute z-50 top-full left-0 mt-2 w-96 bg-popover/90 backdrop-blur-xl border border-border/60 rounded-2xl shadow-2xl overflow-hidden",
324
+ style: { maxWidth: "calc(100vw - 1rem)", marginLeft: shift, maxHeight },
325
+ className: "origin-top absolute z-50 top-full left-0 mt-2 w-96 max-w-[calc(100vw-1rem)] flex flex-col bg-background/60 backdrop-blur-2xl border border-border rounded-2xl shadow-lg shadow-black/5 text-popover-foreground overflow-hidden",
286
326
  children: [
287
327
  /* @__PURE__ */ jsxs("div", { className: "p-2.5 border-b border-border/50", children: [
288
328
  /* @__PURE__ */ jsxs("div", { className: "relative", children: [
@@ -293,48 +333,54 @@ function ModelSelect({
293
333
  ref: inputRef,
294
334
  value: search,
295
335
  onChange: (e) => setSearch(e.target.value),
336
+ onKeyDown: onSearchKeyDown,
296
337
  placeholder: L.search,
338
+ "aria-label": L.search,
339
+ role: "combobox",
340
+ "aria-expanded": isOpen,
341
+ "aria-controls": "yunui-ms-listbox",
342
+ "aria-activedescendant": activeId ? rowDomId(activeId) : void 0,
297
343
  className: "w-full pl-9 pr-8 py-2 text-sm bg-muted/50 border border-transparent rounded-xl outline-none focus:border-ring focus:bg-background transition-colors"
298
344
  }
299
345
  ),
300
- search && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setSearch(""), title: L.clearSearch, className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded-md hover:bg-muted", children: /* @__PURE__ */ jsx(X, { size: 13 }) })
346
+ search && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setSearch(""), title: L.clearSearch, "aria-label": L.clearSearch, className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded-md hover:bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring", children: /* @__PURE__ */ jsx(X, { size: 13 }) })
301
347
  ] }),
302
348
  filters && filters.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 mt-2 px-1", children: [
303
349
  filters.map((f) => {
304
350
  const on = activeFilters.includes(f.key);
305
- return /* @__PURE__ */ jsx("button", { type: "button", title: f.title, onClick: () => setActiveFilters((p) => p.includes(f.key) ? p.filter((k) => k !== f.key) : [...p, f.key]), className: cn("p-1 rounded-md transition-colors", on ? "bg-foreground/10" : "hover:bg-muted"), children: f.node }, f.key);
351
+ return /* @__PURE__ */ jsx("button", { type: "button", title: f.title, "aria-label": f.title, "aria-pressed": on, onClick: () => setActiveFilters((p) => p.includes(f.key) ? p.filter((k) => k !== f.key) : [...p, f.key]), className: cn("p-1 rounded-md transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring", on ? "bg-foreground/10" : "hover:bg-muted"), children: f.node }, f.key);
306
352
  }),
307
- activeFilters.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setActiveFilters([]), title: L.clearFilters, className: "p-1 rounded-md text-muted-foreground hover:bg-muted", children: /* @__PURE__ */ jsx(X, { size: 14 }) })
353
+ activeFilters.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setActiveFilters([]), title: L.clearFilters, "aria-label": L.clearFilters, className: "p-1 rounded-md text-muted-foreground hover:bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring", children: /* @__PURE__ */ jsx(X, { size: 14 }) })
308
354
  ] })
309
355
  ] }),
310
- groups.length > 1 && /* @__PURE__ */ jsx("div", { className: "px-2.5 py-2 border-b border-border/50 overflow-x-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 min-w-max", children: [
311
- /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setActiveGroup(null), className: cn("px-2.5 py-1.5 text-xs rounded-lg font-medium transition-colors whitespace-nowrap", !activeGroup ? "bg-foreground text-background" : "bg-muted text-muted-foreground hover:bg-muted/80"), children: [
356
+ groups.length > 1 && /* @__PURE__ */ jsx("div", { className: "px-2.5 py-2 border-b border-border/50 overflow-x-auto overflow-y-hidden overscroll-x-contain", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 min-w-max", children: [
357
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setActiveGroup(null), "aria-pressed": !activeGroup, className: cn("px-2.5 py-1.5 text-xs rounded-lg font-medium transition-colors whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring", !activeGroup ? "bg-foreground text-background" : "bg-muted text-muted-foreground hover:bg-muted/80"), children: [
312
358
  L.all,
313
359
  " (",
314
360
  options.length,
315
361
  ")"
316
362
  ] }),
317
- groups.map((g) => /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setActiveGroup((c) => c === g ? null : g), className: cn("px-2.5 py-1.5 text-xs rounded-lg font-medium transition-colors flex items-center gap-1.5 whitespace-nowrap", activeGroup === g ? "bg-foreground text-background" : "bg-muted text-muted-foreground hover:bg-muted/80"), children: [
363
+ groups.map((g) => /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setActiveGroup((c) => c === g ? null : g), "aria-pressed": activeGroup === g, className: cn("px-2.5 py-1.5 text-xs rounded-lg font-medium transition-colors flex items-center gap-1.5 whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring", activeGroup === g ? "bg-foreground text-background" : "bg-muted text-muted-foreground hover:bg-muted/80"), children: [
318
364
  groupIcon[g],
319
365
  groupLabel[g] ?? g
320
366
  ] }, g))
321
367
  ] }) }),
322
- /* @__PURE__ */ jsxs("div", { ref: listRef, onWheel, className: "max-h-96 overflow-y-auto overscroll-contain", children: [
368
+ /* @__PURE__ */ jsxs("div", { ref: listRef, onWheel, onMouseMove: clearActiveOnPointer, id: "yunui-ms-listbox", role: "listbox", className: "flex-1 min-h-0 max-h-96 overflow-y-auto overscroll-contain", children: [
323
369
  pinnedList.length > 0 && /* @__PURE__ */ jsxs("div", { className: "px-1.5 py-1.5 border-b border-border/40", children: [
324
370
  /* @__PURE__ */ jsxs("div", { className: "text-[10px] font-medium text-muted-foreground uppercase tracking-wide px-2 mb-1 flex items-center gap-1", children: [
325
371
  /* @__PURE__ */ jsx(Pin, { size: 9 }),
326
372
  " ",
327
373
  L.pinned
328
374
  ] }),
329
- pinnedList.map((o) => /* @__PURE__ */ jsx(ModelRow, { option: o, selected: o.id === value, pinned: true, isPinnable: !!onTogglePin, onSelect: () => select(o.id), onTogglePin: () => onTogglePin?.(o.id) }, o.id))
375
+ pinnedList.map((o) => /* @__PURE__ */ jsx(ModelRow, { domId: rowDomId(o.id), active: o.id === activeId, option: o, selected: o.id === value, pinned: true, isPinnable: !!onTogglePin, onSelect: () => select(o.id), onTogglePin: () => onTogglePin?.(o.id) }, o.id))
330
376
  ] }),
331
377
  /* @__PURE__ */ jsx("div", { className: "px-1.5 py-1.5", children: Object.entries(grouped).map(([g, opts]) => /* @__PURE__ */ jsxs("div", { className: "mb-3 last:mb-0", children: [
332
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-2 mb-1 sticky top-0 bg-popover/95 backdrop-blur-sm py-1.5 z-10", children: [
378
+ /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 pt-1 pb-1.5", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-xl bg-muted px-3 py-2", children: [
333
379
  groupIcon[g],
334
380
  /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold", children: groupLabel[g] ?? g }),
335
- /* @__PURE__ */ jsx("span", { className: "ml-auto text-[10px] text-muted-foreground bg-muted/60 px-2 py-0.5 rounded-full font-medium", children: opts.length })
336
- ] }),
337
- opts.map((o) => /* @__PURE__ */ jsx(ModelRow, { option: o, selected: o.id === value, pinned: false, isPinnable: !!onTogglePin, onSelect: () => select(o.id), onTogglePin: () => onTogglePin?.(o.id) }, o.id))
381
+ /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 min-w-5 text-center text-[10px] font-semibold tabular-nums text-muted-foreground bg-foreground/10 px-1.5 py-0.5 rounded-md", children: opts.length })
382
+ ] }) }),
383
+ opts.map((o) => /* @__PURE__ */ jsx(ModelRow, { domId: rowDomId(o.id), active: o.id === activeId, option: o, selected: o.id === value, pinned: false, isPinnable: !!onTogglePin, onSelect: () => select(o.id), onTogglePin: () => onTogglePin?.(o.id) }, o.id))
338
384
  ] }, g)) }),
339
385
  filtered.length === 0 && /* @__PURE__ */ jsxs("div", { className: "py-12 text-center text-muted-foreground", children: [
340
386
  /* @__PURE__ */ jsx(Sparkles, { size: 28, className: "mx-auto mb-3 opacity-40" }),
@@ -351,6 +397,8 @@ function ModelSelect({
351
397
  var ModelRow = memo(function ModelRow2({
352
398
  option,
353
399
  selected,
400
+ active,
401
+ domId,
354
402
  pinned,
355
403
  isPinnable,
356
404
  onSelect,
@@ -359,13 +407,18 @@ var ModelRow = memo(function ModelRow2({
359
407
  return /* @__PURE__ */ jsxs(
360
408
  "div",
361
409
  {
410
+ id: domId,
362
411
  "data-model-id": option.id,
412
+ role: "option",
413
+ "aria-selected": selected,
363
414
  onClick: onSelect,
364
415
  className: cn(
365
416
  "relative flex items-center gap-3 px-3 py-2.5 rounded-xl cursor-pointer group transition-colors",
366
417
  // A clear gray fill on both states (selected solid, hover lighter)
367
418
  // — the bar's opacity then tells selected from merely-hovered.
368
- selected ? "bg-muted" : "hover:bg-muted"
419
+ selected ? "bg-muted" : "hover:bg-muted",
420
+ // keyboard highlight (arrow-key navigation)
421
+ active && "bg-muted ring-2 ring-ring/40"
369
422
  ),
370
423
  children: [
371
424
  /* @__PURE__ */ jsx(
@@ -406,6 +459,53 @@ var ModelRow = memo(function ModelRow2({
406
459
  }
407
460
  );
408
461
  });
462
+ function ModelManagerCard({
463
+ icon,
464
+ name,
465
+ nameBadges,
466
+ ids,
467
+ selectSlot,
468
+ actions,
469
+ fields,
470
+ capabilities,
471
+ selected,
472
+ className
473
+ }) {
474
+ return /* @__PURE__ */ jsxs(
475
+ "div",
476
+ {
477
+ className: cn(
478
+ "card p-5 transition-shadow hover:shadow-md",
479
+ selected && "ring-2 ring-primary/40 bg-muted/30",
480
+ className
481
+ ),
482
+ children: [
483
+ (selectSlot || actions) && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 -mt-2 mb-3 min-h-7", children: [
484
+ /* @__PURE__ */ jsx("div", { className: "flex items-center", children: selectSlot }),
485
+ actions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-0.5 -mr-1.5 text-muted-foreground", children: actions })
486
+ ] }),
487
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
488
+ icon && /* @__PURE__ */ jsx("div", { className: "shrink-0", children: icon }),
489
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
490
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 gap-y-1 flex-wrap", children: [
491
+ /* @__PURE__ */ jsx("span", { className: "font-semibold leading-tight min-w-0 break-words", children: name }),
492
+ nameBadges
493
+ ] }),
494
+ ids && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1 mt-1.5", children: ids })
495
+ ] })
496
+ ] }),
497
+ fields && fields.length > 0 && /* @__PURE__ */ jsx("dl", { className: "grid grid-cols-2 gap-x-4 gap-y-3 mt-4 text-sm", children: fields.map((f, i) => /* @__PURE__ */ jsxs("div", { className: cn("min-w-0", f.full && "col-span-2"), children: [
498
+ /* @__PURE__ */ jsx("dt", { className: "text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: f.label }),
499
+ /* @__PURE__ */ jsx("dd", { className: "mt-1", children: f.value })
500
+ ] }, i)) }),
501
+ capabilities && /* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
502
+ capabilities.label && /* @__PURE__ */ jsx("div", { className: "text-[10px] font-medium uppercase tracking-wide text-muted-foreground mb-1.5", children: capabilities.label }),
503
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: capabilities.value })
504
+ ] })
505
+ ]
506
+ }
507
+ );
508
+ }
409
509
  var llmCapabilityConfig = [
410
510
  { value: "chat", icon: MessageSquare, iconColor: "text-blue-500", color: "bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/20 hover:bg-blue-500/20" },
411
511
  { value: "streaming", icon: Waves, iconColor: "text-cyan-500", color: "bg-cyan-500/10 text-cyan-600 dark:text-cyan-400 border-cyan-500/20 hover:bg-cyan-500/20" },
@@ -498,7 +598,8 @@ function CapabilitySelector({ selected, onChange, disabled = false, size = "md",
498
598
  type: "button",
499
599
  onClick: () => toggleCapability(cap.value),
500
600
  disabled,
501
- className: `rounded-lg border text-left transition-all flex items-center ${sizeClasses} ${isSelected ? cap.color : "bg-background border-border hover:bg-muted/50"} ${disabled ? "opacity-50 cursor-not-allowed" : ""}`,
601
+ "aria-pressed": isSelected,
602
+ className: `rounded-lg border text-left transition-colors flex items-center outline-none focus-visible:ring-2 focus-visible:ring-ring ${sizeClasses} ${isSelected ? cap.color : "bg-background border-border hover:bg-muted/50"} ${disabled ? "opacity-50 cursor-not-allowed" : ""}`,
502
603
  children: [
503
604
  /* @__PURE__ */ jsx(Icon, { size: iconSize, className: `${isSelected ? "" : cap.iconColor} shrink-0` }),
504
605
  /* @__PURE__ */ jsx("span", { className: "font-medium", children: cap.label })
@@ -1090,7 +1191,7 @@ function ProviderIcon({
1090
1191
  return /* @__PURE__ */ jsx(
1091
1192
  "div",
1092
1193
  {
1093
- className: `${getRadius()} overflow-hidden bg-linear-to-br from-black/2 to-black/5 flex items-center justify-center ${className}`,
1194
+ className: `${getRadius()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1094
1195
  style: { width: size, height: size },
1095
1196
  children: /* @__PURE__ */ jsx("img", { src: effectiveIconUrl, alt: provider, width: size, height: size, className: "object-cover", onError: () => setCustomError(true) })
1096
1197
  }
@@ -1109,7 +1210,7 @@ function ProviderIcon({
1109
1210
  return /* @__PURE__ */ jsx(
1110
1211
  "div",
1111
1212
  {
1112
- className: `${getRadiusClass()} overflow-hidden bg-linear-to-br from-black/2 to-black/5 flex items-center justify-center ${className}`,
1213
+ className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1113
1214
  style: { width: size, height: size },
1114
1215
  children: /* @__PURE__ */ jsx(
1115
1216
  Image,
@@ -1143,7 +1244,7 @@ function ProviderIcon({
1143
1244
  return /* @__PURE__ */ jsx(
1144
1245
  "div",
1145
1246
  {
1146
- className: `${getRadiusClass()} bg-linear-to-br from-black/5 to-black/10 flex items-center justify-center ${className}`,
1247
+ className: `${getRadiusClass()} bg-muted flex items-center justify-center ${className}`,
1147
1248
  style: { width: size, height: size },
1148
1249
  children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: (provider || "?").charAt(0).toUpperCase() })
1149
1250
  }
@@ -1292,7 +1393,7 @@ function ModelIcon({
1292
1393
  return /* @__PURE__ */ jsx(
1293
1394
  "div",
1294
1395
  {
1295
- className: `${getRadiusClass()} overflow-hidden bg-linear-to-br from-black/2 to-black/5 flex items-center justify-center ${className}`,
1396
+ className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1296
1397
  style: { width: size, height: size },
1297
1398
  children: /* @__PURE__ */ jsx(
1298
1399
  Image,
@@ -1331,7 +1432,7 @@ function ModelIcon({
1331
1432
  return /* @__PURE__ */ jsx(
1332
1433
  "div",
1333
1434
  {
1334
- className: `${getRadiusClass()} overflow-hidden bg-linear-to-br from-black/2 to-black/5 flex items-center justify-center ${className}`,
1435
+ className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1335
1436
  style: { width: size, height: size },
1336
1437
  children: /* @__PURE__ */ jsx(
1337
1438
  Image,
@@ -1433,6 +1534,9 @@ function LanguageSwitcher({
1433
1534
  }) {
1434
1535
  const [isOpen, setIsOpen] = useState(false);
1435
1536
  const containerRef = useRef(null);
1537
+ const triggerRef = useRef(null);
1538
+ const panelRef = useRef(null);
1539
+ const { shift, maxHeight } = useAnchoredPosition(isOpen, panelRef);
1436
1540
  useEffect(() => {
1437
1541
  const handleClickOutside = (e) => {
1438
1542
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -1442,6 +1546,17 @@ function LanguageSwitcher({
1442
1546
  document.addEventListener("mousedown", handleClickOutside);
1443
1547
  return () => document.removeEventListener("mousedown", handleClickOutside);
1444
1548
  }, []);
1549
+ useEffect(() => {
1550
+ if (!isOpen) return;
1551
+ const onKey = (e) => {
1552
+ if (e.key === "Escape") {
1553
+ setIsOpen(false);
1554
+ triggerRef.current?.focus();
1555
+ }
1556
+ };
1557
+ document.addEventListener("keydown", onKey);
1558
+ return () => document.removeEventListener("keydown", onKey);
1559
+ }, [isOpen]);
1445
1560
  const handleLocaleChange = (newLocale) => {
1446
1561
  if (newLocale === currentLocale || pending) return;
1447
1562
  setIsOpen(false);
@@ -1452,34 +1567,48 @@ function LanguageSwitcher({
1452
1567
  variant === "pill" ? /* @__PURE__ */ jsxs(
1453
1568
  "button",
1454
1569
  {
1570
+ ref: triggerRef,
1455
1571
  onClick: () => setIsOpen(!isOpen),
1456
- className: "flex items-center gap-1.5 h-9 px-3 rounded-full text-sm font-medium transition-all bg-(--bg-elevated) hover:bg-(--bg-elevated)/80 border border-(--border-hairline) text-(--text-secondary) hover:text-(--text-primary) disabled:opacity-50",
1572
+ className: "flex items-center gap-1.5 h-9 px-2.5 sm:px-3 rounded-full text-sm font-medium transition-all bg-(--bg-elevated) hover:bg-(--bg-elevated)/80 border border-(--border-hairline) text-(--text-secondary) hover:text-(--text-primary) disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
1457
1573
  disabled: pending,
1458
1574
  "aria-label": label,
1575
+ "aria-expanded": isOpen,
1576
+ "aria-haspopup": "listbox",
1459
1577
  children: [
1460
- /* @__PURE__ */ jsx(Globe, { size: 14 }),
1461
- /* @__PURE__ */ jsx("span", { children: currentLabel })
1578
+ /* @__PURE__ */ jsx(Globe, { size: 14, className: "shrink-0" }),
1579
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: currentLabel })
1462
1580
  ]
1463
1581
  }
1464
1582
  ) : /* @__PURE__ */ jsx(
1465
1583
  "button",
1466
1584
  {
1585
+ ref: triggerRef,
1467
1586
  onClick: () => setIsOpen(!isOpen),
1468
- className: "w-9 h-9 rounded-lg flex items-center justify-center hover:bg-foreground/5 transition-colors disabled:opacity-50",
1587
+ className: "w-9 h-9 rounded-lg flex items-center justify-center hover:bg-foreground/5 transition-colors disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
1469
1588
  disabled: pending,
1470
1589
  "aria-label": label,
1590
+ "aria-expanded": isOpen,
1591
+ "aria-haspopup": "listbox",
1471
1592
  children: /* @__PURE__ */ jsx(Globe, { className: "h-[1.2rem] w-[1.2rem]" })
1472
1593
  }
1473
1594
  ),
1474
- isOpen && /* @__PURE__ */ jsx("div", { className: `absolute ${align === "left" ? "left-0" : "right-0"} top-full mt-2 z-50 rounded-2xl border border-white/10 dark:border-white/5 bg-background/60 backdrop-blur-2xl text-popover-foreground shadow-lg shadow-black/5 animate-in fade-in-0 zoom-in-95 duration-200`, children: /* @__PURE__ */ jsx("div", { className: "p-1", children: locales.map((lang) => /* @__PURE__ */ jsx(
1475
- "button",
1595
+ isOpen && /* @__PURE__ */ jsx(
1596
+ "div",
1476
1597
  {
1477
- onClick: () => handleLocaleChange(lang.value),
1478
- className: `dropdown-item w-full text-left ${currentLocale === lang.value ? "active" : ""}`,
1479
- children: /* @__PURE__ */ jsx("span", { className: "flex-1", children: lang.label })
1480
- },
1481
- lang.value
1482
- )) }) })
1598
+ ref: panelRef,
1599
+ style: { marginLeft: shift, maxHeight },
1600
+ className: `absolute ${align === "left" ? "left-0" : "right-0"} top-full mt-2 z-50 flex flex-col overflow-hidden rounded-2xl border border-border bg-background/60 backdrop-blur-2xl text-popover-foreground shadow-lg shadow-black/5 animate-in fade-in-0 zoom-in-95 duration-200`,
1601
+ children: /* @__PURE__ */ jsx("div", { className: "p-1 flex-1 min-h-0 overflow-y-auto", children: locales.map((lang) => /* @__PURE__ */ jsx(
1602
+ "button",
1603
+ {
1604
+ onClick: () => handleLocaleChange(lang.value),
1605
+ className: `dropdown-item w-full text-left ${currentLocale === lang.value ? "active" : ""}`,
1606
+ children: /* @__PURE__ */ jsx("span", { className: "flex-1", children: lang.label })
1607
+ },
1608
+ lang.value
1609
+ )) })
1610
+ }
1611
+ )
1483
1612
  ] });
1484
1613
  }
1485
1614
  function Navbar({
@@ -1541,94 +1670,101 @@ function Navbar({
1541
1670
  }
1542
1671
  return false;
1543
1672
  };
1544
- return /* @__PURE__ */ jsxs("nav", { className: "fixed top-6 left-1/2 -translate-x-1/2 z-50 px-6 py-2.5 max-w-6xl w-[calc(100%-48px)] bg-background/80 backdrop-blur-xl border border-border rounded-full shadow-md flex items-center justify-between", children: [
1545
- /* @__PURE__ */ jsxs(Link, { href: homeHref, className: "flex items-center gap-2 rounded-lg px-2 py-1 -mx-2 hover:bg-foreground/5 transition-colors duration-200", children: [
1546
- /* @__PURE__ */ jsx(Image, { src: logoSrc, alt: appName, width: 28, height: 28, className: "w-7 h-7" }),
1547
- /* @__PURE__ */ jsx("span", { className: "font-semibold text-sm tracking-tight", children: appName })
1548
- ] }),
1549
- variant === "public" && /* @__PURE__ */ jsx("div", { className: "hidden md:flex items-center gap-6 lg:gap-8 absolute left-1/2 -translate-x-1/2", children: links.map((link) => /* @__PURE__ */ jsxs(
1550
- Link,
1551
- {
1552
- href: link.href,
1553
- className: "group relative px-2 lg:px-3 py-2 whitespace-nowrap min-w-15 text-center",
1554
- children: [
1555
- /* @__PURE__ */ jsx("span", { className: `text-sm relative z-10 ${isActive(link.href) ? "text-foreground font-medium" : "text-muted-foreground"}`, children: link.label }),
1556
- /* @__PURE__ */ jsx("span", { className: `absolute bottom-1.5 left-1/2 -translate-x-1/2 h-0.5 bg-foreground rounded-full transition-all duration-200 yunui-accent-bg ${isActive(link.href) ? "w-8" : "w-0 group-hover:w-8"}` })
1557
- ]
1558
- },
1559
- link.href
1560
- )) }),
1561
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0", children: [
1562
- /* @__PURE__ */ jsx("span", { className: "hidden md:flex items-center gap-1.5", children: languageSwitcher }),
1563
- themeToggle ?? /* @__PURE__ */ jsx(ThemeToggle, { variant: "pill" }),
1564
- variant !== "minimal" && /* @__PURE__ */ jsxs(Fragment, { children: [
1565
- /* @__PURE__ */ jsx(
1566
- Link,
1567
- {
1568
- href: loginHref,
1569
- className: "hidden md:block text-sm text-muted-foreground hover:text-foreground transition-colors duration-200 py-2 whitespace-nowrap min-w-15 text-center",
1570
- children: signIn
1571
- }
1572
- ),
1573
- /* @__PURE__ */ jsx(
1574
- Link,
1575
- {
1576
- href: signupHref,
1577
- className: "hidden md:inline-block px-4 py-2 bg-foreground text-background text-sm font-medium rounded-lg hover:bg-foreground/90 hover:shadow-md transition-all duration-200 whitespace-nowrap min-w-20 text-center yunui-accent-bg yunui-accent-on",
1578
- children: signUp
1579
- }
1580
- )
1581
- ] }),
1582
- variant === "public" && /* @__PURE__ */ jsx(
1583
- "button",
1584
- {
1585
- type: "button",
1586
- onClick: () => setMenuOpen((o) => !o),
1587
- className: "md:hidden w-9 h-9 rounded-full flex items-center justify-center hover:bg-foreground/5 transition-colors",
1588
- "aria-label": menuLabel,
1589
- "aria-expanded": menuOpen,
1590
- children: menuOpen ? /* @__PURE__ */ jsx(X, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(Menu, { className: "w-5 h-5" })
1591
- }
1592
- )
1593
- ] }),
1594
- variant === "public" && menuOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
1595
- /* @__PURE__ */ jsx("div", { className: "md:hidden fixed inset-0 -z-10", onClick: () => setMenuOpen(false) }),
1596
- /* @__PURE__ */ jsxs("div", { className: "md:hidden absolute top-full left-0 right-0 mt-3 p-2 bg-background/95 backdrop-blur-xl border border-border rounded-2xl shadow-lg flex flex-col gap-0.5", children: [
1597
- links.map((link) => /* @__PURE__ */ jsx(
1673
+ return /* @__PURE__ */ jsxs(
1674
+ "nav",
1675
+ {
1676
+ style: { top: "max(1.5rem, env(safe-area-inset-top))" },
1677
+ className: "fixed left-1/2 -translate-x-1/2 z-50 px-6 py-2.5 max-w-6xl w-[calc(100%-48px)] bg-background/80 backdrop-blur-xl border border-border rounded-full shadow-md flex items-center justify-between",
1678
+ children: [
1679
+ /* @__PURE__ */ jsxs(Link, { href: homeHref, className: "flex items-center gap-2 min-w-0 rounded-lg px-2 py-1 -mx-2 hover:bg-foreground/5 transition-colors duration-200", children: [
1680
+ /* @__PURE__ */ jsx(Image, { src: logoSrc, alt: appName, width: 28, height: 28, className: "w-7 h-7 shrink-0" }),
1681
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-sm tracking-tight truncate", children: appName })
1682
+ ] }),
1683
+ variant === "public" && /* @__PURE__ */ jsx("div", { className: "hidden md:flex items-center gap-6 lg:gap-8 absolute left-1/2 -translate-x-1/2", children: links.map((link) => /* @__PURE__ */ jsxs(
1598
1684
  Link,
1599
1685
  {
1600
1686
  href: link.href,
1601
- onClick: () => setMenuOpen(false),
1602
- className: `px-4 py-2.5 rounded-xl text-sm transition-colors hover:bg-foreground/5 ${isActive(link.href) ? "text-foreground font-medium" : "text-muted-foreground"}`,
1603
- children: link.label
1687
+ className: "group relative px-2 lg:px-3 py-2 whitespace-nowrap min-w-15 text-center",
1688
+ children: [
1689
+ /* @__PURE__ */ jsx("span", { className: `text-sm relative z-10 ${isActive(link.href) ? "text-foreground font-medium" : "text-muted-foreground"}`, children: link.label }),
1690
+ /* @__PURE__ */ jsx("span", { className: `absolute bottom-1.5 left-1/2 -translate-x-1/2 h-0.5 bg-foreground rounded-full transition-all duration-200 yunui-accent-bg ${isActive(link.href) ? "w-8" : "w-0 group-hover:w-8"}` })
1691
+ ]
1604
1692
  },
1605
1693
  link.href
1606
- )),
1607
- /* @__PURE__ */ jsx("div", { className: "my-1 border-t border-border" }),
1608
- languageSwitcher && /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5", children: languageSwitcher }),
1609
- /* @__PURE__ */ jsx(
1610
- Link,
1611
- {
1612
- href: loginHref,
1613
- onClick: () => setMenuOpen(false),
1614
- className: "px-4 py-2.5 rounded-xl text-sm text-muted-foreground transition-colors hover:bg-foreground/5",
1615
- children: signIn
1616
- }
1617
- ),
1618
- /* @__PURE__ */ jsx(
1619
- Link,
1620
- {
1621
- href: signupHref,
1622
- onClick: () => setMenuOpen(false),
1623
- className: "mt-0.5 px-4 py-2.5 rounded-xl text-sm font-medium text-center bg-foreground text-background hover:bg-foreground/90 transition-colors yunui-accent-bg yunui-accent-on",
1624
- children: signUp
1625
- }
1626
- )
1627
- ] })
1628
- ] })
1629
- ] });
1694
+ )) }),
1695
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0", children: [
1696
+ /* @__PURE__ */ jsx("span", { className: "hidden md:flex items-center gap-1.5", children: languageSwitcher }),
1697
+ themeToggle ?? /* @__PURE__ */ jsx(ThemeToggle, { variant: "pill" }),
1698
+ variant !== "minimal" && /* @__PURE__ */ jsxs(Fragment, { children: [
1699
+ /* @__PURE__ */ jsx(
1700
+ Link,
1701
+ {
1702
+ href: loginHref,
1703
+ className: "hidden md:block text-sm text-muted-foreground hover:text-foreground transition-colors duration-200 py-2 whitespace-nowrap min-w-15 text-center",
1704
+ children: signIn
1705
+ }
1706
+ ),
1707
+ /* @__PURE__ */ jsx(
1708
+ Link,
1709
+ {
1710
+ href: signupHref,
1711
+ className: "hidden md:inline-block px-4 py-2 bg-foreground text-background text-sm font-medium rounded-lg hover:bg-foreground/90 hover:shadow-md transition-all duration-200 whitespace-nowrap min-w-20 text-center yunui-accent-bg yunui-accent-on",
1712
+ children: signUp
1713
+ }
1714
+ )
1715
+ ] }),
1716
+ variant === "public" && /* @__PURE__ */ jsx(
1717
+ "button",
1718
+ {
1719
+ type: "button",
1720
+ onClick: () => setMenuOpen((o) => !o),
1721
+ className: "md:hidden w-9 h-9 rounded-full flex items-center justify-center hover:bg-foreground/5 transition-colors",
1722
+ "aria-label": menuLabel,
1723
+ "aria-expanded": menuOpen,
1724
+ children: menuOpen ? /* @__PURE__ */ jsx(X, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(Menu, { className: "w-5 h-5" })
1725
+ }
1726
+ )
1727
+ ] }),
1728
+ variant === "public" && menuOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
1729
+ /* @__PURE__ */ jsx("div", { className: "md:hidden fixed inset-0 -z-10", "aria-hidden": "true", onClick: () => setMenuOpen(false) }),
1730
+ /* @__PURE__ */ jsxs("div", { className: "md:hidden absolute top-full left-0 right-0 mt-3 p-2 bg-background/60 backdrop-blur-2xl border border-border rounded-2xl shadow-lg shadow-black/5 flex flex-col gap-0.5", children: [
1731
+ links.map((link) => /* @__PURE__ */ jsx(
1732
+ Link,
1733
+ {
1734
+ href: link.href,
1735
+ onClick: () => setMenuOpen(false),
1736
+ className: `px-4 py-2.5 rounded-xl text-sm transition-colors hover:bg-foreground/5 ${isActive(link.href) ? "text-foreground font-medium" : "text-muted-foreground"}`,
1737
+ children: link.label
1738
+ },
1739
+ link.href
1740
+ )),
1741
+ /* @__PURE__ */ jsx("div", { className: "my-1 border-t border-border" }),
1742
+ languageSwitcher && /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5", children: languageSwitcher }),
1743
+ /* @__PURE__ */ jsx(
1744
+ Link,
1745
+ {
1746
+ href: loginHref,
1747
+ onClick: () => setMenuOpen(false),
1748
+ className: "px-4 py-2.5 rounded-xl text-sm text-muted-foreground transition-colors hover:bg-foreground/5",
1749
+ children: signIn
1750
+ }
1751
+ ),
1752
+ /* @__PURE__ */ jsx(
1753
+ Link,
1754
+ {
1755
+ href: signupHref,
1756
+ onClick: () => setMenuOpen(false),
1757
+ className: "mt-0.5 px-4 py-2.5 rounded-xl text-sm font-medium text-center bg-foreground text-background hover:bg-foreground/90 transition-colors yunui-accent-bg yunui-accent-on",
1758
+ children: signUp
1759
+ }
1760
+ )
1761
+ ] })
1762
+ ] })
1763
+ ]
1764
+ }
1765
+ );
1630
1766
  }
1631
1767
 
1632
- export { CapabilityIcon, CapabilitySelector, IDBadge, LanguageSwitcher, ModelAvatar, ModelCard, ModelIcon, ModelSelect, ModelTypeIcon, Navbar, PROVIDER_ICON_SLUGS, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getProviderIconOptions, getProviderName, isKnownCapability, normalizeProviderId };
1768
+ export { CapabilityIcon, CapabilitySelector, IDBadge, LanguageSwitcher, ModelAvatar, ModelCard, ModelIcon, ModelManagerCard, ModelSelect, ModelTypeIcon, Navbar, PROVIDER_ICON_SLUGS, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getProviderIconOptions, getProviderName, isKnownCapability, normalizeProviderId };
1633
1769
  //# sourceMappingURL=ai.js.map
1634
1770
  //# sourceMappingURL=ai.js.map