libre-webui 0.19.0 → 0.19.1

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.
Files changed (33) hide show
  1. package/backend/package.json +1 -1
  2. package/frontend/dist/assets/{index-_lG_lwU-.js → index-BA116EVY.js} +8 -161
  3. package/frontend/dist/index.html +7 -7
  4. package/frontend/dist/js/{ArtifactContainer-CjpvtR8G.js → ArtifactContainer-CBTr5mSK.js} +1 -1
  5. package/frontend/dist/js/{ArtifactDemoPage-yrPXLBQo.js → ArtifactDemoPage-0BLd-m3N.js} +1 -1
  6. package/frontend/dist/js/{ArtifactSlideOutPanel-DdsL2AOQ.js → ArtifactSlideOutPanel-DjGIUKtP.js} +1 -1
  7. package/frontend/dist/js/{ChatPage-D9lWGM8g.js → ChatPage-BgLadsgU.js} +1 -1
  8. package/frontend/dist/js/{FirstTimeSetup-CwLPbHkI.js → FirstTimeSetup-CZKfjAkx.js} +1 -1
  9. package/frontend/dist/js/{GalleryPage-C9DTdo_-.js → GalleryPage-DH-KEeIZ.js} +1 -1
  10. package/frontend/dist/js/{HomePage-iF44c34e.js → HomePage-C4TJCwU6.js} +1 -1
  11. package/frontend/dist/js/{LibreClawPage-B9wWZIz6.js → LibreClawPage-B_eC8oQo.js} +1 -1
  12. package/frontend/dist/js/{ModelSelector-B0RKEJwC.js → ModelSelector-DwhKmtQx.js} +1 -1
  13. package/frontend/dist/js/{ModelsPage-DJXoIOs8.js → ModelsPage-DQm2DgF3.js} +1 -1
  14. package/frontend/dist/js/{NotesPage-BTNH6JR2.js → NotesPage-pNuo3BZp.js} +1 -1
  15. package/frontend/dist/js/{PersonasPage--nqoJ-wA.js → PersonasPage-DpHCAyoD.js} +1 -1
  16. package/frontend/dist/js/{PluginUsagePage-BHwm-BBr.js → PluginUsagePage-Cd5MJbLi.js} +1 -1
  17. package/frontend/dist/js/{RichMessageContent-DYRrXJ75.js → RichMessageContent-B1bidjA8.js} +1 -1
  18. package/frontend/dist/js/{SettingsModal-y1Nzg55O.js → SettingsModal-ZbZKdZcC.js} +1 -1
  19. package/frontend/dist/js/{SystemPage-CHez8h3p.js → SystemPage-CUfqMR-l.js} +1 -1
  20. package/frontend/dist/js/{UserManagementPage-aJhKXQxG.js → UserManagementPage-5ZGnsxNF.js} +1 -1
  21. package/frontend/dist/js/{WorkPage-Ccla0MDm.js → WorkPage-ShAy19E2.js} +3 -3
  22. package/frontend/dist/js/{api-DVP8xiYT.js → api-CI1Inz7g.js} +2 -2
  23. package/frontend/dist/js/{appStore-Cw7PmG-J.js → appStore-wGpPGj47.js} +2 -2
  24. package/frontend/dist/js/{authStore-gv_MgDKr.js → authStore-D-d7UIpv.js} +1 -1
  25. package/frontend/dist/js/{chatStore-DmDbolTg.js → chatStore-BaX22w_g.js} +2 -2
  26. package/frontend/dist/js/{estree-DJwQLE88.js → estree-vPoIgYRx.js} +1 -1
  27. package/frontend/dist/js/{html-DdAOfeK4.js → html-_taODyXh.js} +1 -1
  28. package/frontend/dist/js/{markdown-RaVsONor.js → markdown-CLKggXc3.js} +1 -1
  29. package/frontend/dist/js/{messageCodeStyles-cTX0rQGK.js → messageCodeStyles-B0BoOSOR.js} +1 -1
  30. package/frontend/dist/js/{standalone-B_aPlu7o.js → standalone-53qXRmN5.js} +1 -1
  31. package/frontend/dist/js/{typescript-Dz4OUZSl.js → typescript-C6-ED_Fw.js} +1 -1
  32. package/frontend/dist/js/{ui-DDlcz2oy.js → ui-BXTx1csA.js} +2 -2
  33. package/package.json +1 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{n as r}from"./i18next-DgmgtwsV.js";import{a as i,c as a,d as o,l as s,n as c,r as l,s as u,t as d,u as f}from"./useTranslation-CdeLZqSW.js";import{Bt as p,Ct as m,R as h,Sn as g,Tn as _,V as v,W as y,Xt as b,hn as x,k as S,ln as C,m as w,n as ee,on as T,st as te,v as E,x as D}from"./ui-vendor-D_pYT79f.js";import{t as O}from"./logger-DSXjF4ye.js";import{h as k}from"./api-DVP8xiYT.js";import{t as A}from"./utils-BhpNrGnR.js";import{t as j}from"./Button-X9TT9gTD.js";import{n as ne,t as M}from"./ui-DDlcz2oy.js";var N={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},re=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function P(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(N[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(re),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var F=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,I=/<\/?([^\s]+?)[/\s>]/,ie=/^\s*$/,ae=/^(script|style)$/i,L=`\0`,oe=Object.create(null);function se(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(L).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(L).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(L)>-1&&(e.attrs[t]=n.split(L).join(`<`))}e.children.length&&se(e.children)})}function ce(e,t){let n=t&&t.components||oe,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;F.lastIndex=0;let o;for(;o=F.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(I);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=L,a=o.index+1,F.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=F.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=P(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=P(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&ae.test(s.name)){t=!0,d||(d=e.toLowerCase());let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);ie.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&se(a),a}function le(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`&quot;`)+`"`);return t.length?` `+t.join(` `):``}function ue(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?le(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(ue,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function de(e){return e.reduce(function(e,t){return e+ue(``,t)},``)}var R={parse:ce,stringify:de},z=e(n()),B=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},V=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?H(t):t},fe=e=>Array.isArray(e)&&e.every(z.isValidElement),H=e=>Array.isArray(e)?e:[e],pe=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},me=e=>{let t={};if(!e)return t;let n=e=>{H(e).forEach(e=>{s(e)||(B(e)?n(V(e)):a(e)&&!(0,z.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},U=(e,t,n,r)=>{if(!e)return``;let i=``,o=H(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return o.forEach((e,o)=>{if(s(e)){i+=`${e}`;return}if((0,z.isValidElement)(e)){let{props:a,type:l}=e,u=Object.keys(a).length,d=c.indexOf(l)>-1,f=a.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||a.i18nIsDynamicList){i+=`<${o}></${o}>`;return}if(d&&u<=1){let e=s(f)?f:U(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=U(f,t,n,r);i+=`<${o}>${p}</${o}>`;return}if(e===null){f(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(a(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}f(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}f(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},W=(e,t,n,r,o,c,l)=>{if(n===``)return[];let d=o.transKeepBasicHtmlNodesFor||[],f=n&&new RegExp(d.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!f&&!l)return[n];let p=t??{},m=e=>{H(e).forEach(e=>{s(e)||(B(e)?m(V(e)):a(e)&&!(0,z.isValidElement)(e)&&Object.assign(p,e))})};m(e);let h=Object.keys(p),g=R.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||d.indexOf(e)>-1||h.indexOf(e)>-1}),_={...p,...c},v=(e,t,n)=>{let r=V(e),i=b(r,t.children,n);return fe(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,z.cloneElement)(e,{key:r},i?void 0:t))):n.push(...z.Children.map([e],e=>{if(e.type===z.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`children`&&t!==`i18nIsDynamicList`&&(n[t]=e.props[t])}),(0,z.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`ref`&&t!==`children`&&(n[t]=e.props[t])}),(0,z.cloneElement)(e,n,i?null:t)}))},b=(e,n,c)=>{let p=H(e),m=H(n),h={};return m.reduce((e,n,m)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let i=p[parseInt(n.name,10)];!i&&t&&(i=t[n.name]),c.length===1&&!i&&(i=c[0][n.name]),i||(i={});let x={...n.attrs};l&&Object.keys(x).forEach(e=>{let t=x[e];s(t)&&(x[e]=u(t))});let S=Object.keys(x).length===0?i:pe({props:x},i),C=(0,z.isValidElement)(S),w=C&&B(n,!0)&&!n.voidElement,ee=f&&a(S)&&S.dummy&&!C,T=a(t)&&Object.hasOwnProperty.call(t,n.name);if(s(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(B(S)||w){let t=v(S,n,c);y(S,t,e,m)}else if(ee){let t=b(p,n.children,c);y(S,t,e,m)}else if(Number.isNaN(parseFloat(n.name)))if(T){let t=v(S,n,c);y(S,t,e,m,n.voidElement)}else if(o.transSupportBasicHtmlNodes&&d.indexOf(n.name)>-1)if(n.voidElement)e.push((0,z.createElement)(n.name,{key:`${n.name}-${m}`}));else{let t=h[n.name]||0;h[n.name]=t+1;let r,i=0;for(let e=0;e<p.length;e+=1){let a=p[e];if((0,z.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?H(V(r)):p,o=b(a,n.children,c);e.push((0,z.createElement)(n.name,{key:`${n.name}-${m}`},o))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(p,n.children,c);e.push(`<${n.name}>${t}</${n.name}>`)}else if(a(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,m,n.children.length!==1||!g)}else if(n.type===`text`){let t=o.transWrapTextNodes,a=typeof o.unescape==`function`?o.unescape:i().unescape,s=l?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,z.createElement)(t,{key:`${n.name}-${m}`},s)):e.push(s)}return e},[])};return V(b([{dummy:!0,children:e||[]}],g,H(e||[]))[0])},G=(e,t,n)=>{let r=e.key||t,i=(0,z.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,z.createElement)(z.Fragment,null,i)}return(0,z.createElement)(a,{key:r})},he=(e,t)=>e.map((e,n)=>G(e,n,t)),ge=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:G(e[r],r,t)})}),n},_e=(e,t,n,r)=>e?Array.isArray(e)?he(e,t):a(e)?ge(e,t):(o(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,ve=e=>!a(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function ye({children:e,count:t,parent:n,i18nKey:a,context:c,tOptions:u={},values:d,defaults:f,components:p,ns:m,i18n:h,t:g,shouldUnescape:_,...v}){let y=h||l();if(!y)return o(y,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:a}),e;let b=g||y.t.bind(y)||(e=>e),x={...i(),...y.options?.react},S=m||b.ns||y.options?.defaultNS;S=s(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...u}:u,ee=_??C?.shouldUnescape,T=C?.values?{...C.values,...d}:d,te=C?.components?{...C.components,...p}:p,E=U(e,x,y,a),D=f||w?.defaultValue||E||x.transEmptyNodeValue||(typeof a==`function`?r(a):a),{hashTransKey:O}=x,k=a||(O?O(E||D):E||D);d=y.options?.interpolation?.defaultVariables?T&&Object.keys(T).length>0?{...T,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables}:T;let A=me(e);A&&typeof A.count==`number`&&t===void 0&&(t=A.count);let j=d||t!==void 0&&!y.options?.interpolation?.alwaysFormat||!e?w.interpolation:{interpolation:{...w.interpolation,prefix:`#$?`,suffix:`?$#`}},ne={...w,context:c||w.context,count:t,...d,...j,defaultValue:D,ns:S},M=k?b(k,ne):D;M===k&&D&&(M=D);let N=_e(te,M,y,a),re=N||e,P=null;ve(N)&&(P=N,re=e);let F=W(re,P,M,y,x,ne,ee),I=n??x.defaultTransParent;return I?(0,z.createElement)(I,v,F):F}function be({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:u,ns:d,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,z.useContext)(c)||{},v=f||g||l(),y=p||v?.t.bind(v);return ye({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:u,ns:d||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}var K=t(),q=O(`pages:libre-claw`),xe={queued:`bg-gray-100 text-gray-700 dark:bg-dark-200 dark:text-dark-700`,running:`bg-primary-100 text-primary-700 dark:bg-primary-900/25 dark:text-primary-300`,blocked:`bg-amber-500/20 text-ink dark:bg-amber-900/30`,done:`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`,failed:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300`,cancelled:`bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300`},Se={assistant_message:`text-primary-600 dark:text-primary-300`,assistant_delta:`text-primary-600 dark:text-primary-300`,user_message:`text-gray-700 dark:text-dark-700`,permission_request:`text-ink`,permission_response:`text-gray-600 dark:text-dark-600`,tool_call:`text-gray-600 dark:text-dark-600`,tool_result:`text-gray-600 dark:text-dark-600`,usage:`text-gray-600 dark:text-dark-600`,error:`text-red-600 dark:text-red-300`,run_finished:`text-emerald-600 dark:text-emerald-300`},Ce=[[`lobster`,`Lobster`],[`lobster-light`,`Lobster Light`],[`github-dark`,`GitHub Dark`],[`github-light`,`GitHub Light`],[`monokai-pro`,`Monokai Pro`],[`night-owl`,`Night Owl`],[`tokyo-night`,`Tokyo Night`],[`ayu`,`Ayu`],[`dracula`,`Dracula`],[`catppuccin-mocha`,`Catppuccin Mocha`],[`catppuccin-latte`,`Catppuccin Latte`],[`gruvbox-dark`,`Gruvbox Dark`],[`nord`,`Nord`],[`solarized-dark`,`Solarized Dark`],[`solarized-light`,`Solarized Light`],[`one-dark-pro`,`One Dark Pro`],[`rose-pine`,`Rose Pine`],[`kanagawa`,`Kanagawa`],[`matrix`,`Matrix`]],we=()=>{let{t:e}=d(),[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)([]),[l,u]=(0,z.useState)(null),[f,O]=(0,z.useState)(null),[N,re]=(0,z.useState)(``),[P,F]=(0,z.useState)(null),[I,ie]=(0,z.useState)(!0),[ae,L]=(0,z.useState)(!1),[oe,se]=(0,z.useState)(!1),[ce,le]=(0,z.useState)(!1),[ue,de]=(0,z.useState)(!1),[R,B]=(0,z.useState)(``),[V,fe]=(0,z.useState)(`chat`),[H,pe]=(0,z.useState)(``),[me,U]=(0,z.useState)(``),[W,G]=(0,z.useState)(``),[he,ge]=(0,z.useState)(``),[_e,ve]=(0,z.useState)(!1),[ye,xe]=(0,z.useState)(`lobster`),[Se,we]=(0,z.useState)(!0),[ke,Ae]=(0,z.useState)(``),[je,Y]=(0,z.useState)(``),[X,Fe]=(0,z.useState)(``),[Ie,Le]=(0,z.useState)(`report`),Z=(0,z.useMemo)(()=>r.find(e=>e.run_id===P)||null,[r,P]),Q=(0,z.useMemo)(()=>{let e=new Set(a.filter(e=>e.type===`permission_response`).map(e=>String(e.data.tool_call_id||``)));return a.filter(t=>{if(t.type!==`permission_request`)return!1;let n=String(t.data.tool_call_id||``);return n&&!e.has(n)})},[a]),Re=(0,z.useMemo)(()=>Pe(a,e),[a,e]),$=(0,z.useCallback)(async()=>{try{let[e,t,r,a,o,s]=await Promise.all([k.status(),k.listRuns(30),k.currentModel(),k.currentFallback(),k.usage(``,100),k.listAutomations(50)]);e.success&&e.data&&n(e.data),t.success&&t.data&&(i(t.data.runs),F(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(u(r.data),G(String(r.data.provider||``)),ge(String(r.data.model||``))),a.success&&a.data&&O(a.data),o.success&&o.data&&re(String(o.data.text||``)),s.success&&s.data&&c(s.data.automations)}catch(t){q.error(`Failed to load Libre Claw overview:`,t),_.error(e(`libreClaw.toasts.loadStatusFailed`))}finally{ie(!1)}},[e]),ze=(0,z.useCallback)(async(e,t=!1)=>{let n=t?0:a.length>0&&a[a.length-1]?.event_id||0;try{let r=await k.getEvents(e,n);r.success&&r.data&&o(e=>t?r.data?.events||[]:[...e,...r.data?.events||[]])}catch(e){q.error(`Failed to load Libre Claw events:`,e)}},[a]);(0,z.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,z.useEffect)(()=>{if(!P){let e=window.setTimeout(()=>{o([])},0);return()=>window.clearTimeout(e)}let e=P;k.getEvents(e,0).then(e=>{e.success&&e.data&&o(e.data.events)}).catch(e=>{q.error(`Failed to load Libre Claw events:`,e)})},[P]),(0,z.useEffect)(()=>{if(!P||!Z||![`queued`,`running`,`blocked`].includes(Z.state))return;let e=window.setInterval(()=>{ze(P),k.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[ze,Z,P]);let Be=async()=>{if(!R.trim()){_.error(e(`libreClaw.toasts.enterTask`));return}L(!0);try{let t=await k.startRun({message:R,kind:V,provider:H||void 0,model:me||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),F(n.run_id),B(``),_.success(e(`libreClaw.toasts.runStarted`))}else _.error(t.error||e(`libreClaw.toasts.startRunFailed`))}catch(t){q.error(`Failed to start Libre Claw run:`,t),_.error(e(`libreClaw.toasts.startRunFailed`))}finally{L(!1)}},Ve=async t=>{try{await k.cancelRun(t),await $(),_.success(e(`libreClaw.toasts.runCancelled`))}catch(t){q.error(`Failed to cancel Libre Claw run:`,t),_.error(e(`libreClaw.toasts.cancelRunFailed`))}},He=async(t,n)=>{if(!P)return;let r=String(t.data.tool_call_id||``);if(r)try{await k.resolvePermission(P,r,n),await ze(P,!0),_.success(e(n===`deny`?`libreClaw.toasts.denied`:`libreClaw.toasts.approved`))}catch(t){q.error(`Failed to resolve Libre Claw permission:`,t),_.error(e(`libreClaw.toasts.resolvePermissionFailed`))}},Ue=async()=>{if(!W.trim()||!he.trim()){_.error(e(`libreClaw.toasts.providerModelRequired`));return}se(!0);try{let t=await k.updateModel(W,he,_e);t.success&&t.data?(u(t.data),_.success(e(`libreClaw.toasts.modelUpdated`))):_.error(t.error||e(`libreClaw.toasts.updateModelFailed`))}catch(t){q.error(`Failed to update Libre Claw model:`,t),_.error(e(`libreClaw.toasts.updateModelFailed`))}finally{se(!1)}},We=async()=>{le(!0);try{let t=await k.updateTheme(ye,Se);t.success?_.success(e(`libreClaw.toasts.themeUpdated`)):_.error(t.error||e(`libreClaw.toasts.updateThemeFailed`))}catch(t){q.error(`Failed to update Libre Claw theme:`,t),_.error(e(`libreClaw.toasts.updateThemeFailed`))}finally{le(!1)}},Ge=async()=>{if(!ke.trim()||!je.trim()||!X.trim()){_.error(e(`libreClaw.toasts.automationRequired`));return}de(!0);try{let t=await k.createAutomation({name:ke,schedule:je,prompt:X,route:Ie});t.success?(Ae(``),Y(``),Fe(``),await $(),_.success(e(`libreClaw.toasts.automationCreated`))):_.error(t.error||e(`libreClaw.toasts.createAutomationFailed`))}catch(t){q.error(`Failed to create Libre Claw automation:`,t),_.error(e(`libreClaw.toasts.createAutomationFailed`))}finally{de(!1)}},Ke=async(t,n)=>{try{n===`pause`&&await k.pauseAutomation(t),n===`resume`&&await k.resumeAutomation(t),n===`run`&&await k.runAutomationNow(t),n===`delete`&&await k.deleteAutomation(t),await $(),_.success(e(`libreClaw.toasts.automationUpdated`))}catch(t){q.error(`Failed to update Libre Claw automation:`,t),_.error(e(`libreClaw.toasts.updateAutomationFailed`))}};return(0,K.jsxs)(ne,{width:`wide`,contentClassName:`space-y-6`,children:[(0,K.jsx)(M,{className:`mb-0`,title:e(`libreClaw.title`),description:e(`libreClaw.subtitle`),actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Te,{status:t,t:e}),(0,K.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:$,children:[(0,K.jsx)(h,{className:`h-4 w-4`}),e(`common.refresh`)]}),(0,K.jsxs)(`a`,{href:t?.dashboardUrl||`http://127.0.0.1:8766/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-xl border border-gray-200/80 bg-white/70 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-white dark:border-white/10 dark:bg-white/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.08]`,children:[(0,K.jsx)(p,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})}),!t?.connected&&!I&&(0,K.jsx)(`section`,{className:`rounded-xl border border-amber-200 bg-amber-500/10 p-4 text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(E,{className:`mt-0.5 h-5 w-5 shrink-0 text-amber-500`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`font-semibold`,children:e(`libreClaw.connection.disconnectedTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm opacity-90`,children:(0,K.jsx)(be,{i18nKey:`libreClaw.connection.disconnectedDescription`,components:{command:(0,K.jsx)(`code`,{}),env:(0,K.jsx)(`code`,{})}})}),t?.error&&(0,K.jsx)(`p`,{className:`mt-2 text-xs opacity-80`,children:t.error})]})]})}),(0,K.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.startRun.title`),icon:(0,K.jsx)(v,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`textarea`,{value:R,onChange:e=>B(e.target.value),placeholder:e(`libreClaw.startRun.placeholder`),className:`min-h-32 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-100 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800 dark:focus:border-primary-500 dark:focus:ring-primary-900/30`}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,K.jsxs)(`select`,{value:V,onChange:e=>fe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`chat`,children:e(`libreClaw.startRun.chatRun`)}),(0,K.jsx)(`option`,{value:`goal`,children:e(`libreClaw.startRun.goalMode`)})]}),(0,K.jsx)(`input`,{value:H,onChange:e=>pe(e.target.value),placeholder:e(`libreClaw.startRun.providerOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:me,onChange:e=>U(e.target.value),placeholder:e(`libreClaw.startRun.modelOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(j,{onClick:Be,loading:ae,children:[(0,K.jsx)(x,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,K.jsx)(m,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,K.jsx)(`input`,{value:W,onChange:e=>G(e.target.value),placeholder:e(`libreClaw.modelRoute.providerPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:e(`libreClaw.modelRoute.modelPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>ve(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]}),(0,K.jsx)(j,{variant:`secondary`,onClick:Ue,loading:oe,children:e(`libreClaw.modelRoute.saveModel`)}),(0,K.jsxs)(`div`,{className:`border-t border-gray-100 pt-3 dark:border-dark-200`,children:[(0,K.jsx)(`label`,{className:`mb-1 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-500`,children:e(`libreClaw.modelRoute.theme`)}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-1`,children:[(0,K.jsx)(`select`,{value:ye,onChange:e=>xe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:Ce.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsx)(j,{variant:`secondary`,onClick:We,loading:ce,children:e(`libreClaw.modelRoute.saveTheme`)})]}),(0,K.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Se,onChange:e=>we(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]})]}),l&&(0,K.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(l,null,2)})]})})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.runs.title`),icon:(0,K.jsx)(g,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[r.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.runs.empty`)}),r.map(t=>(0,K.jsxs)(`button`,{onClick:()=>F(t.run_id),className:A(`w-full rounded-xl border p-3 text-start transition`,P===t.run_id?`border-primary-300 bg-primary-50 dark:border-primary-700 dark:bg-primary-900/20`:`border-gray-200 bg-white hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:hover:bg-dark-100`),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,K.jsx)(Ee,{state:t.state,t:e})]}),(0,K.jsxs)(`div`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-dark-500`,children:[t.provider,`:`,t.model]}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:Ne(t.updated_at)})]},t.run_id))]})}),(0,K.jsxs)(J,{title:Z?Z.title:e(`libreClaw.timeline.title`),icon:(0,K.jsx)(b,{className:`h-4 w-4`}),actions:Z&&[`queued`,`running`,`blocked`].includes(Z.state)?(0,K.jsxs)(j,{variant:`danger`,size:`sm`,onClick:()=>Ve(Z.run_id),children:[(0,K.jsx)(D,{className:`h-4 w-4`}),e(`common.cancel`)]}):null,children:[Q.length>0&&(0,K.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-xl border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-800 dark:bg-amber-900/20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,K.jsx)(S,{className:`h-4 w-4 text-amber-500`}),e(`libreClaw.approvals.needed`)]}),Q.map(t=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-white/70 p-3 dark:bg-dark-50/70`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(t.data.name||e(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto rounded bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(t.data.arguments||{},null,2)}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,K.jsxs)(j,{size:`sm`,onClick:()=>He(t,`allow_once`),children:[(0,K.jsx)(T,{className:`h-4 w-4`}),e(`libreClaw.approvals.allowOnce`)]}),(0,K.jsx)(j,{size:`sm`,variant:`secondary`,onClick:()=>He(t,`always_allow_tool`),children:e(`libreClaw.approvals.alwaysAllowTool`)}),(0,K.jsxs)(j,{size:`sm`,variant:`danger`,onClick:()=>He(t,`deny`),children:[(0,K.jsx)(ee,{className:`h-4 w-4`}),e(`libreClaw.approvals.deny`)]})]})]},t.event_id))]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[a.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.timeline.empty`)}),Re.map(t=>(0,K.jsx)(Oe,{item:t,t:e},t.key))]})]})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,K.jsx)(J,{title:e(`libreClaw.automations.title`),icon:(0,K.jsx)(C,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`libreClaw.automations.namePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:je,onChange:e=>Y(e.target.value),placeholder:e(`libreClaw.automations.schedulePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`select`,{value:Ie,onChange:e=>Le(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`report`,children:e(`libreClaw.automations.routes.report`)}),(0,K.jsx)(`option`,{value:`telegram`,children:e(`libreClaw.automations.routes.telegram`)})]}),(0,K.jsx)(j,{onClick:Ge,loading:ue,children:e(`libreClaw.automations.create`)})]}),(0,K.jsx)(`textarea`,{value:X,onChange:e=>Fe(e.target.value),placeholder:e(`libreClaw.automations.promptPlaceholder`),className:`min-h-24 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[s.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.automations.empty`)}),s.map(t=>(0,K.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-3 dark:border-dark-300 dark:bg-dark-50`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.name}),(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[t.schedule,` ·`,` `,e(`libreClaw.automations.routes.${t.route}`,{defaultValue:t.route}),` `,`·`,` `,e(`libreClaw.automations.status.${t.status}`,{defaultValue:t.status})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,K.jsx)(De,{title:e(`libreClaw.automations.runNow`),onClick:()=>Ke(t.automation_id,`run`),children:(0,K.jsx)(v,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:t.status===`paused`?e(`libreClaw.automations.resume`):e(`libreClaw.automations.pause`),onClick:()=>Ke(t.automation_id,t.status===`paused`?`resume`:`pause`),children:t.status===`paused`?(0,K.jsx)(v,{className:`h-4 w-4`}):(0,K.jsx)(y,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:e(`common.delete`),danger:!0,onClick:()=>Ke(t.automation_id,`delete`),children:(0,K.jsx)(w,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,K.jsx)(g,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.usage`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:N||e(`libreClaw.usageFallback.noUsage`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.fallbackRoute`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(f||{},null,2)})]})]})})]}),I&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-white/60 backdrop-blur-sm dark:bg-dark-50/60`,children:(0,K.jsx)(te,{className:`h-7 w-7 animate-spin text-primary-600`})})]})},Te=({status:e,t})=>{let n=!!e?.connected;return(0,K.jsxs)(`span`,{className:A(`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium`,n?`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`:`bg-amber-500/20 text-ink dark:bg-amber-900/30`),children:[(0,K.jsx)(`span`,{className:A(`h-2 w-2 rounded-full`,n?`bg-emerald-500`:`bg-amber-500`)}),t(n?`libreClaw.status.connected`:`libreClaw.status.disconnected`),e?.health?.active_runs!==void 0&&(0,K.jsxs)(`span`,{className:`opacity-70`,children:[`·`,` `,t(`libreClaw.status.activeRuns`,{count:e.health.active_runs})]})]})},Ee=({state:e,t})=>(0,K.jsx)(`span`,{className:A(`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,xe[e]||xe.queued),children:t(`libreClaw.states.${e}`,{defaultValue:e})}),J=({title:e,icon:t,actions:n,children:r})=>(0,K.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/60 dark:border-white/10 dark:bg-white/[0.03]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-5 py-4 dark:border-white/[0.08]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:[(0,K.jsx)(`span`,{className:`text-primary-600 dark:text-primary-300`,children:t}),e]}),n]}),(0,K.jsx)(`div`,{className:`p-5`,children:r})]}),De=({title:e,danger:t,onClick:n,children:r})=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:n,className:A(`inline-flex h-8 w-8 items-center justify-center rounded-lg transition-colors`,t?`text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`:`text-gray-500 hover:bg-gray-100 dark:text-dark-500 dark:hover:bg-dark-200`),children:r}),Oe=({item:e,t})=>(0,K.jsxs)(`article`,{className:A(`rounded-xl border p-3 transition-colors`,e.eventType===`assistant_message`?`border-primary-200 bg-primary-50/60 dark:border-primary-900/60 dark:bg-primary-900/10`:(e.eventType,`border-gray-200/80 bg-white/50 dark:border-white/[0.08] dark:bg-white/[0.025]`)),children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:A(`text-xs font-semibold uppercase tracking-wide`,Se[e.eventType]||`text-gray-500 dark:text-dark-500`),children:e.label}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-400 dark:text-dark-500`,children:[Le(e),` · `,Ne(e.timestamp)]})]}),(0,K.jsx)(ke,{item:e,t})]}),ke=({item:e,t})=>{if(e.kind===`assistant_message`)return(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-gray-900 dark:text-dark-900`,children:Fe(e.events)||t(`libreClaw.timeline.streaming`)});let n=e.events[0];return n?n.type===`assistant_delta`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.text||``)}):n.type===`user_message`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.content||``)}):n.type===`tool_call`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`tool_result`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:[String(n.data.name||t(`libreClaw.fallbacks.tool`)),` ·`,` `,n.data.is_error?t(`libreClaw.timeline.resultError`):t(`libreClaw.timeline.resultOk`)]}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:String(n.data.content||``)})]}):n.type===`permission_request`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.approvals.toolApprovalRequested`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`permission_response`?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.tool`),value:String(n.data.name||n.data.tool_call_id||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.resolution`),value:String(n.data.resolution||t(`libreClaw.fallbacks.resolved`))})]}):n.type===`usage`?(0,K.jsx)(Ae,{data:n.data,t}):n.type===`run_finished`?(0,K.jsx)(je,{data:n.data,t}):n.type===`error`?(0,K.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:String(n.data.message||t(`libreClaw.fallbacks.unknownError`))}):(0,K.jsx)(X,{value:n.data}):null},Ae=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.provider`),value:String(e.provider||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.model`),value:String(e.model||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.input`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.input_tokens),formatted:Q(e.input_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.output`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.output_tokens),formatted:Q(e.output_tokens)})}),Z(e.cached_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cached`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.cached_tokens),formatted:Q(e.cached_tokens)})}),Z(e.reasoning_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.reasoning`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.reasoning_tokens),formatted:Q(e.reasoning_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cost`),value:Re(e.cost)})]}),je=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.state`),value:t(`libreClaw.states.${String(e.state||`done`)}`,{defaultValue:String(e.state||`done`)})}),e.stop_reason!==void 0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.stopReason`),value:String(e.stop_reason)})]}),Y=({label:e,value:t})=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200/80 bg-white/50 px-2.5 py-1 text-xs text-gray-700 dark:border-white/10 dark:bg-white/[0.035] dark:text-dark-700`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-gray-500 dark:text-dark-500`,children:e}),(0,K.jsx)(`span`,{children:t})]}),X=({value:e})=>(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(e,null,2)}),Me=({text:e})=>(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-300 bg-white/30 px-4 py-8 text-center text-sm text-gray-500 dark:border-white/15 dark:bg-white/[0.02] dark:text-dark-500`,children:e}),Ne=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Pe=(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;if(i.type===`assistant_delta`){let i=[];for(;e[r]?.type===`assistant_delta`;){let t=e[r];t&&i.push(t),r+=1}let a=i[0],o=i[i.length-1]||a;a&&o&&n.push({key:`assistant-${a.event_id}-${o.event_id}`,kind:`assistant_message`,eventType:`assistant_message`,label:t(`libreClaw.timeline.assistantResponse`),firstEventId:a.event_id,lastEventId:o.event_id,timestamp:a.timestamp,events:i});continue}n.push({key:`${i.type}-${i.event_id}`,kind:`event`,eventType:i.type,label:Ie(i.type,t),firstEventId:i.event_id,lastEventId:i.event_id,timestamp:i.timestamp,events:[i]}),r+=1}return n},Fe=e=>e.map(e=>String(e.data.text||``)).join(``),Ie=(e,t)=>({user_message:t(`libreClaw.timeline.labels.userMessage`),tool_call:t(`libreClaw.timeline.labels.toolCall`),tool_result:t(`libreClaw.timeline.labels.toolResult`),permission_request:t(`libreClaw.timeline.labels.approvalRequest`),permission_response:t(`libreClaw.timeline.labels.approvalResponse`),run_started:t(`libreClaw.timeline.labels.runStarted`),run_finished:t(`libreClaw.timeline.labels.runFinished`),usage:t(`libreClaw.timeline.labels.usage`),error:t(`libreClaw.timeline.labels.error`)})[e]||e.replace(/_/g,` `),Le=e=>e.firstEventId===e.lastEventId?`#${e.firstEventId}`:`#${e.firstEventId}-#${e.lastEventId}`,Z=e=>{let t=Number(e);return Number.isFinite(t)?t:0},Q=e=>new Intl.NumberFormat().format(Z(e)),Re=e=>{let t=Z(e);return t<=0?`$0.00`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`};export{we as default};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{n as r}from"./i18next-DgmgtwsV.js";import{a as i,c as a,d as o,l as s,n as c,r as l,s as u,t as d,u as f}from"./useTranslation-CdeLZqSW.js";import{Bt as p,Ct as m,R as h,Sn as g,Tn as _,V as v,W as y,Xt as b,hn as x,k as S,ln as C,m as w,n as ee,on as T,st as te,v as E,x as D}from"./ui-vendor-D_pYT79f.js";import{t as O}from"./logger-DSXjF4ye.js";import{h as k}from"./api-CI1Inz7g.js";import{t as A}from"./utils-BhpNrGnR.js";import{t as j}from"./Button-X9TT9gTD.js";import{n as ne,t as M}from"./ui-BXTx1csA.js";var N={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,"!doctype":!0,"!DOCTYPE":!0},re=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function P(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(N[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(re),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var F=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,I=/<\/?([^\s]+?)[/\s>]/,ie=/^\s*$/,ae=/^(script|style)$/i,L=`\0`,oe=Object.create(null);function se(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(L).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(L).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(L)>-1&&(e.attrs[t]=n.split(L).join(`<`))}e.children.length&&se(e.children)})}function ce(e,t){let n=t&&t.components||oe,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;F.lastIndex=0;let o;for(;o=F.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(I);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=L,a=o.index+1,F.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=F.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let m=i.charAt(1)!==`/`,h=i.startsWith(`<!--`),g=p+i.length,_=e.charAt(g),v=f[r+1],y;if(_===`<`&&v){let t=e.substring(g,v.index);y=t.split(`<`).length>t.split(`>`).length}let b;if(h){let t=P(i);if(c<0)return a.push(t),a;b=o[c],b.children.push(t);let n=e.slice(g,v?v.index:void 0);return n.length>0&&b.children.push({type:`text`,content:n}),a}if(m){c++,s=P(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&ae.test(s.name)){t=!0,d||(d=e.toLowerCase());let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,g),r=n===-1?e.length:n,i=e.slice(g,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&_&&_!==`<`&&s.children.push({type:`text`,content:e.slice(g,v?v.index:void 0)}),c===0&&a.push(s),b=o[c-1],b&&b.children.push(s),o[c]=s}if((!m||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(_!==`<`||y)&&_)){b=c===-1?a:o[c].children;let t=v?v.index:-1,n=e.slice(g,t===-1?void 0:t);ie.test(n)&&(n=` `),(t>-1&&c+b.length>=0||n!==` `)&&b.push({type:`text`,content:n})}}),i&&se(a),a}function le(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`&quot;`)+`"`);return t.length?` `+t.join(` `):``}function ue(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?le(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(ue,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function de(e){return e.reduce(function(e,t){return e+ue(``,t)},``)}var R={parse:ce,stringify:de},z=e(n()),B=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},V=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?H(t):t},fe=e=>Array.isArray(e)&&e.every(z.isValidElement),H=e=>Array.isArray(e)?e:[e],pe=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},me=e=>{let t={};if(!e)return t;let n=e=>{H(e).forEach(e=>{s(e)||(B(e)?n(V(e)):a(e)&&!(0,z.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},U=(e,t,n,r)=>{if(!e)return``;let i=``,o=H(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return o.forEach((e,o)=>{if(s(e)){i+=`${e}`;return}if((0,z.isValidElement)(e)){let{props:a,type:l}=e,u=Object.keys(a).length,d=c.indexOf(l)>-1,f=a.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||a.i18nIsDynamicList){i+=`<${o}></${o}>`;return}if(d&&u<=1){let e=s(f)?f:U(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=U(f,t,n,r);i+=`<${o}>${p}</${o}>`;return}if(e===null){f(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(a(e)){let{format:t,...a}=e,o=Object.keys(a);if(o.length===1){let e=t?`${o[0]}, ${t}`:o[0];i+=`{{${e}}}`;return}f(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}f(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},W=(e,t,n,r,o,c,l)=>{if(n===``)return[];let d=o.transKeepBasicHtmlNodesFor||[],f=n&&new RegExp(d.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!f&&!l)return[n];let p=t??{},m=e=>{H(e).forEach(e=>{s(e)||(B(e)?m(V(e)):a(e)&&!(0,z.isValidElement)(e)&&Object.assign(p,e))})};m(e);let h=Object.keys(p),g=R.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||d.indexOf(e)>-1||h.indexOf(e)>-1}),_={...p,...c},v=(e,t,n)=>{let r=V(e),i=b(r,t.children,n);return fe(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},y=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,z.cloneElement)(e,{key:r},i?void 0:t))):n.push(...z.Children.map([e],e=>{if(e.type===z.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`children`&&t!==`i18nIsDynamicList`&&(n[t]=e.props[t])}),(0,z.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t!==`ref`&&t!==`children`&&(n[t]=e.props[t])}),(0,z.cloneElement)(e,n,i?null:t)}))},b=(e,n,c)=>{let p=H(e),m=H(n),h={};return m.reduce((e,n,m)=>{let g=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,_,r.language);if(n.type===`tag`){let i=p[parseInt(n.name,10)];!i&&t&&(i=t[n.name]),c.length===1&&!i&&(i=c[0][n.name]),i||(i={});let x={...n.attrs};l&&Object.keys(x).forEach(e=>{let t=x[e];s(t)&&(x[e]=u(t))});let S=Object.keys(x).length===0?i:pe({props:x},i),C=(0,z.isValidElement)(S),w=C&&B(n,!0)&&!n.voidElement,ee=f&&a(S)&&S.dummy&&!C,T=a(t)&&Object.hasOwnProperty.call(t,n.name);if(s(S)){let t=r.services.interpolator.interpolate(S,_,r.language);e.push(t)}else if(B(S)||w){let t=v(S,n,c);y(S,t,e,m)}else if(ee){let t=b(p,n.children,c);y(S,t,e,m)}else if(Number.isNaN(parseFloat(n.name)))if(T){let t=v(S,n,c);y(S,t,e,m,n.voidElement)}else if(o.transSupportBasicHtmlNodes&&d.indexOf(n.name)>-1)if(n.voidElement)e.push((0,z.createElement)(n.name,{key:`${n.name}-${m}`}));else{let t=h[n.name]||0;h[n.name]=t+1;let r,i=0;for(let e=0;e<p.length;e+=1){let a=p[e];if((0,z.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?H(V(r)):p,o=b(a,n.children,c);e.push((0,z.createElement)(n.name,{key:`${n.name}-${m}`},o))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=b(p,n.children,c);e.push(`<${n.name}>${t}</${n.name}>`)}else if(a(S)&&!C){let t=n.children[0]?g:null;t&&e.push(t)}else y(S,g,e,m,n.children.length!==1||!g)}else if(n.type===`text`){let t=o.transWrapTextNodes,a=typeof o.unescape==`function`?o.unescape:i().unescape,s=l?a(r.services.interpolator.interpolate(n.content,_,r.language)):r.services.interpolator.interpolate(n.content,_,r.language);t?e.push((0,z.createElement)(t,{key:`${n.name}-${m}`},s)):e.push(s)}return e},[])};return V(b([{dummy:!0,children:e||[]}],g,H(e||[]))[0])},G=(e,t,n)=>{let r=e.key||t,i=(0,z.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,z.createElement)(z.Fragment,null,i)}return(0,z.createElement)(a,{key:r})},he=(e,t)=>e.map((e,n)=>G(e,n,t)),ge=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:G(e[r],r,t)})}),n},_e=(e,t,n,r)=>e?Array.isArray(e)?he(e,t):a(e)?ge(e,t):(o(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,ve=e=>!a(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function ye({children:e,count:t,parent:n,i18nKey:a,context:c,tOptions:u={},values:d,defaults:f,components:p,ns:m,i18n:h,t:g,shouldUnescape:_,...v}){let y=h||l();if(!y)return o(y,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:a}),e;let b=g||y.t.bind(y)||(e=>e),x={...i(),...y.options?.react},S=m||b.ns||y.options?.defaultNS;S=s(S)?[S]:S||[`translation`];let{transDefaultProps:C}=x,w=C?.tOptions?{...C.tOptions,...u}:u,ee=_??C?.shouldUnescape,T=C?.values?{...C.values,...d}:d,te=C?.components?{...C.components,...p}:p,E=U(e,x,y,a),D=f||w?.defaultValue||E||x.transEmptyNodeValue||(typeof a==`function`?r(a):a),{hashTransKey:O}=x,k=a||(O?O(E||D):E||D);d=y.options?.interpolation?.defaultVariables?T&&Object.keys(T).length>0?{...T,...y.options.interpolation.defaultVariables}:{...y.options.interpolation.defaultVariables}:T;let A=me(e);A&&typeof A.count==`number`&&t===void 0&&(t=A.count);let j=d||t!==void 0&&!y.options?.interpolation?.alwaysFormat||!e?w.interpolation:{interpolation:{...w.interpolation,prefix:`#$?`,suffix:`?$#`}},ne={...w,context:c||w.context,count:t,...d,...j,defaultValue:D,ns:S},M=k?b(k,ne):D;M===k&&D&&(M=D);let N=_e(te,M,y,a),re=N||e,P=null;ve(N)&&(P=N,re=e);let F=W(re,P,M,y,x,ne,ee),I=n??x.defaultTransParent;return I?(0,z.createElement)(I,v,F):F}function be({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a={},values:o,defaults:s,components:u,ns:d,i18n:f,t:p,shouldUnescape:m,...h}){let{i18n:g,defaultNS:_}=(0,z.useContext)(c)||{},v=f||g||l(),y=p||v?.t.bind(v);return ye({children:e,count:t,parent:n,i18nKey:r,context:i,tOptions:a,values:o,defaults:s,components:u,ns:d||y?.ns||_||v?.options?.defaultNS,i18n:v,t:p,shouldUnescape:m,...h})}var K=t(),q=O(`pages:libre-claw`),xe={queued:`bg-gray-100 text-gray-700 dark:bg-dark-200 dark:text-dark-700`,running:`bg-primary-100 text-primary-700 dark:bg-primary-900/25 dark:text-primary-300`,blocked:`bg-amber-500/20 text-ink dark:bg-amber-900/30`,done:`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`,failed:`bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300`,cancelled:`bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300`},Se={assistant_message:`text-primary-600 dark:text-primary-300`,assistant_delta:`text-primary-600 dark:text-primary-300`,user_message:`text-gray-700 dark:text-dark-700`,permission_request:`text-ink`,permission_response:`text-gray-600 dark:text-dark-600`,tool_call:`text-gray-600 dark:text-dark-600`,tool_result:`text-gray-600 dark:text-dark-600`,usage:`text-gray-600 dark:text-dark-600`,error:`text-red-600 dark:text-red-300`,run_finished:`text-emerald-600 dark:text-emerald-300`},Ce=[[`lobster`,`Lobster`],[`lobster-light`,`Lobster Light`],[`github-dark`,`GitHub Dark`],[`github-light`,`GitHub Light`],[`monokai-pro`,`Monokai Pro`],[`night-owl`,`Night Owl`],[`tokyo-night`,`Tokyo Night`],[`ayu`,`Ayu`],[`dracula`,`Dracula`],[`catppuccin-mocha`,`Catppuccin Mocha`],[`catppuccin-latte`,`Catppuccin Latte`],[`gruvbox-dark`,`Gruvbox Dark`],[`nord`,`Nord`],[`solarized-dark`,`Solarized Dark`],[`solarized-light`,`Solarized Light`],[`one-dark-pro`,`One Dark Pro`],[`rose-pine`,`Rose Pine`],[`kanagawa`,`Kanagawa`],[`matrix`,`Matrix`]],we=()=>{let{t:e}=d(),[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)([]),[l,u]=(0,z.useState)(null),[f,O]=(0,z.useState)(null),[N,re]=(0,z.useState)(``),[P,F]=(0,z.useState)(null),[I,ie]=(0,z.useState)(!0),[ae,L]=(0,z.useState)(!1),[oe,se]=(0,z.useState)(!1),[ce,le]=(0,z.useState)(!1),[ue,de]=(0,z.useState)(!1),[R,B]=(0,z.useState)(``),[V,fe]=(0,z.useState)(`chat`),[H,pe]=(0,z.useState)(``),[me,U]=(0,z.useState)(``),[W,G]=(0,z.useState)(``),[he,ge]=(0,z.useState)(``),[_e,ve]=(0,z.useState)(!1),[ye,xe]=(0,z.useState)(`lobster`),[Se,we]=(0,z.useState)(!0),[ke,Ae]=(0,z.useState)(``),[je,Y]=(0,z.useState)(``),[X,Fe]=(0,z.useState)(``),[Ie,Le]=(0,z.useState)(`report`),Z=(0,z.useMemo)(()=>r.find(e=>e.run_id===P)||null,[r,P]),Q=(0,z.useMemo)(()=>{let e=new Set(a.filter(e=>e.type===`permission_response`).map(e=>String(e.data.tool_call_id||``)));return a.filter(t=>{if(t.type!==`permission_request`)return!1;let n=String(t.data.tool_call_id||``);return n&&!e.has(n)})},[a]),Re=(0,z.useMemo)(()=>Pe(a,e),[a,e]),$=(0,z.useCallback)(async()=>{try{let[e,t,r,a,o,s]=await Promise.all([k.status(),k.listRuns(30),k.currentModel(),k.currentFallback(),k.usage(``,100),k.listAutomations(50)]);e.success&&e.data&&n(e.data),t.success&&t.data&&(i(t.data.runs),F(e=>e||t.data?.runs[0]?.run_id||null)),r.success&&r.data&&(u(r.data),G(String(r.data.provider||``)),ge(String(r.data.model||``))),a.success&&a.data&&O(a.data),o.success&&o.data&&re(String(o.data.text||``)),s.success&&s.data&&c(s.data.automations)}catch(t){q.error(`Failed to load Libre Claw overview:`,t),_.error(e(`libreClaw.toasts.loadStatusFailed`))}finally{ie(!1)}},[e]),ze=(0,z.useCallback)(async(e,t=!1)=>{let n=t?0:a.length>0&&a[a.length-1]?.event_id||0;try{let r=await k.getEvents(e,n);r.success&&r.data&&o(e=>t?r.data?.events||[]:[...e,...r.data?.events||[]])}catch(e){q.error(`Failed to load Libre Claw events:`,e)}},[a]);(0,z.useEffect)(()=>{let e=window.setTimeout(()=>{$()},0);return()=>window.clearTimeout(e)},[$]),(0,z.useEffect)(()=>{if(!P){let e=window.setTimeout(()=>{o([])},0);return()=>window.clearTimeout(e)}let e=P;k.getEvents(e,0).then(e=>{e.success&&e.data&&o(e.data.events)}).catch(e=>{q.error(`Failed to load Libre Claw events:`,e)})},[P]),(0,z.useEffect)(()=>{if(!P||!Z||![`queued`,`running`,`blocked`].includes(Z.state))return;let e=window.setInterval(()=>{ze(P),k.listRuns(30).then(e=>{e.success&&e.data&&i(e.data.runs)})},1500);return()=>window.clearInterval(e)},[ze,Z,P]);let Be=async()=>{if(!R.trim()){_.error(e(`libreClaw.toasts.enterTask`));return}L(!0);try{let t=await k.startRun({message:R,kind:V,provider:H||void 0,model:me||void 0});if(t.success&&t.data){let n=t.data.run;i(e=>[n,...e.filter(e=>e.run_id!==n.run_id)]),F(n.run_id),B(``),_.success(e(`libreClaw.toasts.runStarted`))}else _.error(t.error||e(`libreClaw.toasts.startRunFailed`))}catch(t){q.error(`Failed to start Libre Claw run:`,t),_.error(e(`libreClaw.toasts.startRunFailed`))}finally{L(!1)}},Ve=async t=>{try{await k.cancelRun(t),await $(),_.success(e(`libreClaw.toasts.runCancelled`))}catch(t){q.error(`Failed to cancel Libre Claw run:`,t),_.error(e(`libreClaw.toasts.cancelRunFailed`))}},He=async(t,n)=>{if(!P)return;let r=String(t.data.tool_call_id||``);if(r)try{await k.resolvePermission(P,r,n),await ze(P,!0),_.success(e(n===`deny`?`libreClaw.toasts.denied`:`libreClaw.toasts.approved`))}catch(t){q.error(`Failed to resolve Libre Claw permission:`,t),_.error(e(`libreClaw.toasts.resolvePermissionFailed`))}},Ue=async()=>{if(!W.trim()||!he.trim()){_.error(e(`libreClaw.toasts.providerModelRequired`));return}se(!0);try{let t=await k.updateModel(W,he,_e);t.success&&t.data?(u(t.data),_.success(e(`libreClaw.toasts.modelUpdated`))):_.error(t.error||e(`libreClaw.toasts.updateModelFailed`))}catch(t){q.error(`Failed to update Libre Claw model:`,t),_.error(e(`libreClaw.toasts.updateModelFailed`))}finally{se(!1)}},We=async()=>{le(!0);try{let t=await k.updateTheme(ye,Se);t.success?_.success(e(`libreClaw.toasts.themeUpdated`)):_.error(t.error||e(`libreClaw.toasts.updateThemeFailed`))}catch(t){q.error(`Failed to update Libre Claw theme:`,t),_.error(e(`libreClaw.toasts.updateThemeFailed`))}finally{le(!1)}},Ge=async()=>{if(!ke.trim()||!je.trim()||!X.trim()){_.error(e(`libreClaw.toasts.automationRequired`));return}de(!0);try{let t=await k.createAutomation({name:ke,schedule:je,prompt:X,route:Ie});t.success?(Ae(``),Y(``),Fe(``),await $(),_.success(e(`libreClaw.toasts.automationCreated`))):_.error(t.error||e(`libreClaw.toasts.createAutomationFailed`))}catch(t){q.error(`Failed to create Libre Claw automation:`,t),_.error(e(`libreClaw.toasts.createAutomationFailed`))}finally{de(!1)}},Ke=async(t,n)=>{try{n===`pause`&&await k.pauseAutomation(t),n===`resume`&&await k.resumeAutomation(t),n===`run`&&await k.runAutomationNow(t),n===`delete`&&await k.deleteAutomation(t),await $(),_.success(e(`libreClaw.toasts.automationUpdated`))}catch(t){q.error(`Failed to update Libre Claw automation:`,t),_.error(e(`libreClaw.toasts.updateAutomationFailed`))}};return(0,K.jsxs)(ne,{width:`wide`,contentClassName:`space-y-6`,children:[(0,K.jsx)(M,{className:`mb-0`,title:e(`libreClaw.title`),description:e(`libreClaw.subtitle`),actions:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Te,{status:t,t:e}),(0,K.jsxs)(j,{variant:`secondary`,size:`sm`,onClick:$,children:[(0,K.jsx)(h,{className:`h-4 w-4`}),e(`common.refresh`)]}),(0,K.jsxs)(`a`,{href:t?.dashboardUrl||`http://127.0.0.1:8766/dashboard`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-xl border border-gray-200/80 bg-white/70 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-white dark:border-white/10 dark:bg-white/[0.04] dark:text-dark-700 dark:hover:bg-white/[0.08]`,children:[(0,K.jsx)(p,{className:`h-4 w-4`}),e(`libreClaw.dashboard`)]})]})}),!t?.connected&&!I&&(0,K.jsx)(`section`,{className:`rounded-xl border border-amber-200 bg-amber-500/10 p-4 text-ink dark:border-amber-800 dark:bg-amber-900/20`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(E,{className:`mt-0.5 h-5 w-5 shrink-0 text-amber-500`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`font-semibold`,children:e(`libreClaw.connection.disconnectedTitle`)}),(0,K.jsx)(`p`,{className:`mt-1 text-sm opacity-90`,children:(0,K.jsx)(be,{i18nKey:`libreClaw.connection.disconnectedDescription`,components:{command:(0,K.jsx)(`code`,{}),env:(0,K.jsx)(`code`,{})}})}),t?.error&&(0,K.jsx)(`p`,{className:`mt-2 text-xs opacity-80`,children:t.error})]})]})}),(0,K.jsxs)(`section`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.startRun.title`),icon:(0,K.jsx)(v,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`textarea`,{value:R,onChange:e=>B(e.target.value),placeholder:e(`libreClaw.startRun.placeholder`),className:`min-h-32 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm text-gray-900 outline-none transition focus:border-primary-400 focus:ring-2 focus:ring-primary-100 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800 dark:focus:border-primary-500 dark:focus:ring-primary-900/30`}),(0,K.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-4`,children:[(0,K.jsxs)(`select`,{value:V,onChange:e=>fe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`chat`,children:e(`libreClaw.startRun.chatRun`)}),(0,K.jsx)(`option`,{value:`goal`,children:e(`libreClaw.startRun.goalMode`)})]}),(0,K.jsx)(`input`,{value:H,onChange:e=>pe(e.target.value),placeholder:e(`libreClaw.startRun.providerOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:me,onChange:e=>U(e.target.value),placeholder:e(`libreClaw.startRun.modelOverride`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(j,{onClick:Be,loading:ae,children:[(0,K.jsx)(x,{className:`h-4 w-4`}),e(`libreClaw.startRun.run`)]})]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.modelRoute.title`),icon:(0,K.jsx)(m,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-1`,children:[(0,K.jsx)(`input`,{value:W,onChange:e=>G(e.target.value),placeholder:e(`libreClaw.modelRoute.providerPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:he,onChange:e=>ge(e.target.value),placeholder:e(`libreClaw.modelRoute.modelPlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e,onChange:e=>ve(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]}),(0,K.jsx)(j,{variant:`secondary`,onClick:Ue,loading:oe,children:e(`libreClaw.modelRoute.saveModel`)}),(0,K.jsxs)(`div`,{className:`border-t border-gray-100 pt-3 dark:border-dark-200`,children:[(0,K.jsx)(`label`,{className:`mb-1 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-dark-500`,children:e(`libreClaw.modelRoute.theme`)}),(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] lg:grid-cols-1`,children:[(0,K.jsx)(`select`,{value:ye,onChange:e=>xe(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:Ce.map(([e,t])=>(0,K.jsx)(`option`,{value:e,children:t},e))}),(0,K.jsx)(j,{variant:`secondary`,onClick:We,loading:ce,children:e(`libreClaw.modelRoute.saveTheme`)})]}),(0,K.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-sm text-gray-600 dark:text-dark-600`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Se,onChange:e=>we(e.target.checked),className:`h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500`}),e(`libreClaw.modelRoute.persistGlobal`)]})]}),l&&(0,K.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(l,null,2)})]})})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[360px_minmax(0,1fr)]`,children:[(0,K.jsx)(J,{title:e(`libreClaw.runs.title`),icon:(0,K.jsx)(g,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[r.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.runs.empty`)}),r.map(t=>(0,K.jsxs)(`button`,{onClick:()=>F(t.run_id),className:A(`w-full rounded-xl border p-3 text-start transition`,P===t.run_id?`border-primary-300 bg-primary-50 dark:border-primary-700 dark:bg-primary-900/20`:`border-gray-200 bg-white hover:bg-gray-50 dark:border-dark-300 dark:bg-dark-50 dark:hover:bg-dark-100`),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.title}),(0,K.jsx)(Ee,{state:t.state,t:e})]}),(0,K.jsxs)(`div`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-dark-500`,children:[t.provider,`:`,t.model]}),(0,K.jsx)(`div`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:Ne(t.updated_at)})]},t.run_id))]})}),(0,K.jsxs)(J,{title:Z?Z.title:e(`libreClaw.timeline.title`),icon:(0,K.jsx)(b,{className:`h-4 w-4`}),actions:Z&&[`queued`,`running`,`blocked`].includes(Z.state)?(0,K.jsxs)(j,{variant:`danger`,size:`sm`,onClick:()=>Ve(Z.run_id),children:[(0,K.jsx)(D,{className:`h-4 w-4`}),e(`common.cancel`)]}):null,children:[Q.length>0&&(0,K.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-xl border border-amber-200 bg-amber-500/10 p-3 dark:border-amber-800 dark:bg-amber-900/20`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-ink`,children:[(0,K.jsx)(S,{className:`h-4 w-4 text-amber-500`}),e(`libreClaw.approvals.needed`)]}),Q.map(t=>(0,K.jsxs)(`div`,{className:`rounded-lg bg-white/70 p-3 dark:bg-dark-50/70`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(t.data.name||e(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-36 overflow-auto rounded bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(t.data.arguments||{},null,2)}),(0,K.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,K.jsxs)(j,{size:`sm`,onClick:()=>He(t,`allow_once`),children:[(0,K.jsx)(T,{className:`h-4 w-4`}),e(`libreClaw.approvals.allowOnce`)]}),(0,K.jsx)(j,{size:`sm`,variant:`secondary`,onClick:()=>He(t,`always_allow_tool`),children:e(`libreClaw.approvals.alwaysAllowTool`)}),(0,K.jsxs)(j,{size:`sm`,variant:`danger`,onClick:()=>He(t,`deny`),children:[(0,K.jsx)(ee,{className:`h-4 w-4`}),e(`libreClaw.approvals.deny`)]})]})]},t.event_id))]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[a.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.timeline.empty`)}),Re.map(t=>(0,K.jsx)(Oe,{item:t,t:e},t.key))]})]})]}),(0,K.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,K.jsx)(J,{title:e(`libreClaw.automations.title`),icon:(0,K.jsx)(C,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,K.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`libreClaw.automations.namePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsx)(`input`,{value:je,onChange:e=>Y(e.target.value),placeholder:e(`libreClaw.automations.schedulePlaceholder`),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`select`,{value:Ie,onChange:e=>Le(e.target.value),className:`rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,K.jsx)(`option`,{value:`report`,children:e(`libreClaw.automations.routes.report`)}),(0,K.jsx)(`option`,{value:`telegram`,children:e(`libreClaw.automations.routes.telegram`)})]}),(0,K.jsx)(j,{onClick:Ge,loading:ue,children:e(`libreClaw.automations.create`)})]}),(0,K.jsx)(`textarea`,{value:X,onChange:e=>Fe(e.target.value),placeholder:e(`libreClaw.automations.promptPlaceholder`),className:`min-h-24 w-full rounded-xl border border-gray-200 bg-white px-3 py-2 text-sm dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[s.length===0&&(0,K.jsx)(Me,{text:e(`libreClaw.automations.empty`)}),s.map(t=>(0,K.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-3 dark:border-dark-300 dark:bg-dark-50`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:t.name}),(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:[t.schedule,` ·`,` `,e(`libreClaw.automations.routes.${t.route}`,{defaultValue:t.route}),` `,`·`,` `,e(`libreClaw.automations.status.${t.status}`,{defaultValue:t.status})]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,K.jsx)(De,{title:e(`libreClaw.automations.runNow`),onClick:()=>Ke(t.automation_id,`run`),children:(0,K.jsx)(v,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:t.status===`paused`?e(`libreClaw.automations.resume`):e(`libreClaw.automations.pause`),onClick:()=>Ke(t.automation_id,t.status===`paused`?`resume`:`pause`),children:t.status===`paused`?(0,K.jsx)(v,{className:`h-4 w-4`}):(0,K.jsx)(y,{className:`h-4 w-4`})}),(0,K.jsx)(De,{title:e(`common.delete`),danger:!0,onClick:()=>Ke(t.automation_id,`delete`),children:(0,K.jsx)(w,{className:`h-4 w-4`})})]})]})},t.automation_id))]})]})}),(0,K.jsx)(J,{title:e(`libreClaw.usageFallback.title`),icon:(0,K.jsx)(g,{className:`h-4 w-4`}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.usage`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:N||e(`libreClaw.usageFallback.noUsage`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`mb-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`libreClaw.usageFallback.fallbackRoute`)}),(0,K.jsx)(`pre`,{className:`max-h-52 overflow-auto rounded-xl bg-gray-100 p-3 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(f||{},null,2)})]})]})})]}),I&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-white/60 backdrop-blur-sm dark:bg-dark-50/60`,children:(0,K.jsx)(te,{className:`h-7 w-7 animate-spin text-primary-600`})})]})},Te=({status:e,t})=>{let n=!!e?.connected;return(0,K.jsxs)(`span`,{className:A(`inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-sm font-medium`,n?`bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300`:`bg-amber-500/20 text-ink dark:bg-amber-900/30`),children:[(0,K.jsx)(`span`,{className:A(`h-2 w-2 rounded-full`,n?`bg-emerald-500`:`bg-amber-500`)}),t(n?`libreClaw.status.connected`:`libreClaw.status.disconnected`),e?.health?.active_runs!==void 0&&(0,K.jsxs)(`span`,{className:`opacity-70`,children:[`·`,` `,t(`libreClaw.status.activeRuns`,{count:e.health.active_runs})]})]})},Ee=({state:e,t})=>(0,K.jsx)(`span`,{className:A(`rounded-full px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide`,xe[e]||xe.queued),children:t(`libreClaw.states.${e}`,{defaultValue:e})}),J=({title:e,icon:t,actions:n,children:r})=>(0,K.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/60 dark:border-white/10 dark:bg-white/[0.03]`,children:[(0,K.jsxs)(`header`,{className:`flex items-center justify-between gap-3 border-b border-gray-200/70 px-5 py-4 dark:border-white/[0.08]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-dark-900`,children:[(0,K.jsx)(`span`,{className:`text-primary-600 dark:text-primary-300`,children:t}),e]}),n]}),(0,K.jsx)(`div`,{className:`p-5`,children:r})]}),De=({title:e,danger:t,onClick:n,children:r})=>(0,K.jsx)(`button`,{type:`button`,title:e,onClick:n,className:A(`inline-flex h-8 w-8 items-center justify-center rounded-lg transition-colors`,t?`text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`:`text-gray-500 hover:bg-gray-100 dark:text-dark-500 dark:hover:bg-dark-200`),children:r}),Oe=({item:e,t})=>(0,K.jsxs)(`article`,{className:A(`rounded-xl border p-3 transition-colors`,e.eventType===`assistant_message`?`border-primary-200 bg-primary-50/60 dark:border-primary-900/60 dark:bg-primary-900/10`:(e.eventType,`border-gray-200/80 bg-white/50 dark:border-white/[0.08] dark:bg-white/[0.025]`)),children:[(0,K.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:A(`text-xs font-semibold uppercase tracking-wide`,Se[e.eventType]||`text-gray-500 dark:text-dark-500`),children:e.label}),(0,K.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-400 dark:text-dark-500`,children:[Le(e),` · `,Ne(e.timestamp)]})]}),(0,K.jsx)(ke,{item:e,t})]}),ke=({item:e,t})=>{if(e.kind===`assistant_message`)return(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-6 text-gray-900 dark:text-dark-900`,children:Fe(e.events)||t(`libreClaw.timeline.streaming`)});let n=e.events[0];return n?n.type===`assistant_delta`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.text||``)}):n.type===`user_message`?(0,K.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-gray-800 dark:text-dark-800`,children:String(n.data.content||``)}):n.type===`tool_call`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`tool_result`?(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:[String(n.data.name||t(`libreClaw.fallbacks.tool`)),` ·`,` `,n.data.is_error?t(`libreClaw.timeline.resultError`):t(`libreClaw.timeline.resultOk`)]}),(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:String(n.data.content||``)})]}):n.type===`permission_request`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-dark-900`,children:String(n.data.name||t(`libreClaw.approvals.toolApprovalRequested`))}),(0,K.jsx)(X,{value:n.data.arguments||{}})]}):n.type===`permission_response`?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.tool`),value:String(n.data.name||n.data.tool_call_id||t(`libreClaw.fallbacks.tool`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.resolution`),value:String(n.data.resolution||t(`libreClaw.fallbacks.resolved`))})]}):n.type===`usage`?(0,K.jsx)(Ae,{data:n.data,t}):n.type===`run_finished`?(0,K.jsx)(je,{data:n.data,t}):n.type===`error`?(0,K.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:String(n.data.message||t(`libreClaw.fallbacks.unknownError`))}):(0,K.jsx)(X,{value:n.data}):null},Ae=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.provider`),value:String(e.provider||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.model`),value:String(e.model||t(`libreClaw.fallbacks.unknown`))}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.input`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.input_tokens),formatted:Q(e.input_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.output`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.output_tokens),formatted:Q(e.output_tokens)})}),Z(e.cached_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cached`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.cached_tokens),formatted:Q(e.cached_tokens)})}),Z(e.reasoning_tokens)>0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.reasoning`),value:t(`libreClaw.metrics.tokens`,{count:Z(e.reasoning_tokens),formatted:Q(e.reasoning_tokens)})}),(0,K.jsx)(Y,{label:t(`libreClaw.metrics.cost`),value:Re(e.cost)})]}),je=({data:e,t})=>(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(Y,{label:t(`libreClaw.metrics.state`),value:t(`libreClaw.states.${String(e.state||`done`)}`,{defaultValue:String(e.state||`done`)})}),e.stop_reason!==void 0&&(0,K.jsx)(Y,{label:t(`libreClaw.metrics.stopReason`),value:String(e.stop_reason)})]}),Y=({label:e,value:t})=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200/80 bg-white/50 px-2.5 py-1 text-xs text-gray-700 dark:border-white/10 dark:bg-white/[0.035] dark:text-dark-700`,children:[(0,K.jsx)(`span`,{className:`font-semibold text-gray-500 dark:text-dark-500`,children:e}),(0,K.jsx)(`span`,{children:t})]}),X=({value:e})=>(0,K.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto rounded-lg bg-gray-100 p-2 text-xs text-gray-700 dark:bg-dark-200 dark:text-dark-700`,children:JSON.stringify(e,null,2)}),Me=({text:e})=>(0,K.jsx)(`div`,{className:`rounded-xl border border-dashed border-gray-300 bg-white/30 px-4 py-8 text-center text-sm text-gray-500 dark:border-white/15 dark:bg-white/[0.02] dark:text-dark-500`,children:e}),Ne=e=>{if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()},Pe=(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e[r];if(!i)break;if(i.type===`assistant_delta`){let i=[];for(;e[r]?.type===`assistant_delta`;){let t=e[r];t&&i.push(t),r+=1}let a=i[0],o=i[i.length-1]||a;a&&o&&n.push({key:`assistant-${a.event_id}-${o.event_id}`,kind:`assistant_message`,eventType:`assistant_message`,label:t(`libreClaw.timeline.assistantResponse`),firstEventId:a.event_id,lastEventId:o.event_id,timestamp:a.timestamp,events:i});continue}n.push({key:`${i.type}-${i.event_id}`,kind:`event`,eventType:i.type,label:Ie(i.type,t),firstEventId:i.event_id,lastEventId:i.event_id,timestamp:i.timestamp,events:[i]}),r+=1}return n},Fe=e=>e.map(e=>String(e.data.text||``)).join(``),Ie=(e,t)=>({user_message:t(`libreClaw.timeline.labels.userMessage`),tool_call:t(`libreClaw.timeline.labels.toolCall`),tool_result:t(`libreClaw.timeline.labels.toolResult`),permission_request:t(`libreClaw.timeline.labels.approvalRequest`),permission_response:t(`libreClaw.timeline.labels.approvalResponse`),run_started:t(`libreClaw.timeline.labels.runStarted`),run_finished:t(`libreClaw.timeline.labels.runFinished`),usage:t(`libreClaw.timeline.labels.usage`),error:t(`libreClaw.timeline.labels.error`)})[e]||e.replace(/_/g,` `),Le=e=>e.firstEventId===e.lastEventId?`#${e.firstEventId}`:`#${e.firstEventId}-#${e.lastEventId}`,Z=e=>{let t=Number(e);return Number.isFinite(t)?t:0},Q=e=>new Intl.NumberFormat().format(Z(e)),Re=e=>{let t=Z(e);return t<=0?`$0.00`:t<.01?`$${t.toFixed(6)}`:`$${t.toFixed(4)}`};export{we as default};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{n as r}from"./react-vendor-DPNXrO-8.js";import{d as i}from"./router-vendor-Ca9zqOqT.js";import{t as a}from"./useTranslation-CdeLZqSW.js";import{B as o,Bt as s,Ht as c,P as l,R as u,T as d,Tn as f,Wt as p,Yt as m,an as ee,c as h,dn as g,gt as _,hn as v,n as y,on as b,ot as x,pt as S,t as C,v as w,vt as te}from"./ui-vendor-D_pYT79f.js";import{t as ne}from"./logger-DSXjF4ye.js";import{_ as re,p as T}from"./api-DVP8xiYT.js";import{t as E}from"./utils-BhpNrGnR.js";import{s as ie}from"./chatStore-DmDbolTg.js";import{n as ae}from"./authStore-gv_MgDKr.js";import{u as oe}from"../assets/index-_lG_lwU-.js";var D=e(n(),1),se=r(),O=t();function k(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ce({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:o,hfGgufFiles:l,loadingGguf:d,pullingModel:f,pullProgress:p,setHfTask:m,setHfSort:h,onToggleHfModel:g,onPullHfGguf:v,onCancelPull:b,onRefreshHfModels:S}){let{t:w}=a();return(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`select`,{value:e,onChange:e=>m(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,O.jsx)(`option`,{value:`text-generation`,children:w(`modelManager.huggingface.taskTextGeneration`)}),(0,O.jsx)(`option`,{value:`text-to-speech`,children:w(`modelManager.huggingface.taskTextToSpeech`)}),(0,O.jsx)(`option`,{value:`text-to-image`,children:w(`modelManager.huggingface.taskTextToImage`)}),(0,O.jsx)(`option`,{value:`automatic-speech-recognition`,children:w(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,O.jsxs)(`select`,{value:t,onChange:e=>h(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,O.jsx)(`option`,{value:`downloads`,children:w(`modelManager.huggingface.sortDownloads`)}),(0,O.jsx)(`option`,{value:`likes`,children:w(`modelManager.huggingface.sortLikes`)}),(0,O.jsx)(`option`,{value:`lastModified`,children:w(`modelManager.huggingface.sortRecent`)})]})]})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.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:w(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(x,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(C,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:w(`modelManager.huggingface.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=o===e.id,r=l[e.id]||[],i=d===e.id;return(0,O.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,O.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.id)},children:(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,O.jsx)(C,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,O.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,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(c,{className:`h-3 w-3`}),k(e.downloads)]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(_,{className:`h-3 w-3`}),k(e.likes)]}),e.pipeline_tag&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,O.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,O.jsx)(s,{className:`h-4 w-4 text-gray-400`})}),(0,O.jsx)(ee,{className:E(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,O.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,O.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,O.jsx)(x,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,O.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:w(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,O.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:w(`modelManager.huggingface.noGgufAvailable`)}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:w(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=f===e.ollamaCommand;return(0,O.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,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,O.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,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:p?.percent===void 0?`...`:`${p.percent}%`}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),b()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(y,{className:`h-4 w-4`})})]}):n?(0,O.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),v(e.ollamaCommand,e.filename)},disabled:!!f,className:E(`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,O.jsx)(c,{className:`h-3 w-3 inline mr-1`}),w(`models.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:w(`modelSelector.adminOnlyPull`)})]},e.filename)}),f?.startsWith(`hf.co/`)&&f.includes(e.id)&&p?.percent!==void 0&&(0,O.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${p.percent}%`}})})]})})]},e.id)})})]}),(0,O.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,O.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,O.jsx)(s,{className:`h-3 w-3`}),w(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),S()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(u,{className:E(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function le({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:s,getModelSubLabel:c,onModelSelect:l,onOpenGallery:u}){let{t:d}=a();return(0,O.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,O.jsxs)(`div`,{children:[(0,O.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,O.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,O.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:E(`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,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:s(e)}),c(e)&&(0,O.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:c(e)})]}),t===n&&(0,O.jsx)(b,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(p,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,O.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,O.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,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,O.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,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(S,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function ue({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:o,pullProgress:l,setLibraryCategory:d,isModelInstalled:f,onModelSelect:p,onPullModel:ee,onCancelPull:h,onRefreshLibrary:g}){let{t:_}=a();return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,O.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),d(e)},className:E(`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,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.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,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(x,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(m,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:_(`models.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=f(e.name),r=o===e.name;return(0,O.jsxs)(`div`,{className:E(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,O.jsx)(m,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,O.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,O.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,O.jsx)(m,{className:`h-3 w-3`}),`Cloud`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,O.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,O.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,O.jsx)(c,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,O.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:l?.percent===void 0?`...`:`${l.percent}%`}),(0,O.jsx)(`button`,{onClick:h,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(y,{className:`h-4 w-4`})})]}):t?(0,O.jsx)(`button`,{onClick:()=>p(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,O.jsxs)(`button`,{onClick:()=>ee(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,O.jsx)(c,{className:`h-3 w-3 inline mr-1`}),_(`modelSelector.pull`)]}):(0,O.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&&l?.percent!==void 0&&(0,O.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${l.percent}%`}})})]},e.name)})})]}),(0,O.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,O.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,O.jsx)(s,{className:`h-3 w-3`}),_(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),g()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(u,{className:E(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var de=ne(`components:model-selector`),A=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:o,disabled:s=!1,compact:c=!1,showImageGen:u=!1,onModelsRefresh:p,getModelValue:_,getModelLabel:b,getModelTitle:x,triggerRef:S,triggerTestId:ne,selectTestId:k,ariaLabel:A})=>{let{t:j}=a(),[M,fe]=(0,D.useState)(!1),[N,pe]=(0,D.useState)(``),[P,F]=(0,D.useState)(`installed`),me=(0,D.useRef)(null),I=(0,D.useRef)(null),L=(0,D.useRef)(null),R=(0,D.useRef)(null),he=i(),{user:ge,systemInfo:_e}=ae(),z=ge?.role===`admin`||_e?.requiresAuth===!1,[B,ve]=(0,D.useState)(`all`),[ye,be]=(0,D.useState)(``),[V,xe]=(0,D.useState)(`text-generation`),[H,Se]=(0,D.useState)(`downloads`),[Ce,we]=(0,D.useState)(``),[U,Te]=(0,D.useState)(null),[W,Ee]=(0,D.useState)({}),[De,Oe]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[ke,q]=(0,D.useState)(null),[Ae,J]=(0,D.useState)(null),je=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Me=[{type:`legacy`,label:j(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,O.jsx)(g,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:j(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,O.jsx)(y,{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:j(`modelSelector.personas`),icon:(0,O.jsx)(h,{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:j(`modelSelector.agentModels`,`Agents`),icon:(0,O.jsx)(w,{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:j(`modelSelector.ollamaModels`),icon:(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>ie(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:j(`modelSelector.pluginModels`),icon:(0,O.jsx)(C,{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(N.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(N.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(N.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>_?.(e)??e.name,X=e.find(e=>Y(e)===t);(0,D.useImperativeHandle)(S,()=>L.current);let Z=(0,D.useCallback)((e=!0)=>{fe(!1),pe(``),e&&window.requestAnimationFrame(()=>L.current?.focus())},[]),{data:Ne=[],isLoading:Pe,refetch:Fe}=oe({queryKey:[`ollama-library-selector`,ye,B===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await T.getLibraryModels({search:ye||void 0,sort:`popular`,category:B===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:M&&P===`ollama`}),{data:Ie=[],isLoading:Le,refetch:Re}=oe({queryKey:[`hf-models-selector`,V,Ce,H],queryFn:async()=>{let e=await re.getModels({task:V,search:Ce||void 0,sort:H,limit:30});return e.success&&e.data?e.data:[]},enabled:M&&P===`huggingface`}),ze=Ne.filter(e=>{let t=!N||e.name.toLowerCase().includes(N.toLowerCase())||e.description.toLowerCase().includes(N.toLowerCase()),n=B===`all`||e.category===B;return t&&n}),Be=(0,D.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Oe(e);try{let r=await re.getGgufFiles(t,n);r.success&&r.data&&Ee(t=>({...t,[e]:r.data}))}catch(e){de.error(`Failed to load GGUF files:`,e)}finally{Oe(null)}}},[]),Ve=(0,D.useCallback)(e=>{U===e?Te(null):(Te(e),W[e]||Be(e))},[U,W,Be]),He=(0,D.useCallback)((e,t)=>{if(!z){f.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=T.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),f.success(`Downloaded ${t}`),p?.()},e=>{q(null),K(null),J(null),f.error(`Failed to download: ${e}`)});J(()=>n)}catch{q(null),K(null),f.error(`Failed to start download`)}}},[z,p,G,j]);(0,D.useEffect)(()=>{let e=setTimeout(()=>{P===`huggingface`?we(N):P===`ollama`&&be(N)},300);return()=>clearTimeout(e)},[N,P]),(0,D.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Z();return}if(e.key===`Tab`&&I.current){let t=Array.from(I.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)},[Z,M]),(0,D.useEffect)(()=>{M&&R.current&&R.current.focus()},[M]);let Ue=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;Z();try{let e=await T.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 T.unloadAllModels())}}catch(e){de.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},We=async e=>{if(!z){f.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=T.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),f.success(`Downloaded ${e}`),p?.()},e=>{q(null),K(null),J(null),f.error(`Failed to download: ${e}`)});J(()=>t)}catch{q(null),K(null),f.error(`Failed to start download`)}}},Ge=()=>{Ae&&(Ae(),J(null),K(null),q(null),f.success(`Download cancelled`))},Ke=t=>e.some(e=>ie(e)&&(e.name===t||e.name.startsWith(t+`:`))),Q=e=>e.isLegacySelection?(0,O.jsx)(g,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,O.jsx)(h,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,O.jsx)(C,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),$=e=>b?b(e):e.isLegacySelection?`${e.name} (${j(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.name),qe=e=>e.isLegacySelection?e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):j(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${j(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,O.jsxs)(`div`,{className:E(`relative`,o),ref:me,children:[(0,O.jsxs)(`button`,{ref:L,"data-testid":ne,type:`button`,onClick:()=>!s&&fe(!M),disabled:s,"aria-haspopup":`dialog`,"aria-expanded":M,"aria-label":A&&X?`${A}: ${$(X)}`:A,className:E(c?`h-9 sm:h-10 px-2.5 flex items-center justify-between text-start w-full`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`border border-black/[0.06] bg-gray-100/70 dark:border-white/[0.06] dark:bg-dark-300/70`,`rounded-xl text-sm hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,s?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:c?X?x?.(X)??$(X):j(`modelSelector.selectModel`):void 0,children:[(()=>{if(!X)return c?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(v,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:j(`modelSelector.selectModel`)})]}):j(`modelSelector.selectModel`);if(c){let e=$(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=$(X),t=qe(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,O.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),X.isPersona&&r&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,O.jsx)(g,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,O.jsx)(d,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,O.jsx)(ee,{className:E(c?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0 transition-transform duration-150`,M&&`rotate-180`)})]}),M&&(0,se.createPortal)((0,O.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Z()}),(0,O.jsxs)(`div`,{ref:I,role:`dialog`,"aria-modal":`true`,"aria-label":j(`modelSelector.selectModel`),className:E(`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,O.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:j(`modelSelector.selectModel`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Z(),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:j(`common.close`),children:(0,O.jsx)(y,{className:`h-4 w-4`})})]}),(0,O.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(l,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{ref:R,type:`text`,placeholder:j(P===`installed`?`modelSelector.searchInstalled`:P===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:N,onChange:e=>pe(e.target.value),className:E(`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,O.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,O.jsxs)(`button`,{onClick:()=>{F(`installed`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`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":P===`installed`,children:[(0,O.jsx)(te,{className:`h-4 w-4 inline me-1.5`}),j(`modelSelector.installed`)]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`ollama`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`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":P===`ollama`,children:[(0,O.jsx)(m,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`huggingface`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`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":P===`huggingface`,children:[(0,O.jsx)(C,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),P===`installed`&&(0,O.jsx)(le,{filteredGroups:Me,selectedModel:t,showImageGen:u,getModelValue:Y,getModelIcon:Q,getModelLabel:$,getModelSubLabel:qe,onModelSelect:Ue,onOpenGallery:()=>{Z(!1),he(`/gallery`)}}),P===`ollama`&&(0,O.jsx)(ue,{libraryCategories:je,libraryCategory:B,canInstallModels:z,loadingLibrary:Pe,filteredLibraryModels:ze,pullingModel:G,pullProgress:ke,setLibraryCategory:ve,isModelInstalled:Ke,onModelSelect:Ue,onPullModel:We,onCancelPull:Ge,onRefreshLibrary:()=>{Fe()}}),P===`huggingface`&&(0,O.jsx)(ce,{hfTask:V,hfSort:H,canInstallModels:z,loadingHf:Le,hfModels:Ie,expandedHfModel:U,hfGgufFiles:W,loadingGguf:De,pullingModel:G,pullProgress:ke,setHfTask:xe,setHfSort:Se,onToggleHfModel:Ve,onPullHfGguf:He,onCancelPull:Ge,onRefreshHfModels:()=>{Re()}})]})]}),document.body),(0,O.jsx)(`select`,{"data-testid":k,"aria-label":A,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,O.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})};export{A as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{n as r}from"./react-vendor-DPNXrO-8.js";import{d as i}from"./router-vendor-Ca9zqOqT.js";import{t as a}from"./useTranslation-CdeLZqSW.js";import{B as o,Bt as s,Ht as c,P as l,R as u,T as d,Tn as f,Wt as p,Yt as m,an as ee,c as h,dn as g,gt as _,hn as v,n as y,on as b,ot as x,pt as S,t as C,v as w,vt as te}from"./ui-vendor-D_pYT79f.js";import{t as ne}from"./logger-DSXjF4ye.js";import{_ as re,p as T}from"./api-CI1Inz7g.js";import{t as E}from"./utils-BhpNrGnR.js";import{s as ie}from"./chatStore-BaX22w_g.js";import{n as ae}from"./authStore-D-d7UIpv.js";import{u as oe}from"../assets/index-BA116EVY.js";var D=e(n(),1),se=r(),O=t();function k(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function ce({hfTask:e,hfSort:t,canInstallModels:n,loadingHf:r,hfModels:i,expandedHfModel:o,hfGgufFiles:l,loadingGguf:d,pullingModel:f,pullProgress:p,setHfTask:m,setHfSort:h,onToggleHfModel:g,onPullHfGguf:v,onCancelPull:b,onRefreshHfModels:S}){let{t:w}=a();return(0,O.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0 space-y-2`,children:(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsxs)(`select`,{value:e,onChange:e=>m(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,O.jsx)(`option`,{value:`text-generation`,children:w(`modelManager.huggingface.taskTextGeneration`)}),(0,O.jsx)(`option`,{value:`text-to-speech`,children:w(`modelManager.huggingface.taskTextToSpeech`)}),(0,O.jsx)(`option`,{value:`text-to-image`,children:w(`modelManager.huggingface.taskTextToImage`)}),(0,O.jsx)(`option`,{value:`automatic-speech-recognition`,children:w(`modelManager.huggingface.taskSpeechRecognition`)})]}),(0,O.jsxs)(`select`,{value:t,onChange:e=>h(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,O.jsx)(`option`,{value:`downloads`,children:w(`modelManager.huggingface.sortDownloads`)}),(0,O.jsx)(`option`,{value:`likes`,children:w(`modelManager.huggingface.sortLikes`)}),(0,O.jsx)(`option`,{value:`lastModified`,children:w(`modelManager.huggingface.sortRecent`)})]})]})}),(0,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.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:w(`modelSelector.pullRestricted`)}),r?(0,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(x,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(C,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:w(`modelManager.huggingface.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=o===e.id,r=l[e.id]||[],i=d===e.id;return(0,O.jsxs)(`div`,{className:`bg-white dark:bg-dark-100`,children:[(0,O.jsx)(`div`,{className:`px-3 py-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-dark-200`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),g(e.id)},children:(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`flex-shrink-0 rounded-lg bg-yellow-500/20 p-2 dark:bg-yellow-900/30`,children:(0,O.jsx)(C,{className:`h-4 w-4 text-yellow-600 dark:text-yellow-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.id}),e.gated&&(0,O.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,O.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[`by `,e.author]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-3 mt-1.5 text-xs text-gray-400 dark:text-gray-500`,children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(c,{className:`h-3 w-3`}),k(e.downloads)]}),(0,O.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,O.jsx)(_,{className:`h-3 w-3`}),k(e.likes)]}),e.pipeline_tag&&(0,O.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-gray-100 dark:bg-dark-200`,children:e.pipeline_tag})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,O.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,O.jsx)(s,{className:`h-4 w-4 text-gray-400`})}),(0,O.jsx)(ee,{className:E(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]})}),t&&(0,O.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,O.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,O.jsx)(x,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,O.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:w(`modelManager.huggingface.checkingGguf`)})]}):r.length===0?(0,O.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:w(`modelManager.huggingface.noGgufAvailable`)}):(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:w(`modelManager.huggingface.ggufFilesCount`,{count:r.length})}),r.map(e=>{let t=f===e.ollamaCommand;return(0,O.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,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,O.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,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:p?.percent===void 0?`...`:`${p.percent}%`}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),b()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(y,{className:`h-4 w-4`})})]}):n?(0,O.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),v(e.ollamaCommand,e.filename)},disabled:!!f,className:E(`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,O.jsx)(c,{className:`h-3 w-3 inline mr-1`}),w(`models.pull`)]}):(0,O.jsx)(`span`,{className:`rounded bg-amber-500/20 px-2 py-1 text-[11px] font-medium text-ink dark:bg-amber-900/30`,children:w(`modelSelector.adminOnlyPull`)})]},e.filename)}),f?.startsWith(`hf.co/`)&&f.includes(e.id)&&p?.percent!==void 0&&(0,O.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${p.percent}%`}})})]})})]},e.id)})})]}),(0,O.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,O.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,O.jsx)(s,{className:`h-3 w-3`}),w(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),S()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(u,{className:E(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}function le({filteredGroups:e,selectedModel:t,showImageGen:n,getModelValue:r,getModelIcon:i,getModelLabel:s,getModelSubLabel:c,onModelSelect:l,onOpenGallery:u}){let{t:d}=a();return(0,O.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,O.jsxs)(`div`,{children:[(0,O.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,O.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,O.jsx)(`button`,{type:`button`,"data-testid":`model-selector-option`,"data-model-value":n,"aria-pressed":t===n,onClick:()=>l(n),className:E(`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,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i(e),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsx)(`div`,{dir:e.isPersona?`auto`:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:s(e)}),c(e)&&(0,O.jsx)(`div`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:c(e)})]}),t===n&&(0,O.jsx)(b,{className:`h-4 w-4 text-primary-600 dark:text-primary-400 flex-shrink-0`})]})},n)})]},e.type)):(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(p,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:d(`models.noModelsFound`)})]}),n&&(0,O.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-dark-300`,children:[(0,O.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,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),d(`modelSelector.actions`)]})}),(0,O.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,O.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,O.jsx)(S,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:d(`gallery.generate`)}),(0,O.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:d(`gallery.generateDescription`)})]})]})})]})]})}function ue({libraryCategories:e,libraryCategory:t,canInstallModels:n,loadingLibrary:r,filteredLibraryModels:i,pullingModel:o,pullProgress:l,setLibraryCategory:d,isModelInstalled:f,onModelSelect:p,onPullModel:ee,onCancelPull:h,onRefreshLibrary:g}){let{t:_}=a();return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[(0,O.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-dark-300 flex-shrink-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,O.jsx)(`button`,{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),d(e)},className:E(`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,O.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 scrollbar-thin`,children:[!n&&(0,O.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,O.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,O.jsx)(x,{className:`h-6 w-6 animate-spin text-gray-400`})}):i.length===0?(0,O.jsxs)(`div`,{className:`px-4 py-8 text-center text-gray-500 dark:text-gray-400`,children:[(0,O.jsx)(m,{className:`h-8 w-8 mx-auto mb-2 text-gray-300 dark:text-gray-600`}),(0,O.jsx)(`p`,{className:`text-sm`,children:_(`models.noModelsFound`)})]}):(0,O.jsx)(`div`,{className:`divide-y divide-gray-100 dark:divide-dark-200`,children:i.map(e=>{let t=f(e.name),r=o===e.name;return(0,O.jsxs)(`div`,{className:E(`px-3 py-3 bg-white dark:bg-dark-100`,t&&`bg-green-50/50 dark:bg-green-900/10`),children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,O.jsx)(`div`,{className:`p-2 rounded-lg bg-blue-100 dark:bg-blue-900/30 flex-shrink-0`,children:(0,O.jsx)(m,{className:`h-4 w-4 text-blue-600 dark:text-blue-400`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h4`,{dir:`ltr`,className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:e.name}),t&&(0,O.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,O.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,O.jsx)(m,{className:`h-3 w-3`}),`Cloud`]})]}),(0,O.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 line-clamp-1 mt-0.5`,children:e.description}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[e.sizes.slice(0,3).map(e=>(0,O.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,O.jsxs)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500 flex items-center gap-1`,children:[(0,O.jsx)(c,{className:`h-3 w-3`}),e.pulls]})]})]}),(0,O.jsx)(`div`,{className:`flex-shrink-0`,children:r?(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:l?.percent===void 0?`...`:`${l.percent}%`}),(0,O.jsx)(`button`,{onClick:h,className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,O.jsx)(y,{className:`h-4 w-4`})})]}):t?(0,O.jsx)(`button`,{onClick:()=>p(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,O.jsxs)(`button`,{onClick:()=>ee(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,O.jsx)(c,{className:`h-3 w-3 inline mr-1`}),_(`modelSelector.pull`)]}):(0,O.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&&l?.percent!==void 0&&(0,O.jsx)(`div`,{className:`mt-2 w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden`,children:(0,O.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${l.percent}%`}})})]},e.name)})})]}),(0,O.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,O.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,O.jsx)(s,{className:`h-3 w-3`}),_(`modelManager.huggingface.browseAllLink`)]}),(0,O.jsx)(`button`,{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),g()},className:`p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,O.jsx)(u,{className:E(`h-3.5 w-3.5 text-gray-400`,r&&`animate-spin`)})})]})]})}var de=ne(`components:model-selector`),A=({models:e,selectedModel:t,onModelChange:n,currentPersona:r,className:o,disabled:s=!1,compact:c=!1,showImageGen:u=!1,onModelsRefresh:p,getModelValue:_,getModelLabel:b,getModelTitle:x,triggerRef:S,triggerTestId:ne,selectTestId:k,ariaLabel:A})=>{let{t:j}=a(),[M,fe]=(0,D.useState)(!1),[N,pe]=(0,D.useState)(``),[P,F]=(0,D.useState)(`installed`),me=(0,D.useRef)(null),I=(0,D.useRef)(null),L=(0,D.useRef)(null),R=(0,D.useRef)(null),he=i(),{user:ge,systemInfo:_e}=ae(),z=ge?.role===`admin`||_e?.requiresAuth===!1,[B,ve]=(0,D.useState)(`all`),[ye,be]=(0,D.useState)(``),[V,xe]=(0,D.useState)(`text-generation`),[H,Se]=(0,D.useState)(`downloads`),[Ce,we]=(0,D.useState)(``),[U,Te]=(0,D.useState)(null),[W,Ee]=(0,D.useState)({}),[De,Oe]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[ke,q]=(0,D.useState)(null),[Ae,J]=(0,D.useState)(null),je=[`all`,`general`,`coding`,`reasoning`,`vision`,`embedding`,`cloud`],Me=[{type:`legacy`,label:j(`modelSelector.providerNotRecorded`,`Provider not recorded`),icon:(0,O.jsx)(g,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>e.isLegacySelection),color:`gray`},{type:`unavailable`,label:j(`modelSelector.unavailableSelections`,`Unavailable selections`),icon:(0,O.jsx)(y,{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:j(`modelSelector.personas`),icon:(0,O.jsx)(h,{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:j(`modelSelector.agentModels`,`Agents`),icon:(0,O.jsx)(w,{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:j(`modelSelector.ollamaModels`),icon:(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),models:e.filter(e=>ie(e)&&!e.name.includes(`embed`)),color:`green`},{type:`plugins`,label:j(`modelSelector.pluginModels`),icon:(0,O.jsx)(C,{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(N.toLowerCase())||e.personaName&&e.personaName.toLowerCase().includes(N.toLowerCase())||e.pluginName&&e.pluginName.toLowerCase().includes(N.toLowerCase()))})).filter(e=>e.models.length>0),Y=e=>_?.(e)??e.name,X=e.find(e=>Y(e)===t);(0,D.useImperativeHandle)(S,()=>L.current);let Z=(0,D.useCallback)((e=!0)=>{fe(!1),pe(``),e&&window.requestAnimationFrame(()=>L.current?.focus())},[]),{data:Ne=[],isLoading:Pe,refetch:Fe}=oe({queryKey:[`ollama-library-selector`,ye,B===`cloud`?`cloud`:`all`],queryFn:async()=>{let e=await T.getLibraryModels({search:ye||void 0,sort:`popular`,category:B===`cloud`?`cloud`:void 0});return e.success&&e.data?e.data:[]},enabled:M&&P===`ollama`}),{data:Ie=[],isLoading:Le,refetch:Re}=oe({queryKey:[`hf-models-selector`,V,Ce,H],queryFn:async()=>{let e=await re.getModels({task:V,search:Ce||void 0,sort:H,limit:30});return e.success&&e.data?e.data:[]},enabled:M&&P===`huggingface`}),ze=Ne.filter(e=>{let t=!N||e.name.toLowerCase().includes(N.toLowerCase())||e.description.toLowerCase().includes(N.toLowerCase()),n=B===`all`||e.category===B;return t&&n}),Be=(0,D.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Oe(e);try{let r=await re.getGgufFiles(t,n);r.success&&r.data&&Ee(t=>({...t,[e]:r.data}))}catch(e){de.error(`Failed to load GGUF files:`,e)}finally{Oe(null)}}},[]),Ve=(0,D.useCallback)(e=>{U===e?Te(null):(Te(e),W[e]||Be(e))},[U,W,Be]),He=(0,D.useCallback)((e,t)=>{if(!z){f.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let n=T.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),f.success(`Downloaded ${t}`),p?.()},e=>{q(null),K(null),J(null),f.error(`Failed to download: ${e}`)});J(()=>n)}catch{q(null),K(null),f.error(`Failed to start download`)}}},[z,p,G,j]);(0,D.useEffect)(()=>{let e=setTimeout(()=>{P===`huggingface`?we(N):P===`ollama`&&be(N)},300);return()=>clearTimeout(e)},[N,P]),(0,D.useEffect)(()=>{if(!M)return;let e=e=>{if(e.key===`Escape`){e.preventDefault(),Z();return}if(e.key===`Tab`&&I.current){let t=Array.from(I.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)},[Z,M]),(0,D.useEffect)(()=>{M&&R.current&&R.current.focus()},[M]);let Ue=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;Z();try{let e=await T.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 T.unloadAllModels())}}catch(e){de.warn(`Failed to unload models before switch:`,e)}n({target:{value:i}})},We=async e=>{if(!z){f.error(j(`modelSelector.pullRestricted`));return}if(!G){K(e),q({status:`starting`});try{let t=T.pullModelStream(e,e=>{q(e)},()=>{q(null),K(null),J(null),f.success(`Downloaded ${e}`),p?.()},e=>{q(null),K(null),J(null),f.error(`Failed to download: ${e}`)});J(()=>t)}catch{q(null),K(null),f.error(`Failed to start download`)}}},Ge=()=>{Ae&&(Ae(),J(null),K(null),q(null),f.success(`Download cancelled`))},Ke=t=>e.some(e=>ie(e)&&(e.name===t||e.name.startsWith(t+`:`))),Q=e=>e.isLegacySelection?(0,O.jsx)(g,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPersona?(0,O.jsx)(h,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):e.isPlugin?(0,O.jsx)(C,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}):(0,O.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-600`}),$=e=>b?b(e):e.isLegacySelection?`${e.name} (${j(`modelSelector.legacyProvider`,`provider not recorded`)})`:e.isPersona?e.personaName||e.name:e.isAgent?e.isUnavailable?`${e.agentName||e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.agentName||e.name:(e.isPlugin,e.isUnavailable?`${e.name} (${j(`modelSelector.unavailable`,`unavailable`)})`:e.name),qe=e=>e.isLegacySelection?e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):j(`modelSelector.reselectProvider`,`reselect a provider to pin this model`):e.isPersona?`via ${e.model}`:e.isPlugin?e.isUnavailable?`via ${e.pluginName||e.pluginId} · ${j(`modelSelector.providerUnavailable`,`provider unavailable`)}`:`via ${e.pluginName}`:e.isUnavailable?j(`modelSelector.providerUnavailable`,`provider unavailable`):null;return(0,O.jsxs)(`div`,{className:E(`relative`,o),ref:me,children:[(0,O.jsxs)(`button`,{ref:L,"data-testid":ne,type:`button`,onClick:()=>!s&&fe(!M),disabled:s,"aria-haspopup":`dialog`,"aria-expanded":M,"aria-label":A&&X?`${A}: ${$(X)}`:A,className:E(c?`h-9 sm:h-10 px-2.5 flex items-center justify-between text-start w-full`:`w-full flex items-center justify-between gap-2 px-3 py-2.5 text-start`,`border border-black/[0.06] bg-gray-100/70 dark:border-white/[0.06] dark:bg-dark-300/70`,`rounded-xl text-sm hover:bg-gray-100 dark:hover:bg-dark-300`,`transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500/40`,s?`opacity-50 cursor-not-allowed`:`cursor-pointer`),title:c?X?x?.(X)??$(X):j(`modelSelector.selectModel`):void 0,children:[(()=>{if(!X)return c?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,O.jsx)(v,{className:`h-4 w-4`}),(0,O.jsx)(`span`,{className:`text-xs font-medium text-gray-400 dark:text-gray-500 truncate`,children:j(`modelSelector.selectModel`)})]}):j(`modelSelector.selectModel`);if(c){let e=$(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-xs font-medium text-gray-700 dark:text-gray-200 truncate`,children:e})]})}let e=$(X),t=qe(X);return(0,O.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[Q(X),(0,O.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,O.jsx)(`span`,{dir:X.isPersona?`auto`:`ltr`,className:`text-sm font-medium truncate`,children:e}),t&&(0,O.jsx)(`span`,{dir:`auto`,className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t})]}),X.isPersona&&r&&(0,O.jsxs)(`div`,{className:`flex items-center gap-1 ms-auto`,children:[(0,O.jsx)(g,{className:`h-3 w-3 text-gray-500 dark:text-dark-600`}),r.embedding_model&&(0,O.jsx)(d,{className:`h-3 w-3 text-gray-400 dark:text-dark-500`})]})]})})(),(0,O.jsx)(ee,{className:E(c?`h-3 w-3`:`h-4 w-4`,`text-gray-400 flex-shrink-0 transition-transform duration-150`,M&&`rotate-180`)})]}),M&&(0,se.createPortal)((0,O.jsxs)(`div`,{className:`fixed inset-0 z-[999999] flex items-center justify-center p-3 sm:p-6`,children:[(0,O.jsx)(`div`,{className:`absolute inset-0 bg-gray-950/55 backdrop-blur-md`,onClick:()=>Z()}),(0,O.jsxs)(`div`,{ref:I,role:`dialog`,"aria-modal":`true`,"aria-label":j(`modelSelector.selectModel`),className:E(`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,O.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4 sm:px-5 sm:pt-5`,children:[(0,O.jsx)(`h2`,{className:`text-lg font-medium tracking-[-0.025em] text-gray-950 dark:text-dark-950 rtl:tracking-normal`,children:j(`modelSelector.selectModel`)}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>Z(),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:j(`common.close`),children:(0,O.jsx)(y,{className:`h-4 w-4`})})]}),(0,O.jsx)(`div`,{className:`px-4 pb-3 sm:px-5`,children:(0,O.jsxs)(`div`,{className:`relative`,children:[(0,O.jsx)(l,{className:`absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,O.jsx)(`input`,{ref:R,type:`text`,placeholder:j(P===`installed`?`modelSelector.searchInstalled`:P===`ollama`?`modelSelector.searchOllama`:`modelSelector.searchHuggingFace`),value:N,onChange:e=>pe(e.target.value),className:E(`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,O.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,O.jsxs)(`button`,{onClick:()=>{F(`installed`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`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":P===`installed`,children:[(0,O.jsx)(te,{className:`h-4 w-4 inline me-1.5`}),j(`modelSelector.installed`)]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`ollama`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`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":P===`ollama`,children:[(0,O.jsx)(m,{className:`h-4 w-4 inline me-1.5`}),`Ollama`]}),(0,O.jsxs)(`button`,{onClick:()=>{F(`huggingface`)},className:E(`flex-1 rounded-lg px-2 py-2 text-xs font-medium transition-colors sm:px-4`,P===`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":P===`huggingface`,children:[(0,O.jsx)(C,{className:`h-4 w-4 inline me-1.5`}),`HuggingFace`]})]})]}),P===`installed`&&(0,O.jsx)(le,{filteredGroups:Me,selectedModel:t,showImageGen:u,getModelValue:Y,getModelIcon:Q,getModelLabel:$,getModelSubLabel:qe,onModelSelect:Ue,onOpenGallery:()=>{Z(!1),he(`/gallery`)}}),P===`ollama`&&(0,O.jsx)(ue,{libraryCategories:je,libraryCategory:B,canInstallModels:z,loadingLibrary:Pe,filteredLibraryModels:ze,pullingModel:G,pullProgress:ke,setLibraryCategory:ve,isModelInstalled:Ke,onModelSelect:Ue,onPullModel:We,onCancelPull:Ge,onRefreshLibrary:()=>{Fe()}}),P===`huggingface`&&(0,O.jsx)(ce,{hfTask:V,hfSort:H,canInstallModels:z,loadingHf:Le,hfModels:Ie,expandedHfModel:U,hfGgufFiles:W,loadingGguf:De,pullingModel:G,pullProgress:ke,setHfTask:xe,setHfSort:Se,onToggleHfModel:Ve,onPullHfGguf:He,onCancelPull:Ge,onRefreshHfModels:()=>{Re()}})]})]}),document.body),(0,O.jsx)(`select`,{"data-testid":k,"aria-label":A,"aria-hidden":`true`,dir:`ltr`,value:t,onChange:n,className:`hidden`,tabIndex:-1,children:e.map(e=>(0,O.jsx)(`option`,{value:Y(e),children:$(e)},`${e.isLegacySelection?`legacy`:e.isPersona?`persona`:e.isPlugin?`plugin`:`ollama`}:${e.pluginId||``}:${Y(e)}`))})]})};export{A as t};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-D9j9RECi.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-DHnR5Hw8.js","js/react-vendor-DPNXrO-8.js","js/useTranslation-CdeLZqSW.js","js/ui-vendor-D_pYT79f.js","js/utils-BhpNrGnR.js","js/utils-vendor-1zob7nK9.js","js/Button-X9TT9gTD.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{i as r}from"./router-vendor-Ca9zqOqT.js";import{t as i}from"./useTranslation-CdeLZqSW.js";import{A as a,Bt as o,Et as s,Gt as c,Ht as l,Lt as u,M as d,P as f,R as p,Sn as m,Tn as h,Tt as ee,Wt as g,Xt as _,Yt as v,_ as te,_t as y,an as b,ft as x,gt as S,lt as C,m as w,n as T,nn as E,nt as ne,on as D,ot as re,t as ie,vt as O}from"./ui-vendor-D_pYT79f.js";import{t as ae}from"./logger-DSXjF4ye.js";import{_ as oe,p as k}from"./api-DVP8xiYT.js";import{t as A}from"./utils-BhpNrGnR.js";import{n as se}from"./authStore-gv_MgDKr.js";import{t as j}from"./Button-X9TT9gTD.js";import{n as ce,t as le}from"./ui-DDlcz2oy.js";import{f as ue,u as M}from"../assets/index-_lG_lwU-.js";var N=e(n(),1),P=t();function de({expanded:e,models:t,search:n,task:r,sort:a,loadingModels:s,canInstallModels:c,expandedModelId:l,loadingGgufModelId:u,ggufFiles:d,pullingModel:m,pullProgress:h,setSearch:ee,setTask:g,setSort:_,onToggle:v,onToggleModel:te,onPullGguf:y,onCancelPull:x,onRefresh:S}){let{t:C}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:v,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(ie,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:C(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,P.jsxs)(`span`,{className:A(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,C(`modelManager.library.available`,`available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(f,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:n,onChange:e=>ee(e.target.value),placeholder:C(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:A(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`select`,{value:r,onChange:e=>g(e.target.value),className:A(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`text-generation`,children:C(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,P.jsx)(`option`,{value:`text-to-speech`,children:C(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,P.jsx)(`option`,{value:`text-to-image`,children:C(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,P.jsx)(`option`,{value:`automatic-speech-recognition`,children:C(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,P.jsxs)(`select`,{value:a,onChange:e=>_(e.target.value),className:A(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`downloads`,children:C(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,P.jsx)(`option`,{value:`likes`,children:C(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,P.jsx)(`option`,{value:`lastModified`,children:C(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!c&&(0,P.jsx)(`p`,{className:`text-xs text-ink`,children:C(`modelManager.pull.restricted`)}),s?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(re,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:C(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,P.jsx)(fe,{model:e,expanded:l===e.id,loadingGguf:u===e.id,ggufFiles:d[e.id]||[],pullingModel:m,pullProgress:h,canInstallModels:c,onToggle:()=>te(e.id),onPullGguf:y,onCancelPull:x},e.id))}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,P.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:A(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(o,{className:`h-3 w-3`}),C(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,P.jsxs)(j,{onClick:S,variant:`outline`,size:`sm`,disabled:s,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(p,{className:A(`h-3.5 w-3.5`,s&&`animate-spin`)}),C(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function fe({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:a,pullProgress:s,canInstallModels:c,onToggle:u,onPullGguf:d,onCancelPull:f}){let{t:p}=i();return(0,P.jsxs)(`div`,{className:A(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:u,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-500/20 dark:bg-yellow-900/30`,`text-ink`),children:p(`modelManager.huggingface.gated`,`Gated`)})]}),(0,P.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[p(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,P.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:p(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,P.jsx)(o,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,P.jsx)(b,{className:A(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(l,{className:`h-3.5 w-3.5`}),F(e.downloads)]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(S,{className:`h-3.5 w-3.5`}),F(e.likes)]}),e.pipeline_tag&&(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,P.jsx)(pe,{modelId:e.id,loading:n,files:r,pullingModel:a,pullProgress:s,canInstallModels:c,onPullGguf:d,onCancelPull:f})]})}function pe({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:a,canInstallModels:o,onPullGguf:s,onCancelPull:c}){let{t:l}=i();return(0,P.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,P.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,P.jsx)(re,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,P.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:l(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,P.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:l(`modelManager.huggingface.noGgufAvailable`)}):(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:l(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,P.jsx)(me,{file:e,pulling:r===e.ollamaCommand,pullProgress:a,canInstallModels:o,disabled:!!r||!o,onPullGguf:s,onCancelPull:c},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&a?.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,P.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${a.percent}%`}})})]})})}function me({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:a,onCancelPull:o}){let{t:s}=i();return(0,P.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,P.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,P.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,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,P.jsx)(`button`,{onClick:e=>{e.stopPropagation(),o()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,P.jsx)(T,{className:`h-4 w-4`})})]}):(0,P.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),a(e.ollamaCommand,e.filename)},disabled:n,className:A(`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,P.jsx)(l,{className:`h-3 w-3 inline mr-1`}),s(`models.pull`)]})]})}function F(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function he({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:a,onShowModel:o,onCopyModel:s,onDeleteModel:c}){let{t:l}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:n,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:l(`modelManager.sections.local`)}),(0,P.jsxs)(`span`,{className:A(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,l(`modelManager.local.installed`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,P.jsxs)(`div`,{className:A(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsx)(O,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,P.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:l(`modelManager.local.noModels`)}),(0,P.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:l(`modelManager.local.pullToStart`)})]}):(0,P.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,P.jsx)(ge,{model:e,running:r(e.name),formatSize:a,onShowModel:o,onCopyModel:s,onDeleteModel:c},e.name))})})]})}function ge({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:a,onDeleteModel:o}){let{t:s}=i();return(0,P.jsx)(`div`,{className:A(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:A(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),s(`modelManager.local.running`)]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(O,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(g,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,P.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(_,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,P.jsx)(y,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,P.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,P.jsxs)(j,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(x,{className:`h-3.5 w-3.5`}),s(`modelManager.local.info`)]}),(0,P.jsxs)(j,{onClick:()=>a(e.name),variant:`outline`,size:`sm`,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(c,{className:`h-3.5 w-3.5`}),s(`modelManager.local.copy`)]}),(0,P.jsxs)(j,{onClick:()=>o(e.name),variant:`outline`,size:`sm`,className:A(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(w,{className:`h-3.5 w-3.5`}),s(`modelManager.local.delete`)]})]})]})})}function _e({expanded:e,models:t,totalAvailable:n,categories:r,filter:a,search:o,loading:c,pulling:l,canInstallModels:u,pullSectionExpanded:d,setFilter:m,setSearch:h,isModelInstalled:ee,normalizeCloudPullName:g,onToggle:_,onTogglePullSection:te,onPullModel:y,onRefresh:x}){let{t:S}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:_,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:S(`modelManager.sections.library`)}),(0,P.jsxs)(`span`,{className:A(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,S(`modelManager.library.available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(f,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:o,onChange:e=>h(e.target.value),placeholder:S(`modelManager.library.search`),className:A(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,P.jsx)(`button`,{onClick:()=>m(e),className:A(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,a===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))})]})]}),c?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(p,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:S(`modelManager.library.noResults`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?g(e.name):e.name,n=ee(e.name)||ee(t);return(0,P.jsx)(I,{model:e,installed:n,pulling:l,canInstallModels:u,pullSectionExpanded:d,onTogglePullSection:te,onPullModel:y},e.name)})}),(0,P.jsx)(`div`,{className:`flex justify-center`,children:(0,P.jsxs)(j,{onClick:x,variant:`outline`,size:`sm`,disabled:c,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(p,{className:A(`h-3.5 w-3.5`,c&&`animate-spin`)}),S(`modelManager.library.refresh`)]})})]})]})}function I({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:a,onTogglePullSection:o,onPullModel:s}){let{t:c}=i();return(0,P.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:A(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:A(`flex items-center gap-1 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:[(0,P.jsx)(D,{className:`h-3 w-3`}),c(`modelManager.library.installed`)]})]}),(0,P.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,P.jsx)(`span`,{className:`text-xs text-gray-400`,children:c(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(l,{className:`h-3 w-3`}),e.pulls]}),(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,P.jsxs)(j,{"data-testid":`library-model-install-${e.name}`,onClick:()=>{a||o(),s(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:A(`gap-1 text-xs`,``,``),children:[(0,P.jsx)(l,{className:`h-3 w-3`}),c(`modelManager.pull.button`)]})]})]})}function ve({expanded:e,modelName:t,setModelName:n,pulling:r,progress:a,canInstallModels:s,popularModels:c,onToggle:u,onPull:d,onCancelPull:p,formatSize:m}){let{t:h}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:u,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(l,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:h(`modelManager.sections.pull`)})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(f,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:h(`modelManager.pull.placeholder`),className:A(`w-full rounded-xl border py-2.5 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!s,onKeyDown:e=>{e.key===`Enter`&&!r&&s&&d()}})]}),r?(0,P.jsxs)(j,{onClick:p,variant:`outline`,className:A(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(T,{className:`h-4 w-4`}),h(`modelManager.pull.cancel`)]}):(0,P.jsxs)(j,{onClick:d,disabled:!t.trim()||!s,className:A(`px-4 py-2.5 gap-2`,``),children:[(0,P.jsx)(l,{className:`h-4 w-4`}),h(`modelManager.pull.button`)]})]}),r&&a&&(0,P.jsx)(L,{progress:a,formatSize:m}),!s&&(0,P.jsx)(`p`,{className:`text-xs text-ink-muted`,children:h(`modelManager.pull.restricted`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:h(`modelManager.pull.popular`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.map(e=>(0,P.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!s,className:A(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,P.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},e.name))})]}),(0,P.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:A(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(o,{className:`h-3 w-3`}),h(`modelManager.pull.browseAll`)]})]})]})}function L({progress:e,formatSize:t}){let{t:n}=i(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,P.jsxs)(`div`,{className:A(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,P.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,P.jsx)(`div`,{className:A(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,P.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}var ye=ae(`components:model-manager`),be=N.lazy(()=>r(()=>import(`./ModelManagerModals-D9j9RECi.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),R=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},xe=e=>{let t=e.trim();if(!t||R(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},z=()=>{let{t:e}=i(),{user:t,systemInfo:n}=se(),r=t?.role===`admin`||n?.requiresAuth===!1,o=ue(),[s,l]=(0,N.useState)(`all`),[f,g]=(0,N.useState)(``),[_,v]=(0,N.useState)(``),[y,x]=(0,N.useState)(!1),[S,w]=(0,N.useState)(null),[T,D]=(0,N.useState)(null),[re,ae]=(0,N.useState)(null),[ce,le]=(0,N.useState)(``),[fe,pe]=(0,N.useState)(!1),[me,F]=(0,N.useState)(!1),[ge,I]=(0,N.useState)(!1),[L,R]=(0,N.useState)(``),[z,B]=(0,N.useState)(``),[Se,Ce]=(0,N.useState)(!1),[we,Te]=(0,N.useState)(!1),[V,Ee]=(0,N.useState)(``),[De,Oe]=(0,N.useState)(``),[ke,Ae]=(0,N.useState)(!1),[je,Me]=(0,N.useState)(!1),[Ne,Pe]=(0,N.useState)(``),[Fe,Ie]=(0,N.useState)(``),[Le,Re]=(0,N.useState)(null),[ze,Be]=(0,N.useState)(!1),[Ve,He]=(0,N.useState)(``),[Ue,We]=(0,N.useState)(``),[H,Ge]=(0,N.useState)(`text-generation`),[U,Ke]=(0,N.useState)(`downloads`),[qe,Je]=(0,N.useState)(null),[Ye,Xe]=(0,N.useState)({}),[Ze,Qe]=(0,N.useState)(null),[$e,W]=(0,N.useState)(null),[et,G]=(0,N.useState)(null),[tt,K]=(0,N.useState)(null),[q,nt]=(0,N.useState)(new Set([`pull`,`local`])),J=e=>{nt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:rt,isLoading:it,refetch:at}=M({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([k.getModels(),k.listRunningModels(),k.getVersion(),k.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),Y=rt?.models??[],X=rt?.runningModels??[],ot=rt?.ollamaVersion??null,st=rt?.isHealthy??null,Z=(0,N.useCallback)(async()=>{await at()},[at]),{data:Q=[],isLoading:ct}=M({queryKey:[`ollama-library`],queryFn:async()=>{let e=await k.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:lt=[],isLoading:ut}=M({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await k.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:s===`cloud`}),dt=()=>o.invalidateQueries({queryKey:[`ollama-library`]});(0,N.useEffect)(()=>{let e=setTimeout(()=>{We(Ve)},300);return()=>clearTimeout(e)},[Ve]);let ft=q.has(`huggingface`),{data:pt=[],isLoading:mt}=M({queryKey:[`hf-models`,H,Ue,U],queryFn:async()=>{let e=await oe.getModels({task:H,search:Ue||void 0,sort:U,limit:30});return e.success&&e.data?e.data:[]},enabled:ft}),ht=()=>o.invalidateQueries({queryKey:[`hf-models`,H,Ue,U]}),gt=(0,N.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Qe(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&Xe(t=>({...t,[e]:r.data}))}catch(e){ye.error(`Failed to load GGUF files:`,e)}finally{Qe(null)}}},[]),_t=(0,N.useCallback)(e=>{qe===e?Je(null):(Je(e),Ye[e]||gt(e))},[qe,Ye,gt]),vt=(0,N.useCallback)((t,n)=>{if(!r){h.error(e(`modelManager.pull.restricted`));return}if(!$e){W(t),G({status:`starting`});try{let e=k.pullModelStream(t,e=>{G(e)},()=>{G(null),W(null),K(null),h.success(`Downloaded ${n}`),Z()},e=>{G(null),W(null),K(null),h.error(`Failed to download: ${e}`)});K(()=>e)}catch{G(null),W(null),h.error(`Failed to start download`)}}},[r,$e,Z,e]),yt=(0,N.useCallback)(()=>{tt&&(tt(),K(null),W(null),G(null))},[tt]),bt=async(t,n)=>{if(!r){h.error(e(`modelManager.pull.restricted`));return}let i=t||_.trim(),a=n===`cloud`||!t&&s===`cloud`?xe(i):i;if(!a){h.error(e(`modelManager.pull.enterName`));return}t&&v(a),x(!0),w({status:`starting`});try{let t=k.pullModelStream(a,e=>{w(e)},()=>{w(null),x(!1),D(null),h.success(e(`modelManager.pull.success`,{name:a})),v(``),Z()},t=>{w(null),x(!1),D(null),h.error(e(`modelManager.pull.failed`)+`: `+t)});D(()=>t)}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.pull.failed`)+`: `+n),w(null),x(!1),D(null)}},xt=()=>{T&&(T(),D(null),x(!1),w(null),h.success(e(`modelManager.pull.cancelled`)))},St=async t=>{if(confirm(e(`modelManager.local.deleteConfirm`,{name:t})))try{await k.deleteModel(t),h.success(e(`modelManager.local.deleteSuccess`,{name:t})),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.local.deleteFailed`)+`: `+n)}},Ct=async t=>{F(!0),le(t),pe(!0);try{let n=await k.showModel(t,!0);n.success&&n.data?ae(n.data):h.error(e(`modelManager.modals.details.noDetails`))}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.details.noDetails`)+`: `+n)}finally{F(!1)}},wt=async()=>{if(!L.trim()||!z.trim()){h.error(e(`modelManager.modals.copy.enterBoth`));return}Ce(!0);try{await k.copyModel(L.trim(),z.trim()),h.success(e(`modelManager.modals.copy.success`,{name:z})),I(!1),R(``),B(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.copy.failed`)+`: `+n)}finally{Ce(!1)}},Tt=async()=>{if(!V.trim()||!De.trim()){h.error(e(`modelManager.modals.create.enterBoth`));return}Ae(!0);try{await k.createModel({model:V.trim(),modelfile:De.trim()}),h.success(e(`modelManager.modals.create.success`,{name:V})),Te(!1),Ee(``),Oe(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.create.failed`)+`: `+n)}finally{Ae(!1)}},Et=async()=>{if(!Ne.trim()||!Fe.trim()){h.error(e(`modelManager.modals.embeddings.enterBoth`));return}Be(!0),Re(null);try{let t=await k.generateEmbeddings({model:Ne.trim(),input:Fe.trim()});if(t.success&&t.data){let n=t.data.embeddings?.[0]||[];Re(n),h.success(e(`modelManager.modals.embeddings.success`,{count:n.length}))}}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.embeddings.failed`)+`: `+n)}finally{Be(!1)}},$=e=>{let t=e/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`},Dt=e=>Array.isArray(X)&&X.some(t=>t.name===e),Ot=()=>Y.reduce((e,t)=>e+t.size,0),kt=()=>X.reduce((e,t)=>e+(t.size_vram||0),0),At=e=>Y.some(t=>t.name===e||t.name.startsWith(e+`:`)),jt=(s===`cloud`?lt:Q).filter(e=>{let t=s===`all`||s===`cloud`||e.category===s,n=!f||e.name.toLowerCase().includes(f.toLowerCase())||e.description.toLowerCase().includes(f.toLowerCase());return t&&n}),Mt=[`all`,...new Set([...Q.map(e=>e.category),`cloud`])],Nt=(0,N.useMemo)(()=>Q.length>0?Q.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`deepseek-r1`,category:`reasoning`,size:`7B`},{name:`llama3.2`,category:`general`,size:`3B`},{name:`gemma3`,category:`general`,size:`4B`},{name:`qwen2.5`,category:`general`,size:`7B`},{name:`mistral`,category:`general`,size:`7B`},{name:`codellama`,category:`coding`,size:`7B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`},{name:`llava`,category:`vision`,size:`7B`},{name:`phi3`,category:`general`,size:`3.8B`},{name:`gemma2`,category:`general`,size:`9B`}],[Q]),Pt=fe||ge||we||je;return it?(0,P.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,P.jsx)(p,{className:`h-5 w-5 animate-spin`}),e(`modelManager.loading`)]})}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(`div`,{className:A(`rounded-2xl border px-4 py-3`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:A(`w-2.5 h-2.5 rounded-full`,st?`bg-green-500`:`bg-red-500`)}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(st?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),ot&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(d,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[`v`,ot]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(O,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[Y.length,` `,Y.length===1?e(`modelManager.systemStatus.models`):e(`modelManager.systemStatus.models_plural`)]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(C,{className:`h-4 w-4`}),(0,P.jsx)(`span`,{children:$(Ot())})]}),X.length>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,P.jsx)(m,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[X.length,` `,e(`modelManager.systemStatus.running`),` (`,$(kt()),` `,e(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,P.jsxs)(j,{onClick:Z,variant:`outline`,size:`sm`,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(p,{className:`h-3.5 w-3.5`}),e(`common.refresh`)]})})]})}),(0,P.jsx)(ve,{expanded:q.has(`pull`),modelName:_,setModelName:v,pulling:y,progress:S,canInstallModels:r,popularModels:Nt,onToggle:()=>J(`pull`),onPull:()=>bt(),onCancelPull:xt,formatSize:$}),(0,P.jsx)(_e,{expanded:q.has(`library`),models:jt,totalAvailable:Q.length,categories:Mt,filter:s,search:f,loading:ct||ut,pulling:y,canInstallModels:r,pullSectionExpanded:q.has(`pull`),setFilter:l,setSearch:g,isModelInstalled:At,normalizeCloudPullName:xe,onToggle:()=>J(`library`),onTogglePullSection:()=>J(`pull`),onPullModel:bt,onRefresh:dt}),(0,P.jsx)(de,{expanded:q.has(`huggingface`),models:pt,search:Ve,task:H,sort:U,loadingModels:mt,canInstallModels:r,expandedModelId:qe,loadingGgufModelId:Ze,ggufFiles:Ye,pullingModel:$e,pullProgress:et,setSearch:He,setTask:Ge,setSort:Ke,onToggle:()=>J(`huggingface`),onToggleModel:_t,onPullGguf:vt,onCancelPull:yt,onRefresh:ht}),Array.isArray(X)&&X.length>0&&(0,P.jsxs)(`div`,{className:A(`rounded-2xl border p-4`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,P.jsx)(m,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.running`)}),(0,P.jsxs)(`span`,{className:A(`ms-auto rounded-full px-2 py-0.5 text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[X.length,` `,e(`modelManager.systemStatus.running`)]})]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:X.map(t=>(0,P.jsxs)(`div`,{className:A(`flex items-center justify-between p-4 rounded-lg border`,`bg-white/50 dark:bg-white/[0.025]`,`border-gray-200/80 dark:border-white/[0.08]`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`div`,{className:A(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:t.name}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-gray-500 dark:text-dark-500`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(ne,{className:`h-3 w-3`}),e(`modelManager.systemStatus.vram`),`:`,` `,$(t.size_vram||0)]}),t.size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(O,{className:`h-3 w-3`}),e(`models.size`),`: `,$(t.size)]})]})]})]}),(0,P.jsxs)(`div`,{className:A(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[(0,P.jsx)(ie,{className:`h-3 w-3`}),e(`modelManager.local.running`)]})]},t.name))})]}),(0,P.jsx)(he,{expanded:q.has(`local`),models:Y,onToggle:()=>J(`local`),isModelRunning:Dt,formatSize:$,onShowModel:Ct,onCopyModel:e=>{R(e),I(!0)},onDeleteModel:St}),(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:()=>J(`advanced`),"aria-expanded":q.has(`advanced`),className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(a,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.advanced`)})]}),q.has(`advanced`)?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),q.has(`advanced`)&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,P.jsxs)(j,{onClick:()=>Te(!0),variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(u,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.createModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.fromModelfile`)})]})]}),(0,P.jsxs)(j,{onClick:()=>I(!0),variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(c,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.copyModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.duplicateExisting`)})]})]}),(0,P.jsxs)(j,{onClick:()=>Me(!0),variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(te,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.testEmbeddings`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.generateVectors`)})]})]}),(0,P.jsxs)(j,{onClick:async()=>{try{(await k.checkHealth()).success&&(await at(),h.success(e(`modelManager.advanced.healthy`)))}catch{await at(),h.error(e(`modelManager.systemStatus.offline`))}},variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(ee,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.healthCheck`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.testConnection`)})]})]})]})})]}),Pt&&(0,P.jsx)(N.Suspense,{fallback:null,children:(0,P.jsx)(be,{models:Y,showDetailsModal:fe,setShowDetailsModal:pe,selectedModelName:ce,selectedModelDetails:re,loadingDetails:me,showCopyModal:ge,setShowCopyModal:I,copySource:L,setCopySource:R,copyDestination:z,setCopyDestination:B,copying:Se,handleCopyModel:wt,showCreateModal:we,setShowCreateModal:Te,createModelName:V,setCreateModelName:Ee,createModelfile:De,setCreateModelfile:Oe,creating:ke,handleCreateModel:Tt,showEmbeddingsModal:je,setShowEmbeddingsModal:Me,embeddingsModel:Ne,setEmbeddingsModel:Pe,embeddingsInput:Fe,setEmbeddingsInput:Ie,embeddingsResult:Le,generatingEmbeddings:ze,handleGenerateEmbeddings:Et})})]})},B=()=>{let{t:e}=i();return(0,P.jsxs)(ce,{children:[(0,P.jsx)(le,{title:e(`models.title`),description:e(`models.subtitle`)}),(0,P.jsx)(z,{})]})};export{B as ModelsPage,B as default};
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{i as r}from"./router-vendor-Ca9zqOqT.js";import{t as i}from"./useTranslation-CdeLZqSW.js";import{A as a,Bt as o,Et as s,Gt as c,Ht as l,Lt as u,M as d,P as f,R as p,Sn as m,Tn as h,Tt as ee,Wt as g,Xt as _,Yt as v,_ as te,_t as y,an as b,ft as x,gt as S,lt as C,m as w,n as T,nn as E,nt as ne,on as D,ot as re,t as ie,vt as O}from"./ui-vendor-D_pYT79f.js";import{t as ae}from"./logger-DSXjF4ye.js";import{_ as oe,p as k}from"./api-CI1Inz7g.js";import{t as A}from"./utils-BhpNrGnR.js";import{n as se}from"./authStore-D-d7UIpv.js";import{t as j}from"./Button-X9TT9gTD.js";import{n as ce,t as le}from"./ui-BXTx1csA.js";import{f as ue,u as M}from"../assets/index-BA116EVY.js";var N=e(n(),1),P=t();function de({expanded:e,models:t,search:n,task:r,sort:a,loadingModels:s,canInstallModels:c,expandedModelId:l,loadingGgufModelId:u,ggufFiles:d,pullingModel:m,pullProgress:h,setSearch:ee,setTask:g,setSort:_,onToggle:v,onToggleModel:te,onPullGguf:y,onCancelPull:x,onRefresh:S}){let{t:C}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:v,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(ie,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:C(`modelManager.sections.huggingface`,`HuggingFace Hub`)}),t.length>0&&(0,P.jsxs)(`span`,{className:A(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,C(`modelManager.library.available`,`available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(f,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:n,onChange:e=>ee(e.target.value),placeholder:C(`modelManager.huggingface.search`,`Search HuggingFace models...`),className:A(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`select`,{value:r,onChange:e=>g(e.target.value),className:A(`px-3 py-2 rounded-lg border text-sm min-w-[160px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`text-generation`,children:C(`modelManager.huggingface.tasks.textGen`,`Text Generation`)}),(0,P.jsx)(`option`,{value:`text-to-speech`,children:C(`modelManager.huggingface.tasks.tts`,`Text to Speech`)}),(0,P.jsx)(`option`,{value:`text-to-image`,children:C(`modelManager.huggingface.tasks.image`,`Text to Image`)}),(0,P.jsx)(`option`,{value:`automatic-speech-recognition`,children:C(`modelManager.huggingface.tasks.stt`,`Speech Recognition`)})]}),(0,P.jsxs)(`select`,{value:a,onChange:e=>_(e.target.value),className:A(`px-3 py-2 rounded-lg border text-sm min-w-[140px]`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`),children:[(0,P.jsx)(`option`,{value:`downloads`,children:C(`modelManager.huggingface.sort.downloads`,`Most Downloads`)}),(0,P.jsx)(`option`,{value:`likes`,children:C(`modelManager.huggingface.sort.likes`,`Most Liked`)}),(0,P.jsx)(`option`,{value:`lastModified`,children:C(`modelManager.huggingface.sort.recent`,`Recently Updated`)})]})]}),!c&&(0,P.jsx)(`p`,{className:`text-xs text-ink`,children:C(`modelManager.pull.restricted`)}),s?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(re,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:C(`modelManager.huggingface.noResults`,`No models found. Try adjusting your search or filters.`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:t.map(e=>(0,P.jsx)(fe,{model:e,expanded:l===e.id,loadingGguf:u===e.id,ggufFiles:d[e.id]||[],pullingModel:m,pullProgress:h,canInstallModels:c,onToggle:()=>te(e.id),onPullGguf:y,onCancelPull:x},e.id))}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between pt-2`,children:[(0,P.jsxs)(`a`,{href:`https://huggingface.co/models`,target:`_blank`,rel:`noopener noreferrer`,className:A(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(o,{className:`h-3 w-3`}),C(`modelManager.huggingface.browseAll`,`Browse all on HuggingFace`)]}),(0,P.jsxs)(j,{onClick:S,variant:`outline`,size:`sm`,disabled:s,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(p,{className:A(`h-3.5 w-3.5`,s&&`animate-spin`)}),C(`modelManager.library.refresh`,`Refresh`)]})]})]})]})}function fe({model:e,expanded:t,loadingGguf:n,ggufFiles:r,pullingModel:a,pullProgress:s,canInstallModels:c,onToggle:u,onPullGguf:d,onCancelPull:f}){let{t:p}=i();return(0,P.jsxs)(`div`,{className:A(`rounded-lg border transition-all overflow-hidden`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`p-4 cursor-pointer`,onClick:u,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800 truncate`,children:e.id}),e.gated&&(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded text-xs`,`bg-yellow-500/20 dark:bg-yellow-900/30`,`text-ink`),children:p(`modelManager.huggingface.gated`,`Gated`)})]}),(0,P.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-600 mt-0.5`,children:[p(`modelManager.huggingface.by`,`by`),` `,e.author]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,P.jsx)(`a`,{href:`https://huggingface.co/${e.id}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),className:`p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 transition-colors`,title:p(`modelManager.huggingface.viewOnHF`,`View on HuggingFace`),children:(0,P.jsx)(o,{className:`h-4 w-4 text-gray-400 dark:text-gray-500`})}),(0,P.jsx)(b,{className:A(`h-4 w-4 text-gray-400 transition-transform`,t&&`rotate-180`)})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(l,{className:`h-3.5 w-3.5`}),F(e.downloads)]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(S,{className:`h-3.5 w-3.5`}),F(e.likes)]}),e.pipeline_tag&&(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded`,`bg-gray-200 dark:bg-dark-300`),children:e.pipeline_tag})]})]}),t&&(0,P.jsx)(pe,{modelId:e.id,loading:n,files:r,pullingModel:a,pullProgress:s,canInstallModels:c,onPullGguf:d,onCancelPull:f})]})}function pe({modelId:e,loading:t,files:n,pullingModel:r,pullProgress:a,canInstallModels:o,onPullGguf:s,onCancelPull:c}){let{t:l}=i();return(0,P.jsx)(`div`,{className:`px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100`,children:t?(0,P.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,P.jsx)(re,{className:`h-4 w-4 animate-spin text-gray-400`}),(0,P.jsx)(`span`,{className:`ml-2 text-xs text-gray-500`,children:l(`modelManager.huggingface.checkingGguf`)})]}):n.length===0?(0,P.jsx)(`div`,{className:`py-4 text-center text-xs text-gray-500 dark:text-gray-400`,children:l(`modelManager.huggingface.noGgufAvailable`)}):(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-300 mb-2`,children:l(`modelManager.huggingface.ggufFilesCount`,{count:n.length})}),n.map(e=>(0,P.jsx)(me,{file:e,pulling:r===e.ollamaCommand,pullProgress:a,canInstallModels:o,disabled:!!r||!o,onPullGguf:s,onCancelPull:c},e.filename)),r?.startsWith(`hf.co/`)&&r.includes(e)&&a?.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2`,children:(0,P.jsx)(`div`,{className:`h-1.5 rounded-full bg-primary-500 transition-all duration-300`,style:{width:`${a.percent}%`}})})]})})}function me({file:e,pulling:t,disabled:n,pullProgress:r,onPullGguf:a,onCancelPull:o}){let{t:s}=i();return(0,P.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 border border-gray-200 dark:border-dark-300`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium text-gray-800 dark:text-gray-200 truncate`,children:e.filename}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:[(0,P.jsx)(`span`,{children:e.sizeFormatted}),e.quantization&&(0,P.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,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:`text-xs text-gray-500 w-12 text-right`,children:r?.percent===void 0?`...`:`${r.percent}%`}),(0,P.jsx)(`button`,{onClick:e=>{e.stopPropagation(),o()},className:`p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20`,children:(0,P.jsx)(T,{className:`h-4 w-4`})})]}):(0,P.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),a(e.ollamaCommand,e.filename)},disabled:n,className:A(`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,P.jsx)(l,{className:`h-3 w-3 inline mr-1`}),s(`models.pull`)]})]})}function F(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e}function he({expanded:e,models:t,onToggle:n,isModelRunning:r,formatSize:a,onShowModel:o,onCopyModel:s,onDeleteModel:c}){let{t:l}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:n,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(O,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:l(`modelManager.sections.local`)}),(0,P.jsxs)(`span`,{className:A(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[t.length,` `,l(`modelManager.local.installed`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:t.length===0?(0,P.jsxs)(`div`,{className:A(`text-center py-12 rounded-lg border-2 border-dashed`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsx)(O,{className:`h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600`}),(0,P.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 mb-2`,children:l(`modelManager.local.noModels`)}),(0,P.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:l(`modelManager.local.pullToStart`)})]}):(0,P.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,P.jsx)(ge,{model:e,running:r(e.name),formatSize:a,onShowModel:o,onCopyModel:s,onDeleteModel:c},e.name))})})]})}function ge({model:e,running:t,formatSize:n,onShowModel:r,onCopyModel:a,onDeleteModel:o}){let{t:s}=i();return(0,P.jsx)(`div`,{className:A(`p-4 rounded-lg border transition-colors`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`hover:bg-gray-100 dark:hover:bg-dark-200`),children:(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:A(`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium`,`bg-green-100 dark:bg-green-900/30`,`text-green-700 dark:text-green-400`),children:[(0,P.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 animate-pulse`}),s(`modelManager.local.running`)]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(O,{className:`h-3.5 w-3.5`}),n(e.size)]}),e.details?.parameter_size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(g,{className:`h-3.5 w-3.5`}),e.details.parameter_size]}),e.details?.quantization_level&&(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e.details.quantization_level}),e.details?.family&&(0,P.jsx)(`span`,{className:`text-gray-500 dark:text-gray-500`,children:e.details.family})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 mt-2`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(_,{className:`h-3 w-3`}),new Date(e.modified_at).toLocaleDateString()]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1 font-mono truncate max-w-[200px]`,title:e.digest,children:[(0,P.jsx)(y,{className:`h-3 w-3`}),e.digest.slice(0,12),`...`]})]})]}),(0,P.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,P.jsxs)(j,{onClick:()=>r(e.name),variant:`outline`,size:`sm`,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(x,{className:`h-3.5 w-3.5`}),s(`modelManager.local.info`)]}),(0,P.jsxs)(j,{onClick:()=>a(e.name),variant:`outline`,size:`sm`,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(c,{className:`h-3.5 w-3.5`}),s(`modelManager.local.copy`)]}),(0,P.jsxs)(j,{onClick:()=>o(e.name),variant:`outline`,size:`sm`,className:A(`gap-1.5`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(w,{className:`h-3.5 w-3.5`}),s(`modelManager.local.delete`)]})]})]})})}function _e({expanded:e,models:t,totalAvailable:n,categories:r,filter:a,search:o,loading:c,pulling:l,canInstallModels:u,pullSectionExpanded:d,setFilter:m,setSearch:h,isModelInstalled:ee,normalizeCloudPullName:g,onToggle:_,onTogglePullSection:te,onPullModel:y,onRefresh:x}){let{t:S}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:_,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(v,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:S(`modelManager.sections.library`)}),(0,P.jsxs)(`span`,{className:A(`px-2 py-0.5 rounded-full text-xs font-medium`,`bg-gray-100 dark:bg-dark-200`,`text-gray-600 dark:text-gray-400`),children:[n,` `,S(`modelManager.library.available`)]})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(f,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:o,onChange:e=>h(e.target.value),placeholder:S(`modelManager.library.search`),className:A(`w-full rounded-xl border py-2 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{className:`h-4 w-4 text-gray-400`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(e=>(0,P.jsx)(`button`,{onClick:()=>m(e),className:A(`px-2.5 py-1 rounded-full text-xs font-medium transition-colors`,a===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))})]})]}),c?(0,P.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,P.jsx)(p,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,P.jsx)(`div`,{className:`text-center py-8 text-gray-500`,children:S(`modelManager.library.noResults`)}):(0,P.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t.map(e=>{let t=e.category===`cloud`?g(e.name):e.name,n=ee(e.name)||ee(t);return(0,P.jsx)(I,{model:e,installed:n,pulling:l,canInstallModels:u,pullSectionExpanded:d,onTogglePullSection:te,onPullModel:y},e.name)})}),(0,P.jsx)(`div`,{className:`flex justify-center`,children:(0,P.jsxs)(j,{onClick:x,variant:`outline`,size:`sm`,disabled:c,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(p,{className:A(`h-3.5 w-3.5`,c&&`animate-spin`)}),S(`modelManager.library.refresh`)]})})]})]})}function I({model:e,installed:t,pulling:n,canInstallModels:r,pullSectionExpanded:a,onTogglePullSection:o,onPullModel:s}){let{t:c}=i();return(0,P.jsxs)(`div`,{"data-testid":`library-model-card-${e.name}`,className:A(`p-4 rounded-lg border transition-all`,`bg-gray-50 dark:bg-dark-50`,t?`border-green-200 dark:border-green-800/50`:`border-gray-200 dark:border-dark-300`,`hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400`),children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,P.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:e.name}),t&&(0,P.jsxs)(`span`,{className:A(`flex items-center gap-1 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:[(0,P.jsx)(D,{className:`h-3 w-3`}),c(`modelManager.library.installed`)]})]}),(0,P.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-dark-600 mb-3 line-clamp-2`,children:e.description}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.sizes.slice(0,4).map(e=>(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded text-xs`,`bg-gray-200 dark:bg-dark-300`,`text-gray-600 dark:text-gray-400`),children:e},e)),e.sizes.length>4&&(0,P.jsx)(`span`,{className:`text-xs text-gray-400`,children:c(`modelManager.library.more`,{count:e.sizes.length-4})})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-gray-500`,children:[e.pulls&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(l,{className:`h-3 w-3`}),e.pulls]}),(0,P.jsx)(`span`,{className:A(`px-1.5 py-0.5 rounded capitalize`,e.category===`cloud`?`bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400`:`bg-gray-100 dark:bg-dark-200`),children:e.category})]}),(0,P.jsxs)(j,{"data-testid":`library-model-install-${e.name}`,onClick:()=>{a||o(),s(e.name,e.category)},variant:`outline`,size:`sm`,disabled:n||!r,className:A(`gap-1 text-xs`,``,``),children:[(0,P.jsx)(l,{className:`h-3 w-3`}),c(`modelManager.pull.button`)]})]})]})}function ve({expanded:e,modelName:t,setModelName:n,pulling:r,progress:a,canInstallModels:s,popularModels:c,onToggle:u,onPull:d,onCancelPull:p,formatSize:m}){let{t:h}=i();return(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:u,"aria-expanded":e,className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(l,{className:`h-4 w-4 text-primary-600 dark:text-primary-400`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:h(`modelManager.sections.pull`)})]}),e?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),e&&(0,P.jsxs)(`div`,{className:`p-4 pt-0 space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1`,children:[(0,P.jsx)(f,{className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400 dark:text-gray-500`}),(0,P.jsx)(`input`,{type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:h(`modelManager.pull.placeholder`),className:A(`w-full rounded-xl border py-2.5 pe-4 ps-10 text-sm`,`bg-gray-50 dark:bg-dark-50`,`border-gray-200 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`placeholder-gray-500 dark:placeholder-gray-400`,`focus:outline-none focus:ring-2 focus:ring-primary-500/20`,`focus:border-primary-500`),disabled:r||!s,onKeyDown:e=>{e.key===`Enter`&&!r&&s&&d()}})]}),r?(0,P.jsxs)(j,{onClick:p,variant:`outline`,className:A(`px-4 py-2.5 gap-2`,`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,``,``),children:[(0,P.jsx)(T,{className:`h-4 w-4`}),h(`modelManager.pull.cancel`)]}):(0,P.jsxs)(j,{onClick:d,disabled:!t.trim()||!s,className:A(`px-4 py-2.5 gap-2`,``),children:[(0,P.jsx)(l,{className:`h-4 w-4`}),h(`modelManager.pull.button`)]})]}),r&&a&&(0,P.jsx)(L,{progress:a,formatSize:m}),!s&&(0,P.jsx)(`p`,{className:`text-xs text-ink-muted`,children:h(`modelManager.pull.restricted`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 mb-2`,children:h(`modelManager.pull.popular`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.map(e=>(0,P.jsxs)(`button`,{onClick:()=>n(e.name),disabled:r||!s,className:A(`px-3 py-1.5 rounded-full text-xs font-medium transition-colors`,`bg-gray-100 dark:bg-dark-200`,`text-gray-700 dark:text-gray-300`,`hover:bg-gray-200 dark:hover:bg-dark-300`,`border border-gray-200 dark:border-dark-300`,`disabled:opacity-50 disabled:cursor-not-allowed`),children:[e.name,(0,P.jsx)(`span`,{className:`ml-1 text-gray-400 dark:text-gray-500`,children:e.size})]},e.name))})]}),(0,P.jsxs)(`a`,{href:`https://ollama.com/library`,target:`_blank`,rel:`noopener noreferrer`,className:A(`inline-flex items-center gap-1.5 text-xs`,`text-primary-600 dark:text-primary-400`,`hover:underline`),children:[(0,P.jsx)(o,{className:`h-3 w-3`}),h(`modelManager.pull.browseAll`)]})]})]})}function L({progress:e,formatSize:t}){let{t:n}=i(),r=e.status===`starting`?n(`modelManager.progress.starting`):e.status.startsWith(`pulling`)?`${n(`modelManager.progress.pullingLayer`)} ${e.status.replace(`pulling `,``)}`:e.status.startsWith(`verifying sha256`)?n(`modelManager.progress.verifyingDigest`):e.status===`writing manifest`?n(`modelManager.progress.writing`):e.status===`removing any unused layers`?n(`modelManager.progress.cleaning`):e.status;return(0,P.jsxs)(`div`,{className:A(`p-4 rounded-lg border`,`bg-gray-50 dark:bg-dark-200`,`border-gray-200 dark:border-dark-300`),children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-800 dark:text-dark-700`,children:r}),e.percent!==void 0&&(0,P.jsxs)(`span`,{className:`text-sm font-mono text-gray-600 dark:text-dark-600`,children:[e.percent,`%`]})]}),e.percent!==void 0&&(0,P.jsx)(`div`,{className:`w-full bg-gray-200 dark:bg-dark-400 rounded-full h-2 overflow-hidden`,children:(0,P.jsx)(`div`,{className:A(`h-2 rounded-full transition-all duration-300`,`bg-primary-500 dark:bg-primary-400`),style:{width:`${e.percent}%`}})}),e.total&&e.completed&&(0,P.jsxs)(`div`,{className:`mt-2 text-xs text-gray-600 dark:text-dark-600`,children:[t(e.completed),` / `,t(e.total)]})]})}var ye=ae(`components:model-manager`),be=N.lazy(()=>r(()=>import(`./ModelManagerModals-D9j9RECi.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),R=e=>{let t=e.split(`:`).pop()?.toLowerCase();return t===`cloud`||t?.endsWith(`-cloud`)===!0},xe=e=>{let t=e.trim();if(!t||R(t))return t;let n=t.lastIndexOf(`:`);return n===-1?`${t}:cloud`:`${t.slice(0,n)}:${t.slice(n+1)}-cloud`},z=()=>{let{t:e}=i(),{user:t,systemInfo:n}=se(),r=t?.role===`admin`||n?.requiresAuth===!1,o=ue(),[s,l]=(0,N.useState)(`all`),[f,g]=(0,N.useState)(``),[_,v]=(0,N.useState)(``),[y,x]=(0,N.useState)(!1),[S,w]=(0,N.useState)(null),[T,D]=(0,N.useState)(null),[re,ae]=(0,N.useState)(null),[ce,le]=(0,N.useState)(``),[fe,pe]=(0,N.useState)(!1),[me,F]=(0,N.useState)(!1),[ge,I]=(0,N.useState)(!1),[L,R]=(0,N.useState)(``),[z,B]=(0,N.useState)(``),[Se,Ce]=(0,N.useState)(!1),[we,Te]=(0,N.useState)(!1),[V,Ee]=(0,N.useState)(``),[De,Oe]=(0,N.useState)(``),[ke,Ae]=(0,N.useState)(!1),[je,Me]=(0,N.useState)(!1),[Ne,Pe]=(0,N.useState)(``),[Fe,Ie]=(0,N.useState)(``),[Le,Re]=(0,N.useState)(null),[ze,Be]=(0,N.useState)(!1),[Ve,He]=(0,N.useState)(``),[Ue,We]=(0,N.useState)(``),[H,Ge]=(0,N.useState)(`text-generation`),[U,Ke]=(0,N.useState)(`downloads`),[qe,Je]=(0,N.useState)(null),[Ye,Xe]=(0,N.useState)({}),[Ze,Qe]=(0,N.useState)(null),[$e,W]=(0,N.useState)(null),[et,G]=(0,N.useState)(null),[tt,K]=(0,N.useState)(null),[q,nt]=(0,N.useState)(new Set([`pull`,`local`])),J=e=>{nt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},{data:rt,isLoading:it,refetch:at}=M({queryKey:[`ollama-state`],queryFn:async()=>{let[e,t,n,r]=await Promise.all([k.getModels(),k.listRunningModels(),k.getVersion(),k.checkHealth()]);return{models:e.success&&e.data||[],runningModels:t.success&&Array.isArray(t.data)?t.data:[],ollamaVersion:n.success&&n.data?n.data.version:null,isHealthy:r.success}}}),Y=rt?.models??[],X=rt?.runningModels??[],ot=rt?.ollamaVersion??null,st=rt?.isHealthy??null,Z=(0,N.useCallback)(async()=>{await at()},[at]),{data:Q=[],isLoading:ct}=M({queryKey:[`ollama-library`],queryFn:async()=>{let e=await k.getLibraryModels();return e.success&&e.data?e.data:[]}}),{data:lt=[],isLoading:ut}=M({queryKey:[`ollama-library`,`cloud`],queryFn:async()=>{let e=await k.getLibraryModels({category:`cloud`});return e.success&&e.data?e.data:[]},enabled:s===`cloud`}),dt=()=>o.invalidateQueries({queryKey:[`ollama-library`]});(0,N.useEffect)(()=>{let e=setTimeout(()=>{We(Ve)},300);return()=>clearTimeout(e)},[Ve]);let ft=q.has(`huggingface`),{data:pt=[],isLoading:mt}=M({queryKey:[`hf-models`,H,Ue,U],queryFn:async()=>{let e=await oe.getModels({task:H,search:Ue||void 0,sort:U,limit:30});return e.success&&e.data?e.data:[]},enabled:ft}),ht=()=>o.invalidateQueries({queryKey:[`hf-models`,H,Ue,U]}),gt=(0,N.useCallback)(async e=>{let[t,n]=e.split(`/`);if(!(!t||!n)){Qe(e);try{let r=await oe.getGgufFiles(t,n);r.success&&r.data&&Xe(t=>({...t,[e]:r.data}))}catch(e){ye.error(`Failed to load GGUF files:`,e)}finally{Qe(null)}}},[]),_t=(0,N.useCallback)(e=>{qe===e?Je(null):(Je(e),Ye[e]||gt(e))},[qe,Ye,gt]),vt=(0,N.useCallback)((t,n)=>{if(!r){h.error(e(`modelManager.pull.restricted`));return}if(!$e){W(t),G({status:`starting`});try{let e=k.pullModelStream(t,e=>{G(e)},()=>{G(null),W(null),K(null),h.success(`Downloaded ${n}`),Z()},e=>{G(null),W(null),K(null),h.error(`Failed to download: ${e}`)});K(()=>e)}catch{G(null),W(null),h.error(`Failed to start download`)}}},[r,$e,Z,e]),yt=(0,N.useCallback)(()=>{tt&&(tt(),K(null),W(null),G(null))},[tt]),bt=async(t,n)=>{if(!r){h.error(e(`modelManager.pull.restricted`));return}let i=t||_.trim(),a=n===`cloud`||!t&&s===`cloud`?xe(i):i;if(!a){h.error(e(`modelManager.pull.enterName`));return}t&&v(a),x(!0),w({status:`starting`});try{let t=k.pullModelStream(a,e=>{w(e)},()=>{w(null),x(!1),D(null),h.success(e(`modelManager.pull.success`,{name:a})),v(``),Z()},t=>{w(null),x(!1),D(null),h.error(e(`modelManager.pull.failed`)+`: `+t)});D(()=>t)}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.pull.failed`)+`: `+n),w(null),x(!1),D(null)}},xt=()=>{T&&(T(),D(null),x(!1),w(null),h.success(e(`modelManager.pull.cancelled`)))},St=async t=>{if(confirm(e(`modelManager.local.deleteConfirm`,{name:t})))try{await k.deleteModel(t),h.success(e(`modelManager.local.deleteSuccess`,{name:t})),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.local.deleteFailed`)+`: `+n)}},Ct=async t=>{F(!0),le(t),pe(!0);try{let n=await k.showModel(t,!0);n.success&&n.data?ae(n.data):h.error(e(`modelManager.modals.details.noDetails`))}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.details.noDetails`)+`: `+n)}finally{F(!1)}},wt=async()=>{if(!L.trim()||!z.trim()){h.error(e(`modelManager.modals.copy.enterBoth`));return}Ce(!0);try{await k.copyModel(L.trim(),z.trim()),h.success(e(`modelManager.modals.copy.success`,{name:z})),I(!1),R(``),B(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.copy.failed`)+`: `+n)}finally{Ce(!1)}},Tt=async()=>{if(!V.trim()||!De.trim()){h.error(e(`modelManager.modals.create.enterBoth`));return}Ae(!0);try{await k.createModel({model:V.trim(),modelfile:De.trim()}),h.success(e(`modelManager.modals.create.success`,{name:V})),Te(!1),Ee(``),Oe(``),await Z()}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.create.failed`)+`: `+n)}finally{Ae(!1)}},Et=async()=>{if(!Ne.trim()||!Fe.trim()){h.error(e(`modelManager.modals.embeddings.enterBoth`));return}Be(!0),Re(null);try{let t=await k.generateEmbeddings({model:Ne.trim(),input:Fe.trim()});if(t.success&&t.data){let n=t.data.embeddings?.[0]||[];Re(n),h.success(e(`modelManager.modals.embeddings.success`,{count:n.length}))}}catch(t){let n=t instanceof Error?t.message:String(t);h.error(e(`modelManager.modals.embeddings.failed`)+`: `+n)}finally{Be(!1)}},$=e=>{let t=e/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(e/1048576).toFixed(1)} MB`},Dt=e=>Array.isArray(X)&&X.some(t=>t.name===e),Ot=()=>Y.reduce((e,t)=>e+t.size,0),kt=()=>X.reduce((e,t)=>e+(t.size_vram||0),0),At=e=>Y.some(t=>t.name===e||t.name.startsWith(e+`:`)),jt=(s===`cloud`?lt:Q).filter(e=>{let t=s===`all`||s===`cloud`||e.category===s,n=!f||e.name.toLowerCase().includes(f.toLowerCase())||e.description.toLowerCase().includes(f.toLowerCase());return t&&n}),Mt=[`all`,...new Set([...Q.map(e=>e.category),`cloud`])],Nt=(0,N.useMemo)(()=>Q.length>0?Q.slice(0,10).map(e=>({name:e.name,category:e.category,size:e.sizes?.[0]||``})):[{name:`deepseek-r1`,category:`reasoning`,size:`7B`},{name:`llama3.2`,category:`general`,size:`3B`},{name:`gemma3`,category:`general`,size:`4B`},{name:`qwen2.5`,category:`general`,size:`7B`},{name:`mistral`,category:`general`,size:`7B`},{name:`codellama`,category:`coding`,size:`7B`},{name:`nomic-embed-text`,category:`embedding`,size:`137M`},{name:`llava`,category:`vision`,size:`7B`},{name:`phi3`,category:`general`,size:`3.8B`},{name:`gemma2`,category:`general`,size:`9B`}],[Q]),Pt=fe||ge||we||je;return it?(0,P.jsx)(`div`,{className:`flex items-center justify-center p-8`,children:(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-gray-600 dark:text-dark-600`,children:[(0,P.jsx)(p,{className:`h-5 w-5 animate-spin`}),e(`modelManager.loading`)]})}):(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(`div`,{className:A(`rounded-2xl border px-4 py-3`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`div`,{className:A(`w-2.5 h-2.5 rounded-full`,st?`bg-green-500`:`bg-red-500`)}),(0,P.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(st?`modelManager.systemStatus.online`:`modelManager.systemStatus.offline`)})]}),ot&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(d,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[`v`,ot]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(O,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[Y.length,` `,Y.length===1?e(`modelManager.systemStatus.models`):e(`modelManager.systemStatus.models_plural`)]})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400`,children:[(0,P.jsx)(C,{className:`h-4 w-4`}),(0,P.jsx)(`span`,{children:$(Ot())})]}),X.length>0&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-green-600 dark:text-green-400`,children:[(0,P.jsx)(m,{className:`h-4 w-4`}),(0,P.jsxs)(`span`,{children:[X.length,` `,e(`modelManager.systemStatus.running`),` (`,$(kt()),` `,e(`modelManager.systemStatus.vram`),`)`]})]})]}),(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,P.jsxs)(j,{onClick:Z,variant:`outline`,size:`sm`,className:A(`gap-1.5`,``,``),children:[(0,P.jsx)(p,{className:`h-3.5 w-3.5`}),e(`common.refresh`)]})})]})}),(0,P.jsx)(ve,{expanded:q.has(`pull`),modelName:_,setModelName:v,pulling:y,progress:S,canInstallModels:r,popularModels:Nt,onToggle:()=>J(`pull`),onPull:()=>bt(),onCancelPull:xt,formatSize:$}),(0,P.jsx)(_e,{expanded:q.has(`library`),models:jt,totalAvailable:Q.length,categories:Mt,filter:s,search:f,loading:ct||ut,pulling:y,canInstallModels:r,pullSectionExpanded:q.has(`pull`),setFilter:l,setSearch:g,isModelInstalled:At,normalizeCloudPullName:xe,onToggle:()=>J(`library`),onTogglePullSection:()=>J(`pull`),onPullModel:bt,onRefresh:dt}),(0,P.jsx)(de,{expanded:q.has(`huggingface`),models:pt,search:Ve,task:H,sort:U,loadingModels:mt,canInstallModels:r,expandedModelId:qe,loadingGgufModelId:Ze,ggufFiles:Ye,pullingModel:$e,pullProgress:et,setSearch:He,setTask:Ge,setSort:Ke,onToggle:()=>J(`huggingface`),onToggleModel:_t,onPullGguf:vt,onCancelPull:yt,onRefresh:ht}),Array.isArray(X)&&X.length>0&&(0,P.jsxs)(`div`,{className:A(`rounded-2xl border p-4`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,P.jsx)(m,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.running`)}),(0,P.jsxs)(`span`,{className:A(`ms-auto rounded-full px-2 py-0.5 text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[X.length,` `,e(`modelManager.systemStatus.running`)]})]}),(0,P.jsx)(`div`,{className:`space-y-2`,children:X.map(t=>(0,P.jsxs)(`div`,{className:A(`flex items-center justify-between p-4 rounded-lg border`,`bg-white/50 dark:bg-white/[0.025]`,`border-gray-200/80 dark:border-white/[0.08]`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`div`,{className:A(`w-2 h-2 rounded-full animate-pulse`,`bg-green-500`)}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-dark-800`,children:t.name}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-gray-500 dark:text-dark-500`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(ne,{className:`h-3 w-3`}),e(`modelManager.systemStatus.vram`),`:`,` `,$(t.size_vram||0)]}),t.size&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(O,{className:`h-3 w-3`}),e(`models.size`),`: `,$(t.size)]})]})]})]}),(0,P.jsxs)(`div`,{className:A(`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium`,`border border-gray-200 bg-gray-50 dark:border-white/10 dark:bg-white/[0.04]`,`text-gray-600 dark:text-dark-600`),children:[(0,P.jsx)(ie,{className:`h-3 w-3`}),e(`modelManager.local.running`)]})]},t.name))})]}),(0,P.jsx)(he,{expanded:q.has(`local`),models:Y,onToggle:()=>J(`local`),isModelRunning:Dt,formatSize:$,onShowModel:Ct,onCopyModel:e=>{R(e),I(!0)},onDeleteModel:St}),(0,P.jsxs)(`div`,{className:A(`overflow-hidden rounded-2xl border`,`bg-white/60 dark:bg-white/[0.03]`,`border-gray-200/80 dark:border-white/10`),children:[(0,P.jsxs)(`button`,{onClick:()=>J(`advanced`),"aria-expanded":q.has(`advanced`),className:A(`w-full flex items-center justify-between p-4`,`hover:bg-gray-50 dark:hover:bg-dark-50`,`transition-colors`),children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(a,{className:`h-4 w-4 text-gray-500 dark:text-dark-500`}),(0,P.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:e(`modelManager.sections.advanced`)})]}),q.has(`advanced`)?(0,P.jsx)(E,{className:`h-5 w-5 text-gray-500`}):(0,P.jsx)(b,{className:`h-5 w-5 text-gray-500`})]}),q.has(`advanced`)&&(0,P.jsx)(`div`,{className:`p-4 pt-0`,children:(0,P.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[(0,P.jsxs)(j,{onClick:()=>Te(!0),variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(u,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.createModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.fromModelfile`)})]})]}),(0,P.jsxs)(j,{onClick:()=>I(!0),variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(c,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.copyModel`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.duplicateExisting`)})]})]}),(0,P.jsxs)(j,{onClick:()=>Me(!0),variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(te,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.testEmbeddings`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.generateVectors`)})]})]}),(0,P.jsxs)(j,{onClick:async()=>{try{(await k.checkHealth()).success&&(await at(),h.success(e(`modelManager.advanced.healthy`)))}catch{await at(),h.error(e(`modelManager.systemStatus.offline`))}},variant:`outline`,className:A(`w-full gap-2 justify-start h-auto py-3 px-4`,``,``),children:[(0,P.jsx)(ee,{className:`h-5 w-5 text-gray-500 dark:text-dark-500`}),(0,P.jsxs)(`div`,{className:`text-start`,children:[(0,P.jsx)(`div`,{className:`font-medium`,children:e(`modelManager.advanced.healthCheck`)}),(0,P.jsx)(`div`,{className:`text-xs opacity-70`,children:e(`modelManager.advanced.testConnection`)})]})]})]})})]}),Pt&&(0,P.jsx)(N.Suspense,{fallback:null,children:(0,P.jsx)(be,{models:Y,showDetailsModal:fe,setShowDetailsModal:pe,selectedModelName:ce,selectedModelDetails:re,loadingDetails:me,showCopyModal:ge,setShowCopyModal:I,copySource:L,setCopySource:R,copyDestination:z,setCopyDestination:B,copying:Se,handleCopyModel:wt,showCreateModal:we,setShowCreateModal:Te,createModelName:V,setCreateModelName:Ee,createModelfile:De,setCreateModelfile:Oe,creating:ke,handleCreateModel:Tt,showEmbeddingsModal:je,setShowEmbeddingsModal:Me,embeddingsModel:Ne,setEmbeddingsModel:Pe,embeddingsInput:Fe,setEmbeddingsInput:Ie,embeddingsResult:Le,generatingEmbeddings:ze,handleGenerateEmbeddings:Et})})]})},B=()=>{let{t:e}=i();return(0,P.jsxs)(ce,{children:[(0,P.jsx)(le,{title:e(`models.title`),description:e(`models.subtitle`)}),(0,P.jsx)(z,{})]})};export{B as ModelsPage,B as default};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CdeLZqSW.js";import{B as i,H as a,P as o,Rt as s,Tn as c,Y as l,m as u}from"./ui-vendor-D_pYT79f.js";import{t as d}from"./logger-DSXjF4ye.js";import{v as f}from"./api-DVP8xiYT.js";import{n as p,t as m}from"./utils-BhpNrGnR.js";import{t as h}from"./Button-X9TT9gTD.js";import"./ui-DDlcz2oy.js";import{t as g}from"./RichMessageContent-DYRrXJ75.js";var _=e(n(),1),v=t(),y=d(`pages:notes`),b=800,x=()=>{let{t:e,i18n:t}=r(),[n,d]=(0,_.useState)([]),[x,S]=(0,_.useState)(!0),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(`idle`),F=(0,_.useRef)(null),I=(0,_.useMemo)(()=>n.find(e=>e.id===C)??null,[n,C]);(0,_.useEffect)(()=>{let e=!1;return f.getNotes().then(t=>{e||t.success&&t.data&&d(t.data)}).catch(e=>y.error(`Failed to load notes:`,e)).finally(()=>{e||S(!1)}),()=>{e=!0}},[]);let L=e=>{B(),w(e.id),O(e.title),A(e.content),M(!1),P(`idle`)},R=(e,t,n)=>{F.current!==null&&window.clearTimeout(F.current),P(`saving`),F.current=window.setTimeout(()=>{F.current=null,z(e,t,n)},b)},z=async(t,n,r)=>{try{let e=await f.updateNote(t,{title:n,content:r});if(e.success&&e.data){let n=e.data;d(e=>[n,...e.filter(e=>e.id!==t)].sort((e,t)=>t.updatedAt-e.updatedAt)),P(`saved`)}}catch(t){y.error(`Failed to save note:`,t),c.error(e(`notes.saveFailed`)),P(`idle`)}},B=()=>{F.current!==null&&C&&(window.clearTimeout(F.current),F.current=null,z(C,D,k))};(0,_.useEffect)(()=>()=>{F.current!==null&&window.clearTimeout(F.current)},[]);let V=async()=>{try{let e=await f.createNote(``,``);if(e.success&&e.data){let t=e.data;d(e=>[t,...e]),L(t)}}catch(t){y.error(`Failed to create note:`,t),c.error(e(`notes.createFailed`))}},H=async t=>{if(window.confirm(e(`notes.deleteConfirm`)))try{(await f.deleteNote(t)).success&&(d(e=>e.filter(e=>e.id!==t)),C===t&&w(null))}catch(t){y.error(`Failed to delete note:`,t),c.error(e(`notes.deleteFailed`))}},U=(0,_.useMemo)(()=>{let e=T.trim().toLowerCase();return e?n.filter(t=>t.title.toLowerCase().includes(e)||t.content.toLowerCase().includes(e)):n},[n,T]);return(0,v.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,v.jsxs)(`div`,{className:`flex w-72 shrink-0 flex-col border-e border-black/[0.06] dark:border-white/[0.07]`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4`,children:[(0,v.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`notes.title`)}),(0,v.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>void V(),className:`h-7 w-7 p-0`,title:e(`notes.new`),children:(0,v.jsx)(i,{className:`h-4 w-4`})})]}),(0,v.jsxs)(`div`,{className:`relative mx-3 mb-2`,children:[(0,v.jsx)(o,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400 dark:text-dark-500`}),(0,v.jsx)(`input`,{type:`search`,value:T,onChange:e=>E(e.target.value),placeholder:e(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05] dark:text-dark-900 dark:placeholder:text-dark-500`})]}),(0,v.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:x?null:U.length===0?(0,v.jsxs)(`div`,{className:`px-3 py-10 text-center`,children:[(0,v.jsx)(l,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,v.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:e(`notes.empty`)})]}):(0,v.jsx)(`div`,{className:`space-y-0.5`,children:U.map(n=>(0,v.jsxs)(`div`,{onClick:()=>L(n),className:m(`group cursor-pointer rounded-lg px-2.5 py-2 transition-colors`,C===n.id?`bg-white ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`:`hover:bg-white/60 dark:hover:bg-dark-200/60`),children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,v.jsx)(`p`,{className:`truncate text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:n.title||e(`notes.untitled`)}),(0,v.jsx)(`button`,{onClick:e=>{e.stopPropagation(),H(n.id)},className:`shrink-0 rounded-md p-1 text-red-500 opacity-0 transition-opacity hover:bg-red-50 group-hover:opacity-100 dark:hover:bg-red-900/20`,title:e(`common.delete`),children:(0,v.jsx)(u,{className:`h-3 w-3`})})]}),(0,v.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[p(n.updatedAt,t.language),n.content.trim()&&(0,v.jsxs)(v.Fragment,{children:[` · `,n.content.trim().slice(0,60)]})]})]},n.id))})})]}),(0,v.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:I?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-5 py-3 dark:border-white/[0.07]`,children:[(0,v.jsx)(`input`,{dir:`auto`,value:D,onChange:e=>{O(e.target.value),R(I.id,e.target.value,k)},placeholder:e(`notes.untitled`),className:`min-w-0 flex-1 bg-transparent text-lg font-semibold text-gray-950 placeholder:text-gray-400 focus:outline-none dark:text-dark-950 dark:placeholder:text-dark-500`}),(0,v.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:N===`saving`?e(`common.saving`):N===`saved`?e(`notes.saved`):``}),(0,v.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>M(e=>!e),className:`h-8 gap-1.5 px-2.5 text-xs`,children:j?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(a,{className:`h-3.5 w-3.5`}),e(`common.edit`)]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s,{className:`h-3.5 w-3.5`}),e(`artifacts.preview`)]})})]}),j?(0,v.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-5 py-4 scrollbar-thin`,children:(0,v.jsx)(g,{content:k})}):(0,v.jsx)(`textarea`,{dir:`auto`,value:k,onChange:e=>{A(e.target.value),R(I.id,D,e.target.value)},onBlur:B,placeholder:e(`notes.contentPlaceholder`),className:`min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13.5px] leading-relaxed text-gray-900 placeholder:text-gray-400 focus:outline-none dark:text-dark-900 dark:placeholder:text-dark-500`})]}):(0,v.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(l,{className:`mx-auto mb-3 h-8 w-8 text-gray-300 dark:text-dark-400`}),(0,v.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-600`,children:e(`notes.selectOrCreate`)}),(0,v.jsxs)(h,{size:`sm`,onClick:()=>void V(),className:`mt-4 gap-1.5`,children:[(0,v.jsx)(i,{className:`h-3.5 w-3.5`}),e(`notes.new`)]})]})})})]})};export{x as NotesPage,x as default};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,f as n}from"./markdown-core-DHnR5Hw8.js";import{t as r}from"./useTranslation-CdeLZqSW.js";import{B as i,H as a,P as o,Rt as s,Tn as c,Y as l,m as u}from"./ui-vendor-D_pYT79f.js";import{t as d}from"./logger-DSXjF4ye.js";import{v as f}from"./api-CI1Inz7g.js";import{n as p,t as m}from"./utils-BhpNrGnR.js";import{t as h}from"./Button-X9TT9gTD.js";import"./ui-BXTx1csA.js";import{t as g}from"./RichMessageContent-B1bidjA8.js";var _=e(n(),1),v=t(),y=d(`pages:notes`),b=800,x=()=>{let{t:e,i18n:t}=r(),[n,d]=(0,_.useState)([]),[x,S]=(0,_.useState)(!0),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(``),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(`idle`),F=(0,_.useRef)(null),I=(0,_.useMemo)(()=>n.find(e=>e.id===C)??null,[n,C]);(0,_.useEffect)(()=>{let e=!1;return f.getNotes().then(t=>{e||t.success&&t.data&&d(t.data)}).catch(e=>y.error(`Failed to load notes:`,e)).finally(()=>{e||S(!1)}),()=>{e=!0}},[]);let L=e=>{B(),w(e.id),O(e.title),A(e.content),M(!1),P(`idle`)},R=(e,t,n)=>{F.current!==null&&window.clearTimeout(F.current),P(`saving`),F.current=window.setTimeout(()=>{F.current=null,z(e,t,n)},b)},z=async(t,n,r)=>{try{let e=await f.updateNote(t,{title:n,content:r});if(e.success&&e.data){let n=e.data;d(e=>[n,...e.filter(e=>e.id!==t)].sort((e,t)=>t.updatedAt-e.updatedAt)),P(`saved`)}}catch(t){y.error(`Failed to save note:`,t),c.error(e(`notes.saveFailed`)),P(`idle`)}},B=()=>{F.current!==null&&C&&(window.clearTimeout(F.current),F.current=null,z(C,D,k))};(0,_.useEffect)(()=>()=>{F.current!==null&&window.clearTimeout(F.current)},[]);let V=async()=>{try{let e=await f.createNote(``,``);if(e.success&&e.data){let t=e.data;d(e=>[t,...e]),L(t)}}catch(t){y.error(`Failed to create note:`,t),c.error(e(`notes.createFailed`))}},H=async t=>{if(window.confirm(e(`notes.deleteConfirm`)))try{(await f.deleteNote(t)).success&&(d(e=>e.filter(e=>e.id!==t)),C===t&&w(null))}catch(t){y.error(`Failed to delete note:`,t),c.error(e(`notes.deleteFailed`))}},U=(0,_.useMemo)(()=>{let e=T.trim().toLowerCase();return e?n.filter(t=>t.title.toLowerCase().includes(e)||t.content.toLowerCase().includes(e)):n},[n,T]);return(0,v.jsxs)(`div`,{className:`flex h-full min-h-0`,children:[(0,v.jsxs)(`div`,{className:`flex w-72 shrink-0 flex-col border-e border-black/[0.06] dark:border-white/[0.07]`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between px-4 pb-2 pt-4`,children:[(0,v.jsx)(`h1`,{className:`text-sm font-semibold text-gray-900 dark:text-dark-900`,children:e(`notes.title`)}),(0,v.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>void V(),className:`h-7 w-7 p-0`,title:e(`notes.new`),children:(0,v.jsx)(i,{className:`h-4 w-4`})})]}),(0,v.jsxs)(`div`,{className:`relative mx-3 mb-2`,children:[(0,v.jsx)(o,{className:`pointer-events-none absolute start-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400 dark:text-dark-500`}),(0,v.jsx)(`input`,{type:`search`,value:T,onChange:e=>E(e.target.value),placeholder:e(`common.search`),className:`w-full rounded-lg border border-transparent bg-black/[0.04] py-1.5 pe-2.5 ps-8 text-[13px] text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:bg-white/[0.05] dark:text-dark-900 dark:placeholder:text-dark-500`})]}),(0,v.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-2 pb-3 scrollbar-thin`,children:x?null:U.length===0?(0,v.jsxs)(`div`,{className:`px-3 py-10 text-center`,children:[(0,v.jsx)(l,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,v.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:e(`notes.empty`)})]}):(0,v.jsx)(`div`,{className:`space-y-0.5`,children:U.map(n=>(0,v.jsxs)(`div`,{onClick:()=>L(n),className:m(`group cursor-pointer rounded-lg px-2.5 py-2 transition-colors`,C===n.id?`bg-white ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`:`hover:bg-white/60 dark:hover:bg-dark-200/60`),children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,v.jsx)(`p`,{className:`truncate text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:n.title||e(`notes.untitled`)}),(0,v.jsx)(`button`,{onClick:e=>{e.stopPropagation(),H(n.id)},className:`shrink-0 rounded-md p-1 text-red-500 opacity-0 transition-opacity hover:bg-red-50 group-hover:opacity-100 dark:hover:bg-red-900/20`,title:e(`common.delete`),children:(0,v.jsx)(u,{className:`h-3 w-3`})})]}),(0,v.jsxs)(`p`,{className:`mt-0.5 truncate text-[11px] text-gray-400 dark:text-dark-500`,children:[p(n.updatedAt,t.language),n.content.trim()&&(0,v.jsxs)(v.Fragment,{children:[` · `,n.content.trim().slice(0,60)]})]})]},n.id))})})]}),(0,v.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:I?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/[0.06] px-5 py-3 dark:border-white/[0.07]`,children:[(0,v.jsx)(`input`,{dir:`auto`,value:D,onChange:e=>{O(e.target.value),R(I.id,e.target.value,k)},placeholder:e(`notes.untitled`),className:`min-w-0 flex-1 bg-transparent text-lg font-semibold text-gray-950 placeholder:text-gray-400 focus:outline-none dark:text-dark-950 dark:placeholder:text-dark-500`}),(0,v.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:N===`saving`?e(`common.saving`):N===`saved`?e(`notes.saved`):``}),(0,v.jsx)(h,{size:`sm`,variant:`ghost`,onClick:()=>M(e=>!e),className:`h-8 gap-1.5 px-2.5 text-xs`,children:j?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(a,{className:`h-3.5 w-3.5`}),e(`common.edit`)]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s,{className:`h-3.5 w-3.5`}),e(`artifacts.preview`)]})})]}),j?(0,v.jsx)(`div`,{className:`scroll-region min-h-0 flex-1 overflow-y-auto px-5 py-4 scrollbar-thin`,children:(0,v.jsx)(g,{content:k})}):(0,v.jsx)(`textarea`,{dir:`auto`,value:k,onChange:e=>{A(e.target.value),R(I.id,D,e.target.value)},onBlur:B,placeholder:e(`notes.contentPlaceholder`),className:`min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13.5px] leading-relaxed text-gray-900 placeholder:text-gray-400 focus:outline-none dark:text-dark-900 dark:placeholder:text-dark-500`})]}):(0,v.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(l,{className:`mx-auto mb-3 h-8 w-8 text-gray-300 dark:text-dark-400`}),(0,v.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-600`,children:e(`notes.selectOrCreate`)}),(0,v.jsxs)(h,{size:`sm`,onClick:()=>void V(),className:`mt-4 gap-1.5`,children:[(0,v.jsx)(i,{className:`h-3.5 w-3.5`}),e(`notes.new`)]})]})})})]})};export{x as NotesPage,x as default};