@tombcato/ai-selector-vue 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1707 @@
1
+ import { ref as E, computed as T, onMounted as ce, watch as j, defineComponent as W, onUnmounted as ue, createElementBlock as b, openBlock as y, normalizeClass as P, Fragment as H, renderList as ae, normalizeStyle as J, toDisplayString as x, unref as g, createCommentVNode as Q, createVNode as V, createElementVNode as d, withDirectives as ye, vModelText as ke, createTextVNode as z } from "vue";
2
+ const Z = {
3
+ zh: {
4
+ save: "保存配置",
5
+ saved: "保存成功",
6
+ providerLabel: "Provider",
7
+ modelLabel: "Model",
8
+ selectProvider: "选择 Provider...",
9
+ customBaseUrl: "自定义 Base URL",
10
+ apiKeyLabel: "API Key",
11
+ apiKeyPlaceholder: "输入 API Key...",
12
+ testConnection: "测试模型连接",
13
+ testing: "测试中...",
14
+ testSuccess: "连接成功",
15
+ testFailed: "测试连通性失败",
16
+ selectModel: "选择 Model...",
17
+ searchModel: "搜索或自定义模型...",
18
+ useCustom: "使用自定义",
19
+ noModels: "暂无模型数据",
20
+ apiKeyTip: "输入 API Key 后可获取完整模型列表",
21
+ fetchModelsFailed: "拉取模型列表失败,已使用离线模型列表",
22
+ refreshingModels: "列表刷新中...",
23
+ modelListUpdated: "模型列表已刷新",
24
+ preview: "配置预览",
25
+ unselected: "(未选择)"
26
+ },
27
+ en: {
28
+ save: "Save Config",
29
+ saved: "Saved",
30
+ providerLabel: "Provider",
31
+ modelLabel: "Model",
32
+ selectProvider: "Select Provider...",
33
+ customBaseUrl: "Custom Base URL",
34
+ apiKeyLabel: "API Key",
35
+ apiKeyPlaceholder: "Enter API Key...",
36
+ testConnection: "Test Model Connection",
37
+ testing: "Testing...",
38
+ testSuccess: "Connection Successful",
39
+ testFailed: "Connection Failed",
40
+ selectModel: "Select Model...",
41
+ searchModel: "Search or custom models...",
42
+ useCustom: "Use custom",
43
+ noModels: "No models found",
44
+ apiKeyTip: "Enter API Key to fetch full model list",
45
+ fetchModelsFailed: "Failed to fetch model list, using offline models",
46
+ refreshingModels: "Refreshing models...",
47
+ modelListUpdated: "Model list updated",
48
+ preview: "Config Preview",
49
+ unselected: "(Unselected)"
50
+ }
51
+ }, O = "https://registry.npmmirror.com/@lobehub/icons-static-svg/1.77.0/files/icons", o = {
52
+ OPENAI: "openai",
53
+ ANTHROPIC: "anthropic",
54
+ GEMINI: "gemini",
55
+ DEEPSEEK: "deepseek",
56
+ OPENROUTER: "openrouter",
57
+ GROQ: "groq",
58
+ MISTRAL: "mistral",
59
+ MOONSHOT: "moonshot",
60
+ QWEN: "qwen",
61
+ ZHIPU: "zhipu",
62
+ SILICONFLOW: "siliconflow",
63
+ XAI: "xai",
64
+ TOGETHER: "together",
65
+ FIREWORKS: "fireworks",
66
+ DEEPINFRA: "deepinfra",
67
+ PERPLEXITY: "perplexity",
68
+ COHERE: "cohere",
69
+ OLLAMA: "ollama",
70
+ DOUBAO: "doubao",
71
+ MINIMAX: "minimax"
72
+ }, pe = {
73
+ [o.OPENAI]: {
74
+ id: o.OPENAI,
75
+ name: "OpenAI",
76
+ baseUrl: "https://api.openai.com/v1",
77
+ needsApiKey: !0,
78
+ apiFormat: "openai",
79
+ supportsModelsApi: !0,
80
+ icon: `${O}/openai.svg`
81
+ },
82
+ [o.ANTHROPIC]: {
83
+ id: o.ANTHROPIC,
84
+ name: "Anthropic (Claude)",
85
+ baseUrl: "https://api.anthropic.com/v1",
86
+ needsApiKey: !0,
87
+ apiFormat: "anthropic",
88
+ supportsModelsApi: !1,
89
+ icon: `${O}/anthropic.svg`
90
+ },
91
+ [o.GEMINI]: {
92
+ id: o.GEMINI,
93
+ name: "Google Gemini",
94
+ baseUrl: "https://generativelanguage.googleapis.com/v1beta",
95
+ needsApiKey: !0,
96
+ apiFormat: "gemini",
97
+ supportsModelsApi: !0,
98
+ icon: `${O}/gemini.svg`
99
+ },
100
+ [o.OPENROUTER]: {
101
+ id: o.OPENROUTER,
102
+ name: "OpenRouter",
103
+ baseUrl: "https://openrouter.ai/api/v1",
104
+ needsApiKey: !0,
105
+ apiFormat: "openai",
106
+ supportsModelsApi: !0,
107
+ icon: `${O}/openrouter.svg`
108
+ },
109
+ [o.DEEPSEEK]: {
110
+ id: o.DEEPSEEK,
111
+ name: "DeepSeek",
112
+ baseUrl: "https://api.deepseek.com",
113
+ needsApiKey: !0,
114
+ apiFormat: "openai",
115
+ supportsModelsApi: !0,
116
+ icon: `${O}/deepseek.svg`
117
+ },
118
+ [o.MOONSHOT]: {
119
+ id: o.MOONSHOT,
120
+ name: "Moonshot (Kimi)",
121
+ baseUrl: "https://api.moonshot.cn/v1",
122
+ needsApiKey: !0,
123
+ apiFormat: "openai",
124
+ supportsModelsApi: !0,
125
+ icon: `${O}/moonshot.svg`
126
+ },
127
+ [o.QWEN]: {
128
+ id: o.QWEN,
129
+ name: "通义千问 (Qwen)",
130
+ baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
131
+ needsApiKey: !0,
132
+ apiFormat: "openai",
133
+ supportsModelsApi: !0,
134
+ icon: `${O}/qwen.svg`
135
+ },
136
+ [o.ZHIPU]: {
137
+ id: o.ZHIPU,
138
+ name: "智谱 AI (GLM)",
139
+ baseUrl: "https://open.bigmodel.cn/api/paas/v4",
140
+ needsApiKey: !0,
141
+ apiFormat: "openai",
142
+ supportsModelsApi: !0,
143
+ icon: `${O}/zhipu.svg`
144
+ },
145
+ [o.SILICONFLOW]: {
146
+ id: o.SILICONFLOW,
147
+ name: "硅基流动 (siliconflow)",
148
+ baseUrl: "https://api.siliconflow.cn/v1",
149
+ needsApiKey: !0,
150
+ apiFormat: "openai",
151
+ supportsModelsApi: !0,
152
+ icon: `${O}/siliconcloud.svg`
153
+ },
154
+ [o.DOUBAO]: {
155
+ id: o.DOUBAO,
156
+ name: "火山方舟 (Doubao)",
157
+ baseUrl: "https://ark.cn-beijing.volces.com/api/v3",
158
+ needsApiKey: !0,
159
+ apiFormat: "openai",
160
+ supportsModelsApi: !0,
161
+ icon: `${O}/doubao.svg`
162
+ },
163
+ [o.MINIMAX]: {
164
+ id: o.MINIMAX,
165
+ name: "MiniMax",
166
+ baseUrl: "https://api.minimax.io/v1",
167
+ needsApiKey: !0,
168
+ apiFormat: "openai",
169
+ supportsModelsApi: !1,
170
+ icon: `${O}/minimax.svg`
171
+ },
172
+ [o.XAI]: {
173
+ id: o.XAI,
174
+ name: "xAI (Grok)",
175
+ baseUrl: "https://api.x.ai/v1",
176
+ needsApiKey: !0,
177
+ apiFormat: "openai",
178
+ supportsModelsApi: !0,
179
+ icon: `${O}/grok.svg`
180
+ },
181
+ [o.GROQ]: {
182
+ id: o.GROQ,
183
+ name: "Groq",
184
+ baseUrl: "https://api.groq.com/openai/v1",
185
+ needsApiKey: !0,
186
+ apiFormat: "openai",
187
+ supportsModelsApi: !0,
188
+ icon: `${O}/groq.svg`
189
+ },
190
+ [o.MISTRAL]: {
191
+ id: o.MISTRAL,
192
+ name: "Mistral AI",
193
+ baseUrl: "https://api.mistral.ai/v1",
194
+ needsApiKey: !0,
195
+ apiFormat: "openai",
196
+ supportsModelsApi: !0,
197
+ icon: `${O}/mistral.svg`
198
+ },
199
+ [o.TOGETHER]: {
200
+ id: o.TOGETHER,
201
+ name: "Together AI",
202
+ baseUrl: "https://api.together.xyz/v1",
203
+ needsApiKey: !0,
204
+ apiFormat: "openai",
205
+ supportsModelsApi: !0,
206
+ icon: `${O}/together.svg`
207
+ },
208
+ [o.FIREWORKS]: {
209
+ id: o.FIREWORKS,
210
+ name: "Fireworks AI",
211
+ baseUrl: "https://api.fireworks.ai/inference/v1",
212
+ needsApiKey: !0,
213
+ apiFormat: "openai",
214
+ supportsModelsApi: !0,
215
+ icon: `${O}/fireworks.svg`
216
+ },
217
+ [o.DEEPINFRA]: {
218
+ id: o.DEEPINFRA,
219
+ name: "DeepInfra",
220
+ baseUrl: "https://api.deepinfra.com/v1/openai",
221
+ needsApiKey: !0,
222
+ apiFormat: "openai",
223
+ supportsModelsApi: !0,
224
+ icon: `${O}/deepinfra.svg`
225
+ },
226
+ [o.PERPLEXITY]: {
227
+ id: o.PERPLEXITY,
228
+ name: "Perplexity",
229
+ baseUrl: "https://api.perplexity.ai",
230
+ needsApiKey: !0,
231
+ apiFormat: "openai",
232
+ supportsModelsApi: !1,
233
+ icon: `${O}/perplexity.svg`
234
+ },
235
+ [o.COHERE]: {
236
+ id: o.COHERE,
237
+ name: "Cohere",
238
+ baseUrl: "https://api.cohere.com/v2",
239
+ needsApiKey: !0,
240
+ apiFormat: "cohere",
241
+ supportsModelsApi: !0,
242
+ icon: `${O}/cohere.svg`
243
+ },
244
+ [o.OLLAMA]: {
245
+ id: o.OLLAMA,
246
+ name: "Ollama (Local)",
247
+ baseUrl: "http://localhost:11434/v1",
248
+ needsApiKey: !1,
249
+ apiFormat: "openai",
250
+ supportsModelsApi: !0,
251
+ icon: `${O}/ollama.svg`
252
+ }
253
+ }, Me = {
254
+ [o.OPENAI]: [
255
+ { id: "gpt-5.2-pro", name: "GPT-5.2 Pro" },
256
+ { id: "gpt-5.2", name: "GPT-5.2" },
257
+ { id: "gpt-5", name: "GPT-5" },
258
+ { id: "gpt-5-mini", name: "GPT-5 Mini" },
259
+ { id: "gpt-5-nano", name: "GPT-5 Nano" },
260
+ { id: "gpt-4.1", name: "GPT-4.1" }
261
+ ],
262
+ [o.ANTHROPIC]: [
263
+ { id: "claude-opus-4.5-20251101", name: "Claude Opus 4.5" },
264
+ { id: "claude-opus-4.5-20251101-thinking", name: "Claude Opus 4.5 Thinking" },
265
+ { id: "claude-sonnet-4.5-20250929", name: "Claude Sonnet 4.5" },
266
+ { id: "claude-sonnet-4.5-20250929-thinking", name: "Claude Sonnet 4.5 Thinking" },
267
+ { id: "claude-haiku-4.5-20251001", name: "Claude Haiku 4.5" },
268
+ { id: "claude-haiku-4.5-20251001-thinking", name: "Claude Haiku 4.5 Thinking" },
269
+ { id: "claude-opus-4.1-20250805", name: "Claude Opus 4.1" },
270
+ { id: "claude-opus-4.1-20250805-thinking", name: "Claude Opus 4.1 Thinking" }
271
+ ],
272
+ [o.GEMINI]: [
273
+ { id: "gemini-3-flash-preview", name: "Gemini 3 Flash Preview" },
274
+ { id: "gemini-3-pro-preview", name: "Gemini 3 Pro Preview" },
275
+ { id: "gemini-2.5-pro", name: "Gemini 2.5 Pro" },
276
+ { id: "gemini-2.5-flash", name: "Gemini 2.5 Flash" },
277
+ { id: "gemini-2.5-flash-lite", name: "Gemini 2.5 Flash-Lite" }
278
+ ],
279
+ [o.DEEPSEEK]: [
280
+ { id: "deepseek-chat", name: "Deepseek Chat" },
281
+ { id: "deepseek-reasoner", name: "Deepseek Reasoner" }
282
+ ],
283
+ [o.MISTRAL]: [
284
+ { id: "mistral-large-latest", name: "Mistral Large" },
285
+ { id: "mistral-medium-latest", name: "Mistral Medium" },
286
+ { id: "mistral-small-latest", name: "Mistral Small" },
287
+ { id: "codestral-latest", name: "Codestral" },
288
+ { id: "devstral-latest", name: "Devstral" },
289
+ { id: "magistral-medium-latest", name: "Magistral Medium" },
290
+ { id: "pixtral-large-latest", name: "Pixtral Large" },
291
+ { id: "pixtral-12b-latest", name: "Pixtral 12B" },
292
+ { id: "ministral-8b-latest", name: "Ministral 8B" },
293
+ { id: "ministral-3b-latest", name: "Ministral 3B" }
294
+ ],
295
+ [o.GROQ]: [
296
+ { id: "canopylabs/orpheus-v1-english", name: "Orpheus V1 English" },
297
+ { id: "canopylabs/orpheus-arabic-saudi", name: "Orpheus Arabic Saudi" },
298
+ { id: "moonshotai/kimi-k2-instruct", name: "Kimi K2 Instruct" },
299
+ { id: "groq/compound-mini", name: "Compound Mini" },
300
+ { id: "llama-3.3-70b-versatile", name: "Llama 3.3 70B Versatile" },
301
+ { id: "openai/gpt-oss-120b", name: "Gpt Oss 120B" },
302
+ { id: "qwen/qwen3-32b", name: "Qwen3 32B" },
303
+ { id: "groq/compound", name: "Compound" },
304
+ { id: "meta-llama/llama-4-maverick-17b-128e-instruct", name: "Llama 4 Maverick 17B 128E Instruct" }
305
+ ],
306
+ [o.XAI]: [
307
+ { id: "grok-4", name: "Grok 4" },
308
+ { id: "grok-4-fast", name: "Grok 4 Fast" },
309
+ { id: "grok-3-latest", name: "Grok 3" },
310
+ { id: "grok-3-fast", name: "Grok 3 Fast" },
311
+ { id: "grok-3-mini-latest", name: "Grok 3 Mini" },
312
+ { id: "grok-3-mini-fast", name: "Grok 3 Mini Fast" },
313
+ { id: "grok-vision-beta", name: "Grok Vision (Beta)" }
314
+ ],
315
+ [o.TOGETHER]: [
316
+ { id: "Qwen/Qwen2.5-72B-Instruct-Turbo", name: "Qwen2.5 72B Instruct Turbo" },
317
+ { id: "Qwen/Qwen3-235B-A22B-Thinking-2507", name: "Qwen3 235B A22B Thinking 2507" },
318
+ { id: "deepseek-ai/DeepSeek-R1", name: "Deepseek R1" },
319
+ { id: "deepseek-ai/DeepSeek-V3.1", name: "Deepseek V3.1" },
320
+ { id: "meta-llama/Llama-3.2-3B-Instruct-Turbo", name: "Llama 3.2 3B Instruct Turbo" },
321
+ { id: "meta-llama/Llama-3.3-70B-Instruct-Turbo", name: "Llama 3.3 70B Instruct Turbo" },
322
+ { id: "meta-llama/Llama-3.3-70B-Instruct-Turbo-Free", name: "Llama 3.3 70B Instruct Turbo Free" }
323
+ ],
324
+ [o.FIREWORKS]: [
325
+ { id: "accounts/fireworks/models/llama4-scout-instruct-basic", name: "Llama4 Scout Instruct Basic" },
326
+ { id: "accounts/fireworks/models/qwen3-vl-235b-a22b-thinking", name: "Qwen3 Vl 235B A22B Thinking" },
327
+ { id: "accounts/fireworks/models/deepseek-v3p2", name: "Deepseek V3P2" },
328
+ { id: "accounts/fireworks/models/qwen3-vl-30b-a3b-thinking", name: "Qwen3 Vl 30B A3B Thinking" },
329
+ { id: "accounts/fireworks/models/qwen3-8b", name: "Qwen3 8B" },
330
+ { id: "accounts/fireworks/models/qwen3-vl-30b-a3b-instruct", name: "Qwen3 Vl 30B A3B Instruct" },
331
+ { id: "accounts/fireworks/models/qwen2p5-vl-32b-instruct", name: "Qwen2P5 Vl 32B Instruct" },
332
+ { id: "accounts/fireworks/models/llama4-maverick-instruct-basic", name: "Llama4 Maverick Instruct Basic" },
333
+ { id: "accounts/fireworks/models/qwen3-235b-a22b-thinking-2507", name: "Qwen3 235B A22B Thinking 2507" },
334
+ { id: "accounts/fireworks/models/qwen3-coder-480b-a35b-instruct", name: "Qwen3 Coder 480B A35B Instruct" }
335
+ ],
336
+ [o.DEEPINFRA]: [
337
+ { id: "meta-llama/Llama-3.2-11B-Vision-Instruct", name: "Llama 3.2 11B Vision Instruct" },
338
+ { id: "Qwen/Qwen3-32B", name: "Qwen3 32B" },
339
+ { id: "NousResearch/Hermes-3-Llama-3.1-70B", name: "Hermes 3 Llama 3.1 70B" },
340
+ { id: "Qwen/Qwen2.5-72B-Instruct", name: "Qwen2.5 72B Instruct" },
341
+ { id: "deepseek-ai/DeepSeek-V3-0324", name: "Deepseek V3 0324" },
342
+ { id: "Qwen/Qwen3-VL-235B-A22B-Instruct", name: "Qwen3 Vl 235B A22B Instruct" },
343
+ { id: "meta-llama/Llama-3.2-3B-Instruct", name: "Llama 3.2 3B Instruct" },
344
+ { id: "Qwen/Qwen2.5-VL-32B-Instruct", name: "Qwen2.5 Vl 32B Instruct" },
345
+ { id: "meta-llama/Meta-Llama-3.1-8B-Instruct", name: "Meta Llama 3.1 8B Instruct" },
346
+ { id: "Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo", name: "Qwen3 Coder 480B A35B Instruct Turbo" }
347
+ ],
348
+ [o.OPENROUTER]: [
349
+ { id: "google/gemini-3-flash-preview", name: "Gemini 3 Flash Preview" },
350
+ { id: "mistralai/mistral-small-creative", name: "Mistral Small Creative" },
351
+ { id: "openai/gpt-5.2-chat", name: "Gpt 5.2 Chat" },
352
+ { id: "openai/gpt-5.2-pro", name: "Gpt 5.2 Pro" },
353
+ { id: "openai/gpt-5.2", name: "Gpt 5.2" },
354
+ { id: "mistralai/devstral-2512", name: "Devstral 2512" },
355
+ { id: "openai/gpt-5.1-codex-max", name: "Gpt 5.1 Codex Max" },
356
+ { id: "mistralai/ministral-14b-2512", name: "Ministral 14B 2512" },
357
+ { id: "mistralai/ministral-8b-2512", name: "Ministral 8B 2512" },
358
+ { id: "mistralai/ministral-3b-2512", name: "Ministral 3B 2512" },
359
+ { id: "mistralai/mistral-large-2512", name: "Mistral Large 2512" },
360
+ { id: "deepseek/deepseek-v3.2-speciale", name: "Deepseek V3.2 Speciale" }
361
+ ],
362
+ [o.PERPLEXITY]: [
363
+ { id: "codellama-34b-instruct", name: "Codellama 34B Instruct" },
364
+ { id: "codellama-70b-instruct", name: "Codellama 70B Instruct" },
365
+ { id: "llama-2-70b-chat", name: "Llama 2 70B Chat" },
366
+ { id: "llama-3.1-70b-instruct", name: "Llama 3.1 70B Instruct" },
367
+ { id: "llama-3.1-8b-instruct", name: "Llama 3.1 8B Instruct" },
368
+ { id: "llama-3.1-sonar-huge-128k-online", name: "Llama 3.1 Sonar Huge 128K Online" },
369
+ { id: "llama-3.1-sonar-large-128k-chat", name: "Llama 3.1 Sonar Large 128K Chat" },
370
+ { id: "llama-3.1-sonar-large-128k-online", name: "Llama 3.1 Sonar Large 128K Online" },
371
+ { id: "llama-3.1-sonar-small-128k-chat", name: "Llama 3.1 Sonar Small 128K Chat" }
372
+ ],
373
+ [o.COHERE]: [
374
+ { id: "command-a-vision-07-2025", name: "Command A Vision 07 2025" },
375
+ { id: "command-a-reasoning-08-2025", name: "Command A Reasoning 08 2025" },
376
+ { id: "command-r-08-2024", name: "Command R 08 2024" },
377
+ { id: "command-r7b-arabic-02-2025", name: "Command R7B Arabic 02 2025" },
378
+ { id: "command-r7b-12-2024", name: "Command R7B 12 2024" }
379
+ ],
380
+ [o.MOONSHOT]: [
381
+ { id: "moonshot-v1-128k", name: "Moonshot 128K" },
382
+ { id: "moonshot-v1-32k", name: "Moonshot 32K" },
383
+ { id: "moonshot-v1-8k", name: "Moonshot 8K" },
384
+ { id: "kimi-k2-0711-chat", name: "Kimi K2 Chat" },
385
+ { id: "moonshot-v1-auto", name: "Moonshot Auto" }
386
+ ],
387
+ [o.QWEN]: [
388
+ { id: "qwen-flash", name: "Qwen Flash" },
389
+ { id: "qwen3-vl-plus-2025-12-19", name: "Qwen3 Vl Plus 2025 12 19" },
390
+ { id: "qwen3-tts-vd-realtime-2025-12-16", name: "Qwen3 Tts Vd Realtime 2025 12 16" },
391
+ { id: "qwen-image-edit-plus-2025-12-15", name: "Qwen Image Edit Plus 2025 12 15" },
392
+ { id: "qwen3-omni-flash-2025-12-01", name: "Qwen3 Omni Flash 2025 12 01" },
393
+ { id: "qwen3-omni-flash-realtime-2025-12-01", name: "Qwen3 Omni Flash Realtime 2025 12 01" },
394
+ { id: "qwen3-livetranslate-flash-2025-12-01", name: "Qwen3 Livetranslate Flash 2025 12 01" },
395
+ { id: "qwen3-livetranslate-flash", name: "Qwen3 Livetranslate Flash" },
396
+ { id: "qwen-plus-2025-12-01", name: "Qwen Plus 2025 12 01" },
397
+ { id: "qwen3-tts-vc-realtime-2025-11-27", name: "Qwen3 Tts Vc Realtime 2025 11 27" }
398
+ ],
399
+ [o.ZHIPU]: [
400
+ { id: "glm-4.5", name: "Glm 4.5" },
401
+ { id: "glm-4.5-air", name: "Glm 4.5 Air" },
402
+ { id: "glm-4.6", name: "Glm 4.6" },
403
+ { id: "glm-4.7", name: "Glm 4.7" }
404
+ ],
405
+ [o.SILICONFLOW]: [
406
+ { id: "deepseek-ai/DeepSeek-V3.2", name: "Deepseek V3.2" },
407
+ { id: "deepseek-ai/DeepSeek-V3.1-Terminus", name: "Deepseek V3.1 Terminus" },
408
+ { id: "deepseek-ai/DeepSeek-R1", name: "Deepseek R1" },
409
+ { id: "deepseek-ai/DeepSeek-V3", name: "Deepseek V3" },
410
+ { id: "zai-org/GLM-4.6V", name: "Glm 4.6V" },
411
+ { id: "zai-org/GLM-4.6", name: "Glm 4.6" },
412
+ { id: "Pro/zai-org/GLM-4.7", name: "Glm 4.7" },
413
+ { id: "Qwen/Qwen3-VL-32B-Instruct", name: "Qwen3 Vl 32B Instruct" }
414
+ ],
415
+ [o.OLLAMA]: [
416
+ { id: "llama3.3", name: "Llama 3.3" },
417
+ { id: "llama3.2", name: "Llama 3.2" },
418
+ { id: "qwq", name: "QwQ (推理)" },
419
+ { id: "qwen3:32b", name: "Qwen3 32B" },
420
+ { id: "deepseek-r1:32b", name: "DeepSeek R1 32B" },
421
+ { id: "deepseek-coder-v2", name: "DeepSeek Coder V2" },
422
+ { id: "gemma3:27b", name: "Gemma 3 27B" },
423
+ { id: "mistral:7b", name: "Mistral 7B" },
424
+ { id: "phi4", name: "Phi 4" },
425
+ { id: "codellama", name: "Code Llama" }
426
+ ],
427
+ [o.DOUBAO]: [
428
+ { id: "doubao-seed-1-8-251215", name: "Doubao 1.8" },
429
+ { id: "doubao-seed-1-6-251015", name: "Doubao 1.6" },
430
+ { id: "doubao-seed-1-6-lite-251015", name: "Doubao 1.6 Lite" },
431
+ { id: "doubao-seed-1-6-flash-250828", name: "Doubao 1.6 Flash" },
432
+ { id: "doubao-seed-1-6-thinking-250615", name: "Doubao 1.6 Thinking" }
433
+ ],
434
+ [o.MINIMAX]: [
435
+ { id: "MiniMax-M2.1", name: "MiniMax M2.1" },
436
+ { id: "MiniMax-M2.1-lightning", name: "MiniMax M2.1 Lightning" },
437
+ { id: "MiniMax-M2", name: "MiniMax M2" }
438
+ ]
439
+ };
440
+ function de(e) {
441
+ return Me[e] || [];
442
+ }
443
+ const we = (e) => Array.isArray(e == null ? void 0 : e.data) ? e.data.filter((a) => a.id).map((a) => {
444
+ const s = a.name || (a.id.split("/").pop() ?? "").replace(/[-_]/g, " ").replace(/\b\w/g, (i) => i.toUpperCase());
445
+ return {
446
+ id: a.id,
447
+ name: s,
448
+ created: a.created || 0
449
+ };
450
+ }).sort((a, s) => (s.created || 0) - (a.created || 0)) : [], he = {
451
+ format: "openai",
452
+ getModelsEndpoint: (e) => `${e}/models`,
453
+ getChatEndpoint: (e) => `${e}/chat/completions`,
454
+ buildHeaders: (e) => ({
455
+ "Content-Type": "application/json",
456
+ Authorization: `Bearer ${e}`
457
+ }),
458
+ buildChatPayload: (e, a, s) => ({
459
+ model: e,
460
+ messages: a,
461
+ max_tokens: s
462
+ }),
463
+ parseChatResponse: (e) => {
464
+ var a, s, i;
465
+ return ((i = (s = (a = e.choices) == null ? void 0 : a[0]) == null ? void 0 : s.message) == null ? void 0 : i.content) || "";
466
+ }
467
+ }, Ce = {
468
+ format: "anthropic",
469
+ getChatEndpoint: (e) => `${e}/messages`,
470
+ buildHeaders: (e) => ({
471
+ "Content-Type": "application/json",
472
+ "x-api-key": e,
473
+ "anthropic-version": "2023-06-01"
474
+ }),
475
+ buildChatPayload: (e, a, s) => ({
476
+ model: e,
477
+ messages: a,
478
+ max_tokens: s
479
+ }),
480
+ parseChatResponse: (e) => {
481
+ var a, s;
482
+ return ((s = (a = e.content) == null ? void 0 : a[0]) == null ? void 0 : s.text) || "";
483
+ }
484
+ }, Ie = {
485
+ format: "gemini",
486
+ getModelsEndpoint: (e, a) => `${e}/models?key=${a}`,
487
+ getChatEndpoint: (e, a, s) => `${e}/models/${s}:generateContent?key=${a}`,
488
+ buildHeaders: () => ({
489
+ "Content-Type": "application/json"
490
+ }),
491
+ buildChatPayload: (e, a, s) => ({
492
+ contents: a.map((t) => ({
493
+ role: t.role === "assistant" ? "model" : "user",
494
+ parts: [{ text: t.content }]
495
+ })),
496
+ generationConfig: { maxOutputTokens: s }
497
+ }),
498
+ parseChatResponse: (e) => {
499
+ var a, s, i, t, n;
500
+ return ((n = (t = (i = (s = (a = e.candidates) == null ? void 0 : a[0]) == null ? void 0 : s.content) == null ? void 0 : i.parts) == null ? void 0 : t[0]) == null ? void 0 : n.text) || "";
501
+ },
502
+ // Gemini 返回格式: { models: [{ name: "models/gemini-pro", ... }] }
503
+ parseModelsResponse: (e) => Array.isArray(e.models) ? e.models.filter((a) => {
504
+ var s;
505
+ return (s = a.supportedGenerationMethods) == null ? void 0 : s.includes("generateContent");
506
+ }).map((a) => ({
507
+ id: a.name.replace("models/", ""),
508
+ // "models/gemini-pro" -> "gemini-pro"
509
+ name: a.displayName || a.name.replace("models/", ""),
510
+ created: a.created || 0
511
+ })).sort((a, s) => (s.created || 0) - (a.created || 0)) : []
512
+ }, xe = {
513
+ format: "cohere",
514
+ getModelsEndpoint: (e) => `${e}/models`,
515
+ getChatEndpoint: (e) => `${e}/chat`,
516
+ buildHeaders: (e) => ({
517
+ "Content-Type": "application/json",
518
+ Authorization: `Bearer ${e}`
519
+ }),
520
+ buildChatPayload: (e, a, s) => {
521
+ const i = a[a.length - 1], t = a.slice(0, -1).map((n) => ({
522
+ role: n.role === "assistant" ? "CHATBOT" : "USER",
523
+ message: n.content
524
+ }));
525
+ return {
526
+ model: e,
527
+ message: i.content,
528
+ chat_history: t,
529
+ max_tokens: s
530
+ };
531
+ },
532
+ parseChatResponse: (e) => e.text || ""
533
+ }, Ae = {
534
+ openai: he,
535
+ anthropic: Ce,
536
+ gemini: Ie,
537
+ cohere: xe
538
+ };
539
+ function fe(e) {
540
+ return Ae[e] || he;
541
+ }
542
+ async function Ee(e) {
543
+ const { provider: a, apiKey: s, model: i, baseUrl: t, proxyUrl: n } = e, v = t || a.baseUrl, l = Date.now();
544
+ try {
545
+ if (n) {
546
+ const k = await (await fetch(`${n}/test`, {
547
+ method: "POST",
548
+ headers: { "Content-Type": "application/json" },
549
+ body: JSON.stringify({
550
+ provider_id: a.id,
551
+ api_key: s,
552
+ model: i || "",
553
+ base_url: t || a.baseUrl,
554
+ api_format: a.apiFormat
555
+ })
556
+ })).json();
557
+ return {
558
+ success: k.success,
559
+ latencyMs: k.latency_ms || Date.now() - l,
560
+ message: k.message
561
+ };
562
+ }
563
+ const r = fe(a.apiFormat), u = i || "";
564
+ if (!u)
565
+ return {
566
+ success: !1,
567
+ latencyMs: 0,
568
+ message: "请先选择模型 (Please select a model)"
569
+ };
570
+ const c = r.buildHeaders(s), f = r.buildChatPayload(u, [{ role: "user", content: "Hi" }], 5), p = r.getChatEndpoint(v, s, u), h = await fetch(p, {
571
+ method: "POST",
572
+ headers: c,
573
+ body: JSON.stringify(f)
574
+ }), I = Date.now() - l;
575
+ if (h.ok)
576
+ return { success: !0, latencyMs: I, message: "连接成功" };
577
+ {
578
+ const A = await h.text();
579
+ return {
580
+ success: !1,
581
+ latencyMs: I,
582
+ message: `HTTP ${h.status}: ${A.slice(0, 200)}`
583
+ };
584
+ }
585
+ } catch (r) {
586
+ return {
587
+ success: !1,
588
+ latencyMs: Date.now() - l,
589
+ message: r instanceof Error ? r.message : String(r)
590
+ };
591
+ }
592
+ }
593
+ async function Le(e) {
594
+ var v;
595
+ const { provider: a, apiKey: s, baseUrl: i, proxyUrl: t, fallbackToStatic: n = !0 } = e;
596
+ if (t)
597
+ try {
598
+ const r = await (await fetch(`${t}/models`, {
599
+ method: "POST",
600
+ headers: { "Content-Type": "application/json" },
601
+ body: JSON.stringify({
602
+ provider_id: a.id,
603
+ api_key: s || void 0,
604
+ base_url: i || a.baseUrl
605
+ })
606
+ })).json();
607
+ if (r.success && ((v = r.models) == null ? void 0 : v.length) > 0)
608
+ return r.models;
609
+ } catch (l) {
610
+ if (console.warn("Failed to fetch models via proxy:", l), !n)
611
+ throw l;
612
+ }
613
+ if (!t && a.supportsModelsApi)
614
+ try {
615
+ const l = fe(a.apiFormat);
616
+ if (l.getModelsEndpoint) {
617
+ const r = l.getModelsEndpoint(i || a.baseUrl, s || ""), u = l.buildHeaders(s || ""), c = await fetch(r, {
618
+ method: "GET",
619
+ headers: u
620
+ });
621
+ if (c.ok) {
622
+ const f = await c.json();
623
+ return (l.parseModelsResponse || we)(f);
624
+ } else if (!n)
625
+ throw new Error(`HTTP ${c.status}`);
626
+ }
627
+ } catch (l) {
628
+ if (console.warn("Failed to fetch models directly:", l), !n)
629
+ throw l;
630
+ }
631
+ if (!n && a.supportsModelsApi)
632
+ throw new Error("Failed to fetch models");
633
+ return de(a.id);
634
+ }
635
+ const se = "ai_provider_config", Oe = {
636
+ get: (e) => typeof window > "u" ? null : localStorage.getItem(e),
637
+ set: (e, a) => {
638
+ typeof window > "u" || localStorage.setItem(e, a);
639
+ },
640
+ remove: (e) => {
641
+ typeof window > "u" || localStorage.removeItem(e);
642
+ }
643
+ };
644
+ function Se(e = Oe, a = {}) {
645
+ const s = a.serialize || JSON.stringify, i = a.deserialize || JSON.parse;
646
+ return {
647
+ /**
648
+ * Save AI config
649
+ */
650
+ save(t) {
651
+ try {
652
+ const n = s(t);
653
+ e.set(se, n);
654
+ } catch (n) {
655
+ console.error("Failed to save config:", n);
656
+ }
657
+ },
658
+ /**
659
+ * Load AI config
660
+ */
661
+ load() {
662
+ const t = e.get(se);
663
+ if (!t)
664
+ return null;
665
+ try {
666
+ return i(t);
667
+ } catch (n) {
668
+ return console.error("Failed to load config:", n), null;
669
+ }
670
+ },
671
+ /**
672
+ * Clear AI config
673
+ */
674
+ clear() {
675
+ e.remove(se);
676
+ }
677
+ };
678
+ }
679
+ function Te(e) {
680
+ if (!e)
681
+ return {
682
+ providers: Object.values(pe),
683
+ getModels: (r) => de(r)
684
+ };
685
+ const { mode: a, include: s, exclude: i, custom: t } = e;
686
+ let n = [];
687
+ if (a === "default") {
688
+ let r = Object.values(pe);
689
+ s && s.length > 0 && (r = r.filter((u) => s.includes(u.id))), i && i.length > 0 && (r = r.filter((u) => !i.includes(u.id))), n = [...r];
690
+ }
691
+ const v = {};
692
+ if (t)
693
+ for (const [r, u] of Object.entries(t)) {
694
+ const c = {
695
+ id: r,
696
+ name: u.name,
697
+ baseUrl: u.baseUrl,
698
+ needsApiKey: u.needsApiKey,
699
+ apiFormat: u.apiFormat,
700
+ supportsModelsApi: u.supportsModelsApi ?? !1,
701
+ icon: u.icon
702
+ }, f = n.findIndex((p) => p.id === r);
703
+ f >= 0 ? n[f] = {
704
+ ...n[f],
705
+ ...c,
706
+ icon: c.icon || n[f].icon
707
+ } : n.push(c), u.models && u.models.length > 0 && (v[r] = u.models);
708
+ }
709
+ return { providers: n, getModels: (r) => v[r] ? v[r] : de(r) };
710
+ }
711
+ function Be(e = {}) {
712
+ var F, D, X, q, G;
713
+ const a = E(((F = e.initialConfig) == null ? void 0 : F.providerId) || ""), s = E(((D = e.initialConfig) == null ? void 0 : D.apiKey) || ""), i = E(((X = e.initialConfig) == null ? void 0 : X.model) || ""), t = E(((q = e.initialConfig) == null ? void 0 : q.modelName) || ""), n = E(((G = e.initialConfig) == null ? void 0 : G.baseUrl) || ""), v = E([]), l = E("idle"), r = E(null), u = E(!1), c = E(null), f = T(() => Te(e.providerConfig)), p = T(() => f.value.providers), h = T(
714
+ () => p.value.find((m) => m.id === a.value) || null
715
+ ), I = Se(void 0, {
716
+ serialize: e.onSerialize,
717
+ deserialize: e.onDeserialize
718
+ }), A = E(!1);
719
+ ce(() => {
720
+ const m = I.load();
721
+ m && m.providerId && p.value.some((M) => M.id === m.providerId) && (a.value = m.providerId, m.apiKey && (s.value = m.apiKey), m.model && (i.value = m.model), m.modelName && (t.value = m.modelName), m.baseUrl && (n.value = m.baseUrl)), setTimeout(() => {
722
+ A.value = !0;
723
+ }, 0);
724
+ }), j(a, () => {
725
+ A.value && (s.value = "", i.value = "", t.value = "", n.value = "", l.value = "idle", r.value = null);
726
+ });
727
+ let k = null;
728
+ const L = /* @__PURE__ */ new Map();
729
+ j([a, s, n], () => {
730
+ if (k && clearTimeout(k), !a.value || !h.value) {
731
+ v.value = [], c.value = null, u.value = !1;
732
+ return;
733
+ }
734
+ const m = h.value.supportsModelsApi && (!h.value.needsApiKey || !!s.value), M = n.value || h.value.baseUrl, $ = `${a.value}|${M}|${s.value}`, _ = L.get($);
735
+ if (_) {
736
+ v.value = _, c.value = null, u.value = !1;
737
+ return;
738
+ }
739
+ if (!m) {
740
+ const K = f.value.getModels(a.value);
741
+ v.value = K, L.set($, K), c.value = null, u.value = !1;
742
+ return;
743
+ }
744
+ u.value = !0, c.value = null, v.value.length === 0 && (v.value = f.value.getModels(a.value)), k = setTimeout(async () => {
745
+ try {
746
+ let K;
747
+ e.modelFetcher ? K = await e.modelFetcher({
748
+ type: "fetchModels",
749
+ providerId: h.value.id,
750
+ baseUrl: M,
751
+ apiKey: s.value
752
+ }) : K = await Le({
753
+ provider: h.value,
754
+ apiKey: s.value,
755
+ baseUrl: M,
756
+ proxyUrl: e.proxyUrl,
757
+ fallbackToStatic: !1
758
+ }), v.value = K, L.set($, K);
759
+ } catch (K) {
760
+ console.warn("Model fetch failed:", K), c.value = "fetchModelsFailed", v.value = f.value.getModels(a.value);
761
+ } finally {
762
+ u.value = !1;
763
+ }
764
+ }, 500);
765
+ }, { immediate: !0 }), j([s, n], () => {
766
+ (l.value === "error" || l.value === "success") && (l.value = "idle", r.value = null);
767
+ });
768
+ async function w() {
769
+ if (!h.value || h.value.needsApiKey && !s.value) return;
770
+ l.value = "testing", r.value = null;
771
+ let m;
772
+ if (e.modelFetcher)
773
+ try {
774
+ const M = await e.modelFetcher({
775
+ type: "checkConnection",
776
+ providerId: h.value.id,
777
+ baseUrl: n.value || h.value.baseUrl,
778
+ apiKey: s.value,
779
+ modelId: i.value
780
+ });
781
+ m = {
782
+ success: M.success,
783
+ latencyMs: M.latency || M.latencyMs,
784
+ message: M.message
785
+ };
786
+ } catch (M) {
787
+ m = { success: !1, message: M.message || "Unknown error" };
788
+ }
789
+ else
790
+ m = await Ee({
791
+ provider: h.value,
792
+ apiKey: s.value,
793
+ baseUrl: n.value,
794
+ model: i.value,
795
+ proxyUrl: e.proxyUrl
796
+ });
797
+ return r.value = m, l.value = m.success ? "success" : "error", setTimeout(() => {
798
+ l.value = "idle";
799
+ }, 2e3), m;
800
+ }
801
+ function S() {
802
+ const m = v.value.find(($) => $.id === i.value), M = (m == null ? void 0 : m.name) || t.value || i.value;
803
+ m != null && m.name && m.name !== t.value && (t.value = m.name), I.save({
804
+ providerId: a.value,
805
+ apiKey: s.value,
806
+ model: i.value,
807
+ modelName: M,
808
+ baseUrl: n.value
809
+ });
810
+ }
811
+ function U() {
812
+ I.clear(), a.value = "", s.value = "", i.value = "", t.value = "", n.value = "";
813
+ }
814
+ function B(m, M) {
815
+ if (i.value = m, M)
816
+ t.value = M;
817
+ else {
818
+ const $ = v.value.find((_) => _.id === m);
819
+ t.value = ($ == null ? void 0 : $.name) || m;
820
+ }
821
+ }
822
+ const R = T(() => {
823
+ var m;
824
+ return !(!a.value || !i.value || (m = h.value) != null && m.needsApiKey && !s.value);
825
+ }), C = T(() => {
826
+ var m;
827
+ return {
828
+ providerId: a.value,
829
+ apiKey: s.value,
830
+ model: i.value,
831
+ modelName: t.value,
832
+ baseUrl: n.value || ((m = h.value) == null ? void 0 : m.baseUrl) || ""
833
+ };
834
+ });
835
+ return {
836
+ // State (Refs)
837
+ providerId: a,
838
+ apiKey: s,
839
+ model: i,
840
+ modelName: t,
841
+ baseUrl: n,
842
+ models: v,
843
+ testStatus: l,
844
+ testResult: r,
845
+ isFetchingModels: u,
846
+ fetchModelError: c,
847
+ // Computed
848
+ provider: h,
849
+ providers: p,
850
+ isValid: R,
851
+ config: C,
852
+ // Actions
853
+ runTest: w,
854
+ save: S,
855
+ clear: U,
856
+ selectModel: B
857
+ };
858
+ }
859
+ var Pe = Object.defineProperty, Ue = (e, a, s) => a in e ? Pe(e, a, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[a] = s, ne = (e, a, s) => Ue(e, typeof a != "symbol" ? a + "" : a, s);
860
+ const N = "\0";
861
+ class Fe {
862
+ constructor(a) {
863
+ ne(this, "numOriginalCharacters"), ne(this, "characterList"), ne(this, "characterIndicesMap");
864
+ const s = [...a], i = s.length;
865
+ this.numOriginalCharacters = i, this.characterIndicesMap = /* @__PURE__ */ new Map();
866
+ for (let t = 0; t < i; t++)
867
+ this.characterIndicesMap.set(s[t], t);
868
+ this.characterList = new Array(i * 2 + 1), this.characterList[0] = N;
869
+ for (let t = 0; t < i; t++)
870
+ this.characterList[1 + t] = s[t], this.characterList[1 + i + t] = s[t];
871
+ }
872
+ getCharacterIndices(a, s, i) {
873
+ let t = this.getIndexOfChar(a), n = this.getIndexOfChar(s);
874
+ if (t < 0 || n < 0) return null;
875
+ switch (i) {
876
+ case "DOWN":
877
+ s === N ? n = this.characterList.length : n < t && (n += this.numOriginalCharacters);
878
+ break;
879
+ case "UP":
880
+ t < n && (t += this.numOriginalCharacters);
881
+ break;
882
+ case "ANY":
883
+ if (a !== N && s !== N) {
884
+ if (n < t) {
885
+ const v = t - n;
886
+ this.numOriginalCharacters - t + n < v && (n += this.numOriginalCharacters);
887
+ } else if (t < n) {
888
+ const v = n - t;
889
+ this.numOriginalCharacters - n + t < v && (t += this.numOriginalCharacters);
890
+ }
891
+ }
892
+ break;
893
+ }
894
+ return { startIndex: t, endIndex: n };
895
+ }
896
+ getSupportedCharacters() {
897
+ return new Set(this.characterIndicesMap.keys());
898
+ }
899
+ getCharacterList() {
900
+ return this.characterList;
901
+ }
902
+ getIndexOfChar(a) {
903
+ return a === N ? 0 : this.characterIndicesMap.has(a) ? this.characterIndicesMap.get(a) + 1 : -1;
904
+ }
905
+ }
906
+ const te = 0, Y = 1, ee = 2;
907
+ function $e(e, a, s) {
908
+ let i = 0, t = 0;
909
+ const n = [];
910
+ for (; ; ) {
911
+ const v = i === e.length, l = t === a.length;
912
+ if (v && l) break;
913
+ if (v) {
914
+ for (; t < a.length; t++) n.push(Y);
915
+ break;
916
+ }
917
+ if (l) {
918
+ for (; i < e.length; i++) n.push(ee);
919
+ break;
920
+ }
921
+ const r = s.has(e[i]), u = s.has(a[t]);
922
+ if (r && u) {
923
+ let c = i + 1, f = t + 1;
924
+ for (; c < e.length && s.has(e[c]); ) c++;
925
+ for (; f < a.length && s.has(a[f]); ) f++;
926
+ const p = c - i, h = f - t;
927
+ if (p === h)
928
+ for (let I = 0; I < p; I++) n.push(te);
929
+ else {
930
+ const I = Array(p + 1).fill(null).map(() => Array(h + 1).fill(0));
931
+ for (let w = 0; w <= p; w++) I[w][0] = w;
932
+ for (let w = 0; w <= h; w++) I[0][w] = w;
933
+ for (let w = 1; w <= p; w++)
934
+ for (let S = 1; S <= h; S++) {
935
+ const U = e[i + w - 1] === a[t + S - 1] ? 0 : 1;
936
+ I[w][S] = Math.min(I[w - 1][S] + 1, I[w][S - 1] + 1, I[w - 1][S - 1] + U);
937
+ }
938
+ const A = [];
939
+ let k = p, L = h;
940
+ for (; k > 0 || L > 0; )
941
+ if (k === 0)
942
+ A.push(Y), L--;
943
+ else if (L === 0)
944
+ A.push(ee), k--;
945
+ else {
946
+ const w = I[k][L - 1], S = I[k - 1][L], U = I[k - 1][L - 1];
947
+ w < S && w < U ? (A.push(Y), L--) : S < U ? (A.push(ee), k--) : (A.push(te), k--, L--);
948
+ }
949
+ for (let w = A.length - 1; w >= 0; w--) n.push(A[w]);
950
+ }
951
+ i = c, t = f;
952
+ } else r ? (n.push(Y), t++) : u ? (n.push(ee), i++) : (n.push(te), i++, t++);
953
+ }
954
+ return n;
955
+ }
956
+ function ie() {
957
+ return {
958
+ currentChar: N,
959
+ targetChar: N,
960
+ charList: null,
961
+ startIndex: 0,
962
+ endIndex: 0,
963
+ sourceWidth: 0,
964
+ currentWidth: 0,
965
+ targetWidth: 0,
966
+ directionAdj: 1,
967
+ prevDelta: 0,
968
+ currDelta: 0
969
+ };
970
+ }
971
+ function re(e, a, s, i) {
972
+ const t = { ...e };
973
+ t.targetChar = a, t.sourceWidth = t.currentWidth, t.targetWidth = a === N ? 0 : 1;
974
+ let n = !1;
975
+ for (const v of s) {
976
+ const l = v.getCharacterIndices(t.currentChar, a, i);
977
+ if (l) {
978
+ t.charList = v.getCharacterList(), t.startIndex = l.startIndex, t.endIndex = l.endIndex, n = !0;
979
+ break;
980
+ }
981
+ }
982
+ return n || (t.charList = t.currentChar === a ? [t.currentChar] : [t.currentChar, a], t.startIndex = 0, t.endIndex = t.currentChar === a ? 0 : 1), t.directionAdj = t.endIndex >= t.startIndex ? 1 : -1, t.prevDelta = t.currDelta, t.currDelta = 0, t;
983
+ }
984
+ function le(e, a, s = !1) {
985
+ const i = { ...e }, t = Math.abs(i.endIndex - i.startIndex), n = a * t, v = n - Math.floor(n), l = i.prevDelta * (1 - a), r = v * i.directionAdj + l, u = i.startIndex + Math.floor(n) * i.directionAdj;
986
+ return a >= 1 ? (i.currentChar = i.targetChar, i.currDelta = 0, i.prevDelta = 0) : s && i.charList && u >= 0 && u < i.charList.length && (i.currentChar = i.charList[u], i.currDelta = r), i.currentWidth = i.sourceWidth + (i.targetWidth - i.sourceWidth) * a, { col: i, charIdx: u, delta: r };
987
+ }
988
+ const ve = {
989
+ linear: (e) => e,
990
+ easeIn: (e) => e * e,
991
+ easeOut: (e) => 1 - (1 - e) * (1 - e),
992
+ easeInOut: (e) => e < 0.5 ? 2 * e * e : 1 - Math.pow(-2 * e + 2, 2) / 2,
993
+ bounce: (e) => e < 1 / 2.75 ? 7.5625 * e * e : e < 2 / 2.75 ? 7.5625 * (e -= 1.5 / 2.75) * e + 0.75 : e < 2.5 / 2.75 ? 7.5625 * (e -= 2.25 / 2.75) * e + 0.9375 : 7.5625 * (e -= 2.625 / 2.75) * e + 0.984375
994
+ }, oe = 1.2, Ke = /* @__PURE__ */ W({
995
+ __name: "Ticker",
996
+ props: {
997
+ value: { type: String, required: !0 },
998
+ characterLists: { type: Array, default: () => ["0123456789"] },
999
+ duration: { type: Number, default: 500 },
1000
+ direction: { type: String, default: "ANY" },
1001
+ easing: { type: String, default: "easeInOut" },
1002
+ className: { type: String, default: "" },
1003
+ charWidth: { type: Number, default: 1 }
1004
+ },
1005
+ setup(e) {
1006
+ const a = e, s = E([]), i = E(1);
1007
+ let t;
1008
+ const n = T(() => a.characterLists.map((r) => new Fe(r))), v = T(() => {
1009
+ const r = /* @__PURE__ */ new Set();
1010
+ return n.value.forEach((u) => u.getSupportedCharacters().forEach((c) => r.add(c))), r;
1011
+ });
1012
+ j(() => a.value, (r, u) => {
1013
+ if (r === u) return;
1014
+ t && (cancelAnimationFrame(t), t = void 0);
1015
+ let c = s.value;
1016
+ i.value < 1 && i.value > 0 && (c = c.map((C) => le(C, i.value, !0).col));
1017
+ const f = [...r], p = c.map((C) => C.currentChar), h = $e(p, f, v.value);
1018
+ let I = 0, A = 0;
1019
+ const k = [], L = c.filter((C) => C.currentWidth > 0);
1020
+ for (const C of h)
1021
+ if (C === Y)
1022
+ k.push(re(ie(), f[A++], n.value, a.direction));
1023
+ else if (C === te) {
1024
+ const F = L[I++] || ie();
1025
+ k.push(re(F, f[A++], n.value, a.direction));
1026
+ } else {
1027
+ const F = L[I++] || ie();
1028
+ k.push(re(F, N, n.value, a.direction));
1029
+ }
1030
+ s.value = k, i.value = 0;
1031
+ const w = performance.now(), S = a.duration, U = ve[a.easing] || ve.linear;
1032
+ let B = 0;
1033
+ const R = (C) => {
1034
+ const F = Math.min((C - w) / S, 1), D = U(F);
1035
+ if ((C - B >= 16 || F >= 1) && (B = C, i.value = D), F < 1)
1036
+ t = requestAnimationFrame(R);
1037
+ else {
1038
+ const q = s.value.map((G) => le(G, 1).col).filter((G) => G.currentWidth > 0);
1039
+ s.value = q, i.value = 1, t = void 0;
1040
+ }
1041
+ };
1042
+ t = requestAnimationFrame(R);
1043
+ }, { immediate: !0 }), ue(() => {
1044
+ t && cancelAnimationFrame(t);
1045
+ });
1046
+ const l = T(() => s.value.map((r) => {
1047
+ const { charIdx: u, delta: c } = le(r, i.value), f = r.sourceWidth + (r.targetWidth - r.sourceWidth) * i.value;
1048
+ if (f <= 0) return { width: f, chars: [] };
1049
+ const p = [], h = r.charList || [], I = c * oe, A = (C, F, D) => {
1050
+ C >= 0 && C < h.length && p.push({
1051
+ key: `${D}-${C}`,
1052
+ char: h[C],
1053
+ offset: I + F
1054
+ });
1055
+ };
1056
+ A(u, 0, "c"), A(u + 1, -oe, "n"), A(u - 1, oe, "p");
1057
+ const k = (C) => C && C.length > 0 && C.charCodeAt(0) > 255, L = (C) => k(C) ? 1.25 : 0.8, w = h[r.startIndex] || "", S = h[r.endIndex] || "", U = L(w), B = L(S), R = U + (B - U) * i.value;
1058
+ return { width: f, chars: p, baseW: R };
1059
+ }).filter((r) => r.width > 0));
1060
+ return (r, u) => (y(), b("div", {
1061
+ class: P(["ticker", e.className])
1062
+ }, [
1063
+ (y(!0), b(H, null, ae(l.value, (c, f) => (y(), b("div", {
1064
+ key: f,
1065
+ class: "ticker-column",
1066
+ style: J({ width: `${c.width * (c.baseW || 0.8) * e.charWidth}em` })
1067
+ }, [
1068
+ (y(!0), b(H, null, ae(c.chars, (p) => (y(), b("div", {
1069
+ key: p.key,
1070
+ class: "ticker-char",
1071
+ style: J({ transform: `translateY(${p.offset}em)` })
1072
+ }, x(p.char === g(N) ? " " : p.char), 5))), 128))
1073
+ ], 4))), 128))
1074
+ ], 2));
1075
+ }
1076
+ }), Re = (e, a) => {
1077
+ const s = e.__vccOpts || e;
1078
+ for (const [i, t] of a)
1079
+ s[i] = t;
1080
+ return s;
1081
+ }, Ne = /* @__PURE__ */ Re(Ke, [["__scopeId", "data-v-7e47ac69"]]), ge = /* @__PURE__ */ W({
1082
+ __name: "SmartText",
1083
+ props: {
1084
+ text: {},
1085
+ className: {},
1086
+ placeholder: {}
1087
+ },
1088
+ setup(e) {
1089
+ return (a, s) => !e.text && e.placeholder ? (y(), b("span", {
1090
+ key: 0,
1091
+ class: P(["apmsu-placeholder", e.className])
1092
+ }, x(e.placeholder), 3)) : e.text ? (y(), b("span", {
1093
+ key: 1,
1094
+ class: P(["inline-flex min-w-0", e.className])
1095
+ }, [
1096
+ V(g(Ne), {
1097
+ value: e.text,
1098
+ "char-width": 0.8,
1099
+ duration: 300
1100
+ }, null, 8, ["value"])
1101
+ ], 2)) : Q("", !0);
1102
+ }
1103
+ }), De = { class: "apmsu-label" }, Ge = { class: "relative" }, Qe = ["disabled"], _e = {
1104
+ key: 0,
1105
+ class: "flex items-center gap-2 min-w-0"
1106
+ }, ze = ["src", "alt"], Ve = {
1107
+ key: 1,
1108
+ class: "apmsu-placeholder"
1109
+ }, He = ["onClick"], We = { class: "flex items-center gap-2 flex-shrink-0" }, qe = ["src", "alt"], je = { class: "font-medium whitespace-nowrap" }, Xe = { class: "apmsu-hint-text ml-auto text-right truncate flex-1 min-w-0" }, Ye = /* @__PURE__ */ W({
1110
+ __name: "ProviderSelect",
1111
+ props: {
1112
+ providers: {},
1113
+ selectedProviderId: {},
1114
+ disabled: { type: Boolean, default: !1 },
1115
+ language: { default: "zh" }
1116
+ },
1117
+ emits: ["select"],
1118
+ setup(e, { emit: a }) {
1119
+ const s = e, i = a, t = E(!1), n = E(null), v = T(() => Z[s.language]), l = T(() => s.providers.find((c) => c.id === s.selectedProviderId));
1120
+ function r(c) {
1121
+ n.value && !n.value.contains(c.target) && (t.value = !1);
1122
+ }
1123
+ ce(() => {
1124
+ document.addEventListener("mousedown", r);
1125
+ }), ue(() => {
1126
+ document.removeEventListener("mousedown", r);
1127
+ });
1128
+ function u(c) {
1129
+ i("select", c), t.value = !1;
1130
+ }
1131
+ return (c, f) => (y(), b("div", {
1132
+ class: "apmsu-field",
1133
+ ref_key: "triggerRef",
1134
+ ref: n
1135
+ }, [
1136
+ d("label", De, x(v.value.providerLabel), 1),
1137
+ d("div", Ge, [
1138
+ d("button", {
1139
+ type: "button",
1140
+ onClick: f[0] || (f[0] = (p) => !e.disabled && (t.value = !t.value)),
1141
+ disabled: e.disabled,
1142
+ class: "apmsu-select-trigger"
1143
+ }, [
1144
+ l.value ? (y(), b("div", _e, [
1145
+ d("img", {
1146
+ src: l.value.icon,
1147
+ alt: l.value.name,
1148
+ class: "apmsu-provider-icon"
1149
+ }, null, 8, ze),
1150
+ V(ge, {
1151
+ text: l.value.name
1152
+ }, null, 8, ["text"])
1153
+ ])) : (y(), b("span", Ve, x(v.value.selectProvider), 1)),
1154
+ (y(), b("svg", {
1155
+ class: P(["apmsu-chevron", t.value ? "rotate-180" : ""]),
1156
+ fill: "none",
1157
+ stroke: "currentColor",
1158
+ viewBox: "0 0 24 24"
1159
+ }, [...f[1] || (f[1] = [
1160
+ d("path", {
1161
+ "stroke-linecap": "round",
1162
+ "stroke-linejoin": "round",
1163
+ "stroke-width": "2",
1164
+ d: "M19 9l-7 7-7-7"
1165
+ }, null, -1)
1166
+ ])], 2))
1167
+ ], 8, Qe),
1168
+ d("div", {
1169
+ class: P(["apmsu-dropdown max-h-[300px] overflow-auto p-1 origin-top", t.value ? "apmsu-dropdown-open" : ""])
1170
+ }, [
1171
+ (y(!0), b(H, null, ae(e.providers, (p) => (y(), b("button", {
1172
+ key: p.id,
1173
+ type: "button",
1174
+ onClick: (h) => u(p.id),
1175
+ class: P(["apmsu-dropdown-item rounded-sm", e.selectedProviderId === p.id && "apmsu-dropdown-item-active"])
1176
+ }, [
1177
+ d("div", We, [
1178
+ d("img", {
1179
+ src: p.icon,
1180
+ alt: p.name,
1181
+ class: "apmsu-provider-icon"
1182
+ }, null, 8, qe),
1183
+ d("span", je, x(p.name), 1)
1184
+ ]),
1185
+ d("span", Xe, x(p.baseUrl.replace("https://", "")), 1)
1186
+ ], 10, He))), 128))
1187
+ ], 2)
1188
+ ])
1189
+ ], 512));
1190
+ }
1191
+ }), Je = {
1192
+ key: 0,
1193
+ class: "apmsu-field"
1194
+ }, Ze = { class: "apmsu-label" }, et = { class: "relative" }, tt = ["type", "value", "placeholder", "disabled"], at = { class: "absolute right-3 top-1/2 -translate-y-1/2 flex items-center justify-center" }, st = {
1195
+ key: 0,
1196
+ class: "w-4 h-4 text-gray-400",
1197
+ fill: "none",
1198
+ stroke: "currentColor",
1199
+ viewBox: "0 0 24 24"
1200
+ }, nt = {
1201
+ key: 1,
1202
+ class: "w-4 h-4 text-gray-400",
1203
+ fill: "none",
1204
+ stroke: "currentColor",
1205
+ viewBox: "0 0 24 24"
1206
+ }, it = /* @__PURE__ */ W({
1207
+ __name: "AuthInput",
1208
+ props: {
1209
+ provider: {},
1210
+ apiKey: {},
1211
+ testStatus: {},
1212
+ disabled: { type: Boolean, default: !1 },
1213
+ language: { default: "zh" }
1214
+ },
1215
+ emits: ["update:apiKey"],
1216
+ setup(e, { emit: a }) {
1217
+ const s = e, i = a, t = E(!1), n = T(() => Z[s.language]), v = T(() => s.testStatus === "success" ? "apmsu-input apmsu-input-success" : "apmsu-input apmsu-input-default");
1218
+ return (l, r) => e.provider && e.provider.needsApiKey ? (y(), b("div", Je, [
1219
+ d("label", Ze, x(n.value.apiKeyLabel), 1),
1220
+ d("div", et, [
1221
+ d("input", {
1222
+ type: t.value ? "text" : "password",
1223
+ value: e.apiKey,
1224
+ onInput: r[0] || (r[0] = (u) => i("update:apiKey", u.target.value)),
1225
+ onFocus: r[1] || (r[1] = (u) => t.value = !0),
1226
+ onBlur: r[2] || (r[2] = (u) => t.value = !1),
1227
+ placeholder: n.value.apiKeyPlaceholder,
1228
+ disabled: e.disabled,
1229
+ class: P([v.value, "pr-10"])
1230
+ }, null, 42, tt),
1231
+ d("span", at, [
1232
+ t.value ? (y(), b("svg", st, [...r[3] || (r[3] = [
1233
+ d("path", {
1234
+ "stroke-linecap": "round",
1235
+ "stroke-linejoin": "round",
1236
+ "stroke-width": "2",
1237
+ d: "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
1238
+ }, null, -1),
1239
+ d("path", {
1240
+ "stroke-linecap": "round",
1241
+ "stroke-linejoin": "round",
1242
+ "stroke-width": "2",
1243
+ d: "M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"
1244
+ }, null, -1)
1245
+ ])])) : (y(), b("svg", nt, [...r[4] || (r[4] = [
1246
+ d("path", {
1247
+ "stroke-linecap": "round",
1248
+ "stroke-linejoin": "round",
1249
+ "stroke-width": "2",
1250
+ d: "M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"
1251
+ }, null, -1)
1252
+ ])]))
1253
+ ])
1254
+ ])
1255
+ ])) : Q("", !0);
1256
+ }
1257
+ }), rt = { class: "apmsu-label flex items-center justify-between" }, lt = { class: "relative" }, ot = ["disabled"], dt = { class: "p-1.5 border-b border-gray-100 dark:border-zinc-800" }, ct = ["placeholder", "autofocus"], ut = { class: "max-h-60 overflow-auto" }, mt = { class: "text-blue-500" }, pt = ["onClick"], vt = {
1258
+ key: 1,
1259
+ class: "p-4 text-center apmsu-hint-text"
1260
+ }, ht = {
1261
+ key: 0,
1262
+ class: "min-h-[20px] flex items-center"
1263
+ }, ft = {
1264
+ key: 0,
1265
+ class: "apmsu-hint-text animate-pulse"
1266
+ }, gt = {
1267
+ key: 1,
1268
+ class: "apmsu-hint-text dark:text-zinc-500"
1269
+ }, bt = {
1270
+ key: 2,
1271
+ class: "apmsu-hint-text"
1272
+ }, yt = {
1273
+ key: 3,
1274
+ class: "apmsu-hint-text"
1275
+ }, kt = /* @__PURE__ */ W({
1276
+ __name: "ModelSelect",
1277
+ props: {
1278
+ provider: {},
1279
+ models: {},
1280
+ selectedModelId: {},
1281
+ hasApiKey: { type: Boolean },
1282
+ disabled: { type: Boolean, default: !1 },
1283
+ language: { default: "zh" },
1284
+ isFetchingModels: { type: Boolean },
1285
+ fetchModelError: {},
1286
+ selectedModelName: {}
1287
+ },
1288
+ emits: ["select"],
1289
+ setup(e, { emit: a }) {
1290
+ const s = e, i = a, t = E(!1), n = E(""), v = E(null), l = T(() => Z[s.language]), r = T(
1291
+ () => s.models.filter(
1292
+ (p) => p.name.toLowerCase().includes(n.value.toLowerCase()) || p.id.toLowerCase().includes(n.value.toLowerCase())
1293
+ )
1294
+ ), u = T(
1295
+ () => {
1296
+ var p;
1297
+ return ((p = s.models.find((h) => h.id === s.selectedModelId)) == null ? void 0 : p.name) || s.selectedModelName || s.selectedModelId;
1298
+ }
1299
+ );
1300
+ function c(p) {
1301
+ v.value && !v.value.contains(p.target) && (t.value = !1, n.value = "");
1302
+ }
1303
+ ce(() => {
1304
+ document.addEventListener("mousedown", c);
1305
+ }), ue(() => {
1306
+ document.removeEventListener("mousedown", c);
1307
+ });
1308
+ function f(p, h) {
1309
+ i("select", p, h), t.value = !1, n.value = "";
1310
+ }
1311
+ return (p, h) => {
1312
+ var I, A;
1313
+ return y(), b("div", {
1314
+ class: "apmsu-field",
1315
+ ref_key: "triggerRef",
1316
+ ref: v
1317
+ }, [
1318
+ d("label", rt, [
1319
+ d("span", null, x(l.value.modelLabel), 1)
1320
+ ]),
1321
+ d("div", lt, [
1322
+ d("button", {
1323
+ type: "button",
1324
+ onClick: h[0] || (h[0] = (k) => !e.disabled && e.provider && (t.value = !t.value)),
1325
+ disabled: e.disabled || !e.provider,
1326
+ class: "apmsu-select-trigger"
1327
+ }, [
1328
+ V(ge, {
1329
+ text: u.value ? u.value : "",
1330
+ placeholder: l.value.selectModel
1331
+ }, null, 8, ["text", "placeholder"]),
1332
+ (y(), b("svg", {
1333
+ class: P(["apmsu-chevron", t.value ? "rotate-180" : ""]),
1334
+ fill: "none",
1335
+ stroke: "currentColor",
1336
+ viewBox: "0 0 24 24"
1337
+ }, [...h[3] || (h[3] = [
1338
+ d("path", {
1339
+ "stroke-linecap": "round",
1340
+ "stroke-linejoin": "round",
1341
+ "stroke-width": "2",
1342
+ d: "M19 9l-7 7-7-7"
1343
+ }, null, -1)
1344
+ ])], 2))
1345
+ ], 8, ot),
1346
+ d("div", {
1347
+ class: P(["apmsu-dropdown origin-top", t.value ? "apmsu-dropdown-open" : ""])
1348
+ }, [
1349
+ d("div", dt, [
1350
+ ye(d("input", {
1351
+ type: "text",
1352
+ "onUpdate:modelValue": h[1] || (h[1] = (k) => n.value = k),
1353
+ placeholder: l.value.searchModel,
1354
+ class: "apmsu-select-trigger",
1355
+ autofocus: t.value
1356
+ }, null, 8, ct), [
1357
+ [ke, n.value]
1358
+ ])
1359
+ ]),
1360
+ d("div", ut, [
1361
+ n.value && !r.value.some((k) => k.id === n.value) ? (y(), b("button", {
1362
+ key: 0,
1363
+ type: "button",
1364
+ onClick: h[2] || (h[2] = (k) => f(n.value)),
1365
+ class: "apmsu-dropdown-item bg-blue-50 dark:bg-blue-900/20 border-b"
1366
+ }, [
1367
+ d("span", mt, x(l.value.useCustom) + ": " + x(n.value), 1)
1368
+ ])) : Q("", !0),
1369
+ (y(!0), b(H, null, ae(r.value, (k) => (y(), b("button", {
1370
+ key: k.id,
1371
+ type: "button",
1372
+ onClick: (L) => f(k.id, k.name),
1373
+ class: P(["apmsu-dropdown-item", e.selectedModelId === k.id && "apmsu-dropdown-item-active"])
1374
+ }, [
1375
+ d("span", null, x(k.name), 1)
1376
+ ], 10, pt))), 128)),
1377
+ r.value.length === 0 && !n.value ? (y(), b("div", vt, x(l.value.noModels), 1)) : Q("", !0)
1378
+ ])
1379
+ ], 2)
1380
+ ]),
1381
+ (I = e.provider) != null && I.supportsModelsApi ? (y(), b("div", ht, [
1382
+ e.isFetchingModels ? (y(), b("p", ft, x(l.value.refreshingModels), 1)) : e.fetchModelError ? (y(), b("p", gt, x(l.value[e.fetchModelError] || e.fetchModelError), 1)) : (A = e.provider) != null && A.needsApiKey && !e.hasApiKey ? (y(), b("p", bt, x(l.value.apiKeyTip), 1)) : (y(), b("p", yt, x(l.value.modelListUpdated), 1))
1383
+ ])) : Q("", !0)
1384
+ ], 512);
1385
+ };
1386
+ }
1387
+ }), Mt = { class: "overflow-hidden" }, wt = ["value", "placeholder", "disabled"], Ct = /* @__PURE__ */ W({
1388
+ __name: "BaseUrlInput",
1389
+ props: {
1390
+ provider: {},
1391
+ baseUrl: {},
1392
+ disabled: { type: Boolean, default: !1 },
1393
+ language: { default: "zh" }
1394
+ },
1395
+ emits: ["update:baseUrl"],
1396
+ setup(e, { emit: a }) {
1397
+ const s = e, i = a, t = E(!1), n = T(() => Z[s.language]);
1398
+ return (v, l) => e.provider ? (y(), b(H, { key: 0 }, [
1399
+ d("button", {
1400
+ type: "button",
1401
+ onClick: l[0] || (l[0] = (r) => t.value = !t.value),
1402
+ class: "text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 flex items-center gap-1 transition-colors"
1403
+ }, [
1404
+ (y(), b("svg", {
1405
+ class: P(["w-3 h-3 transition-transform", t.value && "rotate-90"]),
1406
+ fill: "none",
1407
+ stroke: "currentColor",
1408
+ viewBox: "0 0 24 24"
1409
+ }, [...l[2] || (l[2] = [
1410
+ d("path", {
1411
+ "stroke-linecap": "round",
1412
+ "stroke-linejoin": "round",
1413
+ "stroke-width": "2",
1414
+ d: "M9 5l7 7-7 7"
1415
+ }, null, -1)
1416
+ ])], 2)),
1417
+ z(" " + x(n.value.customBaseUrl), 1)
1418
+ ]),
1419
+ d("div", {
1420
+ class: "grid transition-all duration-200 ease-out",
1421
+ style: J({ gridTemplateRows: t.value ? "1fr" : "0fr" })
1422
+ }, [
1423
+ d("div", Mt, [
1424
+ d("input", {
1425
+ type: "text",
1426
+ value: e.baseUrl,
1427
+ onInput: l[1] || (l[1] = (r) => i("update:baseUrl", r.target.value)),
1428
+ placeholder: e.provider.baseUrl,
1429
+ disabled: e.disabled,
1430
+ class: "apmsu-input apmsu-input-default"
1431
+ }, null, 40, wt)
1432
+ ])
1433
+ ], 4)
1434
+ ], 64)) : Q("", !0);
1435
+ }
1436
+ }), It = { class: "apmsu-card" }, xt = {
1437
+ key: 0,
1438
+ class: "text-lg font-semibold mb-4"
1439
+ }, At = { class: "space-y-3" }, Et = { class: "space-y-4" }, Lt = { class: "pt-2 space-y-2" }, Ot = { class: "flex gap-2" }, St = ["disabled"], Tt = {
1440
+ key: 0,
1441
+ class: "flex items-center justify-center gap-2"
1442
+ }, Bt = {
1443
+ key: 1,
1444
+ class: "flex items-center justify-center gap-2"
1445
+ }, Pt = {
1446
+ key: 2,
1447
+ class: "flex items-center justify-center gap-2"
1448
+ }, Ut = ["disabled"], Ft = {
1449
+ key: 0,
1450
+ class: "flex items-center justify-center gap-2"
1451
+ }, $t = { class: "overflow-hidden" }, Kt = { class: "p-2 rounded-md bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800" }, Rt = { class: "text-xs text-red-600 dark:text-red-400 line-clamp-3 text-left" }, Nt = {
1452
+ key: 1,
1453
+ class: "mt-6 border border-gray-200/50 dark:border-zinc-800 rounded-lg overflow-hidden"
1454
+ }, Dt = { class: "text-xs font-medium text-gray-500 dark:text-zinc-500 uppercase tracking-wider" }, Gt = { class: "overflow-hidden" }, Qt = { class: "text-xs text-gray-600 dark:text-zinc-400 font-mono overflow-x-auto leading-relaxed p-4 bg-zinc-50 dark:bg-zinc-900/50" }, zt = /* @__PURE__ */ W({
1455
+ __name: "AIConfigForm",
1456
+ props: {
1457
+ proxyUrl: {},
1458
+ config: {},
1459
+ initialConfig: {},
1460
+ title: {},
1461
+ showPreview: { type: Boolean, default: !1 },
1462
+ saveButtonText: {},
1463
+ disabled: { type: Boolean, default: !1 },
1464
+ onSerialize: {},
1465
+ onDeserialize: {},
1466
+ language: { default: "zh" },
1467
+ modelFetcher: {}
1468
+ },
1469
+ emits: ["save", "testResult", "change"],
1470
+ setup(e, { emit: a }) {
1471
+ const s = e, i = a, {
1472
+ providerId: t,
1473
+ apiKey: n,
1474
+ model: v,
1475
+ modelName: l,
1476
+ baseUrl: r,
1477
+ models: u,
1478
+ testStatus: c,
1479
+ testResult: f,
1480
+ provider: p,
1481
+ providers: h,
1482
+ isValid: I,
1483
+ config: A,
1484
+ runTest: k,
1485
+ save: L,
1486
+ selectModel: w,
1487
+ isFetchingModels: S,
1488
+ fetchModelError: U
1489
+ } = Be({
1490
+ proxyUrl: s.proxyUrl,
1491
+ providerConfig: s.config,
1492
+ initialConfig: s.initialConfig,
1493
+ onSerialize: s.onSerialize,
1494
+ onDeserialize: s.onDeserialize,
1495
+ modelFetcher: s.modelFetcher
1496
+ }), B = T(() => Z[s.language]), R = E("idle"), C = E(!1);
1497
+ j([t, n, v, r], () => {
1498
+ i("change", {
1499
+ providerId: t.value,
1500
+ apiKey: n.value,
1501
+ model: v.value,
1502
+ baseUrl: r.value
1503
+ });
1504
+ }), j(f, (m) => {
1505
+ m && i("testResult", m);
1506
+ });
1507
+ function F() {
1508
+ L(), R.value = "saved", i("save", A.value), setTimeout(() => {
1509
+ R.value = "idle";
1510
+ }, 2e3);
1511
+ }
1512
+ function D(m) {
1513
+ t.value = m;
1514
+ }
1515
+ function X(m) {
1516
+ n.value = m;
1517
+ }
1518
+ function q(m, M) {
1519
+ w(m, M);
1520
+ }
1521
+ function G(m) {
1522
+ r.value = m;
1523
+ }
1524
+ return (m, M) => {
1525
+ var $, _, K, me;
1526
+ return y(), b("div", It, [
1527
+ e.title ? (y(), b("h2", xt, x(e.title), 1)) : Q("", !0),
1528
+ d("div", At, [
1529
+ V(Ye, {
1530
+ providers: g(h),
1531
+ selectedProviderId: g(t),
1532
+ onSelect: D,
1533
+ disabled: e.disabled,
1534
+ language: e.language
1535
+ }, null, 8, ["providers", "selectedProviderId", "disabled", "language"]),
1536
+ V(Ct, {
1537
+ provider: g(p),
1538
+ baseUrl: g(r),
1539
+ "onUpdate:baseUrl": G,
1540
+ disabled: e.disabled,
1541
+ language: e.language
1542
+ }, null, 8, ["provider", "baseUrl", "disabled", "language"]),
1543
+ d("div", {
1544
+ class: P(["transition-all duration-500 ease-in-out", g(t) ? "max-h-[1000px] opacity-100 overflow-visible" : "max-h-0 opacity-0 overflow-hidden"])
1545
+ }, [
1546
+ d("div", Et, [
1547
+ V(it, {
1548
+ provider: g(p),
1549
+ apiKey: g(n),
1550
+ "onUpdate:apiKey": X,
1551
+ testStatus: g(c),
1552
+ disabled: e.disabled,
1553
+ language: e.language,
1554
+ isFetchingModels: g(S),
1555
+ fetchModelError: g(U)
1556
+ }, null, 8, ["provider", "apiKey", "testStatus", "disabled", "language", "isFetchingModels", "fetchModelError"]),
1557
+ V(kt, {
1558
+ provider: g(p),
1559
+ models: g(u),
1560
+ selectedModelId: g(v),
1561
+ onSelect: q,
1562
+ hasApiKey: !!g(n),
1563
+ disabled: e.disabled,
1564
+ language: e.language,
1565
+ isFetchingModels: g(S),
1566
+ fetchModelError: g(U),
1567
+ selectedModelName: g(l)
1568
+ }, null, 8, ["provider", "models", "selectedModelId", "hasApiKey", "disabled", "language", "isFetchingModels", "fetchModelError", "selectedModelName"])
1569
+ ])
1570
+ ], 2),
1571
+ d("div", Lt, [
1572
+ d("div", Ot, [
1573
+ d("button", {
1574
+ type: "button",
1575
+ onClick: M[0] || (M[0] = (be) => g(k)()),
1576
+ disabled: !g(t) || !g(n) || !g(v) || e.disabled || g(c) === "testing",
1577
+ class: P([
1578
+ "apmsu-btn flex-1",
1579
+ g(c) === "success" ? "apmsu-btn-success" : g(c) === "error" ? "bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-900/40" : "apmsu-btn-ghost border border-gray-200 dark:border-zinc-700"
1580
+ ])
1581
+ }, [
1582
+ g(c) === "testing" ? (y(), b("span", Tt, [
1583
+ M[2] || (M[2] = d("svg", {
1584
+ class: "apmsu-icon-spin",
1585
+ viewBox: "0 0 24 24",
1586
+ fill: "none"
1587
+ }, [
1588
+ d("circle", {
1589
+ class: "opacity-25",
1590
+ cx: "12",
1591
+ cy: "12",
1592
+ r: "10",
1593
+ stroke: "currentColor",
1594
+ "stroke-width": "4"
1595
+ }),
1596
+ d("path", {
1597
+ class: "opacity-75",
1598
+ fill: "currentColor",
1599
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
1600
+ })
1601
+ ], -1)),
1602
+ z(" " + x(B.value.testing), 1)
1603
+ ])) : g(c) === "success" ? (y(), b("span", Bt, [
1604
+ M[3] || (M[3] = d("svg", {
1605
+ class: "apmsu-icon-success",
1606
+ fill: "currentColor",
1607
+ viewBox: "0 0 24 24"
1608
+ }, [
1609
+ d("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" })
1610
+ ], -1)),
1611
+ z(" " + x(B.value.testSuccess) + " " + x(($ = g(f)) != null && $.latencyMs ? `${g(f).latencyMs}ms` : ""), 1)
1612
+ ])) : g(c) === "error" ? (y(), b("span", Pt, [
1613
+ M[4] || (M[4] = d("svg", {
1614
+ class: "apmsu-icon-error",
1615
+ fill: "currentColor",
1616
+ viewBox: "0 0 24 24"
1617
+ }, [
1618
+ d("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" })
1619
+ ], -1)),
1620
+ z(" " + x(B.value.testFailed), 1)
1621
+ ])) : (y(), b(H, { key: 3 }, [
1622
+ z(x(B.value.testConnection), 1)
1623
+ ], 64))
1624
+ ], 10, St),
1625
+ d("button", {
1626
+ onClick: F,
1627
+ disabled: !g(I) || e.disabled,
1628
+ class: P(["apmsu-btn flex-1", R.value === "saved" ? "apmsu-btn-success" : "apmsu-btn-primary"])
1629
+ }, [
1630
+ R.value === "saved" ? (y(), b("span", Ft, [
1631
+ M[5] || (M[5] = d("svg", {
1632
+ class: "w-4 h-4",
1633
+ fill: "none",
1634
+ stroke: "currentColor",
1635
+ viewBox: "0 0 24 24"
1636
+ }, [
1637
+ d("path", {
1638
+ "stroke-linecap": "round",
1639
+ "stroke-linejoin": "round",
1640
+ "stroke-width": "2.5",
1641
+ d: "M5 13l4 4L19 7"
1642
+ })
1643
+ ], -1)),
1644
+ z(" " + x(B.value.saved), 1)
1645
+ ])) : (y(), b(H, { key: 1 }, [
1646
+ z(x(e.saveButtonText || B.value.save), 1)
1647
+ ], 64))
1648
+ ], 10, Ut)
1649
+ ]),
1650
+ d("div", {
1651
+ class: "grid transition-all duration-200 ease-out",
1652
+ style: J({ gridTemplateRows: !((_ = g(f)) != null && _.success) && ((K = g(f)) != null && K.message) && g(c) !== "testing" && g(c) !== "success" ? "1fr" : "0fr" })
1653
+ }, [
1654
+ d("div", $t, [
1655
+ d("div", Kt, [
1656
+ d("p", Rt, x((me = g(f)) == null ? void 0 : me.message), 1)
1657
+ ])
1658
+ ])
1659
+ ], 4)
1660
+ ])
1661
+ ]),
1662
+ e.showPreview && g(p) ? (y(), b("div", Nt, [
1663
+ d("button", {
1664
+ type: "button",
1665
+ onClick: M[1] || (M[1] = (be) => C.value = !C.value),
1666
+ class: "w-full flex items-center justify-between px-4 py-3 bg-zinc-50 dark:bg-zinc-900/50 hover:bg-zinc-100 dark:hover:bg-zinc-800/50 transition-colors"
1667
+ }, [
1668
+ d("h3", Dt, x(B.value.preview), 1),
1669
+ (y(), b("svg", {
1670
+ class: P(["w-4 h-4 text-gray-400 transition-transform duration-200", C.value ? "rotate-180" : ""]),
1671
+ fill: "none",
1672
+ stroke: "currentColor",
1673
+ viewBox: "0 0 24 24"
1674
+ }, [...M[6] || (M[6] = [
1675
+ d("path", {
1676
+ "stroke-linecap": "round",
1677
+ "stroke-linejoin": "round",
1678
+ "stroke-width": "2",
1679
+ d: "M19 9l-7 7-7-7"
1680
+ }, null, -1)
1681
+ ])], 2))
1682
+ ]),
1683
+ d("div", {
1684
+ class: "grid transition-all duration-200 ease-out",
1685
+ style: J({ gridTemplateRows: C.value ? "1fr" : "0fr" })
1686
+ }, [
1687
+ d("div", Gt, [
1688
+ d("pre", Qt, "" + x(JSON.stringify({
1689
+ provider: g(p).name,
1690
+ apiFormat: g(p).apiFormat,
1691
+ baseUrl: g(r) || g(p).baseUrl,
1692
+ model: g(v) || B.value.unselected,
1693
+ hasApiKey: !!g(n)
1694
+ }, null, 2)) + `
1695
+ `, 1)
1696
+ ])
1697
+ ], 4)
1698
+ ])) : Q("", !0)
1699
+ ]);
1700
+ };
1701
+ }
1702
+ });
1703
+ export {
1704
+ zt as AIConfigForm,
1705
+ Be as useAIConfig
1706
+ };
1707
+ //# sourceMappingURL=index.js.map