libre-webui 0.37.1 → 0.37.2
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/backend/dist/services/agentCliService.d.ts.map +1 -1
- package/backend/dist/services/agentCliService.js +3 -0
- package/backend/dist/services/agentCliService.js.map +1 -1
- package/backend/dist/utils/pluginDefinitionTrust.js +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/index-DWLnkKwj.js +16 -0
- package/frontend/dist/index.html +17 -17
- package/frontend/dist/js/{ArtifactContainer-B1-GVzVf.js → ArtifactContainer-D4v4l15L.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-goftRHdk.js → ArtifactDemoPage-B2uaVpsi.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-_8RA8_JV.js → ArtifactSandboxFrame-DlWJHI-r.js} +1 -1
- package/frontend/dist/js/{ArtifactSlideOutPanel-DlkOZI5N.js → ArtifactSlideOutPanel-laZ98QKB.js} +1 -1
- package/frontend/dist/js/{AutomationModal-BaaxZF1M.js → AutomationModal-CjjiEZFA.js} +1 -1
- package/frontend/dist/js/{AutomationsPage-DY2x7zVm.js → AutomationsPage-jnWmD58y.js} +1 -1
- package/frontend/dist/js/{AvatarUpload-CH_n1Ef0.js → AvatarUpload-KaBaTKoG.js} +1 -1
- package/frontend/dist/js/{CalendarPage-DLo5nm3Q.js → CalendarPage-Dc7r-86c.js} +1 -1
- package/frontend/dist/js/{ChannelsPage-DnQI7mzq.js → ChannelsPage-DHPabX1e.js} +1 -1
- package/frontend/dist/js/{ChatPage-BaDkJnEC.js → ChatPage-ZvGp-iqV.js} +1 -1
- package/frontend/dist/js/{ConnectModels-B4dGb5yc.js → ConnectModels-aUTD6s9B.js} +1 -1
- package/frontend/dist/js/{CordisPage-CPiYn2Bx.js → CordisPage-DZKcpPVj.js} +1 -1
- package/frontend/dist/js/{EvaluationsPage-DpdGpd7x.js → EvaluationsPage-BB7sPhIR.js} +1 -1
- package/frontend/dist/js/{FirstTimeSetup-By8OE1JS.js → FirstTimeSetup-elqSi9JH.js} +1 -1
- package/frontend/dist/js/{GalleryPage-ByZyIhZQ.js → GalleryPage-CrlNRnkn.js} +1 -1
- package/frontend/dist/js/{HomePage-Btc-Mvin.js → HomePage-lR9h7_a1.js} +1 -1
- package/frontend/dist/js/{LanguageSwitcher-B3CxRW6J.js → LanguageSwitcher-CWkbzpxT.js} +1 -1
- package/frontend/dist/js/{LibreClawPage-3Sonm1gu.js → LibreClawPage-P19FnNlu.js} +1 -1
- package/frontend/dist/js/{NotesPage-lFhfjMqJ.js → NotesPage-DopG0M4B.js} +1 -1
- package/frontend/dist/js/{PersonasPage-nOThOpXp.js → PersonasPage-CIJINcQK.js} +1 -1
- package/frontend/dist/js/{PluginUsagePage-BRbHeRf7.js → PluginUsagePage-Cj0mUxD8.js} +1 -1
- package/frontend/dist/js/RichMessageContent-BZndQSJU.js +1 -0
- package/frontend/dist/js/{RichMessageContent-BZ7KKJKK.js → RichMessageContent-DxCHlUlY.js} +1 -1
- package/frontend/dist/js/{SettingsModal-VpsAx2Ns.js → SettingsModal-wAuFQOE4.js} +3 -3
- package/frontend/dist/js/{ShareDialog-CnxPGPb_.js → ShareDialog-Bhpt_Y1N.js} +1 -1
- package/frontend/dist/js/{SystemPage-D2ikvhDp.js → SystemPage-BfhVXqar.js} +1 -1
- package/frontend/dist/js/{UserManagementPanel-vxpiyiTZ.js → UserManagementPanel-BU95ZPOv.js} +1 -1
- package/frontend/dist/js/{WhatsNewModal-DAAFzY0d.js → WhatsNewModal-Dl69bG2T.js} +1 -1
- package/frontend/dist/js/{WorkPage-BYpYD9mr.js → WorkPage-CSderbeT.js} +1 -1
- package/frontend/dist/js/api-CU-JXx2u.js +1 -0
- package/frontend/dist/js/{api-CVUaOaq4.js → api-DPXCtanG.js} +1 -1
- package/frontend/dist/js/{appNavigation-CqtrZ9bm.js → appNavigation-R8iKverf.js} +1 -1
- package/frontend/dist/js/{appStore-Biw63DtJ.js → appStore-BD70bvas.js} +2 -2
- package/frontend/dist/js/appVersion-C7sxqgMd.js +1 -0
- package/frontend/dist/js/{authStore-C5qKrmn4.js → authStore-D8fc-Hl0.js} +3 -3
- package/frontend/dist/js/authStore-FNKLFUQp.js +1 -0
- package/frontend/dist/js/{chatStore-DQhEqb9F.js → chatStore-CK5ojwft.js} +3 -3
- package/frontend/dist/js/{client-gf5bjBrn.js → client-BeJbHHWx.js} +2 -2
- package/frontend/dist/js/{config-CNvgxwAm.js → config-D6Kcp5n3.js} +1 -1
- package/frontend/dist/js/{cordisApi-BYjA4EOQ.js → cordisApi-BS8QMSV4.js} +1 -1
- package/frontend/dist/js/{evaluationsApi-Bg12ekHo.js → evaluationsApi-2YwZBPk5.js} +1 -1
- package/frontend/dist/js/{messageCodeStyles-DJZ4QMVq.js → messageCodeStyles-D4haBw80.js} +1 -1
- package/frontend/dist/js/{teamEventStream-PXiwR5Kr.js → teamEventStream-omPy51va.js} +1 -1
- package/frontend/dist/js/{ui-DDMjO5dd.js → ui-D5-4niRk.js} +2 -2
- package/frontend/dist/js/{useChat-DaIZ2Dbu.js → useChat-DnGClJeX.js} +1 -1
- package/frontend/dist/js/{useDictation-BXyX1U8r.js → useDictation-D7zVBjDJ.js} +1 -1
- package/frontend/dist/js/{workApi-C3Td_lFD.js → workApi-C5InfT8x.js} +1 -1
- package/frontend/dist/js/workApi-FV75LKJn.js +1 -0
- package/package.json +1 -1
- package/plugins/codex-oauth.json +2 -0
- package/frontend/dist/assets/index-BrDSO609.js +0 -20
- package/frontend/dist/js/RichMessageContent-oyydJjgc.js +0 -1
- package/frontend/dist/js/api-C0ligMmL.js +0 -1
- package/frontend/dist/js/appVersion-D78eXAb-.js +0 -1
- package/frontend/dist/js/authStore-2DsDTcIu.js +0 -1
- package/frontend/dist/js/workApi-BIS9RxRi.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/authStore-
|
|
2
|
-
import{a as e,o as t,t as n}from"./logger-BR4forr_.js";import{n as r,t as i}from"./config-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/authStore-FNKLFUQp.js","js/authStore-D8fc-Hl0.js","js/logger-BR4forr_.js","js/chatStore-CK5ojwft.js","js/i18next-DOICz7ZY.js","js/utils-p8Gt72YP.js","js/utils-vendor-DISWt2y9.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-wiHys0m2.js","js/ui-vendor-BhHHyHk3.js","js/goober.modern-BaHbaW3_.js","js/api-DPXCtanG.js","js/config-D6Kcp5n3.js","js/workApi-C5InfT8x.js","js/appStore-BD70bvas.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,o as t,t as n}from"./logger-BR4forr_.js";import{n as r,t as i}from"./config-D6Kcp5n3.js";var a=class extends Error{name=`HttpError`;code;config;response;constructor(e,t,n,r){super(e),this.code=t,this.config=n,this.response=r}},o=e=>e instanceof a,s=/^[a-z][a-z0-9+.-]*:\/\//i,c=(e,t,n)=>{if(n!=null){if(Array.isArray(n)){for(let r of n)c(e,`${t}[]`,r);return}if(n instanceof Date){e.append(t,n.toISOString());return}if(typeof n==`object`){e.append(t,JSON.stringify(n));return}e.append(t,String(n))}},l=(e,t,n)=>{let r=e;if(t&&!s.test(e)){let n=t.replace(/\/+$/,``);r=e?`${n}/${e.replace(/^\/+/,``)}`:n}if(!n)return r;let i=new URLSearchParams;for(let[e,t]of Object.entries(n))c(i,e,t);let a=i.toString();if(!a)return r;let[o,l]=r.split(`#`,2);return`${o}${o.includes(`?`)?`&`:`?`}${a}${l?`#${l}`:``}`},u=e=>typeof e==`string`||typeof FormData<`u`&&e instanceof FormData||typeof Blob<`u`&&e instanceof Blob||typeof URLSearchParams<`u`&&e instanceof URLSearchParams||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof ReadableStream<`u`&&e instanceof ReadableStream,d=(e,t)=>{let n=t.toLowerCase();for(let t of Object.keys(e))if(t.toLowerCase()===n)return t},f=(e,t)=>{if(e==null)return;let n=d(t,`content-type`);return typeof FormData<`u`&&e instanceof FormData?(n&&t[n].toLowerCase().startsWith(`multipart/form-data`)&&delete t[n],e):u(e)?e:(n||(t[`Content-Type`]=`application/json`),JSON.stringify(e))},p=async(e,t)=>{if(e.status===204||e.status===205)return null;switch(t){case`blob`:return e.blob();case`arraybuffer`:return e.arrayBuffer();case`text`:return e.text();default:{let t=await e.text();if(!t)return null;if(!((e.headers.get(`content-type`)||``).includes(`json`)||/^\s*[[{]/.test(t.slice(0,64))))return t;try{return JSON.parse(t)}catch{return t}}}},m=e=>e instanceof Error&&(e.name===`AbortError`||e.name===`TimeoutError`),h=e=>{if(e.length===0)return{signal:void 0,cleanup:()=>{}};if(e.length===1)return{signal:e[0],cleanup:()=>{}};let t=new AbortController,n=[];for(let r of e){if(r.aborted){t.abort(r.reason);break}let e=()=>t.abort(r.reason);r.addEventListener(`abort`,e,{once:!0}),n.push(()=>r.removeEventListener(`abort`,e))}return{signal:t.signal,cleanup:()=>n.forEach(e=>e())}},g=(e={})=>{let t=e.fetch,n=async n=>{let r=e.onRequest?e.onRequest({...n}):{...n},i={...r,baseURL:r.baseURL??e.baseURL,timeout:r.timeout??e.timeout??0,method:(r.method||`GET`).toUpperCase()},o={...i.headers||{}},s=f(i.data,o),c=l(i.url||``,i.baseURL,i.params),u=[];i.signal&&u.push(i.signal);let d,g=!1;if(i.timeout&&i.timeout>0){let e=new AbortController;d=setTimeout(()=>{g=!0,e.abort()},i.timeout),u.push(e.signal)}let _=h(u),v=t=>e.onError?e.onError(t):Promise.reject(t);try{let e;try{e=await(t||fetch)(c,{method:i.method,headers:o,body:s,signal:_.signal})}catch(e){return g?v(new a(`timeout of ${i.timeout}ms exceeded`,`ECONNABORTED`,i)):m(e)?v(new a(`canceled`,`ERR_CANCELED`,i)):v(new a(`Network Error`,`ERR_NETWORK`,i))}let n={data:await p(e,i.responseType||`json`),status:e.status,statusText:e.statusText,headers:e.headers,config:i};return e.status>=200&&e.status<300?n:v(new a(`Request failed with status code ${e.status}`,e.status>=500?`ERR_BAD_RESPONSE`:`ERR_BAD_REQUEST`,i,n))}finally{d&&clearTimeout(d),_.cleanup()}},r=e=>(t,r,i={})=>n({...i,url:t,method:e,data:r}),i=e=>(t,r={})=>n({...r,url:t,method:e});return{request:n,get:i(`GET`),delete:i(`DELETE`),head:i(`HEAD`),post:r(`POST`),put:r(`PUT`),patch:r(`PATCH`)}},_=n(`api`);r(),_.debug(`User agent:`,navigator.userAgent),_.debug(`Demo mode detected:`,e());var v=(e,t=!0)=>new Promise(n=>{setTimeout(()=>{n({success:t,data:e,error:t?void 0:`Demo mode: Backend not available`})},500)}),y=g({baseURL:i,timeout:3e5,onRequest:e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers={...e.headers||{},Authorization:`Bearer ${t}`}),e},onError:e=>{if(e.response?.status===401){_.warn(`Session expired or unauthorized, logging out...`),localStorage.removeItem(`auth-token`),t(async()=>{let{useAuthStore:e}=await import(`./authStore-FNKLFUQp.js`);return{useAuthStore:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(({useAuthStore:e})=>{e.getState().logout()});let e=window.location.protocol===`file:`;throw(e?window.location.hash:window.location.pathname).includes(`/login`)||(window.location.href=e?`#/login`:`/login`),Error(`Session expired`)}throw e.response?.status===403&&(e.config?.url??``).startsWith(`/work`)&&e.config?.url!==`/work/access`&&t(async()=>{let{useAuthStore:e}=await import(`./authStore-FNKLFUQp.js`);return{useAuthStore:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(({useAuthStore:e})=>{e.getState().refreshWorkAccess()}),_.error(`API Error:`,e),e}});export{o as a,g as i,v as n,_ as r,y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./logger-BR4forr_.js";var n=t(`config`);function r(e){return e.apiBaseUrl?.trim()?e.apiBaseUrl.trim():e.protocol===`file:`?`http://localhost:3001/api`:`${e.origin}/api`}var i=r({protocol:window.location.protocol,origin:window.location.origin,apiBaseUrl:void 0}),a=e(),o=()=>{a&&(n.debug(`API_BASE_URL configured as:`,i),n.debug(`Window location:`,window.location),n.debug(`Environment variables:`,{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.37.
|
|
1
|
+
import{n as e,t}from"./logger-BR4forr_.js";var n=t(`config`);function r(e){return e.apiBaseUrl?.trim()?e.apiBaseUrl.trim():e.protocol===`file:`?`http://localhost:3001/api`:`${e.origin}/api`}var i=r({protocol:window.location.protocol,origin:window.location.origin,apiBaseUrl:void 0}),a=e(),o=()=>{a&&(n.debug(`API_BASE_URL configured as:`,i),n.debug(`Window location:`,window.location),n.debug(`Environment variables:`,{BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_APP_VERSION:`0.37.2`}))};export{o as n,i as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./logger-BR4forr_.js";import{t}from"./config-
|
|
1
|
+
import{a as e}from"./logger-BR4forr_.js";import{t}from"./config-D6Kcp5n3.js";import{a as n,t as r}from"./client-BeJbHHWx.js";var i=()=>{let e=localStorage.getItem(`auth-token`);return e?{Authorization:`Bearer ${e}`}:{}},a=e=>{let t=JSON.parse(e);if(t&&typeof t==`object`&&`type`in t){let e=t;switch(e.type){case`text`:case`reasoning`:if(typeof e.text==`string`)return e;break;case`error`:if(typeof e.message==`string`)return e;break;case`tool-call`:case`tool-result`:if(typeof e.callId==`string`&&typeof e.name==`string`&&(e.type===`tool-call`||typeof e.isError==`boolean`))return e;break;case`done`:if(typeof e.reason==`string`)return e;break;case`approval-request`:{let t=e.approval;if(t&&typeof t.id==`string`&&typeof t.sessionId==`string`&&typeof t.toolName==`string`)return e;break}case`approval-decision`:if(typeof e.approvalId==`string`&&[`allowed-once`,`rejected`,`cancelled`,`unavailable`].includes(String(e.outcome)))return e}}throw Error(`Invalid engine stream chunk`)},o={getModels:async()=>(await r.get(`/cordis/models`)).data,updateSettings:async(e,t)=>(await r.patch(`/cordis/sessions/${encodeURIComponent(e)}/settings`,t)).data.session,decideApproval:async(e,t,n)=>{await r.post(`/cordis/sessions/${encodeURIComponent(e)}/approvals/${encodeURIComponent(t)}`,{decision:n})},getHealth:async()=>{try{return(await r.get(`/cordis/health`)).data}catch(e){if(n(e)&&e.response?.data){let t=e.response.data;if(typeof t.ready==`boolean`)return t}throw e}},getAccess:async()=>(await r.get(`/cordis/access`)).data,setAccess:async e=>(await r.put(`/cordis/access`,{enabled:e})).data,listSessions:async()=>e()?[]:(await r.get(`/cordis/sessions`)).data.sessions??[],getSession:async e=>(await r.get(`/cordis/sessions/${encodeURIComponent(e)}`)).data.session,createSession:async(e={})=>(await r.post(`/cordis/sessions`,e)).data.session,deleteSession:async e=>(await r.delete(`/cordis/sessions/${encodeURIComponent(e)}`)).data.success,listAgents:async()=>e()?[]:(await r.get(`/cordis/agents`)).data.agents??[],listTools:async()=>e()?[]:(await r.get(`/cordis/tools`)).data.tools??[],cancel:async e=>(await r.post(`/cordis/sessions/${encodeURIComponent(e)}/cancel`)).data.success,sendMessage:async(n,r,o={})=>{if(e()){let e=[{type:`text`,text:`Demo mode has no engine attached.`},{type:`done`,reason:`demo`}];return e.forEach(e=>o.onChunk?.(e)),e}let s=await fetch(`${t}/cordis/sessions/${encodeURIComponent(n)}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`,...i()},body:JSON.stringify({text:r}),signal:o.signal});if(!s.ok){let e=await s.json().then(e=>e.error).catch(()=>void 0);throw Error(e??`HTTP error! status: ${s.status}`)}if(!s.body)throw Error(`No response body reader available`);let c=s.body.getReader(),l=new TextDecoder,u=[],d=``;try{for(;;){o.signal?.throwIfAborted();let{done:e,value:t}=await c.read();o.signal?.throwIfAborted(),d+=l.decode(t,{stream:!e});let n=d.split(`
|
|
2
2
|
`);d=n.pop()??``,e&&d.trim()!==``&&n.push(d);for(let e of n){if(e.trim()===``)continue;let t=a(e);if(u.push(t),o.onChunk?.(t),t.type===`done`)return u}if(e)throw Error(`Engine stream ended before completing the turn`)}}finally{await c.cancel().catch(()=>void 0),c.releaseLock()}}};export{o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./logger-BR4forr_.js";import{n as t,t as n}from"./client-
|
|
1
|
+
import{a as e}from"./logger-BR4forr_.js";import{n as t,t as n}from"./client-BeJbHHWx.js";var r={upsertFeedback:r=>e()?Promise.resolve(t(void 0)):n.post(`/evaluations/feedback`,r).then(e=>e.data),deleteFeedback:e=>n.delete(`/evaluations/feedback/${encodeURIComponent(e)}`).then(()=>void 0),listFeedback:(e=!1)=>n.get(e?`/evaluations/feedback/all`:`/evaluations/feedback`).then(e=>e.data),runArenaMatch:e=>n.post(`/evaluations/arena/matches`,e).then(e=>e.data),voteArena:e=>n.post(`/evaluations/arena/votes`,e).then(e=>e.data),leaderboard:()=>n.get(`/evaluations/arena/leaderboard`).then(e=>e.data),listSets:()=>n.get(`/evaluations/sets`).then(e=>e.data),saveSet:e=>(e.id?n.put(`/evaluations/sets/${encodeURIComponent(e.id)}`,e):n.post(`/evaluations/sets`,e)).then(e=>e.data),deleteSet:e=>n.delete(`/evaluations/sets/${encodeURIComponent(e)}`).then(()=>void 0),listRuns:e=>n.get(`/evaluations/runs`,{params:e?{setId:e}:{}}).then(e=>e.data),startRun:e=>n.post(`/evaluations/runs`,e).then(e=>e.data),getRun:e=>n.get(`/evaluations/runs/${encodeURIComponent(e)}`).then(e=>e.data),cancelRun:e=>n.post(`/evaluations/runs/${encodeURIComponent(e)}/cancel`).then(()=>void 0),exportRun:e=>n.get(`/evaluations/runs/${encodeURIComponent(e)}/export`,{responseType:`blob`}).then(e=>e.data)};export{r as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-wiHys0m2.js";import{t as r}from"./logger-BR4forr_.js";import{t as i}from"./useTranslation-B9kflK9S.js";import{a}from"./utils-p8Gt72YP.js";import{Cn as o,In as s,Kn as c,On as l,Qn as u,jn as d,qn as f}from"./ui-vendor-BhHHyHk3.js";import{t as p}from"./appStore-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-vendor-wiHys0m2.js";import{t as r}from"./logger-BR4forr_.js";import{t as i}from"./useTranslation-B9kflK9S.js";import{a}from"./utils-p8Gt72YP.js";import{Cn as o,In as s,Kn as c,On as l,Qn as u,jn as d,qn as f}from"./ui-vendor-BhHHyHk3.js";import{t as p}from"./appStore-BD70bvas.js";var m=e(t(),1),h={selection:8,impact:14,success:[10,28,12],warning:[18,42,18]},g=()=>typeof window>`u`||typeof navigator>`u`?!1:navigator.maxTouchPoints>0||window.matchMedia?.(`(pointer: coarse)`).matches===!0,_=()=>typeof navigator<`u`&&typeof navigator.vibrate==`function`&&g(),v=(e=`selection`)=>p.getState().preferences.hapticFeedbackEnabled!==!0||!_()?!1:navigator.vibrate(h[e]),y=[/^ {0,3}(?:`{3,}|~{3,})/m,/`[^`\n]+`/,/^\s{0,3}#{1,6}\s/m,/^\s{0,3}[-*+]\s/m,/^\s{0,3}\d+\.\s/m,/^\s{0,3}>\s/m,/\[[^\]]+\]\([^)]+\)/,/!\[[^\]]*]\([^)]+\)/,/\|.*\|/,/\*\*[^*]+\*\*/,/__[^_]+__/,/~~[^~]+~~/,/\\\[[\s\S]*?\\\]/,/\\\([\s\S]*?\\\)/,/\$\$[\s\S]*?\$\$/,/(^|[^$])\$[^$\n]+\$/],b=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function x(e){let t=[],n=/^( {0,3})(`{3,}|~{3,})([^\n\r]*)(?:\r?\n|$)/gm,r;for(;r=n.exec(e);){let i=r[1].length,a=r[2],o=a[0],s=r[3].trim();if(o==="`"&&s.includes("`"))continue;let c=n.lastIndex,l=RegExp(`^ {0,3}${b(o)}{${a.length},}[ \\t]*(?:\\r?\\n|$)`,`gm`);l.lastIndex=c;let u=l.exec(e),d=s.split(/\s+/)[0]||null;if(!u){t.push({start:r.index,end:e.length,codeStart:c,codeEnd:e.length,indent:i,language:d,complete:!1});break}t.push({start:r.index,end:l.lastIndex,codeStart:c,codeEnd:u.index,indent:i,language:d,complete:!0}),n.lastIndex=l.lastIndex}return t}function S(e){return/<(?:html|head|body)(?:\s|>)|<\/(?:head|body|html)\s*>/i.test(e)}function C(e,t){return e.start<t.end&&t.start<e.end}function w(e,t){let n=/^( {0,3})(<!doctype\s+html(?:\s|>|$)|<html(?:\s[^>\n\r]*)?>)/gim,r;for(;r=n.exec(e);){let n=r.index+r[1].length;if(t.some(e=>n>=e.start&&n<e.end))continue;let i=e.slice(n);if(!S(i.slice(r[2].length)))continue;let a=/<\/html\s*>/i.exec(i),o=a?n+a.index+a[0].length:e.length;return{start:r.index,end:o,codeStart:n,codeEnd:o,indent:0,language:`html`,complete:!!a}}return null}function T(e){let t=x(e),n=w(e,t);return n?[...t.filter(e=>!C(e,n)),n].sort((e,t)=>e.start-t.start):t}function E(e,t){return t===0?e:e.replace(RegExp(`^ {1,${t}}`,`gm`),``)}function D(e){return y.some(t=>t.test(e))}function O(e){let t=[],n=T(e),r=0;for(let i of n){let n=e.slice(r,i.start);n&&t.push({type:`text`,content:n}),t.push({type:`code`,language:i.language,content:E(e.slice(i.codeStart,i.codeEnd),i.indent),complete:i.complete}),r=i.end}let i=e.slice(r);return(i||t.length===0)&&t.push({type:`text`,content:i}),t}function k(e){let t=e=>e.replace(/\\\[([\s\S]*?)\\\]/g,(e,t)=>`$$${t}$$`).replace(/\\\(([\s\S]*?)\\\)/g,(e,t)=>`$${t}$`),n=e=>{let n=/`[^`\n]+`/g,r=``,i=0,a;for(;a=n.exec(e);)r+=t(e.slice(i,a.index)),r+=a[0],i=n.lastIndex;return r+t(e.slice(i))},r=x(e),i=``,a=0;for(let t of r)i+=n(e.slice(a,t.start)),i+=e.slice(t.start,t.end),a=t.end;return i+=n(e.slice(a)),i}var A=n(),j=r(`components:ui:message-code-block`),M=24,N={bash:`sh`,c:`c`,cpp:`cpp`,csharp:`cs`,css:`css`,go:`go`,html:`html`,htm:`html`,java:`java`,javascript:`js`,js:`js`,json:`json`,jsx:`jsx`,kotlin:`kt`,markdown:`md`,mermaid:`mmd`,php:`php`,python:`py`,py:`py`,ruby:`rb`,rust:`rs`,sh:`sh`,shell:`sh`,sql:`sql`,svg:`svg`,swift:`swift`,toml:`toml`,ts:`ts`,tsx:`tsx`,typescript:`ts`,xml:`xml`,yaml:`yaml`,yml:`yaml`,zsh:`sh`};function P(e,t){let n=(e||``).toLowerCase();if(n===`html`||n===`htm`)return`html`;if(n===`svg`)return`svg`;if(n===`mermaid`)return`mermaid`;let r=t.slice(0,500).toLowerCase();return(!n||n===`xml`)&&r.includes(`<svg`)?`svg`:!n&&(r.includes(`<!doctype html`)||r.includes(`<html`))?`html`:null}function F({code:e,language:t,state:n,children:r}){let{t:h}=i(),g=p(e=>e.openArtifactPanel),[_,y]=m.useState(null),[b,x]=m.useState(null),S=m.useRef(null),C=_===e,w=t||`text`,T=h(C?`artifacts.copied`:`artifacts.copy`),E=`${T}: ${w}`,D=m.useMemo(()=>e?e.split(`
|
|
2
2
|
`).length:0,[e]),O=b===null?n===`complete`&&D>M:!b,k=n===`complete`?P(t,e):null;return m.useEffect(()=>()=>{S.current!==null&&window.clearTimeout(S.current)},[]),(0,A.jsxs)(`div`,{dir:`ltr`,"data-testid":`code-block`,"data-state":n,"data-language":w,"data-collapsed":O,className:`group relative my-4 overflow-hidden rounded-xl border border-line bg-surface-subtle text-left text-ink shadow-[0_12px_32px_rgba(13,17,23,0.1)] dark:border-white/10 dark:bg-dark-50 dark:text-dark-900 dark:shadow-[0_12px_32px_rgba(13,17,23,0.16)]`,children:[(0,A.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-line bg-surface-raised/70 px-3.5 dark:border-white/10 dark:bg-white/[0.035]`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,A.jsx)(s,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle dark:text-dark-500`}),(0,A.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium lowercase tracking-[-0.01em] text-ink-muted dark:text-dark-700`,children:w})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n===`streaming`&&(0,A.jsx)(`span`,{role:`status`,"aria-label":h(`common.loading`),className:`flex h-7 w-7 items-center justify-center`,children:(0,A.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-primary-400`})}),D>M&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>x(O),className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(O?`artifacts.expand`:`artifacts.collapse`),"aria-label":h(O?`artifacts.expand`:`artifacts.collapse`),"aria-expanded":!O,children:O?(0,A.jsx)(c,{className:`h-3.5 w-3.5`}):(0,A.jsx)(f,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>{if(!e)return;let n=N[(t||``).toLowerCase()]||`txt`,r=new Blob([e],{type:`text/plain;charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`snippet.${n}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)},disabled:!e,className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 disabled:cursor-default disabled:opacity-35 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(`common.download`),"aria-label":`${h(`common.download`)}: ${w}`,children:(0,A.jsx)(l,{className:`h-3.5 w-3.5`})}),k&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>{if(!k||!e)return;let t=Date.now();g({id:a(),type:k,title:`${w} ${h(`artifacts.preview`)}`,content:e,language:w,createdAt:t,updatedAt:t})},className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:h(`artifacts.preview`),"aria-label":`${h(`artifacts.preview`)}: ${w}`,children:(0,A.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`button`,{type:`button`,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),v(`success`),y(e),S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{y(null),S.current=null},2e3)}catch(e){j.error(`Failed to copy code:`,e)}},disabled:!e,className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 disabled:cursor-default disabled:opacity-35 dark:text-dark-500 dark:hover:bg-white/[0.08] dark:hover:text-dark-900`,title:T,"aria-label":E,children:C?(0,A.jsx)(u,{className:`h-3.5 w-3.5 text-green-400`}):(0,A.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,A.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:C?E:``})]})]}),O?(0,A.jsx)(`button`,{type:`button`,onClick:()=>x(!0),className:`block w-full px-3.5 py-2.5 text-left font-mono text-[11px] italic text-ink-subtle transition-colors hover:bg-surface-raised/70 hover:text-ink dark:text-dark-500 dark:hover:bg-white/[0.035] dark:hover:text-dark-900`,children:h(`chatMessage.hiddenLines`,{count:D})}):r]})}var I=`rgb(var(--color-dark-50))`,L=`rgb(var(--color-surface-subtle))`,R=`max-h-[60vh] min-h-12 overflow-auto bg-surface-subtle p-4 text-left font-mono text-[14px] leading-6 text-ink whitespace-pre tabular-nums dark:bg-dark-50 dark:text-dark-900`,z={maxHeight:`60vh`,minHeight:`3rem`,overflow:`auto`,padding:`1rem`,fontSize:`14px`,lineHeight:`1.5rem`,fontFamily:`"JetBrains Mono", ui-monospace, SFMono-Regular, monospace`,whiteSpace:`pre`};export{F as a,D as c,z as i,v as l,L as n,O as o,R as r,k as s,I as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./config-
|
|
1
|
+
import{t as e}from"./config-D6Kcp5n3.js";var t=()=>{let e=localStorage.getItem(`auth-token`);return e?{Authorization:`Bearer ${e}`}:{}},n=8,r=2e3,i=(e,t)=>new Promise(n=>{let r=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})}),a=async a=>{let o=0,s=0;for(;!a.signal.aborted&&s<n;)try{let n=await fetch(`${e}${a.path}?after=${o}`,{headers:{Accept:`text/event-stream`,...t()},credentials:`same-origin`,signal:a.signal});if(!n.ok||!n.body){s+=1,await i(r,a.signal);continue}s=0;let c=n.body.getReader(),l=new TextDecoder,u=``;try{for(;;){let{done:e,value:t}=await c.read();u+=l.decode(t,{stream:!e}).replace(/\r\n/g,`
|
|
2
2
|
`);let n=u.indexOf(`
|
|
3
3
|
|
|
4
4
|
`);for(;n>=0;){let e=u.slice(0,n);u=u.slice(n+2),n=u.indexOf(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/OptimizedSyntaxHighlighter-ajqwyBQm.js","js/OptimizedSyntaxHighlighter-CzzV6ONG.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-wiHys0m2.js","js/syntax-highlight-DNc3FFCa.js","js/markdown-core-KjS96SYW.js","js/RichMessageContent-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-wiHys0m2.js";import{o as i}from"./logger-BR4forr_.js";import{t as a}from"./useTranslation-B9kflK9S.js";import{t as o}from"./utils-p8Gt72YP.js";import{Lt as s,n as c}from"./ui-vendor-BhHHyHk3.js";import{t as l}from"./appStore-Biw63DtJ.js";import{a as u,c as d,i as f,n as p,o as m,r as h,t as g}from"./messageCodeStyles-DJZ4QMVq.js";import"./Button-CGMYia4g.js";import{t as _}from"./useDialogFocus-BPTG_Zmy.js";var v=e(t(),1),y=r(),b=({label:e,error:t,helper:n,className:r,id:i,...a})=>{let s=(0,v.useId)(),c=i||`input-${s}`,l=`${c}-feedback`,u=[a[`aria-describedby`],(t||n)&&l].filter(Boolean).join(` `)||void 0;return(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,y.jsx)(`label`,{htmlFor:c,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,y.jsx)(`input`,{id:c,className:o(`block w-full rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`placeholder:text-ink-subtle transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,r),...a,"aria-invalid":t?!0:a[`aria-invalid`],"aria-describedby":u}),t&&(0,y.jsx)(`p`,{id:l,role:`alert`,className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,y.jsx)(`p`,{id:l,className:`text-xs leading-relaxed text-ink-muted`,children:n})]})},x=v.forwardRef(({label:e,error:t,helper:n,className:r,id:i,...a},s)=>{let c=(0,v.useId)(),l=i||`textarea-${c}`,u=`${l}-feedback`,d=[a[`aria-describedby`],(t||n)&&u].filter(Boolean).join(` `)||void 0;return(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,y.jsx)(`label`,{htmlFor:l,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,y.jsx)(`textarea`,{ref:s,id:l,className:o(`block w-full resize-none rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`placeholder:text-ink-subtle transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,r),...a,"aria-invalid":t?!0:a[`aria-invalid`],"aria-describedby":d}),t&&(0,y.jsx)(`p`,{id:u,role:`alert`,className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,y.jsx)(`p`,{id:u,className:`text-xs leading-relaxed text-ink-muted`,children:n})]})});x.displayName=`Textarea`;var S=({label:e,error:t,helper:n,options:r,className:i,id:a,...s})=>{let c=(0,v.useId)(),l=a||`select-${c}`,u=`${l}-feedback`,d=[s[`aria-describedby`],(t||n)&&u].filter(Boolean).join(` `)||void 0;return(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,y.jsx)(`label`,{htmlFor:l,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,y.jsx)(`select`,{id:l,className:o(`block w-full rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,i),...s,"aria-invalid":t?!0:s[`aria-invalid`],"aria-describedby":d,children:r.map((e,t)=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.key??`${e.value}-${t}`))}),t&&(0,y.jsx)(`p`,{id:u,role:`alert`,className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,y.jsx)(`p`,{id:u,className:`text-xs leading-relaxed text-ink-muted`,children:n})]})},C=({className:e,...t})=>(0,y.jsx)(s,{...t,"aria-hidden":`true`,className:o(`h-3.5 w-3.5 shrink-0 animate-spin text-ink-subtle motion-reduce:animate-none`,e)}),w=v.lazy(()=>i(()=>import(`./OptimizedSyntaxHighlighter-ajqwyBQm.js`),__vite__mapDeps([0,1,2,3,4,5]))),T=8e4;function E({content:e}){return e?(0,y.jsx)(`div`,{dir:`auto`,className:`whitespace-pre-wrap break-words leading-relaxed`,children:e}):null}function D({content:e,language:t,complete:n}){let r=n?e.replace(/\r?\n$/,``):e,i=l(e=>e.theme.mode!==`light`),a=v.useRef(null),o=v.useRef(!0),s=v.useDeferredValue(r),c=r.length<=T,d=v.useCallback(e=>{a.current=e,e&&o.current&&(e.scrollTop=e.scrollHeight)},[]);v.useLayoutEffect(()=>{let e=a.current;e&&o.current&&(e.scrollTop=e.scrollHeight)},[r,s]);let m=v.useCallback(()=>{let e=a.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;o.current=t<24},[]),_=v.useMemo(()=>({children:e,...t})=>(0,y.jsx)(`pre`,{...t,ref:d,onScroll:e=>{m(),t.onScroll?.(e)},children:e}),[d,m]),b=(0,y.jsx)(`pre`,{ref:d,onScroll:m,className:h,children:(0,y.jsx)(`code`,{children:r})});return(0,y.jsx)(u,{code:r,language:t,state:n?`complete`:`streaming`,children:c?(0,y.jsx)(v.Suspense,{fallback:b,children:(0,y.jsx)(w,{language:t||`text`,isDark:i,codeTheme:`night`,backgroundColor:i?g:p,borderRadius:0,customStyle:f,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,preTag:_,children:s})}):b})}var O=v.memo(({content:e,className:t,segments:n,isStreaming:r=!0})=>{let i=v.useMemo(()=>n??m(e),[e,n]),a=i[i.length-1],s=a?.type===`code`&&!a.complete;return(0,y.jsxs)(`div`,{className:o(`text-sm leading-relaxed text-ink`,t),children:[i.map((e,t)=>e.type===`code`?(0,y.jsx)(D,{...e},`${e.type}-${t}`):(0,y.jsx)(E,{content:e.content},`${e.type}-${t}`)),r&&!s&&(0,y.jsx)(C,{"data-testid":`message-streaming-cursor`,className:`ms-1 inline-block align-text-bottom`})]})});O.displayName=`StreamingMessageContent`;var k=v.lazy(()=>i(()=>import(`./RichMessageContent-oyydJjgc.js`),__vite__mapDeps([6,7,2,3,8,9,10,11,12,13,14,15,5])));function A({content:e,className:t}){return(0,y.jsx)(`div`,{dir:`auto`,className:o(`text-sm leading-relaxed text-ink whitespace-pre-wrap break-words`,t),children:e})}var j=v.memo(({content:e,className:t,isStreaming:n=!1})=>{let r=v.useMemo(()=>n?m(e):[],[e,n]),i=r.some(e=>e.type===`code`);if(n&&i)return(0,y.jsx)(O,{content:e,className:t,segments:r});let a;return a=d(e)?(0,y.jsx)(v.Suspense,{fallback:(0,y.jsx)(O,{content:e,className:t,isStreaming:!1}),children:(0,y.jsx)(k,{content:e,className:t})}):(0,y.jsx)(A,{content:e,className:t}),(0,y.jsxs)(y.Fragment,{children:[a,n&&(0,y.jsx)(`span`,{"data-testid":`message-streaming-cursor`,"aria-hidden":`true`,className:`ms-1 inline-block h-5 w-1 animate-pulse rounded-full bg-primary-500 align-text-bottom`})]})});j.displayName=`MessageContent`;var M=({children:e,htmlFor:t,className:n=``})=>(0,y.jsx)(`label`,{htmlFor:t,className:o(`text-sm font-medium tracking-[-0.005em] text-ink-muted`,n),children:e}),N=({checked:e,onChange:t,disabled:n=!1,className:r=``})=>(0,y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-disabled":n||void 0,disabled:n,onClick:()=>t(!e),className:o(`relative inline-flex h-6 w-11 flex-shrink-0 items-center justify-center rounded-full bg-transparent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas dark:focus-visible:ring-primary-400`,n?`cursor-not-allowed opacity-50`:`cursor-pointer`,r),children:(0,y.jsx)(`span`,{"aria-hidden":`true`,className:o(`relative inline-flex h-6 w-11 items-center rounded-full border shadow-inner`,`transition-[background-color,border-color] duration-150 ease-out motion-reduce:transition-none`,e?`border-primary-600/70 bg-primary-600`:`border-line-strong bg-surface-subtle`),children:(0,y.jsx)(`span`,{className:o(`inline-block h-4 w-4 rounded-full bg-white shadow-subtle ring-1 ring-black/5`,`transform transition-transform duration-150 ease-out motion-reduce:transition-none`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})}),P={narrow:`max-w-4xl`,default:`max-w-6xl`,wide:`max-w-7xl`},F=({children:e,width:t=`default`,className:n,contentClassName:r,...i})=>(0,y.jsx)(`div`,{"data-testid":`page-scroll-region`,className:o(`scroll-region h-full min-h-0 scrollbar-thin`,n),...i,children:(0,y.jsx)(`div`,{className:o(`mx-auto w-full px-4 pb-16 pt-7 sm:px-6 sm:pb-20 sm:pt-10 lg:px-8`,P[t],r),children:e})}),I=({title:e,description:t,eyebrow:n,actions:r,meta:i,className:a,...s})=>(0,y.jsxs)(`header`,{className:o(`mb-8 flex flex-col gap-6 border-b border-gray-200/70 pb-7 text-start dark:border-white/[0.08] sm:mb-10 sm:pb-9 md:flex-row md:items-end md:justify-between`,a),...s,children:[(0,y.jsxs)(`div`,{className:`min-w-0 max-w-3xl`,children:[n&&(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-medium uppercase tracking-[0.18em] text-gray-500 dark:text-dark-500 rtl:tracking-normal`,children:n}),(0,y.jsx)(`h1`,{className:`text-balance text-3xl font-normal leading-[1.02] tracking-[-0.04em] text-gray-950 dark:text-dark-950 sm:text-5xl rtl:leading-[1.15] rtl:tracking-normal`,children:e}),t&&(0,y.jsx)(`p`,{className:`mt-4 max-w-2xl text-sm leading-6 text-gray-600 dark:text-dark-600 sm:text-base sm:leading-7`,children:t}),i&&(0,y.jsx)(`div`,{className:`mt-4`,children:i})]}),r&&(0,y.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 md:justify-end`,children:r})]}),L=n(),R=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,z=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,B=({titleId:e,title:t,subtitle:n,onClose:r,children:i,footer:a,widthClassName:s=`max-w-lg`,testId:c})=>{let l=(0,v.useRef)(null);return _(l,{onClose:r}),(0,L.createPortal)((0,y.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:r,children:(0,y.jsx)(`div`,{ref:l,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-labelledby":e,"data-testid":c,className:o(`flex max-h-[90vh] w-full flex-col overflow-hidden rounded-3xl border border-black/[0.07] bg-white shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in dark:border-white/[0.08] dark:bg-dark-25`,s),onClick:e=>e.stopPropagation(),children:(0,y.jsxs)(`div`,{"data-testid":`modal-scroll-region`,className:`min-h-0 overflow-y-auto p-6 scrollbar-thin`,children:[(0,y.jsx)(V,{titleId:e,title:t,subtitle:n,onClose:r}),i&&(0,y.jsx)(`div`,{className:`space-y-4`,children:i}),a&&(0,y.jsx)(`div`,{className:`mt-5 flex justify-end gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:a})]})})}),document.body)},V=({titleId:e,title:t,subtitle:n,onClose:r})=>{let{t:i}=a();return(0,y.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`h3`,{id:e,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:t}),n&&(0,y.jsx)(`p`,{className:`mt-1 text-[12px] leading-5 text-gray-500 dark:text-dark-500`,children:n})]}),(0,y.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`common.close`),className:`shrink-0 rounded-xl p-2 transition-colors hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 dark:hover:bg-dark-200`,children:(0,y.jsx)(c,{size:20,className:`text-gray-500`})})]})},H=({icon:e,label:t,destructive:n,disabled:r,testId:i,onClick:a})=>(0,y.jsx)(`button`,{type:`button`,onClick:a,disabled:r,title:t,"aria-label":t,"data-testid":i,className:o(`rounded-lg p-1.5 text-gray-400 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,n?`hover:bg-red-500/10 hover:text-red-500`:`hover:bg-black/[0.04] hover:text-gray-700 dark:hover:bg-white/[0.06] dark:hover:text-dark-800`),children:(0,y.jsx)(e,{className:`h-3.5 w-3.5`})});export{I as a,M as c,C as d,S as f,z as i,j as l,b as m,B as n,F as o,x as p,R as r,N as s,H as t,O as u};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/OptimizedSyntaxHighlighter-ajqwyBQm.js","js/OptimizedSyntaxHighlighter-CzzV6ONG.js","js/rolldown-runtime-hePW80VL.js","js/react-vendor-wiHys0m2.js","js/syntax-highlight-DNc3FFCa.js","js/markdown-core-KjS96SYW.js","js/RichMessageContent-BZndQSJU.js","js/RichMessageContent-DxCHlUlY.js","js/logger-BR4forr_.js","js/utils-p8Gt72YP.js","js/utils-vendor-DISWt2y9.js","js/appStore-BD70bvas.js","js/messageCodeStyles-D4haBw80.js","js/useTranslation-B9kflK9S.js","js/ui-vendor-BhHHyHk3.js","js/goober.modern-BaHbaW3_.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-wiHys0m2.js";import{o as i}from"./logger-BR4forr_.js";import{t as a}from"./useTranslation-B9kflK9S.js";import{t as o}from"./utils-p8Gt72YP.js";import{Lt as s,n as c}from"./ui-vendor-BhHHyHk3.js";import{t as l}from"./appStore-BD70bvas.js";import{a as u,c as d,i as f,n as p,o as m,r as h,t as g}from"./messageCodeStyles-D4haBw80.js";import"./Button-CGMYia4g.js";import{t as _}from"./useDialogFocus-BPTG_Zmy.js";var v=e(t(),1),y=r(),b=({label:e,error:t,helper:n,className:r,id:i,...a})=>{let s=(0,v.useId)(),c=i||`input-${s}`,l=`${c}-feedback`,u=[a[`aria-describedby`],(t||n)&&l].filter(Boolean).join(` `)||void 0;return(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,y.jsx)(`label`,{htmlFor:c,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,y.jsx)(`input`,{id:c,className:o(`block w-full rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`placeholder:text-ink-subtle transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,r),...a,"aria-invalid":t?!0:a[`aria-invalid`],"aria-describedby":u}),t&&(0,y.jsx)(`p`,{id:l,role:`alert`,className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,y.jsx)(`p`,{id:l,className:`text-xs leading-relaxed text-ink-muted`,children:n})]})},x=v.forwardRef(({label:e,error:t,helper:n,className:r,id:i,...a},s)=>{let c=(0,v.useId)(),l=i||`textarea-${c}`,u=`${l}-feedback`,d=[a[`aria-describedby`],(t||n)&&u].filter(Boolean).join(` `)||void 0;return(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,y.jsx)(`label`,{htmlFor:l,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,y.jsx)(`textarea`,{ref:s,id:l,className:o(`block w-full resize-none rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`placeholder:text-ink-subtle transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,r),...a,"aria-invalid":t?!0:a[`aria-invalid`],"aria-describedby":d}),t&&(0,y.jsx)(`p`,{id:u,role:`alert`,className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,y.jsx)(`p`,{id:u,className:`text-xs leading-relaxed text-ink-muted`,children:n})]})});x.displayName=`Textarea`;var S=({label:e,error:t,helper:n,options:r,className:i,id:a,...s})=>{let c=(0,v.useId)(),l=a||`select-${c}`,u=`${l}-feedback`,d=[s[`aria-describedby`],(t||n)&&u].filter(Boolean).join(` `)||void 0;return(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,y.jsx)(`label`,{htmlFor:l,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,y.jsx)(`select`,{id:l,className:o(`block w-full rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,i),...s,"aria-invalid":t?!0:s[`aria-invalid`],"aria-describedby":d,children:r.map((e,t)=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.key??`${e.value}-${t}`))}),t&&(0,y.jsx)(`p`,{id:u,role:`alert`,className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,y.jsx)(`p`,{id:u,className:`text-xs leading-relaxed text-ink-muted`,children:n})]})},C=({className:e,...t})=>(0,y.jsx)(s,{...t,"aria-hidden":`true`,className:o(`h-3.5 w-3.5 shrink-0 animate-spin text-ink-subtle motion-reduce:animate-none`,e)}),w=v.lazy(()=>i(()=>import(`./OptimizedSyntaxHighlighter-ajqwyBQm.js`),__vite__mapDeps([0,1,2,3,4,5]))),T=8e4;function E({content:e}){return e?(0,y.jsx)(`div`,{dir:`auto`,className:`whitespace-pre-wrap break-words leading-relaxed`,children:e}):null}function D({content:e,language:t,complete:n}){let r=n?e.replace(/\r?\n$/,``):e,i=l(e=>e.theme.mode!==`light`),a=v.useRef(null),o=v.useRef(!0),s=v.useDeferredValue(r),c=r.length<=T,d=v.useCallback(e=>{a.current=e,e&&o.current&&(e.scrollTop=e.scrollHeight)},[]);v.useLayoutEffect(()=>{let e=a.current;e&&o.current&&(e.scrollTop=e.scrollHeight)},[r,s]);let m=v.useCallback(()=>{let e=a.current;if(!e)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;o.current=t<24},[]),_=v.useMemo(()=>({children:e,...t})=>(0,y.jsx)(`pre`,{...t,ref:d,onScroll:e=>{m(),t.onScroll?.(e)},children:e}),[d,m]),b=(0,y.jsx)(`pre`,{ref:d,onScroll:m,className:h,children:(0,y.jsx)(`code`,{children:r})});return(0,y.jsx)(u,{code:r,language:t,state:n?`complete`:`streaming`,children:c?(0,y.jsx)(v.Suspense,{fallback:b,children:(0,y.jsx)(w,{language:t||`text`,isDark:i,codeTheme:`night`,backgroundColor:i?g:p,borderRadius:0,customStyle:f,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,preTag:_,children:s})}):b})}var O=v.memo(({content:e,className:t,segments:n,isStreaming:r=!0})=>{let i=v.useMemo(()=>n??m(e),[e,n]),a=i[i.length-1],s=a?.type===`code`&&!a.complete;return(0,y.jsxs)(`div`,{className:o(`text-sm leading-relaxed text-ink`,t),children:[i.map((e,t)=>e.type===`code`?(0,y.jsx)(D,{...e},`${e.type}-${t}`):(0,y.jsx)(E,{content:e.content},`${e.type}-${t}`)),r&&!s&&(0,y.jsx)(C,{"data-testid":`message-streaming-cursor`,className:`ms-1 inline-block align-text-bottom`})]})});O.displayName=`StreamingMessageContent`;var k=v.lazy(()=>i(()=>import(`./RichMessageContent-BZndQSJU.js`),__vite__mapDeps([6,7,2,3,8,9,10,11,12,13,14,15,5])));function A({content:e,className:t}){return(0,y.jsx)(`div`,{dir:`auto`,className:o(`text-sm leading-relaxed text-ink whitespace-pre-wrap break-words`,t),children:e})}var j=v.memo(({content:e,className:t,isStreaming:n=!1})=>{let r=v.useMemo(()=>n?m(e):[],[e,n]),i=r.some(e=>e.type===`code`);if(n&&i)return(0,y.jsx)(O,{content:e,className:t,segments:r});let a;return a=d(e)?(0,y.jsx)(v.Suspense,{fallback:(0,y.jsx)(O,{content:e,className:t,isStreaming:!1}),children:(0,y.jsx)(k,{content:e,className:t})}):(0,y.jsx)(A,{content:e,className:t}),(0,y.jsxs)(y.Fragment,{children:[a,n&&(0,y.jsx)(`span`,{"data-testid":`message-streaming-cursor`,"aria-hidden":`true`,className:`ms-1 inline-block h-5 w-1 animate-pulse rounded-full bg-primary-500 align-text-bottom`})]})});j.displayName=`MessageContent`;var M=({children:e,htmlFor:t,className:n=``})=>(0,y.jsx)(`label`,{htmlFor:t,className:o(`text-sm font-medium tracking-[-0.005em] text-ink-muted`,n),children:e}),N=({checked:e,onChange:t,disabled:n=!1,className:r=``})=>(0,y.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-disabled":n||void 0,disabled:n,onClick:()=>t(!e),className:o(`relative inline-flex h-6 w-11 flex-shrink-0 items-center justify-center rounded-full bg-transparent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas dark:focus-visible:ring-primary-400`,n?`cursor-not-allowed opacity-50`:`cursor-pointer`,r),children:(0,y.jsx)(`span`,{"aria-hidden":`true`,className:o(`relative inline-flex h-6 w-11 items-center rounded-full border shadow-inner`,`transition-[background-color,border-color] duration-150 ease-out motion-reduce:transition-none`,e?`border-primary-600/70 bg-primary-600`:`border-line-strong bg-surface-subtle`),children:(0,y.jsx)(`span`,{className:o(`inline-block h-4 w-4 rounded-full bg-white shadow-subtle ring-1 ring-black/5`,`transform transition-transform duration-150 ease-out motion-reduce:transition-none`,e?`translate-x-6 rtl:-translate-x-6`:`translate-x-1 rtl:-translate-x-1`)})})}),P={narrow:`max-w-4xl`,default:`max-w-6xl`,wide:`max-w-7xl`},F=({children:e,width:t=`default`,className:n,contentClassName:r,...i})=>(0,y.jsx)(`div`,{"data-testid":`page-scroll-region`,className:o(`scroll-region h-full min-h-0 scrollbar-thin`,n),...i,children:(0,y.jsx)(`div`,{className:o(`mx-auto w-full px-4 pb-16 pt-7 sm:px-6 sm:pb-20 sm:pt-10 lg:px-8`,P[t],r),children:e})}),I=({title:e,description:t,eyebrow:n,actions:r,meta:i,className:a,...s})=>(0,y.jsxs)(`header`,{className:o(`mb-8 flex flex-col gap-6 border-b border-gray-200/70 pb-7 text-start dark:border-white/[0.08] sm:mb-10 sm:pb-9 md:flex-row md:items-end md:justify-between`,a),...s,children:[(0,y.jsxs)(`div`,{className:`min-w-0 max-w-3xl`,children:[n&&(0,y.jsx)(`div`,{className:`mb-3 text-[11px] font-medium uppercase tracking-[0.18em] text-gray-500 dark:text-dark-500 rtl:tracking-normal`,children:n}),(0,y.jsx)(`h1`,{className:`text-balance text-3xl font-normal leading-[1.02] tracking-[-0.04em] text-gray-950 dark:text-dark-950 sm:text-5xl rtl:leading-[1.15] rtl:tracking-normal`,children:e}),t&&(0,y.jsx)(`p`,{className:`mt-4 max-w-2xl text-sm leading-6 text-gray-600 dark:text-dark-600 sm:text-base sm:leading-7`,children:t}),i&&(0,y.jsx)(`div`,{className:`mt-4`,children:i})]}),r&&(0,y.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 md:justify-end`,children:r})]}),L=n(),R=`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900`,z=`mb-1 block text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500`,B=({titleId:e,title:t,subtitle:n,onClose:r,children:i,footer:a,widthClassName:s=`max-w-lg`,testId:c})=>{let l=(0,v.useRef)(null);return _(l,{onClose:r}),(0,L.createPortal)((0,y.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:r,children:(0,y.jsx)(`div`,{ref:l,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-labelledby":e,"data-testid":c,className:o(`flex max-h-[90vh] w-full flex-col overflow-hidden rounded-3xl border border-black/[0.07] bg-white shadow-[0_24px_80px_rgba(0,0,0,0.24)] animate-scale-in dark:border-white/[0.08] dark:bg-dark-25`,s),onClick:e=>e.stopPropagation(),children:(0,y.jsxs)(`div`,{"data-testid":`modal-scroll-region`,className:`min-h-0 overflow-y-auto p-6 scrollbar-thin`,children:[(0,y.jsx)(V,{titleId:e,title:t,subtitle:n,onClose:r}),i&&(0,y.jsx)(`div`,{className:`space-y-4`,children:i}),a&&(0,y.jsx)(`div`,{className:`mt-5 flex justify-end gap-3 border-t border-gray-200 pt-4 dark:border-dark-300`,children:a})]})})}),document.body)},V=({titleId:e,title:t,subtitle:n,onClose:r})=>{let{t:i}=a();return(0,y.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`h3`,{id:e,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:t}),n&&(0,y.jsx)(`p`,{className:`mt-1 text-[12px] leading-5 text-gray-500 dark:text-dark-500`,children:n})]}),(0,y.jsx)(`button`,{type:`button`,onClick:r,"aria-label":i(`common.close`),className:`shrink-0 rounded-xl p-2 transition-colors hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 dark:hover:bg-dark-200`,children:(0,y.jsx)(c,{size:20,className:`text-gray-500`})})]})},H=({icon:e,label:t,destructive:n,disabled:r,testId:i,onClick:a})=>(0,y.jsx)(`button`,{type:`button`,onClick:a,disabled:r,title:t,"aria-label":t,"data-testid":i,className:o(`rounded-lg p-1.5 text-gray-400 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,n?`hover:bg-red-500/10 hover:text-red-500`:`hover:bg-black/[0.04] hover:text-gray-700 dark:hover:bg-white/[0.06] dark:hover:text-dark-800`),children:(0,y.jsx)(e,{className:`h-3.5 w-3.5`})});export{I as a,M as c,C as d,S as f,z as i,j as l,b as m,B as n,F as o,x as p,R as r,N as s,H as t,O as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./react-vendor-wiHys0m2.js";import{a as n,t as r}from"./logger-BR4forr_.js";import{t as i}from"./useTranslation-B9kflK9S.js";import{a,c as o,s}from"./utils-p8Gt72YP.js";import{g as c,t as l}from"./chatStore-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./react-vendor-wiHys0m2.js";import{a as n,t as r}from"./logger-BR4forr_.js";import{t as i}from"./useTranslation-B9kflK9S.js";import{a,c as o,s}from"./utils-p8Gt72YP.js";import{g as c,t as l}from"./chatStore-CK5ojwft.js";import{wr as u}from"./ui-vendor-BhHHyHk3.js";import{t as d}from"./config-D6Kcp5n3.js";import{P as f,d as p}from"./api-DPXCtanG.js";import{n as m}from"./authStore-D8fc-Hl0.js";import{t as h}from"./appStore-BD70bvas.js";import{c as g,s as _}from"./artifactHtml-DDmfpcB0.js";var v=e(t(),1),y=/```([^\n`]*)\n([\s\S]*?)\n```/g,b=/^(?:%%|flowchart|graph|sequenceDiagram|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|gantt|pie|mindmap|timeline|gitGraph|quadrantChart|requirementDiagram|sankey-beta|xychart-beta|block-beta|architecture-beta|packet-beta|kanban|radar-beta|treemap-beta|C4Context)\b/i,x=/[\w@./-]+\.(?:html?|css|mjs|js|jsx|ts|tsx|svg|json|py)/i,ee=[`html`,`react`,`svg`,`mermaid`,`chart`,`code`,`text`,`json`],S=[{regex:/<artifact\s+type="([^"]+)"\s+title="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>({type:A(e[1]),title:C(e[2]).trim()||`Artifact`,content:e[3].trim()})},{regex:/<artifact\s+type="([^"]+)"[^>]*>([\s\S]*?)<\/artifact>/gi,extract:e=>{let t=A(e[1]);return{type:t,title:`${t.toUpperCase()} Artifact`,content:e[2].trim()}}}];function C(e){if(typeof document<`u`){let t=document.createElement(`div`);return t.innerHTML=e,t.textContent||t.innerText||``}return T(w(e))}function w(e){return e.replace(/&(lt|gt|quot|apos|#39);/gi,(e,t)=>{switch(t.toLowerCase()){case`lt`:return`<`;case`gt`:return`>`;case`quot`:return`"`;case`apos`:case`#39`:return`'`;default:return``}}).replace(/&/gi,`&`)}function T(e){let t=``,n=!1,r=null;for(let i=0;i<e.length;i+=1){let a=e[i];if(n){if(r){a===r&&(r=null);continue}if(a===`"`||a===`'`){r=a;continue}a===`>`&&(n=!1);continue}if(a===`<`){let t=e[i+1];if(t&&/[!/A-Za-z?]/.test(t)){n=!0;continue}}t+=a}return t}function E(e){let t=e.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(t)return C(t[1]).trim()||null;let n=e.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i);return n&&C(n[1]).trim()||null}function D(e){for(let t of[/export\s+default\s+(?:function|class)\s+([A-Z]\w*)/,/export\s+default\s+([A-Z]\w*)\s*(?:;|$)/m,/(?:function|class)\s+([A-Z]\w*)/,/const\s+([A-Z]\w*)\s*[:=]/,/(?:function|const|class)\s+(\w+)/]){let n=e.match(t);if(n)return n[1]}return null}function O(e){let t=e.match(/^\s*title\s+(.+)$/im);if(t)return t[1].trim();let n=e.trim().match(/^([A-Za-z][\w-]*)/);if(!n)return null;let r=n[1].replace(/-(?:beta|v2)$/i,``).replace(/([a-z])([A-Z])/g,`$1 $2`);return`${r.charAt(0).toUpperCase()}${r.slice(1)}`}function k(e){if(e.includes(`def main(`))return`Python Script`;let t=e.match(/class\s+(\w+)/);if(t)return`${t[1]} Class`;let n=e.match(/def\s+(\w+)/);return n&&n[1]!==`__init__`?`${n[1]} Function`:null}function te(e){let t=e.match(/function\s+(\w+)/);if(t)return`${t[1]} Function`;let n=e.match(/(?:const|let)\s+(\w+)\s*=/);return n?n[1]:null}function A(e){let t=e.trim().toLowerCase();return ee.includes(t)?t:`text`}function j(e){if(!e)return;let t=e.trim().toLowerCase().replace(/^\./,``).replace(/[,:;]+$/,``);switch(t){case`htm`:case`html`:return`html`;case`js`:case`mjs`:case`javascript`:return`javascript`;case`jsx`:case`tsx`:case`react`:return`react`;case`ts`:case`typescript`:return`typescript`;case`py`:case`python`:return`python`;case`css`:case`svg`:case`json`:return t;default:return t||void 0}}function M(e){let t=[],n=new RegExp(y),r;for(;(r=n.exec(e))!==null;){let n=r[1].trim(),i=ne(n,N(e,r.index));t.push({raw:r[0],info:n,content:r[2].trim(),start:r.index,end:r.index+r[0].length,language:i.language,fileName:i.fileName})}return t}function ne(e,t){let n=re(e)||t,r=e.split(/\s+/).filter(Boolean)[0]?.replace(/[{}[\]()]/g,``);return{language:(r&&!x.test(r)&&!r.includes(`=`)?j(r):void 0)||j(F(n)),fileName:n}}function re(e){let t=e.match(/(?:file(?:name)?|path|name)\s*=\s*["']?([^"'\s]+)["']?/i);if(t&&x.test(t[1]))return P(t[1]);let n=e.match(x);return n?P(n[0]):void 0}function N(e,t){let n=e.slice(Math.max(0,t-180),t).split(`
|
|
2
2
|
`).slice(-3).reverse();for(let e of n){let t=e.trim().replace(/^#{1,6}\s*/,``).replace(/^[-*]\s*/,``).replace(/[::]\s*$/,``).match(x);if(t)return P(t[0])}}function P(e){return e.replace(/^["'`]+|["'`:]+$/g,``)}function F(e){return e?.match(/\.([a-z0-9]+)$/i)?.[1]}function I(e){return e?.split(/[\\/]/).pop()}function L(e){let t=I(e);if(!t)return null;let n=t.replace(/\.[^.]+$/,``);return/^(index|main|app)$/i.test(n)?null:n.replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function R(e){let t=Date.now();return{...e,id:`artifact-${t}-${o(9)}`,createdAt:t,updatedAt:t}}function z(e){let t=j(e.language)||j(F(e.fileName));switch(t){case`html`:return{type:`html`,title:E(e.content)||L(e.fileName)||`HTML Document`};case`svg`:return{type:`svg`,title:L(e.fileName)||`SVG Image`};case`react`:return{type:`react`,title:D(e.content)||L(e.fileName)||`React Component`,language:`jsx`};case`mermaid`:return{type:`mermaid`,title:O(e.content)||`Diagram`,language:`mermaid`};case`json`:return{type:`json`,title:L(e.fileName)||`JSON Data`};case`python`:return{type:`code`,title:k(e.content)||L(e.fileName)||`Python Code`,language:`python`};case`css`:return{type:`code`,title:L(e.fileName)||`CSS Styles`,language:`css`};case`javascript`:return{type:`code`,title:te(e.content)||L(e.fileName)||`JavaScript Code`,language:`javascript`};case`typescript`:return{type:`code`,title:L(e.fileName)||`TypeScript Code`,language:`typescript`};default:return t?{type:`code`,title:L(e.fileName)||`${t.toUpperCase()} Code`,language:t}:null}}function B(e){return(j(e.language)||j(F(e.fileName)))===`html`}function V(e){return(j(e.language)||j(F(e.fileName)))===`css`}function ie(e){return(j(e.language)||j(F(e.fileName)))===`javascript`}function H(e){let t=M(e),n=t.filter(B);if(n.length===0)return null;let r=t.filter(V),i=t.filter(ie);if(r.length===0&&i.length===0)return null;let a=n.find(e=>/(^|[/\\])index\.html?$/i.test(e.fileName||``))||n[0],o=U(a.content,r,i),s=g(o,r.map(e=>e.content),i.map(e=>e.content));return q(s,`html`)?{artifact:R({type:`html`,title:E(s)||L(a.fileName)||`Interactive HTML App`,description:`Bundled generated HTML, CSS, and JavaScript files into one runnable artifact.`,content:s}),ranges:[a,...r,...i]}:null}function U(e,t,n){let r=e;for(let e of t){let t=I(e.fileName);t&&(r=r.replace(RegExp(`<link\\b[^>]*href=["'][^"']*${K(t)}["'][^>]*>`,`gi`),``))}for(let e of n){let t=I(e.fileName);t&&(r=r.replace(RegExp(`<script\\b[^>]*src=["'][^"']*${K(t)}["'][^>]*>\\s*<\\/script>`,`gi`),``))}return r}function ae(e){let t=/<!doctype\s+html|<html[\s>]/i.exec(e);if(!t||t.index===void 0)return null;let n=M(e);if(W(t.index,n))return null;let r=t.index,i=/<\/html>/gi;i.lastIndex=r;let a=i.exec(e),o=a?a.index+a[0].length:e.length,s=e.slice(r,o).trim();return q(s,`html`)?{artifact:R({type:`html`,title:E(s)||`HTML Document`,content:s}),ranges:[{start:r,end:o}]}:null}function W(e,t){return t.some(t=>e>=t.start&&e<=t.end)}function G(e,t){return[...t].sort((e,t)=>t.start-e.start).reduce((e,t)=>`${e.slice(0,t.start)}${e.slice(t.end)}`,e)}function K(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function q(e,t){if(t===`html`){let t=e.trim(),n=/<[^>]+>/.test(t),r=/<(canvas|script|style|button|form|input|select|textarea|video|audio)\b/i.test(t)||/\bon(?:click|input|submit|keydown|keyup|mousemove)=/i.test(t);return n&&(_(t)||t.length>160||r)}if(t===`svg`)return/<svg[^>]*>/.test(e);if(t===`react`)return/<[A-Za-z][^>]*>/.test(e)&&/\b(?:export\s+default|return\s*[(<]|=>\s*[(<]|createRoot|render\s*\()/.test(e);if(t===`mermaid`)return b.test(e.trim());if(t===`json`)try{return JSON.parse(e),e.trim().length>100}catch{return!1}if(t===`code`){let t=e.split(`
|
|
3
3
|
`).length,n=e.trim().length,r=/function|class|def |import |from |const |let |var |if |for |while |try |catch/.test(e);return(n>500||t>15)&&r}return e.trim().length>200}function oe(e){let t=[],n=e;for(let e of S){e.regex.lastIndex=0;let r=[],i;for(;(i=e.regex.exec(n))!==null;){let n=e.extract(i);q(n.content,n.type)&&(t.push(R({type:n.type,title:n.title,content:n.content})),r.push({start:i.index,end:i.index+i[0].length}))}n=G(n,r)}let r=H(n);for(;r;)t.push(r.artifact),n=G(n,r.ranges),r=H(n);let i=ae(n);i&&(t.push(i.artifact),n=G(n,i.ranges));let a=M(n),o=[];for(let e of a){let n=z(e);n&&q(e.content,n.type)&&(t.push(R({type:n.type,title:n.title,content:e.content,language:n.language})),o.push(e))}return n=G(n,o),{content:n.trim(),artifacts:t}}var J=new Map;function se(e,t,n=``){let r=J.get(e);if(n){if((!r||r.state===`none`)&&(J.set(e,{state:`open`,startedAt:Date.now()}),!t))return;let n=J.get(e);t&&n?.state===`open`&&J.set(e,{state:`done`,durationMs:Date.now()-n.startedAt});return}if(r&&r.state!==`open`||!t)return;let i=s(t);if(!r){i.thinkingComplete?J.set(e,{state:`none`}):J.set(e,{state:`open`,startedAt:Date.now()});return}i.thinkingComplete&&J.set(e,{state:`done`,durationMs:Date.now()-r.startedAt})}function Y(e){let t=J.get(e);if(t){if(t.state===`done`)return t.durationMs;if(t.state===`open`)return Date.now()-t.startedAt}}function ce(e){let t=J.get(e);if(J.delete(e),t){if(t.state===`done`)return t.durationMs;if(t.state===`open`)return Date.now()-t.startedAt}}function le(e){let t=e/1e3;if(t<.95)return`${Math.max(.1,Math.round(t*10)/10)}s`;if(t<60)return`${Math.round(t)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return r>0?`${n}m ${r}s`:`${n}m`}var ue=(e,t)=>{l.setState(n=>{let r=n=>n&&n.id===e?{...n,settings:{...n.settings,...t.length>0?{promptQueue:t}:{promptQueue:void 0}}}:n;return{currentSession:r(n.currentSession),sessions:n.sessions.map(e=>r(e))}})},de=(e,t)=>{t?.add(e.assistantMessageId),e.cancelRequested=!0,e.jobId&&e.abort.abort()},fe=async e=>{if(!e.cancelledMessageIds.has(e.assistantMessageId))return!1;try{let t=await(e.cancelByIdentity??Q)(e.sessionId,e.assistantMessageId);await e.settle(t)}catch(t){e.onError?.(t)}return!0},pe=e=>{e.retainForContinuation||e.cancelledMessageIds.delete(e.assistantMessageId)},me=async(e,t,n={})=>{if(e.jobId=t.jobId,!e.cancelRequested)return`stream`;e.abort.abort();let[,r]=await Promise.allSettled([(n.byJob??ye)(t.jobId),(n.byIdentity??Q)(e.sessionId,e.assistantMessageId)]);if(r.status===`rejected`)throw r.reason;return r.value.completed?`completed`:`cancelled`},he=async e=>{let t=await e.loadSession(e.sessionId);if(t.id!==e.sessionId)throw Error(`Reloaded chat session does not match the completed turn.`);if(!t.messages.find(t=>t.id===e.assistantMessageId&&t.role===`assistant`))throw Error(`Completed assistant message is absent from chat storage.`);return e.applySession(t),t},X=async e=>{try{let t=await e.json(),n=typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:void 0;if(n)return Error(n)}catch{}return Error(`Chat event request failed with status ${e.status}.`)},Z=()=>{let e=localStorage.getItem(`auth-token`);return e?{Authorization:`Bearer ${e}`}:{}},ge=async e=>{let t=await fetch(`${d}/chat/sessions/${encodeURIComponent(e.sessionId)}/generations`,{method:`POST`,headers:{"Content-Type":`application/json`,...Z()},credentials:`same-origin`,signal:e.signal,body:JSON.stringify({message:e.message,images:e.images,userMessageId:e.userMessageId,assistantMessageId:e.assistantMessageId,options:e.options,webSearch:e.webSearch,tools:e.tools===!0,...e.toolSelection?{toolSelection:e.toolSelection}:{},regenerate:e.regenerate===!0,originalMessageId:e.originalMessageId,...e.modelOverride?{modelOverride:e.modelOverride}:{},...e.compare?{compare:!0}:{}})});if(!t.ok)throw await X(t);let n=await t.json();if(!n.data?.jobId)throw Error(`Chat generation response did not include a durable job.`);return n.data},_e=async(e,t)=>{if(!e.body)throw Error(`Chat event stream has no response body.`);let n=e.body.getReader(),r=new TextDecoder,i=``,a=0,o=!1,s=e=>{let n,r=[];for(let t of e.split(`
|
|
4
4
|
`))t.startsWith(`id:`)&&(n=Number(t.slice(3).trim())),t.startsWith(`data:`)&&r.push(t.slice(5).trimStart());if(!Number.isSafeInteger(n)||!r.length)return;let i=JSON.parse(r.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-wiHys0m2.js";import{t as i}from"./useQuery-hWmQjdLu.js";import{d as a}from"./router-vendor-HZm4FR0A.js";import{t as o}from"./logger-BR4forr_.js";import{t as s}from"./useTranslation-B9kflK9S.js";import{t as c}from"./utils-p8Gt72YP.js";import{h as l,s as u,t as d}from"./chatStore-DQhEqb9F.js";import{An as f,G as p,It as m,Kt as h,Ln as g,M as _,On as v,Qn as y,S as b,Tn as x,Yt as S,Z as C,Zn as ee,Zt as w,ar as T,c as te,et as E,lr as D,n as O,t as k,wr as A}from"./ui-vendor-BhHHyHk3.js";import{C as ne,g as re,t as ie,y as j}from"./api-CVUaOaq4.js";import{t as ae}from"./authStore-C5qKrmn4.js";var M=e(t(),1),oe=n(),N=r();function P(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function se({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:a,hfGgufFiles:o,loadingGguf:l,pullingModel:u,pullProgress:d,setHfTask:f,setHfSort:p,onToggleHfModel:h,onPullHfGguf:g,onCancelPull:_,onRefreshHfModels:y}){let{t:b}=s();return(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(`select`,{value:e,onChange:e=>f(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`text-generation`,children:b(`modelManager.huggingface.taskTextGeneration`)}),(0,N.jsx)(`option`,{value:`text-to-speech`,children:b(`modelManager.huggingface.taskTextToSpeech`)}),(0,N.jsx)(`option`,{value:`text-to-image`,children:b(`modelManager.huggingface.taskTextToImage`)}),(0,N.jsx)(`option`,{value:`automatic-speech-recognition`,children:b(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,N.jsxs)(`select`,{value:t,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`downloads`,children:b(`modelManager.huggingface.sortDownloads`)}),(0,N.jsx)(`option`,{value:`likes`,children:b(`modelManager.huggingface.sortLikes`)}),(0,N.jsx)(`option`,{value:`lastModified`,children:b(`modelManager.huggingface.sortRecent`)})]})]})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:b(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(m,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(k,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:b(`modelManager.huggingface.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=a===e.id,r=o[e.id]||[],i=l===e.id;return(0,N.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,N.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),h(e.id)},children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,N.jsx)(k,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,N.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,N.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(v,{className:`h-3 w-3`}),P(e.downloads)]}),(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),P(e.likes)]}),e.pipeline_tag&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,N.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(x,{className:`h-4 w-4 text-gray-400`})}),(0,N.jsx)(ee,{className:c(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,N.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,N.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,N.jsx)(m,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,N.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:b(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,N.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:b(`modelManager.huggingface.noGgufAvailable`)}):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:b(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(O,{className:`h-4 w-4`})})]}):n?(0,N.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.ollamaCommand,e.filename)},disabled:!!u,className:c(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,N.jsx)(v,{className:`h-3 w-3 inline mr-1`}),b(`models.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:b(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&d?.percent!==void 0&&(0,N.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),b(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),y()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(C,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function ce({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:a,getModelSubLabel:o,onModelSelect:l,onOpenGallery:u}){let{t:d}=s();return(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,N.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:c(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:a(e)}),o(e)&&(0,N.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:o(e)})]}),t===n&&(0,N.jsx)(y,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(f,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,N.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(E,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,N.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),u()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(h,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function le({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:a,pullProgress:o,setLibraryCategory:l,isModelInstalled:u,onModelSelect:d,onPullModel:f,onCancelPull:p,onRefreshLibrary:h}){let{t:_}=s();return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,N.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:c(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:_(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(m,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(g,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:_(`models.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=a===e.name;return(0,N.jsxs)(`div`,{className:c(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,N.jsx)(g,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:_(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,N.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),`Cloud`]})]}),(0,N.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,N.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,N.jsx)(v,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,N.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:o?.percent===void 0?`...`:`${o.percent}%`}),(0,N.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(O,{className:`h-4 w-4`})})]}):t?(0,N.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:_(`modelSelector.use`)}):n?(0,N.jsxs)(`button`,{onClick:()=>f(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,N.jsx)(v,{className:`h-3 w-3 inline mr-1`}),_(`modelSelector.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:_(`modelSelector.adminOnlyPull`)})})]}),r&&o?.percent!==void 0&&(0,N.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${o.percent}%`}})})]},e.name)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),_(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),h()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(C,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var ue=o(`components:model-selector`),F=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:o,disabled:f=!1,compact:m=!1,showImageGen:h=!1,onModelsRefresh:v,getModelValue:y,getModelLabel:x,getModelTitle:S,triggerRef:C,triggerTestId:E,selectTestId:ie,ariaLabel:P})=>{let{t:F}=s(),[I,L]=(0,M.useState)(!1),[R,z]=(0,M.useState)(``),[B,V]=(0,M.useState)(`installed`),de=(0,M.useRef)(null),H=(0,M.useRef)(null),fe=(0,M.useRef)(null),pe=(0,M.useRef)(null),me=a(),{user:he,systemInfo:ge}=ae(),U=he?.role===`admin`||ge?.requiresAuth===!1,[W,_e]=(0,M.useState)(`all`),[ve,ye]=(0,M.useState)(``),[be,xe]=(0,M.useState)(`text-generation`),[Se,Ce]=(0,M.useState)(`downloads`),[we,Te]=(0,M.useState)(``),[Ee,De]=(0,M.useState)(null),[Oe,ke]=(0,M.useState)({}),[Ae,je]=(0,M.useState)(null),[G,K]=(0,M.useState)(null),[Me,q]=(0,M.useState)(null),[Ne,J]=(0,M.useState)(null),Pe=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Fe=[{type:`legacy`,label:F(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:F(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,N.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:F(`modelSelector.personas`),icon:(0,N.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:F(`modelSelector.agentModels`,`Agents`),icon:(0,N.jsx)(b,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:F(`modelSelector.ollamaModels`),icon:(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>l(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:F(`modelSelector.pluginModels`),icon:(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(R.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(R.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(R.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>y?.(e)??e.name,Ie=d(e=>e.modelMetadata),X=d(e=>e.personas),Z=e.find(e=>Y(e)===t),Le=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}let r=X[t]??X[n];if(r?.name)return r.name;if(e.personaName&&e.personaName!==t)return e.personaName},Re=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}return X[t]??X[n]};(0,M.useImperativeHandle)(C,()=>fe.current);let Q=(0,M.useCallback)((e=!0)=>{L(!1),z(``),e&&window.requestAnimationFrame(()=>fe.current?.focus())},[]),{data:ze=[],isLoading:Be,refetch:Ve}=i({queryKey:[`ollama-library-selector`,ve,W===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await j.getLibraryModels({search:ve||void 0,sort:`popular`,category:W===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:I&&B===`ollama`}),{data:He=[],isLoading:Ue,refetch:We}=i({queryKey:[`hf-models-selector`,be,we,Se],queryFn:async()=>{let e=await ne.getModels({task:be,search:we||void 0,sort:Se,limit:30});return e.success&&e.data?e.data:[]},enabled:I&&B===`huggingface`}),Ge=ze.filter(e=>{let t=!R||e.name.toLowerCase().includes(R.toLowerCase())||e.description.toLowerCase().includes(R.toLowerCase()),n=W===`all`||e.category===W;return t&&n}),Ke=(0,M.useCallback)(async e=>{let[t,n]=e.split(`/`);if(t&&n){je(e);try{let r=await ne.getGgufFiles(t,n);r.success&&r.data&&ke(t=>({...t,[e]:r.data}))}catch(e){ue.error(`Failed to load GGUF files:`,e)}finally{je(null)}}},[]),qe=(0,M.useCallback)(e=>{Ee===e?De(null):(De(e),Oe[e]||Ke(e))},[Ee,Oe,Ke]),Je=(0,M.useCallback)((e,t)=>{if(!U){A.error(F(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=j.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),A.success(F(`modelDownload.success`,{name:t})),v?.()},e=>{q(null),K(null),J(null),A.error(F(`modelDownload.failed`,{error:e}))});J(()=>n)}catch{q(null),K(null),A.error(F(`modelDownload.startFailed`))}}},[U,v,G,F]);(0,M.useEffect)(()=>{let e=setTimeout(()=>{B===`huggingface`?Te(R):B===`ollama`&&ye(R)},300);return()=>clearTimeout(e)},[R,B]),(0,M.useEffect)(()=>{if(!I)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Q();return}if(e.key===`Tab`&&H.current){let t=Array.from(H.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Q,I]),(0,M.useEffect)(()=>{I&&pe.current&&pe.current.focus()},[I]);let Ye=async t=>{let r=e.find(e=>Y(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?Y(r):t,a=r?.name??t;Q();try{let e=await j.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await j.unloadAllModels())}}catch(e){ue.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},Xe=async e=>{if(!U){A.error(F(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=j.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),A.success(F(`modelDownload.success`,{name:e})),v?.()},e=>{q(null),K(null),J(null),A.error(F(`modelDownload.failed`,{error:e}))});J(()=>t)}catch{q(null),K(null),A.error(F(`modelDownload.startFailed`))}}},Ze=()=>{Ne&&(Ne(),J(null),K(null),q(null),A.success(F(`modelDownload.cancelled`)))},Qe=t=>e.some(e=>l(e)&&(e.name===t||e.name.startsWith(t+`:`))),$e=e=>{let t=Ie[u(e)]?.avatar;if(t&&!e.isPersona)return(0,N.jsx)(`img`,{src:t,alt:``,className:`h-4 w-4 shrink-0 rounded-full object-cover`});if(e.isPersona||e.isLegacySelection){let t=Re(e);if(t)return(0,N.jsx)(`img`,{src:re(t,64),alt:``,className:`h-4 w-4 shrink-0 rounded object-cover`})}return e.isLegacySelection?(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,N.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})},$=e=>{if(x)return x(e);let t=Ie[u(e)]?.label;return t&&!e.isPersona?t:e.isLegacySelection?`${Le(e)??e.name} (${F(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?Le(e)||e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.name)},et=e=>e.isLegacySelection?e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):F(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${F(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,N.jsxs)(`div`,{className:c(`relative min-w-0`,o),ref:de,children:[(0,N.jsxs)(`button`,{ref:fe,"data-testid":E,type:`button`,onClick:()=>!f&&L(!I),disabled:f,"aria-haspopup":`dialog`,"aria-expanded":I,"aria-label":P&&Z?`${P}: ${$(Z)}`:P,className:c(m?`flex h-9 w-full min-w-0 items-center justify-between gap-2 px-2.5 text-start`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`rounded-xl border border-line bg-surface-subtle text-sm text-ink hover:bg-hover-solid`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,f?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:m?Z?S?.(Z)??$(Z):F(`modelSelector.selectModel`):void 0,children:[(()=>{if(!Z)return m?(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(D,{className:`h-4 w-4 shrink-0`}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium text-ink-subtle`,children:F(`modelSelector.selectModel`)})]}):F(`modelSelector.selectModel`);if(m){let e=$(Z);return(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`shrink-0`,children:$e(Z)}),(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`truncate text-xs font-medium text-ink`,children:e})]})}let e=$(Z),t=et(Z);return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[$e(Z),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,N.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),Z.isPersona&&r&&(0,N.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,N.jsx)(T,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,N.jsx)(_,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,N.jsx)(ee,{className:c(m?`h-3 w-3`:`h-4 w-4`,`shrink-0 text-ink-subtle transition-transform duration-150 motion-reduce:transition-none`,I&&`rotate-180`)})]}),I&&(0,oe.createPortal)((0,N.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,N.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Q()}),(0,N.jsxs)(`div`,{ref:H,role:`dialog`,"aria-modal":`true`,"aria-label":F(`modelSelector.selectModel`),className:c(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,N.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:F(`modelSelector.selectModel`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>Q(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:F(`common.close`),children:(0,N.jsx)(O,{className:`h-4 w-4`})})]}),(0,N.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(p,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,N.jsx)(`input`,{ref:pe,type:`text`,placeholder:F(B===`installed`?`modelSelector.searchInstalled`:B===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:R,onChange:e=>z(e.target.value),className:c(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,N.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,N.jsxs)(`button`,{onClick:()=>{V(`installed`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,B===`installed`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":B===`installed`,children:[(0,N.jsx)(w,{className:`h-4 w-4 inline me-1.5`}),F(`modelSelector.installed`)]}),(0,N.jsxs)(`button`,{onClick:()=>{V(`ollama`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,B===`ollama`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":B===`ollama`,children:[(0,N.jsx)(g,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,N.jsxs)(`button`,{onClick:()=>{V(`huggingface`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,B===`huggingface`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":B===`huggingface`,children:[(0,N.jsx)(k,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),B===`installed`&&(0,N.jsx)(ce,{filteredGroups:Fe,selectedModel:t,showImageGen:h,getModelValue:Y,getModelIcon:$e,getModelLabel:$,getModelSubLabel:et,onModelSelect:Ye,onOpenGallery:()=>{Q(!1),me(`/gallery`)}}),B===`ollama`&&(0,N.jsx)(le,{libraryCategories:Pe,libraryCategory:W,canInstallModels:U,loadingLibrary:Be,filteredLibraryModels:Ge,pullingModel:G,pullProgress:Me,setLibraryCategory:_e,isModelInstalled:Qe,onModelSelect:Ye,onPullModel:Xe,onCancelPull:Ze,onRefreshLibrary:()=>{Ve()}}),B===`huggingface`&&(0,N.jsx)(se,{hfTask:be,hfSort:Se,canInstallModels:U,loadingHf:Ue,hfModels:He,expandedHfModel:Ee,hfGgufFiles:Oe,loadingGguf:Ae,pullingModel:G,pullProgress:Me,setHfTask:xe,setHfSort:Ce,onToggleHfModel:qe,onPullHfGguf:Je,onCancelPull:Ze,onRefreshHfModels:()=>{We()}})]})]}),document.body),(0,N.jsx)(`select`,{"data-testid":ie,"aria-label":P,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,N.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})},I=o(`hooks:dictation`),L=()=>{if(typeof window>`u`)return;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition},R=[{mimeType:`audio/webm;codecs=opus`,format:`webm`}],z=300,B=.25,V=e=>`${encodeURIComponent(e.plugin)}:${encodeURIComponent(e.model)}`;function de(e){if(typeof MediaRecorder>`u`)return;let t=new Set((e.config?.formats||[]).map(e=>e.toLowerCase()));return R.find(e=>(t.size===0||t.has(e.format))&&(typeof MediaRecorder.isTypeSupported!=`function`||MediaRecorder.isTypeSupported(e.mimeType)))?.mimeType}function H({onStart:e,onText:t,ownerKey:n}){let{t:r,i18n:i}=s(),[a,o]=(0,M.useState)(`idle`),[c,l]=(0,M.useState)([]),u=(0,M.useRef)(null),d=(0,M.useRef)(null),f=(0,M.useRef)(null),p=(0,M.useRef)(null),m=(0,M.useRef)(null),h=(0,M.useRef)(0),g=(0,M.useRef)(`idle`),_=(0,M.useRef)(void 0),v=(0,M.useRef)(e),y=(0,M.useRef)(t);(0,M.useEffect)(()=>{v.current=e,y.current=t},[e,t]),(0,M.useEffect)(()=>{let e=!1;return ie.getModels().then(t=>{!e&&t.success&&t.data&&l(t.data)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let b=(0,M.useMemo)(()=>typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices&&!!L(),[]),x=typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia,S=(0,M.useMemo)(()=>[...b?[{key:`browser`,kind:`browser`}]:[],...x?c.filter(e=>!!de(e)).map(e=>({key:V(e),kind:`provider`,model:e})):[]],[b,x,c]),[C,ee]=(0,M.useState)(``),w=(0,M.useMemo)(()=>S.find(e=>e.key===C)??S[0],[C,S]),T=w?.kind===`provider`?w.model:void 0,te=S.length>0,E=(0,M.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),D=(0,M.useCallback)(e=>{g.current=e,o(e)},[]),O=(0,M.useCallback)(()=>{h.current+=1,E(),u.current?.stop(),u.current=null,p.current?.abort(),p.current=null;let e=d.current;d.current=null,e&&(e.ondataavailable=null,e.onerror=null,e.onstop=null,e.state===`recording`&&e.stop()),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,D(`idle`)},[E,D]);return(0,M.useEffect)(()=>(_.current=n,O),[O,n]),{supported:te,phase:a,toggle:(0,M.useCallback)(async()=>{let e=g.current;if(e===`starting`||e===`transcribing`){O();return}if(e===`recording`){d.current?.state===`recording`?(D(`transcribing`),d.current.stop()):O();return}if(T){let e=h.current+1;h.current=e;let t=_.current;v.current(),D(`starting`);try{let n=await navigator.mediaDevices.getUserMedia({audio:!0});if(h.current!==e||_.current!==t){n.getTracks().forEach(e=>e.stop());return}f.current=n;let a=de(T),o=a?new MediaRecorder(n,{mimeType:a}):new MediaRecorder(n),s=[];o.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},o.onerror=()=>{n.getTracks().forEach(e=>e.stop()),E(),h.current===e&&(d.current=null,f.current=null,D(`idle`),A.error(r(`voiceMode.transcriptionFailed`)))},o.onstop=()=>{if(n.getTracks().forEach(e=>e.stop()),E(),h.current!==e||_.current!==t)return;if(d.current=null,f.current=null,s.length===0){D(`idle`);return}let a=new Blob(s,{type:o.mimeType||s[0].type||`audio/webm`}),c=new AbortController;p.current=c,D(`transcribing`),ie.transcribe(a,T,{language:i.language,signal:c.signal,fallbackMessage:r(`voiceMode.transcriptionFailed`)}).then(n=>{h.current!==e||_.current!==t||c.signal.aborted||y.current(n.text.trim())}).catch(e=>{c.signal.aborted||(I.error(`Provider transcription failed:`,e),A.error(e instanceof Error?e.message:r(`voiceMode.transcriptionFailed`)))}).finally(()=>{p.current===c&&h.current===e&&(p.current=null,D(`idle`))})},d.current=o,o.start(250);let c=T.config?.max_duration_seconds,l=typeof c==`number`&&c>0?Math.min(c,z):z;m.current=window.setTimeout(()=>{h.current===e&&o.state===`recording`&&o.stop()},Math.max(.1,l-B)*1e3),D(`recording`);return}catch(t){if(h.current!==e)return;I.error(`Failed to start provider dictation:`,t),E(),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,d.current=null,D(`idle`),A.error(r(`voiceMode.transcriptionFailed`));return}}let t=L();if(!t)return;let n=h.current+1;h.current=n;let a=_.current,o=new t;o.lang=i.language,o.continuous=!0,o.interimResults=!0,v.current(),o.onresult=e=>{if(h.current!==n||_.current!==a||u.current!==o)return;let t=``;for(let n=0;n<e.results.length;n++)t+=e.results[n][0]?.transcript??``;y.current(t.trim())},o.onend=()=>{h.current===n&&(u.current=null,D(`idle`))},o.onerror=()=>{h.current===n&&(u.current=null,D(`idle`))},u.current=o,D(`recording`);try{o.start()}catch(e){I.error(`Failed to start dictation:`,e),u.current=null,D(`idle`)}},[O,E,i.language,T,D,r]),cancel:O,sources:S,activeSourceKey:w?.key??``,setSourceKey:ee,providerModel:T}}export{F as n,H as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,r as n,t as r}from"./react-vendor-wiHys0m2.js";import{t as i}from"./useQuery-hWmQjdLu.js";import{d as a}from"./router-vendor-HZm4FR0A.js";import{t as o}from"./logger-BR4forr_.js";import{t as s}from"./useTranslation-B9kflK9S.js";import{t as c}from"./utils-p8Gt72YP.js";import{h as l,s as u,t as d}from"./chatStore-CK5ojwft.js";import{An as f,G as p,It as m,Kt as h,Ln as g,M as _,On as v,Qn as y,S as b,Tn as x,Yt as S,Z as C,Zn as ee,Zt as w,ar as T,c as te,et as E,lr as D,n as O,t as k,wr as A}from"./ui-vendor-BhHHyHk3.js";import{C as ne,g as re,t as ie,y as j}from"./api-DPXCtanG.js";import{t as ae}from"./authStore-D8fc-Hl0.js";var M=e(t(),1),oe=n(),N=r();function P(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function se({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:a,hfGgufFiles:o,loadingGguf:l,pullingModel:u,pullProgress:d,setHfTask:f,setHfSort:p,onToggleHfModel:h,onPullHfGguf:g,onCancelPull:_,onRefreshHfModels:y}){let{t:b}=s();return(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(`select`,{value:e,onChange:e=>f(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`flex-1 px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`text-generation`,children:b(`modelManager.huggingface.taskTextGeneration`)}),(0,N.jsx)(`option`,{value:`text-to-speech`,children:b(`modelManager.huggingface.taskTextToSpeech`)}),(0,N.jsx)(`option`,{value:`text-to-image`,children:b(`modelManager.huggingface.taskTextToImage`)}),(0,N.jsx)(`option`,{value:`automatic-speech-recognition`,children:b(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,N.jsxs)(`select`,{value:t,onChange:e=>p(e.target.value),onMouseDown:e=>e.stopPropagation(),className:`px-2 py-1.5 rounded-lg border text-xs bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,children:[(0,N.jsx)(`option`,{value:`downloads`,children:b(`modelManager.huggingface.sortDownloads`)}),(0,N.jsx)(`option`,{value:`likes`,children:b(`modelManager.huggingface.sortLikes`)}),(0,N.jsx)(`option`,{value:`lastModified`,children:b(`modelManager.huggingface.sortRecent`)})]})]})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:b(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(m,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(k,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:b(`modelManager.huggingface.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=a===e.id,r=o[e.id]||[],i=l===e.id;return(0,N.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,N.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),h(e.id)},children:(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,N.jsx)(k,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,N.jsx)(`span`,{className:`rounded bg-yellow-500/20 px-1.5 py-0.5 text-xs text-ink dark:bg-yellow-900/30`,children:`Gated`})]}),(0,N.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(v,{className:`h-3 w-3`}),P(e.downloads)]}),(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,N.jsx)(S,{className:`h-3 w-3`}),P(e.likes)]}),e.pipeline_tag&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,N.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(x,{className:`h-4 w-4 text-gray-400`})}),(0,N.jsx)(ee,{className:c(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,N.jsx)(`div`,{className:`px-3 pb-3 pt-1 border-t border-gray-100 dark:border-dark-200 bg-gray-50 dark:bg-dark-200`,children:i?(0,N.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,N.jsx)(m,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,N.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:b(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,N.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:b(`modelManager.huggingface.noGgufAvailable`)}):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:b(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=u===e.ollamaCommand;return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300`,children:[(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400`,children:e.quantization})]})]}),t?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:d?.percent===void 0?`...`:`${d.percent}%`}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),_()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(O,{className:`h-4 w-4`})})]}):n?(0,N.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.ollamaCommand,e.filename)},disabled:!!u,className:c(`px-3 py-1.5 rounded-lg text-xs font-medium`,`bg-primary-100 dark:bg-primary-900/30`,`text-primary-700 dark:text-primary-400`,`hover:bg-primary-200 dark:hover:bg-primary-900/50`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[(0,N.jsx)(v,{className:`h-3 w-3 inline mr-1`}),b(`models.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:b(`modelSelector.adminOnlyPull`)})]},e.filename)}),u?.startsWith(`hf.co/`)&&u.includes(e.id)&&d?.percent!==void 0&&(0,N.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${d.percent}%`}})})]})})]},e.id)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),b(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),y()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(C,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function ce({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:a,getModelSubLabel:o,onModelSelect:l,onOpenGallery:u}){let{t:d}=s();return(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-dark-400`,children:[e.length>0?e.map(e=>(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300 border-b border-gray-200 dark:border-dark-400 sticky top-0`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon,e.label,` (`,e.models.length,`)`]})}),e.models.map(e=>{let n=r(e);return(0,N.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:c(`block w-full cursor-pointer border-b border-gray-100 px-3 py-3 text-start last:border-b-0 dark:border-dark-200`,`hover:bg-gray-50 dark:hover:bg-dark-200`,`bg-white dark:bg-dark-100 transition-colors`,`focus-visible:relative focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/50`,t===n&&`bg-primary-50 dark:bg-primary-900/30`),children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:a(e)}),o(e)&&(0,N.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:o(e)})]}),t===n&&(0,N.jsx)(y,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(f,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,N.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 text-xs font-semibold text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-dark-300`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(E,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,N.jsx)(`div`,{onMouseDown:e=>{e.preventDefault(),u()},className:`px-3 py-3 cursor-pointer hover:bg-blue-50 dark:hover:bg-blue-900/20 bg-white dark:bg-dark-100`,children:(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(h,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,N.jsxs)(`div`,{className:`flex-1`,children:[(0,N.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,N.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function le({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:a,pullProgress:o,setLibraryCategory:l,isModelInstalled:u,onModelSelect:d,onPullModel:f,onCancelPull:p,onRefreshLibrary:h}){let{t:_}=s();return(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,N.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,N.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),l(e)},className:c(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,t===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400`:`bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-dark-300`),children:e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,N.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,N.jsx)(`div`,{className:`mx-3 mb-1 mt-3 rounded-lg border border-amber-200 bg-amber-500/10 px-3 py-2 text-xs text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:_(`modelSelector.pullRestricted`)}),r?(0,N.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,N.jsx)(m,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,N.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,N.jsx)(g,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,N.jsx)(`p`,{className:`text-sm`,children:_(`models.noModelsFound`)})]}):(0,N.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=u(e.name),r=a===e.name;return(0,N.jsxs)(`div`,{className:c(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,N.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,N.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,N.jsx)(g,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400`,children:_(`modelSelector.installed`)}),(e.category===`cloud`||e.tags?.includes(`cloud`))&&(0,N.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400 flex items-center gap-1`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),`Cloud`]})]}),(0,N.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-gray-100 dark:bg-dark-200 text-gray-600 dark:text-gray-400`,children:e},e)),e.pulls&&(0,N.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,N.jsx)(v,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,N.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:o?.percent===void 0?`...`:`${o.percent}%`}),(0,N.jsx)(`button`,{onClick:p,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,N.jsx)(O,{className:`h-4 w-4`})})]}):t?(0,N.jsx)(`button`,{onClick:()=>d(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 hover:bg-green-200 dark:hover:bg-green-900/50`,children:_(`modelSelector.use`)}):n?(0,N.jsxs)(`button`,{onClick:()=>f(e.name),className:`px-3 py-1.5 rounded-lg text-xs font-medium bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-400 hover:bg-primary-200 dark:hover:bg-primary-900/50`,children:[(0,N.jsx)(v,{className:`h-3 w-3 inline mr-1`}),_(`modelSelector.pull`)]}):(0,N.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:_(`modelSelector.adminOnlyPull`)})})]}),r&&o?.percent!==void 0&&(0,N.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${o.percent}%`}})})]},e.name)})})]}),(0,N.jsxs)(`div`,{className:`px-3 py-2 border-t border-gray-200 dark:border-dark-300 flex items-center justify-between flex-shrink-0`,children:[(0,N.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,onMouseDown:e=>e.stopPropagation(),className:`text-xs text-primary-600 dark:text-primary-400 hover:underline flex items-center gap-1`,children:[(0,N.jsx)(x,{className:`h-3 w-3`}),_(`modelManager.huggingface.browseAllLink`)]}),(0,N.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),h()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,N.jsx)(C,{className:c(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var ue=o(`components:model-selector`),F=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:o,disabled:f=!1,compact:m=!1,showImageGen:h=!1,onModelsRefresh:v,getModelValue:y,getModelLabel:x,getModelTitle:S,triggerRef:C,triggerTestId:E,selectTestId:ie,ariaLabel:P})=>{let{t:F}=s(),[I,L]=(0,M.useState)(!1),[R,z]=(0,M.useState)(``),[B,V]=(0,M.useState)(`installed`),de=(0,M.useRef)(null),H=(0,M.useRef)(null),fe=(0,M.useRef)(null),pe=(0,M.useRef)(null),me=a(),{user:he,systemInfo:ge}=ae(),U=he?.role===`admin`||ge?.requiresAuth===!1,[W,_e]=(0,M.useState)(`all`),[ve,ye]=(0,M.useState)(``),[be,xe]=(0,M.useState)(`text-generation`),[Se,Ce]=(0,M.useState)(`downloads`),[we,Te]=(0,M.useState)(``),[Ee,De]=(0,M.useState)(null),[Oe,ke]=(0,M.useState)({}),[Ae,je]=(0,M.useState)(null),[G,K]=(0,M.useState)(null),[Me,q]=(0,M.useState)(null),[Ne,J]=(0,M.useState)(null),Pe=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Fe=[{type:`legacy`,label:F(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:F(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,N.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isUnavailable&&!e.isLegacySelection),color:`gray`},{type:`personas`,label:F(`modelSelector.personas`),icon:(0,N.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPersona&&!e.isUnavailable),color:`purple`},{type:`agents`,label:F(`modelSelector.agentModels`,`Agents`),icon:(0,N.jsx)(b,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isAgent&&!e.isUnavailable),color:`green`},{type:`ollama`,label:F(`modelSelector.ollamaModels`),icon:(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>l(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:F(`modelSelector.pluginModels`),icon:(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isPlugin&&!e.isUnavailable),color:`green`}].filter(e=>e.models.length>0).map(e=>({...e,models:e.models.filter(e=>e.name.toLowerCase().includes(R.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(R.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(R.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>y?.(e)??e.name,Ie=d(e=>e.modelMetadata),X=d(e=>e.personas),Z=e.find(e=>Y(e)===t),Le=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}let r=X[t]??X[n];if(r?.name)return r.name;if(e.personaName&&e.personaName!==t)return e.personaName},Re=e=>{if(!e.name.startsWith(`persona:`))return;let t=e.name.slice(8),n=t;try{n=decodeURIComponent(t)}catch{}return X[t]??X[n]};(0,M.useImperativeHandle)(C,()=>fe.current);let Q=(0,M.useCallback)((e=!0)=>{L(!1),z(``),e&&window.requestAnimationFrame(()=>fe.current?.focus())},[]),{data:ze=[],isLoading:Be,refetch:Ve}=i({queryKey:[`ollama-library-selector`,ve,W===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await j.getLibraryModels({search:ve||void 0,sort:`popular`,category:W===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:I&&B===`ollama`}),{data:He=[],isLoading:Ue,refetch:We}=i({queryKey:[`hf-models-selector`,be,we,Se],queryFn:async()=>{let e=await ne.getModels({task:be,search:we||void 0,sort:Se,limit:30});return e.success&&e.data?e.data:[]},enabled:I&&B===`huggingface`}),Ge=ze.filter(e=>{let t=!R||e.name.toLowerCase().includes(R.toLowerCase())||e.description.toLowerCase().includes(R.toLowerCase()),n=W===`all`||e.category===W;return t&&n}),Ke=(0,M.useCallback)(async e=>{let[t,n]=e.split(`/`);if(t&&n){je(e);try{let r=await ne.getGgufFiles(t,n);r.success&&r.data&&ke(t=>({...t,[e]:r.data}))}catch(e){ue.error(`Failed to load GGUF files:`,e)}finally{je(null)}}},[]),qe=(0,M.useCallback)(e=>{Ee===e?De(null):(De(e),Oe[e]||Ke(e))},[Ee,Oe,Ke]),Je=(0,M.useCallback)((e,t)=>{if(!U){A.error(F(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=j.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),A.success(F(`modelDownload.success`,{name:t})),v?.()},e=>{q(null),K(null),J(null),A.error(F(`modelDownload.failed`,{error:e}))});J(()=>n)}catch{q(null),K(null),A.error(F(`modelDownload.startFailed`))}}},[U,v,G,F]);(0,M.useEffect)(()=>{let e=setTimeout(()=>{B===`huggingface`?Te(R):B===`ollama`&&ye(R)},300);return()=>clearTimeout(e)},[R,B]),(0,M.useEffect)(()=>{if(!I)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Q();return}if(e.key===`Tab`&&H.current){let t=Array.from(H.current.querySelectorAll(`button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1];if(!n||!r)return;e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[Q,I]),(0,M.useEffect)(()=>{I&&pe.current&&pe.current.focus()},[I]);let Ye=async t=>{let r=e.find(e=>Y(e)===t)??e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t),i=r?Y(r):t,a=r?.name??t;Q();try{let e=await j.listRunningModels();if(e.success&&e.data){let t=e.data;t.length>0&&(r?.isPlugin!==!0&&t.some(e=>e.name===a||a.startsWith(`persona:`))||await j.unloadAllModels())}}catch(e){ue.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},Xe=async e=>{if(!U){A.error(F(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=j.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),A.success(F(`modelDownload.success`,{name:e})),v?.()},e=>{q(null),K(null),J(null),A.error(F(`modelDownload.failed`,{error:e}))});J(()=>t)}catch{q(null),K(null),A.error(F(`modelDownload.startFailed`))}}},Ze=()=>{Ne&&(Ne(),J(null),K(null),q(null),A.success(F(`modelDownload.cancelled`)))},Qe=t=>e.some(e=>l(e)&&(e.name===t||e.name.startsWith(t+`:`))),$e=e=>{let t=Ie[u(e)]?.avatar;if(t&&!e.isPersona)return(0,N.jsx)(`img`,{src:t,alt:``,className:`h-4 w-4 shrink-0 rounded-full object-cover`});if(e.isPersona||e.isLegacySelection){let t=Re(e);if(t)return(0,N.jsx)(`img`,{src:re(t,64),alt:``,className:`h-4 w-4 shrink-0 rounded object-cover`})}return e.isLegacySelection?(0,N.jsx)(T,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,N.jsx)(te,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,N.jsx)(k,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,N.jsx)(D,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`})},$=e=>{if(x)return x(e);let t=Ie[u(e)]?.label;return t&&!e.isPersona?t:e.isLegacySelection?`${Le(e)??e.name} (${F(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?Le(e)||e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${F(`modelSelector.unavailable`,`unavailable`)})`:e.name)},et=e=>e.isLegacySelection?e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):F(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${F(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?F(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,N.jsxs)(`div`,{className:c(`relative min-w-0`,o),ref:de,children:[(0,N.jsxs)(`button`,{ref:fe,"data-testid":E,type:`button`,onClick:()=>!f&&L(!I),disabled:f,"aria-haspopup":`dialog`,"aria-expanded":I,"aria-label":P&&Z?`${P}: ${$(Z)}`:P,className:c(m?`flex h-9 w-full min-w-0 items-center justify-between gap-2 px-2.5 text-start`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`rounded-xl border border-line bg-surface-subtle text-sm text-ink hover:bg-hover-solid`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,f?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:m?Z?S?.(Z)??$(Z):F(`modelSelector.selectModel`):void 0,children:[(()=>{if(!Z)return m?(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(D,{className:`h-4 w-4 shrink-0`}),(0,N.jsx)(`span`,{className:`truncate text-xs font-medium text-ink-subtle`,children:F(`modelSelector.selectModel`)})]}):F(`modelSelector.selectModel`);if(m){let e=$(Z);return(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`shrink-0`,children:$e(Z)}),(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`truncate text-xs font-medium text-ink`,children:e})]})}let e=$(Z),t=et(Z);return(0,N.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[$e(Z),(0,N.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,N.jsx)(`span`,{dir:Z.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,N.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),Z.isPersona&&r&&(0,N.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,N.jsx)(T,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,N.jsx)(_,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,N.jsx)(ee,{className:c(m?`h-3 w-3`:`h-4 w-4`,`shrink-0 text-ink-subtle transition-transform duration-150 motion-reduce:transition-none`,I&&`rotate-180`)})]}),I&&(0,oe.createPortal)((0,N.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,N.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Q()}),(0,N.jsxs)(`div`,{ref:H,role:`dialog`,"aria-modal":`true`,"aria-label":F(`modelSelector.selectModel`),className:c(`relative flex w-full max-w-xl flex-col overflow-hidden bg-white/[0.98] dark:bg-dark-25/[0.98]`,`h-[min(620px,88vh)] rounded-[1.5rem] border border-black/[0.08] dark:border-white/[0.09]`,`shadow-[0_30px_100px_rgba(0,0,0,0.28)] backdrop-blur-xl animate-scale-in`),onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,N.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:F(`modelSelector.selectModel`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>Q(),className:`flex h-9 w-9 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-950 dark:text-dark-500 dark:hover:bg-dark-200 dark:hover:text-dark-950`,title:F(`common.close`),children:(0,N.jsx)(O,{className:`h-4 w-4`})})]}),(0,N.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(p,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,N.jsx)(`input`,{ref:pe,type:`text`,placeholder:F(B===`installed`?`modelSelector.searchInstalled`:B===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:R,onChange:e=>z(e.target.value),className:c(`w-full rounded-xl border border-black/[0.07] bg-gray-100/70 py-2.5 ps-10 pe-4 text-sm dark:border-white/[0.07] dark:bg-dark-200/70`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`text-gray-900 dark:text-dark-900 placeholder:text-gray-400 dark:placeholder:text-dark-500`)})]})}),(0,N.jsxs)(`div`,{className:`mx-4 mb-3 flex rounded-xl bg-gray-100/70 p-1 dark:bg-dark-200/70 sm:mx-5`,children:[(0,N.jsxs)(`button`,{onClick:()=>{V(`installed`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,B===`installed`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":B===`installed`,children:[(0,N.jsx)(w,{className:`h-4 w-4 inline me-1.5`}),F(`modelSelector.installed`)]}),(0,N.jsxs)(`button`,{onClick:()=>{V(`ollama`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,B===`ollama`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":B===`ollama`,children:[(0,N.jsx)(g,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,N.jsxs)(`button`,{onClick:()=>{V(`huggingface`)},className:c(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,B===`huggingface`?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),"aria-pressed":B===`huggingface`,children:[(0,N.jsx)(k,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),B===`installed`&&(0,N.jsx)(ce,{filteredGroups:Fe,selectedModel:t,showImageGen:h,getModelValue:Y,getModelIcon:$e,getModelLabel:$,getModelSubLabel:et,onModelSelect:Ye,onOpenGallery:()=>{Q(!1),me(`/gallery`)}}),B===`ollama`&&(0,N.jsx)(le,{libraryCategories:Pe,libraryCategory:W,canInstallModels:U,loadingLibrary:Be,filteredLibraryModels:Ge,pullingModel:G,pullProgress:Me,setLibraryCategory:_e,isModelInstalled:Qe,onModelSelect:Ye,onPullModel:Xe,onCancelPull:Ze,onRefreshLibrary:()=>{Ve()}}),B===`huggingface`&&(0,N.jsx)(se,{hfTask:be,hfSort:Se,canInstallModels:U,loadingHf:Ue,hfModels:He,expandedHfModel:Ee,hfGgufFiles:Oe,loadingGguf:Ae,pullingModel:G,pullProgress:Me,setHfTask:xe,setHfSort:Ce,onToggleHfModel:qe,onPullHfGguf:Je,onCancelPull:Ze,onRefreshHfModels:()=>{We()}})]})]}),document.body),(0,N.jsx)(`select`,{"data-testid":ie,"aria-label":P,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,N.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})},I=o(`hooks:dictation`),L=()=>{if(typeof window>`u`)return;let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition},R=[{mimeType:`audio/webm;codecs=opus`,format:`webm`}],z=300,B=.25,V=e=>`${encodeURIComponent(e.plugin)}:${encodeURIComponent(e.model)}`;function de(e){if(typeof MediaRecorder>`u`)return;let t=new Set((e.config?.formats||[]).map(e=>e.toLowerCase()));return R.find(e=>(t.size===0||t.has(e.format))&&(typeof MediaRecorder.isTypeSupported!=`function`||MediaRecorder.isTypeSupported(e.mimeType)))?.mimeType}function H({onStart:e,onText:t,ownerKey:n}){let{t:r,i18n:i}=s(),[a,o]=(0,M.useState)(`idle`),[c,l]=(0,M.useState)([]),u=(0,M.useRef)(null),d=(0,M.useRef)(null),f=(0,M.useRef)(null),p=(0,M.useRef)(null),m=(0,M.useRef)(null),h=(0,M.useRef)(0),g=(0,M.useRef)(`idle`),_=(0,M.useRef)(void 0),v=(0,M.useRef)(e),y=(0,M.useRef)(t);(0,M.useEffect)(()=>{v.current=e,y.current=t},[e,t]),(0,M.useEffect)(()=>{let e=!1;return ie.getModels().then(t=>{!e&&t.success&&t.data&&l(t.data)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let b=(0,M.useMemo)(()=>typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices&&!!L(),[]),x=typeof window<`u`&&window.isSecureContext&&typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia,S=(0,M.useMemo)(()=>[...b?[{key:`browser`,kind:`browser`}]:[],...x?c.filter(e=>!!de(e)).map(e=>({key:V(e),kind:`provider`,model:e})):[]],[b,x,c]),[C,ee]=(0,M.useState)(``),w=(0,M.useMemo)(()=>S.find(e=>e.key===C)??S[0],[C,S]),T=w?.kind===`provider`?w.model:void 0,te=S.length>0,E=(0,M.useCallback)(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),D=(0,M.useCallback)(e=>{g.current=e,o(e)},[]),O=(0,M.useCallback)(()=>{h.current+=1,E(),u.current?.stop(),u.current=null,p.current?.abort(),p.current=null;let e=d.current;d.current=null,e&&(e.ondataavailable=null,e.onerror=null,e.onstop=null,e.state===`recording`&&e.stop()),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,D(`idle`)},[E,D]);return(0,M.useEffect)(()=>(_.current=n,O),[O,n]),{supported:te,phase:a,toggle:(0,M.useCallback)(async()=>{let e=g.current;if(e===`starting`||e===`transcribing`){O();return}if(e===`recording`){d.current?.state===`recording`?(D(`transcribing`),d.current.stop()):O();return}if(T){let e=h.current+1;h.current=e;let t=_.current;v.current(),D(`starting`);try{let n=await navigator.mediaDevices.getUserMedia({audio:!0});if(h.current!==e||_.current!==t){n.getTracks().forEach(e=>e.stop());return}f.current=n;let a=de(T),o=a?new MediaRecorder(n,{mimeType:a}):new MediaRecorder(n),s=[];o.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},o.onerror=()=>{n.getTracks().forEach(e=>e.stop()),E(),h.current===e&&(d.current=null,f.current=null,D(`idle`),A.error(r(`voiceMode.transcriptionFailed`)))},o.onstop=()=>{if(n.getTracks().forEach(e=>e.stop()),E(),h.current!==e||_.current!==t)return;if(d.current=null,f.current=null,s.length===0){D(`idle`);return}let a=new Blob(s,{type:o.mimeType||s[0].type||`audio/webm`}),c=new AbortController;p.current=c,D(`transcribing`),ie.transcribe(a,T,{language:i.language,signal:c.signal,fallbackMessage:r(`voiceMode.transcriptionFailed`)}).then(n=>{h.current!==e||_.current!==t||c.signal.aborted||y.current(n.text.trim())}).catch(e=>{c.signal.aborted||(I.error(`Provider transcription failed:`,e),A.error(e instanceof Error?e.message:r(`voiceMode.transcriptionFailed`)))}).finally(()=>{p.current===c&&h.current===e&&(p.current=null,D(`idle`))})},d.current=o,o.start(250);let c=T.config?.max_duration_seconds,l=typeof c==`number`&&c>0?Math.min(c,z):z;m.current=window.setTimeout(()=>{h.current===e&&o.state===`recording`&&o.stop()},Math.max(.1,l-B)*1e3),D(`recording`);return}catch(t){if(h.current!==e)return;I.error(`Failed to start provider dictation:`,t),E(),f.current?.getTracks().forEach(e=>e.stop()),f.current=null,d.current=null,D(`idle`),A.error(r(`voiceMode.transcriptionFailed`));return}}let t=L();if(!t)return;let n=h.current+1;h.current=n;let a=_.current,o=new t;o.lang=i.language,o.continuous=!0,o.interimResults=!0,v.current(),o.onresult=e=>{if(h.current!==n||_.current!==a||u.current!==o)return;let t=``;for(let n=0;n<e.results.length;n++)t+=e.results[n][0]?.transcript??``;y.current(t.trim())},o.onend=()=>{h.current===n&&(u.current=null,D(`idle`))},o.onerror=()=>{h.current===n&&(u.current=null,D(`idle`))},u.current=o,D(`recording`);try{o.start()}catch(e){I.error(`Failed to start dictation:`,e),u.current=null,D(`idle`)}},[O,E,i.language,T,D,r]),cancel:O,sources:S,activeSourceKey:w?.key??``,setSourceKey:ee,providerModel:T}}export{F as n,H as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./config-
|
|
1
|
+
import{t as e}from"./config-D6Kcp5n3.js";import{t}from"./client-BeJbHHWx.js";var n=new Set([`snapshot`,`run_state`,`reasoning_delta`,`assistant_delta`,`tool_call`,`tool_result`,`approval`,`usage`,`skill_loaded`,`error`,`done`]),r=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,i=e=>{if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`){let t=Number(e);if(Number.isFinite(t))return t;let n=Date.parse(e);if(Number.isFinite(n))return n}return Date.now()},a=(e,t,a,o,s)=>{let c=r(e);if(!c)return;let l=Number(c.id??t),u=String(c.type??a??``),d=String(c.taskId??o),f=String(c.runId??s);if(!Number.isSafeInteger(l)||l<0||!n.has(u)||d!==o||f!==s)return;let p=c.data;return{id:l,type:u,taskId:d,runId:f,timestamp:i(c.timestamp),data:r(p)||(p===void 0?{}:{content:p})}},o=(e,t,n)=>{let r,i,o=[];for(let t of e.split(`
|
|
2
2
|
`)){if(!t||t.startsWith(`:`))continue;let e=t.indexOf(`:`),n=e===-1?t:t.slice(0,e),a=e===-1?``:t.slice(e+1),s=a.startsWith(` `)?a.slice(1):a;n===`id`&&(r=s),n===`event`&&(i=s),n===`data`&&o.push(s)}if(o.length===0)return;let s=o.join(`
|
|
3
3
|
`);if(s===`[DONE]`)return a({id:r,type:`done`,taskId:t,runId:n,timestamp:Date.now(),data:{}},r,i,t,n);try{return a(JSON.parse(s),r,i,t,n)}catch{return}},s=class{taskId;runId;onEvent;buffer=``;constructor(e,t,n){this.taskId=e,this.runId=t,this.onEvent=n}push(e){e&&(this.buffer+=e,this.drain())}finish(e=``){if(this.buffer+=e,this.drain(),!this.buffer.trim()){this.buffer=``;return}let t=o(this.buffer.replace(/\r\n?/g,`
|
|
4
4
|
`),this.taskId,this.runId);this.buffer=``,t&&this.onEvent(t)}drain(){let e=/\r?\n\r?\n/.exec(this.buffer);for(;e?.index!==void 0;){let t=this.buffer.slice(0,e.index).replace(/\r\n?/g,`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./workApi-C5InfT8x.js";export{e as workApi};
|
package/package.json
CHANGED