1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[69356],{12279:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(56059).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},33004:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(56059).A)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},60074:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(56059).A)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},69356:(e,a,t)=>{t.r(a),t.d(a,{TabExtension:()=>k});var s=t(53757),n=t(24361),r=t(24839),l=t(33004),i=t(79428),d=t(17671),c=t(60039),o=t(60074),x=t(12279);let m=[{id:"ask-default",label:"Default (å
¨ç)",cn:!1},{id:"ask-fallback-1",label:"Fallback 1 (å
¨ç)",cn:!1},{id:"ask-fallback-2",label:"Fallback 2 (å
¨ç)",cn:!1},{id:"ask-default-cn",label:"Default (ä¸å½å¤§é)",cn:!0},{id:"ask-fallback-cn-1",label:"Fallback 1 (ä¸å½å¤§é)",cn:!0},{id:"ask-fallback-cn-2",label:"Fallback 2 (ä¸å½å¤§é)",cn:!0}],u="extension-provider-preference";function p(){let[e,a]=(0,n.useState)("Proof: building in public works.\n\nAnd we're just getting started \uD83D\uDC40\nMore features for quality products coming soon."),[t,c]=(0,n.useState)("friendly"),[o,x]=(0,n.useState)(""),[m,u]=(0,n.useState)(!1),[p,b]=(0,n.useState)(null),h=(0,n.useCallback)(async()=>{if(!e.trim())return;u(!0),b(null);let a=Date.now();try{let s=await fetch("/api/extension/reply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:e.trim(),tone:t,language:o})}),n=await s.json().catch(()=>({}));b({...n,status:s.status,durationMs:Date.now()-a})}catch(e){b({error:e instanceof Error?e.message:"Network error",durationMs:Date.now()-a})}finally{u(!1)}},[e,t,o]),f=p&&200===p.status&&p.reply;return(0,s.jsxs)("section",{className:"rounded-xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900",children:[(0,s.jsxs)("div",{className:"mb-4 flex items-center gap-2",children:[(0,s.jsx)(r.A,{className:"h-4 w-4 text-zinc-500"}),(0,s.jsx)("h2",{className:"text-sm font-semibold",children:"Extension å夿µè¯"}),(0,s.jsx)("span",{className:"ml-auto text-[10px] text-zinc-400",children:"POST /api/extension/reply"})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400",children:"æ¨æå
容"}),(0,s.jsx)("textarea",{value:e,onChange:e=>a(e.target.value),rows:4,className:"w-full rounded-md border border-zinc-200 bg-zinc-50 px-3 py-2 text-xs font-mono dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-100",placeholder:"è¾å
¥æ¨æå
容..."})]}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400",children:"Tone"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("select",{value:t,onChange:e=>c(e.target.value),className:"w-full appearance-none rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 pr-7 text-xs dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-100",children:[(0,s.jsx)("option",{value:"friendly",children:"Friendly"}),(0,s.jsx)("option",{value:"professional",children:"Professional"}),(0,s.jsx)("option",{value:"curious",children:"Curious"}),(0,s.jsx)("option",{value:"humorous",children:"Humorous"})]}),(0,s.jsx)(l.A,{className:"pointer-events-none absolute right-2 top-1/2 h-3 w-3 -translate-y-1/2 text-zinc-400"})]})]}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("label",{className:"mb-1 block text-xs font-medium text-zinc-600 dark:text-zinc-400",children:"Languageï¼ç©º=èªå¨ï¼"}),(0,s.jsx)("input",{type:"text",value:o,onChange:e=>x(e.target.value),placeholder:"en / zh / auto",className:"w-full rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 text-xs dar
1k:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-100"})]})]}),(0,s.jsxs)("button",{type:"button",onClick:h,disabled:m||!e.trim(),className:"flex items-center gap-2 rounded-md bg-zinc-900 px-4 py-2 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900",children:[m?(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(r.A,{className:"h-3.5 w-3.5"}),m?"çæä¸...":"çæåå¤"]}),p&&(0,s.jsx)("div",{className:`rounded-md border px-4 py-3 text-xs ${f?"border-emerald-200 bg-emerald-50 dark:border-emerald-800 dark:bg-emerald-900/20":"border-red-200 bg-red-50 dark:border-red-800 dark:bg-red-900/20"}`,children:f?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(d.A,{className:"h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400"}),(0,s.jsxs)("span",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:["æå \xb7 ",p.durationMs,"ms \xb7 模å: ",p.model??p.modelId??"â"]}),p.provider&&(0,s.jsxs)("span",{className:"text-zinc-500",children:[p.provider," \xb7 ",p.baseUrl??"default"]}),"number"==typeof p.creditsUsed&&(0,s.jsxs)("span",{className:"ml-auto text-zinc-500",children:["-",p.creditsUsed," creditsï¼å©ä½ ",p.creditsLeft??"â","ï¼"]})]}),(0,s.jsx)("div",{className:"whitespace-pre-wrap rounded bg-white/60 p-2 font-mono text-zinc-800 dark:bg-black/20 dark:text-zinc-200",children:p.reply})]}):(0,s.jsxs)("div",{className:"flex items-start gap-2 text-red-700 dark:text-red-300",children:[(0,s.jsxs)("span",{className:"font-medium",children:["HTTP ",p.status??"â"," \xb7 ",p.durationMs,"ms"]}),(0,s.jsx)("span",{className:"ml-1",children:p.error??JSON.stringify(p)})]})})]})]})}function b(){let[e,a]=(0,n.useState)("auto"),[t,r]=(0,n.useState)(!1),[d,m]=(0,n.use
1State)(!1),[p,b]=(0,n.useState)(null),h=(0,n.useCallback)(async()=>{r(!0),b(null);try{let e=await fetch("/api/admin/models"),t=await e.json().catch(()=>null);if(!e.ok)return void b(`å 载失败ï¼HTTP ${e.status}`);let s=Array.isArray(t?.models)?t.models.find(e=>e?.id===u):null,n=(s?.modelId??"").toString().trim().toLowerCase();a("openrouter"===n||"volcengine"===n?n:"auto")}catch(e){b(e instanceof Error?e.message:"å 载失败")}finally{r(!1)}},[]);(0,n.useEffect)(()=>{h()},[h]);let f=(0,n.useCallback)(async()=>{m(!0),b(null);try{let a=await fetch("/api/admin/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:[{id:u,name:"Extension Provider Preference",modelId:e,enabled:!1,priority:9988}]})});if(!a.ok){let e=await a.json().catch(()=>null);b(e?.error||`ä¿å失败ï¼HTTP ${a.status}`);return}b("å·²ä¿å")}catch(e){b(e instanceof Error?e.message:"ä¿å失败")}finally{m(!1)}},[e]);return(0,s.jsxs)("section",{className:"rounded-xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900",children:[(0,s.jsxs)("div",{className:"mb-4 flex items-center gap-2",children:[(0,s.jsx)(c.A,{className:"h-4 w-4 text-zinc-500"}),(0,s.jsx)("h2",{className:"text-sm font-semibold",children:"Extension Provider è·¯ç±"})]}),(0,s.jsx)("p",{className:"mb-4 text-[11px] text-zinc-500 dark:text-zinc-400",children:"宿¶æ§å¶ Extension ä¼å
å°è¯åªä¸ª providerãéæ©âèªå¨âæ¶ï¼æç»å®æ¨¡åèªèº«é
ç½®é¡ºåºæ§è¡ï¼éæ©åºå® provider æ¶ï¼ä¼ä¼å
å°è¯è¯¥ providerï¼å¤±è´¥åä»å¯åéå°å¦ä¸ä¾§ã"}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsxs)("select",{value:e,onChange:e=>a("openrouter"===e.target.value||"volcengine"===e.target.value?e.target.value:"auto"),disabled:t||d,className:"w-full appearance-none rounded-md border border-zinc-200 bg-zinc-50 px-3 py-2 pr-7 text-xs dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-100",children:[(0,s.jsx)("option",{value:"auto",children:"èªå¨ï¼ææ¨¡åé
ç½®ï¼"}),(0,s.jsx)("option",{value:"openrouter",children:"OpenRouter ä¼å
"}),(0,s.jsx)("option",{value:"volcengine",children:"ç«å±±å¼æä¼å
"})]}),(0,s.jsx)(l.A,{className:"pointer-events-none absolute right-2 top-1/2 h-3 w-3 -translate-y-1/2 text-zinc-400"})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>void h(),disabled:t||d,className:"flex items-center gap-1 rounded-md border border-zinc-200 px-3 py-2 text-xs text-zinc-600 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300",children:[(0,s.jsx)(o.A,{className:`h-3 w-3 ${t?"animate-spin":""}`}),"å·æ°"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>void f(),disabled:t||d,className:"flex items-center gap-1 rounded-md bg-zinc-900 px-3 py-2 text-xs font-medium text-white disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-900",children:[d?(0,s.jsx)(i.A,{className:"h-3 w-3 animate-spin"}):(0,s.jsx)(x.A,{className:"h-3 w-3"}),"ä¿å"]})]})]}),p&&(0,s.jsx)("div",{className:`mt-3 text-xs ${"å·²ä¿å"===p?"text-emerald-600 dark:text-emerald-400":"text-red-600 dark:text-red-400"}`,children:p})]})}function h(e){let{models:a,modelsLoading:t}=e,[r,l]=(0,n.useState)({"ask-default":"","ask-fallback-1":"","ask-fallback-2":"","ask-default-cn":"","ask-fallback-cn-1":"","ask-fallback-cn-2":""}),[d,x]=(0,n.useState)(!1),[u,p]=(0,n.useState)(null),[b,h]=(0,n.useState)({}),[k,j]=(0,n.useState)(null),g=(0,n.useCallback)(async()=>{x(!0),j(null);try{let e=await fetch("/api/admin/models");if(!e.ok){let a=await e.json().catch(()=>({}));j(a.error??`HTTP ${e.status}`);return}let a=(await e.json()).models??[],t={};for(let e of m){let s=a.find(a=>a.id===e.id);t[e.id]=s?.modelId??""}l(t)}catch(e){j(e instanceof Error?e.message:"Network error")}finally{x(!1)}},[]);(0,n.useEffect)(()=>{g()},[g]);let v=(0,n.useCallback)(async e=>{let a=(r[e]??"").trim();if(a){p(e),h(a=>({...a,[e]:""}));try{let t=await fetch("/api/admin/models",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({models:[{id:e,name:e,modelId:a,priority:999,enabled:!1}]})}),s=await t.json().catch(()=>({}));t.ok?(h(a=>({...a,[e]:"å·²ä¿å"})),setTimeout(()=>h(a=>({...a,[e]:""})),3e3)):h(a=>({...a,[e]:s.error??`HTTP ${t.status}`}))}catch(a){h(t=>({...t,[e]:a instanceof Error?a.message:"Network error"}))}finally{p(null)}}},[r]);return(0,s.jsxs)("section",{className:"rounded-xl border border-zinc-200 bg-white p-5 shadow-sm dark:border-zinc-800 dark:bg-zinc-900",children:[(0,s.jsxs)("div",{className:"mb-4 flex items-center gap-2",children:[(0,s.jsx)(c.A,{className:"h-4 w-4 text-zinc-500"}),(0,s.jsx)("h2",{className:"text-sm font-semibold",children:"Extension Fallback 模åé
ç½®"}),(0,s.jsxs)("button",{type:"button",onClick:g,disabled:d,className:"ml-auto flex items-center gap-1 rounded px-2 py-1 text-[11px] text-zinc-500 hover:bg-zinc-100 dark:hover:bg-zinc-800",children:[(0,s.jsx)(o.A,{className:`h-3 w-3 ${d?"animate-spin":""}`}),"å·æ°"]})]}),(0,s.jsxs)("p",{className:"mb-4 text-[11px] text-zinc-500 dark:text-zinc-400",children:["é
ç½® Extension çæå夿¶ä½¿ç¨ç模åä¼å
级é¾ã æ¯ä¸ª Binding ID å¯¹åº ",(0,s.jsx)("code",{className:"rounded bg-zinc-100 px-1 dark:bg-zinc-800",children:"model_configs"})," 表ä¸çä¸è¡ï¼ å
¶ ",(0,s.jsx)("code",{className:"rounded bg-zinc-100 px-1 dark:bg-zinc-800",children:"model_id"})," åæ®µæåå®é
模åç IDã ç空表示使ç¨é»è®¤æ¨¡åå
åºã"]}),k&&(0,s.jsx)("div",{className:"mb-3 rounded-md bg-red-50 px-3 py-2 text-xs text-red-700 dark:bg-red-900/20 dark:text-red-300",children:k}),t?(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-zinc-500",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}),"å 载模åå表..."]}):(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wide text-zinc-400",children:"å
¨çï¼éä¸å½å¤§éï¼"}),(0,s.jsx)("div",{className:"space-y-2",children:m.filter(e=>!e.cn).map(e=>(0,s.jsx)(f,{bindingId:e.id,label:e.label,models:a,value:r[e.id]??"",onChange:a=>l(t=>
1({...t,[e.id]:a})),onSave:()=>v(e.id),saving:u===e.id,message:b[e.id]??""},e.id))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wide text-zinc-400",children:"ä¸å½å¤§é"}),(0,s.jsx)("div",{className:"space-y-2",children:m.filter(e=>e.cn).map(e=>(0,s.jsx)(f,{bindingId:e.id,label:e.label,models:a,value:r[e.id]??"",onChange:a=>l(t=>({...t,[e.id]:a})),onSave:()=>v(e.id),saving:u===e.id,message:b[e.id]??""},e.id))})]})]})]})}function f(e){let{bindingId:a,label:t,models:n,value:r,onChange:c,onSave:o,saving:m,message:u}=e,p="å·²ä¿å"===u;return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"w-40 shrink-0 text-xs text-zinc-600 dark:text-zinc-400",children:[(0,s.jsx)("div",{className:"font-medium",children:t}),(0,s.jsx)("div",{className:"font-mono text-[10px] text-zinc-400",children:a})]}),(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsxs)("select",{value:r,onChange:e=>c(e.target.value),className:"w-full appearance-none rounded-md border border-zinc-200 bg-zinc-50 px-3 py-1.5 pr-7 text-xs dark:border-zinc-700 dark:bg-zinc-800 dark:text-zinc-100",children:[(0,s.jsx)("option",{value:"",children:"â æªé
ç½®ï¼ä½¿ç¨é»è®¤å
åºï¼â"}),n.map(e=>(0,s.jsxs)("option",{value:e.id,children:[e.name," (",e.id,")"]},e.id))]}),(0,s.jsx)(l.A,{className:"pointer-events-none absolute right-2 top-1/2 h-3 w-3 -translate-y-1/2 text-zinc-400"})]}),(0,s.jsxs)("button",{type:"button",onClick:o,disabled:m||!r,className:"flex items-center gap-1 rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-900",children:[m?(0,s.jsx)(i.A,{className:"h-3 w-3 animate-spin"}):(0,s.jsx)(x.A,{className:"h-3 w-3"}),"ä¿å"]}),u&&(0,s.jsxs)("span",{className:`text-[11px] ${p?"text-emerald-600 dark:text-emerald-400":"text-red-600 dark:text-red-400"}`,children:[p&&(0,s.jsx)(d.A,{className:"mr-0.5 inline h-3 w-3"}),u]})]})}function k(e){let{adminModels:a,modelsLoading:t,loadAdminModels:r}=e;(0,n.useEffect)(()=>{a||t||"function"!=typeof r||r()},[a,t,r]);let l=Array.isArray(a)?a.map(e=>({id:e.id,name:e.name,modelId:e.modelId})):[];return(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)(p,{}),(0,s.jsx)(b,{}),(0,s.jsx)(h,{models:l,modelsLoading:!!t})]})}},79428:(e,a,t)=>{t.d(a,{A:()=>s});let s=(0,t(56059).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.