@fudrouter/fsrouter 0.6.81 → 0.6.83
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/open-sse/providers/registry/nous-research.js +278 -0
- package/open-sse/providers/registry/nous-research.js +278 -0
- package/package.json +1 -1
- package/public/.vite/manifest.json +89 -89
- package/public/assets/EndpointPageClient.B1Pk_WAK.js +6 -0
- package/public/assets/Loading.CYS14nGq.js +1 -0
- package/public/assets/NoAuthProxyCard.CbdAR_EJ.js +89 -0
- package/public/assets/index.WEEOI9Yd.js +89 -0
- package/public/assets/page.0V4YzdlE.js +1 -0
- package/public/assets/page.4HQp0W96.js +1 -0
- package/public/assets/page.6WqoW7rJ.js +6 -0
- package/public/assets/page.8wawKT_1.js +31 -0
- package/public/assets/page.B3i_xr2T.js +64 -0
- package/public/assets/page.B5WRSQGC.js +1 -0
- package/public/assets/page.B7FGH_5K.js +1 -0
- package/public/assets/page.B9P9zKv3.js +5 -0
- package/public/assets/page.BKP0wYIK.js +23 -0
- package/public/assets/page.BYBO0NtL.js +1 -0
- package/public/assets/page.Bg89P00k.js +1 -0
- package/public/assets/page.BqAhnX2u.js +1 -0
- package/public/assets/page.BrFtZdnn.js +2 -0
- package/public/assets/page.BuWdnu7k.js +1 -0
- package/public/assets/page.CDv8_as_.js +1 -0
- package/public/assets/page.CKjbKM6f.js +1 -0
- package/public/assets/page.CWfxstdC.js +5 -0
- package/public/assets/page.Cc2BUz5h.js +1 -0
- package/public/assets/page.Ce_8sge3.js +4 -0
- package/public/assets/page.CfVZCsMm.js +1 -0
- package/public/assets/page.ClOh42sE.js +1 -0
- package/public/assets/page.CuA_DfQG.js +1 -0
- package/public/assets/page.DCPWvJU4.js +1 -0
- package/public/assets/page.DP-BfKv8.js +1 -0
- package/public/assets/page.DQ0jp0G1.js +1 -0
- package/public/assets/page.DYd0ZEzM.js +1 -0
- package/public/assets/page.D_05_f-z.js +1 -0
- package/public/assets/page.Dc_ARSSS.js +1 -0
- package/public/assets/page.DjkxfoPR.js +1 -0
- package/public/assets/page.FrFOYEwa.js +1 -0
- package/public/assets/page.PTAgP9hn.js +1 -0
- package/public/assets/page.SS6G2WdS.js +1 -0
- package/public/assets/page.W9wqy988.js +1 -0
- package/public/assets/page.f_n3mtFq.js +1 -0
- package/public/assets/page.mc94aTsQ.js +1 -0
- package/public/assets/page.q9bsf4tq.js +2 -0
- package/public/assets/page.y4Bfqvc0.js +6 -0
- package/public/index.html +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./index.WEEOI9Yd.js";import{b as n}from"./router.Cjj1--8t.js";import"./zustand.akaTi5uX.js";function j(){const[o,p]=n.useState("tts"),[x,h]=n.useState(""),[t,s]=n.useState(null),[i,r]=n.useState(!1),u=async()=>{r(!0);try{const a=await fetch("/api/audio/speech",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({input:x,model:"tts-1",voice:"alloy"})});if(a.ok){const c=await a.blob();s({audio:URL.createObjectURL(c)})}else s({error:await a.text()})}catch(a){s({error:a.message})}r(!1)},m=async a=>{const c=a.target.files[0];if(!c)return;r(!0);const l=new FormData;l.append("file",c),l.append("model","whisper-1");try{const d=await fetch("/api/audio/transcriptions",{method:"POST",body:l});s(await d.json())}catch(d){s({error:d.message})}r(!1)};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Audio"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>p("tts"),className:`px-4 py-2 rounded-lg ${o==="tts"?"bg-primary text-white":"bg-black/5"}`,children:"Text to Speech"}),e.jsx("button",{onClick:()=>p("stt"),className:`px-4 py-2 rounded-lg ${o==="stt"?"bg-primary text-white":"bg-black/5"}`,children:"Speech to Text"})]}),o==="tts"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("textarea",{className:"w-full p-3 rounded-lg border h-40",placeholder:"Enter text to convert to speech...",value:x,onChange:a=>h(a.target.value)}),e.jsx("button",{onClick:u,disabled:i,className:"px-4 py-2 bg-primary text-white rounded-lg",children:i?"Generating...":"Generate Speech"}),(t==null?void 0:t.audio)&&e.jsx("audio",{controls:!0,src:t.audio,className:"w-full"})]}),o==="stt"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{type:"file",accept:"audio/*",onChange:m,className:"block"}),i&&e.jsx("p",{children:"Transcribing..."})]}),(t==null?void 0:t.error)&&e.jsx("p",{className:"text-red-500",children:t.error}),(t==null?void 0:t.text)&&e.jsx("pre",{className:"p-4 bg-black/5 rounded-lg text-sm",children:t.text})]})}export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s,B as Be,k as je,l as Ie,h as Le}from"./index.WEEOI9Yd.js";import{b as d}from"./router.Cjj1--8t.js";import{B as qe}from"./NoAuthProxyCard.CbdAR_EJ.js";import"./zustand.akaTi5uX.js";const O={sessions:"basic-chat.sessions",activeSessionId:"basic-chat.activeSessionId",activeProviderId:"basic-chat.activeProviderId",draft:"basic-chat.draft"};function J(){var e;return(e=globalThis.crypto)!=null&&e.randomUUID?globalThis.crypto.randomUUID():`chat_${Date.now()}_${Math.random().toString(16).slice(2)}`}function Fe(e,a){try{return JSON.parse(e)}catch{return a}}function S(e){if(typeof e=="string")return e;if(e==null)return"";if(Array.isArray(e))return e.map(S).filter(Boolean).join(" ");if(typeof e=="object"){if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function He(e=""){return String(e).replace(/[-_]/g," ").replace(/\b\w/g,a=>a.toUpperCase()).trim()||"Unknown"}function Je(e){if(!e)return"Now";const a=new Date(e).getTime();if(Number.isNaN(a))return"Now";const m=Math.max(1,Math.round((Date.now()-a)/6e4));if(m<60)return`${m}m`;const u=Math.round(m/60);return u<24?`${u}h`:`${Math.round(u/24)}d`}function Ne(e=""){const a=S(e).replace(/\s+/g," ").trim();return a?a.length>52?`${a.slice(0,52).trimEnd()}…`:a:"New chat"}function Ke(e){const a=S(e.content).trim(),m=Array.isArray(e.attachments)?e.attachments:[];if(m.length===0)return a;const u=[];a&&u.push({type:"text",text:a});for(const w of m)w!=null&&w.dataUrl&&u.push({type:"image_url",image_url:{url:w.dataUrl}});return u.length>0?u:a}function We(e){var w,A;if(!e||typeof e!="object")return"";const a=(w=e.choices)==null?void 0:w[0];return[((a==null?void 0:a.delta)||{}).content,(A=a==null?void 0:a.message)==null?void 0:A.content,e.output_text,e.text].map(S).filter(Boolean)[0]||""}async function Ye(e){return await new Promise((a,m)=>{const u=new FileReader;u.onload=()=>a(String(u.result||"")),u.onerror=()=>m(u.error||new Error("Failed to read file")),u.readAsDataURL(e)})}function Ve(e){return{...e,messages:Array.isArray(e.messages)?e.messages.map(a=>({...a})):[]}}function de(e){return(e==null?void 0:e.name)||He((e==null?void 0:e.provider)||(e==null?void 0:e.id)||"provider")}function Ge(e,a){return e!=null&&e.id?{id:`${a.provider}/${e.id}`,requestModel:`${a.provider}/${e.id}`,name:e.name||e.id,providerId:a.provider,providerName:de(a),source:"static"}:null}function Qe(e,a){const m=typeof e=="string"?e:(e==null?void 0:e.id)||(e==null?void 0:e.name)||(e==null?void 0:e.model)||"";if(!m)return null;const u=typeof e=="string"?e:(e==null?void 0:e.name)||(e==null?void 0:e.displayName)||m;let w=m;return(je(a.provider)||Ie(a.provider))&&!m.includes("/")&&(w=`${a.provider}/${m}`),{id:w,requestModel:w,name:u,providerId:a.provider,providerName:de(a),source:"live"}}function Xe(e){return Array.isArray(e==null?void 0:e.models)?e.models:Array.isArray(e==null?void 0:e.data)?e.data:Array.isArray(e==null?void 0:e.results)?e.results:Array.isArray(e)?e:[]}function Ze(e){const a=new Map;for(const m of e)m!=null&&m.id&&(a.has(m.id)||a.set(m.id,m));return Array.from(a.values())}function et(){const[e,a]=d.useState([]),[m,u]=d.useState(!0),[w,A]=d.useState(""),[h,D]=d.useState(()=>{if(typeof window>"u")return[];try{const t=Fe(globalThis.localStorage.getItem(O.sessions),[]);return Array.isArray(t)?t.map(r=>({...r,messages:Array.isArray(r.messages)?r.messages:[]})):[]}catch{return[]}}),[g,M]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeSessionId)||""),[R,P]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.activeProviderId)||""),[I,U]=d.useState(""),[_,ce]=d.useState(()=>typeof window>"u"?"":globalThis.localStorage.getItem(O.draft)||""),[z,Q]=d.useState([]),[me,ue]=d.useState(!1),[Se,pe]=d.useState(""),[fe,X]=d.useState(""),[K,Ae]=d.useState(!1),[Me,Z]=d.useState(!1),[De,ee]=d.useState(!1),xe=d.useRef(null),B=d.useRef(null),te=d.useRef(!1),se=d.useRef(null),re=d.useRef(null);d.useEffect(()=>{Ae(!0)},[]),d.useEffect(()=>{let t=!1;async function r(){u(!0),A("");try{const n=await(await fetch("/api/providers",{cache:"no-store"})).json().catch(()=>({})),o=Array.isArray(n.connections)?n.connections.filter(c=>(c==null?void 0:c.isActive)!==!1):[];if(o.length===0){t||(a([]),A("No providers connected yet."));return}const x=new Map;for(const c of o){const p=c.provider||c.id,b=de(c),$=je(p)?"openai-compatible":Ie(p)?"anthropic-compatible":p;x.has(p)||x.set(p,{providerId:p,providerName:b,providerType:$,connections:[],models:[]});const N=x.get(p);N.providerName=N.providerName||b,N.providerType=N.providerType||$,N.connections.push(c);const W=Le(p).map(Y=>Ge(Y,c)).filter(Boolean);N.models.push(...W)}const k=await Promise.all(o.map(async c=>{try{const p=await fetch(`/api/providers/${c.id}/models`,{cache:"no-store"}),b=await p.json().catch(()=>({}));if(!p.ok)return{connection:c,models:[]};const $=Xe(b).map(N=>Qe(N,c)).filter(Boolean);return{connection:c,models:$}}catch{return{connection:c,models:[]}}}));for(const c of k){const p=c.connection.provider||c.connection.id,b=x.get(p);b&&b.models.push(...c.models)}const q=Array.from(x.values()).map(c=>({...c,models:Ze(c.models).sort((p,b)=>p.name.localeCompare(b.name))})).filter(c=>c.models.length>0).sort((c,p)=>c.providerName.localeCompare(p.providerName));t||(a(q),q.length===0&&A("Providers connected but no models available."))}catch(i){t||(A(S(i==null?void 0:i.message)||"Failed to load providers/models."),a([]))}finally{t||u(!1)}}return r(),()=>{t=!0}},[]),d.useEffect(()=>{const t=r=>{se.current&&!se.current.contains(r.target)&&Z(!1),re.current&&!re.current.contains(r.target)&&ee(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const y=d.useMemo(()=>{const t=new Map;for(const r of e)for(const i of r.models)t.set(i.id,{...i,providerId:r.providerId,providerName:r.providerName});return t},[e]),E=d.useMemo(()=>e.find(t=>t.providerId===R)||e[0]||null,[e,R]),v=d.useMemo(()=>{var t;if(I&&y.has(I))return y.get(I);if(g){const r=h.find(i=>i.id===g);if(r!=null&&r.modelId&&y.has(r.modelId))return y.get(r.modelId)}return((t=E==null?void 0:E.models)==null?void 0:t[0])||null},[I,y,E,h,g]),ie=d.useMemo(()=>h.find(t=>t.id===g)||null,[h,g]),he=(ie==null?void 0:ie.messages)||[],ge=d.useMemo(()=>[...h].sort((t,r)=>new Date(r.updatedAt).getTime()-new Date(t.updatedAt).getTime()),[h]),ae=!me&&!!v&&(_.trim().length>0||z.length>0);d.useEffect(()=>{if(K)try{globalThis.localStorage.setItem(O.sessions,JSON.stringify(h)),globalThis.localStorage.setItem(O.activeSessionId,g),globalThis.localStorage.setItem(O.activeProviderId,R),globalThis.localStorage.setItem(O.draft,_)}catch{}},[K,h,g,R,_]),d.useEffect(()=>{if(!K||m||te.current||e.length===0)return;const t=e.find(n=>n.providerId===R)||e[0],r=I&&y.has(I)?y.get(I):t.models[0];if(h.length>0){const n=h.find(x=>x.id===g)||h[0],o=n!=null&&n.modelId&&y.has(n.modelId)?y.get(n.modelId):r;te.current=!0,M(n.id),P((o==null?void 0:o.providerId)||t.providerId),U((o==null?void 0:o.id)||r.id);return}const i={id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:r.id,modelName:r.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]};te.current=!0,D([i]),M(i.id),P(t.providerId),U(r.id)},[K,m,e,y,h,g,R,I]);const L=(t,r)=>{D(i=>i.map(n=>n.id===t?r(Ve(n)):n))},ne=t=>t?{id:J(),title:"New chat",providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),messages:[]}:null,ke=t=>{const r=h.find(i=>i.id===t);r&&(M(t),P(r.providerId||R),U(r.modelId||I),ee(!1))},Te=()=>{if(!g)return;const t=h.filter(i=>i.id!==g),r=t[0]||null;D(t),r?(M(r.id),P(r.providerId),U(r.modelId)):(M(""),P(""),U(""))},Ce=t=>{const r=y.get(t);if(!r)return;const i=h.find(n=>n.id===g);if(i&&i.messages.length>0){const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}else if(i)D(n=>n.map(o=>o.id===i.id?{...o,providerId:r.providerId,providerName:r.providerName,modelId:r.id,modelName:r.name}:o)),M(i.id);else{const n=ne(r);if(!n)return;D(o=>[n,...o]),M(n.id)}P(r.providerId),U(r.id),Z(!1)},Oe=async t=>{const r=Array.from(t.target.files||[]);if(r.length===0)return;const i=r.filter(o=>o.type.startsWith("image/"));if(i.length===0){t.target.value="";return}const n=await Promise.all(i.map(async o=>({id:J(),name:o.name,type:o.type,size:o.size,dataUrl:await Ye(o)})));Q(o=>[...o,...n]),t.target.value=""},Re=t=>{Q(r=>r.filter(i=>i.id!==t))},Ee=()=>{var t;(t=B.current)==null||t.abort()},$e=(t,r)=>{const i=Ne(r);L(t,n=>({...n,title:n.title==="New chat"?i:n.title,updatedAt:new Date().toISOString()}))},we=async()=>{var p,b,$,N,W,Y;const t=v||((p=E==null?void 0:E.models)==null?void 0:p[0])||null;if(!t)return;const r=_.trim();if(!r&&z.length===0)return;let i=g,n=h.find(l=>l.id===i);if(!n){if(n=ne(t),!n)return;i=n.id,D(l=>[n,...l]),M(i)}const o={id:J(),role:"user",content:r,attachments:z.map(l=>({id:l.id,name:l.name,type:l.type,dataUrl:l.dataUrl})),createdAt:new Date().toISOString()},x=J(),k={id:x,role:"assistant",content:"",createdAt:new Date().toISOString(),status:"streaming"},q=[...n.messages||[],o,k];D(l=>l.map(j=>j.id===i?{...j,providerId:t.providerId,providerName:t.providerName,modelId:t.id,modelName:t.name,messages:q,updatedAt:new Date().toISOString(),title:j.title==="New chat"?Ne(r):j.title}:j)),ce(""),Q([]),ue(!0),pe(x),X(""),(b=B.current)==null||b.abort(),B.current=new AbortController;const c=q.filter(l=>!(l.role==="assistant"&&l.id===x)).map(l=>({role:l.role,content:l.role==="user"?Ke(l):l.content}));try{const l=await fetch("/api/dashboard/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({model:t.requestModel||t.id,messages:c,stream:!0}),signal:B.current.signal});if(!l.ok){const f=await l.json().catch(()=>({}));throw new Error(S(f.error||f.message||`Request failed (${l.status})`))}const j=($=l.body)==null?void 0:$.getReader();if(!j){const f=await l.json().catch(()=>({})),C=S(((Y=(W=(N=f==null?void 0:f.choices)==null?void 0:N[0])==null?void 0:W.message)==null?void 0:Y.content)||(f==null?void 0:f.output_text)||(f==null?void 0:f.error)||(f==null?void 0:f.message)||"");L(i,F=>({...F,messages:F.messages.map(H=>H.id===x?{...H,content:C,status:"done"}:H),updatedAt:new Date().toISOString()}));return}const V=new TextDecoder;let T="",G="";for(;;){const{value:f,done:C}=await j.read();if(C)break;T+=V.decode(f,{stream:!0});const F=T.split(/\r?\n/);T=F.pop()||"";for(const H of F){const ve=H.trim();if(!ve.startsWith("data:"))continue;const oe=ve.slice(5).trim();if(!(!oe||oe==="[DONE]"))try{const ze=JSON.parse(oe),be=We(ze);if(!be)continue;G+=be,X(G),L(i,ye=>({...ye,messages:ye.messages.map(le=>le.id===x?{...le,content:G,status:"streaming"}:le),updatedAt:new Date().toISOString()}))}catch{}}}L(i,f=>({...f,messages:f.messages.map(C=>C.id===x?{...C,content:G||C.content,status:"done"}:C),updatedAt:new Date().toISOString()})),$e(i,r)}catch(l){if(l.name!=="AbortError"){const j=S((l==null?void 0:l.message)||l);L(i,V=>({...V,messages:V.messages.map(T=>T.id===x?{...T,content:T.content||`Error: ${j}`,status:"error"}:T),updatedAt:new Date().toISOString()})),A(j||"Failed to send message.")}}finally{ue(!1),pe(""),X(""),B.current=null}},Pe=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ae&&we())},Ue=v?`${v.name}`:"Select model",_e=v?v.requestModel:"Choose from connected providers";return s.jsx("div",{className:"relative flex-1 flex flex-col h-full min-h-0 min-w-0 bg-[#212121] text-white overflow-hidden",children:s.jsxs("div",{className:"relative mx-auto flex flex-1 h-full min-h-0 w-full max-w-4xl flex-col",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 px-4 py-3 lg:px-6",children:[s.jsxs("div",{ref:se,className:"relative",children:[s.jsx("button",{type:"button",onClick:()=>Z(t=>!t),className:"flex items-center gap-3 rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-left transition hover:bg-white/8",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-semibold text-white",children:Ue}),s.jsx("span",{className:"material-symbols-outlined text-[18px] text-white/70",children:"expand_more"})]}),s.jsx("p",{className:"truncate text-xs text-white/55",children:_e})]})}),Me?s.jsxs("div",{className:"absolute left-0 top-[calc(100%+10px)] z-30 w-[min(520px,calc(100vw-2rem))] overflow-hidden rounded-[20px] border border-white/10 bg-[#262626] shadow-2xl shadow-black/50",children:[s.jsxs("div",{className:"border-b border-white/10 px-4 py-3",children:[s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Models"}),s.jsx("p",{className:"text-sm text-white/75",children:"Only from connected providers"})]}),s.jsx("div",{className:"max-h-[60vh] overflow-y-auto p-2 custom-scrollbar",children:e.map(t=>s.jsxs("div",{className:"mb-2 rounded-[16px] border border-white/10 bg-black/20 p-2",children:[s.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[s.jsx("p",{className:"text-sm font-semibold text-white",children:t.providerName}),s.jsx(qe,{size:"sm",variant:"default",children:t.models.length})]}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:t.models.map(r=>{const i=r.id===I;return s.jsx("button",{type:"button",onClick:()=>Ce(r.id),className:`rounded-[14px] border px-3 py-3 text-left transition ${i?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:r.name}),s.jsx("p",{className:"truncate text-[11px] text-white/45",children:r.requestModel})]}),i?s.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-300",children:"check_circle"}):null]})},r.id)})})]},t.providerId))})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>ee(t=>!t),className:"rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white/80 transition hover:bg-white/8",children:"History"}),s.jsx(Be,{variant:"ghost",size:"sm",icon:"delete",onClick:Te,disabled:!g||h.length===0,children:"Clear"})]})]}),De?s.jsxs("div",{ref:re,className:"absolute right-4 top-[72px] z-20 w-[min(360px,calc(100vw-2rem))] rounded-[20px] border border-white/10 bg-[#262626] p-2 shadow-2xl shadow-black/50 lg:right-6",children:[s.jsx("div",{className:"px-3 py-2",children:s.jsx("p",{className:"text-xs uppercase tracking-[0.22em] text-white/45",children:"Recent chats"})}),s.jsx("div",{className:"max-h-[48vh] space-y-2 overflow-y-auto p-1 custom-scrollbar",children:ge.length===0?s.jsx("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/5 p-4 text-sm text-white/55",children:"No conversations yet."}):ge.map(t=>{var n;const r=t.id===g,i=[...t.messages||[]].reverse().find(o=>o.role==="user")||((n=t.messages)==null?void 0:n[0]);return s.jsx("button",{type:"button",onClick:()=>ke(t.id),className:`w-full rounded-[16px] border px-3 py-3 text-left transition ${r?"border-blue-400/40 bg-blue-500/15":"border-white/10 bg-white/5 hover:bg-white/8"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"truncate text-sm font-medium text-white",children:t.title}),s.jsx("p",{className:"mt-1 truncate text-xs text-white/50",children:S(i==null?void 0:i.content)||"Empty chat"})]}),s.jsx("span",{className:"text-[10px] text-white/40 shrink-0",children:Je(t.updatedAt)})]})},t.id)})})]}):null,w?s.jsx("div",{className:"mt-4 rounded-[18px] border border-rose-500/20 bg-rose-500/10 px-4 py-3 text-rose-100",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"error"}),s.jsx("p",{className:"text-sm leading-6",children:w})]})}):null,s.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[s.jsxs("div",{className:"flex-1 overflow-y-auto py-4 custom-scrollbar",children:[he.length===0?s.jsx("div",{className:"flex min-h-[50vh] items-center justify-center px-4 text-center",children:s.jsxs("div",{className:"max-w-xl space-y-4",children:[s.jsx("div",{className:"mx-auto flex size-16 items-center justify-center rounded-[20px] border border-white/10 bg-white/5 text-white/80",children:s.jsx("span",{className:"material-symbols-outlined text-[30px]",children:"chat"})}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("h2",{className:"text-2xl font-semibold text-white",children:"Start a conversation"}),s.jsx("p",{className:"text-sm leading-6 text-white/60",children:"Simple chat interface to interact with any AI model from connected providers. Select a model and start chatting!"})]})]})}):null,s.jsx("div",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 px-4",children:he.map(t=>{var x;const r=t.role==="user",i=t.role==="assistant",n=i&&t.id===Se&&t.status==="streaming",o=S(t.content)||(i?fe:"");return s.jsx("div",{className:`flex w-full ${r?"justify-end":"justify-start"} mb-6`,children:s.jsxs("div",{className:`max-w-[min(88%,42rem)] ${r?"rounded-3xl bg-[#2f2f2f] px-5 py-3.5 text-white":"text-white/90"}`,children:[s.jsx("div",{className:"mb-1 flex items-center justify-between gap-3",children:s.jsx("span",{className:"text-xs font-semibold",children:r?"You":(v==null?void 0:v.name)||"Assistant"})}),(x=t.attachments)!=null&&x.length?s.jsx("div",{className:"mb-3 grid grid-cols-2 gap-2 sm:grid-cols-3 mt-2",children:t.attachments.map(k=>s.jsx("a",{href:k.dataUrl,target:"_blank",rel:"noreferrer",className:"overflow-hidden rounded-[18px] border border-white/10 bg-black/20",children:s.jsx("img",{src:k.dataUrl,alt:k.name,className:"h-28 w-full object-cover"})},k.id))}):null,s.jsxs("div",{className:"whitespace-pre-wrap break-words text-[15px] leading-7",children:[o,i&&n&&!fe?s.jsx("span",{className:"inline-block animate-pulse",children:"▋"}):null]})]})},t.id)})})]}),s.jsxs("div",{className:"shrink-0 pt-2",children:[z.length>0?s.jsx("div",{className:"mx-auto mb-3 flex w-full max-w-3xl flex-wrap gap-2 px-4",children:z.map(t=>s.jsxs("div",{className:"flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-white/80 max-w-[12rem] truncate",children:t.name}),s.jsx("button",{type:"button",onClick:()=>Re(t.id),className:"text-white/55 hover:text-white","aria-label":"Remove attachment",children:s.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"close"})})]},t.id))}):null,s.jsx("div",{className:"mx-auto w-full max-w-3xl px-4 pb-2",children:s.jsxs("div",{className:"rounded-[26px] bg-[#2f2f2f] px-3 pt-3 pb-2 shadow-[0_0_15px_rgba(0,0,0,0.10)] ring-1 ring-white/5",children:[s.jsx("textarea",{value:_,onChange:t=>ce(t.target.value),onKeyDown:Pe,placeholder:"Message AI",rows:1,className:"w-full resize-none bg-transparent px-2 text-[15px] leading-6 text-white outline-none placeholder:text-white/40 custom-scrollbar max-h-[25vh] overflow-y-auto"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>{var t;return(t=xe.current)==null?void 0:t.click()},disabled:!v||m,className:"p-2 text-white/50 hover:text-white transition rounded-full hover:bg-white/5",children:s.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"attach_file"})}),s.jsx("input",{ref:xe,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Oe}),s.jsx("span",{className:"text-xs font-medium text-white/30 truncate max-w-[120px]",children:v?v.name:"No model"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[me?s.jsx("button",{type:"button",onClick:Ee,className:"p-2 text-white bg-white/10 hover:bg-white/20 transition rounded-full h-8 w-8 flex items-center justify-center",children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"stop"})}):null,s.jsx("button",{onClick:we,disabled:!ae,className:`h-8 w-8 rounded-full flex items-center justify-center transition ${ae?"bg-white text-black hover:opacity-90":"bg-white/10 text-white/30 cursor-not-allowed"}`,children:s.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})})]})]})]})})]}),s.jsx("p",{className:"mx-auto mt-2 max-w-3xl px-4 pb-4 text-center text-[11px] text-white/30",children:"Model list is filtered from connected providers."})]})]})})}function at(){return s.jsx(et,{})}export{at as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as ot,j as e,B as i,M as I,C as lt}from"./index.WEEOI9Yd.js";import{b as l}from"./router.Cjj1--8t.js";import{C as Pe,B as k,T as ie,I as y}from"./NoAuthProxyCard.CbdAR_EJ.js";import{C as Se}from"./Loading.CYS14nGq.js";import"./zustand.akaTi5uX.js";function at(x){return x==="active"?"success":x==="error"?"error":"default"}function nt(x){if(!x)return"Never";const W=new Date(x);return Number.isNaN(W.getTime())?"Never":W.toLocaleString()}function ce(x={}){return{name:x.name||"",proxyUrl:x.proxyUrl||"",noProxy:x.noProxy||"",isActive:x.isActive!==!1,strictProxy:x.strictProxy===!0}}function ht(){const[x,W]=l.useState([]),[De,A]=l.useState(!1),[$,B]=l.useState(""),[b,L]=l.useState([]),[E,Y]=l.useState(null),[c,U]=l.useState([]),[Te,Ie]=l.useState(!0),[Ae,K]=l.useState(!1),[$e,Q]=l.useState(!1),[Ee,de]=l.useState(!1),[Ue,xe]=l.useState(!1),[Oe,me]=l.useState(!1),[O,M]=l.useState(!1),[V,he]=l.useState(null),[u,C]=l.useState(ce()),[X,ue]=l.useState(""),[F,Z]=l.useState({vercelToken:"",projectName:"vercel-relay"}),[j,_]=l.useState({accountId:"",apiToken:"",projectName:"cloudflare-relay"}),[N,q]=l.useState({denoToken:"",orgDomain:"",projectName:""}),[R,pe]=l.useState(!1),[J,fe]=l.useState(!1),[p,S]=l.useState(!1),[ee,ye]=l.useState(null),[h,H]=l.useState([]),[v,ge]=l.useState(!1),[be,te]=l.useState({current:0,total:0}),[z,D]=l.useState(!1),[g,w]=l.useState(null),se=l.useRef(null),n=ot();l.useEffect(()=>{const t=s=>{se.current&&!se.current.contains(s.target)&&M(!1)};return O&&document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[O]);const f=l.useCallback(async()=>{try{const t=await fetch("/api/proxy-pools?includeUsage=true",{cache:"no-store"}),s=await t.json();t.ok&&U(s.proxyPools||[])}catch(t){console.log("Error fetching proxy pools:",t)}finally{Ie(!1)}},[]),G=l.useCallback(async()=>{try{const t=await fetch("/api/proxy-combos",{cache:"no-store"}),s=await t.json();t.ok&&W(s.combos||[])}catch{}},[]);l.useEffect(()=>{f(),G()},[f,G]);const je=()=>{he(null),C(ce())},ve=()=>{je(),K(!0)},Me=t=>{he(t),C(ce(t)),K(!0)},re=()=>{K(!1),je()},Fe=async()=>{const t={name:u.name.trim(),proxyUrl:u.proxyUrl.trim(),noProxy:u.noProxy.trim(),isActive:u.isActive===!0,strictProxy:u.strictProxy===!0};if(!(!t.name||!t.proxyUrl)){pe(!0);try{const s=!!V,r=await fetch(s?`/api/proxy-pools/${V.id}`:"/api/proxy-pools",{method:s?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(r.ok)await f(),re(),n.success(V?"Proxy pool updated":"Proxy pool created");else{const o=await r.json();n.error(o.error||"Failed to save proxy pool")}}catch(s){console.log("Error saving proxy pool:",s)}finally{pe(!1)}}},Re=async t=>{w({title:"Delete Proxy Pool",message:`Delete proxy pool "${t.name}"?`,onConfirm:async()=>{w(null);try{const s=await fetch(`/api/proxy-pools/${t.id}`,{method:"DELETE"});if(s.ok){U(o=>o.filter(a=>a.id!==t.id)),n.success("Proxy pool deleted");return}const r=await s.json();s.status===409?n.warning(`Cannot delete: ${r.boundConnectionCount||0} connection(s) are still using this pool.`):n.error(r.error||"Failed to delete proxy pool")}catch(s){console.log("Error deleting proxy pool:",s),n.error("Failed to delete proxy pool")}}})},ze=async t=>{ye(t);try{const s=await fetch(`/api/proxy-pools/${t}/test`,{method:"POST"}),r=await s.json();if(!s.ok){n.error(r.error||"Failed to test proxy");return}await f(),n.success(r.ok?"Proxy test passed":"Proxy test failed")}catch(s){console.log("Error testing proxy pool:",s),n.error("Failed to test proxy")}finally{ye(null)}},We=async t=>{const s=!t.isActive;U(r=>r.map(o=>o.id===t.id?{...o,isActive:s}:o));try{(await fetch(`/api/proxy-pools/${t.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:s})})).ok||(U(o=>o.map(a=>a.id===t.id?{...a,isActive:t.isActive}:a)),n.error("Failed to update active state"))}catch(r){console.log("Error toggling active:",r),U(o=>o.map(a=>a.id===t.id?{...a,isActive:t.isActive}:a))}},oe=c.length>0&&h.length===c.length,Be=t=>H(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t]),Le=()=>H(oe?[]:c.map(t=>t.id)),ke=()=>H([]),Ce=async t=>{const s=h.length>0?h:c.map(r=>r.id);if(s.length!==0){D(!0);try{let r=0,o=0;for(const a of s)try{(await fetch(`/api/proxy-pools/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:t})})).ok?r+=1:o+=1}catch{o+=1}await f(),n.success(`${t?"Activated":"Deactivated"} ${r}${o?`, failed ${o}`:""}`)}finally{D(!1)}}},Ve=async()=>{h.length!==0&&w({title:"Delete Proxy Pools",message:`Delete ${h.length} proxy pool(s)?`,onConfirm:async()=>{w(null),D(!0);try{let t=0,s=0,r=0;for(const o of h)try{const a=await fetch(`/api/proxy-pools/${o}`,{method:"DELETE"});a.ok?t+=1:a.status===409?s+=1:r+=1}catch{r+=1}await f(),ke(),n.success(`Deleted ${t}${s?`, ${s} bound`:""}${r?`, ${r} failed`:""}`)}finally{D(!1)}}})},_e=async()=>{const t=h.length>0?c.filter(d=>h.includes(d.id)):c;if(t.length===0)return;ge(!0),te({current:0,total:t.length});let s=0;const r=[];let o=0;const a=10,m=[...t],P=async()=>{for(;m.length>0;){const d=m.shift();if(!d)break;try{const T=await fetch(`/api/proxy-pools/${d.id}/test`,{method:"POST"}),we=await T.json();T.ok&&we.ok?s+=1:r.push(d.id)}catch{r.push(d.id)}finally{o+=1,te({current:o,total:t.length})}}};await Promise.all(Array.from({length:Math.min(a,t.length)},P)),await f(),ge(!1),te({current:0,total:0}),r.length>0?w({title:"Disable Dead Proxies",message:`Alive: ${s}, Dead: ${r.length}.
|
|
2
|
+
|
|
3
|
+
Disable ${r.length} dead proxies?`,onConfirm:async()=>{w(null),D(!0);try{for(const d of r)try{await fetch(`/api/proxy-pools/${d}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isActive:!1})})}catch{}await f(),n.success(`Disabled ${r.length} dead proxies`)}finally{D(!1)}}}):n.success(`Health check done. Alive: ${s}, Dead: ${r.length}`)};l.useEffect(()=>{H(t=>t.filter(s=>c.some(r=>r.id===s)))},[c]);const qe=()=>{ue(""),Q(!0)},Ne=()=>{J||Q(!1)},Je=()=>{Z({vercelToken:"",projectName:"vercel-relay"}),de(!0)},le=()=>{p||de(!1)},He=()=>{_({accountId:"",apiToken:"",projectName:"cloudflare-relay"}),xe(!0)},ae=()=>{p||xe(!1)},Ge=()=>{q({denoToken:"",orgDomain:"",projectName:""}),me(!0)},ne=()=>{p||me(!1)},Ye=async()=>{if(F.vercelToken.trim()){S(!0);try{const t=await fetch("/api/proxy-pools/vercel-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),s=await t.json();t.ok?(await f(),le(),n.success(`Deployed: ${s.deployUrl}`)):n.error(s.error||"Deploy failed")}catch(t){console.log("Error deploying Vercel relay:",t),n.error("Deploy failed")}finally{S(!1)}}},Ke=async()=>{if(!(!j.accountId.trim()||!j.apiToken.trim())){S(!0);try{const t=await fetch("/api/proxy-pools/cloudflare-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j)}),s=await t.json();t.ok?(await f(),ae(),n.success(`Deployed: ${s.deployUrl}`)):n.error(s.error||"Deploy failed")}catch(t){console.log("Error deploying Cloudflare relay:",t),n.error("Deploy failed")}finally{S(!1)}}},Qe=async()=>{if(N.denoToken.trim()){S(!0);try{const t=await fetch("/api/proxy-pools/deno-deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),s=await t.json();t.ok?(await f(),ne(),n.success(`Deployed: ${s.deployUrl}`)):n.error(s.error||"Deploy failed")}catch(t){console.log("Error deploying Deno relay:",t),n.error("Deploy failed")}finally{S(!1)}}},Xe=t=>{const s=t.trim();if(!s)return null;if(s.includes("://")){const o=new URL(s),a=o.port?`${o.hostname}:${o.port}`:o.hostname;return{proxyUrl:o.toString(),name:`Imported ${a}`}}const r=s.split(":");if(r.length===4){const[o,a,m,P]=r;if(!o||!a||!m||!P)throw new Error("Invalid host:port:user:pass format");const d=`http://${encodeURIComponent(m)}:${encodeURIComponent(P)}@${o}:${a}`;return{proxyUrl:new URL(d).toString(),name:`Imported ${o}:${a}`}}throw new Error("Unsupported format")},Ze=async()=>{const t=X.split(/\r?\n/).map(o=>o.trim()).filter(Boolean);if(t.length===0){n.warning("Please paste at least one proxy line.");return}const s=[],r=[];if(t.forEach((o,a)=>{try{const m=Xe(o);m&&s.push({...m,lineNumber:a+1})}catch(m){r.push(`Line ${a+1}: ${m.message}`)}}),r.length>0){n.error(`Invalid proxy format:
|
|
4
|
+
${r.join(`
|
|
5
|
+
`)}`);return}fe(!0);try{const o=new Set(c.map(d=>`${(d.proxyUrl||"").trim()}|||${(d.noProxy||"").trim()}`));let a=0,m=0,P=0;for(const d of s){const T=`${d.proxyUrl}|||`;if(o.has(T)){m+=1;continue}(await fetch("/api/proxy-pools",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d.name,proxyUrl:d.proxyUrl,noProxy:"",isActive:!0})})).ok?(a+=1,o.add(T)):P+=1}await f(),Q(!1),n.success(`Batch import completed: Created ${a}, Skipped ${m}, Failed ${P}`)}catch(o){console.log("Error batch importing proxies:",o),n.error("Batch import failed")}finally{fe(!1)}},et=l.useMemo(()=>c.filter(t=>t.isActive===!0).length,[c]);if(Te)return e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[e.jsx(Se,{}),e.jsx(Se,{})]});const tt=async()=>{if(!$.trim()||b.length===0)return;const t=E?"PUT":"POST",s=E?{id:E.id,name:$,poolIds:b}:{name:$,poolIds:b};await fetch("/api/proxy-combos",{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),A(!1),B(""),L([]),Y(null),G()},st=async t=>{await fetch("/api/proxy-combos",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})}),G()},rt=t=>{var s;return((s=c.find(r=>r.id===t))==null?void 0:s.name)||t.slice(0,8)};return e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-col gap-4 px-1 sm:gap-6 sm:px-0",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("h1",{className:"text-xl font-semibold sm:text-2xl",children:"Proxy Pools"})}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:flex sm:items-center",children:[e.jsxs("div",{className:"relative",ref:se,children:[e.jsxs(i,{size:"sm",variant:"secondary",icon:"rocket_launch",onClick:()=>M(!O),children:["Deploy Relay",e.jsx("span",{className:"material-symbols-outlined ml-1 text-[18px]",children:O?"expand_less":"expand_more"})]}),O&&e.jsxs("div",{className:"absolute left-0 top-full z-50 mt-1 w-48 rounded-xl border border-black/10 bg-white p-1 shadow-xl dark:border-white/10 dark:bg-zinc-900 sm:left-auto sm:right-0",children:[e.jsxs("button",{onClick:()=>{He(),M(!1)},className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-main transition-colors hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-orange-500",children:"cloud"}),"Cloudflare Relay"]}),e.jsxs("button",{onClick:()=>{Je(),M(!1)},className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-main transition-colors hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-blue-500",children:"cloud_upload"}),"Vercel Relay"]}),e.jsxs("button",{onClick:()=>{Ge(),M(!1)},className:"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-text-main transition-colors hover:bg-black/5 dark:hover:bg-white/5",children:[e.jsx("span",{className:"material-symbols-outlined text-[20px] text-green-500",children:"terminal"}),"Deno Relay"]})]})]}),e.jsx(i,{size:"sm",variant:"secondary",icon:"upload",onClick:qe,children:"Batch Import"}),e.jsx(i,{size:"sm",icon:"add",onClick:ve,children:"Add Proxy Pool"})]})]}),e.jsxs(Pe,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:[c.length>0&&e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-muted cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:oe,onChange:Le,className:"size-4 rounded border-black/20 dark:border-white/20"}),oe?"Unselect all":"Select all"]}),e.jsxs(k,{variant:"default",children:["Total: ",c.length]}),e.jsxs(k,{variant:"success",children:["Active: ",et]})]}),(h.length>0||v)&&e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"checklist"}),e.jsx("span",{className:"text-xs font-medium text-primary",children:h.length>0?`${h.length} selected`:"All pools"}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e.jsx(i,{size:"sm",icon:v?"progress_activity":"health_and_safety",onClick:_e,disabled:v||z||c.length===0,children:v?`Checking ${be.current}/${be.total}`:"Health Check"}),h.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(i,{size:"sm",variant:"secondary",icon:"toggle_on",onClick:()=>Ce(!0),disabled:z||v,children:"Activate"}),e.jsx(i,{size:"sm",variant:"secondary",icon:"toggle_off",onClick:()=>Ce(!1),disabled:z||v,children:"Deactivate"}),e.jsx(i,{size:"sm",variant:"secondary",icon:"delete",onClick:Ve,disabled:z||v,children:"Delete"}),e.jsx(i,{size:"sm",variant:"ghost",onClick:ke,disabled:z||v,children:"Clear"})]})]})]}),c.length===0?e.jsxs("div",{className:"text-center py-10",children:[e.jsx("p",{className:"text-text-main font-medium mb-1",children:"No proxy pool entries yet"}),e.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Create a proxy pool entry, then assign it to connections."}),e.jsx(i,{icon:"add",onClick:ve,children:"Add Proxy Pool"})]}):e.jsx("div",{className:"flex flex-col divide-y divide-black/[0.04] dark:divide-white/[0.05]",children:c.map(t=>e.jsxs("div",{className:"flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0 flex-1",children:[e.jsx("input",{type:"checkbox",checked:h.includes(t.id),onChange:()=>Be(t.id),className:"mt-1 size-4 shrink-0 rounded border-black/20 dark:border-white/20"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"min-w-0 max-w-full truncate text-sm font-medium sm:max-w-[18rem]",children:t.name}),e.jsx(k,{variant:at(t.testStatus),size:"sm",dot:!0,children:t.testStatus||"unknown"}),e.jsx(k,{variant:t.isActive?"success":"default",size:"sm",children:t.isActive?"active":"inactive"}),t.type==="vercel"&&e.jsx(k,{variant:"default",size:"sm",children:"vercel relay"}),t.type==="cloudflare"&&e.jsx(k,{variant:"default",size:"sm",children:"cloudflare relay"}),e.jsxs(k,{variant:"default",size:"sm",children:[t.boundConnectionCount||0," bound"]})]}),e.jsx("p",{className:"text-xs text-text-muted truncate mt-1",children:t.proxyUrl}),t.noProxy?e.jsxs("p",{className:"text-xs text-text-muted truncate",children:["No proxy: ",t.noProxy]}):null,e.jsxs("p",{className:"text-[11px] text-text-muted mt-1",children:["Last tested: ",nt(t.lastTestedAt),t.lastError?` · ${t.lastError}`:""]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(ie,{size:"sm",checked:t.isActive===!0,onChange:()=>We(t),title:t.isActive?"Disable":"Enable"}),e.jsx("button",{onClick:()=>ze(t.id),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Test proxy",disabled:ee===t.id,children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",style:ee===t.id?{animation:"spin 1s linear infinite"}:void 0,children:ee===t.id?"progress_activity":"science"})}),e.jsx("button",{onClick:()=>Me(t),className:"p-2 rounded hover:bg-black/5 dark:hover:bg-white/5 text-text-muted hover:text-primary",title:"Edit",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"edit"})}),e.jsx("button",{onClick:()=>Re(t),className:"p-2 rounded hover:bg-red-500/10 text-red-500",title:"Delete",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]},t.id))})]}),e.jsx(I,{isOpen:$e,title:"Batch Import Proxies",onClose:Ne,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-text-main mb-1 block",children:"Paste Proxy List (One per line)"}),e.jsx("textarea",{value:X,onChange:t=>ue(t.target.value),placeholder:`http://user:pass@127.0.0.1:7897
|
|
6
|
+
127.0.0.1:7897:user:pass`,className:"w-full min-h-[180px] py-2 px-3 text-sm text-text-main bg-white dark:bg-white/5 border border-black/10 dark:border-white/10 rounded-md focus:ring-1 focus:ring-primary/30 focus:border-primary/50 focus:outline-none transition-all"}),e.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Supported formats: protocol://user:pass@host:port, host:port:user:pass"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Ze,disabled:!X.trim()||J,children:J?"Importing...":"Import"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:Ne,disabled:J,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Ee,title:"Deploy Vercel Relay",onClose:le,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg bg-blue-500/5 border border-blue-500/10 p-3 flex flex-col gap-1.5",children:[e.jsx("p",{className:"text-sm text-text-main font-medium",children:"What is Vercel Relay?"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Deploys an edge relay function to Vercel. All AI provider requests will be forwarded through Vercel's edge network, masking your real IP from providers."}),e.jsxs("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[e.jsx("li",{children:"Your IP is replaced by Vercel's dynamic edge IPs (hundreds of IPs across 20+ global regions)"}),e.jsx("li",{children:"Vercel serves millions of apps — providers can't block Vercel IPs without affecting legitimate traffic"}),e.jsx("li",{children:"Free tier: 100GB bandwidth/month, 500K edge invocations"}),e.jsx("li",{children:"Deploy multiple relays on different accounts for more IP diversity"})]})]}),e.jsx(y,{label:"Vercel API Token",value:F.vercelToken,onChange:t=>Z(s=>({...s,vercelToken:t.target.value})),placeholder:"your-vercel-api-token",hint:e.jsxs(e.Fragment,{children:["Token is used once for deployment and not stored. ",e.jsx("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Get token →"})]}),type:"password"}),e.jsx(y,{label:"Project Name",value:F.projectName,onChange:t=>Z(s=>({...s,projectName:t.target.value})),placeholder:"my-relay",hint:"Unique name for your Vercel project. Leave empty for auto-generated name."}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Ye,disabled:!F.vercelToken.trim()||p,children:p?"Deploying... (may take ~1 min)":"Deploy"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:le,disabled:p,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Ue,title:"Deploy Cloudflare Relay",onClose:ae,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg bg-orange-500/5 border border-orange-500/10 p-3 flex flex-col gap-1.5",children:[e.jsx("p",{className:"text-sm text-text-main font-medium",children:"What is Cloudflare Relay?"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Deploys a Cloudflare Worker as a proxy relay. All AI provider requests will be forwarded through Cloudflare's global edge network."}),e.jsxs("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[e.jsx("li",{children:"High performance global routing and IP masking via Cloudflare Workers"}),e.jsx("li",{children:"Free tier: 100,000 requests per day"}),e.jsx("li",{children:"Requires Cloudflare Account ID and a Workers API Token (Edit Workers permission)"})]}),e.jsxs("div",{className:"mt-2 pt-2 border-t border-orange-500/10 text-xs text-text-muted",children:[e.jsx("p",{className:"font-medium text-text-main mb-1",children:"How to generate your API Token:"}),e.jsxs("ol",{className:"list-decimal pl-4 space-y-0.5",children:[e.jsxs("li",{children:["Go to ",e.jsx("b",{children:"My Profile"})," → ",e.jsx("b",{children:"API Tokens"})," → ",e.jsx("b",{children:"Create Token"})]}),e.jsxs("li",{children:["Scroll down to ",e.jsx("b",{children:"Custom Token"})," and click ",e.jsx("b",{children:"Get started"})]}),e.jsxs("li",{children:["Under ",e.jsx("b",{children:"Permissions"}),": Account | Workers Scripts | Edit"]}),e.jsxs("li",{children:["Under ",e.jsx("b",{children:"Account Resources"}),": Include | Account | ",e.jsx("i",{children:"Your Account Name"})]}),e.jsxs("li",{children:["Click ",e.jsx("b",{children:"Continue to summary"})," → ",e.jsx("b",{children:"Create Token"})]})]})]})]}),e.jsx(y,{label:"Account ID",value:j.accountId,onChange:t=>_(s=>({...s,accountId:t.target.value})),placeholder:"your-cloudflare-account-id",hint:e.jsx(e.Fragment,{children:"Found on the right side of the Cloudflare dashboard overview page."})}),e.jsx(y,{label:"API Token",value:j.apiToken,onChange:t=>_(s=>({...s,apiToken:t.target.value})),placeholder:"your-cloudflare-api-token",hint:e.jsxs(e.Fragment,{children:['Requires "Workers Scripts: Edit" permission. ',e.jsx("a",{href:"https://dash.cloudflare.com/profile/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Get token →"})]}),type:"password"}),e.jsx(y,{label:"Worker Name",value:j.projectName,onChange:t=>_(s=>({...s,projectName:t.target.value})),placeholder:"my-relay",hint:"Unique name for your Cloudflare Worker. Leave empty for auto-generated name."}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Ke,disabled:!j.accountId.trim()||!j.apiToken.trim()||p,children:p?"Deploying...":"Deploy Worker"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:ae,disabled:p,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Oe,title:"Deploy Deno Relay",onClose:ne,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg bg-black/5 dark:bg-white/5 border border-black/10 dark:border-white/10 p-3 flex flex-col gap-1.5",children:[e.jsx("p",{className:"text-sm text-text-main font-medium",children:"What is Deno Relay?"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Deploys a relay worker to Deno Deploy's global edge network. All AI provider requests are forwarded through Deno's edge, masking your real IP."}),e.jsxs("ul",{className:"text-xs text-text-muted list-disc pl-4 space-y-0.5",children:[e.jsx("li",{children:"Deno Deploy v2 runs on a high-performance global edge network"}),e.jsx("li",{children:"Free tier: 1M requests & 100GiB outbound traffic per month"}),e.jsx("li",{children:"No per-request CPU time limits (unlike Vercel/Cloudflare)"}),e.jsx("li",{children:"Support up to 20 active apps & 50 custom domains"}),e.jsx("li",{children:"Deploy multiple relays for maximum IP diversity"})]}),e.jsxs("div",{className:"mt-2 pt-2 border-t border-black/10 dark:border-white/10 text-xs text-text-muted",children:[e.jsx("p",{className:"font-medium text-text-main mb-1",children:"How to generate API token:"}),e.jsxs("ol",{className:"list-decimal pl-4 space-y-0.5",children:[e.jsxs("li",{children:["Go to ",e.jsx("b",{children:"console.deno.com"})]}),e.jsxs("li",{children:["Select your ",e.jsx("b",{children:"Organization"})," → ",e.jsx("b",{children:"Settings"})," → ",e.jsx("b",{children:"Organization Tokens"})]}),e.jsxs("li",{children:["Create a ",e.jsx("b",{children:"Organization Token"})," (prefix ",e.jsx("b",{children:"ddo_"}),")"]})]})]})]}),e.jsx(y,{label:"Deno Deploy API Token",value:N.denoToken,onChange:t=>q(s=>({...s,denoToken:t.target.value})),placeholder:"ddo_xxxxxxxxxxxxxxxx",hint:e.jsx(e.Fragment,{children:"Token is used once for deployment, not stored. Found in Organization Settings."}),type:"password"}),e.jsx(y,{label:"Organization Domain",value:N.orgDomain,onChange:t=>q(s=>({...s,orgDomain:t.target.value})),placeholder:"your-org.deno.net",hint:"Organization's default domain. Your relay URL will be in the format: https://my-relay.your-org.deno.net"}),e.jsx(y,{label:"App Name",value:N.projectName,onChange:t=>q(s=>({...s,projectName:t.target.value})),placeholder:"deno-relay",hint:"Unique app name. Leave empty for auto-generated name."}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Qe,disabled:!N.denoToken.trim()||!N.orgDomain.trim()||p,children:p?"Deploying...":"Deploy Relay"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:ne,disabled:p,children:"Cancel"})]})]})}),e.jsx(I,{isOpen:Ae,title:V?"Edit Proxy Pool":"Add Proxy Pool",onClose:re,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(y,{label:"Name",value:u.name,onChange:t=>C(s=>({...s,name:t.target.value})),placeholder:"Office Proxy"}),e.jsx(y,{label:"Proxy URL",value:u.proxyUrl,onChange:t=>C(s=>({...s,proxyUrl:t.target.value})),placeholder:"http://127.0.0.1:7897"}),e.jsx(y,{label:"No Proxy",value:u.noProxy,onChange:t=>C(s=>({...s,noProxy:t.target.value})),placeholder:"localhost,127.0.0.1,.internal",hint:"Comma-separated hosts/domains to bypass proxy"}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Active"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Inactive pools are ignored by runtime resolution."})]}),e.jsx(ie,{checked:u.isActive===!0,onChange:()=>C(t=>({...t,isActive:!t.isActive})),disabled:R})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border border-border/50 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:"Strict Proxy"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Fail request if proxy is unreachable instead of falling back to direct."})]}),e.jsx(ie,{checked:u.strictProxy===!0,onChange:()=>C(t=>({...t,strictProxy:!t.strictProxy})),disabled:R})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(i,{fullWidth:!0,onClick:Fe,disabled:!u.name.trim()||!u.proxyUrl.trim()||R,children:R?"Saving...":"Save"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:re,disabled:R,children:"Cancel"})]})]})}),e.jsxs(Pe,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Proxy Combos"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Round-robin rotation across multiple pools"})]}),e.jsx(i,{size:"sm",icon:"add",onClick:()=>{Y(null),B(""),L([]),A(!0)},children:"Add Combo"})]}),x.length===0?e.jsx("p",{className:"text-sm text-text-muted py-4 text-center",children:"No combos yet. Create one to rotate proxies automatically."}):e.jsx("div",{className:"space-y-2",children:x.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-border-subtle bg-surface hover:bg-surface/50",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm text-text-main",children:t.name}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:(t.poolIds||[]).map((s,r)=>e.jsxs("span",{children:[r>0?" → ":"",rt(s)]},s))})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-3",children:[e.jsxs(k,{variant:"success",size:"sm",children:[(t.poolIds||[]).length," pools"]}),e.jsx("button",{onClick:()=>{Y(t),B(t.name),L(t.poolIds||[]),A(!0)},className:"text-xs text-brand-400 hover:text-brand-300 cursor-pointer",children:"Edit"}),e.jsx("button",{onClick:()=>st(t.id),className:"text-xs text-red-400 hover:text-red-300 cursor-pointer",children:"Delete"})]})]},t.id))})]}),e.jsx(I,{isOpen:De,onClose:()=>A(!1),title:E?"Edit Combo":"Create Proxy Combo",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-text-muted block mb-1",children:"Combo Name"}),e.jsx(y,{value:$,onChange:t=>B(t.target.value),placeholder:"e.g. Free Proxy Round Robin"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-text-muted block mb-2",children:"Select Pools (click to toggle)"}),e.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1 rounded-lg border border-border-subtle p-2",children:c.map(t=>e.jsxs("label",{className:`flex items-center gap-2 p-2 rounded cursor-pointer text-sm transition-colors ${b.includes(t.id)?"bg-primary/10 text-primary":"hover:bg-surface-2 text-text-main"}`,children:[e.jsx("input",{type:"checkbox",checked:b.includes(t.id),onChange:s=>{L(s.target.checked?[...b,t.id]:b.filter(r=>r!==t.id))},className:"rounded"}),t.name]},t.id))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{fullWidth:!0,onClick:tt,disabled:!$.trim()||b.length===0,children:E?"Save Changes":"Create Combo"}),e.jsx(i,{fullWidth:!0,variant:"ghost",onClick:()=>A(!1),children:"Cancel"})]})]})}),e.jsx(lt,{isOpen:!!g,onClose:()=>w(null),onConfirm:g==null?void 0:g.onConfirm,title:(g==null?void 0:g.title)||"Confirm",message:g==null?void 0:g.message,variant:"danger"})]})}export{ht as default};
|