libre-webui 0.8.3 → 0.8.4

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.
@@ -1 +1 @@
1
- import{j as e}from"./markdown-vendor-QwEm2Xso.js";import{r as l,e as A}from"./router-vendor-CmbUVdlE.js";import{a as q,c as d,i as E,B as T}from"../assets/index-CT6_wIIb.js";import{X as Q,ad as H,aB as U,aq as W,k as M,T as $,F as k,L,aC as X,I as F,u as J,t as O}from"./ui-vendor-DsBonqC3.js";import"./utils-vendor-3oAsqusP.js";const V=({image:r,onClose:o,onDelete:h,onDownload:s})=>{const{t:i}=q();l.useEffect(()=>{const n=m=>{m.key==="Escape"&&o()};return document.addEventListener("keydown",n),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",n),document.body.style.overflow=""}},[o]);const j=n=>new Date(n).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),f=()=>{if(s)s(r);else{const n=document.createElement("a");n.href=r.imageData,n.download=`generated-${r.id}.png`,document.body.appendChild(n),n.click(),document.body.removeChild(n)}};return A.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[99999] flex items-center justify-center",onClick:o,children:[e.jsx("div",{className:"absolute inset-0 bg-black/90 backdrop-blur-sm"}),e.jsxs("div",{className:"relative flex flex-col lg:flex-row max-w-7xl max-h-[95vh] w-full mx-4 gap-4",onClick:n=>n.stopPropagation(),children:[e.jsx("button",{onClick:o,className:d("absolute -top-12 right-0 lg:top-0 lg:-right-12 z-10","p-2 rounded-full","bg-white/10 hover:bg-white/20","transition-colors"),children:e.jsx(Q,{className:"h-6 w-6 text-white"})}),e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:e.jsx("img",{src:r.imageData,alt:r.prompt,className:"max-w-full max-h-[70vh] lg:max-h-[90vh] object-contain rounded-lg"})}),e.jsxs("div",{className:d("w-full lg:w-80 flex-shrink-0","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","rounded-xl p-4 lg:p-5","overflow-y-auto max-h-[25vh] lg:max-h-[90vh]"),children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 ophelia:text-[#737373] mb-1",children:i("gallery.prompt")}),e.jsx("p",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa] text-sm leading-relaxed",children:r.prompt})]}),e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(H,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.model"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r.model})]}),r.size&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(U,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.size"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r.size})]}),r.quality&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-gray-400 dark:text-gray-500 ophelia:text-[#525252] text-xs font-bold",children:"Q"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.quality"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa] capitalize",children:r.quality})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(W,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.created"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:j(r.createdAt)})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t border-gray-200 dark:border-dark-300 ophelia:border-[#262626]",children:[e.jsxs("button",{onClick:f,className:d("flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg","bg-primary-600 dark:bg-primary-600 ophelia:bg-[#9333ea]","hover:bg-primary-700 dark:hover:bg-primary-500 ophelia:hover:bg-[#a855f7]","text-white font-medium text-sm","transition-colors"),children:[e.jsx(M,{className:"h-4 w-4"}),i("gallery.download")]}),h&&e.jsx("button",{onClick:()=>h(r.id),className:d("p-2.5 rounded-lg","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","hover:bg-red-100 dark:hover:bg-red-900/30 ophelia:hover:bg-red-900/30","text-gray-600 dark:text-gray-300 ophelia:text-[#a3a3a3]","hover:text-red-600 dark:hover:text-red-400 ophelia:hover:text-red-400","transition-colors"),title:"Delete image",children:e.jsx($,{className:"h-4 w-4"})})]})]})]})]}),document.body)},Y=({onImageCountChange:r})=>{const{t:o}=q(),[h,s]=l.useState([]),[i,j]=l.useState(0),[f,n]=l.useState(!0),[m,G]=l.useState(!1),[p,S]=l.useState(null),[b,C]=l.useState(null),P=20,N=l.useCallback(async(t=0,u=!1)=>{try{t===0?n(!0):G(!0);const c=await E.getGallery({limit:P,offset:t});c.success&&c.data&&(s(u?v=>[...v,...c.data.images]:c.data.images),j(c.data.total),r?.(c.data.total))}catch(c){console.error("Failed to load gallery:",c),k.error(o("imageGallery.loadFailed"))}finally{n(!1),G(!1)}},[r,o]);l.useEffect(()=>{N()},[N]);const D=()=>{N(h.length,!0)},z=async(t,u)=>{if(u.stopPropagation(),!b){C(t);try{(await E.deleteGalleryImage(t)).success?(s(v=>v.filter(y=>y.id!==t)),j(v=>v-1),r?.(i-1),k.success(o("imageGallery.deleteSuccess")),p?.id===t&&S(null)):k.error(o("imageGallery.deleteFailed"))}catch(c){console.error("Failed to delete image:",c),k.error(o("imageGallery.deleteFailed"))}finally{C(null)}}},w=(t,u)=>{u.stopPropagation();const c=document.createElement("a");c.href=t.imageData,c.download=`generated-${t.id}.png`,document.body.appendChild(c),c.click(),document.body.removeChild(c)},I=t=>new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});return f?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(L,{className:"h-8 w-8 animate-spin text-gray-400 dark:text-gray-500"})}):h.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(X,{className:"h-16 w-16 text-gray-300 dark:text-gray-600 ophelia:text-[#404040] mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa] mb-2",children:o("imageGallery.noImages")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373] max-w-sm",children:o("imageGallery.noImagesHint")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:d("columns-1 sm:columns-2 lg:columns-3 xl:columns-4","gap-4 space-y-4"),children:h.map(t=>e.jsxs("div",{className:d("break-inside-avoid group relative cursor-pointer","rounded-xl overflow-hidden","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","hover:border-gray-300 dark:hover:border-dark-400 ophelia:hover:border-[#404040]","transition-all duration-200","hover:shadow-lg dark:hover:shadow-dark-400/20 ophelia:hover:shadow-[#9333ea]/10"),onClick:()=>S(t),children:[e.jsx("img",{src:t.imageData,alt:t.prompt,className:"w-full h-auto object-cover",loading:"lazy"}),e.jsxs("div",{className:d("absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent","opacity-0 group-hover:opacity-100 transition-opacity duration-200","flex flex-col justify-end p-3"),children:[e.jsx("p",{className:"text-white text-sm line-clamp-2 mb-2",children:t.prompt}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-white/70 text-xs",children:I(t.createdAt)}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:u=>w(t,u),className:d("p-1.5 rounded-lg","bg-white/20 hover:bg-white/30","transition-colors"),title:o("imageGallery.download"),children:e.jsx(M,{className:"h-4 w-4 text-white"})}),e.jsx("button",{onClick:u=>z(t.id,u),disabled:b===t.id,className:d("p-1.5 rounded-lg","bg-white/20 hover:bg-red-500/80","transition-colors",b===t.id&&"opacity-50 cursor-not-allowed"),title:o("imageGallery.delete"),children:b===t.id?e.jsx(L,{className:"h-4 w-4 text-white animate-spin"}):e.jsx($,{className:"h-4 w-4 text-white"})})]})]})]})]},t.id))}),h.length<i&&e.jsx("div",{className:"flex justify-center mt-8",children:e.jsx("button",{onClick:D,disabled:m,className:d("px-6 py-2.5 rounded-xl font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626]","text-gray-700 dark:text-gray-200 ophelia:text-[#fafafa]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","transition-colors","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4 animate-spin"}),o("common.loading")]}):o("imageGallery.loadMore",{current:h.length,total:i})})}),p&&e.jsx(V,{image:p,onClose:()=>S(null),onDelete:t=>{z(t,{stopPropagation:()=>{}})},onDownload:t=>{w(t,{stopPropagation:()=>{}})}})]})},Z=({isOpen:r,onClose:o,onImageGenerated:h})=>{const{t:s}=q(),[i,j]=l.useState([]),[f,n]=l.useState(""),[m,G]=l.useState(""),[p,S]=l.useState(""),[b,C]=l.useState("1024x1024"),[P,N]=l.useState("standard"),[D,z]=l.useState(!1),[w,I]=l.useState(null),[t,u]=l.useState(["512x512","768x768","1024x1024"]),[c,v]=l.useState(["standard","high"]),[y,_]=l.useState(null);l.useEffect(()=>{r&&(async()=>{try{const x=await E.getPlugins();if(x.success&&x.data&&(j(x.data),x.data.length>0)){const g=x.data[0];n(g.id),g.models.length>0&&G(g.models[0]),g.config?.sizes&&(u(g.config.sizes),C(g.config.default_size||g.config.sizes[0]||"1024x1024")),g.config?.qualities&&(v(g.config.qualities),N(g.config.default_quality||g.config.qualities[0]||"standard")),_(g.config?.max_prompt_length??null)}}catch(x){console.error("Failed to load image generation plugins:",x)}})()},[r]),l.useEffect(()=>{const a=i.find(x=>x.id===f);a&&(a.models.length>0&&!a.models.includes(m)&&G(a.models[0]),a.config?.sizes&&(u(a.config.sizes),a.config.sizes.includes(b)||C(a.config.default_size||a.config.sizes[0])),a.config?.qualities&&(v(a.config.qualities),a.config.qualities.includes(P)||N(a.config.default_quality||a.config.qualities[0])),_(a.config?.max_prompt_length??null))},[f,i,m,b,P]);const B=async()=>{if(!m||!p.trim()){k.error(s("imageGeneration.enterPrompt"));return}if(y&&p.length>y){k.error(s("imageGeneration.promptTooLong",{max:y.toLocaleString()}));return}z(!0),I(null);try{const a=await E.generate({model:m,prompt:p.trim(),size:b,quality:P});if(a.success&&a.data?.images&&a.data.images.length>0){const x=a.data.images[0];let g=null;x.b64_json?g=`data:image/png;base64,${x.b64_json}`:x.url&&(g=x.url),g&&(k.success(s("imageGeneration.success")),h?(h(g,p.trim(),m),S(""),I(null),o()):I(g))}else k.error(s("imageGeneration.failed"))}catch(a){console.error("Image generation failed:",a);const x=a instanceof Error?a.message:s("imageGeneration.failed");k.error(x)}finally{z(!1)}},K=()=>{if(!w)return;const a=document.createElement("a");a.href=w,a.download=`generated-image-${Date.now()}.png`,document.body.appendChild(a),a.click(),document.body.removeChild(a)};if(!r)return null;const R=i.find(a=>a.id===f);return A.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[99999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:o}),e.jsxs("div",{className:d("relative bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","rounded-2xl shadow-2xl","w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col"),onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5 text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]"}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:s("imageGeneration.title")})]}),e.jsx("button",{onClick:o,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a] transition-colors",children:e.jsx(Q,{className:"h-5 w-5 text-gray-500 dark:text-gray-400"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:i.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(F,{className:"h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600 ophelia:text-[#525252]"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:s("imageGeneration.noModels")}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:s("imageGeneration.configurePlugin")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("settings.plugins.title")}),e.jsx("select",{value:f,onChange:a=>n(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:i.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.model")}),e.jsx("select",{value:m,onChange:a=>G(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:R?.models.map(a=>e.jsx("option",{value:a,children:a},a))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.size")}),e.jsx("select",{value:b,onChange:a=>C(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:t.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.quality")}),e.jsx("select",{value:P,onChange:a=>N(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:c.map(a=>e.jsx("option",{value:a,children:a.charAt(0).toUpperCase()+a.slice(1)},a))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.prompt")}),e.jsx("textarea",{value:p,onChange:a=>S(a.target.value),placeholder:s("imageGeneration.promptPlaceholder"),rows:5,className:d("w-full px-3 py-2 rounded-lg text-sm resize-none","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#737373]","focus:outline-none focus:ring-2 focus:ring-primary-500/20",y&&p.length>y&&"border-red-500 dark:border-red-500 ophelia:border-red-500")}),y&&e.jsxs("div",{className:d("text-xs mt-1 text-right",p.length>y?"text-red-500":"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]"),children:[p.length.toLocaleString()," /"," ",y.toLocaleString()]})]}),w&&e.jsxs("div",{className:"relative rounded-xl overflow-hidden border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]",children:[e.jsx("img",{src:w,alt:"Generated",className:"w-full h-auto"}),e.jsx("button",{onClick:K,className:d("absolute bottom-3 right-3 p-2 rounded-lg","bg-white/90 dark:bg-dark-100/90 ophelia:bg-[#0a0a0a]/90","hover:bg-white dark:hover:bg-dark-100 ophelia:hover:bg-[#0a0a0a]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","transition-colors"),title:s("imageGallery.download"),children:e.jsx(M,{className:"h-5 w-5 text-gray-700 dark:text-gray-200 ophelia:text-[#fafafa]"})})]})]})}),i.length>0&&e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:e.jsx(T,{onClick:B,disabled:D||!p.trim()||!m,className:d("w-full py-2.5 rounded-xl font-medium","bg-primary-600 dark:bg-primary-600 ophelia:bg-[#9333ea]","hover:bg-primary-700 dark:hover:bg-primary-500 ophelia:hover:bg-[#a855f7]","text-white","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors"),children:D?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(L,{className:"h-4 w-4 animate-spin"}),s("imageGeneration.generating")]}):e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(J,{className:"h-4 w-4"}),s("imageGeneration.generate")]})})})]})]}),document.body)},le=()=>{const{t:r}=q(),[o,h]=l.useState(null),[s,i]=l.useState(!1),[j,f]=l.useState(0),n=l.useCallback(()=>{f(m=>m+1)},[]);return e.jsxs("div",{className:"h-full overflow-auto",children:[e.jsxs("div",{className:"max-w-7xl mx-auto p-6",children:[e.jsxs("div",{className:"text-center max-w-md mx-auto mb-8",children:[e.jsx("h2",{className:"libre-brand text-4xl sm:text-5xl font-normal text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa] mb-3",style:{fontWeight:300,letterSpacing:"0.01em"},children:r("sidebar.navigation.imagine")}),e.jsxs("p",{className:"text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] leading-relaxed",children:[r("gallery.subtitle"),o!==null&&o>0&&e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 ophelia:text-[#737373]",children:[" ","· ",r("gallery.imageCount",{count:o})]})]}),e.jsxs(T,{onClick:()=>i(!0),className:d("mt-4 px-6 py-2.5 rounded-xl font-medium","bg-primary-600 dark:bg-primary-600 ophelia:bg-[#9333ea]","hover:bg-primary-700 dark:hover:bg-primary-500 ophelia:hover:bg-[#a855f7]","text-white","transition-colors"),children:[e.jsx(O,{className:"h-4 w-4 mr-2"}),r("gallery.generate")]})]}),e.jsx(Y,{onImageCountChange:h},j)]}),e.jsx(Z,{isOpen:s,onClose:()=>i(!1),onImageGenerated:n})]})};export{le as GalleryPage,le as default};
1
+ import{j as e}from"./markdown-vendor-B0lXrrRZ.js";import{r as l,e as A}from"./router-vendor-DdQhGl5t.js";import{a as q,c as d,i as E,B as T}from"../assets/index-DW8C1vVk.js";import{X as Q,ad as H,aB as U,aq as W,k as M,T as $,F as k,L,aC as X,I as F,u as J,t as O}from"./ui-vendor-C4ZcWovR.js";import"./utils-vendor-BFlGJDIj.js";const V=({image:r,onClose:o,onDelete:h,onDownload:s})=>{const{t:i}=q();l.useEffect(()=>{const n=m=>{m.key==="Escape"&&o()};return document.addEventListener("keydown",n),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",n),document.body.style.overflow=""}},[o]);const j=n=>new Date(n).toLocaleString(void 0,{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),f=()=>{if(s)s(r);else{const n=document.createElement("a");n.href=r.imageData,n.download=`generated-${r.id}.png`,document.body.appendChild(n),n.click(),document.body.removeChild(n)}};return A.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[99999] flex items-center justify-center",onClick:o,children:[e.jsx("div",{className:"absolute inset-0 bg-black/90 backdrop-blur-sm"}),e.jsxs("div",{className:"relative flex flex-col lg:flex-row max-w-7xl max-h-[95vh] w-full mx-4 gap-4",onClick:n=>n.stopPropagation(),children:[e.jsx("button",{onClick:o,className:d("absolute -top-12 right-0 lg:top-0 lg:-right-12 z-10","p-2 rounded-full","bg-white/10 hover:bg-white/20","transition-colors"),children:e.jsx(Q,{className:"h-6 w-6 text-white"})}),e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:e.jsx("img",{src:r.imageData,alt:r.prompt,className:"max-w-full max-h-[70vh] lg:max-h-[90vh] object-contain rounded-lg"})}),e.jsxs("div",{className:d("w-full lg:w-80 flex-shrink-0","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","rounded-xl p-4 lg:p-5","overflow-y-auto max-h-[25vh] lg:max-h-[90vh]"),children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-500 dark:text-gray-400 ophelia:text-[#737373] mb-1",children:i("gallery.prompt")}),e.jsx("p",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa] text-sm leading-relaxed",children:r.prompt})]}),e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(H,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.model"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r.model})]}),r.size&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(U,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.size"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r.size})]}),r.quality&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"w-4 h-4 flex items-center justify-center text-gray-400 dark:text-gray-500 ophelia:text-[#525252] text-xs font-bold",children:"Q"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.quality"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa] capitalize",children:r.quality})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(W,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:[i("gallery.created"),":"]}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:j(r.createdAt)})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t border-gray-200 dark:border-dark-300 ophelia:border-[#262626]",children:[e.jsxs("button",{onClick:f,className:d("flex-1 flex items-center justify-center gap-2 py-2.5 rounded-lg","bg-primary-600 dark:bg-primary-600 ophelia:bg-[#9333ea]","hover:bg-primary-700 dark:hover:bg-primary-500 ophelia:hover:bg-[#a855f7]","text-white font-medium text-sm","transition-colors"),children:[e.jsx(M,{className:"h-4 w-4"}),i("gallery.download")]}),h&&e.jsx("button",{onClick:()=>h(r.id),className:d("p-2.5 rounded-lg","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","hover:bg-red-100 dark:hover:bg-red-900/30 ophelia:hover:bg-red-900/30","text-gray-600 dark:text-gray-300 ophelia:text-[#a3a3a3]","hover:text-red-600 dark:hover:text-red-400 ophelia:hover:text-red-400","transition-colors"),title:"Delete image",children:e.jsx($,{className:"h-4 w-4"})})]})]})]})]}),document.body)},Y=({onImageCountChange:r})=>{const{t:o}=q(),[h,s]=l.useState([]),[i,j]=l.useState(0),[f,n]=l.useState(!0),[m,G]=l.useState(!1),[p,S]=l.useState(null),[b,C]=l.useState(null),P=20,N=l.useCallback(async(t=0,u=!1)=>{try{t===0?n(!0):G(!0);const c=await E.getGallery({limit:P,offset:t});c.success&&c.data&&(s(u?v=>[...v,...c.data.images]:c.data.images),j(c.data.total),r?.(c.data.total))}catch(c){console.error("Failed to load gallery:",c),k.error(o("imageGallery.loadFailed"))}finally{n(!1),G(!1)}},[r,o]);l.useEffect(()=>{N()},[N]);const D=()=>{N(h.length,!0)},z=async(t,u)=>{if(u.stopPropagation(),!b){C(t);try{(await E.deleteGalleryImage(t)).success?(s(v=>v.filter(y=>y.id!==t)),j(v=>v-1),r?.(i-1),k.success(o("imageGallery.deleteSuccess")),p?.id===t&&S(null)):k.error(o("imageGallery.deleteFailed"))}catch(c){console.error("Failed to delete image:",c),k.error(o("imageGallery.deleteFailed"))}finally{C(null)}}},w=(t,u)=>{u.stopPropagation();const c=document.createElement("a");c.href=t.imageData,c.download=`generated-${t.id}.png`,document.body.appendChild(c),c.click(),document.body.removeChild(c)},I=t=>new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});return f?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(L,{className:"h-8 w-8 animate-spin text-gray-400 dark:text-gray-500"})}):h.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(X,{className:"h-16 w-16 text-gray-300 dark:text-gray-600 ophelia:text-[#404040] mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa] mb-2",children:o("imageGallery.noImages")}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373] max-w-sm",children:o("imageGallery.noImagesHint")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:d("columns-1 sm:columns-2 lg:columns-3 xl:columns-4","gap-4 space-y-4"),children:h.map(t=>e.jsxs("div",{className:d("break-inside-avoid group relative cursor-pointer","rounded-xl overflow-hidden","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","hover:border-gray-300 dark:hover:border-dark-400 ophelia:hover:border-[#404040]","transition-all duration-200","hover:shadow-lg dark:hover:shadow-dark-400/20 ophelia:hover:shadow-[#9333ea]/10"),onClick:()=>S(t),children:[e.jsx("img",{src:t.imageData,alt:t.prompt,className:"w-full h-auto object-cover",loading:"lazy"}),e.jsxs("div",{className:d("absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent","opacity-0 group-hover:opacity-100 transition-opacity duration-200","flex flex-col justify-end p-3"),children:[e.jsx("p",{className:"text-white text-sm line-clamp-2 mb-2",children:t.prompt}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-white/70 text-xs",children:I(t.createdAt)}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:u=>w(t,u),className:d("p-1.5 rounded-lg","bg-white/20 hover:bg-white/30","transition-colors"),title:o("imageGallery.download"),children:e.jsx(M,{className:"h-4 w-4 text-white"})}),e.jsx("button",{onClick:u=>z(t.id,u),disabled:b===t.id,className:d("p-1.5 rounded-lg","bg-white/20 hover:bg-red-500/80","transition-colors",b===t.id&&"opacity-50 cursor-not-allowed"),title:o("imageGallery.delete"),children:b===t.id?e.jsx(L,{className:"h-4 w-4 text-white animate-spin"}):e.jsx($,{className:"h-4 w-4 text-white"})})]})]})]})]},t.id))}),h.length<i&&e.jsx("div",{className:"flex justify-center mt-8",children:e.jsx("button",{onClick:D,disabled:m,className:d("px-6 py-2.5 rounded-xl font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626]","text-gray-700 dark:text-gray-200 ophelia:text-[#fafafa]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","transition-colors","disabled:opacity-50 disabled:cursor-not-allowed"),children:m?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4 animate-spin"}),o("common.loading")]}):o("imageGallery.loadMore",{current:h.length,total:i})})}),p&&e.jsx(V,{image:p,onClose:()=>S(null),onDelete:t=>{z(t,{stopPropagation:()=>{}})},onDownload:t=>{w(t,{stopPropagation:()=>{}})}})]})},Z=({isOpen:r,onClose:o,onImageGenerated:h})=>{const{t:s}=q(),[i,j]=l.useState([]),[f,n]=l.useState(""),[m,G]=l.useState(""),[p,S]=l.useState(""),[b,C]=l.useState("1024x1024"),[P,N]=l.useState("standard"),[D,z]=l.useState(!1),[w,I]=l.useState(null),[t,u]=l.useState(["512x512","768x768","1024x1024"]),[c,v]=l.useState(["standard","high"]),[y,_]=l.useState(null);l.useEffect(()=>{r&&(async()=>{try{const x=await E.getPlugins();if(x.success&&x.data&&(j(x.data),x.data.length>0)){const g=x.data[0];n(g.id),g.models.length>0&&G(g.models[0]),g.config?.sizes&&(u(g.config.sizes),C(g.config.default_size||g.config.sizes[0]||"1024x1024")),g.config?.qualities&&(v(g.config.qualities),N(g.config.default_quality||g.config.qualities[0]||"standard")),_(g.config?.max_prompt_length??null)}}catch(x){console.error("Failed to load image generation plugins:",x)}})()},[r]),l.useEffect(()=>{const a=i.find(x=>x.id===f);a&&(a.models.length>0&&!a.models.includes(m)&&G(a.models[0]),a.config?.sizes&&(u(a.config.sizes),a.config.sizes.includes(b)||C(a.config.default_size||a.config.sizes[0])),a.config?.qualities&&(v(a.config.qualities),a.config.qualities.includes(P)||N(a.config.default_quality||a.config.qualities[0])),_(a.config?.max_prompt_length??null))},[f,i,m,b,P]);const B=async()=>{if(!m||!p.trim()){k.error(s("imageGeneration.enterPrompt"));return}if(y&&p.length>y){k.error(s("imageGeneration.promptTooLong",{max:y.toLocaleString()}));return}z(!0),I(null);try{const a=await E.generate({model:m,prompt:p.trim(),size:b,quality:P});if(a.success&&a.data?.images&&a.data.images.length>0){const x=a.data.images[0];let g=null;x.b64_json?g=`data:image/png;base64,${x.b64_json}`:x.url&&(g=x.url),g&&(k.success(s("imageGeneration.success")),h?(h(g,p.trim(),m),S(""),I(null),o()):I(g))}else k.error(s("imageGeneration.failed"))}catch(a){console.error("Image generation failed:",a);const x=a instanceof Error?a.message:s("imageGeneration.failed");k.error(x)}finally{z(!1)}},K=()=>{if(!w)return;const a=document.createElement("a");a.href=w,a.download=`generated-image-${Date.now()}.png`,document.body.appendChild(a),a.click(),document.body.removeChild(a)};if(!r)return null;const R=i.find(a=>a.id===f);return A.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[99999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:o}),e.jsxs("div",{className:d("relative bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","rounded-2xl shadow-2xl","w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col"),onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5 text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]"}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:s("imageGeneration.title")})]}),e.jsx("button",{onClick:o,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a] transition-colors",children:e.jsx(Q,{className:"h-5 w-5 text-gray-500 dark:text-gray-400"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:i.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(F,{className:"h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600 ophelia:text-[#525252]"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]",children:s("imageGeneration.noModels")}),e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:s("imageGeneration.configurePlugin")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("settings.plugins.title")}),e.jsx("select",{value:f,onChange:a=>n(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:i.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.model")}),e.jsx("select",{value:m,onChange:a=>G(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:R?.models.map(a=>e.jsx("option",{value:a,children:a},a))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.size")}),e.jsx("select",{value:b,onChange:a=>C(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:t.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.quality")}),e.jsx("select",{value:P,onChange:a=>N(a.target.value),className:d("w-full px-3 py-2 rounded-lg text-sm","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:c.map(a=>e.jsx("option",{value:a,children:a.charAt(0).toUpperCase()+a.slice(1)},a))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:s("imageGeneration.prompt")}),e.jsx("textarea",{value:p,onChange:a=>S(a.target.value),placeholder:s("imageGeneration.promptPlaceholder"),rows:5,className:d("w-full px-3 py-2 rounded-lg text-sm resize-none","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#737373]","focus:outline-none focus:ring-2 focus:ring-primary-500/20",y&&p.length>y&&"border-red-500 dark:border-red-500 ophelia:border-red-500")}),y&&e.jsxs("div",{className:d("text-xs mt-1 text-right",p.length>y?"text-red-500":"text-gray-500 dark:text-gray-400 ophelia:text-[#737373]"),children:[p.length.toLocaleString()," /"," ",y.toLocaleString()]})]}),w&&e.jsxs("div",{className:"relative rounded-xl overflow-hidden border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]",children:[e.jsx("img",{src:w,alt:"Generated",className:"w-full h-auto"}),e.jsx("button",{onClick:K,className:d("absolute bottom-3 right-3 p-2 rounded-lg","bg-white/90 dark:bg-dark-100/90 ophelia:bg-[#0a0a0a]/90","hover:bg-white dark:hover:bg-dark-100 ophelia:hover:bg-[#0a0a0a]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","transition-colors"),title:s("imageGallery.download"),children:e.jsx(M,{className:"h-5 w-5 text-gray-700 dark:text-gray-200 ophelia:text-[#fafafa]"})})]})]})}),i.length>0&&e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:e.jsx(T,{onClick:B,disabled:D||!p.trim()||!m,className:d("w-full py-2.5 rounded-xl font-medium","bg-primary-600 dark:bg-primary-600 ophelia:bg-[#9333ea]","hover:bg-primary-700 dark:hover:bg-primary-500 ophelia:hover:bg-[#a855f7]","text-white","disabled:opacity-50 disabled:cursor-not-allowed","transition-colors"),children:D?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(L,{className:"h-4 w-4 animate-spin"}),s("imageGeneration.generating")]}):e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx(J,{className:"h-4 w-4"}),s("imageGeneration.generate")]})})})]})]}),document.body)},le=()=>{const{t:r}=q(),[o,h]=l.useState(null),[s,i]=l.useState(!1),[j,f]=l.useState(0),n=l.useCallback(()=>{f(m=>m+1)},[]);return e.jsxs("div",{className:"h-full overflow-auto",children:[e.jsxs("div",{className:"max-w-7xl mx-auto p-6",children:[e.jsxs("div",{className:"text-center max-w-md mx-auto mb-8",children:[e.jsx("h2",{className:"libre-brand text-4xl sm:text-5xl font-normal text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa] mb-3",style:{fontWeight:300,letterSpacing:"0.01em"},children:r("sidebar.navigation.imagine")}),e.jsxs("p",{className:"text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] leading-relaxed",children:[r("gallery.subtitle"),o!==null&&o>0&&e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 ophelia:text-[#737373]",children:[" ","· ",r("gallery.imageCount",{count:o})]})]}),e.jsxs(T,{onClick:()=>i(!0),className:d("mt-4 px-6 py-2.5 rounded-xl font-medium","bg-primary-600 dark:bg-primary-600 ophelia:bg-[#9333ea]","hover:bg-primary-700 dark:hover:bg-primary-500 ophelia:hover:bg-[#a855f7]","text-white","transition-colors"),children:[e.jsx(O,{className:"h-4 w-4 mr-2"}),r("gallery.generate")]})]}),e.jsx(Y,{onImageCountChange:h},j)]}),e.jsx(Z,{isOpen:s,onClose:()=>i(!1),onImageGenerated:n})]})};export{le as GalleryPage,le as default};
@@ -1 +1 @@
1
- import{j as e}from"./markdown-vendor-QwEm2Xso.js";import{r as l,e as Z}from"./router-vendor-CmbUVdlE.js";import{a as We,b as Ga,o as h,h as Re,c as s,B as g}from"../assets/index-CT6_wIIb.js";import{z as o,a3 as f,al as Ta,ab as T,am as _a,an as Ae,k as C,i as _,j as z,a8 as pe,X as F,f as ue,ac as Ba,ao as Ra,C as Aa,$ as $e,ae as qe,af as $a,ap as qa,ad as Ua,aq as Va,ar as Wa,d as Ia,O as be,T as Ka,w as Oa,as as Ue,at as Ve,au as Xa}from"./ui-vendor-DsBonqC3.js";import"./utils-vendor-3oAsqusP.js";const Za=()=>{const{t:r}=We(),{user:Ie,systemInfo:Ke}=Ga(),p=Ie?.role==="admin"||(Ke?.allowUserModelPull??!0),[u,Oe]=l.useState([]),[b,Xe]=l.useState([]),[j,Ze]=l.useState([]),[J,fe]=l.useState(!1),[Q,Je]=l.useState("all"),[B,Qe]=l.useState(""),[Ye,ye]=l.useState(!1),[Y,R]=l.useState(""),[v,H]=l.useState(!1),[c,N]=l.useState(null),[ke,P]=l.useState(null),[n,ea]=l.useState(null),[aa,ra]=l.useState(""),[sa,ee]=l.useState(!1),[ta,je]=l.useState(!1),[la,E]=l.useState(!1),[A,ae]=l.useState(""),[D,ve]=l.useState(""),[re,Ne]=l.useState(!1),[da,$]=l.useState(!1),[L,we]=l.useState(""),[q,Me]=l.useState(""),[se,Se]=l.useState(!1),[oa,te]=l.useState(!1),[U,ia]=l.useState(""),[V,na]=l.useState(""),[W,Ce]=l.useState(null),[le,ze]=l.useState(!1),[Fe,ca]=l.useState(null),[He,I]=l.useState(null),[K,ga]=l.useState([]),[de,Pe]=l.useState(!1),[oe,xa]=l.useState(""),[Ee,ha]=l.useState(""),[ie,ma]=l.useState("text-generation"),[ne,pa]=l.useState("downloads"),[ce,De]=l.useState(null),[ge,ua]=l.useState({}),[ba,Le]=l.useState(null),[w,G]=l.useState(null),[O,M]=l.useState(null),[xe,X]=l.useState(null),[x,fa]=l.useState(new Set(["pull","local"])),S=a=>{fa(t=>{const d=new Set(t);return d.has(a)?d.delete(a):d.add(a),d})},y=l.useCallback(async()=>{ye(!0);try{const[a,t,d,i]=await Promise.all([h.getModels(),h.listRunningModels(),h.getVersion(),h.checkHealth()]);a.success&&Oe(a.data||[]),t.success&&Xe(Array.isArray(t.data)?t.data:[]),d.success&&d.data&&ca(d.data.version),I(i.success)}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.pull.failed")+": "+t),I(!1)}finally{ye(!1)}},[r]),Ge=async()=>{fe(!0);try{const a=await h.getLibraryModels();a.success&&a.data&&Ze(a.data)}catch(a){console.error("Failed to load library models:",a)}finally{fe(!1)}};l.useEffect(()=>{y(),Ge()},[]),l.useEffect(()=>{const a=setTimeout(()=>{ha(oe)},300);return()=>clearTimeout(a)},[oe]);const Te=async()=>{Pe(!0);try{const a=await Re.getModels({task:ie,search:Ee||void 0,sort:ne,limit:30});a.success&&a.data&&ga(a.data)}catch(a){console.error("Failed to load HuggingFace models:",a)}finally{Pe(!1)}};l.useEffect(()=>{x.has("huggingface")&&Te()},[x,ie,Ee,ne]);const _e=l.useCallback(async a=>{const[t,d]=a.split("/");if(!(!t||!d)){Le(a);try{const i=await Re.getGgufFiles(t,d);i.success&&i.data&&ua(m=>({...m,[a]:i.data}))}catch(i){console.error("Failed to load GGUF files:",i)}finally{Le(null)}}},[]),ya=l.useCallback(a=>{ce===a?De(null):(De(a),ge[a]||_e(a))},[ce,ge,_e]),ka=l.useCallback((a,t)=>{if(!p){o.error(r("modelManager.pull.restricted"));return}if(!w){G(a),M({status:"starting"});try{const d=h.pullModelStream(a,i=>{M(i)},()=>{M(null),G(null),X(null),o.success(`Downloaded ${t}`),y()},i=>{M(null),G(null),X(null),o.error(`Failed to download: ${i}`)});X(()=>d)}catch{M(null),G(null),o.error("Failed to start download")}}},[p,w,y,r]),ja=l.useCallback(()=>{xe&&(xe(),X(null),G(null),M(null))},[xe]),he=async a=>{if(!p){o.error(r("modelManager.pull.restricted"));return}const t=a||Y.trim();if(!t){o.error(r("modelManager.pull.enterName"));return}a&&R(a),H(!0),N({status:"starting"});try{const d=h.pullModelStream(t,i=>{N(i)},()=>{N(null),H(!1),P(null),o.success(r("modelManager.pull.success",{name:t})),R(""),y()},i=>{N(null),H(!1),P(null),o.error(r("modelManager.pull.failed")+": "+i)});P(()=>d)}catch(d){const i=d instanceof Error?d.message:String(d);o.error(r("modelManager.pull.failed")+": "+i),N(null),H(!1),P(null)}},va=()=>{ke&&(ke(),P(null),H(!1),N(null),o.success(r("modelManager.pull.cancelled")))},Na=async a=>{if(confirm(r("modelManager.local.deleteConfirm",{name:a})))try{await h.deleteModel(a),o.success(r("modelManager.local.deleteSuccess",{name:a})),await y()}catch(t){const d=t instanceof Error?t.message:String(t);o.error(r("modelManager.local.deleteFailed")+": "+d)}},wa=async a=>{je(!0),ra(a),ee(!0);try{const t=await h.showModel(a,!0);t.success&&t.data?ea(t.data):o.error(r("modelManager.modals.details.noDetails"))}catch(t){const d=t instanceof Error?t.message:String(t);o.error(r("modelManager.modals.details.noDetails")+": "+d)}finally{je(!1)}},Ma=async()=>{if(!A.trim()||!D.trim()){o.error(r("modelManager.modals.copy.enterBoth"));return}Ne(!0);try{await h.copyModel(A.trim(),D.trim()),o.success(r("modelManager.modals.copy.success",{name:D})),E(!1),ae(""),ve(""),await y()}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.modals.copy.failed")+": "+t)}finally{Ne(!1)}},Sa=async()=>{if(!L.trim()||!q.trim()){o.error(r("modelManager.modals.create.enterBoth"));return}Se(!0);try{await h.createModel({model:L.trim(),modelfile:q.trim()}),o.success(r("modelManager.modals.create.success",{name:L})),$(!1),we(""),Me(""),await y()}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.modals.create.failed")+": "+t)}finally{Se(!1)}},Ca=async()=>{if(!U.trim()||!V.trim()){o.error(r("modelManager.modals.embeddings.enterBoth"));return}ze(!0),Ce(null);try{const a=await h.generateEmbeddings({model:U.trim(),input:V.trim()});if(a.success&&a.data){const t=a.data.embeddings?.[0]||[];Ce(t),o.success(r("modelManager.modals.embeddings.success",{count:t.length}))}}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.modals.embeddings.failed")+": "+t)}finally{ze(!1)}},k=a=>{const t=a/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(a/(1024*1024)).toFixed(1)} MB`},za=a=>Array.isArray(b)&&b.some(t=>t.name===a),Fa=()=>u.reduce((a,t)=>a+t.size,0),Ha=()=>b.reduce((a,t)=>a+(t.size_vram||0),0),Pa=a=>u.some(t=>t.name===a||t.name.startsWith(a+":")),Be=j.filter(a=>{const t=Q==="all"||a.category===Q,d=!B||a.name.toLowerCase().includes(B.toLowerCase())||a.description.toLowerCase().includes(B.toLowerCase());return t&&d}),Ea=["all",...new Set(j.map(a=>a.category))],Da=l.useMemo(()=>j.length>0?j.slice(0,10).map(a=>({name:a.name,category:a.category,size:a.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"}],[j]);return Ye?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsxs("div",{className:"flex items-center gap-3 text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3]",children:[e.jsx(f,{className:"h-5 w-5 animate-spin"}),r("modelManager.loading")]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:s("rounded-xl p-4 border","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:s("w-2.5 h-2.5 rounded-full",He?"bg-green-500 ophelia:bg-[#4ade80]":"bg-red-500 ophelia:bg-[#f87171]")}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]",children:r(He?"modelManager.systemStatus.online":"modelManager.systemStatus.offline")})]}),Fe&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]",children:[e.jsx(Ta,{className:"h-4 w-4"}),e.jsxs("span",{children:["v",Fe]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]",children:[e.jsx(T,{className:"h-4 w-4"}),e.jsxs("span",{children:[u.length," ",u.length!==1?r("modelManager.systemStatus.models_plural"):r("modelManager.systemStatus.models")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]",children:[e.jsx(_a,{className:"h-4 w-4"}),e.jsx("span",{children:k(Fa())})]}),b.length>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400 ophelia:text-[#4ade80]",children:[e.jsx(Ae,{className:"h-4 w-4"}),e.jsxs("span",{children:[b.length," ",r("modelManager.systemStatus.running")," (",k(Ha())," ",r("modelManager.systemStatus.vram"),")"]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(g,{onClick:y,variant:"outline",size:"sm",className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(f,{className:"h-3.5 w-3.5"}),r("common.refresh")]})})]})}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("pull"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[#9333ea]/20"),children:e.jsx(C,{className:"h-5 w-5 text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.pull")})]}),x.has("pull")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("pull")&&e.jsxs("div",{className:"p-4 pt-0 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsx("input",{type:"text",value:Y,onChange:a=>R(a.target.value),placeholder:r("modelManager.pull.placeholder"),className:s("w-full pl-10 pr-4 py-2.5 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#525252]","focus:outline-none focus:ring-2 focus:ring-primary-500/20 ophelia:focus:ring-[#9333ea]/20","focus:border-primary-500 ophelia:focus:border-[#9333ea]"),disabled:v||!p,onKeyDown:a=>a.key==="Enter"&&!v&&p&&he()})]}),v?e.jsxs(g,{onClick:va,variant:"outline",className:s("px-4 py-2.5 gap-2","text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300","ophelia:text-[#f87171] ophelia:hover:text-[#fca5a5]","ophelia:border-[#262626] ophelia:hover:bg-[#1a1a1a]"),children:[e.jsx(F,{className:"h-4 w-4"}),r("modelManager.pull.cancel")]}):e.jsxs(g,{onClick:()=>he(),disabled:!Y.trim()||!p,className:s("px-4 py-2.5 gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[e.jsx(C,{className:"h-4 w-4"}),r("modelManager.pull.button")]})]}),v&&c&&e.jsxs("div",{className:s("p-4 rounded-lg border","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-dark-700 ophelia:text-[#e5e5e5]",children:c.status==="starting"?r("modelManager.progress.starting"):c.status.startsWith("pulling")?`${r("modelManager.progress.pullingLayer")} ${c.status.replace("pulling ","")}`:c.status.startsWith("verifying sha256")?r("modelManager.progress.verifyingDigest"):c.status==="writing manifest"?r("modelManager.progress.writing"):c.status==="removing any unused layers"?r("modelManager.progress.cleaning"):c.status}),c.percent!==void 0&&e.jsxs("span",{className:"text-sm font-mono text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3]",children:[c.percent,"%"]})]}),c.percent!==void 0&&e.jsx("div",{className:"w-full bg-gray-200 dark:bg-dark-400 ophelia:bg-[#262626] rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:s("h-2 rounded-full transition-all duration-300","bg-primary-500 dark:bg-primary-400 ophelia:bg-[#9333ea]"),style:{width:`${c.percent}%`}})}),c.total&&c.completed&&e.jsxs("div",{className:"mt-2 text-xs text-gray-600 dark:text-dark-600 ophelia:text-[#737373]",children:[k(c.completed)," /"," ",k(c.total)]})]}),!p&&e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:r("modelManager.pull.restricted")}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 ophelia:text-[#737373] mb-2",children:r("modelManager.pull.popular")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Da.map(a=>e.jsxs("button",{onClick:()=>R(a.name),disabled:v||!p,className:s("px-3 py-1.5 rounded-full text-xs font-medium transition-colors","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3]","hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","disabled:opacity-50 disabled:cursor-not-allowed"),children:[a.name,e.jsx("span",{className:"ml-1 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]",children:a.size})]},a.name))})]}),e.jsxs("a",{href:"https://ollama.com/library",target:"_blank",rel:"noopener noreferrer",className:s("inline-flex items-center gap-1.5 text-xs","text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]","hover:underline"),children:[e.jsx(ue,{className:"h-3 w-3"}),r("modelManager.pull.browseAll")]})]})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("library"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-cyan-100 dark:bg-cyan-900/30 ophelia:bg-[#06b6d4]/20"),children:e.jsx(Ba,{className:"h-5 w-5 text-cyan-600 dark:text-cyan-400 ophelia:text-[#22d3ee]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.library")}),e.jsxs("span",{className:s("px-2 py-0.5 rounded-full text-xs font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:[j.length," ",r("modelManager.library.available")]})]}),x.has("library")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("library")&&e.jsxs("div",{className:"p-4 pt-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsx("input",{type:"text",value:B,onChange:a=>Qe(a.target.value),placeholder:r("modelManager.library.search"),className:s("w-full pl-10 pr-4 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#525252]","focus:outline-none focus:ring-2 focus:ring-primary-500/20 ophelia:focus:ring-[#9333ea]/20","focus:border-primary-500 ophelia:focus:border-[#9333ea]")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"h-4 w-4 text-gray-400 ophelia:text-[#525252]"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ea.map(a=>e.jsx("button",{onClick:()=>Je(a),className:s("px-2.5 py-1 rounded-full text-xs font-medium transition-colors",Q===a?"bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[#9333ea]/20 text-primary-700 dark:text-primary-400 ophelia:text-[#a855f7]":"bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a] text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3] hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626]"),children:a.charAt(0).toUpperCase()+a.slice(1)},a))})]})]}),J?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(f,{className:"h-5 w-5 animate-spin text-gray-400 ophelia:text-[#737373]"})}):Be.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 ophelia:text-[#737373]",children:r("modelManager.library.noResults")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:Be.map(a=>{const t=Pa(a.name);return e.jsxs("div",{className:s("p-4 rounded-lg border transition-all","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]",t?"border-green-200 dark:border-green-800/50 ophelia:border-[#22c55e]/30":"border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400 ophelia:hover:border-[#262626]"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:a.name}),t&&e.jsxs("span",{className:s("flex items-center gap-1 px-1.5 py-0.5 rounded text-xs","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/20","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[e.jsx(Aa,{className:"h-3 w-3"}),r("modelManager.library.installed")]})]}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] mb-3 line-clamp-2",children:a.description}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[a.sizes.slice(0,4).map(d=>e.jsx("span",{className:s("px-1.5 py-0.5 rounded text-xs","bg-gray-200 dark:bg-dark-300 ophelia:bg-[#262626]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:d},d)),a.sizes.length>4&&e.jsx("span",{className:"text-xs text-gray-400 ophelia:text-[#737373]",children:r("modelManager.library.more",{count:a.sizes.length-4})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 ophelia:text-[#737373]",children:[a.pulls&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"h-3 w-3"}),a.pulls]}),e.jsx("span",{className:s("px-1.5 py-0.5 rounded capitalize","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]"),children:a.category})]}),e.jsxs(g,{onClick:()=>{x.has("pull")||S("pull"),he(a.name)},variant:"outline",size:"sm",disabled:v||!p,className:s("gap-1 text-xs","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(C,{className:"h-3 w-3"}),r("modelManager.pull.button")]})]})]},a.name)})}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(g,{onClick:Ge,variant:"outline",size:"sm",disabled:J,className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(f,{className:s("h-3.5 w-3.5",J&&"animate-spin")}),r("modelManager.library.refresh")]})})]})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("huggingface"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-yellow-100 dark:bg-yellow-900/30 ophelia:bg-[#eab308]/20"),children:e.jsx($e,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-400 ophelia:text-[#facc15]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.huggingface","HuggingFace Hub")}),K.length>0&&e.jsxs("span",{className:s("px-2 py-0.5 rounded-full text-xs font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:[K.length," ",r("modelManager.library.available","available")]})]}),x.has("huggingface")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("huggingface")&&e.jsxs("div",{className:"p-4 pt-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsx("input",{type:"text",value:oe,onChange:a=>xa(a.target.value),placeholder:r("modelManager.huggingface.search","Search HuggingFace models..."),className:s("w-full pl-10 pr-4 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#525252]","focus:outline-none focus:ring-2 focus:ring-primary-500/20 ophelia:focus:ring-[#9333ea]/20","focus:border-primary-500 ophelia:focus:border-[#9333ea]")})]}),e.jsxs("select",{value:ie,onChange:a=>ma(a.target.value),className:s("px-3 py-2 rounded-lg border text-sm min-w-[160px]","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:[e.jsx("option",{value:"text-generation",children:r("modelManager.huggingface.tasks.textGen","Text Generation")}),e.jsx("option",{value:"text-to-speech",children:r("modelManager.huggingface.tasks.tts","Text to Speech")}),e.jsx("option",{value:"text-to-image",children:r("modelManager.huggingface.tasks.image","Text to Image")}),e.jsx("option",{value:"automatic-speech-recognition",children:r("modelManager.huggingface.tasks.stt","Speech Recognition")})]}),e.jsxs("select",{value:ne,onChange:a=>pa(a.target.value),className:s("px-3 py-2 rounded-lg border text-sm min-w-[140px]","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:[e.jsx("option",{value:"downloads",children:r("modelManager.huggingface.sort.downloads","Most Downloads")}),e.jsx("option",{value:"likes",children:r("modelManager.huggingface.sort.likes","Most Liked")}),e.jsx("option",{value:"lastModified",children:r("modelManager.huggingface.sort.recent","Recently Updated")})]})]}),!p&&e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:r("modelManager.pull.restricted")}),de?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(qe,{className:"h-5 w-5 animate-spin text-gray-400 ophelia:text-[#737373]"})}):K.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 ophelia:text-[#737373]",children:r("modelManager.huggingface.noResults","No models found. Try adjusting your search or filters.")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:K.map(a=>{const t=ce===a.id,d=ba===a.id,i=ge[a.id]||[];return e.jsxs("div",{className:s("rounded-lg border transition-all overflow-hidden","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400 ophelia:hover:border-[#262626]"),children:[e.jsxs("div",{className:"p-4 cursor-pointer",onClick:()=>ya(a.id),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa] truncate",children:a.id}),a.gated&&e.jsx("span",{className:s("px-1.5 py-0.5 rounded text-xs","bg-yellow-100 dark:bg-yellow-900/30 ophelia:bg-[#eab308]/20","text-yellow-700 dark:text-yellow-400 ophelia:text-[#facc15]"),children:r("modelManager.huggingface.gated","Gated")})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-dark-600 ophelia:text-[#737373] mt-0.5",children:[r("modelManager.huggingface.by","by")," ",a.author]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("a",{href:`https://huggingface.co/${a.id}`,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626] transition-colors",title:r("modelManager.huggingface.viewOnHF","View on HuggingFace"),children:e.jsx(ue,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"})}),e.jsx(z,{className:s("h-4 w-4 text-gray-400 transition-transform",t&&"rotate-180")})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600 ophelia:text-[#737373]",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"h-3.5 w-3.5"}),a.downloads>=1e6?`${(a.downloads/1e6).toFixed(1)}M`:a.downloads>=1e3?`${(a.downloads/1e3).toFixed(1)}K`:a.downloads]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($a,{className:"h-3.5 w-3.5"}),a.likes>=1e3?`${(a.likes/1e3).toFixed(1)}K`:a.likes]}),a.pipeline_tag&&e.jsx("span",{className:s("px-1.5 py-0.5 rounded","bg-gray-200 dark:bg-dark-300 ophelia:bg-[#262626]"),children:a.pipeline_tag})]})]}),t&&e.jsx("div",{className:"px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a] bg-white dark:bg-dark-100 ophelia:bg-[#0d0d0d]",children:d?e.jsxs("div",{className:"flex items-center justify-center py-4",children:[e.jsx(qe,{className:"h-4 w-4 animate-spin text-gray-400"}),e.jsx("span",{className:"ml-2 text-xs text-gray-500",children:r("modelManager.huggingface.checkingGguf")})]}):i.length===0?e.jsx("div",{className:"py-4 text-center text-xs text-gray-500 dark:text-gray-400",children:r("modelManager.huggingface.noGgufAvailable")}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.huggingface.ggufFilesCount",{count:i.length})}),i.map(m=>{const La=w===m.ollamaCommand;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 ophelia:bg-[#0a0a0a] border border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-gray-800 dark:text-gray-200 ophelia:text-[#e5e5e5] truncate",children:m.filename}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:m.sizeFormatted}),m.quantization&&e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 ophelia:bg-[#9333ea]/20 text-purple-700 dark:text-purple-400 ophelia:text-[#a855f7]",children:m.quantization})]})]}),La?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-xs text-gray-500 w-12 text-right",children:O?.percent!==void 0?`${O.percent}%`:"..."}),e.jsx("button",{onClick:me=>{me.stopPropagation(),ja()},className:"p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20",children:e.jsx(F,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:me=>{me.stopPropagation(),ka(m.ollamaCommand,m.filename)},disabled:!!w||!p,className:s("px-3 py-1.5 rounded-lg text-xs font-medium","bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[#9333ea]/20","text-primary-700 dark:text-primary-400 ophelia:text-[#a855f7]","hover:bg-primary-200 dark:hover:bg-primary-900/50","disabled:opacity-50 disabled:cursor-not-allowed"),children:[e.jsx(C,{className:"h-3 w-3 inline mr-1"}),r("models.pull")]})]},m.filename)}),w?.startsWith("hf.co/")&&w.includes(a.id)&&O?.percent!==void 0&&e.jsx("div",{className:"w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2",children:e.jsx("div",{className:"h-1.5 rounded-full bg-primary-500 transition-all duration-300",style:{width:`${O.percent}%`}})})]})})]},a.id)})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("a",{href:"https://huggingface.co/models",target:"_blank",rel:"noopener noreferrer",className:s("inline-flex items-center gap-1.5 text-xs","text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]","hover:underline"),children:[e.jsx(ue,{className:"h-3 w-3"}),r("modelManager.huggingface.browseAll","Browse all on HuggingFace")]}),e.jsxs(g,{onClick:Te,variant:"outline",size:"sm",disabled:de,className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(f,{className:s("h-3.5 w-3.5",de&&"animate-spin")}),r("modelManager.library.refresh","Refresh")]})]})]})]}),Array.isArray(b)&&b.length>0&&e.jsxs("div",{className:s("rounded-xl p-4 border","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/20"),children:e.jsx(Ae,{className:"h-5 w-5 text-green-600 dark:text-green-400 ophelia:text-[#4ade80]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.running")}),e.jsxs("span",{className:s("ml-auto px-2 py-0.5 rounded-full text-xs font-medium","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/20","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[b.length," ",r("modelManager.systemStatus.running")]})]}),e.jsx("div",{className:"space-y-2",children:b.map(a=>e.jsxs("div",{className:s("flex items-center justify-between p-4 rounded-lg border","bg-green-50 dark:bg-green-900/10 ophelia:bg-[#22c55e]/5","border-green-200 dark:border-green-800/50 ophelia:border-[#22c55e]/20"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("w-2 h-2 rounded-full animate-pulse","bg-green-500 ophelia:bg-[#4ade80]")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-800 dark:text-green-400 ophelia:text-[#4ade80]",children:a.name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-green-600 dark:text-green-500 ophelia:text-[#22c55e]/80",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qa,{className:"h-3 w-3"}),r("modelManager.systemStatus.vram"),":"," ",k(a.size_vram||0)]}),a.size&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{className:"h-3 w-3"}),r("models.size"),": ",k(a.size)]})]})]})]}),e.jsxs("div",{className:s("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/10","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[e.jsx($e,{className:"h-3 w-3"}),r("modelManager.local.running")]})]},a.name))})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("local"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-blue-100 dark:bg-blue-900/30 ophelia:bg-[#a855f7]/20"),children:e.jsx(T,{className:"h-5 w-5 text-blue-600 dark:text-blue-400 ophelia:text-[#a855f7]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.local")}),e.jsxs("span",{className:s("px-2 py-0.5 rounded-full text-xs font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:[u.length," ",r("modelManager.local.installed")]})]}),x.has("local")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("local")&&e.jsx("div",{className:"p-4 pt-0",children:u.length===0?e.jsxs("div",{className:s("text-center py-12 rounded-lg border-2 border-dashed","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]"),children:[e.jsx(T,{className:"h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600 ophelia:text-[#525252]"}),e.jsx("p",{className:"text-gray-600 dark:text-dark-600 ophelia:text-[#737373] mb-2",children:r("modelManager.local.noModels")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 ophelia:text-[#525252]",children:r("modelManager.local.pullToStart")})]}):e.jsx("div",{className:"space-y-3",children:u.map(a=>e.jsx("div",{className:s("p-4 rounded-lg border transition-colors","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]"),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:a.name}),za(a.name)&&e.jsxs("span",{className:s("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 ophelia:bg-[#22c55e]/20","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 ophelia:bg-[#4ade80] animate-pulse"}),r("modelManager.local.running")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] mt-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{className:"h-3.5 w-3.5"}),k(a.size)]}),a.details?.parameter_size&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ua,{className:"h-3.5 w-3.5"}),a.details.parameter_size]}),a.details?.quantization_level&&e.jsx("span",{className:s("px-1.5 py-0.5 rounded text-xs","bg-gray-200 dark:bg-dark-300 ophelia:bg-[#262626]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:a.details.quantization_level}),a.details?.family&&e.jsx("span",{className:"text-gray-500 dark:text-gray-500 ophelia:text-[#737373]",children:a.details.family})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 ophelia:text-[#525252] mt-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Va,{className:"h-3 w-3"}),new Date(a.modified_at).toLocaleDateString()]}),e.jsxs("span",{className:"flex items-center gap-1 font-mono truncate max-w-[200px]",title:a.digest,children:[e.jsx(Wa,{className:"h-3 w-3"}),a.digest.slice(0,12),"..."]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs(g,{onClick:()=>wa(a.name),variant:"outline",size:"sm",className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Ia,{className:"h-3.5 w-3.5"}),r("modelManager.local.info")]}),e.jsxs(g,{onClick:()=>{ae(a.name),E(!0)},variant:"outline",size:"sm",className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(be,{className:"h-3.5 w-3.5"}),r("modelManager.local.copy")]}),e.jsxs(g,{onClick:()=>Na(a.name),variant:"outline",size:"sm",className:s("gap-1.5","text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300","ophelia:text-[#f87171] ophelia:hover:text-[#fca5a5]","ophelia:border-[#262626] ophelia:hover:bg-[#1a1a1a]"),children:[e.jsx(Ka,{className:"h-3.5 w-3.5"}),r("modelManager.local.delete")]})]})]})},a.name))})})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("advanced"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-amber-100 dark:bg-amber-900/30 ophelia:bg-[#f59e0b]/20"),children:e.jsx(Oa,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 ophelia:text-[#fbbf24]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.advanced")})]}),x.has("advanced")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("advanced")&&e.jsx("div",{className:"p-4 pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs(g,{onClick:()=>$(!0),variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Ue,{className:"h-5 w-5 text-purple-500 ophelia:text-[#a855f7]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.createModel")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.fromModelfile")})]})]}),e.jsxs(g,{onClick:()=>E(!0),variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(be,{className:"h-5 w-5 text-blue-500 ophelia:text-[#60a5fa]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.copyModel")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.duplicateExisting")})]})]}),e.jsxs(g,{onClick:()=>te(!0),variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Ve,{className:"h-5 w-5 text-green-500 ophelia:text-[#4ade80]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.testEmbeddings")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.generateVectors")})]})]}),e.jsxs(g,{onClick:async()=>{try{(await h.checkHealth()).success&&(I(!0),o.success(r("modelManager.advanced.healthy")))}catch{I(!1),o.error(r("modelManager.systemStatus.offline"))}},variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Xa,{className:"h-5 w-5 text-rose-500 ophelia:text-[#fb7185]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.healthCheck")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.testConnection")})]})]})]})})]}),sa&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>ee(!1)}),e.jsxs("div",{className:s("relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:[r("modelManager.modals.details.title"),": ",aa]}),e.jsx("button",{onClick:()=>ee(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsx("div",{className:"overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4",children:ta?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(f,{className:"h-6 w-6 animate-spin text-gray-400 ophelia:text-[#737373]"})}):n?e.jsxs(e.Fragment,{children:[n.details&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.info")}),e.jsx("div",{className:s("p-3 rounded-lg text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]"),children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.details.family&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.family"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.family})]}),n.details.parameter_size&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.parameters"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.parameter_size})]}),n.details.quantization_level&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.quantization"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.quantization_level})]}),n.details.format&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.format"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.format})]})]})})]}),n.system&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.systemPrompt")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.system})]}),n.template&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.template")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-40","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.template})]}),n.parameters&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.parameters")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.parameters})]}),n.license&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.license")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-32","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.license})]}),n.modelfile&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.modelfile")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-60","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.modelfile})]})]}):e.jsx("p",{className:"text-center text-gray-500 ophelia:text-[#737373]",children:r("modelManager.modals.details.noDetails")})})]})]}),document.body),la&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>E(!1)}),e.jsxs("div",{className:s("relative w-full max-w-md rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r("modelManager.modals.copy.title")}),e.jsx("button",{onClick:()=>E(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.copy.source")}),e.jsxs("select",{value:A,onChange:a=>ae(a.target.value),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]"),children:[e.jsx("option",{value:"",children:r("modelManager.modals.copy.selectModel")}),u.map(a=>e.jsx("option",{value:a.name,children:a.name},a.name))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.copy.newName")}),e.jsx("input",{type:"text",value:D,onChange:a=>ve(a.target.value),placeholder:r("modelManager.modals.copy.placeholder"),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]")})]}),e.jsxs(g,{onClick:Ma,disabled:!A.trim()||!D.trim()||re,className:s("w-full gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[re?e.jsx(f,{className:"h-4 w-4 animate-spin"}):e.jsx(be,{className:"h-4 w-4"}),r(re?"modelManager.modals.copy.copying":"modelManager.modals.copy.button")]})]})]})]}),document.body),da&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>$(!1)}),e.jsxs("div",{className:s("relative w-full max-w-lg rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r("modelManager.modals.create.title")}),e.jsx("button",{onClick:()=>$(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.create.name")}),e.jsx("input",{type:"text",value:L,onChange:a=>we(a.target.value),placeholder:r("modelManager.modals.create.namePlaceholder"),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.create.modelfile")}),e.jsx("textarea",{value:q,onChange:a=>Me(a.target.value),placeholder:r("modelManager.modals.create.modelfilePlaceholder"),rows:8,className:s("w-full px-3 py-2 rounded-lg border text-sm font-mono","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]","resize-none")}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.create.see")," ",e.jsx("a",{href:"https://github.com/ollama/ollama/blob/main/docs/modelfile.md",target:"_blank",rel:"noopener noreferrer",className:"text-primary-600 ophelia:text-[#a855f7] hover:underline",children:r("modelManager.modals.create.docs")})," ",r("modelManager.modals.create.docsLink")]})]}),e.jsxs(g,{onClick:Sa,disabled:!L.trim()||!q.trim()||se,className:s("w-full gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[se?e.jsx(f,{className:"h-4 w-4 animate-spin"}):e.jsx(Ue,{className:"h-4 w-4"}),r(se?"modelManager.modals.create.creating":"modelManager.modals.create.button")]})]})]})]}),document.body),oa&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>te(!1)}),e.jsxs("div",{className:s("relative w-full max-w-lg rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r("modelManager.modals.embeddings.title")}),e.jsx("button",{onClick:()=>te(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.embeddings.model")}),e.jsxs("select",{value:U,onChange:a=>ia(a.target.value),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]"),children:[e.jsx("option",{value:"",children:r("modelManager.modals.embeddings.selectModel")}),u.map(a=>e.jsx("option",{value:a.name,children:a.name},a.name))]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 ophelia:text-[#737373]",children:r("modelManager.modals.embeddings.recommended")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.embeddings.input")}),e.jsx("textarea",{value:V,onChange:a=>na(a.target.value),placeholder:r("modelManager.modals.embeddings.placeholder"),rows:3,className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]","resize-none")})]}),e.jsxs(g,{onClick:Ca,disabled:!U.trim()||!V.trim()||le,className:s("w-full gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[le?e.jsx(f,{className:"h-4 w-4 animate-spin"}):e.jsx(Ve,{className:"h-4 w-4"}),r(le?"modelManager.modals.embeddings.generating":"modelManager.modals.embeddings.button")]}),W&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.embeddings.result",{count:W.length})}),e.jsxs("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-32","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:["[",W.slice(0,10).join(", "),W.length>10&&", ..."," ]"]})]})]})]})]}),document.body)]})},rr=()=>{const{t:r}=We();return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"max-w-6xl mx-auto p-6",children:[e.jsxs("div",{className:"text-center max-w-md mx-auto mb-8",children:[e.jsx("h2",{className:"libre-brand text-4xl sm:text-5xl font-normal text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa] mb-3",style:{fontWeight:300,letterSpacing:"0.01em"},children:r("models.title")}),e.jsx("p",{className:"text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] leading-relaxed",children:r("models.subtitle")})]}),e.jsx(Za,{})]})})};export{rr as ModelsPage,rr as default};
1
+ import{j as e}from"./markdown-vendor-B0lXrrRZ.js";import{r as l,e as Z}from"./router-vendor-DdQhGl5t.js";import{a as We,b as Ga,o as h,h as Re,c as s,B as g}from"../assets/index-DW8C1vVk.js";import{z as o,a3 as f,al as Ta,ab as T,am as _a,an as Ae,k as C,i as _,j as z,a8 as pe,X as F,f as ue,ac as Ba,ao as Ra,C as Aa,$ as $e,ae as qe,af as $a,ap as qa,ad as Ua,aq as Va,ar as Wa,d as Ia,O as be,T as Ka,w as Oa,as as Ue,at as Ve,au as Xa}from"./ui-vendor-C4ZcWovR.js";import"./utils-vendor-BFlGJDIj.js";const Za=()=>{const{t:r}=We(),{user:Ie,systemInfo:Ke}=Ga(),p=Ie?.role==="admin"||(Ke?.allowUserModelPull??!0),[u,Oe]=l.useState([]),[b,Xe]=l.useState([]),[j,Ze]=l.useState([]),[J,fe]=l.useState(!1),[Q,Je]=l.useState("all"),[B,Qe]=l.useState(""),[Ye,ye]=l.useState(!1),[Y,R]=l.useState(""),[v,H]=l.useState(!1),[c,N]=l.useState(null),[ke,P]=l.useState(null),[n,ea]=l.useState(null),[aa,ra]=l.useState(""),[sa,ee]=l.useState(!1),[ta,je]=l.useState(!1),[la,E]=l.useState(!1),[A,ae]=l.useState(""),[D,ve]=l.useState(""),[re,Ne]=l.useState(!1),[da,$]=l.useState(!1),[L,we]=l.useState(""),[q,Me]=l.useState(""),[se,Se]=l.useState(!1),[oa,te]=l.useState(!1),[U,ia]=l.useState(""),[V,na]=l.useState(""),[W,Ce]=l.useState(null),[le,ze]=l.useState(!1),[Fe,ca]=l.useState(null),[He,I]=l.useState(null),[K,ga]=l.useState([]),[de,Pe]=l.useState(!1),[oe,xa]=l.useState(""),[Ee,ha]=l.useState(""),[ie,ma]=l.useState("text-generation"),[ne,pa]=l.useState("downloads"),[ce,De]=l.useState(null),[ge,ua]=l.useState({}),[ba,Le]=l.useState(null),[w,G]=l.useState(null),[O,M]=l.useState(null),[xe,X]=l.useState(null),[x,fa]=l.useState(new Set(["pull","local"])),S=a=>{fa(t=>{const d=new Set(t);return d.has(a)?d.delete(a):d.add(a),d})},y=l.useCallback(async()=>{ye(!0);try{const[a,t,d,i]=await Promise.all([h.getModels(),h.listRunningModels(),h.getVersion(),h.checkHealth()]);a.success&&Oe(a.data||[]),t.success&&Xe(Array.isArray(t.data)?t.data:[]),d.success&&d.data&&ca(d.data.version),I(i.success)}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.pull.failed")+": "+t),I(!1)}finally{ye(!1)}},[r]),Ge=async()=>{fe(!0);try{const a=await h.getLibraryModels();a.success&&a.data&&Ze(a.data)}catch(a){console.error("Failed to load library models:",a)}finally{fe(!1)}};l.useEffect(()=>{y(),Ge()},[]),l.useEffect(()=>{const a=setTimeout(()=>{ha(oe)},300);return()=>clearTimeout(a)},[oe]);const Te=async()=>{Pe(!0);try{const a=await Re.getModels({task:ie,search:Ee||void 0,sort:ne,limit:30});a.success&&a.data&&ga(a.data)}catch(a){console.error("Failed to load HuggingFace models:",a)}finally{Pe(!1)}};l.useEffect(()=>{x.has("huggingface")&&Te()},[x,ie,Ee,ne]);const _e=l.useCallback(async a=>{const[t,d]=a.split("/");if(!(!t||!d)){Le(a);try{const i=await Re.getGgufFiles(t,d);i.success&&i.data&&ua(m=>({...m,[a]:i.data}))}catch(i){console.error("Failed to load GGUF files:",i)}finally{Le(null)}}},[]),ya=l.useCallback(a=>{ce===a?De(null):(De(a),ge[a]||_e(a))},[ce,ge,_e]),ka=l.useCallback((a,t)=>{if(!p){o.error(r("modelManager.pull.restricted"));return}if(!w){G(a),M({status:"starting"});try{const d=h.pullModelStream(a,i=>{M(i)},()=>{M(null),G(null),X(null),o.success(`Downloaded ${t}`),y()},i=>{M(null),G(null),X(null),o.error(`Failed to download: ${i}`)});X(()=>d)}catch{M(null),G(null),o.error("Failed to start download")}}},[p,w,y,r]),ja=l.useCallback(()=>{xe&&(xe(),X(null),G(null),M(null))},[xe]),he=async a=>{if(!p){o.error(r("modelManager.pull.restricted"));return}const t=a||Y.trim();if(!t){o.error(r("modelManager.pull.enterName"));return}a&&R(a),H(!0),N({status:"starting"});try{const d=h.pullModelStream(t,i=>{N(i)},()=>{N(null),H(!1),P(null),o.success(r("modelManager.pull.success",{name:t})),R(""),y()},i=>{N(null),H(!1),P(null),o.error(r("modelManager.pull.failed")+": "+i)});P(()=>d)}catch(d){const i=d instanceof Error?d.message:String(d);o.error(r("modelManager.pull.failed")+": "+i),N(null),H(!1),P(null)}},va=()=>{ke&&(ke(),P(null),H(!1),N(null),o.success(r("modelManager.pull.cancelled")))},Na=async a=>{if(confirm(r("modelManager.local.deleteConfirm",{name:a})))try{await h.deleteModel(a),o.success(r("modelManager.local.deleteSuccess",{name:a})),await y()}catch(t){const d=t instanceof Error?t.message:String(t);o.error(r("modelManager.local.deleteFailed")+": "+d)}},wa=async a=>{je(!0),ra(a),ee(!0);try{const t=await h.showModel(a,!0);t.success&&t.data?ea(t.data):o.error(r("modelManager.modals.details.noDetails"))}catch(t){const d=t instanceof Error?t.message:String(t);o.error(r("modelManager.modals.details.noDetails")+": "+d)}finally{je(!1)}},Ma=async()=>{if(!A.trim()||!D.trim()){o.error(r("modelManager.modals.copy.enterBoth"));return}Ne(!0);try{await h.copyModel(A.trim(),D.trim()),o.success(r("modelManager.modals.copy.success",{name:D})),E(!1),ae(""),ve(""),await y()}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.modals.copy.failed")+": "+t)}finally{Ne(!1)}},Sa=async()=>{if(!L.trim()||!q.trim()){o.error(r("modelManager.modals.create.enterBoth"));return}Se(!0);try{await h.createModel({model:L.trim(),modelfile:q.trim()}),o.success(r("modelManager.modals.create.success",{name:L})),$(!1),we(""),Me(""),await y()}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.modals.create.failed")+": "+t)}finally{Se(!1)}},Ca=async()=>{if(!U.trim()||!V.trim()){o.error(r("modelManager.modals.embeddings.enterBoth"));return}ze(!0),Ce(null);try{const a=await h.generateEmbeddings({model:U.trim(),input:V.trim()});if(a.success&&a.data){const t=a.data.embeddings?.[0]||[];Ce(t),o.success(r("modelManager.modals.embeddings.success",{count:t.length}))}}catch(a){const t=a instanceof Error?a.message:String(a);o.error(r("modelManager.modals.embeddings.failed")+": "+t)}finally{ze(!1)}},k=a=>{const t=a/1073741824;return t>=1?`${t.toFixed(2)} GB`:`${(a/(1024*1024)).toFixed(1)} MB`},za=a=>Array.isArray(b)&&b.some(t=>t.name===a),Fa=()=>u.reduce((a,t)=>a+t.size,0),Ha=()=>b.reduce((a,t)=>a+(t.size_vram||0),0),Pa=a=>u.some(t=>t.name===a||t.name.startsWith(a+":")),Be=j.filter(a=>{const t=Q==="all"||a.category===Q,d=!B||a.name.toLowerCase().includes(B.toLowerCase())||a.description.toLowerCase().includes(B.toLowerCase());return t&&d}),Ea=["all",...new Set(j.map(a=>a.category))],Da=l.useMemo(()=>j.length>0?j.slice(0,10).map(a=>({name:a.name,category:a.category,size:a.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"}],[j]);return Ye?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsxs("div",{className:"flex items-center gap-3 text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3]",children:[e.jsx(f,{className:"h-5 w-5 animate-spin"}),r("modelManager.loading")]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:s("rounded-xl p-4 border","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:s("w-2.5 h-2.5 rounded-full",He?"bg-green-500 ophelia:bg-[#4ade80]":"bg-red-500 ophelia:bg-[#f87171]")}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]",children:r(He?"modelManager.systemStatus.online":"modelManager.systemStatus.offline")})]}),Fe&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]",children:[e.jsx(Ta,{className:"h-4 w-4"}),e.jsxs("span",{children:["v",Fe]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]",children:[e.jsx(T,{className:"h-4 w-4"}),e.jsxs("span",{children:[u.length," ",u.length!==1?r("modelManager.systemStatus.models_plural"):r("modelManager.systemStatus.models")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]",children:[e.jsx(_a,{className:"h-4 w-4"}),e.jsx("span",{children:k(Fa())})]}),b.length>0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-600 dark:text-green-400 ophelia:text-[#4ade80]",children:[e.jsx(Ae,{className:"h-4 w-4"}),e.jsxs("span",{children:[b.length," ",r("modelManager.systemStatus.running")," (",k(Ha())," ",r("modelManager.systemStatus.vram"),")"]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(g,{onClick:y,variant:"outline",size:"sm",className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(f,{className:"h-3.5 w-3.5"}),r("common.refresh")]})})]})}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("pull"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[#9333ea]/20"),children:e.jsx(C,{className:"h-5 w-5 text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.pull")})]}),x.has("pull")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("pull")&&e.jsxs("div",{className:"p-4 pt-0 space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsx("input",{type:"text",value:Y,onChange:a=>R(a.target.value),placeholder:r("modelManager.pull.placeholder"),className:s("w-full pl-10 pr-4 py-2.5 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#525252]","focus:outline-none focus:ring-2 focus:ring-primary-500/20 ophelia:focus:ring-[#9333ea]/20","focus:border-primary-500 ophelia:focus:border-[#9333ea]"),disabled:v||!p,onKeyDown:a=>a.key==="Enter"&&!v&&p&&he()})]}),v?e.jsxs(g,{onClick:va,variant:"outline",className:s("px-4 py-2.5 gap-2","text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300","ophelia:text-[#f87171] ophelia:hover:text-[#fca5a5]","ophelia:border-[#262626] ophelia:hover:bg-[#1a1a1a]"),children:[e.jsx(F,{className:"h-4 w-4"}),r("modelManager.pull.cancel")]}):e.jsxs(g,{onClick:()=>he(),disabled:!Y.trim()||!p,className:s("px-4 py-2.5 gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[e.jsx(C,{className:"h-4 w-4"}),r("modelManager.pull.button")]})]}),v&&c&&e.jsxs("div",{className:s("p-4 rounded-lg border","bg-gray-50 dark:bg-dark-200 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]"),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-dark-700 ophelia:text-[#e5e5e5]",children:c.status==="starting"?r("modelManager.progress.starting"):c.status.startsWith("pulling")?`${r("modelManager.progress.pullingLayer")} ${c.status.replace("pulling ","")}`:c.status.startsWith("verifying sha256")?r("modelManager.progress.verifyingDigest"):c.status==="writing manifest"?r("modelManager.progress.writing"):c.status==="removing any unused layers"?r("modelManager.progress.cleaning"):c.status}),c.percent!==void 0&&e.jsxs("span",{className:"text-sm font-mono text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3]",children:[c.percent,"%"]})]}),c.percent!==void 0&&e.jsx("div",{className:"w-full bg-gray-200 dark:bg-dark-400 ophelia:bg-[#262626] rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:s("h-2 rounded-full transition-all duration-300","bg-primary-500 dark:bg-primary-400 ophelia:bg-[#9333ea]"),style:{width:`${c.percent}%`}})}),c.total&&c.completed&&e.jsxs("div",{className:"mt-2 text-xs text-gray-600 dark:text-dark-600 ophelia:text-[#737373]",children:[k(c.completed)," /"," ",k(c.total)]})]}),!p&&e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:r("modelManager.pull.restricted")}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 ophelia:text-[#737373] mb-2",children:r("modelManager.pull.popular")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Da.map(a=>e.jsxs("button",{onClick:()=>R(a.name),disabled:v||!p,className:s("px-3 py-1.5 rounded-full text-xs font-medium transition-colors","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3]","hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626]","border border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","disabled:opacity-50 disabled:cursor-not-allowed"),children:[a.name,e.jsx("span",{className:"ml-1 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]",children:a.size})]},a.name))})]}),e.jsxs("a",{href:"https://ollama.com/library",target:"_blank",rel:"noopener noreferrer",className:s("inline-flex items-center gap-1.5 text-xs","text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]","hover:underline"),children:[e.jsx(ue,{className:"h-3 w-3"}),r("modelManager.pull.browseAll")]})]})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("library"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-cyan-100 dark:bg-cyan-900/30 ophelia:bg-[#06b6d4]/20"),children:e.jsx(Ba,{className:"h-5 w-5 text-cyan-600 dark:text-cyan-400 ophelia:text-[#22d3ee]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.library")}),e.jsxs("span",{className:s("px-2 py-0.5 rounded-full text-xs font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:[j.length," ",r("modelManager.library.available")]})]}),x.has("library")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("library")&&e.jsxs("div",{className:"p-4 pt-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsx("input",{type:"text",value:B,onChange:a=>Qe(a.target.value),placeholder:r("modelManager.library.search"),className:s("w-full pl-10 pr-4 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#525252]","focus:outline-none focus:ring-2 focus:ring-primary-500/20 ophelia:focus:ring-[#9333ea]/20","focus:border-primary-500 ophelia:focus:border-[#9333ea]")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"h-4 w-4 text-gray-400 ophelia:text-[#525252]"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ea.map(a=>e.jsx("button",{onClick:()=>Je(a),className:s("px-2.5 py-1 rounded-full text-xs font-medium transition-colors",Q===a?"bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[#9333ea]/20 text-primary-700 dark:text-primary-400 ophelia:text-[#a855f7]":"bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a] text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3] hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626]"),children:a.charAt(0).toUpperCase()+a.slice(1)},a))})]})]}),J?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(f,{className:"h-5 w-5 animate-spin text-gray-400 ophelia:text-[#737373]"})}):Be.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 ophelia:text-[#737373]",children:r("modelManager.library.noResults")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:Be.map(a=>{const t=Pa(a.name);return e.jsxs("div",{className:s("p-4 rounded-lg border transition-all","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]",t?"border-green-200 dark:border-green-800/50 ophelia:border-[#22c55e]/30":"border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400 ophelia:hover:border-[#262626]"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:a.name}),t&&e.jsxs("span",{className:s("flex items-center gap-1 px-1.5 py-0.5 rounded text-xs","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/20","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[e.jsx(Aa,{className:"h-3 w-3"}),r("modelManager.library.installed")]})]}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] mb-3 line-clamp-2",children:a.description}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[a.sizes.slice(0,4).map(d=>e.jsx("span",{className:s("px-1.5 py-0.5 rounded text-xs","bg-gray-200 dark:bg-dark-300 ophelia:bg-[#262626]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:d},d)),a.sizes.length>4&&e.jsx("span",{className:"text-xs text-gray-400 ophelia:text-[#737373]",children:r("modelManager.library.more",{count:a.sizes.length-4})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 ophelia:text-[#737373]",children:[a.pulls&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"h-3 w-3"}),a.pulls]}),e.jsx("span",{className:s("px-1.5 py-0.5 rounded capitalize","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]"),children:a.category})]}),e.jsxs(g,{onClick:()=>{x.has("pull")||S("pull"),he(a.name)},variant:"outline",size:"sm",disabled:v||!p,className:s("gap-1 text-xs","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(C,{className:"h-3 w-3"}),r("modelManager.pull.button")]})]})]},a.name)})}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(g,{onClick:Ge,variant:"outline",size:"sm",disabled:J,className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(f,{className:s("h-3.5 w-3.5",J&&"animate-spin")}),r("modelManager.library.refresh")]})})]})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("huggingface"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-yellow-100 dark:bg-yellow-900/30 ophelia:bg-[#eab308]/20"),children:e.jsx($e,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-400 ophelia:text-[#facc15]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.huggingface","HuggingFace Hub")}),K.length>0&&e.jsxs("span",{className:s("px-2 py-0.5 rounded-full text-xs font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:[K.length," ",r("modelManager.library.available","available")]})]}),x.has("huggingface")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("huggingface")&&e.jsxs("div",{className:"p-4 pt-0 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(pe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"}),e.jsx("input",{type:"text",value:oe,onChange:a=>xa(a.target.value),placeholder:r("modelManager.huggingface.search","Search HuggingFace models..."),className:s("w-full pl-10 pr-4 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","placeholder-gray-500 dark:placeholder-gray-400 ophelia:placeholder-[#525252]","focus:outline-none focus:ring-2 focus:ring-primary-500/20 ophelia:focus:ring-[#9333ea]/20","focus:border-primary-500 ophelia:focus:border-[#9333ea]")})]}),e.jsxs("select",{value:ie,onChange:a=>ma(a.target.value),className:s("px-3 py-2 rounded-lg border text-sm min-w-[160px]","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:[e.jsx("option",{value:"text-generation",children:r("modelManager.huggingface.tasks.textGen","Text Generation")}),e.jsx("option",{value:"text-to-speech",children:r("modelManager.huggingface.tasks.tts","Text to Speech")}),e.jsx("option",{value:"text-to-image",children:r("modelManager.huggingface.tasks.image","Text to Image")}),e.jsx("option",{value:"automatic-speech-recognition",children:r("modelManager.huggingface.tasks.stt","Speech Recognition")})]}),e.jsxs("select",{value:ne,onChange:a=>pa(a.target.value),className:s("px-3 py-2 rounded-lg border text-sm min-w-[140px]","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-dark-700 ophelia:text-[#fafafa]","focus:outline-none focus:ring-2 focus:ring-primary-500/20"),children:[e.jsx("option",{value:"downloads",children:r("modelManager.huggingface.sort.downloads","Most Downloads")}),e.jsx("option",{value:"likes",children:r("modelManager.huggingface.sort.likes","Most Liked")}),e.jsx("option",{value:"lastModified",children:r("modelManager.huggingface.sort.recent","Recently Updated")})]})]}),!p&&e.jsx("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:r("modelManager.pull.restricted")}),de?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(qe,{className:"h-5 w-5 animate-spin text-gray-400 ophelia:text-[#737373]"})}):K.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 ophelia:text-[#737373]",children:r("modelManager.huggingface.noResults","No models found. Try adjusting your search or filters.")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:K.map(a=>{const t=ce===a.id,d=ba===a.id,i=ge[a.id]||[];return e.jsxs("div",{className:s("rounded-lg border transition-all overflow-hidden","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","hover:shadow-md hover:border-gray-300 dark:hover:border-dark-400 ophelia:hover:border-[#262626]"),children:[e.jsxs("div",{className:"p-4 cursor-pointer",onClick:()=>ya(a.id),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa] truncate",children:a.id}),a.gated&&e.jsx("span",{className:s("px-1.5 py-0.5 rounded text-xs","bg-yellow-100 dark:bg-yellow-900/30 ophelia:bg-[#eab308]/20","text-yellow-700 dark:text-yellow-400 ophelia:text-[#facc15]"),children:r("modelManager.huggingface.gated","Gated")})]}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-dark-600 ophelia:text-[#737373] mt-0.5",children:[r("modelManager.huggingface.by","by")," ",a.author]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("a",{href:`https://huggingface.co/${a.id}`,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-dark-300 ophelia:hover:bg-[#262626] transition-colors",title:r("modelManager.huggingface.viewOnHF","View on HuggingFace"),children:e.jsx(ue,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 ophelia:text-[#525252]"})}),e.jsx(z,{className:s("h-4 w-4 text-gray-400 transition-transform",t&&"rotate-180")})]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-dark-600 ophelia:text-[#737373]",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(C,{className:"h-3.5 w-3.5"}),a.downloads>=1e6?`${(a.downloads/1e6).toFixed(1)}M`:a.downloads>=1e3?`${(a.downloads/1e3).toFixed(1)}K`:a.downloads]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx($a,{className:"h-3.5 w-3.5"}),a.likes>=1e3?`${(a.likes/1e3).toFixed(1)}K`:a.likes]}),a.pipeline_tag&&e.jsx("span",{className:s("px-1.5 py-0.5 rounded","bg-gray-200 dark:bg-dark-300 ophelia:bg-[#262626]"),children:a.pipeline_tag})]})]}),t&&e.jsx("div",{className:"px-4 pb-4 pt-1 border-t border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a] bg-white dark:bg-dark-100 ophelia:bg-[#0d0d0d]",children:d?e.jsxs("div",{className:"flex items-center justify-center py-4",children:[e.jsx(qe,{className:"h-4 w-4 animate-spin text-gray-400"}),e.jsx("span",{className:"ml-2 text-xs text-gray-500",children:r("modelManager.huggingface.checkingGguf")})]}):i.length===0?e.jsx("div",{className:"py-4 text-center text-xs text-gray-500 dark:text-gray-400",children:r("modelManager.huggingface.noGgufAvailable")}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.huggingface.ggufFilesCount",{count:i.length})}),i.map(m=>{const La=w===m.ollamaCommand;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-gray-50 dark:bg-dark-50 ophelia:bg-[#0a0a0a] border border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-gray-800 dark:text-gray-200 ophelia:text-[#e5e5e5] truncate",children:m.filename}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:m.sizeFormatted}),m.quantization&&e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-purple-100 dark:bg-purple-900/30 ophelia:bg-[#9333ea]/20 text-purple-700 dark:text-purple-400 ophelia:text-[#a855f7]",children:m.quantization})]})]}),La?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-xs text-gray-500 w-12 text-right",children:O?.percent!==void 0?`${O.percent}%`:"..."}),e.jsx("button",{onClick:me=>{me.stopPropagation(),ja()},className:"p-1.5 rounded-lg text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20",children:e.jsx(F,{className:"h-4 w-4"})})]}):e.jsxs("button",{onClick:me=>{me.stopPropagation(),ka(m.ollamaCommand,m.filename)},disabled:!!w||!p,className:s("px-3 py-1.5 rounded-lg text-xs font-medium","bg-primary-100 dark:bg-primary-900/30 ophelia:bg-[#9333ea]/20","text-primary-700 dark:text-primary-400 ophelia:text-[#a855f7]","hover:bg-primary-200 dark:hover:bg-primary-900/50","disabled:opacity-50 disabled:cursor-not-allowed"),children:[e.jsx(C,{className:"h-3 w-3 inline mr-1"}),r("models.pull")]})]},m.filename)}),w?.startsWith("hf.co/")&&w.includes(a.id)&&O?.percent!==void 0&&e.jsx("div",{className:"w-full bg-gray-200 dark:bg-dark-300 rounded-full h-1.5 overflow-hidden mt-2",children:e.jsx("div",{className:"h-1.5 rounded-full bg-primary-500 transition-all duration-300",style:{width:`${O.percent}%`}})})]})})]},a.id)})}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("a",{href:"https://huggingface.co/models",target:"_blank",rel:"noopener noreferrer",className:s("inline-flex items-center gap-1.5 text-xs","text-primary-600 dark:text-primary-400 ophelia:text-[#a855f7]","hover:underline"),children:[e.jsx(ue,{className:"h-3 w-3"}),r("modelManager.huggingface.browseAll","Browse all on HuggingFace")]}),e.jsxs(g,{onClick:Te,variant:"outline",size:"sm",disabled:de,className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(f,{className:s("h-3.5 w-3.5",de&&"animate-spin")}),r("modelManager.library.refresh","Refresh")]})]})]})]}),Array.isArray(b)&&b.length>0&&e.jsxs("div",{className:s("rounded-xl p-4 border","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/20"),children:e.jsx(Ae,{className:"h-5 w-5 text-green-600 dark:text-green-400 ophelia:text-[#4ade80]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.running")}),e.jsxs("span",{className:s("ml-auto px-2 py-0.5 rounded-full text-xs font-medium","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/20","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[b.length," ",r("modelManager.systemStatus.running")]})]}),e.jsx("div",{className:"space-y-2",children:b.map(a=>e.jsxs("div",{className:s("flex items-center justify-between p-4 rounded-lg border","bg-green-50 dark:bg-green-900/10 ophelia:bg-[#22c55e]/5","border-green-200 dark:border-green-800/50 ophelia:border-[#22c55e]/20"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("w-2 h-2 rounded-full animate-pulse","bg-green-500 ophelia:bg-[#4ade80]")}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-800 dark:text-green-400 ophelia:text-[#4ade80]",children:a.name}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-green-600 dark:text-green-500 ophelia:text-[#22c55e]/80",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qa,{className:"h-3 w-3"}),r("modelManager.systemStatus.vram"),":"," ",k(a.size_vram||0)]}),a.size&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{className:"h-3 w-3"}),r("models.size"),": ",k(a.size)]})]})]})]}),e.jsxs("div",{className:s("flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium","bg-green-100 dark:bg-green-900/30 ophelia:bg-[#22c55e]/10","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[e.jsx($e,{className:"h-3 w-3"}),r("modelManager.local.running")]})]},a.name))})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("local"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-blue-100 dark:bg-blue-900/30 ophelia:bg-[#a855f7]/20"),children:e.jsx(T,{className:"h-5 w-5 text-blue-600 dark:text-blue-400 ophelia:text-[#a855f7]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.local")}),e.jsxs("span",{className:s("px-2 py-0.5 rounded-full text-xs font-medium","bg-gray-100 dark:bg-dark-200 ophelia:bg-[#1a1a1a]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:[u.length," ",r("modelManager.local.installed")]})]}),x.has("local")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("local")&&e.jsx("div",{className:"p-4 pt-0",children:u.length===0?e.jsxs("div",{className:s("text-center py-12 rounded-lg border-2 border-dashed","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]"),children:[e.jsx(T,{className:"h-12 w-12 mx-auto mb-3 text-gray-300 dark:text-gray-600 ophelia:text-[#525252]"}),e.jsx("p",{className:"text-gray-600 dark:text-dark-600 ophelia:text-[#737373] mb-2",children:r("modelManager.local.noModels")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 ophelia:text-[#525252]",children:r("modelManager.local.pullToStart")})]}):e.jsx("div",{className:"space-y-3",children:u.map(a=>e.jsx("div",{className:s("p-4 rounded-lg border transition-colors","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]","hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]"),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:a.name}),za(a.name)&&e.jsxs("span",{className:s("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 ophelia:bg-[#22c55e]/20","text-green-700 dark:text-green-400 ophelia:text-[#4ade80]"),children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 ophelia:bg-[#4ade80] animate-pulse"}),r("modelManager.local.running")]})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] mt-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(T,{className:"h-3.5 w-3.5"}),k(a.size)]}),a.details?.parameter_size&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ua,{className:"h-3.5 w-3.5"}),a.details.parameter_size]}),a.details?.quantization_level&&e.jsx("span",{className:s("px-1.5 py-0.5 rounded text-xs","bg-gray-200 dark:bg-dark-300 ophelia:bg-[#262626]","text-gray-600 dark:text-gray-400 ophelia:text-[#a3a3a3]"),children:a.details.quantization_level}),a.details?.family&&e.jsx("span",{className:"text-gray-500 dark:text-gray-500 ophelia:text-[#737373]",children:a.details.family})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-400 dark:text-dark-500 ophelia:text-[#525252] mt-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Va,{className:"h-3 w-3"}),new Date(a.modified_at).toLocaleDateString()]}),e.jsxs("span",{className:"flex items-center gap-1 font-mono truncate max-w-[200px]",title:a.digest,children:[e.jsx(Wa,{className:"h-3 w-3"}),a.digest.slice(0,12),"..."]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsxs(g,{onClick:()=>wa(a.name),variant:"outline",size:"sm",className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Ia,{className:"h-3.5 w-3.5"}),r("modelManager.local.info")]}),e.jsxs(g,{onClick:()=>{ae(a.name),E(!0)},variant:"outline",size:"sm",className:s("gap-1.5","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(be,{className:"h-3.5 w-3.5"}),r("modelManager.local.copy")]}),e.jsxs(g,{onClick:()=>Na(a.name),variant:"outline",size:"sm",className:s("gap-1.5","text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300","ophelia:text-[#f87171] ophelia:hover:text-[#fca5a5]","ophelia:border-[#262626] ophelia:hover:bg-[#1a1a1a]"),children:[e.jsx(Ka,{className:"h-3.5 w-3.5"}),r("modelManager.local.delete")]})]})]})},a.name))})})]}),e.jsxs("div",{className:s("rounded-xl border overflow-hidden","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("button",{onClick:()=>S("advanced"),className:s("w-full flex items-center justify-between p-4","hover:bg-gray-50 dark:hover:bg-dark-50 ophelia:hover:bg-[#121212]","transition-colors"),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:s("p-2 rounded-lg","bg-amber-100 dark:bg-amber-900/30 ophelia:bg-[#f59e0b]/20"),children:e.jsx(Oa,{className:"h-5 w-5 text-amber-600 dark:text-amber-400 ophelia:text-[#fbbf24]"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa]",children:r("modelManager.sections.advanced")})]}),x.has("advanced")?e.jsx(_,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"}):e.jsx(z,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})]}),x.has("advanced")&&e.jsx("div",{className:"p-4 pt-0",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs(g,{onClick:()=>$(!0),variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Ue,{className:"h-5 w-5 text-purple-500 ophelia:text-[#a855f7]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.createModel")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.fromModelfile")})]})]}),e.jsxs(g,{onClick:()=>E(!0),variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(be,{className:"h-5 w-5 text-blue-500 ophelia:text-[#60a5fa]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.copyModel")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.duplicateExisting")})]})]}),e.jsxs(g,{onClick:()=>te(!0),variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Ve,{className:"h-5 w-5 text-green-500 ophelia:text-[#4ade80]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.testEmbeddings")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.generateVectors")})]})]}),e.jsxs(g,{onClick:async()=>{try{(await h.checkHealth()).success&&(I(!0),o.success(r("modelManager.advanced.healthy")))}catch{I(!1),o.error(r("modelManager.systemStatus.offline"))}},variant:"outline",className:s("w-full gap-2 justify-start h-auto py-3 px-4","ophelia:border-[#262626] ophelia:text-[#a3a3a3]","ophelia:hover:bg-[#1a1a1a] ophelia:hover:text-[#fafafa]"),children:[e.jsx(Xa,{className:"h-5 w-5 text-rose-500 ophelia:text-[#fb7185]"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:r("modelManager.advanced.healthCheck")}),e.jsx("div",{className:"text-xs opacity-70",children:r("modelManager.advanced.testConnection")})]})]})]})})]}),sa&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>ee(!1)}),e.jsxs("div",{className:s("relative w-full max-w-2xl max-h-[85vh] overflow-hidden rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:[r("modelManager.modals.details.title"),": ",aa]}),e.jsx("button",{onClick:()=>ee(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsx("div",{className:"overflow-y-auto max-h-[calc(85vh-60px)] p-4 space-y-4",children:ta?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(f,{className:"h-6 w-6 animate-spin text-gray-400 ophelia:text-[#737373]"})}):n?e.jsxs(e.Fragment,{children:[n.details&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.info")}),e.jsx("div",{className:s("p-3 rounded-lg text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]"),children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.details.family&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.family"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.family})]}),n.details.parameter_size&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.parameters"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.parameter_size})]}),n.details.quantization_level&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.quantization"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.quantization_level})]}),n.details.format&&e.jsxs("div",{children:[e.jsxs("span",{className:"text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.details.format"),":"]})," ",e.jsx("span",{className:"text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:n.details.format})]})]})})]}),n.system&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.systemPrompt")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.system})]}),n.template&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.template")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-40","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.template})]}),n.parameters&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.parameters")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.parameters})]}),n.license&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.license")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-32","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.license})]}),n.modelfile&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-2",children:r("modelManager.modals.details.modelfile")}),e.jsx("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-60","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:n.modelfile})]})]}):e.jsx("p",{className:"text-center text-gray-500 ophelia:text-[#737373]",children:r("modelManager.modals.details.noDetails")})})]})]}),document.body),la&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>E(!1)}),e.jsxs("div",{className:s("relative w-full max-w-md rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r("modelManager.modals.copy.title")}),e.jsx("button",{onClick:()=>E(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.copy.source")}),e.jsxs("select",{value:A,onChange:a=>ae(a.target.value),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]"),children:[e.jsx("option",{value:"",children:r("modelManager.modals.copy.selectModel")}),u.map(a=>e.jsx("option",{value:a.name,children:a.name},a.name))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.copy.newName")}),e.jsx("input",{type:"text",value:D,onChange:a=>ve(a.target.value),placeholder:r("modelManager.modals.copy.placeholder"),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]")})]}),e.jsxs(g,{onClick:Ma,disabled:!A.trim()||!D.trim()||re,className:s("w-full gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[re?e.jsx(f,{className:"h-4 w-4 animate-spin"}):e.jsx(be,{className:"h-4 w-4"}),r(re?"modelManager.modals.copy.copying":"modelManager.modals.copy.button")]})]})]})]}),document.body),da&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>$(!1)}),e.jsxs("div",{className:s("relative w-full max-w-lg rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r("modelManager.modals.create.title")}),e.jsx("button",{onClick:()=>$(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.create.name")}),e.jsx("input",{type:"text",value:L,onChange:a=>we(a.target.value),placeholder:r("modelManager.modals.create.namePlaceholder"),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.create.modelfile")}),e.jsx("textarea",{value:q,onChange:a=>Me(a.target.value),placeholder:r("modelManager.modals.create.modelfilePlaceholder"),rows:8,className:s("w-full px-3 py-2 rounded-lg border text-sm font-mono","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]","resize-none")}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500 ophelia:text-[#737373]",children:[r("modelManager.modals.create.see")," ",e.jsx("a",{href:"https://github.com/ollama/ollama/blob/main/docs/modelfile.md",target:"_blank",rel:"noopener noreferrer",className:"text-primary-600 ophelia:text-[#a855f7] hover:underline",children:r("modelManager.modals.create.docs")})," ",r("modelManager.modals.create.docsLink")]})]}),e.jsxs(g,{onClick:Sa,disabled:!L.trim()||!q.trim()||se,className:s("w-full gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[se?e.jsx(f,{className:"h-4 w-4 animate-spin"}):e.jsx(Ue,{className:"h-4 w-4"}),r(se?"modelManager.modals.create.creating":"modelManager.modals.create.button")]})]})]})]}),document.body),oa&&Z.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>te(!1)}),e.jsxs("div",{className:s("relative w-full max-w-lg rounded-xl border shadow-2xl","bg-white dark:bg-dark-100 ophelia:bg-[#0a0a0a]","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsxs("div",{className:s("flex items-center justify-between p-4 border-b","border-gray-200 dark:border-dark-300 ophelia:border-[#1a1a1a]"),children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]",children:r("modelManager.modals.embeddings.title")}),e.jsx("button",{onClick:()=>te(!1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-dark-200 ophelia:hover:bg-[#1a1a1a]",children:e.jsx(F,{className:"h-5 w-5 text-gray-500 ophelia:text-[#737373]"})})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.embeddings.model")}),e.jsxs("select",{value:U,onChange:a=>ia(a.target.value),className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]"),children:[e.jsx("option",{value:"",children:r("modelManager.modals.embeddings.selectModel")}),u.map(a=>e.jsx("option",{value:a.name,children:a.name},a.name))]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 ophelia:text-[#737373]",children:r("modelManager.modals.embeddings.recommended")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.embeddings.input")}),e.jsx("textarea",{value:V,onChange:a=>na(a.target.value),placeholder:r("modelManager.modals.embeddings.placeholder"),rows:3,className:s("w-full px-3 py-2 rounded-lg border text-sm","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","border-gray-200 dark:border-dark-300 ophelia:border-[#262626]","text-gray-900 dark:text-gray-100 ophelia:text-[#fafafa]","placeholder-gray-500 ophelia:placeholder-[#525252]","resize-none")})]}),e.jsxs(g,{onClick:Ca,disabled:!U.trim()||!V.trim()||le,className:s("w-full gap-2","ophelia:bg-[#9333ea] ophelia:hover:bg-[#7c3aed] ophelia:text-white"),children:[le?e.jsx(f,{className:"h-4 w-4 animate-spin"}):e.jsx(Ve,{className:"h-4 w-4"}),r(le?"modelManager.modals.embeddings.generating":"modelManager.modals.embeddings.button")]}),W&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 ophelia:text-[#a3a3a3] mb-1",children:r("modelManager.modals.embeddings.result",{count:W.length})}),e.jsxs("pre",{className:s("p-3 rounded-lg text-xs overflow-x-auto max-h-32","bg-gray-50 dark:bg-dark-50 ophelia:bg-[#121212]","text-gray-700 dark:text-gray-300 ophelia:text-[#e5e5e5]"),children:["[",W.slice(0,10).join(", "),W.length>10&&", ..."," ]"]})]})]})]})]}),document.body)]})},rr=()=>{const{t:r}=We();return e.jsx("div",{className:"h-full overflow-auto",children:e.jsxs("div",{className:"max-w-6xl mx-auto p-6",children:[e.jsxs("div",{className:"text-center max-w-md mx-auto mb-8",children:[e.jsx("h2",{className:"libre-brand text-4xl sm:text-5xl font-normal text-gray-900 dark:text-dark-800 ophelia:text-[#fafafa] mb-3",style:{fontWeight:300,letterSpacing:"0.01em"},children:r("models.title")}),e.jsx("p",{className:"text-gray-600 dark:text-dark-600 ophelia:text-[#a3a3a3] leading-relaxed",children:r("models.subtitle")})]}),e.jsx(Za,{})]})})};export{rr as ModelsPage,rr as default};