hatchlight 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/hatchlight.js +130 -113
- package/package.json +1 -1
- package/resources/drizzle/0012_visitors.sql +11 -0
- package/resources/drizzle/meta/0012_snapshot.json +1133 -0
- package/resources/drizzle/meta/_journal.json +7 -0
- package/resources/web/assets/{Assistant-Dcr31LAV.js → Assistant-pvqlzfRM.js} +1 -1
- package/resources/web/assets/{Gallery-CMRGE3qD.js → Gallery-BmgPWzZ8.js} +1 -1
- package/resources/web/assets/Models-DwIqpODX.js +1 -0
- package/resources/web/assets/{Settings-DSXHt9Y3.js → Settings-BV8oksGm.js} +1 -1
- package/resources/web/assets/index-Cp7pzqgE.js +1 -0
- package/resources/web/assets/index-_Khv5YZR.js +327 -0
- package/resources/web/assets/{splash-CLEpm4fL.js → splash-D2QYY8Wj.js} +1 -1
- package/resources/web/index.html +2 -2
- package/resources/web/splash.html +2 -2
- package/resources/web/assets/Models-D468Wmoj.js +0 -1
- package/resources/web/assets/index-DrgBjkJQ.js +0 -322
- package/resources/web/assets/index-ydGCWKys.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as f,a as m,c as h,p,e as v}from"./index-
|
|
1
|
+
import{m as f,a as m,c as h,p,e as v}from"./index-Cp7pzqgE.js";const a=f(navigator.languages??[],["en","pt-BR"],"en"),{t:n}=h(a,v,a==="pt-BR"?p:void 0);document.documentElement.lang=a;const o=document.getElementById("status"),s=document.getElementById("detail"),l=document.getElementById("frame");o.textContent=n("desktop.starting");const y=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let r=!y;m(l,void 0,performance.now());const u=t=>{r&&(m(l,void 0,t),requestAnimationFrame(u))};r&&requestAnimationFrame(u);const c=new URLSearchParams(location.search).get("failed");c!=null&&(r=!1,o.textContent=n("desktop.failed"),o.classList.replace("text-dim","text-danger"),s.textContent=c,s.classList.remove("hidden"),w());function w(){var i;const t=(i=window.__TAURI__)==null?void 0:i.core.invoke;if(!t)return;const d=document.getElementById("hint"),e=document.getElementById("retry");d.textContent=n("desktop.retryHint"),e.textContent=n("desktop.retry"),d.classList.remove("hidden"),e.classList.remove("hidden"),e.addEventListener("click",()=>{e.disabled=!0,t("restart_server").catch(g=>{s.textContent=String(g),e.disabled=!1})})}
|
package/resources/web/index.html
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<meta name="theme-color" content="#09090b" />
|
|
8
8
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
|
9
9
|
<title>Hatchlight</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-_Khv5YZR.js"></script>
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/index-Cp7pzqgE.js">
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-gLwjTNlu.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<meta name="color-scheme" content="dark" />
|
|
7
7
|
<title>Hatchlight</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/splash-
|
|
9
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/splash-D2QYY8Wj.js"></script>
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/assets/index-Cp7pzqgE.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-gLwjTNlu.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body class="overflow-hidden">
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as b,a6 as T,b as R,d as V,r as N,e as w,au as X,l as y,j as e,a9 as $,aa as K,an as Z,ao as k,B as v,ab as G,av as ee,al as H,ac as M,I,af as se,ag as ae,ah as te,ai as le,aj as ne,aw as ie,ax as re,ay as oe,az as L,aA as ce,aB as de,aC as me,aD as xe,aE as pe,a as z,aF as ue,am as ge,at as Q,aG as D,aH as he,aI as fe,C as je,aJ as Ne,aK as P,aL as ve,aM as be,aN as ye,as as ke,aO as we,aP as Ce,aQ as Se,aR as Be,aS as ze}from"./index-DrgBjkJQ.js";import"./index-ydGCWKys.js";const Ee=16*1024**3;function Te({checkpoint:s}){const{t:a,bytes:t,explain:x}=b(),c=T(),l=N.useId(),d=R(),o=()=>d.invalidateQueries({queryKey:["checkpoints"]}),[i,m]=N.useState(String(s.steps)),[h,p]=N.useState(String(s.cfgScale)),[n,r]=N.useState(s.clipSkip==null?"":String(s.clipSkip)),g=w({mutationFn:()=>y.updateCheckpoint(s.id,{steps:Number(i),cfgScale:Number(h),clipSkip:n===""?null:Number(n)}),onSuccess:o}),j=w({mutationFn:()=>y.deleteCheckpoint(s.id),onSuccess:o}),E=Number(i)!==s.steps||Number(h)!==s.cfgScale||(n===""?null:Number(n))!==s.clipSkip,C=i.trim()!==""&&h.trim()!=="",S=[{value:null,label:a("checkpoints.clipSkipNone")},...Array.from({length:12},(f,B)=>({value:String(B+1),label:String(B+1)}))];return e.jsxs("li",{className:"flex flex-col gap-4 rounded-xl border border-line bg-bg/60 p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-60",children:[e.jsx("p",{className:"truncate font-medium",title:s.name,children:s.name}),e.jsx("p",{className:"mt-0.5 text-sm text-dim",children:a("checkpoints.family",{base:ee(a,s.base)})})]}),e.jsx("span",{className:"font-mono text-xs text-dim",children:t(s.size)}),c.admin&&e.jsx(H,{label:a("checkpoints.delete"),ariaLabel:a("checkpoints.deleteNamed",{name:s.name}),question:a("checkpoints.deleteAsk",{name:s.name,size:t(s.size)}),confirm:a("checkpoints.deleteConfirm"),disabled:j.isPending,onConfirm:()=>j.mutate()})]}),e.jsx("fieldset",{disabled:!c.admin,className:"contents",children:e.jsxs("form",{className:"flex flex-wrap items-end gap-3",onSubmit:f=>{f.preventDefault(),g.mutate()},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(M,{htmlFor:`${l}-steps`,className:"text-dim",children:a("checkpoints.steps")}),e.jsx(I,{id:`${l}-steps`,type:"number",min:1,max:150,step:1,value:i,onChange:f=>m(f.target.value),className:"h-10 w-24 font-mono"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(M,{htmlFor:`${l}-guidance`,className:"text-dim",children:a("checkpoints.guidance")}),e.jsx(I,{id:`${l}-guidance`,type:"number",min:0,max:30,step:.5,value:h,onChange:f=>p(f.target.value),className:"h-10 w-24 font-mono"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(M,{htmlFor:`${l}-skip`,className:"text-dim",children:a("checkpoints.clipSkip")}),e.jsxs(se,{items:S,value:n===""?null:n,onValueChange:f=>r(f??""),children:[e.jsx(ae,{id:`${l}-skip`,className:"w-28 font-mono data-[size=default]:h-10",children:e.jsx(te,{})}),e.jsx(le,{children:S.map(f=>e.jsx(ne,{value:f.value,children:f.label},f.label))})]})]}),E&&e.jsx(v,{type:"submit",disabled:g.isPending||!C,children:a("checkpoints.save")})]})}),e.jsx("p",{className:"text-xs leading-relaxed text-dim",children:a("checkpoints.settingsHint")}),(g.error||j.error)&&e.jsx("p",{className:"text-sm text-danger",children:x(g.error??j.error)})]})}function Me(){const{t:s,bytes:a,explain:t}=b(),x=T(),c=R(),l=V({queryKey:["checkpoints"],queryFn:y.checkpoints}),d=N.useRef(null),o=w({mutationFn:m=>{if(m.size>Ee)throw new X("This file is too large","checkpointTooLarge");return y.addCheckpoint(m)},onSuccess:()=>c.invalidateQueries({queryKey:["checkpoints"]})}),i=o.isPending?o.variables:null;return e.jsxs($,{className:K,children:[e.jsxs(Z,{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex max-w-2xl flex-col gap-2",children:[e.jsx("h2",{className:k,children:s("checkpoints.title")}),e.jsx("p",{className:"text-sm leading-relaxed text-dim",children:s("checkpoints.intro")})]}),x.admin&&e.jsx(v,{variant:"secondary",onClick:()=>{var m;return(m=d.current)==null?void 0:m.click()},disabled:i!=null,children:s("checkpoints.add")}),e.jsx("input",{ref:d,type:"file",accept:".safetensors",hidden:!0,onChange:m=>{var p;const h=(p=m.target.files)==null?void 0:p[0];m.target.value="",h&&o.mutate(h)}})]}),e.jsxs(G,{className:"flex flex-col gap-3 empty:hidden",children:[i&&e.jsx("p",{className:"text-sm text-dim",role:"status",children:s("checkpoints.adding",{name:i.name,size:a(i.size)})}),o.error&&e.jsx("p",{className:"text-sm text-danger",children:t(o.error)}),l.error&&e.jsx("p",{className:"text-sm text-danger",children:t(l.error)}),l.data&&l.data.length===0&&!i&&e.jsx("p",{className:"text-sm text-dim",children:s("checkpoints.empty")}),l.data&&l.data.length>0&&e.jsx("ul",{className:"flex flex-col gap-2",children:l.data.map(m=>e.jsx(Te,{checkpoint:m},`${m.id}:${m.steps}:${m.cfgScale}:${m.clipSkip}`))})]})]})}function Fe({eyebrow:s,title:a,intro:t}){return e.jsxs("header",{className:"flex flex-col gap-3",children:[e.jsx("p",{className:k,children:s}),e.jsx("h1",{className:"font-display text-4xl leading-none font-extrabold tracking-tight sm:text-5xl",children:a}),e.jsx("p",{className:"max-w-2xl text-[15px] leading-relaxed text-dim",children:t})]})}function Ie({demo:s,onClose:a}){const{t}=b(),[x,c]=N.useState(s.large);return e.jsx(Ce,{open:!0,onOpenChange:l=>!l&&a(),children:e.jsxs(Se,{showCloseButton:!1,className:"w-auto max-w-[96vw] gap-0 overflow-hidden rounded-2xl p-0 sm:max-w-[96vw]",children:[e.jsx("img",{src:x,alt:s.caption??t("models.demo.sample"),decoding:"async",onError:()=>c(s.src),className:"max-h-[84vh] max-w-full bg-black object-contain"}),e.jsxs("div",{className:"flex items-center justify-between gap-4 p-3 pl-4",children:[e.jsx(Be,{className:z("text-sm font-normal text-dim",!s.caption&&"sr-only"),children:s.caption??t("models.demo.sample")}),e.jsx(ze,{render:e.jsx(v,{variant:"outline"}),children:t("common.close")})]})]})})}function De({model:s}){const{t:a}=b(),[t,x]=N.useState(0),[c,l]=N.useState(!1),[d,o]=N.useState([]),[i,m]=N.useState([]),h=s.demos.map((n,r)=>({...n,src:P(s.id,r,"card"),large:P(s.id,r,"large")})),p=h[t];return p?e.jsxs("div",{children:[e.jsx("div",{className:"aspect-video overflow-hidden bg-black",children:d.includes(t)?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-dim",children:a("models.demo.failed")}):p.media==="video"?e.jsx("video",{src:p.src,controls:!0,preload:"none",playsInline:!0,onError:()=>o(n=>[...n,t]),className:"h-full w-full object-contain"},p.src):e.jsx("button",{type:"button",onClick:()=>l(!0),"aria-label":a("models.demo.enlarge",{caption:p.caption??a("models.demo.sampleShort")}),className:`block h-full w-full cursor-zoom-in outline-none focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset ${i.includes(t)?"":"developing"}`,children:e.jsx("img",{src:p.src,alt:p.caption??a("models.demo.sampleFrom",{model:s.name}),loading:"lazy",decoding:"async",onLoad:()=>m(n=>[...n,t]),onError:()=>o(n=>[...n,t]),className:"h-full w-full object-cover"},p.src)})}),(p.caption||h.length>1)&&e.jsxs("div",{className:"flex items-start justify-between gap-3 px-5 pt-3",children:[e.jsxs("p",{className:"pt-2.5 text-xs leading-relaxed text-dim",children:[p.media==="video"&&`${a("models.demo.video")} · `,p.caption]}),h.length>1&&e.jsx("div",{className:"flex shrink-0 gap-1",children:h.map((n,r)=>e.jsx(v,{variant:"ghost",size:"icon",onClick:()=>x(r),"aria-label":a("models.demo.position",{index:r+1,total:h.length}),"aria-pressed":r===t,className:"font-mono text-xs text-dim aria-pressed:bg-panel-2 aria-pressed:text-ink",children:r+1},n.src))})]}),c&&p.media==="image"&&e.jsx(Ie,{demo:p,onClose:()=>l(!1)})]}):e.jsx("div",{className:"flex aspect-video items-center justify-center bg-bg text-sm text-dim",children:a("models.demo.none")})}function $e({model:s}){const a=b(),{t,bytes:x}=a,c=ke(s.id),l=Math.max((c==null?void 0:c.receivedBytes)??0,s.receivedBytes),d=(c==null?void 0:c.state)??s.state,o=(c==null?void 0:c.bytesPerSecond)??0,i=Math.min(100,l/s.size*100),m=d==="queued"?t("models.progress.queued"):d==="verifying"?t("models.progress.verifying"):[t("models.progress.received",{received:x(l),total:x(s.size)}),o>0&&t("models.progress.speed",{speed:x(o)}),o>0&&we(a,(s.size-l)/o)].filter(Boolean).join(" · ");return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Q,{value:i,label:t("models.progress.label",{model:s.name})}),e.jsxs("p",{className:"font-mono text-xs text-dim",children:[Math.floor(i),"% · ",m]})]})}function A(s,a){switch(a){case"gpu":return s("models.fit.gpu");case"offload":return s("models.fit.offload");case"cpu":return s("models.fit.cpu");case"none":return s("models.fit.none")}}function Le(s,a){const t=`models.summary.${a.id}`;return ye(t)?s(t):a.summary}function Pe(s,a){switch(a){case"text-to-image":return s("models.task.textToImage");case"image-edit":return s("models.task.imageEdit");case"image-to-image":return s("models.task.imageToImage");case"upscale":return s("models.task.upscale");case"text-to-video":return s("models.task.textToVideo");case"image-to-video":return s("models.task.imageToVideo");case"prompt-translation":return s("models.task.promptTranslation");case"picture-description":return s("models.task.pictureDescription")}}function Ae(s,a){switch(a.kind){case"allowed":return s.t("models.commercial.allowed");case"limited":return s.t("models.commercial.limited",{revenue:s.number(a.revenueUsd,{style:"currency",currency:"USD",notation:"compact"})});case"none":return s.t("models.commercial.none")}}const _e={allowed:"border-good/30 text-good",limited:"border-warn/30 text-warn",none:"border-danger/30 text-danger"},Oe={gpu:"bg-good/12 text-good",offload:"bg-warn/12 text-warn",cpu:"bg-warn/12 text-warn",none:"bg-danger/12 text-danger"};function qe({model:s,recommended:a}){const{t}=b(),x=ve(s);if(a)return e.jsxs(D,{variant:"outline",className:"h-6 border-gold/40 px-2.5 text-gold",children:[e.jsx(be,{"aria-hidden":"true"}),t("models.badge.recommended")]});const c=t(x==="gpu"?"models.badge.great":x==="offload"?"models.badge.slow":x==="cpu"?"models.badge.cpu":"models.badge.none");return e.jsxs(D,{className:z("h-6 px-2.5 font-normal",Oe[x]),children:[e.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-current"}),c]})}function Re({model:s,engine:a,freeBytes:t,recommended:x}){const c=b(),{t:l,bytes:d,explain:o}=c,i=w({mutationFn:u=>y.installModel(s.id,u)}),m=w({mutationFn:()=>y.cancelModel(s.id)}),h=w({mutationFn:()=>y.deleteModel(s.id)}),p=T(),n=i.error??m.error??h.error,r=s.state==="installed",g=!r&&s.state!=="available",j=s.variants.find(u=>u.id===s.variant),E=a&&!a.installed&&!r?a.size:0,C=s.size-s.receivedBytes,S=((j==null?void 0:j.files)??[]).filter(u=>u.present).reduce((u,J)=>u+J.size,0),f=s.receivedBytes-S,B=C<=t,W=s.variants.filter(u=>u.id!==s.variant&&u.fit!=="none"),Y=r?s.reclaimableBytes<s.size?l("models.note.installedShared",{size:d(s.reclaimableBytes)}):l("models.note.installed"):[S>0?l("models.note.sharedDownload",{size:d(C),shared:d(S)}):f>0?l("models.note.leftToDownload",{size:d(C)}):l("models.note.toDownload"),E>0&&l("models.note.withEngine",{size:d(E)})].filter(Boolean).join(" · ");return e.jsx("li",{className:"flex",children:e.jsxs($,{className:"w-full gap-0 rounded-2xl py-0 ring-line",children:[e.jsx(De,{model:s}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 p-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(qe,{model:s,recommended:x}),e.jsx(D,{variant:"outline",className:z("h-6 px-2.5 font-normal",_e[s.commercial.kind]),children:Ae(c,s.commercial)})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[e.jsx("h3",{className:"font-display text-xl font-bold tracking-tight",children:s.name}),e.jsx("span",{className:`font-mono text-xs ${r?"text-good":"text-dim"}`,children:r?l("models.installed"):s.media==="video"?l("models.media.video"):l("models.media.image")})]}),e.jsxs("p",{className:"mt-1 text-xs text-dim",children:[s.author," ·"," ",e.jsx("a",{href:s.licenseUrl,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-ink",children:s.license})," ","·"," ",e.jsx("a",{href:s.homepage,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-ink",children:l("models.page")})]})]}),e.jsx("p",{className:"text-sm leading-relaxed text-soft",children:Le(l,s)}),e.jsx("ul",{"aria-label":l("models.task.label"),className:"flex flex-wrap gap-1.5",children:s.tasks.map(u=>e.jsx("li",{className:"rounded-md bg-panel-2 px-2 py-0.5 font-mono text-[11px] text-dim",children:Pe(l,u)},u))}),j?e.jsxs("div",{className:"flex flex-col gap-1 border-t border-line pt-4",children:[e.jsxs("p",{children:[e.jsx("span",{className:"font-mono text-lg",children:d(s.size)})," ",e.jsx("span",{className:"text-sm text-dim",children:Y})]}),e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:j.label})," ",e.jsxs("span",{className:j.fit==="gpu"?"text-dim":"text-danger",children:["· ",A(l,j.fit)]})]}),e.jsxs(he,{className:"text-xs text-dim",children:[e.jsxs(fe,{className:"group -ml-2 inline-flex h-10 items-center gap-1.5 rounded-lg px-2 outline-none hover:text-ink focus-visible:ring-3 focus-visible:ring-ring/50",children:[l("models.files",{count:j.files.length}),s.variants.length>1&&` · ${l("models.versions",{count:s.variants.length})}`,e.jsx(je,{"aria-hidden":"true",className:"size-3.5 transition-transform group-data-panel-open:rotate-180 motion-reduce:transition-none"})]}),e.jsxs(Ne,{children:[e.jsx("ul",{className:"flex flex-col gap-1 font-mono",children:j.files.map(u=>e.jsxs("li",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:"min-w-0 truncate",title:u.name,children:u.name}),e.jsxs("span",{className:"shrink-0",children:[d(u.size),u.present&&` · ${l("models.onDisk")}`]})]},u.name))}),s.variants.length>1&&e.jsx("ul",{className:"mt-3 flex flex-col gap-2",children:s.variants.map(u=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{children:[e.jsx("span",{className:"text-ink",children:u.label})," ·"," ",d(u.size)," · ",A(l,u.fit),u.id===s.variant&&` · ${l(r?"models.variantInstalled":"models.recommended")}`]}),p.admin&&!r&&!g&&W.includes(u)&&e.jsx(v,{variant:"outline",onClick:()=>i.mutate(u.id),disabled:i.isPending,children:l("models.installVersion")})]},u.id))})]})]})]}):e.jsx("p",{className:"text-sm text-danger",children:l("models.noVersion")}),r&&!s.ready&&!g&&e.jsx("p",{className:"text-sm text-danger",children:l("models.engineMissing")}),g&&e.jsx($e,{model:s}),s.error&&!g&&e.jsx("p",{className:"text-sm text-danger",children:l("models.installStopped",{error:o({message:s.error,code:s.errorCode,params:s.errorParams})})}),n&&e.jsx("p",{className:"text-sm text-danger",children:o(n)}),j&&!r&&!g&&!B&&e.jsx("p",{className:"text-sm text-danger",children:l("models.notEnoughSpace",{needed:d(C),free:d(t)})}),!p.admin&&!r&&!g&&e.jsx("p",{className:"mt-auto pt-1 text-sm text-dim",children:l("models.askAdmin")}),e.jsxs("div",{className:z("mt-auto flex flex-wrap gap-2 pt-1",!p.admin&&"hidden"),children:[r&&!s.ready&&!g&&e.jsx(v,{variant:"aurora",onClick:()=>i.mutate(void 0),disabled:i.isPending,children:l("models.installEngine")}),j&&!r&&!g&&e.jsx(v,{variant:"aurora",onClick:()=>i.mutate(void 0),disabled:!B||i.isPending,children:f>0?l("models.resume"):l("models.install")}),g&&e.jsx(v,{variant:"outline",onClick:()=>m.mutate(),disabled:m.isPending,children:s.state==="queued"?l("common.cancel"):l("models.pause")}),(r||f>0)&&!g&&e.jsx(H,{label:l(r?"models.delete":"models.discard"),question:r?l("models.deleteConfirm",{model:s.name,size:d(s.reclaimableBytes)}):l("models.discardConfirm",{model:s.name,size:d(f)}),confirm:l(r?"models.delete":"models.discard"),disabled:h.isPending,onConfirm:()=>h.mutate()})]})]})]})})}const Ve={cuda:"CUDA",rocm:"ROCm",metal:"Metal",vulkan:"Vulkan"};function Ke({view:s}){const a=T(),{t,bytes:x}=b(),{hardware:c,engines:l,disk:d}=s,o=c.gpus.toSorted((i,m)=>m.memoryBytes-i.memoryBytes)[0];return e.jsx($,{className:K,children:e.jsx(G,{children:e.jsxs("dl",{className:"grid gap-x-8 gap-y-6 sm:grid-cols-2 lg:grid-cols-[2fr_2fr_1fr_1fr]",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("dt",{className:k,children:t("models.machine.computer")}),e.jsxs("dd",{className:"text-sm leading-relaxed",children:[o?`${o.name} · ${x(o.memoryBytes)}`:t("models.machine.noGpu"),e.jsxs("span",{className:"text-dim",children:[" ","·"," ",t("models.machine.memory",{size:x(c.memoryBytes)}),c.wsl&&" · WSL"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("dt",{className:k,children:t("models.machine.engine")}),e.jsx("dd",{className:"text-sm leading-relaxed",children:l.length===0?e.jsx("span",{className:"text-danger",children:t("models.machine.noEngine")}):l.map(i=>e.jsxs("span",{className:"block",children:[i.name," ·"," ",i.backend==="cpu"?t("models.machine.cpu"):Ve[i.backend],i.throughWindows&&` ${t("models.machine.windows")}`,e.jsxs("span",{className:"text-dim",children:[" ","·"," ",i.installed?t("models.machine.engineInstalled",{size:x(i.size)}):t("models.machine.engineLater",{size:x(i.size)})]})]},i.engine))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("dt",{className:k,children:t("models.disk.used")}),e.jsx("dd",{className:"font-mono text-lg",children:d.usedBytes>0?x(d.usedBytes):t("models.disk.nothing")})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("dt",{className:k,children:t("models.disk.free")}),e.jsx("dd",{className:"font-mono text-lg",children:x(d.freeBytes)})]}),a.admin&&e.jsx(Qe,{disk:d})]})})})}const _={category:"all",runsWell:!1,commercial:!1,installed:!1},U=["image","edit","video"];function F(s,a){switch(a){case"all":return s("models.filter.all");case"image":return s("models.category.image");case"edit":return s("models.category.edit");case"video":return s("models.category.video")}}function Ge(s,a){switch(a){case"image":return s("models.category.imageBody");case"edit":return s("models.category.editBody");case"video":return s("models.category.videoBody")}}const O="h-10 rounded-full border border-line px-4 font-normal text-dim hover:text-ink aria-pressed:border-ink aria-pressed:bg-ink aria-pressed:text-bg aria-pressed:hover:bg-ink/90 aria-pressed:hover:text-bg",q=["all",...U];function He({view:s}){const{t:a}=b(),[t,x]=N.useState(_),c=s.models.filter(n=>n.media!=="text"),l=re(c),d=oe(L(c,t)),o=n=>x(r=>({...r,...n})),i=n=>L(c,{...t,category:n}).length,m=t.category==="all"?U.map(n=>({category:n,models:d.filter(r=>ce(r)===n)})):[{category:t.category,models:d}],h=n=>e.jsx(Re,{model:n,engine:s.engines.find(r=>n.variants.some(g=>g.id===n.variant&&g.engine===r.engine)),freeBytes:s.disk.freeBytes,recommended:l.has(n.id)},n.id),p=[{key:"runsWell",text:a("models.filter.runsWell")},{key:"commercial",text:a("models.filter.commercial")},{key:"installed",text:a("models.filter.installed")}];return e.jsxs("div",{className:"flex flex-col gap-10 pt-4",children:[e.jsxs("fieldset",{className:"flex flex-col gap-3",children:[e.jsx("legend",{className:"sr-only",children:a("models.filter.label")}),e.jsx(de,{value:[t.category],onValueChange:n=>{const r=q.find(g=>g===n[0]);r&&o({category:r})},className:"flex-wrap",children:q.map(n=>e.jsxs(me,{value:n,className:O,children:[F(a,n),e.jsx("span",{className:"font-mono text-xs opacity-60",children:i(n)})]},n))}),e.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(n=>e.jsxs(xe,{pressed:t[n.key],onPressedChange:r=>o({[n.key]:r}),className:z(O,"text-xs"),children:[t[n.key]&&e.jsx(pe,{"aria-hidden":"true"}),n.text]},n.key))})]}),d.length===0?e.jsxs("p",{className:"text-sm text-dim",children:[a("models.filter.none")," ",e.jsx(v,{variant:"link",onClick:()=>x(_),className:"h-10 px-1 text-ink underline",children:a("models.filter.clear")})]}):m.map(n=>n.models.length>0&&e.jsxs("section",{"aria-label":F(a,n.category),className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h2",{className:"font-display text-2xl font-bold tracking-tight",children:F(a,n.category)}),e.jsx("p",{className:"text-sm text-dim",children:Ge(a,n.category)})]}),e.jsx("ul",{className:"grid gap-5 md:grid-cols-2",children:n.models.map(h)})]},n.category))]})}function Qe({disk:s}){const{t:a,bytes:t,explain:x}=b(),c=ue(),l=ge(),d=s.changeable&&!l,o=c??s.moving,[i,m]=N.useState(!1),[h,p]=N.useState(s.path),n=w({mutationFn:()=>y.moveModels(h),onSuccess:()=>m(!1)}),r=o?Math.round(o.movedBytes/Math.max(o.totalBytes,1)*100):0;return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 border-t border-line pt-6 sm:col-span-2 lg:col-span-4",children:[e.jsx("dt",{className:k,children:a("models.disk.path")}),e.jsxs("dd",{children:[o?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("p",{className:"truncate text-sm",title:o.to,children:a("models.folder.moving",{path:o.to})}),e.jsx(Q,{value:r,label:a("models.folder.moving",{path:o.to})}),e.jsx("p",{className:"font-mono text-xs text-dim",children:a("models.folder.moved",{moved:t(o.movedBytes),total:t(o.totalBytes)})})]}):i?e.jsxs("form",{className:"flex flex-col gap-3",onSubmit:g=>{g.preventDefault(),n.mutate()},children:[e.jsx(I,{value:h,onChange:g=>p(g.target.value),"aria-label":a("models.folder.label"),spellCheck:!1,autoFocus:!0,className:"h-10 font-mono"}),e.jsx("p",{className:"text-xs leading-relaxed text-dim",children:a("models.folder.hint",{size:t(s.usedBytes)})}),n.error&&e.jsx("p",{className:"text-sm text-danger",children:x(n.error)}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{type:"submit",disabled:n.isPending||!h.trim(),children:a("models.folder.move")}),e.jsx(v,{variant:"outline",onClick:()=>{m(!1),n.reset()},children:a("common.cancel")})]})]}):e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:"min-w-0 truncate font-mono text-sm",title:s.path,children:s.path}),d&&e.jsx(v,{variant:"outline",onClick:()=>{p(s.path),m(!0)},children:a("models.folder.change")})]}),s.moveError&&!o&&!i&&e.jsx("p",{className:"mt-2 text-sm text-danger",children:x(s.moveError)})]})]})}function Ye(){const{t:s,explain:a}=b(),t=V({queryKey:["local-models"],queryFn:y.localModels});return e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1060px] flex-col gap-6 px-4 py-8 sm:px-8 sm:py-12",children:[e.jsx(Fe,{eyebrow:s("models.eyebrow"),title:s("models.title"),intro:s("models.intro")}),t.error&&e.jsx("p",{className:"text-sm text-danger",children:a(t.error)}),t.data&&e.jsx(Ke,{view:t.data}),e.jsx(Me,{}),e.jsx(ie,{}),t.data&&e.jsx(He,{view:t.data})]})})}export{Ye as Models,Fe as PageHeader,Ae as commercialText,A as fitText};
|