@yuhuanowo/yunui 0.2.17 → 0.2.19
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/README.md +56 -5
- package/README.zh-CN.md +21 -3
- package/README.zh-TW.md +21 -3
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/agent/catalog.generated.json +29368 -0
- package/agent/recipes/analytics.tsx +121 -0
- package/agent/recipes/chat.tsx +154 -0
- package/agent/recipes/conversation-units.tsx +28 -0
- package/agent/recipes/dashboard.tsx +38 -0
- package/agent/recipes/landing.tsx +26 -0
- package/agent/recipes/setup.md +44 -0
- package/agent/skills/yunui/SKILL.md +82 -0
- package/dist/adapters.d.ts +5 -0
- package/dist/adapters.js +1 -1
- package/dist/ai.d.ts +478 -273
- package/dist/ai.js +1334 -1964
- package/dist/ai.js.map +1 -1
- package/dist/charts.d.ts +149 -0
- package/dist/charts.js +849 -0
- package/dist/charts.js.map +1 -0
- package/dist/chat.d.ts +204 -18
- package/dist/chat.js +887 -132
- package/dist/chat.js.map +1 -1
- package/dist/{chunk-F2HG4TOQ.js → chunk-ASPPAL7E.js} +25 -29
- package/dist/chunk-ASPPAL7E.js.map +1 -0
- package/dist/chunk-AVXIR7ZQ.js +197 -0
- package/dist/chunk-AVXIR7ZQ.js.map +1 -0
- package/dist/chunk-FJ52MVRF.js +82 -0
- package/dist/chunk-FJ52MVRF.js.map +1 -0
- package/dist/chunk-GRUB2GXF.js +15 -0
- package/dist/chunk-GRUB2GXF.js.map +1 -0
- package/dist/{chunk-3RT24MSH.js → chunk-GWD5W5F5.js} +2 -2
- package/dist/{chunk-3RT24MSH.js.map → chunk-GWD5W5F5.js.map} +1 -1
- package/dist/{chunk-BCOKFWXC.js → chunk-I2DAKAD5.js} +423 -281
- package/dist/chunk-I2DAKAD5.js.map +1 -0
- package/dist/chunk-OM7B4O6K.js +193 -0
- package/dist/chunk-OM7B4O6K.js.map +1 -0
- package/dist/chunk-OZIDZFMF.js +70 -0
- package/dist/chunk-OZIDZFMF.js.map +1 -0
- package/dist/chunk-P6LU2FWV.js +35 -0
- package/dist/chunk-P6LU2FWV.js.map +1 -0
- package/dist/chunk-SXWMKFKM.js +41 -0
- package/dist/chunk-SXWMKFKM.js.map +1 -0
- package/dist/chunk-TMTXJFNN.js +2715 -0
- package/dist/chunk-TMTXJFNN.js.map +1 -0
- package/dist/chunk-VNKAEQKU.js +501 -0
- package/dist/chunk-VNKAEQKU.js.map +1 -0
- package/dist/chunk-VSS7ASN2.js +12 -0
- package/dist/chunk-VSS7ASN2.js.map +1 -0
- package/dist/chunk-VYVFMNM7.js +112 -0
- package/dist/chunk-VYVFMNM7.js.map +1 -0
- package/dist/chunk-YKUQ7GCJ.js +230 -0
- package/dist/chunk-YKUQ7GCJ.js.map +1 -0
- package/dist/chunk-Z6WXDNBJ.js +366 -0
- package/dist/chunk-Z6WXDNBJ.js.map +1 -0
- package/dist/chunk-ZBRV6NHL.js +1115 -0
- package/dist/chunk-ZBRV6NHL.js.map +1 -0
- package/dist/code.d.ts +42 -0
- package/dist/code.js +8 -0
- package/dist/code.js.map +1 -0
- package/dist/content.d.ts +26 -40
- package/dist/content.js +400 -418
- package/dist/content.js.map +1 -1
- package/dist/footer-BCd-S806.d.ts +122 -0
- package/dist/index.d.ts +814 -88
- package/dist/index.js +7 -5
- package/dist/language.d.ts +30 -0
- package/dist/language.js +5 -0
- package/dist/language.js.map +1 -0
- package/dist/model-card.d.ts +43 -0
- package/dist/model-card.js +116 -0
- package/dist/model-card.js.map +1 -0
- package/dist/model.d.ts +51 -0
- package/dist/model.js +91 -0
- package/dist/model.js.map +1 -0
- package/dist/motion.d.ts +11 -0
- package/dist/motion.js +9 -0
- package/dist/motion.js.map +1 -0
- package/dist/patterns.d.ts +913 -29
- package/dist/patterns.js +1987 -259
- package/dist/patterns.js.map +1 -1
- package/dist/pickers.d.ts +134 -0
- package/dist/pickers.js +751 -0
- package/dist/pickers.js.map +1 -0
- package/dist/provider-icons-bgBTnami.d.ts +88 -0
- package/dist/segmented-bar-Bsr0PZIL.d.ts +58 -0
- package/dist/sparkline-vy5ec5C6.d.ts +67 -0
- package/icons/apps/aistudio.webp +0 -0
- package/icons/apps/coze.webp +0 -0
- package/icons/apps/dify.webp +0 -0
- package/icons/apps/doubao.webp +0 -0
- package/icons/apps/flowith.webp +0 -0
- package/icons/apps/gemini.webp +0 -0
- package/icons/apps/github-copilot.webp +0 -0
- package/icons/apps/google.webp +0 -0
- package/icons/apps/grok.webp +0 -0
- package/icons/apps/kimi.webp +0 -0
- package/icons/apps/ling.webp +0 -0
- package/icons/apps/longcat.webp +0 -0
- package/icons/apps/monica.webp +0 -0
- package/icons/apps/n8n.webp +0 -0
- package/icons/apps/notebooklm.webp +0 -0
- package/icons/apps/perplexity.webp +0 -0
- package/icons/apps/poe.webp +0 -0
- package/icons/apps/qingyan.webp +0 -0
- package/icons/apps/stepfun.webp +0 -0
- package/icons/apps/tiangong.webp +0 -0
- package/icons/apps/yuanbao.webp +0 -0
- package/icons/apps/zai.webp +0 -0
- package/icons/models/ai21.webp +0 -0
- package/icons/models/aimass.webp +0 -0
- package/icons/models/anthropic.webp +0 -0
- package/icons/models/baichuan.webp +0 -0
- package/icons/models/byte_dance.webp +0 -0
- package/icons/models/chatglm.webp +0 -0
- package/icons/models/claude.webp +0 -0
- package/icons/models/codegeex.webp +0 -0
- package/icons/models/cogview3flash.webp +0 -0
- package/icons/models/cohere.webp +0 -0
- package/icons/models/copilot.webp +0 -0
- package/icons/models/dalle.webp +0 -0
- package/icons/models/dbrx.webp +0 -0
- package/icons/models/deepseek.webp +0 -0
- package/icons/models/doubao.webp +0 -0
- package/icons/models/flux.webp +0 -0
- package/icons/models/gemini.webp +0 -0
- package/icons/models/gemma.webp +0 -0
- package/icons/models/google.webp +0 -0
- package/icons/models/grok.webp +0 -0
- package/icons/models/hailuo.webp +0 -0
- package/icons/models/huggingface.webp +0 -0
- package/icons/models/hunyuan.webp +0 -0
- package/icons/models/ibm.webp +0 -0
- package/icons/models/ideogram.webp +0 -0
- package/icons/models/internlm.webp +0 -0
- package/icons/models/jina.webp +0 -0
- package/icons/models/ling.webp +0 -0
- package/icons/models/llava.webp +0 -0
- package/icons/models/luma.webp +0 -0
- package/icons/models/magic.webp +0 -0
- package/icons/models/microsoft.webp +0 -0
- package/icons/models/midjourney.webp +0 -0
- package/icons/models/minimax.webp +0 -0
- package/icons/models/mistral.webp +0 -0
- package/icons/models/moonshot.webp +0 -0
- package/icons/models/nousresearch.webp +0 -0
- package/icons/models/nvidia.webp +0 -0
- package/icons/models/o3.webp +0 -0
- package/icons/models/openai.webp +0 -0
- package/icons/models/palm.webp +0 -0
- package/icons/models/perplexity.webp +0 -0
- package/icons/models/qwen.webp +0 -0
- package/icons/models/stability.webp +0 -0
- package/icons/models/step.webp +0 -0
- package/icons/models/suno.webp +0 -0
- package/icons/models/upstage.webp +0 -0
- package/icons/models/vidu.webp +0 -0
- package/icons/models/volcengine.webp +0 -0
- package/icons/models/voyageai.webp +0 -0
- package/icons/models/wenxin.webp +0 -0
- package/icons/models/yi.webp +0 -0
- package/icons/models/zai.webp +0 -0
- package/icons/models/zero-one.webp +0 -0
- package/icons/models/zhipu.webp +0 -0
- package/icons/providers/302ai.webp +0 -0
- package/icons/providers/ace.webp +0 -0
- package/icons/providers/adobe.webp +0 -0
- package/icons/providers/adobefirefly.webp +0 -0
- package/icons/providers/agentvoice.webp +0 -0
- package/icons/providers/agnesai.webp +0 -0
- package/icons/providers/agui.webp +0 -0
- package/icons/providers/ai2.webp +0 -0
- package/icons/providers/ai21.webp +0 -0
- package/icons/providers/ai302.webp +0 -0
- package/icons/providers/ai360.webp +0 -0
- package/icons/providers/aihubmix.webp +0 -0
- package/icons/providers/aimass.webp +0 -0
- package/icons/providers/aimlapi.webp +0 -0
- package/icons/providers/aionlabs.webp +0 -0
- package/icons/providers/airjelly.webp +0 -0
- package/icons/providers/aistudio.webp +0 -0
- package/icons/providers/akashchat.webp +0 -0
- package/icons/providers/alephalpha.webp +0 -0
- package/icons/providers/alibaba.webp +0 -0
- package/icons/providers/alibabacloud.webp +0 -0
- package/icons/providers/amdradeoncloud.webp +0 -0
- package/icons/providers/amp.webp +0 -0
- package/icons/providers/anspire.webp +0 -0
- package/icons/providers/antgroup.webp +0 -0
- package/icons/providers/anthropic.webp +0 -0
- package/icons/providers/antigravity.webp +0 -0
- package/icons/providers/anyscale.webp +0 -0
- package/icons/providers/apertis.webp +0 -0
- package/icons/providers/apple.webp +0 -0
- package/icons/providers/appwrite.webp +0 -0
- package/icons/providers/arcee.webp +0 -0
- package/icons/providers/askverdict.webp +0 -0
- package/icons/providers/assemblyai.webp +0 -0
- package/icons/providers/atlascloud.webp +0 -0
- package/icons/providers/automatic.webp +0 -0
- package/icons/providers/aws-bedrock.webp +0 -0
- package/icons/providers/aws.webp +0 -0
- package/icons/providers/aya.webp +0 -0
- package/icons/providers/azure.webp +0 -0
- package/icons/providers/azureai.webp +0 -0
- package/icons/providers/baai.webp +0 -0
- package/icons/providers/baichuan.webp +0 -0
- package/icons/providers/baidu-cloud.webp +0 -0
- package/icons/providers/baidu.webp +0 -0
- package/icons/providers/baiducloud.webp +0 -0
- package/icons/providers/bailian.webp +0 -0
- package/icons/providers/baseten.webp +0 -0
- package/icons/providers/bedrock.webp +0 -0
- package/icons/providers/bfl.webp +0 -0
- package/icons/providers/bigModel.webp +0 -0
- package/icons/providers/bilibili.webp +0 -0
- package/icons/providers/bilibiliindex.webp +0 -0
- package/icons/providers/bing.webp +0 -0
- package/icons/providers/bocha.webp +0 -0
- package/icons/providers/brave.webp +0 -0
- package/icons/providers/briaai.webp +0 -0
- package/icons/providers/browserless.webp +0 -0
- package/icons/providers/burncloud.webp +0 -0
- package/icons/providers/bytedance.webp +0 -0
- package/icons/providers/capcut.webp +0 -0
- package/icons/providers/celestoai.webp +0 -0
- package/icons/providers/centml.webp +0 -0
- package/icons/providers/cerebras.webp +0 -0
- package/icons/providers/chatglm.webp +0 -0
- package/icons/providers/cheaperinference.webp +0 -0
- package/icons/providers/cherrystudio.webp +0 -0
- package/icons/providers/chutes.webp +0 -0
- package/icons/providers/civitai.webp +0 -0
- package/icons/providers/claude.webp +0 -0
- package/icons/providers/claudecode.webp +0 -0
- package/icons/providers/cline.webp +0 -0
- package/icons/providers/clipdrop.webp +0 -0
- package/icons/providers/cloudflare.webp +0 -0
- package/icons/providers/codebuddy.webp +0 -0
- package/icons/providers/codeflicker.webp +0 -0
- package/icons/providers/codegeex.webp +0 -0
- package/icons/providers/codex.webp +0 -0
- package/icons/providers/cogvideo.webp +0 -0
- package/icons/providers/cogview.webp +0 -0
- package/icons/providers/cogview3flash.webp +0 -0
- package/icons/providers/cohere.webp +0 -0
- package/icons/providers/colab.webp +0 -0
- package/icons/providers/cometapi.webp +0 -0
- package/icons/providers/comfyui.webp +0 -0
- package/icons/providers/commanda.webp +0 -0
- package/icons/providers/commandcode.webp +0 -0
- package/icons/providers/copilot.webp +0 -0
- package/icons/providers/copilotkit.webp +0 -0
- package/icons/providers/coqui.webp +0 -0
- package/icons/providers/coze.webp +0 -0
- package/icons/providers/crewai.webp +0 -0
- package/icons/providers/crusoe.webp +0 -0
- package/icons/providers/cursor.webp +0 -0
- package/icons/providers/cybercut.webp +0 -0
- package/icons/providers/dalle.webp +0 -0
- package/icons/providers/dbrx.webp +0 -0
- package/icons/providers/decart.webp +0 -0
- package/icons/providers/deepai.webp +0 -0
- package/icons/providers/deepcogito.webp +0 -0
- package/icons/providers/deepinfra.webp +0 -0
- package/icons/providers/deepl.webp +0 -0
- package/icons/providers/deepmind.webp +0 -0
- package/icons/providers/deepseek.webp +0 -0
- package/icons/providers/devin.webp +0 -0
- package/icons/providers/dify.webp +0 -0
- package/icons/providers/digitalocean.webp +0 -0
- package/icons/providers/doc2x.webp +0 -0
- package/icons/providers/docsearch.webp +0 -0
- package/icons/providers/dolphin.webp +0 -0
- package/icons/providers/dothoosh.webp +0 -0
- package/icons/providers/dotsstudio.webp +0 -0
- package/icons/providers/doubao.webp +0 -0
- package/icons/providers/dreammachine.webp +0 -0
- package/icons/providers/elevenlabs.webp +0 -0
- package/icons/providers/elevenx.webp +0 -0
- package/icons/providers/empiriolabs.webp +0 -0
- package/icons/providers/essentialai.webp +0 -0
- package/icons/providers/exa.webp +0 -0
- package/icons/providers/fal.webp +0 -0
- package/icons/providers/fastgpt.webp +0 -0
- package/icons/providers/featherless.webp +0 -0
- package/icons/providers/figma.webp +0 -0
- package/icons/providers/firecrawl.webp +0 -0
- package/icons/providers/fireworks.webp +0 -0
- package/icons/providers/fishaudio.webp +0 -0
- package/icons/providers/flexai.webp +0 -0
- package/icons/providers/flora.webp +0 -0
- package/icons/providers/flowith.webp +0 -0
- package/icons/providers/flux.webp +0 -0
- package/icons/providers/friendli.webp +0 -0
- package/icons/providers/gemini.webp +0 -0
- package/icons/providers/geminicli.webp +0 -0
- package/icons/providers/gemma.webp +0 -0
- package/icons/providers/gitee-ai.webp +0 -0
- package/icons/providers/giteeai.webp +0 -0
- package/icons/providers/github.webp +0 -0
- package/icons/providers/githubcopilot.webp +0 -0
- package/icons/providers/glama.webp +0 -0
- package/icons/providers/glif.webp +0 -0
- package/icons/providers/glmv.webp +0 -0
- package/icons/providers/gmi.svg +5 -0
- package/icons/providers/gmicloud.webp +0 -0
- package/icons/providers/google.webp +0 -0
- package/icons/providers/googlecloud.webp +0 -0
- package/icons/providers/goose.webp +0 -0
- package/icons/providers/gradio.webp +0 -0
- package/icons/providers/greenpt.webp +0 -0
- package/icons/providers/greptile.webp +0 -0
- package/icons/providers/grok.webp +0 -0
- package/icons/providers/grokbot.webp +0 -0
- package/icons/providers/groq.webp +0 -0
- package/icons/providers/hailuo.webp +0 -0
- package/icons/providers/haiper.webp +0 -0
- package/icons/providers/happyhorse.webp +0 -0
- package/icons/providers/hedra.webp +0 -0
- package/icons/providers/hermesagent.webp +0 -0
- package/icons/providers/higress.webp +0 -0
- package/icons/providers/huawei.webp +0 -0
- package/icons/providers/huaweicloud.webp +0 -0
- package/icons/providers/huggingface.webp +0 -0
- package/icons/providers/hunyuan.webp +0 -0
- package/icons/providers/hyperbolic.webp +0 -0
- package/icons/providers/ibm.webp +0 -0
- package/icons/providers/ideogram.webp +0 -0
- package/icons/providers/iflytekcloud.webp +0 -0
- package/icons/providers/inception.webp +0 -0
- package/icons/providers/inceptron.webp +0 -0
- package/icons/providers/inference.webp +0 -0
- package/icons/providers/infermatic.webp +0 -0
- package/icons/providers/infini.webp +0 -0
- package/icons/providers/infinigence.webp +0 -0
- package/icons/providers/inflection.webp +0 -0
- package/icons/providers/internlm.webp +0 -0
- package/icons/providers/ionet.webp +0 -0
- package/icons/providers/jimeng.webp +0 -0
- package/icons/providers/jina.webp +0 -0
- package/icons/providers/junie.webp +0 -0
- package/icons/providers/kagi.webp +0 -0
- package/icons/providers/kilocode.webp +0 -0
- package/icons/providers/kimi.webp +0 -0
- package/icons/providers/kiro.webp +0 -0
- package/icons/providers/kling.webp +0 -0
- package/icons/providers/kluster.webp +0 -0
- package/icons/providers/kolors.webp +0 -0
- package/icons/providers/krea.webp +0 -0
- package/icons/providers/kwaikat.webp +0 -0
- package/icons/providers/kwaipilot.webp +0 -0
- package/icons/providers/lambda.webp +0 -0
- package/icons/providers/langchain.webp +0 -0
- package/icons/providers/langfuse.webp +0 -0
- package/icons/providers/langgraph.webp +0 -0
- package/icons/providers/langsmith.webp +0 -0
- package/icons/providers/leptonai.webp +0 -0
- package/icons/providers/lg.webp +0 -0
- package/icons/providers/lightricks.webp +0 -0
- package/icons/providers/ling.webp +0 -0
- package/icons/providers/liquid.webp +0 -0
- package/icons/providers/livekit.webp +0 -0
- package/icons/providers/llamaindex.webp +0 -0
- package/icons/providers/llava.webp +0 -0
- package/icons/providers/llmapi.webp +0 -0
- package/icons/providers/llmgateway.webp +0 -0
- package/icons/providers/lmstudio.webp +0 -0
- package/icons/providers/lobehub.webp +0 -0
- package/icons/providers/lobot.webp +0 -0
- package/icons/providers/longcat.webp +0 -0
- package/icons/providers/lovable.webp +0 -0
- package/icons/providers/lovart.webp +0 -0
- package/icons/providers/luma.webp +0 -0
- package/icons/providers/magic.webp +0 -0
- package/icons/providers/magpie.webp +0 -0
- package/icons/providers/make.webp +0 -0
- package/icons/providers/manus.webp +0 -0
- package/icons/providers/mastra.webp +0 -0
- package/icons/providers/mcp.webp +0 -0
- package/icons/providers/mcpso.webp +0 -0
- package/icons/providers/menlo.webp +0 -0
- package/icons/providers/meshy.webp +0 -0
- package/icons/providers/meta.webp +0 -0
- package/icons/providers/metaai.webp +0 -0
- package/icons/providers/metagpt.webp +0 -0
- package/icons/providers/microsoft.webp +0 -0
- package/icons/providers/midjourney.webp +0 -0
- package/icons/providers/minimax.webp +0 -0
- package/icons/providers/mistral.webp +0 -0
- package/icons/providers/modelscope.webp +0 -0
- package/icons/providers/monica.webp +0 -0
- package/icons/providers/moonshot.webp +0 -0
- package/icons/providers/morph.webp +0 -0
- package/icons/providers/moxt.webp +0 -0
- package/icons/providers/muse.webp +0 -0
- package/icons/providers/myshell.webp +0 -0
- package/icons/providers/n8n.webp +0 -0
- package/icons/providers/nanobanana.webp +0 -0
- package/icons/providers/nebius.webp +0 -0
- package/icons/providers/newapi.webp +0 -0
- package/icons/providers/nextbit.webp +0 -0
- package/icons/providers/notebooklm.webp +0 -0
- package/icons/providers/notion.webp +0 -0
- package/icons/providers/nousresearch.webp +0 -0
- package/icons/providers/nova.webp +0 -0
- package/icons/providers/novelai.webp +0 -0
- package/icons/providers/novita.webp +0 -0
- package/icons/providers/nplcloud.webp +0 -0
- package/icons/providers/nvidia.webp +0 -0
- package/icons/providers/o3.webp +0 -0
- package/icons/providers/obsidian.webp +0 -0
- package/icons/providers/ollama.webp +0 -0
- package/icons/providers/omlx.webp +0 -0
- package/icons/providers/openai.webp +0 -0
- package/icons/providers/openchat.webp +0 -0
- package/icons/providers/openclaw.webp +0 -0
- package/icons/providers/opencode.webp +0 -0
- package/icons/providers/openhands.webp +0 -0
- package/icons/providers/openhuman.webp +0 -0
- package/icons/providers/openrouter.webp +0 -0
- package/icons/providers/openwebui.webp +0 -0
- package/icons/providers/paddleocr.webp +0 -0
- package/icons/providers/palm.webp +0 -0
- package/icons/providers/parasail.webp +0 -0
- package/icons/providers/perceptron.webp +0 -0
- package/icons/providers/perplexity.webp +0 -0
- package/icons/providers/phala.webp +0 -0
- package/icons/providers/phidata.webp +0 -0
- package/icons/providers/phind.webp +0 -0
- package/icons/providers/pi.webp +0 -0
- package/icons/providers/pika.webp +0 -0
- package/icons/providers/pixverse.webp +0 -0
- package/icons/providers/player2.webp +0 -0
- package/icons/providers/poe.webp +0 -0
- package/icons/providers/pollinations.webp +0 -0
- package/icons/providers/poolside.webp +0 -0
- package/icons/providers/ppio.webp +0 -0
- package/icons/providers/prunaai.webp +0 -0
- package/icons/providers/pydanticai.webp +0 -0
- package/icons/providers/qingyan.webp +0 -0
- package/icons/providers/qiniu.webp +0 -0
- package/icons/providers/qoder.webp +0 -0
- package/icons/providers/qwen.webp +0 -0
- package/icons/providers/railway.webp +0 -0
- package/icons/providers/recraft.webp +0 -0
- package/icons/providers/reflection.webp +0 -0
- package/icons/providers/reka.webp +0 -0
- package/icons/providers/relace.webp +0 -0
- package/icons/providers/replicate.webp +0 -0
- package/icons/providers/replit.webp +0 -0
- package/icons/providers/reve.webp +0 -0
- package/icons/providers/roocode.webp +0 -0
- package/icons/providers/rsshub.webp +0 -0
- package/icons/providers/runway.webp +0 -0
- package/icons/providers/rwkv.webp +0 -0
- package/icons/providers/sakana.webp +0 -0
- package/icons/providers/sambanova.webp +0 -0
- package/icons/providers/search1api.webp +0 -0
- package/icons/providers/searchapi.webp +0 -0
- package/icons/providers/searxng.webp +0 -0
- package/icons/providers/sensenova.webp +0 -0
- package/icons/providers/silicon.webp +0 -0
- package/icons/providers/siliconcloud.webp +0 -0
- package/icons/providers/sillytavern.webp +0 -0
- package/icons/providers/skywork.webp +0 -0
- package/icons/providers/slock.webp +0 -0
- package/icons/providers/smithery.webp +0 -0
- package/icons/providers/snowflake.webp +0 -0
- package/icons/providers/sophnet.webp +0 -0
- package/icons/providers/sora.webp +0 -0
- package/icons/providers/spark.webp +0 -0
- package/icons/providers/speedai.webp +0 -0
- package/icons/providers/stability.webp +0 -0
- package/icons/providers/statecloud.webp +0 -0
- package/icons/providers/step.webp +0 -0
- package/icons/providers/stepfun.webp +0 -0
- package/icons/providers/straico.webp +0 -0
- package/icons/providers/streamlake.webp +0 -0
- package/icons/providers/sub2api.webp +0 -0
- package/icons/providers/submodel.webp +0 -0
- package/icons/providers/suno.webp +0 -0
- package/icons/providers/sync.webp +0 -0
- package/icons/providers/tabbit.webp +0 -0
- package/icons/providers/targon.webp +0 -0
- package/icons/providers/tavily.webp +0 -0
- package/icons/providers/tencent-cloud-ti.webp +0 -0
- package/icons/providers/tencent.webp +0 -0
- package/icons/providers/tencentcloud.webp +0 -0
- package/icons/providers/tiangong.webp +0 -0
- package/icons/providers/tii.webp +0 -0
- package/icons/providers/together.webp +0 -0
- package/icons/providers/topazlabs.webp +0 -0
- package/icons/providers/trae.webp +0 -0
- package/icons/providers/tripo.webp +0 -0
- package/icons/providers/turix.webp +0 -0
- package/icons/providers/typesafeai.webp +0 -0
- package/icons/providers/udio.webp +0 -0
- package/icons/providers/unionalpha.webp +0 -0
- package/icons/providers/unsloth.webp +0 -0
- package/icons/providers/unstructured.webp +0 -0
- package/icons/providers/upstage.webp +0 -0
- package/icons/providers/v0.webp +0 -0
- package/icons/providers/vectorizerai.webp +0 -0
- package/icons/providers/venice.webp +0 -0
- package/icons/providers/vercel.webp +0 -0
- package/icons/providers/vertexai.webp +0 -0
- package/icons/providers/vidu.webp +0 -0
- package/icons/providers/viggle.webp +0 -0
- package/icons/providers/vllm.webp +0 -0
- package/icons/providers/volcengine.webp +0 -0
- package/icons/providers/voyage.webp +0 -0
- package/icons/providers/voyageai.webp +0 -0
- package/icons/providers/wafer.webp +0 -0
- package/icons/providers/wandb.webp +0 -0
- package/icons/providers/wavespeed.webp +0 -0
- package/icons/providers/wenxin.webp +0 -0
- package/icons/providers/windsurf.webp +0 -0
- package/icons/providers/workbuddy.webp +0 -0
- package/icons/providers/workersai.webp +0 -0
- package/icons/providers/worldrouter.webp +0 -0
- package/icons/providers/xai.webp +0 -0
- package/icons/providers/xiaomimimo.webp +0 -0
- package/icons/providers/xinference.webp +0 -0
- package/icons/providers/xpay.webp +0 -0
- package/icons/providers/xuanyuan.webp +0 -0
- package/icons/providers/yandex.webp +0 -0
- package/icons/providers/yi.webp +0 -0
- package/icons/providers/youmind.webp +0 -0
- package/icons/providers/yuanbao.webp +0 -0
- package/icons/providers/zai.webp +0 -0
- package/icons/providers/zapier.webp +0 -0
- package/icons/providers/zeabur.webp +0 -0
- package/icons/providers/zencoder.webp +0 -0
- package/icons/providers/zenmux.webp +0 -0
- package/icons/providers/zero-one.webp +0 -0
- package/icons/providers/zeroone.webp +0 -0
- package/icons/providers/zhipu.webp +0 -0
- package/licenses/beautiful-ui-MIT.txt +21 -0
- package/package.json +53 -10
- package/scripts/yunui-audit.mjs +664 -0
- package/scripts/yunui-cli.mjs +868 -0
- package/scripts/yunui-init.mjs +138 -0
- package/styles/content.css +37 -3
- package/styles/tokens.css +41 -0
- package/styles/yunui.css +1586 -141
- package/dist/chunk-BCOKFWXC.js.map +0 -1
- package/dist/chunk-DDUP7GAX.js +0 -86
- package/dist/chunk-DDUP7GAX.js.map +0 -1
- package/dist/chunk-F2HG4TOQ.js.map +0 -1
- package/dist/chunk-HH3JBHRP.js +0 -1211
- package/dist/chunk-HH3JBHRP.js.map +0 -1
- package/dist/chunk-N4QO7RN5.js +0 -98
- package/dist/chunk-N4QO7RN5.js.map +0 -1
- package/dist/chunk-QEIBYOG2.js +0 -188
- package/dist/chunk-QEIBYOG2.js.map +0 -1
- package/dist/footer-BoFu7Wqq.d.ts +0 -46
- package/icons/apps/ling.png +0 -0
- package/icons/models/ling.png +0 -0
- package/icons/providers/Kwaipilot.png +0 -0
package/dist/ai.js
CHANGED
|
@@ -1,264 +1,608 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
2
|
+
export { DiscordIcon, Footer, GithubIcon, InstagramIcon, Navbar } from './chunk-YKUQ7GCJ.js';
|
|
3
|
+
import { TextShimmer } from './chunk-ASPPAL7E.js';
|
|
4
|
+
import { Button, RadioGroup, RadioGroupItem, Checkbox, Badge } from './chunk-I2DAKAD5.js';
|
|
5
|
+
export { LanguageSwitcher } from './chunk-VYVFMNM7.js';
|
|
6
|
+
import { mergeLabels } from './chunk-GRUB2GXF.js';
|
|
7
|
+
import { useDismissOnOutside, FloatingPanel } from './chunk-Z6WXDNBJ.js';
|
|
8
|
+
import { ProviderIcon } from './chunk-ZBRV6NHL.js';
|
|
9
|
+
export { CapabilitySelector, PROVIDER_ICON_SLUGS, ProviderAvatar, ProviderIcon, ProviderNames, getDeveloperIconPath, getIconPath, getProviderIconOptions, normalizeProviderId } from './chunk-ZBRV6NHL.js';
|
|
10
|
+
import { cn } from './chunk-VSS7ASN2.js';
|
|
11
|
+
import { useYunUI } from './chunk-GWD5W5F5.js';
|
|
12
|
+
import { useState, useId, useRef, useEffect, useCallback, useMemo, Children, isValidElement, Fragment as Fragment$1, useLayoutEffect } from 'react';
|
|
13
|
+
import { Sparkles, ChevronDown, X, ArrowRight, Check, CircleAlert, Clock3, Loader2, RefreshCw, ArrowUp, ChevronRight, Bot, CircleUserRound, LogOut, RotateCcw, FileText, Terminal, Pencil, Wrench, Image, Globe, Search, CircleHelp, Scissors, ThumbsUp, Type, Radio, Box, Shield, Shuffle, Music, Video, Mic, Volume2, Headphones, Palette, Hash, MessageSquare, Ban, ShieldQuestion, Copy } from 'lucide-react';
|
|
10
14
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
11
15
|
import { cva } from 'class-variance-authority';
|
|
12
16
|
|
|
13
|
-
function ThinkingBlock({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
function ThinkingBlock({
|
|
18
|
+
content,
|
|
19
|
+
isStreaming = false,
|
|
20
|
+
doneLabel,
|
|
21
|
+
defaultOpen = false,
|
|
22
|
+
open,
|
|
23
|
+
onOpenChange,
|
|
24
|
+
steps = [],
|
|
25
|
+
selectedStepId,
|
|
26
|
+
onStepSelect,
|
|
27
|
+
labels,
|
|
28
|
+
renderContent
|
|
29
|
+
}) {
|
|
30
|
+
const translate = useYunUI().useT("common.thinking");
|
|
31
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
32
|
+
const contentId = `${useId()}-thinking-content`;
|
|
33
|
+
const controlled = open !== void 0;
|
|
34
|
+
const isOpen = controlled ? open : internalOpen;
|
|
35
|
+
const canToggle = !controlled || Boolean(onOpenChange);
|
|
36
|
+
const fallback = (key, value) => {
|
|
37
|
+
try {
|
|
38
|
+
const translated = translate(key);
|
|
39
|
+
return translated && translated !== key && !translated.endsWith(`.${key}`) ? translated : value;
|
|
40
|
+
} catch {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const copy = {
|
|
45
|
+
title: labels?.title ?? fallback("label", "Thinking"),
|
|
46
|
+
active: labels?.active ?? fallback("active", "Thinking"),
|
|
47
|
+
inProgress: labels?.inProgress ?? fallback("inProgress", "In progress"),
|
|
48
|
+
completed: labels?.completed ?? fallback("completed", "Completed"),
|
|
49
|
+
failed: labels?.failed ?? fallback("failed", "Failed"),
|
|
50
|
+
cancelled: labels?.cancelled ?? fallback("cancelled", "Cancelled"),
|
|
51
|
+
pending: labels?.pending ?? fallback("pending", "Pending")
|
|
52
|
+
};
|
|
53
|
+
const wasStreaming = useRef(isStreaming);
|
|
54
|
+
const [justFinished, setJustFinished] = useState(false);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (wasStreaming.current && !isStreaming) setJustFinished(true);
|
|
57
|
+
if (isStreaming) setJustFinished(false);
|
|
58
|
+
wasStreaming.current = isStreaming;
|
|
59
|
+
}, [isStreaming]);
|
|
60
|
+
const requestOpen = () => {
|
|
61
|
+
if (!canToggle) return;
|
|
62
|
+
const next = !isOpen;
|
|
63
|
+
if (!controlled) setInternalOpen(next);
|
|
64
|
+
onOpenChange?.(next);
|
|
65
|
+
};
|
|
66
|
+
const statusLabel = (status) => ({
|
|
67
|
+
pending: copy.pending,
|
|
68
|
+
running: copy.active,
|
|
69
|
+
done: copy.completed,
|
|
70
|
+
failed: copy.failed,
|
|
71
|
+
cancelled: copy.cancelled
|
|
72
|
+
})[status];
|
|
73
|
+
const statusIcon2 = (status) => {
|
|
74
|
+
const common = "h-3.5 w-3.5 shrink-0";
|
|
75
|
+
switch (status) {
|
|
76
|
+
case "running":
|
|
77
|
+
return /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: cn(common, "motion-safe:animate-spin text-primary") });
|
|
78
|
+
case "done":
|
|
79
|
+
return /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: cn(common, "text-(--success)") });
|
|
80
|
+
case "failed":
|
|
81
|
+
return /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, className: cn(common, "text-(--error)") });
|
|
82
|
+
case "cancelled":
|
|
83
|
+
return /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: cn(common, "text-muted-foreground") });
|
|
84
|
+
default:
|
|
85
|
+
return /* @__PURE__ */ jsx(Clock3, { "aria-hidden": true, className: cn(common, "text-muted-foreground/60") });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return /* @__PURE__ */ jsxs("section", { className: "@container/think my-2 w-full min-w-0", "data-yunui": "thinking-block", children: [
|
|
17
89
|
/* @__PURE__ */ jsxs(
|
|
18
90
|
"button",
|
|
19
91
|
{
|
|
20
|
-
|
|
92
|
+
type: "button",
|
|
93
|
+
onClick: requestOpen,
|
|
94
|
+
disabled: !canToggle,
|
|
21
95
|
"aria-expanded": isOpen,
|
|
22
|
-
|
|
96
|
+
"aria-controls": contentId,
|
|
97
|
+
"aria-label": doneLabel && !isStreaming ? `${copy.title}: ${doneLabel}` : void 0,
|
|
98
|
+
className: "group flex min-h-8 w-fit max-w-full items-center gap-2 rounded-md px-1.5 text-left text-[13px] text-muted-foreground transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
|
|
23
99
|
children: [
|
|
24
|
-
/* @__PURE__ */ jsx("
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium whitespace-nowrap", children: t("label") }),
|
|
29
|
-
isStreaming && /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider font-semibold text-primary bg-primary/10 px-1.5 py-0.5 rounded whitespace-nowrap", children: t("active") }),
|
|
30
|
-
/* @__PURE__ */ jsx("div", { className: "ml-auto", children: isOpen ? /* @__PURE__ */ jsx(ChevronUp, { size: 14, className: "text-muted-foreground/70" }) : /* @__PURE__ */ jsx(ChevronDown, { size: 14, className: "text-muted-foreground/70" }) })
|
|
100
|
+
/* @__PURE__ */ jsx(Sparkles, { "aria-hidden": true, className: cn("h-3.5 w-3.5 shrink-0", isStreaming ? "text-primary" : "text-muted-foreground") }),
|
|
101
|
+
isStreaming ? /* @__PURE__ */ jsx(TextShimmer, { text: copy.title, role: "status", className: "min-w-0 truncate font-medium text-foreground" }) : /* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate font-medium text-foreground", justFinished && "yunui-swap-in"), children: doneLabel ?? copy.title }, doneLabel ?? copy.title),
|
|
102
|
+
isStreaming ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-1.5 w-1.5 shrink-0 rounded-full bg-primary motion-safe:animate-pulse" }) : null,
|
|
103
|
+
/* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn("h-3.5 w-3.5 shrink-0 transition-transform motion-reduce:transition-none", isOpen && "rotate-180") })
|
|
31
104
|
]
|
|
32
105
|
}
|
|
33
106
|
),
|
|
34
|
-
/* @__PURE__ */ jsx(
|
|
35
|
-
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
"div",
|
|
36
109
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
110
|
+
id: contentId,
|
|
111
|
+
"aria-hidden": !isOpen,
|
|
112
|
+
inert: !isOpen,
|
|
113
|
+
"data-open": isOpen,
|
|
114
|
+
className: "yunui-disclosure min-w-0",
|
|
115
|
+
children: /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: steps.length ? /* @__PURE__ */ jsx("ol", { "aria-label": copy.title, className: "ml-2 mt-1 flex min-w-0 flex-col gap-0.5 border-l border-border/70 py-1 pl-3", children: steps.map((step) => {
|
|
116
|
+
const contentNode = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
117
|
+
statusIcon2(step.status),
|
|
118
|
+
/* @__PURE__ */ jsx("span", { className: cn("min-w-0 text-left text-[12.5px] text-foreground", step.mono && "font-mono text-xs"), children: step.label }),
|
|
119
|
+
step.meta != null ? /* @__PURE__ */ jsx("span", { "data-yunui": "thinking-block-step-meta", className: "col-start-2 min-w-0 break-words text-[11px] tabular-nums text-muted-foreground @min-[360px]/think:col-start-3 @min-[360px]/think:max-w-[10rem] @min-[360px]/think:text-right", children: step.meta }) : null,
|
|
120
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: statusLabel(step.status) })
|
|
121
|
+
] });
|
|
122
|
+
return /* @__PURE__ */ jsxs("li", { "data-yunui": "thinking-block-step", className: "min-w-0", children: [
|
|
123
|
+
onStepSelect ? /* @__PURE__ */ jsx(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
"aria-pressed": selectedStepId === step.id,
|
|
128
|
+
onClick: () => onStepSelect(step.id),
|
|
129
|
+
className: cn("grid min-h-8 w-full min-w-0 grid-cols-[0.875rem_minmax(0,1fr)] items-center gap-x-2 gap-y-0.5 rounded-sm px-1.5 text-left transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring @min-[360px]/think:grid-cols-[0.875rem_minmax(0,1fr)_auto]", selectedStepId === step.id && "bg-muted/60"),
|
|
130
|
+
children: contentNode
|
|
131
|
+
}
|
|
132
|
+
) : /* @__PURE__ */ jsx("div", { className: "grid min-h-8 min-w-0 grid-cols-[0.875rem_minmax(0,1fr)] items-center gap-x-2 gap-y-0.5 px-1.5 @min-[360px]/think:grid-cols-[0.875rem_minmax(0,1fr)_auto]", children: contentNode }),
|
|
133
|
+
step.detail != null ? /* @__PURE__ */ jsx("div", { "data-yunui": "thinking-block-step-detail", className: "ml-5 border-l border-border/70 py-1 pl-2.5 text-xs leading-relaxed text-muted-foreground", children: step.detail }) : null
|
|
134
|
+
] }, step.id);
|
|
135
|
+
}) }) : content ? /* @__PURE__ */ jsxs("div", { className: "ml-2 mt-1 border-l border-border/70 py-1 pl-3 pr-2 text-[13px] leading-relaxed text-muted-foreground", children: [
|
|
42
136
|
renderContent ? renderContent(content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: content }),
|
|
43
|
-
isStreaming
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
animate: { opacity: [0.4, 1, 0.4] },
|
|
47
|
-
transition: { duration: 1.2, repeat: Infinity },
|
|
48
|
-
className: "inline-block w-1 h-3 bg-muted-foreground/60 ml-0.5 align-middle"
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
] }) : /* @__PURE__ */ jsx("span", { className: "italic opacity-50", children: t("inProgress") }) })
|
|
137
|
+
isStreaming ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "ml-1 inline-block h-3 w-1 animate-pulse bg-muted-foreground/70 align-middle motion-reduce:animate-none" }) : null
|
|
138
|
+
] }) : isStreaming ? /* @__PURE__ */ jsx("p", { className: "ml-2 mt-1 border-l border-border/70 py-1 pl-3 text-[12px] text-muted-foreground", children: copy.inProgress }) : null })
|
|
52
139
|
}
|
|
53
|
-
)
|
|
140
|
+
)
|
|
54
141
|
] });
|
|
55
142
|
}
|
|
143
|
+
function domIdPart(value) {
|
|
144
|
+
return Array.from(value, (character) => character.codePointAt(0)?.toString(16) ?? "0").join("-") || "empty";
|
|
145
|
+
}
|
|
56
146
|
var ICONS = {
|
|
57
147
|
terminal: Terminal,
|
|
58
148
|
search: Search,
|
|
59
149
|
globe: Globe,
|
|
60
150
|
image: Image,
|
|
61
151
|
file: FileText,
|
|
62
|
-
tool: Wrench
|
|
152
|
+
tool: Wrench,
|
|
153
|
+
think: Sparkles,
|
|
154
|
+
write: Pencil,
|
|
155
|
+
run: Terminal,
|
|
156
|
+
read: FileText
|
|
63
157
|
};
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
children
|
|
77
|
-
}
|
|
78
|
-
),
|
|
79
|
-
!isLast && /* @__PURE__ */ jsx("span", { className: "my-1 w-0.5 flex-1 rounded-full bg-border" })
|
|
80
|
-
] });
|
|
158
|
+
function useDisclosure({ id, open: controlledOpen, defaultOpen = false, onToggleRow }) {
|
|
159
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
160
|
+
const controlled = controlledOpen !== void 0;
|
|
161
|
+
const open = controlled ? controlledOpen : internalOpen;
|
|
162
|
+
const canToggle = !controlled || Boolean(onToggleRow);
|
|
163
|
+
const toggle = () => {
|
|
164
|
+
if (!canToggle) return;
|
|
165
|
+
const next = !open;
|
|
166
|
+
if (!controlled) setInternalOpen(next);
|
|
167
|
+
onToggleRow?.(id, next);
|
|
168
|
+
};
|
|
169
|
+
return { open, canToggle, toggle };
|
|
81
170
|
}
|
|
82
|
-
function Collapse({ open, children }) {
|
|
171
|
+
function Collapse({ open, children, id }) {
|
|
83
172
|
return /* @__PURE__ */ jsx(
|
|
84
173
|
"div",
|
|
85
174
|
{
|
|
175
|
+
id,
|
|
176
|
+
"aria-hidden": !open,
|
|
177
|
+
inert: !open,
|
|
86
178
|
className: cn(
|
|
87
|
-
"grid transition-[grid-template-rows,opacity] duration-
|
|
179
|
+
"grid transition-[grid-template-rows,opacity] duration-(--dur-slow) ease-out motion-reduce:transition-none",
|
|
88
180
|
open ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
|
|
89
181
|
),
|
|
90
182
|
children: /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children })
|
|
91
183
|
}
|
|
92
184
|
);
|
|
93
185
|
}
|
|
94
|
-
function
|
|
95
|
-
return /* @__PURE__ */ jsx(
|
|
186
|
+
function statusIcon(status) {
|
|
187
|
+
if (status === "running") return /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 motion-safe:animate-spin text-primary" });
|
|
188
|
+
if (status === "done") return /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-(--success)" });
|
|
189
|
+
if (status === "error" || status === "failed") return /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-(--error)" });
|
|
190
|
+
if (status === "cancelled") return /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" });
|
|
191
|
+
return /* @__PURE__ */ jsx(Clock3, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground/60" });
|
|
192
|
+
}
|
|
193
|
+
function statusText(status, labels) {
|
|
194
|
+
if (status === "done") return labels.completed ?? "Completed";
|
|
195
|
+
if (status === "failed") return labels.failed ?? "Failed";
|
|
196
|
+
if (status === "cancelled") return labels.cancelled ?? "Cancelled";
|
|
197
|
+
if (status === "error") return labels.error ?? "Error";
|
|
198
|
+
if (status === "pending") return labels.pending ?? "Pending";
|
|
199
|
+
return labels.running ?? "Running";
|
|
96
200
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
201
|
+
function toneClass(tone) {
|
|
202
|
+
if (tone === "add") return "text-(--success)";
|
|
203
|
+
if (tone === "del") return "text-(--error)";
|
|
204
|
+
return "text-muted-foreground";
|
|
205
|
+
}
|
|
206
|
+
function ReasoningRow({ block, labels, onToggleRow, renderContent }) {
|
|
207
|
+
const instanceId = useId();
|
|
99
208
|
const expandable = Boolean(block.content.trim());
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"aria-hidden": "true",
|
|
106
|
-
className: "absolute h-4 w-4 animate-ping rounded-full bg-primary/15 motion-reduce:hidden"
|
|
107
|
-
}
|
|
108
|
-
) : null,
|
|
109
|
-
/* @__PURE__ */ jsx(
|
|
110
|
-
Brain,
|
|
111
|
-
{
|
|
112
|
-
size: 13,
|
|
113
|
-
strokeWidth: 1.75,
|
|
114
|
-
className: cn(block.active && "animate-pulse motion-reduce:animate-none")
|
|
115
|
-
}
|
|
116
|
-
)
|
|
117
|
-
] }) }),
|
|
118
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1 pb-2", children: /* @__PURE__ */ jsxs(
|
|
119
|
-
"div",
|
|
209
|
+
const disclosure = useDisclosure({ id: block.id, open: block.open, defaultOpen: block.defaultOpen, onToggleRow });
|
|
210
|
+
const title = `${instanceId}-reasoning-${domIdPart(block.id)}`;
|
|
211
|
+
return /* @__PURE__ */ jsxs("div", { "data-yunui": "agent-timeline-reasoning-disclosure", className: "min-w-0 py-1", children: [
|
|
212
|
+
/* @__PURE__ */ jsxs(
|
|
213
|
+
"button",
|
|
120
214
|
{
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
215
|
+
type: "button",
|
|
216
|
+
disabled: !expandable || !disclosure.canToggle,
|
|
217
|
+
"aria-expanded": expandable ? disclosure.open : void 0,
|
|
218
|
+
"aria-controls": expandable ? title : void 0,
|
|
219
|
+
onClick: disclosure.toggle,
|
|
220
|
+
className: "flex min-h-8 w-full items-center gap-2 rounded-lg px-2 text-left transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
|
|
126
221
|
children: [
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
onClick: () => expandable && setOpen(!open),
|
|
132
|
-
"aria-expanded": expandable ? open : void 0,
|
|
133
|
-
className: cn(
|
|
134
|
-
"flex h-[30px] w-full items-center gap-2 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
|
|
135
|
-
expandable ? "cursor-pointer rounded-none px-2.5 hover:bg-muted/40" : "cursor-default rounded-md px-1.5"
|
|
136
|
-
),
|
|
137
|
-
children: [
|
|
138
|
-
block.active ? /* @__PURE__ */ jsx(
|
|
139
|
-
TextShimmer,
|
|
140
|
-
{
|
|
141
|
-
text: block.label,
|
|
142
|
-
className: "min-w-0 flex-1 truncate text-[13px]",
|
|
143
|
-
"data-agent-timeline-active": "true"
|
|
144
|
-
}
|
|
145
|
-
) : /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-[13px] text-muted-foreground", children: block.label }),
|
|
146
|
-
expandable ? /* @__PURE__ */ jsx(Chevron, { open }) : null
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
),
|
|
150
|
-
expandable ? /* @__PURE__ */ jsx(Collapse, { open, children: /* @__PURE__ */ jsx(
|
|
151
|
-
"div",
|
|
152
|
-
{
|
|
153
|
-
"data-yunui": "agent-timeline-reasoning-content",
|
|
154
|
-
className: "border-t border-border/50 px-2.5 pb-2.5 pt-2 text-[12.5px] leading-relaxed text-muted-foreground",
|
|
155
|
-
children: renderContent ? renderContent(block.content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: block.content })
|
|
156
|
-
}
|
|
157
|
-
) }) : null
|
|
222
|
+
/* @__PURE__ */ jsx(Sparkles, { "aria-hidden": true, size: 14, className: cn("shrink-0", block.active ? "text-primary" : "text-muted-foreground") }),
|
|
223
|
+
block.active ? /* @__PURE__ */ jsx(TextShimmer, { text: block.label, active: true, "data-agent-timeline-active": "true", className: "min-w-0 flex-1 truncate text-[13px]" }) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[13px] text-foreground", children: block.label }),
|
|
224
|
+
block.active ? /* @__PURE__ */ jsx("span", { className: "sr-only", children: labels.running ?? "Running" }) : null,
|
|
225
|
+
expandable ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", disclosure.open && "rotate-180") }) : null
|
|
158
226
|
]
|
|
159
227
|
}
|
|
160
|
-
)
|
|
228
|
+
),
|
|
229
|
+
expandable ? /* @__PURE__ */ jsx(Collapse, { id: title, open: disclosure.open, children: /* @__PURE__ */ jsx("div", { "data-yunui": "agent-timeline-reasoning-content", className: "ml-8 border-l border-border pl-3 pr-2 py-2 text-sm leading-relaxed text-muted-foreground", children: renderContent ? renderContent(block.content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: block.content }) }) }) : null
|
|
161
230
|
] });
|
|
162
231
|
}
|
|
163
|
-
function ToolRow({ block,
|
|
164
|
-
const
|
|
232
|
+
function ToolRow({ block, labels, onToggleRow, onToggleDiff }) {
|
|
233
|
+
const instanceId = useId();
|
|
234
|
+
const expandable = Boolean(block.command || block.output || block.outputContent != null || block.details?.length || block.files?.length);
|
|
235
|
+
const disclosure = useDisclosure({ id: block.id, open: block.open, defaultOpen: block.defaultOpen, onToggleRow });
|
|
236
|
+
const [openDiff, setOpenDiff] = useState(null);
|
|
165
237
|
const Icon = ICONS[block.icon ?? "tool"];
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
className:
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
),
|
|
182
|
-
children:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
),
|
|
193
|
-
/* @__PURE__ */ jsx(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
"
|
|
200
|
-
{
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
238
|
+
const detailId = `${instanceId}-tool-${domIdPart(block.id)}`;
|
|
239
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("min-w-0", block.indent && "ml-5"), "data-yunui": "agent-tool-row", children: [
|
|
240
|
+
/* @__PURE__ */ jsxs(
|
|
241
|
+
"button",
|
|
242
|
+
{
|
|
243
|
+
type: "button",
|
|
244
|
+
disabled: !expandable || !disclosure.canToggle,
|
|
245
|
+
"aria-expanded": expandable ? disclosure.open : void 0,
|
|
246
|
+
"aria-controls": expandable ? detailId : void 0,
|
|
247
|
+
onClick: disclosure.toggle,
|
|
248
|
+
className: "group flex min-h-8 w-full min-w-0 items-center gap-2 rounded-lg px-2 text-left transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
|
|
249
|
+
children: [
|
|
250
|
+
/* @__PURE__ */ jsx(Icon, { "aria-hidden": true, size: 14, className: "shrink-0 text-muted-foreground" }),
|
|
251
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-[13px] font-medium text-foreground", children: block.verb }),
|
|
252
|
+
block.summary || block.command ? /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11.5px] text-muted-foreground", children: block.summary ?? block.command }) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
|
|
253
|
+
statusIcon(block.status),
|
|
254
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: statusText(block.status, labels) }),
|
|
255
|
+
expandable ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", disclosure.open && "rotate-180") }) : null
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
expandable ? /* @__PURE__ */ jsx(Collapse, { id: detailId, open: disclosure.open, children: /* @__PURE__ */ jsxs("div", { className: "ml-6 mr-2 mt-0.5 border-l border-border/70 py-1.5 pl-3", children: [
|
|
260
|
+
block.command ? /* @__PURE__ */ jsxs("div", { className: "mb-1.5 font-mono text-xs text-foreground/80", children: [
|
|
261
|
+
"$ ",
|
|
262
|
+
block.command
|
|
263
|
+
] }) : null,
|
|
264
|
+
block.outputContent != null ? /* @__PURE__ */ jsx("div", { role: "region", "aria-label": labels.toolOutput?.(block.verb) ?? `${block.verb} output`, className: "min-w-0", children: block.outputContent }) : block.output ? /* @__PURE__ */ jsx("pre", { role: "region", "aria-label": labels.toolOutput?.(block.verb) ?? `${block.verb} output`, tabIndex: 0, className: "max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-sm bg-muted/30 px-2 py-1.5 font-mono text-xs text-foreground/80", children: block.output }) : null,
|
|
265
|
+
block.details?.length ? /* @__PURE__ */ jsx("div", { className: "mt-2 flex flex-col gap-1", children: block.details.map((detail) => /* @__PURE__ */ jsx("div", { className: cn("flex items-baseline justify-between gap-3 text-xs", toneClass(detail.tone ?? "context"), detail.mono && "font-mono"), children: /* @__PURE__ */ jsx("span", { className: "min-w-0 whitespace-pre-wrap", children: detail.text }) }, detail.id)) }) : null,
|
|
266
|
+
block.files?.length ? /* @__PURE__ */ jsx("div", { className: "mt-2 flex flex-wrap gap-1.5", children: block.files.map((file, fileIndex) => {
|
|
267
|
+
const fileOpen = openDiff === file.id;
|
|
268
|
+
const canShowLines = Boolean(file.lines?.length || onToggleDiff);
|
|
269
|
+
const diffId = `${instanceId}-diff-${fileIndex}-${domIdPart(file.id)}`;
|
|
270
|
+
const chip = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
271
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: file.file }),
|
|
272
|
+
/* @__PURE__ */ jsxs("span", { className: "shrink-0 text-(--success) tabular-nums", children: [
|
|
273
|
+
"+",
|
|
274
|
+
file.additions
|
|
275
|
+
] }),
|
|
276
|
+
file.deletions ? /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-(--error) tabular-nums", children: [
|
|
277
|
+
"\u2212",
|
|
278
|
+
file.deletions
|
|
279
|
+
] }) : null
|
|
280
|
+
] });
|
|
281
|
+
return /* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
|
|
282
|
+
canShowLines ? /* @__PURE__ */ jsx("button", { type: "button", "aria-expanded": fileOpen, "aria-controls": file.lines?.length ? diffId : void 0, "aria-label": labels.showDiff?.(file.file) ?? `Show diff for ${file.file}`, onClick: () => {
|
|
283
|
+
const next = fileOpen ? null : file.id;
|
|
284
|
+
setOpenDiff(next);
|
|
285
|
+
onToggleDiff?.(file.id, next !== null);
|
|
286
|
+
}, className: "inline-flex max-w-full items-center gap-2 rounded-full bg-muted/50 px-2 py-1 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: chip }) : /* @__PURE__ */ jsx("span", { className: "inline-flex max-w-full items-center gap-2 rounded-full bg-muted/50 px-2 py-1 font-mono text-[11px] text-muted-foreground", children: chip }),
|
|
287
|
+
file.lines?.length ? /* @__PURE__ */ jsx(Collapse, { open: fileOpen, id: diffId, children: /* @__PURE__ */ jsx("pre", { className: "mt-1 max-h-48 overflow-auto rounded-sm bg-muted/30 p-2 font-mono text-[11px]", children: file.lines.map((line) => /* @__PURE__ */ jsxs("span", { className: cn("block whitespace-pre-wrap", toneClass(line.tone)), children: [
|
|
288
|
+
line.text,
|
|
289
|
+
"\n"
|
|
290
|
+
] }, line.id)) }) }) : null
|
|
291
|
+
] }, file.id);
|
|
292
|
+
}) }) : null
|
|
293
|
+
] }) }) : null
|
|
210
294
|
] });
|
|
211
295
|
}
|
|
212
|
-
function
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
296
|
+
function TaskRow({ block, labels, onToggleRow }) {
|
|
297
|
+
const instanceId = useId();
|
|
298
|
+
const expandable = Boolean(block.details?.length);
|
|
299
|
+
const disclosure = useDisclosure({ id: block.id, open: block.open, defaultOpen: block.defaultOpen, onToggleRow });
|
|
300
|
+
const detailId = `${instanceId}-task-${domIdPart(block.id)}`;
|
|
301
|
+
return /* @__PURE__ */ jsxs("div", { "data-yunui": "agent-task-row", className: "min-w-0", children: [
|
|
302
|
+
/* @__PURE__ */ jsxs(
|
|
303
|
+
"button",
|
|
304
|
+
{
|
|
305
|
+
type: "button",
|
|
306
|
+
disabled: !expandable || !disclosure.canToggle,
|
|
307
|
+
"aria-expanded": expandable ? disclosure.open : void 0,
|
|
308
|
+
"aria-controls": expandable ? detailId : void 0,
|
|
309
|
+
onClick: disclosure.toggle,
|
|
310
|
+
className: "flex min-h-10 w-full min-w-0 items-center gap-2.5 rounded-sm px-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
|
|
311
|
+
children: [
|
|
312
|
+
statusIcon(block.status),
|
|
313
|
+
block.status === "done" || block.status === "failed" || block.status === "cancelled" ? /* @__PURE__ */ jsx("span", { className: cn("shrink-0 text-[11px] font-medium", block.status === "done" ? "text-(--success)" : block.status === "failed" ? "text-(--error)" : "text-muted-foreground"), children: statusText(block.status, labels) }) : /* @__PURE__ */ jsx("span", { className: "sr-only", children: statusText(block.status, labels) }),
|
|
314
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[13px] font-medium text-foreground", children: block.label }),
|
|
315
|
+
block.amount != null ? /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: block.amount }) : null,
|
|
316
|
+
block.step !== void 0 && block.status === "running" ? /* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground", children: block.step }) : null,
|
|
317
|
+
expandable ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", disclosure.open && "rotate-180") }) : null
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
expandable ? /* @__PURE__ */ jsx(Collapse, { id: detailId, open: disclosure.open, children: /* @__PURE__ */ jsx("div", { className: "ml-5 border-l border-border/70 py-1.5 pl-3 pr-2", children: block.details?.map((detail) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 py-1 text-xs", children: [
|
|
322
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 text-muted-foreground", children: detail.label }),
|
|
323
|
+
detail.meta != null ? /* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono tabular-nums text-muted-foreground/80", children: detail.meta }) : null
|
|
324
|
+
] }, detail.id)) }) }) : null
|
|
325
|
+
] });
|
|
326
|
+
}
|
|
327
|
+
function ApprovalRow({ block, isLast, onApprove, onReject, labels }) {
|
|
328
|
+
return /* @__PURE__ */ jsxs("div", { className: "min-w-0 py-1.5", "data-yunui": "agent-approval-row", "data-last": isLast || void 0, "aria-busy": block.busy || void 0, children: [
|
|
329
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
330
|
+
/* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, size: 14, className: "shrink-0 text-muted-foreground" }),
|
|
331
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-[13px] font-medium text-foreground", children: block.title }),
|
|
332
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono text-[11px] text-muted-foreground", children: block.verb }),
|
|
333
|
+
block.decision ? /* @__PURE__ */ jsx(Badge, { variant: block.decision === "approved" ? "success" : "error", children: block.decidedLabel ?? block.decision }) : null
|
|
334
|
+
] }),
|
|
335
|
+
block.message != null ? /* @__PURE__ */ jsx("p", { className: "ml-6 mt-1 text-[12.5px] text-muted-foreground", children: block.message }) : null,
|
|
336
|
+
block.argsText ? /* @__PURE__ */ jsx("pre", { tabIndex: 0, role: "region", "aria-label": `${block.title}: ${block.verb}`, className: "ml-6 mt-1 max-h-40 overflow-auto whitespace-pre-wrap bg-muted/30 px-2 py-1.5 font-mono text-[11.5px] text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring", children: block.argsText }) : null,
|
|
337
|
+
!block.decision ? /* @__PURE__ */ jsxs("div", { className: "ml-6 mt-2 flex flex-wrap items-center gap-2", children: [
|
|
338
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "primary", disabled: block.disabled || block.busy || !onApprove, onClick: () => {
|
|
339
|
+
if (!block.disabled && !block.busy) onApprove?.(block.id);
|
|
340
|
+
}, children: block.allowLabel }),
|
|
341
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", disabled: block.disabled || block.busy || !onReject, onClick: () => {
|
|
342
|
+
if (!block.disabled && !block.busy) onReject?.(block.id);
|
|
343
|
+
}, children: block.denyLabel }),
|
|
344
|
+
block.busy ? /* @__PURE__ */ jsx("span", { role: "status", className: "text-xs text-muted-foreground", children: labels?.waitingForHost ?? "Waiting for host\u2026" }) : null
|
|
345
|
+
] }) : null
|
|
236
346
|
] });
|
|
237
347
|
}
|
|
238
|
-
function AgentTimeline({
|
|
239
|
-
|
|
348
|
+
function AgentTimeline({
|
|
349
|
+
blocks,
|
|
350
|
+
renderContent,
|
|
351
|
+
onApprove,
|
|
352
|
+
onReject,
|
|
353
|
+
labels,
|
|
354
|
+
open,
|
|
355
|
+
defaultOpen = true,
|
|
356
|
+
onOpenChange,
|
|
357
|
+
onToggleRow,
|
|
358
|
+
onToggleDiff,
|
|
359
|
+
className
|
|
360
|
+
}) {
|
|
361
|
+
const contentId = `${useId()}-timeline-content`;
|
|
362
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
363
|
+
const controlled = open !== void 0;
|
|
364
|
+
const isOpen = controlled ? open : internalOpen;
|
|
365
|
+
const canToggle = !controlled || Boolean(onOpenChange);
|
|
366
|
+
const visible = blocks.filter((block) => !(block.kind === "reasoning" && !block.content.trim() && !block.active));
|
|
240
367
|
if (!visible.length) return null;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
368
|
+
const counts = {
|
|
369
|
+
steps: visible.length,
|
|
370
|
+
reasoning: visible.filter((block) => block.kind === "reasoning").length,
|
|
371
|
+
tools: visible.filter((block) => block.kind === "tool").length,
|
|
372
|
+
tasks: visible.filter((block) => block.kind === "task").length,
|
|
373
|
+
approvals: visible.filter((block) => block.kind === "approval").length
|
|
374
|
+
};
|
|
375
|
+
const summary = labels?.summary?.(counts) ?? labels?.stepCount?.(counts.steps) ?? (counts.steps ? `${counts.steps} ${counts.steps === 1 ? "step" : "steps"}` : labels?.process ?? "Process");
|
|
376
|
+
const requestOpen = () => {
|
|
377
|
+
if (!canToggle) return;
|
|
378
|
+
const next = !isOpen;
|
|
379
|
+
if (!controlled) setInternalOpen(next);
|
|
380
|
+
onOpenChange?.(next);
|
|
381
|
+
};
|
|
382
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 flex-col", className), "data-yunui": "agent-timeline", children: [
|
|
383
|
+
/* @__PURE__ */ jsxs(
|
|
384
|
+
"button",
|
|
385
|
+
{
|
|
386
|
+
type: "button",
|
|
387
|
+
disabled: !canToggle,
|
|
388
|
+
"aria-expanded": isOpen,
|
|
389
|
+
"aria-controls": contentId,
|
|
390
|
+
onClick: requestOpen,
|
|
391
|
+
className: "flex min-h-8 w-fit max-w-full items-center gap-2 rounded-sm px-1.5 text-left text-[13px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
|
|
392
|
+
children: [
|
|
393
|
+
/* @__PURE__ */ jsx(Sparkles, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
394
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: summary }),
|
|
395
|
+
/* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", isOpen && "rotate-180") })
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
),
|
|
399
|
+
/* @__PURE__ */ jsx(Collapse, { open: isOpen, id: contentId, children: /* @__PURE__ */ jsx("div", { className: "mt-1 flex min-w-0 flex-col gap-0.5", children: visible.map((block, index) => {
|
|
400
|
+
if (block.kind === "reasoning") return /* @__PURE__ */ jsx(ReasoningRow, { block, labels: labels ?? {}, onToggleRow, renderContent }, block.id);
|
|
401
|
+
if (block.kind === "tool") return /* @__PURE__ */ jsx(ToolRow, { block, labels: labels ?? {}, onToggleRow, onToggleDiff }, block.id);
|
|
402
|
+
if (block.kind === "task") return /* @__PURE__ */ jsx(TaskRow, { block, labels: labels ?? {}, onToggleRow }, block.id);
|
|
403
|
+
return /* @__PURE__ */ jsx(ApprovalRow, { block, isLast: index === visible.length - 1, onApprove, onReject, labels }, block.id);
|
|
404
|
+
}) }) })
|
|
405
|
+
] });
|
|
406
|
+
}
|
|
407
|
+
var DEFAULT_LABELS = {
|
|
408
|
+
dismiss: "Dismiss questions",
|
|
409
|
+
back: "Back",
|
|
410
|
+
next: "Next",
|
|
411
|
+
skip: "Skip",
|
|
412
|
+
submit: "Submit answers",
|
|
413
|
+
submitting: "Submitting\u2026",
|
|
414
|
+
otherPlaceholder: "Something else\u2026"
|
|
415
|
+
};
|
|
416
|
+
function domPart(value) {
|
|
417
|
+
return Array.from(value, (character) => character.codePointAt(0)?.toString(16) ?? "0").join("-") || "empty";
|
|
418
|
+
}
|
|
419
|
+
function ApprovalQuestion({
|
|
420
|
+
questions,
|
|
421
|
+
activeQuestionId,
|
|
422
|
+
answers,
|
|
423
|
+
onAnswersChange,
|
|
424
|
+
onActiveQuestionChange,
|
|
425
|
+
onSkip,
|
|
426
|
+
onSubmit,
|
|
427
|
+
onDismiss,
|
|
428
|
+
submitting = false,
|
|
429
|
+
disabled = false,
|
|
430
|
+
labels,
|
|
431
|
+
className
|
|
432
|
+
}) {
|
|
433
|
+
const generatedId = useId();
|
|
434
|
+
const questionIndex = questions.findIndex((question2) => question2.id === activeQuestionId);
|
|
435
|
+
const question = questions[questionIndex];
|
|
436
|
+
if (!question) return null;
|
|
437
|
+
const copy = {
|
|
438
|
+
dismiss: labels?.dismiss ?? DEFAULT_LABELS.dismiss,
|
|
439
|
+
back: labels?.back ?? DEFAULT_LABELS.back,
|
|
440
|
+
next: labels?.next ?? DEFAULT_LABELS.next,
|
|
441
|
+
skip: labels?.skip ?? DEFAULT_LABELS.skip,
|
|
442
|
+
submit: labels?.submit ?? DEFAULT_LABELS.submit,
|
|
443
|
+
submitting: labels?.submitting ?? DEFAULT_LABELS.submitting,
|
|
444
|
+
otherPlaceholder: labels?.otherPlaceholder ?? DEFAULT_LABELS.otherPlaceholder
|
|
445
|
+
};
|
|
446
|
+
const answer = answers[question.id] ?? { optionIds: [] };
|
|
447
|
+
const hasSelection = answer.optionIds.some(
|
|
448
|
+
(id) => question.options.some((option) => option.id === id && !option.disabled)
|
|
449
|
+
);
|
|
450
|
+
const hasOtherText = Boolean(question.other && answer.optionIds.includes(question.other.id) && answer.otherText?.trim());
|
|
451
|
+
const canContinue = question.required === false || hasSelection || hasOtherText;
|
|
452
|
+
const isLast = questionIndex === questions.length - 1;
|
|
453
|
+
const updateAnswer = (next) => {
|
|
454
|
+
onAnswersChange({ ...answers, [question.id]: next });
|
|
455
|
+
};
|
|
456
|
+
const toggleOption = (optionId) => {
|
|
457
|
+
const option = question.options.find((item) => item.id === optionId);
|
|
458
|
+
const isOtherOption = question.other?.id === optionId;
|
|
459
|
+
if (!option && !isOtherOption || option?.disabled) return;
|
|
460
|
+
const current = answer.optionIds;
|
|
461
|
+
const selected = current.includes(optionId);
|
|
462
|
+
const optionIds = question.type === "single" ? [optionId] : selected ? current.filter((id) => id !== optionId) : [...current, optionId];
|
|
463
|
+
updateAnswer({
|
|
464
|
+
...answer,
|
|
465
|
+
optionIds,
|
|
466
|
+
...question.type === "single" && question.other && optionId !== question.other.id ? { otherText: "" } : {}
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
const continueQuestion = () => {
|
|
470
|
+
if (!canContinue) return;
|
|
471
|
+
if (isLast) {
|
|
472
|
+
onSubmit?.(answers);
|
|
473
|
+
return;
|
|
252
474
|
}
|
|
253
|
-
|
|
475
|
+
if (onActiveQuestionChange) onActiveQuestionChange(questions[questionIndex + 1].id);
|
|
476
|
+
};
|
|
477
|
+
return /* @__PURE__ */ jsxs("section", { "data-yunui": "approval-question", className: cn("w-full max-w-md rounded-xl border border-border/70 bg-card p-3.5 shadow-none", className), "aria-labelledby": `${generatedId}-title`, "aria-busy": submitting || void 0, children: [
|
|
478
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-2.5 flex items-start justify-between gap-3", children: [
|
|
479
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
480
|
+
/* @__PURE__ */ jsxs("div", { "aria-live": "polite", "aria-atomic": "true", children: [
|
|
481
|
+
/* @__PURE__ */ jsx("p", { className: "mb-1 text-xs text-muted-foreground", children: labels?.progress?.(questionIndex + 1, questions.length) ?? `Question ${questionIndex + 1} of ${questions.length}` }),
|
|
482
|
+
/* @__PURE__ */ jsx("h3", { id: `${generatedId}-title`, className: "text-sm font-semibold text-foreground", children: question.title })
|
|
483
|
+
] }),
|
|
484
|
+
question.message != null ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: question.message }) : null
|
|
485
|
+
] }),
|
|
486
|
+
onDismiss ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "h-6 w-6 shrink-0 text-muted-foreground", disabled: disabled || submitting, onClick: onDismiss, "aria-label": copy.dismiss, children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "h-3.5 w-3.5" }) }) : null
|
|
487
|
+
] }),
|
|
488
|
+
/* @__PURE__ */ jsxs("fieldset", { className: "min-w-0", "aria-labelledby": `${generatedId}-title`, children: [
|
|
489
|
+
/* @__PURE__ */ jsx("legend", { className: "sr-only", children: question.title }),
|
|
490
|
+
question.type === "single" ? /* @__PURE__ */ jsxs(
|
|
491
|
+
RadioGroup,
|
|
492
|
+
{
|
|
493
|
+
value: answer.optionIds.find((id) => id === question.other?.id || question.options.some((option) => option.id === id)) ?? "",
|
|
494
|
+
onValueChange: toggleOption,
|
|
495
|
+
disabled: disabled || submitting,
|
|
496
|
+
orientation: "vertical",
|
|
497
|
+
className: "gap-0",
|
|
498
|
+
children: [
|
|
499
|
+
question.options.map((option) => {
|
|
500
|
+
const checked = answer.optionIds.includes(option.id);
|
|
501
|
+
const inputId = `${generatedId}-${domPart(question.id)}-${domPart(option.id)}`;
|
|
502
|
+
const labelId = `${inputId}-label`;
|
|
503
|
+
return /* @__PURE__ */ jsx("div", { className: cn("transition-colors", checked && "bg-muted/50", !option.disabled && !disabled && !submitting && "hover:bg-muted/50"), children: /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: cn("flex min-h-9 cursor-pointer items-start gap-2.5 px-2 py-1.5", (option.disabled || disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
|
|
504
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: inputId, value: option.id, disabled: disabled || submitting || option.disabled, "aria-labelledby": labelId, className: "mt-0.5" }),
|
|
505
|
+
/* @__PURE__ */ jsxs("span", { id: labelId, className: "min-w-0 flex-1 text-sm text-foreground", children: [
|
|
506
|
+
/* @__PURE__ */ jsx("span", { className: "block", children: option.label }),
|
|
507
|
+
option.detail != null ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.detail }) : null
|
|
508
|
+
] })
|
|
509
|
+
] }) }, option.id);
|
|
510
|
+
}),
|
|
511
|
+
question.other ? (() => {
|
|
512
|
+
const otherSelected = answer.optionIds.includes(question.other.id);
|
|
513
|
+
const otherId = `${generatedId}-${domPart(question.id)}-${domPart(question.other.id)}`;
|
|
514
|
+
const otherLabelId = `${otherId}-label`;
|
|
515
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("transition-colors", otherSelected && "bg-muted/50", !disabled && !submitting && "hover:bg-muted/50"), children: [
|
|
516
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: otherId, className: cn("flex min-h-9 cursor-pointer items-center gap-2.5 px-2 py-1.5 text-sm text-foreground", (disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
|
|
517
|
+
/* @__PURE__ */ jsx(RadioGroupItem, { id: otherId, value: question.other.id, disabled: disabled || submitting, "aria-labelledby": otherLabelId }),
|
|
518
|
+
/* @__PURE__ */ jsx("span", { id: otherLabelId, children: question.other.label })
|
|
519
|
+
] }),
|
|
520
|
+
otherSelected ? /* @__PURE__ */ jsx(
|
|
521
|
+
"input",
|
|
522
|
+
{
|
|
523
|
+
value: answer.otherText ?? "",
|
|
524
|
+
disabled: disabled || submitting,
|
|
525
|
+
onChange: (event) => updateAnswer({ ...answer, otherText: event.target.value }),
|
|
526
|
+
placeholder: question.other.placeholder ?? copy.otherPlaceholder,
|
|
527
|
+
"aria-label": question.other.placeholder ?? copy.otherPlaceholder,
|
|
528
|
+
className: "mb-2 ml-9 w-[calc(100%-2.75rem)] rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
529
|
+
}
|
|
530
|
+
) : null
|
|
531
|
+
] }, question.other.id);
|
|
532
|
+
})() : null
|
|
533
|
+
]
|
|
534
|
+
}
|
|
535
|
+
) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0", children: [
|
|
536
|
+
question.options.map((option) => {
|
|
537
|
+
const checked = answer.optionIds.includes(option.id);
|
|
538
|
+
const inputId = `${generatedId}-${domPart(question.id)}-${domPart(option.id)}`;
|
|
539
|
+
const labelId = `${inputId}-label`;
|
|
540
|
+
return /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: cn("flex min-h-9 cursor-pointer items-start gap-2.5 px-2 py-1.5 transition-colors", checked && "bg-muted/50", !option.disabled && !disabled && !submitting && "hover:bg-muted/50", (option.disabled || disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
|
|
541
|
+
/* @__PURE__ */ jsx(Checkbox, { id: inputId, checked, disabled: disabled || submitting || option.disabled, onCheckedChange: () => toggleOption(option.id), "aria-labelledby": labelId, className: "mt-0.5" }),
|
|
542
|
+
/* @__PURE__ */ jsxs("span", { id: labelId, className: "min-w-0 flex-1 text-sm text-foreground", children: [
|
|
543
|
+
/* @__PURE__ */ jsx("span", { className: "block", children: option.label }),
|
|
544
|
+
option.detail != null ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.detail }) : null
|
|
545
|
+
] })
|
|
546
|
+
] }, option.id);
|
|
547
|
+
}),
|
|
548
|
+
question.other ? (() => {
|
|
549
|
+
const otherSelected = answer.optionIds.includes(question.other.id);
|
|
550
|
+
const otherId = `${generatedId}-${domPart(question.id)}-${domPart(question.other.id)}`;
|
|
551
|
+
const otherLabelId = `${otherId}-label`;
|
|
552
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("transition-colors", otherSelected && "bg-muted/50"), children: [
|
|
553
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: otherId, className: cn("flex min-h-9 cursor-pointer items-center gap-2.5 px-2 py-1.5 text-sm text-foreground transition-colors", !disabled && !submitting && "hover:bg-muted/50", (disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
|
|
554
|
+
/* @__PURE__ */ jsx(Checkbox, { id: otherId, checked: otherSelected, disabled: disabled || submitting, onCheckedChange: () => toggleOption(question.other.id), "aria-labelledby": otherLabelId }),
|
|
555
|
+
/* @__PURE__ */ jsx("span", { id: otherLabelId, children: question.other.label })
|
|
556
|
+
] }),
|
|
557
|
+
otherSelected ? /* @__PURE__ */ jsx(
|
|
558
|
+
"input",
|
|
559
|
+
{
|
|
560
|
+
value: answer.otherText ?? "",
|
|
561
|
+
disabled: disabled || submitting,
|
|
562
|
+
onChange: (event) => updateAnswer({ ...answer, otherText: event.target.value }),
|
|
563
|
+
placeholder: question.other.placeholder ?? copy.otherPlaceholder,
|
|
564
|
+
"aria-label": question.other.placeholder ?? copy.otherPlaceholder,
|
|
565
|
+
className: "mb-2 ml-9 w-[calc(100%-2.75rem)] rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
566
|
+
}
|
|
567
|
+
) : null
|
|
568
|
+
] });
|
|
569
|
+
})() : null
|
|
570
|
+
] })
|
|
571
|
+
] }),
|
|
572
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between gap-2", children: [
|
|
573
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: disabled || submitting || questionIndex === 0 || !onActiveQuestionChange, onClick: () => onActiveQuestionChange?.(questions[questionIndex - 1].id), children: copy.back }),
|
|
574
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
575
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: disabled || submitting || !onSkip, onClick: () => onSkip?.(question.id), children: copy.skip }),
|
|
576
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "primary", size: "sm", disabled: disabled || submitting || !canContinue || (isLast ? !onSubmit : !onActiveQuestionChange), onClick: continueQuestion, children: [
|
|
577
|
+
isLast ? submitting ? copy.submitting : copy.submit : copy.next,
|
|
578
|
+
!isLast ? /* @__PURE__ */ jsx(ArrowRight, { "aria-hidden": true, className: "ml-1 h-3.5 w-3.5" }) : null
|
|
579
|
+
] })
|
|
580
|
+
] })
|
|
581
|
+
] })
|
|
582
|
+
] });
|
|
254
583
|
}
|
|
255
584
|
function AgentRunStatus({
|
|
256
585
|
label,
|
|
257
586
|
phase = "thinking",
|
|
258
|
-
active =
|
|
587
|
+
active = !["waiting", "completed", "failed", "cancelled"].includes(phase),
|
|
588
|
+
elapsed,
|
|
259
589
|
className,
|
|
260
590
|
...props
|
|
261
591
|
}) {
|
|
592
|
+
const lastLabel = useRef(label);
|
|
593
|
+
const [leaving, setLeaving] = useState(null);
|
|
594
|
+
const [rolled, setRolled] = useState(false);
|
|
595
|
+
const leaveId = useRef(0);
|
|
596
|
+
useEffect(() => {
|
|
597
|
+
if (lastLabel.current === label) return;
|
|
598
|
+
setLeaving({ id: ++leaveId.current, text: lastLabel.current });
|
|
599
|
+
setRolled(true);
|
|
600
|
+
lastLabel.current = label;
|
|
601
|
+
const timer = setTimeout(() => setLeaving(null), 200);
|
|
602
|
+
return () => clearTimeout(timer);
|
|
603
|
+
}, [label]);
|
|
604
|
+
const terminal = phase === "completed" || phase === "failed" || phase === "cancelled";
|
|
605
|
+
const Icon = phase === "completed" ? Check : phase === "failed" ? CircleAlert : phase === "cancelled" ? X : phase === "waiting" ? Clock3 : phase === "thinking" && active ? Sparkles : active ? Loader2 : Clock3;
|
|
262
606
|
return /* @__PURE__ */ jsxs(
|
|
263
607
|
"div",
|
|
264
608
|
{
|
|
@@ -268,545 +612,440 @@ function AgentRunStatus({
|
|
|
268
612
|
"data-yunui": "agent-run-status",
|
|
269
613
|
"data-phase": phase,
|
|
270
614
|
"data-active": active || void 0,
|
|
271
|
-
className: cn(
|
|
272
|
-
"flex min-h-9 w-fit max-w-full min-w-0 items-center gap-2 py-1 text-[13.5px] text-muted-foreground",
|
|
273
|
-
className
|
|
274
|
-
),
|
|
615
|
+
className: cn("flex min-h-8 w-fit max-w-full min-w-0 items-center gap-2 py-1 text-[13px] text-muted-foreground", className),
|
|
275
616
|
...props,
|
|
276
617
|
children: [
|
|
277
618
|
/* @__PURE__ */ jsx(
|
|
278
|
-
|
|
279
|
-
{
|
|
280
|
-
text: label,
|
|
281
|
-
active,
|
|
282
|
-
"data-run-status-label": true,
|
|
283
|
-
className: "min-w-0 max-w-xl truncate font-medium"
|
|
284
|
-
}
|
|
285
|
-
),
|
|
286
|
-
/* @__PURE__ */ jsx(
|
|
287
|
-
"span",
|
|
619
|
+
Icon,
|
|
288
620
|
{
|
|
289
|
-
"data-run-status-
|
|
290
|
-
"aria-hidden":
|
|
621
|
+
"data-run-status-indicator": true,
|
|
622
|
+
"aria-hidden": true,
|
|
291
623
|
className: cn(
|
|
292
|
-
"
|
|
293
|
-
active ? "
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
"
|
|
297
|
-
|
|
298
|
-
className: "h-1 w-1 rounded-full bg-primary/60 motion-safe:animate-pulse",
|
|
299
|
-
style: {
|
|
300
|
-
animationDelay: `${index * 180}ms`,
|
|
301
|
-
animationDuration: "1.1s"
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
index
|
|
305
|
-
))
|
|
624
|
+
"h-3.5 w-3.5 shrink-0",
|
|
625
|
+
active && !terminal && phase === "thinking" ? "text-primary" : "",
|
|
626
|
+
active && !terminal && phase !== "thinking" ? "motion-safe:animate-spin text-primary" : "",
|
|
627
|
+
phase === "completed" ? "text-(--success)" : "",
|
|
628
|
+
phase === "failed" ? "text-(--error)" : ""
|
|
629
|
+
)
|
|
306
630
|
}
|
|
307
|
-
)
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ jsxs("span", { className: "yunui-roll min-w-0 max-w-xl", children: [
|
|
633
|
+
leaving ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "yunui-roll-out truncate font-medium text-foreground", children: leaving.text }, leaving.id) : null,
|
|
634
|
+
/* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate", rolled && "yunui-roll-in"), children: /* @__PURE__ */ jsx(
|
|
635
|
+
TextShimmer,
|
|
636
|
+
{
|
|
637
|
+
text: label,
|
|
638
|
+
active: active && !terminal,
|
|
639
|
+
"data-run-status-label": true,
|
|
640
|
+
className: "min-w-0 max-w-xl truncate font-medium text-foreground"
|
|
641
|
+
}
|
|
642
|
+
) }, label)
|
|
643
|
+
] }),
|
|
644
|
+
elapsed ? /* @__PURE__ */ jsx("span", { "data-run-status-elapsed": true, className: "shrink-0 text-[12px] tabular-nums text-muted-foreground", children: elapsed }) : null
|
|
308
645
|
]
|
|
309
646
|
}
|
|
310
647
|
);
|
|
311
648
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const handleCopy = async (e) => {
|
|
321
|
-
e.preventDefault();
|
|
322
|
-
e.stopPropagation();
|
|
323
|
-
if (!await copyToClipboard(text)) return;
|
|
324
|
-
setCopied(true);
|
|
325
|
-
setTimeout(() => setCopied(false), 1500);
|
|
326
|
-
};
|
|
327
|
-
return /* @__PURE__ */ jsxs(
|
|
328
|
-
"button",
|
|
649
|
+
var CATEGORY_TONE = {
|
|
650
|
+
accent: "bg-accent",
|
|
651
|
+
muted: "bg-muted-foreground",
|
|
652
|
+
warning: "bg-warning-solid-medium"
|
|
653
|
+
};
|
|
654
|
+
function IncludedMark({ included, tone }) {
|
|
655
|
+
return /* @__PURE__ */ jsx(
|
|
656
|
+
"span",
|
|
329
657
|
{
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/* @__PURE__ */ jsx("span", { className: `opacity-0 group-hover/badge:opacity-100 absolute right-0 inset-y-0 flex items-center justify-center rounded-r-md bg-muted/90 backdrop-blur-sm transition-opacity duration-200 ${sm ? "w-4" : "w-5"}`, children: copied ? /* @__PURE__ */ jsx(Check, { size: sm ? 9 : 10 }) : /* @__PURE__ */ jsx(Copy, { size: sm ? 9 : 10 }) })
|
|
338
|
-
]
|
|
658
|
+
"aria-hidden": "true",
|
|
659
|
+
className: cn(
|
|
660
|
+
"flex size-[18px] shrink-0 items-center justify-center rounded-[5px] transition-[background-color,color,transform] duration-(--dur-fast)",
|
|
661
|
+
included ? tone === "error" ? "bg-(--error) text-[var(--bg-base)]" : "bg-(--success) text-[var(--bg-base)]" : "bg-muted text-muted-foreground shadow-[0_0_0_1px_var(--border-default)]"
|
|
662
|
+
),
|
|
663
|
+
style: { transform: included ? "scale(1)" : "scale(0.92)" },
|
|
664
|
+
children: included ? /* @__PURE__ */ jsx(Check, { "aria-hidden": "true", className: "size-3", strokeWidth: 3 }) : null
|
|
339
665
|
}
|
|
340
666
|
);
|
|
341
667
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
description,
|
|
360
|
-
capabilities = [],
|
|
361
|
-
developer,
|
|
362
|
-
context,
|
|
363
|
-
tier,
|
|
364
|
-
price,
|
|
365
|
-
nonofficial,
|
|
366
|
-
suspended,
|
|
668
|
+
function stateText(state, labels, count) {
|
|
669
|
+
if (state === "busy") return labels.busy ?? "Applying changes\u2026";
|
|
670
|
+
if (state === "applied") return labels.applied?.(count) ?? `${count} ${count === 1 ? "edit" : "edits"} applied`;
|
|
671
|
+
if (state === "error") return labels.error ?? "Could not apply changes";
|
|
672
|
+
if (state === "cancelled") return labels.cancelled ?? "Changes cancelled";
|
|
673
|
+
if (state === "disabled") return labels.disabled ?? "Changes unavailable";
|
|
674
|
+
return null;
|
|
675
|
+
}
|
|
676
|
+
function DiffTable({
|
|
677
|
+
rows,
|
|
678
|
+
selectedIds,
|
|
679
|
+
onSelectionChange,
|
|
680
|
+
onApply,
|
|
681
|
+
onReject,
|
|
682
|
+
state = "idle",
|
|
683
|
+
statusMessage,
|
|
684
|
+
resultCount,
|
|
367
685
|
labels,
|
|
368
|
-
|
|
369
|
-
className = ""
|
|
686
|
+
className
|
|
370
687
|
}) {
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between mb-3", children: [
|
|
388
|
-
icon,
|
|
389
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: shownCaps.map((cap) => {
|
|
390
|
-
const { icon: Icon, color } = CAPABILITY_ICONS[cap];
|
|
391
|
-
return /* @__PURE__ */ jsx("div", { className: "p-1 rounded-md bg-muted/50", title: cap, children: /* @__PURE__ */ jsx(Icon, { size: 11, className: color }) }, cap);
|
|
392
|
-
}) })
|
|
393
|
-
] }),
|
|
394
|
-
/* @__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: [
|
|
395
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: name }),
|
|
396
|
-
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" }),
|
|
397
|
-
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: [
|
|
398
|
-
/* @__PURE__ */ jsx(PauseCircle, { size: 10 }),
|
|
399
|
-
labels?.suspended ?? "Suspended"
|
|
400
|
-
] })
|
|
401
|
-
] }) }),
|
|
402
|
-
ids.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1.5 mb-3", children: ids.map((id, idx) => /* @__PURE__ */ jsx(IDBadge, { text: id }, idx)) }),
|
|
403
|
-
/* @__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" }) }),
|
|
404
|
-
/* @__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: [
|
|
405
|
-
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 min-w-0", children: [
|
|
406
|
-
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" }) }),
|
|
407
|
-
developer?.label && /* @__PURE__ */ jsx("span", { className: "truncate min-w-0", children: developer.label })
|
|
408
|
-
] }),
|
|
409
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
410
|
-
context && /* @__PURE__ */ jsx("span", { className: "bg-muted px-1.5 py-0.5 rounded-sm font-medium", children: context }),
|
|
411
|
-
tier && tier !== "free" && /* @__PURE__ */ jsx("span", { className: "bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 px-1.5 py-0.5 rounded-sm font-medium", children: tier }),
|
|
412
|
-
price && /* @__PURE__ */ jsx("span", { className: "font-mono", children: price })
|
|
413
|
-
] })
|
|
414
|
-
] })
|
|
415
|
-
]
|
|
416
|
-
}
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
function HScrollRow({ children, className }) {
|
|
420
|
-
const scrollRef = useRef(null);
|
|
421
|
-
const [thumb, setThumb] = useState({ w: 0, x: 0, show: false });
|
|
422
|
-
const sync = () => {
|
|
423
|
-
const el = scrollRef.current;
|
|
424
|
-
if (!el) return;
|
|
425
|
-
const { scrollWidth, clientWidth, scrollLeft } = el;
|
|
426
|
-
const overflow = scrollWidth - clientWidth;
|
|
427
|
-
if (overflow <= 1) {
|
|
428
|
-
setThumb((t) => t.show ? { w: 0, x: 0, show: false } : t);
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
const w = Math.max(clientWidth / scrollWidth * clientWidth, 28);
|
|
432
|
-
const x = scrollLeft / overflow * (clientWidth - w);
|
|
433
|
-
setThumb({ w, x, show: true });
|
|
434
|
-
};
|
|
435
|
-
useEffect(() => {
|
|
436
|
-
const el = scrollRef.current;
|
|
437
|
-
if (!el) return;
|
|
438
|
-
sync();
|
|
439
|
-
el.addEventListener("scroll", sync, { passive: true });
|
|
440
|
-
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(sync) : null;
|
|
441
|
-
ro?.observe(el);
|
|
442
|
-
if (el.firstElementChild) ro?.observe(el.firstElementChild);
|
|
443
|
-
return () => {
|
|
444
|
-
el.removeEventListener("scroll", sync);
|
|
445
|
-
ro?.disconnect();
|
|
446
|
-
};
|
|
447
|
-
}, []);
|
|
448
|
-
const onThumbDown = (e) => {
|
|
449
|
-
const el = scrollRef.current;
|
|
450
|
-
if (!el) return;
|
|
451
|
-
e.preventDefault();
|
|
452
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
453
|
-
const startX = e.clientX;
|
|
454
|
-
const startScroll = el.scrollLeft;
|
|
455
|
-
const move = (ev) => {
|
|
456
|
-
const { scrollWidth, clientWidth } = el;
|
|
457
|
-
const w = Math.max(clientWidth / scrollWidth * clientWidth, 28);
|
|
458
|
-
const travel = clientWidth - w;
|
|
459
|
-
if (travel <= 0) return;
|
|
460
|
-
el.scrollLeft = startScroll + (ev.clientX - startX) / travel * (scrollWidth - clientWidth);
|
|
461
|
-
};
|
|
462
|
-
const up = () => {
|
|
463
|
-
window.removeEventListener("pointermove", move);
|
|
464
|
-
window.removeEventListener("pointerup", up);
|
|
465
|
-
};
|
|
466
|
-
window.addEventListener("pointermove", move);
|
|
467
|
-
window.addEventListener("pointerup", up);
|
|
688
|
+
const selected = new Set(selectedIds);
|
|
689
|
+
const changeRows = rows.filter((row) => row.change !== "unchanged");
|
|
690
|
+
const selectableRows = changeRows.filter((row) => !row.disabled);
|
|
691
|
+
const validSelected = selectableRows.filter((row) => selected.has(row.id));
|
|
692
|
+
const selectedValues = validSelected.map((row) => row.id);
|
|
693
|
+
const removals = validSelected.filter((row) => row.change === "remove").length;
|
|
694
|
+
const additions = validSelected.filter((row) => row.change === "add").length;
|
|
695
|
+
const changeCount = removals + additions;
|
|
696
|
+
const locked = state !== "idle";
|
|
697
|
+
const requestStatus = stateText(state, labels ?? {}, resultCount ?? changeCount);
|
|
698
|
+
const toggleRow = (row) => {
|
|
699
|
+
if (locked || row.disabled || row.change === "unchanged" || !onSelectionChange) return;
|
|
700
|
+
const next = new Set(selectedValues);
|
|
701
|
+
if (next.has(row.id)) next.delete(row.id);
|
|
702
|
+
else next.add(row.id);
|
|
703
|
+
onSelectionChange(selectableRows.filter((candidate) => next.has(candidate.id)).map((candidate) => candidate.id));
|
|
468
704
|
};
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
705
|
+
const renderRow = (row) => {
|
|
706
|
+
const changed = row.change !== "unchanged";
|
|
707
|
+
const included = changed && !row.disabled && selected.has(row.id);
|
|
708
|
+
const removed = row.change === "remove";
|
|
709
|
+
const interactive = changed && !row.disabled && !locked && Boolean(onSelectionChange);
|
|
710
|
+
const tint = included ? removed ? "bg-error-soft" : "bg-success-soft" : "";
|
|
711
|
+
const cellTone = included ? removed ? "text-error" : "text-success" : "";
|
|
712
|
+
const accessibleLabel = row.accessibleLabel ?? row.primary;
|
|
713
|
+
return /* @__PURE__ */ jsxs(
|
|
714
|
+
"tr",
|
|
472
715
|
{
|
|
473
|
-
|
|
716
|
+
tabIndex: interactive ? 0 : void 0,
|
|
717
|
+
"aria-label": changed ? labels?.includeRow?.(accessibleLabel) ?? `Include change: ${accessibleLabel}` : void 0,
|
|
718
|
+
"aria-selected": changed ? included : void 0,
|
|
719
|
+
"aria-disabled": changed && !interactive ? true : void 0,
|
|
720
|
+
onClick: interactive ? () => toggleRow(row) : void 0,
|
|
721
|
+
onKeyDown: interactive ? (event) => {
|
|
722
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
723
|
+
event.preventDefault();
|
|
724
|
+
toggleRow(row);
|
|
725
|
+
}
|
|
726
|
+
} : void 0,
|
|
474
727
|
className: cn(
|
|
475
|
-
"
|
|
476
|
-
|
|
728
|
+
"border-b border-border transition-[background-color,filter,opacity] duration-(--dur-fast) last:border-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
|
|
729
|
+
tint,
|
|
730
|
+
interactive && "cursor-pointer hover:brightness-[0.985]"
|
|
477
731
|
),
|
|
478
|
-
children
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
732
|
+
children: [
|
|
733
|
+
/* @__PURE__ */ jsx("td", { className: cn("px-3 @max-[320px]/diff:px-2 py-2.5 text-[13px] font-medium tabular-nums text-foreground transition-colors duration-(--dur-base)", cellTone), children: row.primary }),
|
|
734
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 @max-[320px]/diff:px-2 py-2.5", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex h-5 min-w-0 max-w-full items-center gap-1.5 rounded-full bg-muted px-2 @max-[320px]/diff:px-1.5 text-[11.5px] font-medium shadow-[0_0_0_1px_var(--border-default)]", children: [
|
|
735
|
+
row.categoryTone ? /* @__PURE__ */ jsx("span", { className: cn("size-1.5 shrink-0 rounded-full", CATEGORY_TONE[row.categoryTone]), "aria-hidden": "true" }) : null,
|
|
736
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-[var(--text-secondary)]", children: row.category })
|
|
737
|
+
] }) }),
|
|
738
|
+
/* @__PURE__ */ jsx(
|
|
739
|
+
"td",
|
|
740
|
+
{
|
|
741
|
+
className: cn("px-3 @max-[320px]/diff:px-2 py-2.5 text-[12.5px] text-[var(--text-secondary)] transition-colors duration-(--dur-base)", cellTone, included && removed && "line-through"),
|
|
742
|
+
style: included && removed ? { textDecorationColor: "color-mix(in srgb, var(--error) 50%, transparent)" } : void 0,
|
|
743
|
+
children: /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-2", children: [
|
|
744
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: row.secondary }),
|
|
745
|
+
changed ? /* @__PURE__ */ jsx(IncludedMark, { included, tone: removed ? "error" : "success" }) : null
|
|
746
|
+
] })
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
]
|
|
750
|
+
},
|
|
751
|
+
row.id
|
|
752
|
+
);
|
|
753
|
+
};
|
|
754
|
+
return /* @__PURE__ */ jsx("div", { className: cn("@container/diff w-full max-w-[380px]", className), "data-yunui": "diff-table", "data-diff-state": state, children: /* @__PURE__ */ jsxs("div", { className: "relative overflow-hidden rounded-xl border border-border bg-card shadow-sm", children: [
|
|
755
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-border px-3 py-2.5", children: [
|
|
756
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 text-[12.5px] font-medium text-foreground", children: labels?.title ?? "Proposed changes" }),
|
|
757
|
+
state === "idle" && changeCount > 0 ? /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] text-[var(--text-secondary)]", children: labels?.hint ?? "Select the changes to apply" }) : null
|
|
758
|
+
] }),
|
|
759
|
+
/* @__PURE__ */ jsxs("table", { className: "w-full table-fixed border-collapse text-left", children: [
|
|
760
|
+
/* @__PURE__ */ jsxs("colgroup", { children: [
|
|
761
|
+
/* @__PURE__ */ jsx("col", { className: "w-[34%] @max-[320px]/diff:w-[40%]" }),
|
|
762
|
+
/* @__PURE__ */ jsx("col", { className: "w-[30%] @max-[320px]/diff:w-[28%]" }),
|
|
763
|
+
/* @__PURE__ */ jsx("col", { className: "w-[36%] @max-[320px]/diff:w-[32%]" })
|
|
764
|
+
] }),
|
|
765
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "border-b border-border", children: [labels?.primaryColumn ?? "Item", labels?.categoryColumn ?? "Category", labels?.secondaryColumn ?? "Details"].map((heading, index) => /* @__PURE__ */ jsx("th", { scope: "col", className: "px-3 @max-[320px]/diff:px-2 py-2.5 whitespace-nowrap text-[12px] font-medium text-[var(--text-secondary)]", children: heading }, index)) }) }),
|
|
766
|
+
/* @__PURE__ */ jsx("tbody", { children: rows.map(renderRow) })
|
|
767
|
+
] }),
|
|
768
|
+
/* @__PURE__ */ jsx("div", { className: "flex min-h-11 items-center justify-between gap-3 @max-[320px]/diff:flex-wrap border-t border-border px-2.5 py-2", children: state === "idle" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
769
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 @max-[320px]/diff:w-full text-[11.5px] tabular-nums text-[var(--text-secondary)]", "aria-live": "polite", children: labels?.selectionSummary?.(removals, additions) ?? `${removals} ${removals === 1 ? "removal" : "removals"} \xB7 ${additions} ${additions === 1 ? "addition" : "additions"}` }),
|
|
770
|
+
/* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1.5 @max-[320px]/diff:ml-auto", children: [
|
|
771
|
+
onReject ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-7 rounded-full px-2.5 text-[12px]", onClick: () => onReject(selectedValues), children: labels?.reject ?? "Reject" }) : null,
|
|
772
|
+
/* @__PURE__ */ jsx(
|
|
773
|
+
Button,
|
|
774
|
+
{
|
|
775
|
+
type: "button",
|
|
776
|
+
variant: "primary",
|
|
777
|
+
size: "sm",
|
|
778
|
+
className: "h-7 rounded-full px-3 text-[12px]",
|
|
779
|
+
disabled: !onApply || changeCount === 0,
|
|
780
|
+
onClick: () => {
|
|
781
|
+
if (onApply && changeCount > 0) onApply(selectedValues);
|
|
782
|
+
},
|
|
783
|
+
children: labels?.apply?.(changeCount) ?? `Apply ${changeCount} ${changeCount === 1 ? "change" : "changes"}`
|
|
784
|
+
}
|
|
785
|
+
)
|
|
786
|
+
] })
|
|
787
|
+
] }) : /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: "min-w-0 text-[11.5px] text-[var(--text-secondary)]", children: statusMessage ?? requestStatus }) })
|
|
788
|
+
] }) });
|
|
493
789
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
790
|
+
var DEFAULT_LABELS2 = {
|
|
791
|
+
keep: "Keep",
|
|
792
|
+
discard: "Discard",
|
|
793
|
+
placeholder: "Describe edits",
|
|
794
|
+
submitInstruction: "Submit custom instruction",
|
|
795
|
+
customAction: "Custom instruction",
|
|
796
|
+
working: "Working",
|
|
797
|
+
error: "The edit request failed. Original text is unchanged.",
|
|
798
|
+
cancelled: "Edit request cancelled. Original text is unchanged.",
|
|
799
|
+
retry: "Try again",
|
|
800
|
+
showMoreActions: "Show more actions",
|
|
801
|
+
showFewerActions: "Show fewer actions",
|
|
802
|
+
result: "Suggested edit"
|
|
803
|
+
};
|
|
804
|
+
var iconProps = { size: 14, strokeWidth: 1.8, "aria-hidden": true };
|
|
805
|
+
var DEFAULT_ACTIONS = [
|
|
806
|
+
{ id: "Explain", action: "Explain", icon: /* @__PURE__ */ jsx(CircleHelp, { ...iconProps }) },
|
|
807
|
+
{ id: "Improve", action: "Improve", busyLabel: "Improving", icon: /* @__PURE__ */ jsx(Sparkles, { ...iconProps }) },
|
|
808
|
+
{ id: "Shorten", action: "Shorten", busyLabel: "Shortening", icon: /* @__PURE__ */ jsx(Scissors, { ...iconProps }) },
|
|
809
|
+
{ id: "Tone", action: "Change tone", busyLabel: "Changing tone", icon: /* @__PURE__ */ jsx(ThumbsUp, { ...iconProps }) },
|
|
810
|
+
{ id: "Grammar", action: "Fix grammar", icon: /* @__PURE__ */ jsx(Type, { ...iconProps }) }
|
|
811
|
+
];
|
|
812
|
+
var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
813
|
+
function SelectionActions({
|
|
814
|
+
lead = "",
|
|
815
|
+
selectedText,
|
|
816
|
+
resultText,
|
|
817
|
+
state = "idle",
|
|
818
|
+
actions = DEFAULT_ACTIONS,
|
|
819
|
+
busyLabel,
|
|
499
820
|
labels,
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
821
|
+
disabled = false,
|
|
822
|
+
onAction,
|
|
823
|
+
onAccept,
|
|
824
|
+
onDismiss,
|
|
825
|
+
onRetry,
|
|
826
|
+
className
|
|
506
827
|
}) {
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
828
|
+
const copy = mergeLabels(DEFAULT_LABELS2, labels);
|
|
829
|
+
const [prompt, setPrompt] = useState("");
|
|
830
|
+
const [expanded, setExpanded] = useState(false);
|
|
831
|
+
const [anchor, setAnchor] = useState({ x: 0, y: 0 });
|
|
832
|
+
const [positioned, setPositioned] = useState(false);
|
|
833
|
+
const [maxBarWidth, setMaxBarWidth] = useState(0);
|
|
834
|
+
const hostRef = useRef(null);
|
|
835
|
+
const selectionRef = useRef(null);
|
|
836
|
+
const barRef = useRef(null);
|
|
837
|
+
const frameRef = useRef(null);
|
|
838
|
+
const previousSelectionRef = useRef(selectedText);
|
|
839
|
+
const place = useCallback(() => {
|
|
840
|
+
if (typeof window === "undefined") return;
|
|
841
|
+
if (frameRef.current) {
|
|
842
|
+
if (frameRef.current.kind === "raf") window.cancelAnimationFrame(frameRef.current.id);
|
|
843
|
+
else window.clearTimeout(frameRef.current.id);
|
|
844
|
+
}
|
|
845
|
+
const measure = () => {
|
|
846
|
+
frameRef.current = null;
|
|
847
|
+
const host = hostRef.current;
|
|
848
|
+
const selected = selectionRef.current;
|
|
849
|
+
if (!host || !selected) return;
|
|
850
|
+
const bounds = selected.getBoundingClientRect();
|
|
851
|
+
const lines = Array.from(selected.getClientRects());
|
|
852
|
+
const lastLine = lines.at(-1);
|
|
853
|
+
const hostBounds = host.getBoundingClientRect();
|
|
854
|
+
if (!lastLine || bounds.width === 0 || bounds.height === 0 || hostBounds.width === 0) {
|
|
855
|
+
setPositioned(false);
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
const availableWidth = Math.max(0, Math.min(hostBounds.width - 16, window.innerWidth - 48));
|
|
859
|
+
setMaxBarWidth((current) => Math.abs(current - availableWidth) < 1 ? current : availableWidth);
|
|
860
|
+
const barWidth = barRef.current?.getBoundingClientRect().width ?? 0;
|
|
861
|
+
const hostPadding = Math.min(8, hostBounds.width / 2);
|
|
862
|
+
const halfBar = Math.min(barWidth / 2, Math.max(0, hostBounds.width / 2 - hostPadding));
|
|
863
|
+
const minX = hostPadding + halfBar;
|
|
864
|
+
const maxX = Math.max(minX, hostBounds.width - hostPadding - halfBar);
|
|
865
|
+
const next = {
|
|
866
|
+
x: Math.round(Math.min(maxX, Math.max(minX, bounds.left - hostBounds.left + bounds.width / 2))),
|
|
867
|
+
y: Math.round(lastLine.bottom - hostBounds.top + 8)
|
|
868
|
+
};
|
|
869
|
+
setAnchor((current) => current.x === next.x && current.y === next.y ? current : next);
|
|
870
|
+
setPositioned(true);
|
|
541
871
|
};
|
|
872
|
+
frameRef.current = typeof window.requestAnimationFrame === "function" ? { id: window.requestAnimationFrame(measure), kind: "raf" } : { id: window.setTimeout(measure, 0), kind: "timeout" };
|
|
542
873
|
}, []);
|
|
543
|
-
|
|
544
|
-
if (
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
const el = listRef.current.querySelector(`[data-model-id="${CSS.escape(value)}"]`);
|
|
549
|
-
el?.scrollIntoView({ block: "nearest" });
|
|
550
|
-
}
|
|
551
|
-
}, 50);
|
|
552
|
-
return () => clearTimeout(t);
|
|
553
|
-
}, [isOpen, value]);
|
|
554
|
-
const groups = useMemo(() => {
|
|
555
|
-
const counts = {};
|
|
556
|
-
for (const o of options) counts[o.group] = (counts[o.group] || 0) + 1;
|
|
557
|
-
return Object.entries(counts).sort((a, b) => b[1] - a[1]).map(([g]) => g);
|
|
558
|
-
}, [options]);
|
|
559
|
-
const groupLabel = useMemo(() => {
|
|
560
|
-
const m = {};
|
|
561
|
-
for (const o of options) if (o.groupLabel) m[o.group] = o.groupLabel;
|
|
562
|
-
return m;
|
|
563
|
-
}, [options]);
|
|
564
|
-
const groupIcon = useMemo(() => {
|
|
565
|
-
const m = {};
|
|
566
|
-
for (const o of options) if (o.groupIcon && !(o.group in m)) m[o.group] = o.groupIcon;
|
|
567
|
-
return m;
|
|
568
|
-
}, [options]);
|
|
569
|
-
const filtered = useMemo(() => {
|
|
570
|
-
const q = search.trim().toLowerCase();
|
|
571
|
-
return options.filter((o) => {
|
|
572
|
-
if (q) {
|
|
573
|
-
const hay = `${o.label} ${o.searchText ?? ""} ${o.group}`.toLowerCase();
|
|
574
|
-
if (!hay.includes(q)) return false;
|
|
575
|
-
}
|
|
576
|
-
if (activeGroup && o.group !== activeGroup) return false;
|
|
577
|
-
if (activeFilters.length && filters) {
|
|
578
|
-
const fs = filters.filter((f) => activeFilters.includes(f.key));
|
|
579
|
-
if (!fs.every((f) => f.match(o))) return false;
|
|
580
|
-
}
|
|
581
|
-
return true;
|
|
582
|
-
});
|
|
583
|
-
}, [options, search, activeGroup, activeFilters, filters]);
|
|
584
|
-
const pinnedList = filtered.filter((o) => pinnedSet.has(o.id));
|
|
585
|
-
const grouped = useMemo(() => {
|
|
586
|
-
const acc = {};
|
|
587
|
-
for (const o of filtered) {
|
|
588
|
-
if (pinnedSet.has(o.id)) continue;
|
|
589
|
-
(acc[o.group] ??= []).push(o);
|
|
874
|
+
useIsomorphicLayoutEffect(() => {
|
|
875
|
+
if (previousSelectionRef.current !== selectedText) {
|
|
876
|
+
previousSelectionRef.current = selectedText;
|
|
877
|
+
setPrompt("");
|
|
878
|
+
setExpanded(false);
|
|
590
879
|
}
|
|
591
|
-
|
|
592
|
-
}, [
|
|
593
|
-
const selected = options.find((o) => o.id === value);
|
|
594
|
-
const onWheel = (e) => {
|
|
595
|
-
const el = e.currentTarget;
|
|
596
|
-
const atTop = el.scrollTop <= 1;
|
|
597
|
-
const atBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - 1;
|
|
598
|
-
if (atTop && e.deltaY < 0 || atBottom && e.deltaY > 0) e.preventDefault();
|
|
599
|
-
};
|
|
600
|
-
const select = (id) => {
|
|
601
|
-
onChange(id);
|
|
602
|
-
setIsOpen(false);
|
|
603
|
-
};
|
|
604
|
-
const panelMaxHeight = maxHeight == null ? "min(32rem, calc(100dvh - 7rem))" : `min(${maxHeight}px, 32rem, calc(100dvh - 7rem))`;
|
|
605
|
-
const flatOptions = useMemo(() => {
|
|
606
|
-
const out = [...pinnedList];
|
|
607
|
-
for (const opts of Object.values(grouped)) out.push(...opts);
|
|
608
|
-
return out;
|
|
609
|
-
}, [pinnedList, grouped]);
|
|
610
|
-
const [activeIndex, setActiveIndex] = useState(-1);
|
|
611
|
-
useEffect(() => {
|
|
612
|
-
setActiveIndex(-1);
|
|
613
|
-
}, [isOpen, search, activeGroup, activeFilters]);
|
|
614
|
-
const clearActiveOnPointer = () => setActiveIndex((i) => i === -1 ? i : -1);
|
|
880
|
+
place();
|
|
881
|
+
}, [place, selectedText, resultText, state, lead]);
|
|
615
882
|
useEffect(() => {
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
e.preventDefault();
|
|
625
|
-
setActiveIndex((i) => Math.min(i + 1, flatOptions.length - 1));
|
|
626
|
-
} else if (e.key === "ArrowUp") {
|
|
627
|
-
e.preventDefault();
|
|
628
|
-
setActiveIndex((i) => i < 0 ? flatOptions.length - 1 : Math.max(i - 1, 0));
|
|
629
|
-
} else if (e.key === "Enter") {
|
|
630
|
-
e.preventDefault();
|
|
631
|
-
const o = flatOptions[activeIndex] ?? flatOptions[0];
|
|
632
|
-
if (o) select(o.id);
|
|
633
|
-
} else if (e.key === "Escape") {
|
|
634
|
-
e.preventDefault();
|
|
635
|
-
setIsOpen(false);
|
|
883
|
+
const host = hostRef.current;
|
|
884
|
+
const selected = selectionRef.current;
|
|
885
|
+
if (!host) return;
|
|
886
|
+
const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => place()) : null;
|
|
887
|
+
if (resizeObserver) {
|
|
888
|
+
resizeObserver.observe(host);
|
|
889
|
+
if (selected) resizeObserver.observe(selected);
|
|
890
|
+
if (barRef.current) resizeObserver.observe(barRef.current);
|
|
636
891
|
}
|
|
892
|
+
window.addEventListener("resize", place);
|
|
893
|
+
return () => {
|
|
894
|
+
resizeObserver?.disconnect();
|
|
895
|
+
window.removeEventListener("resize", place);
|
|
896
|
+
if (frameRef.current) {
|
|
897
|
+
if (frameRef.current.kind === "raf") window.cancelAnimationFrame(frameRef.current.id);
|
|
898
|
+
else window.clearTimeout(frameRef.current.id);
|
|
899
|
+
frameRef.current = null;
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
}, [place]);
|
|
903
|
+
const busy = state === "busy";
|
|
904
|
+
const hasResult = state === "result" && typeof resultText === "string";
|
|
905
|
+
const locked = busy || disabled;
|
|
906
|
+
const visibleText = hasResult ? resultText : selectedText;
|
|
907
|
+
const activity = busyLabel ?? labels?.working ?? DEFAULT_LABELS2.working;
|
|
908
|
+
const run = (action, instruction) => {
|
|
909
|
+
if (locked || !onAction) return;
|
|
910
|
+
setExpanded(false);
|
|
911
|
+
onAction(action, instruction);
|
|
637
912
|
};
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
style: { maxWidth: "calc(100vw - 1rem)", marginLeft: shift, maxHeight: panelMaxHeight },
|
|
671
|
-
className: `absolute z-50 left-0 ${placement === "top" ? "bottom-full mb-2 origin-bottom" : "top-full mt-2 origin-top"} w-96 max-w-[calc(100vw-1rem)] flex flex-col bg-popover border border-border rounded-2xl shadow-lg shadow-black/5 text-popover-foreground overflow-hidden`,
|
|
672
|
-
children: [
|
|
673
|
-
renderHeader && /* @__PURE__ */ jsx("div", { className: "p-2.5 border-b border-border/50", children: renderHeader() }),
|
|
674
|
-
/* @__PURE__ */ jsxs("div", { className: "p-2.5 border-b border-border/50", children: [
|
|
675
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
676
|
-
/* @__PURE__ */ jsx(Search, { size: 15, className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }),
|
|
677
|
-
/* @__PURE__ */ jsx(
|
|
678
|
-
"input",
|
|
679
|
-
{
|
|
680
|
-
ref: inputRef,
|
|
681
|
-
value: search,
|
|
682
|
-
onChange: (e) => setSearch(e.target.value),
|
|
683
|
-
onKeyDown: onSearchKeyDown,
|
|
684
|
-
placeholder: L.search,
|
|
685
|
-
"aria-label": L.search,
|
|
686
|
-
role: "combobox",
|
|
687
|
-
"aria-expanded": isOpen,
|
|
688
|
-
"aria-controls": "yunui-ms-listbox",
|
|
689
|
-
"aria-activedescendant": activeId ? rowDomId(activeId) : void 0,
|
|
690
|
-
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"
|
|
691
|
-
}
|
|
692
|
-
),
|
|
693
|
-
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 }) })
|
|
694
|
-
] }),
|
|
695
|
-
filters && filters.length > 0 && /* @__PURE__ */ jsx(HScrollRow, { className: "mt-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 px-2.5 pb-2 w-max", children: [
|
|
696
|
-
filters.map((f) => {
|
|
697
|
-
const on = activeFilters.includes(f.key);
|
|
698
|
-
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("shrink-0 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);
|
|
699
|
-
}),
|
|
700
|
-
activeFilters.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setActiveFilters([]), title: L.clearFilters, "aria-label": L.clearFilters, className: "shrink-0 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 }) })
|
|
701
|
-
] }) })
|
|
702
|
-
] }),
|
|
703
|
-
groups.length > 1 && /* @__PURE__ */ jsx("div", { className: "border-b border-border/50", children: /* @__PURE__ */ jsx(HScrollRow, { children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 px-2.5 pt-2 pb-2.5 w-max", children: [
|
|
704
|
-
/* @__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: [
|
|
705
|
-
L.all,
|
|
706
|
-
" (",
|
|
707
|
-
options.length,
|
|
708
|
-
")"
|
|
709
|
-
] }),
|
|
710
|
-
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: [
|
|
711
|
-
groupIcon[g],
|
|
712
|
-
groupLabel[g] ?? g
|
|
713
|
-
] }, g))
|
|
714
|
-
] }) }) }),
|
|
715
|
-
/* @__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: [
|
|
716
|
-
pinnedList.length > 0 && /* @__PURE__ */ jsxs("div", { className: "px-1.5 py-1.5 border-b border-border/40", children: [
|
|
717
|
-
/* @__PURE__ */ jsxs("div", { className: "text-[10px] font-medium text-muted-foreground uppercase tracking-wide px-2 mb-1 flex items-center gap-1", children: [
|
|
718
|
-
/* @__PURE__ */ jsx(Pin, { size: 9 }),
|
|
719
|
-
" ",
|
|
720
|
-
L.pinned
|
|
721
|
-
] }),
|
|
722
|
-
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))
|
|
723
|
-
] }),
|
|
724
|
-
/* @__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: [
|
|
725
|
-
/* @__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: [
|
|
726
|
-
groupIcon[g],
|
|
727
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-semibold", children: groupLabel[g] ?? g }),
|
|
728
|
-
/* @__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 })
|
|
729
|
-
] }) }),
|
|
730
|
-
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))
|
|
731
|
-
] }, g)) }),
|
|
732
|
-
filtered.length === 0 && /* @__PURE__ */ jsxs("div", { className: "py-12 text-center text-muted-foreground", children: [
|
|
733
|
-
/* @__PURE__ */ jsx(Sparkles, { size: 28, className: "mx-auto mb-3 opacity-40" }),
|
|
734
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm", children: L.noResults })
|
|
735
|
-
] })
|
|
736
|
-
] }),
|
|
737
|
-
renderFooter && filtered.length > 0 && /* @__PURE__ */ jsx("div", { className: "border-t border-border/50 px-3 py-2 bg-muted/30 text-xs text-muted-foreground", children: renderFooter(filtered.length) })
|
|
738
|
-
]
|
|
739
|
-
}
|
|
740
|
-
)
|
|
741
|
-
] })
|
|
742
|
-
);
|
|
743
|
-
}
|
|
744
|
-
var ModelRow = memo(function ModelRow2({
|
|
745
|
-
option,
|
|
746
|
-
selected,
|
|
747
|
-
active,
|
|
748
|
-
domId,
|
|
749
|
-
pinned,
|
|
750
|
-
isPinnable,
|
|
751
|
-
onSelect,
|
|
752
|
-
onTogglePin
|
|
753
|
-
}) {
|
|
754
|
-
return /* @__PURE__ */ jsxs(
|
|
755
|
-
"div",
|
|
756
|
-
{
|
|
757
|
-
id: domId,
|
|
758
|
-
"data-model-id": option.id,
|
|
759
|
-
role: "option",
|
|
760
|
-
"aria-selected": selected,
|
|
761
|
-
onClick: onSelect,
|
|
762
|
-
className: cn(
|
|
763
|
-
"relative flex items-center gap-3 px-3 py-2.5 rounded-xl cursor-pointer group transition-colors",
|
|
764
|
-
// A clear gray fill on both states (selected solid, hover lighter)
|
|
765
|
-
// — the bar's opacity then tells selected from merely-hovered.
|
|
766
|
-
selected ? "bg-muted" : "hover:bg-muted",
|
|
767
|
-
// keyboard highlight (arrow-key navigation)
|
|
768
|
-
active && "bg-muted ring-2 ring-ring/40"
|
|
769
|
-
),
|
|
770
|
-
children: [
|
|
771
|
-
/* @__PURE__ */ jsx(
|
|
913
|
+
const submitPrompt = (event) => {
|
|
914
|
+
event.preventDefault();
|
|
915
|
+
const instruction = prompt.trim();
|
|
916
|
+
if (!instruction) return;
|
|
917
|
+
run(labels?.customAction ?? DEFAULT_LABELS2.customAction, instruction);
|
|
918
|
+
};
|
|
919
|
+
return /* @__PURE__ */ jsx("div", { className: cn("@container/selection w-full max-w-[460px]", className), "data-yunui": "selection-actions", "data-selection-state": state, children: /* @__PURE__ */ jsxs("div", { ref: hostRef, "data-yunui": "selection-actions-host", className: "relative pb-12", children: [
|
|
920
|
+
/* @__PURE__ */ jsxs("p", { className: "text-[13px] leading-relaxed text-foreground", children: [
|
|
921
|
+
lead,
|
|
922
|
+
/* @__PURE__ */ jsxs("span", { ref: selectionRef, "data-yunui": "selection-actions-selected", style: hasResult && resultText === "" ? { display: "inline-block", minWidth: 1, minHeight: "1em" } : void 0, className: "box-decoration-clone rounded-[3px] bg-accent-subtle text-foreground", children: [
|
|
923
|
+
hasResult ? /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
924
|
+
copy.result,
|
|
925
|
+
": "
|
|
926
|
+
] }) : null,
|
|
927
|
+
visibleText
|
|
928
|
+
] })
|
|
929
|
+
] }),
|
|
930
|
+
/* @__PURE__ */ jsx(
|
|
931
|
+
"div",
|
|
932
|
+
{
|
|
933
|
+
"data-yunui": "selection-actions-anchor",
|
|
934
|
+
className: "absolute left-0 top-0 z-10",
|
|
935
|
+
style: {
|
|
936
|
+
transform: `translate3d(${anchor.x}px, ${anchor.y}px, 0) translateX(-50%)`,
|
|
937
|
+
transition: "transform 320ms cubic-bezier(0.77,0,0.175,1), opacity 180ms ease-out",
|
|
938
|
+
opacity: positioned ? 1 : 0,
|
|
939
|
+
pointerEvents: positioned ? "auto" : "none",
|
|
940
|
+
willChange: "transform"
|
|
941
|
+
},
|
|
942
|
+
"aria-hidden": !positioned,
|
|
943
|
+
inert: !positioned,
|
|
944
|
+
children: /* @__PURE__ */ jsxs(
|
|
772
945
|
"div",
|
|
773
946
|
{
|
|
774
|
-
|
|
947
|
+
ref: barRef,
|
|
775
948
|
className: cn(
|
|
776
|
-
"
|
|
777
|
-
|
|
778
|
-
)
|
|
779
|
-
}
|
|
780
|
-
),
|
|
781
|
-
option.icon,
|
|
782
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
783
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
784
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium truncate", children: option.label }),
|
|
785
|
-
option.badges
|
|
786
|
-
] }),
|
|
787
|
-
option.detail
|
|
788
|
-
] }),
|
|
789
|
-
option.meta && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1 shrink-0", children: option.meta }),
|
|
790
|
-
isPinnable && /* @__PURE__ */ jsx(
|
|
791
|
-
"button",
|
|
792
|
-
{
|
|
793
|
-
type: "button",
|
|
794
|
-
onClick: (e) => {
|
|
795
|
-
e.stopPropagation();
|
|
796
|
-
onTogglePin();
|
|
797
|
-
},
|
|
798
|
-
className: cn(
|
|
799
|
-
"p-1.5 rounded-md transition-all shrink-0 lg:opacity-0 lg:group-hover:opacity-100",
|
|
800
|
-
pinned ? "text-foreground opacity-100 hover:bg-muted/50" : "text-muted-foreground/40 opacity-60 hover:text-foreground/70 hover:bg-muted/50"
|
|
949
|
+
"flex w-fit max-w-[calc(100vw-48px)] items-center justify-center gap-0.5 rounded-full border border-border bg-card p-1 font-sans text-foreground shadow-lg",
|
|
950
|
+
state === "error" || state === "cancelled" || busy ? "min-h-9" : "h-9 overflow-hidden"
|
|
801
951
|
),
|
|
802
|
-
|
|
803
|
-
children:
|
|
952
|
+
style: maxBarWidth > 0 ? { maxWidth: maxBarWidth } : void 0,
|
|
953
|
+
children: [
|
|
954
|
+
busy ? /* @__PURE__ */ jsxs("span", { role: "status", className: "inline-flex min-w-0 max-w-full items-center gap-1.5 whitespace-normal break-words px-2.5 py-1 text-[12.5px] text-[var(--text-secondary)]", children: [
|
|
955
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "size-3 shrink-0 rounded-full border-[1.5px] border-border border-t-foreground motion-safe:animate-spin" }),
|
|
956
|
+
activity,
|
|
957
|
+
"\u2026"
|
|
958
|
+
] }) : null,
|
|
959
|
+
hasResult ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
960
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "primary", size: "sm", className: "h-7 shrink-0 rounded-full px-2.5 text-[12.5px]", disabled: disabled || !onAccept, onClick: () => {
|
|
961
|
+
if (resultText !== void 0) onAccept?.(resultText);
|
|
962
|
+
}, children: [
|
|
963
|
+
/* @__PURE__ */ jsx(Check, { "aria-hidden": "true", size: 14 }),
|
|
964
|
+
copy.keep
|
|
965
|
+
] }),
|
|
966
|
+
onDismiss ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "h-7 shrink-0 rounded-full px-2.5 text-[12.5px]", disabled, onClick: onDismiss, children: [
|
|
967
|
+
/* @__PURE__ */ jsx(X, { "aria-hidden": "true", size: 14 }),
|
|
968
|
+
copy.discard
|
|
969
|
+
] }) : null,
|
|
970
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mx-0.5 h-4 w-px shrink-0 bg-border" }),
|
|
971
|
+
onRetry ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "size-7 shrink-0 rounded-full p-0", disabled, "aria-label": copy.retry, onClick: onRetry, children: /* @__PURE__ */ jsx(RefreshCw, { "aria-hidden": "true", size: 14 }) }) : null
|
|
972
|
+
] }) : null,
|
|
973
|
+
state === "error" || state === "cancelled" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
974
|
+
/* @__PURE__ */ jsx("span", { role: "status", className: "min-w-0 max-w-[min(18rem,calc(100vw-8rem))] whitespace-normal break-words px-2 py-1 text-[11px] leading-snug text-[var(--text-secondary)]", children: state === "error" ? labels?.error ?? DEFAULT_LABELS2.error : labels?.cancelled ?? DEFAULT_LABELS2.cancelled }),
|
|
975
|
+
onDismiss ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-7 shrink-0 rounded-full px-2.5 text-[12.5px]", disabled, onClick: onDismiss, children: copy.discard }) : null,
|
|
976
|
+
onRetry ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "size-7 shrink-0 rounded-full p-0", disabled, "aria-label": copy.retry, onClick: onRetry, children: /* @__PURE__ */ jsx(RefreshCw, { "aria-hidden": "true", size: 14 }) }) : null
|
|
977
|
+
] }) : null,
|
|
978
|
+
state === "idle" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
979
|
+
/* @__PURE__ */ jsx(
|
|
980
|
+
"div",
|
|
981
|
+
{
|
|
982
|
+
className: "flex min-w-0 items-center overflow-hidden transition-[max-width,opacity,transform] duration-(--dur-slow)",
|
|
983
|
+
"aria-hidden": expanded,
|
|
984
|
+
inert: expanded,
|
|
985
|
+
style: { maxWidth: expanded ? 0 : 145, opacity: expanded ? 0 : 1, transform: expanded ? "translateX(-8px)" : "translateX(0)", transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)" },
|
|
986
|
+
children: /* @__PURE__ */ jsxs("form", { className: "flex h-7 w-[145px] min-w-0 shrink-0 items-center max-[420px]:w-[94px] @max-[360px]/selection:w-[94px]", onSubmit: submitPrompt, children: [
|
|
987
|
+
/* @__PURE__ */ jsx(
|
|
988
|
+
"input",
|
|
989
|
+
{
|
|
990
|
+
value: prompt,
|
|
991
|
+
onChange: (event) => setPrompt(event.target.value),
|
|
992
|
+
"aria-label": copy.placeholder,
|
|
993
|
+
placeholder: copy.placeholder,
|
|
994
|
+
disabled: disabled || !onAction,
|
|
995
|
+
className: "h-7 w-full min-w-0 bg-transparent py-0 pr-2.5 pl-3 text-[12.5px] text-foreground placeholder:text-muted-foreground focus:outline-none max-[420px]:pr-0 max-[420px]:pl-2 @max-[360px]/selection:pr-0 @max-[360px]/selection:pl-2"
|
|
996
|
+
}
|
|
997
|
+
),
|
|
998
|
+
/* @__PURE__ */ jsx("button", { type: "submit", "aria-label": copy.submitInstruction, disabled: disabled || !onAction || !prompt.trim(), className: "mr-1 flex size-6 shrink-0 items-center justify-center rounded-full text-foreground hover:bg-muted disabled:opacity-40", children: /* @__PURE__ */ jsx(ArrowUp, { "aria-hidden": "true", size: 13 }) })
|
|
999
|
+
] })
|
|
1000
|
+
}
|
|
1001
|
+
),
|
|
1002
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mx-1 h-4 w-px shrink-0 bg-border" }),
|
|
1003
|
+
/* @__PURE__ */ jsx(
|
|
1004
|
+
"div",
|
|
1005
|
+
{
|
|
1006
|
+
"data-yunui": "selection-actions-scroll",
|
|
1007
|
+
className: "flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none]",
|
|
1008
|
+
children: (expanded ? actions : actions.slice(0, 2)).map((item) => /* @__PURE__ */ jsxs(
|
|
1009
|
+
Button,
|
|
1010
|
+
{
|
|
1011
|
+
type: "button",
|
|
1012
|
+
variant: "ghost",
|
|
1013
|
+
size: "sm",
|
|
1014
|
+
className: "h-7 shrink-0 rounded-full px-2.5 text-[12px]",
|
|
1015
|
+
disabled: disabled || !onAction,
|
|
1016
|
+
onClick: () => run(item.action ?? item.id),
|
|
1017
|
+
children: [
|
|
1018
|
+
item.icon,
|
|
1019
|
+
item.label ?? item.id
|
|
1020
|
+
]
|
|
1021
|
+
},
|
|
1022
|
+
item.id
|
|
1023
|
+
))
|
|
1024
|
+
}
|
|
1025
|
+
),
|
|
1026
|
+
actions.length > 2 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1027
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mx-0.5 h-4 w-px shrink-0 bg-border" }),
|
|
1028
|
+
/* @__PURE__ */ jsx(
|
|
1029
|
+
"button",
|
|
1030
|
+
{
|
|
1031
|
+
type: "button",
|
|
1032
|
+
"aria-label": expanded ? copy.showFewerActions : copy.showMoreActions,
|
|
1033
|
+
"aria-expanded": expanded,
|
|
1034
|
+
disabled,
|
|
1035
|
+
onClick: () => setExpanded((value) => !value),
|
|
1036
|
+
className: "flex size-7 shrink-0 items-center justify-center rounded-full text-foreground transition-[background-color,transform] hover:bg-muted active:scale-[0.96] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1037
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": "true", size: 14, style: { transform: expanded ? "rotate(180deg)" : void 0 } })
|
|
1038
|
+
}
|
|
1039
|
+
)
|
|
1040
|
+
] }) : null
|
|
1041
|
+
] }) : null
|
|
1042
|
+
]
|
|
804
1043
|
}
|
|
805
1044
|
)
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
);
|
|
809
|
-
}
|
|
1045
|
+
}
|
|
1046
|
+
)
|
|
1047
|
+
] }) });
|
|
1048
|
+
}
|
|
810
1049
|
function ModelManagerCard({
|
|
811
1050
|
icon,
|
|
812
1051
|
name,
|
|
@@ -857,1027 +1096,24 @@ function ModelManagerCard({
|
|
|
857
1096
|
}
|
|
858
1097
|
);
|
|
859
1098
|
}
|
|
860
|
-
var llmCapabilityConfig = [
|
|
861
|
-
{ 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" },
|
|
862
|
-
{ 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" },
|
|
863
|
-
{ value: "function_calling", icon: Code, iconColor: "text-purple-500", color: "bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 hover:bg-purple-500/20" },
|
|
864
|
-
{ value: "vision", icon: Eye, iconColor: "text-amber-500", color: "bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20 hover:bg-amber-500/20" },
|
|
865
|
-
{ value: "thinking", icon: Brain, iconColor: "text-pink-500", color: "bg-pink-500/10 text-pink-600 dark:text-pink-400 border-pink-500/20 hover:bg-pink-500/20" }
|
|
866
|
-
];
|
|
867
|
-
var imageCapabilityConfig = [
|
|
868
|
-
{ value: "image_edit", icon: Pencil, iconColor: "text-orange-500", color: "bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20 hover:bg-orange-500/20" },
|
|
869
|
-
{ value: "negative_prompt", icon: Ban, iconColor: "text-red-500", color: "bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20 hover:bg-red-500/20" },
|
|
870
|
-
{ value: "seed_control", icon: Fingerprint, iconColor: "text-indigo-500", color: "bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20 hover:bg-indigo-500/20" },
|
|
871
|
-
{ value: "lora", icon: Layers, iconColor: "text-teal-500", color: "bg-teal-500/10 text-teal-600 dark:text-teal-400 border-teal-500/20 hover:bg-teal-500/20" },
|
|
872
|
-
{ value: "guidance_scale", icon: SlidersHorizontal, iconColor: "text-yellow-500", color: "bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 hover:bg-yellow-500/20" },
|
|
873
|
-
{ value: "strength", icon: SlidersHorizontal, iconColor: "text-orange-500", color: "bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/20 hover:bg-orange-500/20" },
|
|
874
|
-
{ value: "batch", 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" }
|
|
875
|
-
];
|
|
876
|
-
var audioCapabilityConfig = [
|
|
877
|
-
{ value: "tts", icon: Mic, iconColor: "text-green-500", color: "bg-green-500/10 text-green-600 dark:text-green-400 border-green-500/20 hover:bg-green-500/20" },
|
|
878
|
-
{ value: "stt", 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" },
|
|
879
|
-
{ value: "audio_translation", icon: Waves, iconColor: "text-purple-500", color: "bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20 hover:bg-purple-500/20" }
|
|
880
|
-
];
|
|
881
|
-
var videoCapabilityConfig = [
|
|
882
|
-
{ value: "video_generation", icon: Video, iconColor: "text-red-500", color: "bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20 hover:bg-red-500/20" }
|
|
883
|
-
];
|
|
884
|
-
var musicCapabilityConfig = [
|
|
885
|
-
{ value: "music_generation", icon: Music, iconColor: "text-pink-500", color: "bg-pink-500/10 text-pink-600 dark:text-pink-400 border-pink-500/20 hover:bg-pink-500/20" }
|
|
886
|
-
];
|
|
887
|
-
var threedCapabilityConfig = [
|
|
888
|
-
{ value: "threed_generation", icon: Box, iconColor: "text-indigo-500", color: "bg-indigo-500/10 text-indigo-600 dark:text-indigo-400 border-indigo-500/20 hover:bg-indigo-500/20" }
|
|
889
|
-
];
|
|
890
|
-
var realtimeCapabilityConfig = [
|
|
891
|
-
{ value: "realtime_voice", icon: Radio, iconColor: "text-yellow-500", color: "bg-yellow-500/10 text-yellow-600 dark:text-yellow-400 border-yellow-500/20 hover:bg-yellow-500/20" }
|
|
892
|
-
];
|
|
893
|
-
function CapabilitySelector({ selected, onChange, disabled = false, size = "md", columns = 4, modelType }) {
|
|
894
|
-
const t = useYunUI().useT("capabilities");
|
|
895
|
-
const toggleCapability = (cap) => {
|
|
896
|
-
if (disabled) return;
|
|
897
|
-
onChange(
|
|
898
|
-
selected.includes(cap) ? selected.filter((c) => c !== cap) : [...selected, cap]
|
|
899
|
-
);
|
|
900
|
-
};
|
|
901
|
-
const buildCapabilities = (config) => {
|
|
902
|
-
return config.map((cap) => ({
|
|
903
|
-
...cap,
|
|
904
|
-
label: t(cap.value)
|
|
905
|
-
}));
|
|
906
|
-
};
|
|
907
|
-
const getCapabilities = () => {
|
|
908
|
-
switch (modelType) {
|
|
909
|
-
case "image_generation":
|
|
910
|
-
return buildCapabilities(imageCapabilityConfig);
|
|
911
|
-
case "audio":
|
|
912
|
-
case "tts":
|
|
913
|
-
case "stt":
|
|
914
|
-
return buildCapabilities(audioCapabilityConfig);
|
|
915
|
-
case "video":
|
|
916
|
-
case "video_generation":
|
|
917
|
-
return buildCapabilities(videoCapabilityConfig);
|
|
918
|
-
case "music":
|
|
919
|
-
case "music_generation":
|
|
920
|
-
return buildCapabilities(musicCapabilityConfig);
|
|
921
|
-
case "3d":
|
|
922
|
-
case "threed":
|
|
923
|
-
case "threed_generation":
|
|
924
|
-
return buildCapabilities(threedCapabilityConfig);
|
|
925
|
-
case "realtime":
|
|
926
|
-
case "realtime_voice":
|
|
927
|
-
return buildCapabilities(realtimeCapabilityConfig);
|
|
928
|
-
default:
|
|
929
|
-
return buildCapabilities(llmCapabilityConfig);
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
const capabilityOptions = getCapabilities();
|
|
933
|
-
const sizeClasses = size === "sm" ? "p-2.5 text-xs gap-1.5" : "p-3 text-sm gap-2";
|
|
934
|
-
const iconSize = size === "sm" ? 14 : 16;
|
|
935
|
-
const gridColsClass = {
|
|
936
|
-
1: "grid-cols-1",
|
|
937
|
-
2: "grid-cols-2",
|
|
938
|
-
3: "grid-cols-2 sm:grid-cols-3",
|
|
939
|
-
4: "grid-cols-2 sm:grid-cols-4",
|
|
940
|
-
5: "grid-cols-2 sm:grid-cols-3 lg:grid-cols-5",
|
|
941
|
-
6: "grid-cols-2 sm:grid-cols-3 lg:grid-cols-6"
|
|
942
|
-
}[columns] || "grid-cols-2 sm:grid-cols-3";
|
|
943
|
-
return /* @__PURE__ */ jsx("div", { className: `grid ${gridColsClass} gap-2`, children: capabilityOptions.map((cap) => {
|
|
944
|
-
const isSelected = selected.includes(cap.value);
|
|
945
|
-
const Icon = cap.icon;
|
|
946
|
-
return /* @__PURE__ */ jsxs(
|
|
947
|
-
"button",
|
|
948
|
-
{
|
|
949
|
-
type: "button",
|
|
950
|
-
onClick: () => toggleCapability(cap.value),
|
|
951
|
-
disabled,
|
|
952
|
-
"aria-pressed": isSelected,
|
|
953
|
-
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" : ""}`,
|
|
954
|
-
children: [
|
|
955
|
-
/* @__PURE__ */ jsx(Icon, { size: iconSize, className: `${isSelected ? "" : cap.iconColor} shrink-0` }),
|
|
956
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children: cap.label })
|
|
957
|
-
]
|
|
958
|
-
},
|
|
959
|
-
cap.value
|
|
960
|
-
);
|
|
961
|
-
}) });
|
|
962
|
-
}
|
|
963
|
-
var CAPABILITY_BY_KEY = Object.fromEntries(
|
|
964
|
-
[
|
|
965
|
-
...llmCapabilityConfig,
|
|
966
|
-
...imageCapabilityConfig,
|
|
967
|
-
...audioCapabilityConfig,
|
|
968
|
-
...videoCapabilityConfig,
|
|
969
|
-
...musicCapabilityConfig,
|
|
970
|
-
...threedCapabilityConfig,
|
|
971
|
-
...realtimeCapabilityConfig
|
|
972
|
-
].map((c) => [c.value, c])
|
|
973
|
-
);
|
|
974
|
-
function isKnownCapability(capability) {
|
|
975
|
-
return capability in CAPABILITY_BY_KEY;
|
|
976
|
-
}
|
|
977
|
-
function CapabilityIcon({
|
|
978
|
-
capability,
|
|
979
|
-
size = 14,
|
|
980
|
-
className
|
|
981
|
-
}) {
|
|
982
|
-
const cfg = CAPABILITY_BY_KEY[capability];
|
|
983
|
-
if (!cfg) return null;
|
|
984
|
-
const Icon = cfg.icon;
|
|
985
|
-
return /* @__PURE__ */ jsx(Icon, { size, className: cn(cfg.iconColor, "shrink-0", className) });
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
// src/ai/icon-slugs.generated.ts
|
|
989
|
-
var PROVIDER_ICON_SLUGS = /* @__PURE__ */ new Set([
|
|
990
|
-
"ace",
|
|
991
|
-
"adobe",
|
|
992
|
-
"adobefirefly",
|
|
993
|
-
"agentvoice",
|
|
994
|
-
"agui",
|
|
995
|
-
"ai2",
|
|
996
|
-
"ai21",
|
|
997
|
-
"ai302",
|
|
998
|
-
"ai360",
|
|
999
|
-
"aihubmix",
|
|
1000
|
-
"aimass",
|
|
1001
|
-
"aionlabs",
|
|
1002
|
-
"airjelly",
|
|
1003
|
-
"aistudio",
|
|
1004
|
-
"akashchat",
|
|
1005
|
-
"alephalpha",
|
|
1006
|
-
"alibaba",
|
|
1007
|
-
"alibabacloud",
|
|
1008
|
-
"amp",
|
|
1009
|
-
"antgroup",
|
|
1010
|
-
"anthropic",
|
|
1011
|
-
"antigravity",
|
|
1012
|
-
"anyscale",
|
|
1013
|
-
"apertis",
|
|
1014
|
-
"apple",
|
|
1015
|
-
"arcee",
|
|
1016
|
-
"askverdict",
|
|
1017
|
-
"assemblyai",
|
|
1018
|
-
"atlascloud",
|
|
1019
|
-
"automatic",
|
|
1020
|
-
"aws",
|
|
1021
|
-
"aya",
|
|
1022
|
-
"azure",
|
|
1023
|
-
"azureai",
|
|
1024
|
-
"baai",
|
|
1025
|
-
"baichuan",
|
|
1026
|
-
"baidu",
|
|
1027
|
-
"baiducloud",
|
|
1028
|
-
"bailian",
|
|
1029
|
-
"baseten",
|
|
1030
|
-
"bedrock",
|
|
1031
|
-
"bfl",
|
|
1032
|
-
"bilibili",
|
|
1033
|
-
"bilibiliindex",
|
|
1034
|
-
"bing",
|
|
1035
|
-
"briaai",
|
|
1036
|
-
"burncloud",
|
|
1037
|
-
"bytedance",
|
|
1038
|
-
"capcut",
|
|
1039
|
-
"centml",
|
|
1040
|
-
"cerebras",
|
|
1041
|
-
"chatglm",
|
|
1042
|
-
"cherrystudio",
|
|
1043
|
-
"civitai",
|
|
1044
|
-
"claude",
|
|
1045
|
-
"claudecode",
|
|
1046
|
-
"cline",
|
|
1047
|
-
"clipdrop",
|
|
1048
|
-
"cloudflare",
|
|
1049
|
-
"codebuddy",
|
|
1050
|
-
"codeflicker",
|
|
1051
|
-
"codegeex",
|
|
1052
|
-
"codex",
|
|
1053
|
-
"cogvideo",
|
|
1054
|
-
"cogview",
|
|
1055
|
-
"cohere",
|
|
1056
|
-
"colab",
|
|
1057
|
-
"cometapi",
|
|
1058
|
-
"comfyui",
|
|
1059
|
-
"commanda",
|
|
1060
|
-
"copilot",
|
|
1061
|
-
"copilotkit",
|
|
1062
|
-
"coqui",
|
|
1063
|
-
"coze",
|
|
1064
|
-
"crewai",
|
|
1065
|
-
"crusoe",
|
|
1066
|
-
"cursor",
|
|
1067
|
-
"cybercut",
|
|
1068
|
-
"dalle",
|
|
1069
|
-
"dbrx",
|
|
1070
|
-
"deepai",
|
|
1071
|
-
"deepcogito",
|
|
1072
|
-
"deepinfra",
|
|
1073
|
-
"deepl",
|
|
1074
|
-
"deepmind",
|
|
1075
|
-
"deepseek",
|
|
1076
|
-
"devin",
|
|
1077
|
-
"dify",
|
|
1078
|
-
"doc2x",
|
|
1079
|
-
"docsearch",
|
|
1080
|
-
"dolphin",
|
|
1081
|
-
"doubao",
|
|
1082
|
-
"dreammachine",
|
|
1083
|
-
"elevenlabs",
|
|
1084
|
-
"elevenx",
|
|
1085
|
-
"essentialai",
|
|
1086
|
-
"exa",
|
|
1087
|
-
"fal",
|
|
1088
|
-
"fastgpt",
|
|
1089
|
-
"featherless",
|
|
1090
|
-
"figma",
|
|
1091
|
-
"fireworks",
|
|
1092
|
-
"fishaudio",
|
|
1093
|
-
"flora",
|
|
1094
|
-
"flowith",
|
|
1095
|
-
"flux",
|
|
1096
|
-
"friendli",
|
|
1097
|
-
"gemini",
|
|
1098
|
-
"geminicli",
|
|
1099
|
-
"gemma",
|
|
1100
|
-
"giteeai",
|
|
1101
|
-
"github",
|
|
1102
|
-
"githubcopilot",
|
|
1103
|
-
"glama",
|
|
1104
|
-
"glif",
|
|
1105
|
-
"glmv",
|
|
1106
|
-
"google",
|
|
1107
|
-
"googlecloud",
|
|
1108
|
-
"goose",
|
|
1109
|
-
"gradio",
|
|
1110
|
-
"greptile",
|
|
1111
|
-
"grok",
|
|
1112
|
-
"groq",
|
|
1113
|
-
"hailuo",
|
|
1114
|
-
"haiper",
|
|
1115
|
-
"hedra",
|
|
1116
|
-
"hermesagent",
|
|
1117
|
-
"higress",
|
|
1118
|
-
"huawei",
|
|
1119
|
-
"huaweicloud",
|
|
1120
|
-
"huggingface",
|
|
1121
|
-
"hunyuan",
|
|
1122
|
-
"hyperbolic",
|
|
1123
|
-
"ibm",
|
|
1124
|
-
"ideogram",
|
|
1125
|
-
"iflytekcloud",
|
|
1126
|
-
"inception",
|
|
1127
|
-
"inference",
|
|
1128
|
-
"infermatic",
|
|
1129
|
-
"infinigence",
|
|
1130
|
-
"inflection",
|
|
1131
|
-
"internlm",
|
|
1132
|
-
"jimeng",
|
|
1133
|
-
"jina",
|
|
1134
|
-
"junie",
|
|
1135
|
-
"kilocode",
|
|
1136
|
-
"kimi",
|
|
1137
|
-
"kiro",
|
|
1138
|
-
"kling",
|
|
1139
|
-
"kluster",
|
|
1140
|
-
"kolors",
|
|
1141
|
-
"krea",
|
|
1142
|
-
"kwaikat",
|
|
1143
|
-
"kwaipilot",
|
|
1144
|
-
"lambda",
|
|
1145
|
-
"langchain",
|
|
1146
|
-
"langfuse",
|
|
1147
|
-
"langgraph",
|
|
1148
|
-
"langsmith",
|
|
1149
|
-
"leptonai",
|
|
1150
|
-
"lg",
|
|
1151
|
-
"lightricks",
|
|
1152
|
-
"liquid",
|
|
1153
|
-
"livekit",
|
|
1154
|
-
"llamaindex",
|
|
1155
|
-
"llava",
|
|
1156
|
-
"llmapi",
|
|
1157
|
-
"lmstudio",
|
|
1158
|
-
"lobehub",
|
|
1159
|
-
"longcat",
|
|
1160
|
-
"lovable",
|
|
1161
|
-
"lovart",
|
|
1162
|
-
"luma",
|
|
1163
|
-
"magic",
|
|
1164
|
-
"make",
|
|
1165
|
-
"manus",
|
|
1166
|
-
"mastra",
|
|
1167
|
-
"mcp",
|
|
1168
|
-
"mcpso",
|
|
1169
|
-
"menlo",
|
|
1170
|
-
"meshy",
|
|
1171
|
-
"meta",
|
|
1172
|
-
"metaai",
|
|
1173
|
-
"metagpt",
|
|
1174
|
-
"microsoft",
|
|
1175
|
-
"midjourney",
|
|
1176
|
-
"minimax",
|
|
1177
|
-
"mistral",
|
|
1178
|
-
"modelscope",
|
|
1179
|
-
"monica",
|
|
1180
|
-
"moonshot",
|
|
1181
|
-
"morph",
|
|
1182
|
-
"moxt",
|
|
1183
|
-
"myshell",
|
|
1184
|
-
"n8n",
|
|
1185
|
-
"nanobanana",
|
|
1186
|
-
"nebius",
|
|
1187
|
-
"newapi",
|
|
1188
|
-
"notebooklm",
|
|
1189
|
-
"notion",
|
|
1190
|
-
"nousresearch",
|
|
1191
|
-
"nova",
|
|
1192
|
-
"novelai",
|
|
1193
|
-
"novita",
|
|
1194
|
-
"nplcloud",
|
|
1195
|
-
"nvidia",
|
|
1196
|
-
"obsidian",
|
|
1197
|
-
"ollama",
|
|
1198
|
-
"openai",
|
|
1199
|
-
"openchat",
|
|
1200
|
-
"openclaw",
|
|
1201
|
-
"opencode",
|
|
1202
|
-
"openhands",
|
|
1203
|
-
"openhuman",
|
|
1204
|
-
"openrouter",
|
|
1205
|
-
"openwebui",
|
|
1206
|
-
"palm",
|
|
1207
|
-
"parasail",
|
|
1208
|
-
"perplexity",
|
|
1209
|
-
"phidata",
|
|
1210
|
-
"phind",
|
|
1211
|
-
"pika",
|
|
1212
|
-
"pixverse",
|
|
1213
|
-
"player2",
|
|
1214
|
-
"poe",
|
|
1215
|
-
"pollinations",
|
|
1216
|
-
"ppio",
|
|
1217
|
-
"prunaai",
|
|
1218
|
-
"pydanticai",
|
|
1219
|
-
"qingyan",
|
|
1220
|
-
"qiniu",
|
|
1221
|
-
"qoder",
|
|
1222
|
-
"qwen",
|
|
1223
|
-
"railway",
|
|
1224
|
-
"recraft",
|
|
1225
|
-
"relace",
|
|
1226
|
-
"replicate",
|
|
1227
|
-
"replit",
|
|
1228
|
-
"reve",
|
|
1229
|
-
"roocode",
|
|
1230
|
-
"rsshub",
|
|
1231
|
-
"runway",
|
|
1232
|
-
"rwkv",
|
|
1233
|
-
"sambanova",
|
|
1234
|
-
"search1api",
|
|
1235
|
-
"searchapi",
|
|
1236
|
-
"sensenova",
|
|
1237
|
-
"siliconcloud",
|
|
1238
|
-
"sillytavern",
|
|
1239
|
-
"skywork",
|
|
1240
|
-
"slock",
|
|
1241
|
-
"smithery",
|
|
1242
|
-
"snowflake",
|
|
1243
|
-
"sophnet",
|
|
1244
|
-
"sora",
|
|
1245
|
-
"spark",
|
|
1246
|
-
"speedai",
|
|
1247
|
-
"stability",
|
|
1248
|
-
"statecloud",
|
|
1249
|
-
"stepfun",
|
|
1250
|
-
"straico",
|
|
1251
|
-
"streamlake",
|
|
1252
|
-
"submodel",
|
|
1253
|
-
"suno",
|
|
1254
|
-
"sync",
|
|
1255
|
-
"targon",
|
|
1256
|
-
"tavily",
|
|
1257
|
-
"tencent",
|
|
1258
|
-
"tencentcloud",
|
|
1259
|
-
"tiangong",
|
|
1260
|
-
"tii",
|
|
1261
|
-
"together",
|
|
1262
|
-
"topazlabs",
|
|
1263
|
-
"trae",
|
|
1264
|
-
"tripo",
|
|
1265
|
-
"turix",
|
|
1266
|
-
"udio",
|
|
1267
|
-
"unstructured",
|
|
1268
|
-
"upstage",
|
|
1269
|
-
"v0",
|
|
1270
|
-
"vectorizerai",
|
|
1271
|
-
"venice",
|
|
1272
|
-
"vercel",
|
|
1273
|
-
"vertexai",
|
|
1274
|
-
"vidu",
|
|
1275
|
-
"viggle",
|
|
1276
|
-
"vllm",
|
|
1277
|
-
"volcengine",
|
|
1278
|
-
"voyage",
|
|
1279
|
-
"wenxin",
|
|
1280
|
-
"windsurf",
|
|
1281
|
-
"workersai",
|
|
1282
|
-
"worldrouter",
|
|
1283
|
-
"xai",
|
|
1284
|
-
"xiaomimimo",
|
|
1285
|
-
"xinference",
|
|
1286
|
-
"xpay",
|
|
1287
|
-
"xuanyuan",
|
|
1288
|
-
"yandex",
|
|
1289
|
-
"yi",
|
|
1290
|
-
"youmind",
|
|
1291
|
-
"yuanbao",
|
|
1292
|
-
"zai",
|
|
1293
|
-
"zapier",
|
|
1294
|
-
"zeabur",
|
|
1295
|
-
"zencoder",
|
|
1296
|
-
"zenmux",
|
|
1297
|
-
"zeroone",
|
|
1298
|
-
"zhipu"
|
|
1299
|
-
]);
|
|
1300
|
-
var developerIconMap = {
|
|
1301
|
-
// Major AI companies
|
|
1302
|
-
openai: "openai.webp",
|
|
1303
|
-
anthropic: "anthropic.webp",
|
|
1304
|
-
google: "google.webp",
|
|
1305
|
-
gemini: "gemini.webp",
|
|
1306
|
-
gemma: "gemma.webp",
|
|
1307
|
-
"deepseek": "deepseek.webp",
|
|
1308
|
-
qwen: "qwen.webp",
|
|
1309
|
-
mistral: "mistral.webp",
|
|
1310
|
-
"01.ai": "zero-one.webp",
|
|
1311
|
-
"zero-one": "zero-one.webp",
|
|
1312
|
-
xai: "grok.webp",
|
|
1313
|
-
// Chinese companies
|
|
1314
|
-
zhipu: "zhipu.webp",
|
|
1315
|
-
moonshot: "moonshot.webp",
|
|
1316
|
-
baichuan: "baichuan.webp",
|
|
1317
|
-
alibaba: "dashscope.png",
|
|
1318
|
-
minimax: "minimax.webp",
|
|
1319
|
-
volcengine: "volcengine.webp",
|
|
1320
|
-
bytedance: "byte_dance.webp",
|
|
1321
|
-
baidu: "wenxin.webp",
|
|
1322
|
-
// baidu-cloud.svg only exists under /icons/providers/; ERNIE/Wenxin icon lives in /icons/models/
|
|
1323
|
-
tencent: "dianxin.png",
|
|
1324
|
-
doubao: "doubao.webp",
|
|
1325
|
-
hunyuan: "hunyuan.webp",
|
|
1326
|
-
sparkdesk: "sparkdesk.webp",
|
|
1327
|
-
wenxin: "wenxin.webp",
|
|
1328
|
-
stepfun: "step.webp",
|
|
1329
|
-
// Research organizations
|
|
1330
|
-
ai21: "ai21.webp",
|
|
1331
|
-
adept: "adept.png",
|
|
1332
|
-
aisingapore: "aisingapore.png",
|
|
1333
|
-
bigcode: "bigcode.webp",
|
|
1334
|
-
codegeex: "codegeex.webp",
|
|
1335
|
-
cohere: "cohere.webp",
|
|
1336
|
-
dbrx: "dbrx.webp",
|
|
1337
|
-
gryphe: "gryphe.png",
|
|
1338
|
-
hailuo: "hailuo.webp",
|
|
1339
|
-
internlm: "internlm.webp",
|
|
1340
|
-
jina: "jina.webp",
|
|
1341
|
-
nvidia: "nvidia.webp",
|
|
1342
|
-
rakutenai: "rakutenai.png",
|
|
1343
|
-
upstage: "upstage.webp",
|
|
1344
|
-
voyageai: "voyageai.webp",
|
|
1345
|
-
xirang: "xirang.png",
|
|
1346
|
-
yi: "zero-one.webp",
|
|
1347
|
-
zai: "zai.webp",
|
|
1348
|
-
// Image/Audio/Video models
|
|
1349
|
-
chatgpt: "chatgpt.jpeg",
|
|
1350
|
-
dalle: "dalle.webp",
|
|
1351
|
-
flux: "flux.webp",
|
|
1352
|
-
ideogram: "ideogram.webp",
|
|
1353
|
-
keling: "keling.png",
|
|
1354
|
-
luma: "luma.webp",
|
|
1355
|
-
midjourney: "midjourney.webp",
|
|
1356
|
-
stability: "stability.webp",
|
|
1357
|
-
suno: "suno.webp",
|
|
1358
|
-
vidu: "vidu.webp",
|
|
1359
|
-
tokenflux: "tokenflux.png",
|
|
1360
|
-
// Other
|
|
1361
|
-
huggingface: "huggingface.webp",
|
|
1362
|
-
meta: "llama.png",
|
|
1363
|
-
facebook: "llama.png",
|
|
1364
|
-
// no meta.png under /icons/models/; Meta/Facebook family uses the Llama icon
|
|
1365
|
-
microsoft: "microsoft.webp",
|
|
1366
|
-
ibm: "ibm.webp",
|
|
1367
|
-
github: "copilot.webp",
|
|
1368
|
-
tele: "tele.png",
|
|
1369
|
-
ling: "ling.png",
|
|
1370
|
-
mimo: "mimo.svg",
|
|
1371
|
-
pangu: "pangu.svg",
|
|
1372
|
-
xiaomi: "xiaomi.png",
|
|
1373
|
-
// Model-family icons with dedicated art under /icons/models/
|
|
1374
|
-
claude: "claude.webp",
|
|
1375
|
-
codestral: "codestral.png",
|
|
1376
|
-
mixtral: "mixtral.png",
|
|
1377
|
-
pixtral: "pixtral.png",
|
|
1378
|
-
llava: "llava.webp",
|
|
1379
|
-
palm: "palm.webp",
|
|
1380
|
-
chatglm: "chatglm.webp",
|
|
1381
|
-
internvl: "internvl.png",
|
|
1382
|
-
minicpm: "minicpm.webp",
|
|
1383
|
-
nousresearch: "nousresearch.webp"
|
|
1384
|
-
};
|
|
1385
|
-
var modelDeveloperPatterns = [
|
|
1386
|
-
[/claude|anthropic/, "claude"],
|
|
1387
|
-
[/gemini/, "gemini"],
|
|
1388
|
-
[/gemma/, "gemma"],
|
|
1389
|
-
[/palm|bison/, "palm"],
|
|
1390
|
-
[/gpt|openai|davinci|chatgpt|text-embedding|dall-?e|whisper|codex|o[134]-/, "openai"],
|
|
1391
|
-
[/glm|chatglm|zhipu|z\.?ai/, "zai"],
|
|
1392
|
-
[/minimax|hailuo|abab/, "minimax"],
|
|
1393
|
-
[/qwen|qwq|dashscope|alibaba|tongyi/, "qwen"],
|
|
1394
|
-
[/deepseek/, "deepseek"],
|
|
1395
|
-
[/llama|meta-/, "meta"],
|
|
1396
|
-
[/mistral|mixtral|codestral|pixtral|magistral|ministral/, "mistral"],
|
|
1397
|
-
[/grok|x-?ai/, "xai"],
|
|
1398
|
-
[/moonshot|kimi/, "moonshot"],
|
|
1399
|
-
[/doubao/, "doubao"],
|
|
1400
|
-
[/hunyuan/, "hunyuan"],
|
|
1401
|
-
[/ernie|wenxin|baidu/, "wenxin"],
|
|
1402
|
-
[/step-|stepfun/, "stepfun"],
|
|
1403
|
-
[/yi-|zero-one|01-ai/, "yi"],
|
|
1404
|
-
[/command|cohere/, "cohere"],
|
|
1405
|
-
[/phi-\d|microsoft/, "microsoft"],
|
|
1406
|
-
[/nemotron|nvidia/, "nvidia"],
|
|
1407
|
-
[/internlm|internvl/, "internlm"],
|
|
1408
|
-
[/flux/, "flux"]
|
|
1409
|
-
];
|
|
1410
|
-
function getModelDeveloperId(...identifiers) {
|
|
1411
|
-
const haystack = identifiers.filter(Boolean).join(" ").toLowerCase();
|
|
1412
|
-
for (const [pattern, developer] of modelDeveloperPatterns) {
|
|
1413
|
-
if (pattern.test(haystack)) return developer;
|
|
1414
|
-
}
|
|
1415
|
-
const first = identifiers.find((value) => Boolean(value));
|
|
1416
|
-
if (!first) return "";
|
|
1417
|
-
const parts = first.split("/").filter(Boolean);
|
|
1418
|
-
return parts.at(-1) || first;
|
|
1419
|
-
}
|
|
1420
|
-
function getDeveloperIconPath(developer) {
|
|
1421
|
-
if (!developer) return null;
|
|
1422
|
-
const file = getDeveloperIconFile(developer);
|
|
1423
|
-
return file ? `/icons/models/${file}` : null;
|
|
1424
|
-
}
|
|
1425
|
-
function getDeveloperIconFile(developer) {
|
|
1426
|
-
if (!developer) return null;
|
|
1427
|
-
const normalized = developer.toLowerCase().replace(/[-_\s]/g, "");
|
|
1428
|
-
if (developerIconMap[normalized]) {
|
|
1429
|
-
return developerIconMap[normalized];
|
|
1430
|
-
}
|
|
1431
|
-
let best = null;
|
|
1432
|
-
for (const [key, file] of Object.entries(developerIconMap)) {
|
|
1433
|
-
if (key.length >= 3 && normalized.includes(key) && (!best || key.length > best.key.length)) {
|
|
1434
|
-
best = { key, file };
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
if (best) return best.file;
|
|
1438
|
-
return null;
|
|
1439
|
-
}
|
|
1440
|
-
var providerIconMap = {
|
|
1441
|
-
// Major providers
|
|
1442
|
-
openai: "openai.webp",
|
|
1443
|
-
anthropic: "anthropic.webp",
|
|
1444
|
-
google: "google.webp",
|
|
1445
|
-
gemini: "gemini.webp",
|
|
1446
|
-
deepseek: "deepseek.webp",
|
|
1447
|
-
mistral: "mistral.webp",
|
|
1448
|
-
groq: "groq.webp",
|
|
1449
|
-
grok: "grok.webp",
|
|
1450
|
-
xai: "grok.webp",
|
|
1451
|
-
// Cloud providers
|
|
1452
|
-
azure: "azure.webp",
|
|
1453
|
-
"azure-openai": "azure.webp",
|
|
1454
|
-
aws: "aws.webp",
|
|
1455
|
-
bedrock: "bedrock.webp",
|
|
1456
|
-
// Chinese providers
|
|
1457
|
-
zhipu: "zhipu.webp",
|
|
1458
|
-
moonshot: "moonshot.webp",
|
|
1459
|
-
baichuan: "baichuan.webp",
|
|
1460
|
-
alibaba: "dashscope.png",
|
|
1461
|
-
qwen: "dashscope.png",
|
|
1462
|
-
dashscope: "dashscope.png",
|
|
1463
|
-
minimax: "minimax.webp",
|
|
1464
|
-
volcengine: "volcengine.webp",
|
|
1465
|
-
doubao: "doubao.webp",
|
|
1466
|
-
bytedance: "bytedance.webp",
|
|
1467
|
-
baidu: "baidu-cloud.webp",
|
|
1468
|
-
// Other providers
|
|
1469
|
-
nvidia: "nvidia.webp",
|
|
1470
|
-
huggingface: "huggingface.webp",
|
|
1471
|
-
ollama: "ollama.webp",
|
|
1472
|
-
lmstudio: "lmstudio.webp",
|
|
1473
|
-
openrouter: "openrouter.webp",
|
|
1474
|
-
tokenrouter: "tokenrouter.png",
|
|
1475
|
-
together: "together.webp",
|
|
1476
|
-
cohere: "cohere.webp",
|
|
1477
|
-
perplexity: "perplexity.webp",
|
|
1478
|
-
fireworks: "fireworks.webp",
|
|
1479
|
-
github: "github.webp",
|
|
1480
|
-
jina: "jina.webp",
|
|
1481
|
-
modelscope: "modelscope.webp",
|
|
1482
|
-
siliconflow: "silicon.webp",
|
|
1483
|
-
silicon: "silicon.webp",
|
|
1484
|
-
cerebras: "cerebras.webp",
|
|
1485
|
-
hyperbolic: "hyperbolic.webp",
|
|
1486
|
-
lepton: "lepton.png",
|
|
1487
|
-
cloudflare: "cloudflare.webp",
|
|
1488
|
-
vllm: "vllm.webp",
|
|
1489
|
-
zai: "zai.webp",
|
|
1490
|
-
// Image/special
|
|
1491
|
-
step: "step.webp",
|
|
1492
|
-
"zero-one": "zero-one.webp",
|
|
1493
|
-
yi: "zero-one.webp",
|
|
1494
|
-
infini: "infini.webp",
|
|
1495
|
-
// Additional providers / gateways with icons under /icons/providers/.
|
|
1496
|
-
// Keys are normalized (lowercase, separators stripped) to match getIconPath().
|
|
1497
|
-
xiaomi: "Xiaomi.png",
|
|
1498
|
-
intel: "intel.png",
|
|
1499
|
-
nomic: "nomic.png",
|
|
1500
|
-
mixedbread: "mixedbread.png",
|
|
1501
|
-
lanyun: "lanyun.png",
|
|
1502
|
-
newapi: "newapi.webp",
|
|
1503
|
-
ocoolai: "ocoolai.png",
|
|
1504
|
-
ph8: "ph8.png",
|
|
1505
|
-
ppio: "ppio.webp",
|
|
1506
|
-
vertexai: "vertexai.webp",
|
|
1507
|
-
gcp: "vertexai.webp",
|
|
1508
|
-
"302ai": "302ai.webp",
|
|
1509
|
-
aihubmix: "aihubmix.webp",
|
|
1510
|
-
dmxapi: "DMXAPI.png",
|
|
1511
|
-
bailian: "bailian.webp",
|
|
1512
|
-
bigmodel: "bigModel.webp",
|
|
1513
|
-
burncloud: "burncloud.webp",
|
|
1514
|
-
cherryin: "cherryin.png",
|
|
1515
|
-
giteeai: "gitee-ai.webp",
|
|
1516
|
-
qiniu: "qiniu.webp",
|
|
1517
|
-
sophnet: "sophnet.webp",
|
|
1518
|
-
longcat: "longcat.webp",
|
|
1519
|
-
alayanew: "alayanew.webp",
|
|
1520
|
-
cephalon: "cephalon.jpeg",
|
|
1521
|
-
mcprouter: "mcprouter.webp",
|
|
1522
|
-
gpustack: "gpustack.svg",
|
|
1523
|
-
kwaipilot: "Kwaipilot.webp",
|
|
1524
|
-
tencentcloudti: "tencent-cloud-ti.webp",
|
|
1525
|
-
neteaseyoudao: "netease-youdao.svg",
|
|
1526
|
-
aionly: "aiOnly.webp"
|
|
1527
|
-
};
|
|
1528
|
-
function getProviderIconOptions() {
|
|
1529
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1530
|
-
const out = [];
|
|
1531
|
-
for (const [key, file] of Object.entries(providerIconMap)) {
|
|
1532
|
-
if (seen.has(file)) continue;
|
|
1533
|
-
seen.add(file);
|
|
1534
|
-
out.push({ value: `/icons/providers/${file}`, label: key });
|
|
1535
|
-
}
|
|
1536
|
-
return out.sort((a, b) => a.label.localeCompare(b.label));
|
|
1537
|
-
}
|
|
1538
|
-
function normalizeProviderId(id) {
|
|
1539
|
-
return (id ?? "").toLowerCase().replace(/[-_\s]/g, "");
|
|
1540
|
-
}
|
|
1541
|
-
function getIconPath(providerId) {
|
|
1542
|
-
const normalized = normalizeProviderId(providerId);
|
|
1543
|
-
if (!normalized) return null;
|
|
1544
|
-
if (providerIconMap[normalized]) {
|
|
1545
|
-
return `/icons/providers/${providerIconMap[normalized]}`;
|
|
1546
|
-
}
|
|
1547
|
-
if (PROVIDER_ICON_SLUGS.has(normalized)) {
|
|
1548
|
-
return `/icons/providers/${normalized}.webp`;
|
|
1549
|
-
}
|
|
1550
|
-
let best = null;
|
|
1551
|
-
for (const [key, file] of Object.entries(providerIconMap)) {
|
|
1552
|
-
if (key.length >= 3 && normalized.includes(key) && (!best || key.length > best.key.length)) {
|
|
1553
|
-
best = { key, file };
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
if (best) return `/icons/providers/${best.file}`;
|
|
1557
|
-
return null;
|
|
1558
|
-
}
|
|
1559
|
-
function applyIconBase(path, base) {
|
|
1560
|
-
if (!path || base === "/icons") return path;
|
|
1561
|
-
return path.startsWith("/icons/") ? base + path.slice(6) : path;
|
|
1562
|
-
}
|
|
1563
|
-
function ProviderIcon({
|
|
1564
|
-
provider,
|
|
1565
|
-
className = "",
|
|
1566
|
-
size = 20,
|
|
1567
|
-
rounded = false,
|
|
1568
|
-
iconUrl
|
|
1569
|
-
}) {
|
|
1570
|
-
const { Image, iconBasePath } = useYunUI();
|
|
1571
|
-
const [customError, setCustomError] = useState(false);
|
|
1572
|
-
const [pathError, setPathError] = useState(false);
|
|
1573
|
-
const effectiveIconUrl = iconUrl;
|
|
1574
|
-
if (effectiveIconUrl && !customError) {
|
|
1575
|
-
if (rounded) {
|
|
1576
|
-
const getRadius = () => size <= 14 ? "rounded-sm" : size <= 20 ? "rounded-md" : "rounded-lg";
|
|
1577
|
-
return /* @__PURE__ */ jsx(
|
|
1578
|
-
"div",
|
|
1579
|
-
{
|
|
1580
|
-
className: `${getRadius()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
|
|
1581
|
-
style: { width: size, height: size },
|
|
1582
|
-
children: /* @__PURE__ */ jsx("img", { src: effectiveIconUrl, alt: provider, width: size, height: size, className: "object-cover", onError: () => setCustomError(true) })
|
|
1583
|
-
}
|
|
1584
|
-
);
|
|
1585
|
-
}
|
|
1586
|
-
return /* @__PURE__ */ jsx("img", { src: effectiveIconUrl, alt: provider, width: size, height: size, className: `object-contain ${className}`, onError: () => setCustomError(true) });
|
|
1587
|
-
}
|
|
1588
|
-
const iconPath = applyIconBase(getIconPath(provider), iconBasePath);
|
|
1589
|
-
const getRadiusClass = () => {
|
|
1590
|
-
if (size <= 14) return "rounded-sm";
|
|
1591
|
-
if (size <= 20) return "rounded-md";
|
|
1592
|
-
return "rounded-lg";
|
|
1593
|
-
};
|
|
1594
|
-
if (iconPath && !pathError) {
|
|
1595
|
-
if (rounded) {
|
|
1596
|
-
return /* @__PURE__ */ jsx(
|
|
1597
|
-
"div",
|
|
1598
|
-
{
|
|
1599
|
-
className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
|
|
1600
|
-
style: { width: size, height: size },
|
|
1601
|
-
children: /* @__PURE__ */ jsx(
|
|
1602
|
-
Image,
|
|
1603
|
-
{
|
|
1604
|
-
src: iconPath,
|
|
1605
|
-
alt: provider,
|
|
1606
|
-
width: size,
|
|
1607
|
-
height: size,
|
|
1608
|
-
className: "object-cover",
|
|
1609
|
-
unoptimized: true,
|
|
1610
|
-
onError: () => setPathError(true)
|
|
1611
|
-
}
|
|
1612
|
-
)
|
|
1613
|
-
}
|
|
1614
|
-
);
|
|
1615
|
-
}
|
|
1616
|
-
return /* @__PURE__ */ jsx(
|
|
1617
|
-
Image,
|
|
1618
|
-
{
|
|
1619
|
-
src: iconPath,
|
|
1620
|
-
alt: provider,
|
|
1621
|
-
width: size,
|
|
1622
|
-
height: size,
|
|
1623
|
-
className: `object-contain ${className}`,
|
|
1624
|
-
unoptimized: true,
|
|
1625
|
-
onError: () => setPathError(true)
|
|
1626
|
-
}
|
|
1627
|
-
);
|
|
1628
|
-
}
|
|
1629
|
-
if (rounded) {
|
|
1630
|
-
return /* @__PURE__ */ jsx(
|
|
1631
|
-
"div",
|
|
1632
|
-
{
|
|
1633
|
-
className: `${getRadiusClass()} bg-muted flex items-center justify-center ${className}`,
|
|
1634
|
-
style: { width: size, height: size },
|
|
1635
|
-
children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: (provider || "?").charAt(0).toUpperCase() })
|
|
1636
|
-
}
|
|
1637
|
-
);
|
|
1638
|
-
}
|
|
1639
|
-
return /* @__PURE__ */ jsxs(
|
|
1640
|
-
"svg",
|
|
1641
|
-
{
|
|
1642
|
-
className,
|
|
1643
|
-
width: size,
|
|
1644
|
-
height: size,
|
|
1645
|
-
viewBox: "0 0 24 24",
|
|
1646
|
-
fill: "none",
|
|
1647
|
-
stroke: "currentColor",
|
|
1648
|
-
strokeWidth: "2",
|
|
1649
|
-
children: [
|
|
1650
|
-
/* @__PURE__ */ jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "3" }),
|
|
1651
|
-
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
1652
|
-
]
|
|
1653
|
-
}
|
|
1654
|
-
);
|
|
1655
|
-
}
|
|
1656
|
-
function ProviderAvatar({
|
|
1657
|
-
provider,
|
|
1658
|
-
size = 32,
|
|
1659
|
-
className = ""
|
|
1660
|
-
}) {
|
|
1661
|
-
return /* @__PURE__ */ jsx(ProviderIcon, { provider, size, rounded: true, className });
|
|
1662
|
-
}
|
|
1663
|
-
var ProviderNames = {
|
|
1664
|
-
openai: "OpenAI",
|
|
1665
|
-
anthropic: "Anthropic",
|
|
1666
|
-
google: "Google",
|
|
1667
|
-
gemini: "Gemini",
|
|
1668
|
-
deepseek: "DeepSeek",
|
|
1669
|
-
mistral: "Mistral",
|
|
1670
|
-
xai: "xAI",
|
|
1671
|
-
grok: "Grok",
|
|
1672
|
-
groq: "Groq",
|
|
1673
|
-
azure: "Azure",
|
|
1674
|
-
"azure-openai": "Azure OpenAI",
|
|
1675
|
-
aws: "AWS",
|
|
1676
|
-
bedrock: "Bedrock",
|
|
1677
|
-
nvidia: "NVIDIA",
|
|
1678
|
-
zhipu: "Zhipu",
|
|
1679
|
-
moonshot: "Moonshot",
|
|
1680
|
-
alibaba: "Alibaba",
|
|
1681
|
-
qwen: "Qwen",
|
|
1682
|
-
dashscope: "DashScope",
|
|
1683
|
-
minimax: "MiniMax",
|
|
1684
|
-
volcengine: "Volcengine",
|
|
1685
|
-
doubao: "Doubao",
|
|
1686
|
-
bytedance: "ByteDance",
|
|
1687
|
-
baidu: "Baidu",
|
|
1688
|
-
baichuan: "Baichuan",
|
|
1689
|
-
yi: "Yi",
|
|
1690
|
-
openrouter: "OpenRouter",
|
|
1691
|
-
tokenrouter: "TokenRouter",
|
|
1692
|
-
huggingface: "HuggingFace",
|
|
1693
|
-
ollama: "Ollama",
|
|
1694
|
-
lmstudio: "LM Studio",
|
|
1695
|
-
together: "Together",
|
|
1696
|
-
cohere: "Cohere",
|
|
1697
|
-
perplexity: "Perplexity",
|
|
1698
|
-
fireworks: "Fireworks",
|
|
1699
|
-
github: "GitHub Models",
|
|
1700
|
-
jina: "Jina",
|
|
1701
|
-
modelscope: "ModelScope",
|
|
1702
|
-
siliconflow: "SiliconFlow",
|
|
1703
|
-
silicon: "SiliconFlow",
|
|
1704
|
-
cerebras: "Cerebras",
|
|
1705
|
-
hyperbolic: "Hyperbolic",
|
|
1706
|
-
lepton: "Lepton",
|
|
1707
|
-
step: "Step",
|
|
1708
|
-
infini: "Infini",
|
|
1709
|
-
cloudflare: "Cloudflare",
|
|
1710
|
-
vllm: "vLLM",
|
|
1711
|
-
zai: "Z.ai",
|
|
1712
|
-
// Additional providers / gateways
|
|
1713
|
-
xiaomi: "Xiaomi",
|
|
1714
|
-
intel: "Intel",
|
|
1715
|
-
nomic: "Nomic",
|
|
1716
|
-
mixedbread: "Mixedbread",
|
|
1717
|
-
lanyun: "Lanyun",
|
|
1718
|
-
newapi: "New API",
|
|
1719
|
-
ocoolai: "OCoolAI",
|
|
1720
|
-
ph8: "PH8",
|
|
1721
|
-
ppio: "PPIO",
|
|
1722
|
-
vertexai: "Vertex AI",
|
|
1723
|
-
gcp: "Vertex AI",
|
|
1724
|
-
"302ai": "302.AI",
|
|
1725
|
-
aihubmix: "AiHubMix",
|
|
1726
|
-
dmxapi: "DMXAPI",
|
|
1727
|
-
bailian: "Bailian",
|
|
1728
|
-
bigmodel: "BigModel",
|
|
1729
|
-
burncloud: "BurnCloud",
|
|
1730
|
-
cherryin: "CherryIN",
|
|
1731
|
-
giteeai: "Gitee AI",
|
|
1732
|
-
qiniu: "Qiniu",
|
|
1733
|
-
sophnet: "SophNet",
|
|
1734
|
-
longcat: "LongCat",
|
|
1735
|
-
alayanew: "AlayaNew",
|
|
1736
|
-
cephalon: "Cephalon",
|
|
1737
|
-
mcprouter: "MCP Router",
|
|
1738
|
-
gpustack: "GPUStack",
|
|
1739
|
-
kwaipilot: "Kwaipilot",
|
|
1740
|
-
tencentcloudti: "Tencent Cloud TI",
|
|
1741
|
-
neteaseyoudao: "NetEase Youdao",
|
|
1742
|
-
aionly: "AiOnly"
|
|
1743
|
-
};
|
|
1744
|
-
function getProviderName(providerId) {
|
|
1745
|
-
if (!providerId) return "";
|
|
1746
|
-
const normalized = providerId.toLowerCase().replace(/[-_\s]/g, "");
|
|
1747
|
-
if (ProviderNames[normalized]) return ProviderNames[normalized];
|
|
1748
|
-
let best = null;
|
|
1749
|
-
for (const [key, name] of Object.entries(ProviderNames)) {
|
|
1750
|
-
if (key.length >= 3 && normalized.includes(key) && (!best || key.length > best.key.length)) {
|
|
1751
|
-
best = { key, name };
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
if (best) return best.name;
|
|
1755
|
-
return providerId.charAt(0).toUpperCase() + providerId.slice(1);
|
|
1756
|
-
}
|
|
1757
|
-
function getProxiedImageUrl(url) {
|
|
1758
|
-
return url;
|
|
1759
|
-
}
|
|
1760
|
-
function ModelIcon({
|
|
1761
|
-
iconUrl,
|
|
1762
|
-
developer,
|
|
1763
|
-
provider,
|
|
1764
|
-
className = "",
|
|
1765
|
-
size = 20,
|
|
1766
|
-
rounded = false
|
|
1767
|
-
}) {
|
|
1768
|
-
const { Image, iconBasePath } = useYunUI();
|
|
1769
|
-
const [failedPriority, setFailedPriority] = useState(0);
|
|
1770
|
-
const getRadiusClass = () => {
|
|
1771
|
-
if (size <= 14) return "rounded-sm";
|
|
1772
|
-
if (size <= 20) return "rounded-md";
|
|
1773
|
-
return "rounded-lg";
|
|
1774
|
-
};
|
|
1775
|
-
if (failedPriority < 1 && iconUrl && iconUrl.trim()) {
|
|
1776
|
-
const src = iconUrl.startsWith("http") ? getProxiedImageUrl(iconUrl) : iconUrl.startsWith("/") ? iconUrl : `${iconBasePath}/models/${iconUrl}`;
|
|
1777
|
-
const handleError = () => setFailedPriority(1);
|
|
1778
|
-
if (rounded) {
|
|
1779
|
-
return /* @__PURE__ */ jsx(
|
|
1780
|
-
"div",
|
|
1781
|
-
{
|
|
1782
|
-
className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
|
|
1783
|
-
style: { width: size, height: size },
|
|
1784
|
-
children: /* @__PURE__ */ jsx(
|
|
1785
|
-
Image,
|
|
1786
|
-
{
|
|
1787
|
-
src,
|
|
1788
|
-
alt: provider,
|
|
1789
|
-
width: size,
|
|
1790
|
-
height: size,
|
|
1791
|
-
className: "object-cover",
|
|
1792
|
-
unoptimized: true,
|
|
1793
|
-
onError: handleError
|
|
1794
|
-
}
|
|
1795
|
-
)
|
|
1796
|
-
}
|
|
1797
|
-
);
|
|
1798
|
-
}
|
|
1799
|
-
return /* @__PURE__ */ jsx(
|
|
1800
|
-
Image,
|
|
1801
|
-
{
|
|
1802
|
-
src,
|
|
1803
|
-
alt: provider,
|
|
1804
|
-
width: size,
|
|
1805
|
-
height: size,
|
|
1806
|
-
className: `object-contain ${className}`,
|
|
1807
|
-
unoptimized: true,
|
|
1808
|
-
onError: handleError
|
|
1809
|
-
}
|
|
1810
|
-
);
|
|
1811
|
-
}
|
|
1812
|
-
if (failedPriority < 2 && developer) {
|
|
1813
|
-
const developerIconFile = getDeveloperIconFile(developer);
|
|
1814
|
-
if (developerIconFile) {
|
|
1815
|
-
const src = `${iconBasePath}/models/${developerIconFile}`;
|
|
1816
|
-
const handleError = () => setFailedPriority(2);
|
|
1817
|
-
if (rounded) {
|
|
1818
|
-
return /* @__PURE__ */ jsx(
|
|
1819
|
-
"div",
|
|
1820
|
-
{
|
|
1821
|
-
className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
|
|
1822
|
-
style: { width: size, height: size },
|
|
1823
|
-
children: /* @__PURE__ */ jsx(
|
|
1824
|
-
Image,
|
|
1825
|
-
{
|
|
1826
|
-
src,
|
|
1827
|
-
alt: developer,
|
|
1828
|
-
width: size,
|
|
1829
|
-
height: size,
|
|
1830
|
-
className: "object-cover",
|
|
1831
|
-
unoptimized: true,
|
|
1832
|
-
onError: handleError
|
|
1833
|
-
}
|
|
1834
|
-
)
|
|
1835
|
-
}
|
|
1836
|
-
);
|
|
1837
|
-
}
|
|
1838
|
-
return /* @__PURE__ */ jsx(
|
|
1839
|
-
Image,
|
|
1840
|
-
{
|
|
1841
|
-
src,
|
|
1842
|
-
alt: developer,
|
|
1843
|
-
width: size,
|
|
1844
|
-
height: size,
|
|
1845
|
-
className: `object-contain ${className}`,
|
|
1846
|
-
unoptimized: true,
|
|
1847
|
-
onError: handleError
|
|
1848
|
-
}
|
|
1849
|
-
);
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
return /* @__PURE__ */ jsx(ProviderIcon, { provider, size, rounded, className });
|
|
1853
|
-
}
|
|
1854
|
-
function ModelAvatar({
|
|
1855
|
-
iconUrl,
|
|
1856
|
-
developer,
|
|
1857
|
-
provider,
|
|
1858
|
-
size = 32,
|
|
1859
|
-
className = ""
|
|
1860
|
-
}) {
|
|
1861
|
-
return /* @__PURE__ */ jsx(ModelIcon, { iconUrl, developer, provider, size, rounded: true, className });
|
|
1862
|
-
}
|
|
1863
1099
|
function ProviderIconImg({ provider, size = 16 }) {
|
|
1864
1100
|
return /* @__PURE__ */ jsx(ProviderIcon, { provider, size, rounded: true });
|
|
1865
1101
|
}
|
|
1866
1102
|
var MODEL_TYPE_ICONS = {
|
|
1867
|
-
chat: /* @__PURE__ */ jsx(MessageSquare, { size: 16, className: "text-blue-
|
|
1868
|
-
completion: /* @__PURE__ */ jsx(FileText, { size: 16, className: "text-gray-
|
|
1869
|
-
embedding: /* @__PURE__ */ jsx(Hash, { size: 16, className: "text-purple-
|
|
1870
|
-
image_generation: /* @__PURE__ */ jsx(Palette, { size: 16, className: "text-pink-
|
|
1871
|
-
audio: /* @__PURE__ */ jsx(Headphones, { size: 16, className: "text-orange-
|
|
1872
|
-
tts: /* @__PURE__ */ jsx(Volume2, { size: 16, className: "text-green-
|
|
1873
|
-
stt: /* @__PURE__ */ jsx(Mic, { size: 16, className: "text-red-
|
|
1874
|
-
video: /* @__PURE__ */ jsx(Video, { size: 16, className: "text-cyan-
|
|
1875
|
-
video_generation: /* @__PURE__ */ jsx(Video, { size: 16, className: "text-cyan-
|
|
1876
|
-
music_generation: /* @__PURE__ */ jsx(Music, { size: 16, className: "text-orange-
|
|
1877
|
-
rerank: /* @__PURE__ */ jsx(Shuffle, { size: 16, className: "text-indigo-
|
|
1878
|
-
moderation: /* @__PURE__ */ jsx(Shield, { size: 16, className: "text-yellow-
|
|
1879
|
-
"3d": /* @__PURE__ */ jsx(Box, { size: 16, className: "text-amber-
|
|
1880
|
-
realtime: /* @__PURE__ */ jsx(Radio, { size: 16, className: "text-yellow-
|
|
1103
|
+
chat: /* @__PURE__ */ jsx(MessageSquare, { size: 16, className: "text-blue-600" }),
|
|
1104
|
+
completion: /* @__PURE__ */ jsx(FileText, { size: 16, className: "text-gray-600" }),
|
|
1105
|
+
embedding: /* @__PURE__ */ jsx(Hash, { size: 16, className: "text-purple-600" }),
|
|
1106
|
+
image_generation: /* @__PURE__ */ jsx(Palette, { size: 16, className: "text-pink-600" }),
|
|
1107
|
+
audio: /* @__PURE__ */ jsx(Headphones, { size: 16, className: "text-orange-600" }),
|
|
1108
|
+
tts: /* @__PURE__ */ jsx(Volume2, { size: 16, className: "text-green-600" }),
|
|
1109
|
+
stt: /* @__PURE__ */ jsx(Mic, { size: 16, className: "text-red-600" }),
|
|
1110
|
+
video: /* @__PURE__ */ jsx(Video, { size: 16, className: "text-cyan-600" }),
|
|
1111
|
+
video_generation: /* @__PURE__ */ jsx(Video, { size: 16, className: "text-cyan-600" }),
|
|
1112
|
+
music_generation: /* @__PURE__ */ jsx(Music, { size: 16, className: "text-orange-600" }),
|
|
1113
|
+
rerank: /* @__PURE__ */ jsx(Shuffle, { size: 16, className: "text-indigo-600" }),
|
|
1114
|
+
moderation: /* @__PURE__ */ jsx(Shield, { size: 16, className: "text-yellow-600" }),
|
|
1115
|
+
"3d": /* @__PURE__ */ jsx(Box, { size: 16, className: "text-amber-600" }),
|
|
1116
|
+
realtime: /* @__PURE__ */ jsx(Radio, { size: 16, className: "text-yellow-600" })
|
|
1881
1117
|
};
|
|
1882
1118
|
function ModelTypeIcon({ type, size = 16 }) {
|
|
1883
1119
|
const icon = MODEL_TYPE_ICONS[type.toLowerCase()];
|
|
@@ -1887,274 +1123,408 @@ function ModelTypeIcon({ type, size = 16 }) {
|
|
|
1887
1123
|
return /* @__PURE__ */ jsx(Bot, { size, className: "text-muted-foreground" });
|
|
1888
1124
|
}
|
|
1889
1125
|
var variants = {
|
|
1890
|
-
primary: "bg-
|
|
1891
|
-
outline: "border hover:bg-
|
|
1892
|
-
ghost: "hover:bg-
|
|
1893
|
-
secondary: "border bg-
|
|
1126
|
+
primary: "bg-primary text-primary-foreground hover:bg-primary/80 disabled:bg-secondary disabled:text-secondary-foreground",
|
|
1127
|
+
outline: "border border-border hover:bg-accent hover:text-accent-foreground",
|
|
1128
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
1129
|
+
secondary: "border border-border bg-secondary text-secondary-foreground hover:bg-accent hover:text-accent-foreground"
|
|
1130
|
+
};
|
|
1131
|
+
var sizes = {
|
|
1132
|
+
sm: "gap-1 px-2 py-1.5 text-xs",
|
|
1133
|
+
icon: "p-1.5 [&_svg]:size-5",
|
|
1134
|
+
"icon-sm": "p-1.5 [&_svg]:size-4.5",
|
|
1135
|
+
"icon-xs": "p-1 [&_svg]:size-4"
|
|
1894
1136
|
};
|
|
1895
1137
|
var buttonVariants = cva(
|
|
1896
|
-
"inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-
|
|
1138
|
+
"inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-(--dur-fast) disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1897
1139
|
{
|
|
1898
1140
|
variants: {
|
|
1899
1141
|
variant: variants,
|
|
1900
1142
|
// fumadocs use `color` instead of `variant`
|
|
1901
1143
|
color: variants,
|
|
1902
|
-
size:
|
|
1903
|
-
sm: "gap-1 px-2 py-1.5 text-xs",
|
|
1904
|
-
icon: "p-1.5 [&_svg]:size-5",
|
|
1905
|
-
"icon-sm": "p-1.5 [&_svg]:size-4.5",
|
|
1906
|
-
"icon-xs": "p-1 [&_svg]:size-4"
|
|
1907
|
-
}
|
|
1144
|
+
size: sizes
|
|
1908
1145
|
}
|
|
1909
1146
|
}
|
|
1910
1147
|
);
|
|
1911
|
-
function
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
pending = false,
|
|
1919
|
-
className = ""
|
|
1148
|
+
function AccountMenu({
|
|
1149
|
+
user,
|
|
1150
|
+
items = [],
|
|
1151
|
+
signInHref,
|
|
1152
|
+
onSignOut,
|
|
1153
|
+
labels,
|
|
1154
|
+
className
|
|
1920
1155
|
}) {
|
|
1921
|
-
const
|
|
1922
|
-
const
|
|
1156
|
+
const { Link } = useYunUI();
|
|
1157
|
+
const [open, setOpen] = useState(false);
|
|
1158
|
+
const ref = useRef(null);
|
|
1923
1159
|
const triggerRef = useRef(null);
|
|
1924
|
-
const
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1934
|
-
}, []);
|
|
1160
|
+
const menuRef = useRef(null);
|
|
1161
|
+
const insideRefs = useMemo(() => [menuRef], []);
|
|
1162
|
+
const menuId = `${useId()}-account-menu`;
|
|
1163
|
+
const signInLabel = labels?.signIn ?? "Sign in";
|
|
1164
|
+
const signOutLabel = labels?.signOut ?? "Sign out";
|
|
1165
|
+
const fallbackName = labels?.fallbackName ?? "Account";
|
|
1166
|
+
useDismissOnOutside(open, () => setOpen(false), ref, { escape: false, extraRefs: insideRefs });
|
|
1167
|
+
const identityKey = user == null ? String(user) : JSON.stringify([user.name ?? "", user.email ?? "", user.avatarUrl ?? ""]);
|
|
1168
|
+
useEffect(() => setOpen(false), [identityKey]);
|
|
1935
1169
|
useEffect(() => {
|
|
1936
|
-
if (!
|
|
1937
|
-
const
|
|
1938
|
-
|
|
1939
|
-
|
|
1170
|
+
if (!open) return;
|
|
1171
|
+
const focusableItems = () => Array.from(
|
|
1172
|
+
menuRef.current?.querySelectorAll("[role='menuitem']:not([aria-disabled='true'])") ?? []
|
|
1173
|
+
);
|
|
1174
|
+
const focusFirstItem = () => focusableItems()[0]?.focus();
|
|
1175
|
+
const frame = requestAnimationFrame(focusFirstItem);
|
|
1176
|
+
const onKeyDown = (event) => {
|
|
1177
|
+
if (event.key === "Escape") {
|
|
1178
|
+
event.preventDefault();
|
|
1179
|
+
event.stopPropagation();
|
|
1180
|
+
setOpen(false);
|
|
1940
1181
|
triggerRef.current?.focus();
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
if (event.key === "Tab") {
|
|
1185
|
+
setOpen(false);
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
const items2 = focusableItems();
|
|
1189
|
+
if (!items2.length) return;
|
|
1190
|
+
const currentIndex = items2.indexOf(document.activeElement);
|
|
1191
|
+
let nextIndex;
|
|
1192
|
+
if (event.key === "ArrowDown") nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % items2.length;
|
|
1193
|
+
else if (event.key === "ArrowUp") nextIndex = currentIndex < 0 ? items2.length - 1 : (currentIndex - 1 + items2.length) % items2.length;
|
|
1194
|
+
else if (event.key === "Home") nextIndex = 0;
|
|
1195
|
+
else if (event.key === "End") nextIndex = items2.length - 1;
|
|
1196
|
+
if (nextIndex !== void 0) {
|
|
1197
|
+
event.preventDefault();
|
|
1198
|
+
event.stopPropagation();
|
|
1199
|
+
items2[nextIndex]?.focus();
|
|
1941
1200
|
}
|
|
1942
1201
|
};
|
|
1943
|
-
document.addEventListener("keydown",
|
|
1944
|
-
return () =>
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
if (newLocale === currentLocale || pending) return;
|
|
1948
|
-
setIsOpen(false);
|
|
1949
|
-
onChange(newLocale);
|
|
1950
|
-
};
|
|
1951
|
-
const currentLabel = locales.find((l) => l.value === currentLocale)?.label ?? currentLocale;
|
|
1952
|
-
return (
|
|
1953
|
-
// inline-flex so the root shrink-wraps the trigger; a block root filled the row and made the
|
|
1954
|
-
// right-0 dropdown anchor to the row's far edge instead of the trigger.
|
|
1955
|
-
/* @__PURE__ */ jsxs("div", { ref: containerRef, className: `relative inline-flex ${className}`, children: [
|
|
1956
|
-
variant === "pill" ? /* @__PURE__ */ jsxs(
|
|
1957
|
-
"button",
|
|
1958
|
-
{
|
|
1959
|
-
ref: triggerRef,
|
|
1960
|
-
onClick: () => setIsOpen(!isOpen),
|
|
1961
|
-
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",
|
|
1962
|
-
disabled: pending,
|
|
1963
|
-
"aria-label": label,
|
|
1964
|
-
"aria-expanded": isOpen,
|
|
1965
|
-
"aria-haspopup": "listbox",
|
|
1966
|
-
children: [
|
|
1967
|
-
/* @__PURE__ */ jsx(Globe, { size: 14, className: "shrink-0" }),
|
|
1968
|
-
/* @__PURE__ */ jsx("span", { className: "whitespace-nowrap", children: currentLabel })
|
|
1969
|
-
]
|
|
1970
|
-
}
|
|
1971
|
-
) : /* @__PURE__ */ jsx(
|
|
1972
|
-
"button",
|
|
1973
|
-
{
|
|
1974
|
-
ref: triggerRef,
|
|
1975
|
-
onClick: () => setIsOpen(!isOpen),
|
|
1976
|
-
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",
|
|
1977
|
-
disabled: pending,
|
|
1978
|
-
"aria-label": label,
|
|
1979
|
-
"aria-expanded": isOpen,
|
|
1980
|
-
"aria-haspopup": "listbox",
|
|
1981
|
-
children: /* @__PURE__ */ jsx(Globe, { className: "h-[1.2rem] w-[1.2rem]" })
|
|
1982
|
-
}
|
|
1983
|
-
),
|
|
1984
|
-
isOpen && /* @__PURE__ */ jsx(
|
|
1985
|
-
"div",
|
|
1986
|
-
{
|
|
1987
|
-
ref: panelRef,
|
|
1988
|
-
style: { marginLeft: shift, maxHeight },
|
|
1989
|
-
className: `absolute ${align === "left" ? "left-0" : "right-0"} ${placement === "top" ? "bottom-full mb-2 origin-bottom" : "top-full mt-2 origin-top"} z-50 flex flex-col overflow-hidden rounded-2xl border border-border bg-popover/95 backdrop-blur-2xl text-popover-foreground shadow-lg shadow-black/5 animate-in fade-in-0 zoom-in-95 duration-200`,
|
|
1990
|
-
children: /* @__PURE__ */ jsx("div", { className: "p-1 flex-1 min-h-0 overflow-y-auto", children: locales.map((lang) => /* @__PURE__ */ jsx(
|
|
1991
|
-
"button",
|
|
1992
|
-
{
|
|
1993
|
-
onClick: () => handleLocaleChange(lang.value),
|
|
1994
|
-
className: `dropdown-item w-full text-left ${currentLocale === lang.value ? "active" : ""}`,
|
|
1995
|
-
children: /* @__PURE__ */ jsx("span", { className: "flex-1", children: lang.label })
|
|
1996
|
-
},
|
|
1997
|
-
lang.value
|
|
1998
|
-
)) })
|
|
1999
|
-
}
|
|
2000
|
-
)
|
|
2001
|
-
] })
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
function Navbar({
|
|
2005
|
-
appName,
|
|
2006
|
-
logoSrc = "/favicon.ico",
|
|
2007
|
-
links = [],
|
|
2008
|
-
currentPath = "/",
|
|
2009
|
-
variant = "public",
|
|
2010
|
-
labels,
|
|
2011
|
-
languageSwitcher,
|
|
2012
|
-
themeToggle,
|
|
2013
|
-
homeHref = "/",
|
|
2014
|
-
loginHref = "/login",
|
|
2015
|
-
signupHref = "/signup"
|
|
2016
|
-
}) {
|
|
2017
|
-
const { Link, Image } = useYunUI();
|
|
2018
|
-
const [scrollSection, setScrollSection] = useState("");
|
|
2019
|
-
const [menuOpen, setMenuOpen] = useState(false);
|
|
2020
|
-
const signIn = labels?.signIn ?? "Sign In";
|
|
2021
|
-
const signUp = labels?.signUp ?? "Sign Up";
|
|
2022
|
-
const menuLabel = labels?.menu ?? "Menu";
|
|
2023
|
-
const activeSection = useMemo(() => {
|
|
2024
|
-
return currentPath === "/" ? scrollSection : "";
|
|
2025
|
-
}, [currentPath, scrollSection]);
|
|
2026
|
-
useEffect(() => {
|
|
2027
|
-
if (currentPath !== "/") return;
|
|
2028
|
-
const sections = document.querySelectorAll("section[id]");
|
|
2029
|
-
if (sections.length === 0) return;
|
|
2030
|
-
const handleScroll = () => {
|
|
2031
|
-
const scrollPosition = window.scrollY + 150;
|
|
2032
|
-
let currentSection = "";
|
|
2033
|
-
sections.forEach((section) => {
|
|
2034
|
-
const sectionTop = section.offsetTop;
|
|
2035
|
-
const sectionHeight = section.offsetHeight;
|
|
2036
|
-
if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {
|
|
2037
|
-
currentSection = `#${section.id}`;
|
|
2038
|
-
}
|
|
2039
|
-
});
|
|
2040
|
-
setScrollSection(currentSection);
|
|
1202
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
1203
|
+
return () => {
|
|
1204
|
+
cancelAnimationFrame(frame);
|
|
1205
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
2041
1206
|
};
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
1207
|
+
}, [open]);
|
|
1208
|
+
if (user === void 0) {
|
|
1209
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cn("block h-9 w-9", className) });
|
|
1210
|
+
}
|
|
1211
|
+
if (user === null) {
|
|
1212
|
+
return /* @__PURE__ */ jsx(
|
|
1213
|
+
Link,
|
|
1214
|
+
{
|
|
1215
|
+
href: signInHref,
|
|
1216
|
+
"aria-label": signInLabel,
|
|
1217
|
+
className: cn(
|
|
1218
|
+
"flex h-9 w-9 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-foreground/5 hover:text-foreground",
|
|
1219
|
+
className
|
|
1220
|
+
),
|
|
1221
|
+
children: /* @__PURE__ */ jsx(CircleUserRound, { className: "h-4 w-4" })
|
|
2051
1222
|
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
/* @__PURE__ */
|
|
2090
|
-
|
|
1223
|
+
);
|
|
1224
|
+
}
|
|
1225
|
+
const name = user.name || fallbackName;
|
|
1226
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("relative", className), children: [
|
|
1227
|
+
/* @__PURE__ */ jsx(
|
|
1228
|
+
"button",
|
|
1229
|
+
{
|
|
1230
|
+
ref: triggerRef,
|
|
1231
|
+
type: "button",
|
|
1232
|
+
onClick: () => setOpen((v) => !v),
|
|
1233
|
+
"aria-haspopup": "menu",
|
|
1234
|
+
"aria-controls": open ? menuId : void 0,
|
|
1235
|
+
"aria-expanded": open,
|
|
1236
|
+
"aria-label": labels?.menu ?? name,
|
|
1237
|
+
className: "flex h-9 w-9 items-center justify-center overflow-hidden rounded-full transition-colors hover:bg-foreground/5 outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1238
|
+
children: user.avatarUrl ? (
|
|
1239
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
1240
|
+
/* @__PURE__ */ jsx("img", { src: user.avatarUrl, alt: "", width: 28, height: 28, className: "h-7 w-7 rounded-full" })
|
|
1241
|
+
) : /* @__PURE__ */ jsx(CircleUserRound, { className: "h-4 w-4 text-muted-foreground" })
|
|
1242
|
+
}
|
|
1243
|
+
),
|
|
1244
|
+
open && /* @__PURE__ */ jsxs(
|
|
1245
|
+
FloatingPanel,
|
|
1246
|
+
{
|
|
1247
|
+
id: menuId,
|
|
1248
|
+
ref: menuRef,
|
|
1249
|
+
anchorRef: ref,
|
|
1250
|
+
align: "end",
|
|
1251
|
+
role: "menu",
|
|
1252
|
+
className: "z-50 w-56 overflow-y-auto rounded-2xl border border-border bg-popover p-1.5 shadow-lg shadow-black/5",
|
|
1253
|
+
children: [
|
|
1254
|
+
/* @__PURE__ */ jsxs("div", { className: "border-b border-border px-3 py-2.5", children: [
|
|
1255
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-medium", children: name }),
|
|
1256
|
+
user.email && /* @__PURE__ */ jsx("p", { className: "text-caption truncate", children: user.email })
|
|
1257
|
+
] }),
|
|
1258
|
+
items.map((item) => {
|
|
1259
|
+
const Icon = item.icon;
|
|
1260
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1261
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4", "aria-hidden": true }),
|
|
1262
|
+
item.label
|
|
1263
|
+
] });
|
|
1264
|
+
const rowClass = "mt-1 flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-foreground/5 hover:text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
1265
|
+
return item.onSelect ? /* @__PURE__ */ jsx(
|
|
1266
|
+
"button",
|
|
2091
1267
|
{
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
1268
|
+
type: "button",
|
|
1269
|
+
role: "menuitem",
|
|
1270
|
+
onClick: () => {
|
|
1271
|
+
item.onSelect?.();
|
|
1272
|
+
setOpen(false);
|
|
1273
|
+
},
|
|
1274
|
+
className: rowClass,
|
|
1275
|
+
children: body
|
|
1276
|
+
},
|
|
1277
|
+
item.key
|
|
1278
|
+
) : /* @__PURE__ */ jsx(
|
|
2098
1279
|
Link,
|
|
2099
1280
|
{
|
|
2100
|
-
href:
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
1281
|
+
href: item.href ?? "#",
|
|
1282
|
+
role: "menuitem",
|
|
1283
|
+
onClick: () => setOpen(false),
|
|
1284
|
+
className: rowClass,
|
|
1285
|
+
children: body
|
|
1286
|
+
},
|
|
1287
|
+
item.key
|
|
1288
|
+
);
|
|
1289
|
+
}),
|
|
1290
|
+
onSignOut && /* @__PURE__ */ jsxs(
|
|
2107
1291
|
"button",
|
|
2108
1292
|
{
|
|
2109
1293
|
type: "button",
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
1294
|
+
role: "menuitem",
|
|
1295
|
+
onClick: () => {
|
|
1296
|
+
onSignOut();
|
|
1297
|
+
setOpen(false);
|
|
1298
|
+
},
|
|
1299
|
+
className: "mt-1 flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm text-muted-foreground transition-colors hover:bg-foreground/5 hover:text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1300
|
+
children: [
|
|
1301
|
+
/* @__PURE__ */ jsx(LogOut, { className: "h-4 w-4", "aria-hidden": true }),
|
|
1302
|
+
signOutLabel
|
|
1303
|
+
]
|
|
2115
1304
|
}
|
|
2116
1305
|
)
|
|
2117
|
-
]
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
1306
|
+
]
|
|
1307
|
+
}
|
|
1308
|
+
)
|
|
1309
|
+
] });
|
|
1310
|
+
}
|
|
1311
|
+
var DEFAULT_LABELS3 = {
|
|
1312
|
+
running: "Running",
|
|
1313
|
+
success: "Done",
|
|
1314
|
+
error: "Failed",
|
|
1315
|
+
approval: "Waiting for approval",
|
|
1316
|
+
denied: "Denied",
|
|
1317
|
+
input: "Input",
|
|
1318
|
+
output: "Output",
|
|
1319
|
+
allow: "Allow",
|
|
1320
|
+
deny: "Deny",
|
|
1321
|
+
retry: "Retry",
|
|
1322
|
+
copy: "Copy",
|
|
1323
|
+
copied: "Copied",
|
|
1324
|
+
copyFailed: "Copy failed",
|
|
1325
|
+
showMore: "Show more",
|
|
1326
|
+
showLess: "Show less"
|
|
1327
|
+
};
|
|
1328
|
+
function StatusIcon({ status }) {
|
|
1329
|
+
const common = "h-4 w-4 shrink-0";
|
|
1330
|
+
switch (status) {
|
|
1331
|
+
case "running":
|
|
1332
|
+
return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: cn(common, "text-muted-foreground motion-safe:animate-spin") }) }, "running");
|
|
1333
|
+
case "success":
|
|
1334
|
+
return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap yunui-check-draw", children: /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: cn(common, "text-(--success)") }) }, "success");
|
|
1335
|
+
case "error":
|
|
1336
|
+
return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, className: cn(common, "text-(--error)") }) }, "error");
|
|
1337
|
+
case "approval":
|
|
1338
|
+
return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(ShieldQuestion, { "aria-hidden": true, className: cn(common, "text-primary") }) }, "approval");
|
|
1339
|
+
default:
|
|
1340
|
+
return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(Ban, { "aria-hidden": true, className: cn(common, "text-muted-foreground") }) }, "denied");
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
function CopyButton({ text, label, copiedLabel, failedLabel }) {
|
|
1344
|
+
const [state, setState] = useState("idle");
|
|
1345
|
+
const timer = useRef(void 0);
|
|
1346
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
1347
|
+
const onClick = async () => {
|
|
1348
|
+
try {
|
|
1349
|
+
await navigator.clipboard.writeText(text);
|
|
1350
|
+
setState("copied");
|
|
1351
|
+
} catch {
|
|
1352
|
+
setState("failed");
|
|
1353
|
+
}
|
|
1354
|
+
clearTimeout(timer.current);
|
|
1355
|
+
timer.current = setTimeout(() => setState("idle"), 1600);
|
|
1356
|
+
};
|
|
1357
|
+
const shown = state === "copied" ? copiedLabel : state === "failed" ? failedLabel : label;
|
|
1358
|
+
return (
|
|
1359
|
+
// Fixed-width slot: the label swaps in place so the row never changes width.
|
|
1360
|
+
/* @__PURE__ */ jsxs("button", { type: "button", onClick, className: "inline-flex h-6 min-w-[4.5rem] items-center justify-center gap-1 rounded-md px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [
|
|
1361
|
+
/* @__PURE__ */ jsxs("span", { className: "yunui-swap-in inline-flex items-center gap-1", children: [
|
|
1362
|
+
state === "copied" ? /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "h-3 w-3 text-(--success)" }) : /* @__PURE__ */ jsx(Copy, { "aria-hidden": true, className: "h-3 w-3" }),
|
|
1363
|
+
shown
|
|
1364
|
+
] }, state),
|
|
1365
|
+
/* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: state === "idle" ? "" : shown })
|
|
1366
|
+
] })
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
function Block({ title, text, maxLines, labels }) {
|
|
1370
|
+
const [expanded, setExpanded] = useState(false);
|
|
1371
|
+
const lines = text.split("\n");
|
|
1372
|
+
const long = lines.length > maxLines;
|
|
1373
|
+
const shown = long && !expanded ? lines.slice(0, maxLines).join("\n") : text;
|
|
1374
|
+
return /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
1375
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1376
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: title }),
|
|
1377
|
+
/* @__PURE__ */ jsx(CopyButton, { text, label: labels.copy, copiedLabel: labels.copied, failedLabel: labels.copyFailed })
|
|
1378
|
+
] }),
|
|
1379
|
+
/* @__PURE__ */ jsx("pre", { tabIndex: 0, className: "mt-1 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted/50 px-2.5 py-2 font-mono text-[11.5px] leading-relaxed text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: shown }),
|
|
1380
|
+
long ? /* @__PURE__ */ jsx("button", { type: "button", "aria-expanded": expanded, onClick: () => setExpanded((v) => !v), className: "mt-1 text-[11px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline", children: expanded ? labels.showLess : labels.showMore }) : null
|
|
1381
|
+
] });
|
|
1382
|
+
}
|
|
1383
|
+
function ToolCall({
|
|
1384
|
+
title,
|
|
1385
|
+
status,
|
|
1386
|
+
mark,
|
|
1387
|
+
summary,
|
|
1388
|
+
duration,
|
|
1389
|
+
reason,
|
|
1390
|
+
input,
|
|
1391
|
+
output,
|
|
1392
|
+
maxLines = 8,
|
|
1393
|
+
open,
|
|
1394
|
+
defaultOpen = false,
|
|
1395
|
+
onOpenChange,
|
|
1396
|
+
onApprove,
|
|
1397
|
+
onDeny,
|
|
1398
|
+
onRetry,
|
|
1399
|
+
labels,
|
|
1400
|
+
index = 0,
|
|
1401
|
+
className
|
|
1402
|
+
}) {
|
|
1403
|
+
const copy = mergeLabels(DEFAULT_LABELS3, labels);
|
|
1404
|
+
const baseId = useId();
|
|
1405
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
1406
|
+
const controlled = open !== void 0;
|
|
1407
|
+
const isOpen = controlled ? open : internalOpen;
|
|
1408
|
+
const hasDetails = Boolean(input || output);
|
|
1409
|
+
const toggle = () => {
|
|
1410
|
+
if (!hasDetails) return;
|
|
1411
|
+
if (!controlled) setInternalOpen(!isOpen);
|
|
1412
|
+
onOpenChange?.(!isOpen);
|
|
1413
|
+
};
|
|
1414
|
+
const statusText2 = { running: copy.running, success: copy.success, error: copy.error, approval: copy.approval, denied: copy.denied }[status];
|
|
1415
|
+
const meta = [summary, duration].filter(Boolean).join(" \xB7 ");
|
|
1416
|
+
const [announce, setAnnounce] = useState("");
|
|
1417
|
+
const first = useRef(true);
|
|
1418
|
+
useEffect(() => {
|
|
1419
|
+
if (first.current) {
|
|
1420
|
+
first.current = false;
|
|
1421
|
+
return;
|
|
2154
1422
|
}
|
|
1423
|
+
setAnnounce(`${title}: ${statusText2}`);
|
|
1424
|
+
}, [status]);
|
|
1425
|
+
const detailsId = `${baseId}-details`;
|
|
1426
|
+
return /* @__PURE__ */ jsxs("div", { "data-yunui": "tool-call", "data-status": status, style: { ["--i"]: index }, className: cn("min-w-0 rounded-xl", status === "approval" && "ring-1 ring-primary/50", className), children: [
|
|
1427
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-h-9 items-center gap-2 px-2 py-1", children: [
|
|
1428
|
+
/* @__PURE__ */ jsxs(
|
|
1429
|
+
"button",
|
|
1430
|
+
{
|
|
1431
|
+
type: "button",
|
|
1432
|
+
onClick: toggle,
|
|
1433
|
+
"aria-expanded": hasDetails ? isOpen : void 0,
|
|
1434
|
+
"aria-controls": hasDetails ? detailsId : void 0,
|
|
1435
|
+
disabled: !hasDetails,
|
|
1436
|
+
className: "flex min-w-0 flex-1 items-center gap-2 rounded-md text-left text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",
|
|
1437
|
+
children: [
|
|
1438
|
+
mark ? /* @__PURE__ */ jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground", "aria-hidden": true, children: mark }) : null,
|
|
1439
|
+
status === "running" ? /* @__PURE__ */ jsx(TextShimmer, { text: title, className: "min-w-0 truncate text-foreground" }) : /* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate", status === "success" ? "text-foreground" : status === "denied" ? "text-muted-foreground line-through decoration-muted-foreground/40" : "text-foreground"), children: title }),
|
|
1440
|
+
meta ? /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 pl-2 text-[11.5px] tabular-nums text-muted-foreground", children: meta }) : null
|
|
1441
|
+
]
|
|
1442
|
+
}
|
|
1443
|
+
),
|
|
1444
|
+
status === "approval" ? /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1", children: [
|
|
1445
|
+
/* @__PURE__ */ jsx("button", { type: "button", disabled: !onDeny, onClick: onDeny, className: "h-7 rounded-lg px-2.5 text-[12px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: copy.deny }),
|
|
1446
|
+
/* @__PURE__ */ jsx("button", { type: "button", disabled: !onApprove, onClick: onApprove, className: "h-7 rounded-lg bg-foreground px-2.5 text-[12px] text-background transition-opacity hover:opacity-90 disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: copy.allow })
|
|
1447
|
+
] }) : null,
|
|
1448
|
+
status === "error" && onRetry ? /* @__PURE__ */ jsxs("button", { type: "button", onClick: onRetry, className: "inline-flex h-7 shrink-0 items-center gap-1 rounded-lg border border-border px-2.5 text-[12px] text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [
|
|
1449
|
+
/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true, className: "h-3 w-3" }),
|
|
1450
|
+
copy.retry
|
|
1451
|
+
] }) : null,
|
|
1452
|
+
/* @__PURE__ */ jsx(StatusIcon, { status }),
|
|
1453
|
+
hasDetails ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-(--dur-spring) ease-(--ease-spring)", isOpen && "rotate-180") }) : null
|
|
1454
|
+
] }),
|
|
1455
|
+
reason ? /* @__PURE__ */ jsx("p", { className: "px-2 pb-1.5 pl-8 text-[12px] leading-snug text-muted-foreground", children: reason }) : null,
|
|
1456
|
+
hasDetails ? /* @__PURE__ */ jsx("div", { id: detailsId, "data-open": isOpen, inert: !isOpen, "aria-hidden": !isOpen, className: "yunui-disclosure", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2.5 px-2 pb-2.5 pt-1", children: [
|
|
1457
|
+
input ? /* @__PURE__ */ jsx(Block, { title: copy.input, text: input, maxLines, labels: copy }) : null,
|
|
1458
|
+
output ? /* @__PURE__ */ jsx(Block, { title: copy.output, text: output, maxLines, labels: copy }) : null
|
|
1459
|
+
] }) }) }) : null,
|
|
1460
|
+
/* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: announce })
|
|
1461
|
+
] });
|
|
1462
|
+
}
|
|
1463
|
+
var DEFAULT_GROUP_LABELS = {
|
|
1464
|
+
used: (n) => n === 1 ? "Used 1 tool" : `Used ${n} tools`,
|
|
1465
|
+
using: (n) => n === 1 ? "Using 1 tool" : `Using ${n} tools`,
|
|
1466
|
+
waiting: "Waiting for you",
|
|
1467
|
+
failed: (n) => `${n} failed`
|
|
1468
|
+
};
|
|
1469
|
+
function ToolCallGroup({ children, marks, duration, open, defaultOpen, onOpenChange, autoCollapse = true, labels, className }) {
|
|
1470
|
+
const copy = { ...DEFAULT_GROUP_LABELS, ...labels };
|
|
1471
|
+
const calls = Children.toArray(children).filter((c) => isValidElement(c));
|
|
1472
|
+
const statuses = calls.map((c) => c.props.status);
|
|
1473
|
+
const running = statuses.filter((s) => s === "running").length;
|
|
1474
|
+
const approval = statuses.filter((s) => s === "approval").length;
|
|
1475
|
+
const failed = statuses.filter((s) => s === "error").length;
|
|
1476
|
+
const busy = running > 0 || approval > 0;
|
|
1477
|
+
const baseId = useId();
|
|
1478
|
+
const controlled = open !== void 0;
|
|
1479
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen ?? busy);
|
|
1480
|
+
const touched = useRef(false);
|
|
1481
|
+
const isOpen = controlled ? open : internalOpen;
|
|
1482
|
+
const set = useCallback(
|
|
1483
|
+
(next) => {
|
|
1484
|
+
if (!controlled) setInternalOpen(next);
|
|
1485
|
+
onOpenChange?.(next);
|
|
1486
|
+
},
|
|
1487
|
+
[controlled, onOpenChange]
|
|
2155
1488
|
);
|
|
1489
|
+
useEffect(() => {
|
|
1490
|
+
if (approval > 0 && !isOpen) set(true);
|
|
1491
|
+
}, [approval]);
|
|
1492
|
+
const wasBusy = useRef(busy);
|
|
1493
|
+
useEffect(() => {
|
|
1494
|
+
let timer;
|
|
1495
|
+
if (wasBusy.current && !busy && autoCollapse && !touched.current && isOpen) timer = setTimeout(() => set(false), 450);
|
|
1496
|
+
wasBusy.current = busy;
|
|
1497
|
+
return () => clearTimeout(timer);
|
|
1498
|
+
}, [busy]);
|
|
1499
|
+
const headline = approval > 0 ? copy.waiting : running > 0 ? copy.using(calls.length) : copy.used(calls.length);
|
|
1500
|
+
const listId = `${baseId}-list`;
|
|
1501
|
+
return /* @__PURE__ */ jsxs("div", { "data-yunui": "tool-call-group", "data-busy": busy || void 0, className: cn("min-w-0 rounded-2xl border border-border bg-card/40", className), children: [
|
|
1502
|
+
/* @__PURE__ */ jsxs(
|
|
1503
|
+
"button",
|
|
1504
|
+
{
|
|
1505
|
+
type: "button",
|
|
1506
|
+
"aria-expanded": isOpen,
|
|
1507
|
+
"aria-controls": listId,
|
|
1508
|
+
onClick: () => {
|
|
1509
|
+
touched.current = true;
|
|
1510
|
+
set(!isOpen);
|
|
1511
|
+
},
|
|
1512
|
+
className: "flex min-h-10 w-full items-center gap-2.5 rounded-2xl px-3 text-left text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1513
|
+
children: [
|
|
1514
|
+
marks ? /* @__PURE__ */ jsx("span", { className: "flex -space-x-1.5 text-muted-foreground", "aria-hidden": true, children: marks }) : null,
|
|
1515
|
+
busy ? /* @__PURE__ */ jsx(TextShimmer, { text: headline, className: "min-w-0 truncate text-foreground" }) : /* @__PURE__ */ jsx("span", { className: "yunui-swap-in min-w-0 truncate text-foreground", children: headline }, "done"),
|
|
1516
|
+
/* @__PURE__ */ jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-2 text-[11.5px] tabular-nums text-muted-foreground", children: [
|
|
1517
|
+
failed > 0 ? /* @__PURE__ */ jsx("span", { className: "text-(--error)", children: copy.failed(failed) }) : null,
|
|
1518
|
+
duration && !busy ? /* @__PURE__ */ jsx("span", { children: duration }) : null
|
|
1519
|
+
] }),
|
|
1520
|
+
/* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-(--dur-spring) ease-(--ease-spring)", isOpen && "rotate-180") })
|
|
1521
|
+
]
|
|
1522
|
+
}
|
|
1523
|
+
),
|
|
1524
|
+
/* @__PURE__ */ jsx("div", { id: listId, "data-open": isOpen, inert: !isOpen, "aria-hidden": !isOpen, className: "yunui-disclosure", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "border-t border-border/70 py-1", children: calls.map((call, i) => /* @__PURE__ */ jsx("div", { className: isOpen ? "yunui-stagger-in" : void 0, style: { ["--i"]: i }, children: /* @__PURE__ */ jsx(Fragment$1, { children: call }) }, call.key ?? i)) }) }) })
|
|
1525
|
+
] });
|
|
2156
1526
|
}
|
|
2157
1527
|
|
|
2158
|
-
export { AgentRunStatus, AgentTimeline,
|
|
1528
|
+
export { AccountMenu, AgentRunStatus, AgentTimeline, ApprovalQuestion, DiffTable, ModelManagerCard, ModelTypeIcon, ProviderIconImg, SelectionActions, ThinkingBlock, ToolCall, ToolCallGroup, buttonVariants };
|
|
2159
1529
|
//# sourceMappingURL=ai.js.map
|
|
2160
1530
|
//# sourceMappingURL=ai.js.map
|