model-pulse / assets /Galaxy-BGV5jbrO.js
tardellirs's picture
Update site
cad84dd verified
Raw History Blame Contribute Delete
27.7 kB
import{d as ee,h as se,g as me,T as re,u as t,s as Ce,f as N,n as oe,a as ie,S as ae,b as de,L as Ae,c as Fe,e as Pe,A as le}from"./index-iljbJvME.js";const J=[{label:"Quantized",one:"quantization",color:"#3b6ff5",of:"Quantized from"},{label:"Fine-tuned",one:"fine-tune",color:"#ff8a1f",of:"Fine-tuned from"},{label:"Adapters",one:"adapter",color:"#2f8f5b",of:"Adapter on"},{label:"Merges",one:"merge",color:"#a35bf0",of:"Merge built on"}],be=[1,2,0,3],Q="#1b1b1f",ce="#fbfaf5",fe="#ffd21e",he="#63615b",xe=[0,330,590,800,960],ne=Math.PI*2,ue=["","1st","2nd","3rd","4th+"],ye=()=>matchMedia("(prefers-reduced-motion: reduce)").matches,te=e=>e.split("/").pop()??e,X=(e,a)=>e.nodes.rel[a]>=0?e.nodes.rel[a]:1;function ke(e,a){let h=Math.imul(e^2654435769,2246822507)^Math.imul(a+1,3266489909);return h^=h>>>13,h=Math.imul(h,668265263),h^=h>>>16,(h>>>0)/4294967296}function ve(e){const{parent:a,dl30:h}=e.nodes,d=a.length,C=new Uint8Array(d),T=new Int32Array(d).fill(1),s=new Int32Array(d+1);for(let l=1;l<d;l++)C[l]=Math.min(4,C[a[l]]+1),s[a[l]+1]++;for(let l=0;l<d;l++)s[l+1]+=s[l];const F=s.slice(0,d),z=new Int32Array(Math.max(0,d-1));for(let l=1;l<d;l++)z[F[a[l]]++]=l;for(let l=d-1;l>0;l--)T[a[l]]+=T[l];const x=[0,0,0,0,0];for(let l=1;l<d;l++)x[C[l]]++;const v=l=>1+Math.pow(T[l]-1,.8),y=new Float32Array(d),S=new Float32Array(d),R=new Float32Array(d),B=new Float32Array(d),b=(l,W,M)=>{l.sort((A,P)=>v(P)-v(A)||(h[P]||0)-(h[A]||0));const o=[];l.forEach((A,P)=>P%2?o.unshift(A):o.push(A));const w=o.reduce((A,P)=>A+v(P),0)||1;let k=W;for(const A of o){const P=(M-W)*v(A)/w;y[A]=k+P/2,S[A]=P,k+=P}},U=Array.from(z.subarray(s[0],s[1])),H=[0,1,2,3].map(l=>U.filter(W=>X(e,W)===l)),_=be.filter(l=>H[l].length),K=_.length>1?.05:0,j=_.map(l=>Math.sqrt(H[l].reduce((W,M)=>W+v(M),0))),q=j.reduce((l,W)=>l+W,0)||1,f=_.length>1?.12:1,Z=j.map(l=>Math.max(f,l/q)),Y=Z.reduce((l,W)=>l+W,0),I=ne-K*_.length,V=[];let r=-Math.PI/2-Z[0]/Y*I/2;_.forEach((l,W)=>{const M=Z[W]/Y*I;V.push({rel:l,a0:r,a1:r+M,count:H[l].length}),b(H[l],r,r+M),r+=M+K});for(let l=1;l<d;l++)s[l+1]>s[l]&&b(Array.from(z.subarray(s[l],s[l+1])),y[l]-S[l]/2,y[l]+S[l]/2);let p=1;for(let l=1;l<d;l++)p=Math.max(p,h[l]||0);const $=new Float32Array(d);for(let l=1;l<d;l++)$[l]=(h[l]||0)>0?Math.min(24,1.6+22*Math.sqrt((h[l]||0)/p)):1.2;const n=x.map(l=>Math.max(14,Math.min(120,Math.sqrt(l)*1.3)));for(let l=1;l<d;l++){const W=C[l],M=$[l]>=5,o=xe[W]+(M?0:(ke(l,1)-.5)*n[W]),w=M?y[l]:y[l]+(ke(l,2)-.5)*Math.min(S[l]*.9,.08);R[l]=Math.cos(w)*o,B[l]=Math.sin(w)*o}const i=Int32Array.from({length:d},(l,W)=>W).sort((l,W)=>(h[W]||0)-(h[l]||0)),c=[0,1,2,3].map(l=>Int32Array.from({length:d},(W,M)=>M).filter(W=>W>0&&X(e,W)===l)),u=i.filter(l=>l>0&&(h[l]||0)>0).slice(0,160),m=x.reduce((l,W,M)=>W?M:l,1),g=xe.slice(1,m+1),E=g[g.length-1]+n[m]/2+120,D=24,O=new Map;for(let l=0;l<d;l++){const W=Math.floor(R[l]/D)*100003+Math.floor(B[l]/D),M=O.get(W);M?M.push(l):O.set(W,[l])}return{n:d,x:R,y:B,ang:y,size:$,depth:C,sub:T,start:s,kids:z,byRel:c,order:i,rings:g,sectors:V,gens:x,extent:E,cell:D,grid:O,links:u}}const we=(e,a)=>Math.min(2.6,Math.max(1,Math.sqrt(e/a))),Te=e=>22+6*(e-1);function Se(e,a,h,d,C,T,s){var V;const{x:F,y:z,size:x}=T,v=r=>(r-d.cx)*d.k+a/2,y=r=>(r-d.cy)*d.k+h/2,S=v(0),R=y(0),B=we(d.k,s.kFit),b=s.p>=1?1:1-(1-s.p)**3;e.globalAlpha=1,e.fillStyle=ce,e.fillRect(0,0,a,h);for(const r of T.sectors)s.hidden[r.rel]||(e.beginPath(),e.moveTo(S,R),e.arc(S,R,(T.extent-60)*d.k,r.a0,r.a1),e.closePath(),e.fillStyle=J[r.rel].color,e.globalAlpha=.045,e.fill());e.globalAlpha=1,e.setLineDash([3,5]),e.lineWidth=1,e.strokeStyle="rgba(27,27,31,0.28)";for(const r of T.rings)e.beginPath(),e.arc(S,R,r*d.k*b,0,ne),e.stroke();e.setLineDash([]);const U=(V=s.focus)==null?void 0:V.mark;e.strokeStyle=Q,e.lineWidth=1,e.globalAlpha=(U?.06:.16)*b,e.beginPath();for(const r of T.links){const p=C.nodes.parent[r];s.hidden[X(C,r)]||(U==null?void 0:U[r])===1||(e.moveTo(v(F[p]*b),y(z[p]*b)),e.lineTo(v(F[r]*b),y(z[r]*b)))}if(e.stroke(),e.globalAlpha=1,s.focus){e.strokeStyle=Q,e.lineWidth=1.2,e.globalAlpha=.35*b,e.beginPath();for(const r of s.focus.ids.subarray(1,300)){if(s.hidden[X(C,r)])continue;const p=C.nodes.parent[r];e.moveTo(v(F[p]*b),y(z[p]*b)),e.lineTo(v(F[r]*b),y(z[r]*b))}e.stroke(),e.globalAlpha=1}for(let r=0;r<4;r++){if(s.hidden[r])continue;e.fillStyle=J[r].color,e.globalAlpha=U?.14:.5;const p=new Path2D;for(const $ of T.byRel[r]){if(x[$]>=5||(U==null?void 0:U[$])===1)continue;const n=v(F[$]*b),i=y(z[$]*b),c=x[$]*B;n<-c||i<-c||n>a+c||i>h+c||(c<1.6?p.rect(n-c,i-c,c*2,c*2):(p.moveTo(n+c,i),p.arc(n,i,c,0,ne)))}e.fill(p)}e.globalAlpha=1;for(let r=T.n-1;r>=0;r--){const p=T.order[r];if(p===0||x[p]<5||s.hidden[X(C,p)])continue;const $=v(F[p]*b),n=y(z[p]*b),i=x[p]*B;e.globalAlpha=U&&!U[p]?.25:1,e.beginPath(),e.arc($,n,i,0,ne),e.fillStyle=J[X(C,p)].color,e.fill(),e.lineWidth=2,e.strokeStyle=Q,e.stroke()}if(e.globalAlpha=1,s.focus){const r=s.focus.ids.length<=600;e.lineWidth=1,e.strokeStyle=Q;for(const p of s.focus.ids){if(x[p]>=5||s.hidden[X(C,p)])continue;const $=v(F[p]*b),n=y(z[p]*b),i=Math.max(r?2.6:1.8,x[p]*B);$<-i||n<-i||$>a+i||n>h+i||(e.beginPath(),e.arc($,n,i,0,ne),e.fillStyle=J[X(C,p)].color,e.fill(),r&&e.stroke())}}const H=Te(B);e.beginPath(),e.arc(S+4,R+4,H,0,ne),e.fillStyle=Q,e.fill(),e.beginPath(),e.arc(S,R,H,0,ne),e.fillStyle=fe,e.fill(),e.lineWidth=3,e.strokeStyle=Q,e.stroke();for(const r of[s.sel,s.hover])r>0&&ge(e,a,h,d,C,T,s.kFit,r,r===s.sel);if(s.p<1)return;const _=[[S-H-6,R-H-6,H*2+12,H*2+12],[a-64,0,64,150]];for(const r of T.links){if(s.hidden[X(C,r)]||x[r]<5)continue;const p=x[r]*B;_.push([v(F[r])-p,y(z[r])-p,p*2,p*2])}e.textBaseline="middle",e.lineJoin="round";for(const r of T.sectors){if(s.hidden[r.rel])continue;const p=(r.a0+r.a1)/2,$=(T.extent-70)*d.k,n=S+Math.cos(p)*$,i=R+Math.sin(p)*$,c=J[r.rel].label,u=`${N(r.count)} direct`;e.font="600 13px 'IBM Plex Mono', ui-monospace, monospace";const m=e.measureText(`${c} ${u}`).width,g=Math.max(6,Math.min(a-m-6,n-m/2));i<10||i>h-10||(e.lineWidth=4,e.strokeStyle=ce,e.strokeText(`${c} ${u}`,g,i),e.fillStyle=J[r.rel].color,e.fillText(c,g,i),e.fillStyle=Q,e.fillText(u,g+e.measureText(`${c} `).width,i),_.push([g-2,i-10,m+4,20]))}e.font="500 11.5px 'IBM Plex Mono', ui-monospace, monospace",T.rings.forEach((r,p)=>{const $=`${ue[p+1]} generation`,n=e.measureText($).width,i=S-n/2,c=R+r*d.k+11;c<8||c>h-8||(e.lineWidth=4,e.strokeStyle=ce,e.strokeText($,i,c),e.fillStyle=he,e.fillText($,i,c),_.push([i-2,c-8,n+4,16]))}),e.font="600 15px 'Fredoka', system-ui, sans-serif";const K=te(C.root.id),j=e.measureText(K).width,q=R+H+16;q<h-8&&(e.lineWidth=5,e.strokeStyle=ce,e.strokeText(K,S-j/2,q),e.fillStyle=Q,e.fillText(K,S-j/2,q),_.push([S-j/2-2,q-10,j+4,20]));const f=s.labels??Math.min(40,Math.round(14+10*Math.max(0,Math.log2(d.k/s.kFit)))),Z=new Set;e.font="600 13px 'Source Sans 3', system-ui, sans-serif";let Y=0;const I=(r,p=!1)=>{var D;const $=p&&s.focus?C.nodes.id[r]:te(C.nodes.id[r]);if(!p&&Z.has($))return;const n=v(F[r]),i=y(z[r]),c=x[r]*B,u=Math.cos(T.ang[r])>=-.1,m=e.measureText($).width,g=u?n+c+5:n-c-5-m,E=i-9;g<4||E<4||g+m>a-4||E+18>h-4||!p&&_.some(O=>g<O[0]+O[2]&&g+m>O[0]&&E<O[1]+O[3]&&E+18>O[1])||(_.push([g-2,E,m+4,18]),(D=s.labelHits)==null||D.push([g-2,E,m+4,18,r]),Z.add($),e.lineWidth=4,e.strokeStyle=ce,e.strokeText($,g,i),e.fillStyle=Q,e.fillText($,g,i),Y++)};if(s.sel>0&&I(s.sel,!0),s.focus){for(let r=C.nodes.parent[s.focus.ids[0]];r>0;r=C.nodes.parent[r])I(r);for(const r of s.focus.ids.subarray(0,200))Y<f&&!s.hidden[X(C,r)]&&I(r)}for(let r=0;r<Math.min(T.n,800)&&Y<f;r++){const p=T.order[r];p>0&&(C.nodes.dl30[p]||0)>0&&!s.hidden[X(C,p)]&&I(p)}}function ge(e,a,h,d,C,T,s,F,z){const x=R=>(T.x[R]-d.cx)*d.k+a/2,v=R=>(T.y[R]-d.cy)*d.k+h/2,y=we(d.k,s);e.globalAlpha=.5,e.strokeStyle=J[X(C,F)].color,e.lineWidth=1.2,e.beginPath();for(let R=T.start[F];R<T.start[F+1]&&R<T.start[F]+400;R++){const B=T.kids[R];e.moveTo(x(F),v(F)),e.lineTo(x(B),v(B))}e.stroke(),e.globalAlpha=1,e.strokeStyle=Q,e.lineWidth=2.5,e.beginPath();let S=F;for(e.moveTo(x(S),v(S));S>0;)S=C.nodes.parent[S],e.lineTo(x(S),v(S));e.stroke(),e.beginPath(),e.arc(x(F),v(F),Math.max(5,T.size[F]*y)+5,0,ne),e.lineWidth=3,e.strokeStyle=z?Q:he,e.stroke(),z&&(e.beginPath(),e.arc(x(F),v(F),Math.max(5,T.size[F]*y)+9,0,ne),e.lineWidth=2,e.strokeStyle=fe,e.stroke())}const Me=(e,a,h)=>({k:(Math.min(a,h)/2-8)/e.extent,cx:0,cy:0});function Ie({g:e,L:a,focus:h,hidden:d,sel:C,hoverExt:T,onSel:s,flyTo:F}){const z=le(null),x=le(null),v=le({W:0,H:0,dpr:1,view:{k:1,cx:0,cy:0},kFit:1,p:ye()?1:0,hover:-1,raf:0,labels:[]}),y=le({hidden:d,sel:C,hoverExt:T});y.current={hidden:d,sel:C,hoverExt:T};const S=le(null),R=le(0),B=le(s);B.current=s;const[b,U]=ee(null),H=()=>y.current.hoverExt>0?y.current.hoverExt:v.current.hover,_=()=>{var u,m;const n=v.current,i=(u=x.current)==null?void 0:u.getContext("2d");if(!i||!n.W)return;i.setTransform(n.dpr,0,0,n.dpr,0,0),n.labels=[];const c=performance.now();if(Se(i,n.W,n.H,n.view,e,a,{p:n.p,hidden:y.current.hidden,hover:-1,sel:y.current.sel,kFit:n.kFit,focus:h,labelHits:n.labels}),n.p>=1){const g=((m=S.current)==null?void 0:m.img)??document.createElement("canvas");(g.width!==x.current.width||g.height!==x.current.height)&&(g.width=x.current.width,g.height=x.current.height);const E=g.getContext("2d");E.setTransform(1,0,0,1,0,0),E.drawImage(x.current,0,0),S.current={img:g,view:{...n.view},heavy:performance.now()-c>22}}H()>0&&ge(i,n.W,n.H,n.view,e,a,n.kFit,H(),!1)},K=()=>{var E;const n=v.current,i=(E=x.current)==null?void 0:E.getContext("2d"),c=S.current;if(!i||!c)return _();const u=n.view.k/c.view.k;i.setTransform(1,0,0,1,0,0),i.fillStyle=ce,i.fillRect(0,0,x.current.width,x.current.height);const m=(n.W/2-n.W/2*u+(c.view.cx-n.view.cx)*n.view.k)*n.dpr,g=(n.H/2-n.H/2*u+(c.view.cy-n.view.cy)*n.view.k)*n.dpr;i.drawImage(c.img,m,g,c.img.width*u,c.img.height*u),i.setTransform(n.dpr,0,0,n.dpr,0,0),u===1&&m===0&&g===0&&H()>0&&ge(i,n.W,n.H,n.view,e,a,n.kFit,H(),!1)},j=()=>{const n=v.current;n.raf||(n.raf=requestAnimationFrame(()=>{n.raf=0,_()}))},q=()=>{var i;const n=v.current;if(!((i=S.current)!=null&&i.heavy))return j();n.raf||(n.raf=requestAnimationFrame(()=>{n.raf=0,K()})),clearTimeout(R.current),R.current=window.setTimeout(j,160)},f=()=>{const n=v.current,i=S.current;i&&n.p>=1&&i.view.k===n.view.k&&i.view.cx===n.view.cx&&i.view.cy===n.view.cy?n.raf||(n.raf=requestAnimationFrame(()=>{n.raf=0,K()})):j()},Z=(n,i,c=!1)=>{if(ye()){i(1),j();return}const u=performance.now(),m=g=>{var D;const E=Math.min(1,(g-u)/n);i(E),c&&E<1&&((D=S.current)!=null&&D.heavy)?K():_(),E<1&&requestAnimationFrame(m)};requestAnimationFrame(m)};se(()=>{const n=v.current,i=()=>{const u=z.current.getBoundingClientRect(),m=!n.W;n.W=u.width,n.H=u.height,n.dpr=Math.min(2,devicePixelRatio||1),x.current.width=Math.round(n.W*n.dpr),x.current.height=Math.round(n.H*n.dpr);const g=Me(a,n.W,n.H);if(n.view=m?g:{...n.view,k:n.view.k*(g.k/n.kFit)},n.kFit=g.k,_(),m&&Y.current){const E=Y.current;Y.current=null,I(E)}},c=new ResizeObserver(i);return c.observe(z.current),n.p<1&&Z(1100,u=>{n.p=u}),()=>{c.disconnect(),clearTimeout(R.current)}},[a]),se(j,[d,C]),se(f,[T]);const Y=le(null),I=n=>{const i=v.current;if(!i.W){Y.current=n;return}const c={...i.view},u={k:Math.max(c.k,i.kFit*(n.zoom??3.5)),cx:a.x[n.i],cy:a.y[n.i]};Z(700,m=>{const g=m<.5?4*m**3:1-(-2*m+2)**3/2;i.view={k:c.k*(u.k/c.k)**g,cx:c.cx+(u.cx-c.cx)*g,cy:c.cy+(u.cy-c.cy)*g}},!0)};se(()=>{F&&I(F)},[F]);const V=(n,i,c)=>{const u=v.current,m=u.view,g=(n-u.W/2)/m.k+m.cx,E=(i-u.H/2)/m.k+m.cy,D=Math.min(u.kFit*60,Math.max(u.kFit*.7,m.k*c));u.view={k:D,cx:g-(n-u.W/2)/D,cy:E-(i-u.H/2)/D},q()},r=(n,i)=>{const c=v.current,u=c.view;for(const k of c.labels)if(n>=k[0]&&n<=k[0]+k[2]&&i>=k[1]&&i<=k[1]+k[3])return k[4];const m=(n-c.W/2)/u.k+u.cx,g=(i-c.H/2)/u.k+u.cy,E=we(u.k,c.kFit);if(Math.hypot(m,g)*u.k<=Te(E))return 0;const D=30/u.k,O=Math.floor((m-D)/a.cell),l=Math.floor((m+D)/a.cell),W=Math.floor((g-D)/a.cell),M=Math.floor((g+D)/a.cell);let o=-1,w=1/0;for(let k=O;k<=l;k++)for(let A=W;A<=M;A++)for(const P of a.grid.get(k*100003+A)??[]){if(P===0||y.current.hidden[X(e,P)])continue;const L=a.size[P]*E,G=Math.hypot((a.x[P]-m)*u.k,(a.y[P]-g)*u.k);G<=Math.max(7,L+5)&&G-1.6*L<w&&(o=P,w=G-1.6*L)}return o};se(()=>{const n=x.current,i=v.current,c=new Map;let u=0,m=0;const g=M=>{const o=n.getBoundingClientRect();return{x:M.clientX-o.left,y:M.clientY-o.top}},E=M=>{n.setPointerCapture(M.pointerId),c.set(M.pointerId,g(M)),u=0,m=0},D=M=>{const o=g(M);if(!c.has(M.pointerId)){if(M.pointerType!=="mouse")return;const k=r(o.x,o.y);k!==i.hover&&(i.hover=k,f()),U(k>=0?{i:k,x:o.x,y:o.y}:null),n.style.cursor=k>=0?"pointer":"grab";return}const w=c.get(M.pointerId);if(c.set(M.pointerId,o),c.size===1)u+=Math.abs(o.x-w.x)+Math.abs(o.y-w.y),i.view={...i.view,cx:i.view.cx-(o.x-w.x)/i.view.k,cy:i.view.cy-(o.y-w.y)/i.view.k},i.hover>=0&&(i.hover=-1,U(null)),q();else if(c.size===2){const[k,A]=[...c.values()],P=Math.hypot(k.x-A.x,k.y-A.y);m&&V((k.x+A.x)/2,(k.y+A.y)/2,P/m),m=P,u=99}},O=M=>{const o=c.get(M.pointerId);if(c.delete(M.pointerId),c.size<2&&(m=0),o&&u<6&&c.size===0){const w=r(o.x,o.y);B.current(w>0?w:-1)}},l=M=>{M.preventDefault();const o=g(M);V(o.x,o.y,Math.exp(-M.deltaY*(M.deltaMode?.05:.0018)))},W=()=>{i.hover>=0&&(i.hover=-1,f()),U(null)};return n.addEventListener("pointerdown",E),n.addEventListener("pointermove",D),n.addEventListener("pointerup",O),n.addEventListener("pointercancel",O),n.addEventListener("pointerleave",W),n.addEventListener("wheel",l,{passive:!1}),()=>{n.removeEventListener("pointerdown",E),n.removeEventListener("pointermove",D),n.removeEventListener("pointerup",O),n.removeEventListener("pointercancel",O),n.removeEventListener("pointerleave",W),n.removeEventListener("wheel",l)}},[a]);const p=n=>{const i=v.current;V(i.W/2,i.H/2,n)},$=()=>{const n=v.current,i={...n.view},c=Me(a,n.W,n.H);Z(500,u=>{const m=1-(1-u)**3;n.view={k:i.k+(c.k-i.k)*m,cx:i.cx*(1-m),cy:i.cy*(1-m)}},!0)};return t("div",{class:"o-sky",ref:z,children:[t("canvas",{ref:x,role:"img","aria-label":`${N(a.n-1)} models built on ${e.root.id}, arranged by generation and kind`}),t("div",{class:"g-zoom",children:[t("button",{"aria-label":"Zoom in",onClick:()=>p(1.6),children:"+"}),t("button",{"aria-label":"Zoom out",onClick:()=>p(1/1.6),children:"−"}),t("button",{"aria-label":"Show everything",onClick:$,children:"⤢"})]}),b&&b.i!==C&&t("div",{class:"g-tip",style:{left:Math.min(b.x,(v.current.W||9999)-260),top:b.y},children:[t("b",{children:b.i===0?e.root.id:e.nodes.id[b.i]}),t("span",{children:[b.i===0?"the base model":`${J[X(e,b.i)].one}, ${ue[a.depth[b.i]]} generation`,", ",de(e.nodes.dl30[b.i])," downloads a month",a.sub[b.i]>1?`, ${N(a.sub[b.i]-1)} built on it`:""]})]})]})}async function $e(e,a,h){await Promise.all(["600 60px 'Fredoka'","500 20px 'IBM Plex Mono'","600 14px 'Source Sans 3'"].map(b=>document.fonts.load(b)));const d=1600,C=900,T=document.createElement("canvas");T.width=d,T.height=C;const s=T.getContext("2d"),F=(C/2-20)/a.extent;Se(s,d,C,{k:F,cx:-290/F,cy:0},e,a,{p:1,hidden:[!1,!1,!1,!1],hover:-1,sel:h?h.ids[0]:-1,kFit:F,focus:h,labels:14});const z=s.createLinearGradient(0,0,640,0);z.addColorStop(0,"rgba(251,250,245,1)"),z.addColorStop(.8,"rgba(251,250,245,0.92)"),z.addColorStop(1,"rgba(251,250,245,0)"),s.fillStyle=z,s.fillRect(0,0,640,C);const x=(b,U,H,_,K,j=520)=>{if(s.font=_,s.fillStyle=K,s.textBaseline="alphabetic",s.measureText(b).width>j){for(;b.length>3&&s.measureText(b+"…").width>j;)b=b.slice(0,-1);b+="…"}s.fillText(b,U,H)};s.fillStyle=Q,s.beginPath(),s.roundRect(70,70,56,56,14),s.fill(),s.fillStyle=fe,s.beginPath(),s.roundRect(64,64,56,56,14),s.fill(),s.lineWidth=4,s.strokeStyle=Q,s.stroke(),s.beginPath(),s.lineWidth=5,s.lineJoin="round",s.lineCap="round",s.moveTo(74,94),s.lineTo(84,94),s.lineTo(90,78),s.lineTo(100,108),s.lineTo(106,94),s.lineTo(112,94),s.stroke(),x("Model Pulse Galaxy",138,104,"600 32px 'Fredoka'",Q);const[v,y]=e.root.id.includes("/")?[e.root.id.split("/")[0],te(e.root.id)]:["",e.root.id],S=y.length>18?50:64;x(v?v+"/":"",66,228,"500 24px 'IBM Plex Mono'",he),s.font=`600 ${S}px 'Fredoka'`;const R=Math.min(540,s.measureText(y).width+28);s.fillStyle=fe,s.beginPath(),s.roundRect(58,246,R,S+20,12),s.fill(),x(y,72,246+S+2,`600 ${S}px 'Fredoka'`,Q,510),x(N(e.total),66,432,"600 72px 'Fredoka'",Q),x("models built on it",68,470,"500 24px 'IBM Plex Mono'",he);let B=560;for(const b of a.sectors)s.fillStyle=J[b.rel].color,s.beginPath(),s.arc(76,B-8,9,0,ne),s.fill(),s.lineWidth=2,s.strokeStyle=Q,s.stroke(),x(`${J[b.rel].label} ${N(a.byRel[b.rel].length)}`,98,B,"500 24px 'IBM Plex Mono'",Q),B+=42;return x("modelpulse.ifsp.dev",66,C-50,"500 22px 'IBM Plex Mono'",he),new Promise(b=>T.toBlob(U=>b(U),"image/png"))}function We({counts:e}){const a=e.reduce((h,d)=>h+d,0)||1;return t("span",{class:"o-bar","aria-hidden":"true",children:be.map(h=>e[h]>0&&t("i",{style:{width:`${e[h]/a*100}%`,background:J[h].color}},h))})}function Re(){const[e,a]=ee([]);return se(()=>{document.title="Model galaxies: every model built on Llama, Qwen, FLUX and more · Model Pulse",me("/api/galaxies").then(h=>a(h.slice(0,16))).catch(()=>{})},[]),t(ae,{children:[t("div",{class:"wrap w-entry g-entry",children:[t("h1",{children:[t(Fe,{size:72}),"Model Pulse ",t("span",{class:"hl",children:"Galaxy"})]}),t("p",{class:"lede",children:"Every model built on a base model, laid out like a solar system: one orbit per generation, one sector for each kind of derivative, and the most downloaded as the biggest planets."}),t("div",{class:"g-search",children:t(Pe,{big:!0,placeholder:"A base model, e.g. meta-llama/Llama-3.1-8B",onPick:h=>oe({view:"galaxy",model:h})})})]}),e.length>0&&t("section",{class:"wrap g-fams",children:[t("h2",{children:"The biggest galaxies"}),t("div",{class:"g-grid",children:e.map(h=>t("a",{class:"g-fam",href:ie({view:"galaxy",model:h.id}),onClick:d=>{d.preventDefault(),oe({view:"galaxy",model:h.id})},children:[t("span",{class:"o",children:[h.id.split("/")[0],"/"]}),t("span",{class:"nm",children:te(h.id)}),t(We,{counts:[h.n_quantized,h.n_finetune,h.n_adapter,h.n_merge]}),t("span",{class:"c",children:[t("b",{children:N(h.fam_members)})," models, ",de(h.fam_dl30)," downloads a month"]})]},h.id))})]})]})}function ze({model:e}){const[a,h]=ee(null),[d,C]=ee(null),[T,s]=ee(!0),[F,z]=ee(null),[x,v]=ee([!1,!1,!1,!1]),[y,S]=ee(-1),[R,B]=ee(-1),[b,U]=ee(null),[H,_]=ee(""),[K,j]=ee(!1);se(()=>{if(!e)return;let o=!0;return document.title=`${e} galaxy: every model built on it · Model Pulse`,h(null),C(null),s(!0),z(null),S(-1),_(""),me(`/api/galaxy/${e}`).then(async w=>{const k=w.lineage[w.lineage.length-1];let A=null;if(k){const P=await me(`/api/galaxy/${k}`).catch(()=>null),L=P?P.nodes.id.indexOf(w.root.id):-1;P&&L>0&&(A={g:P,i:L})}o&&(h(w),C(A),A&&S(A.i),document.title=A?`${w.root.id} in the ${A.g.root.id} galaxy · Model Pulse`:`${w.root.id} galaxy: ${w.total.toLocaleString("en")} models built on it · Model Pulse`)}).catch(w=>o&&z(w.message)),()=>{o=!1}},[e]);const q=T&&!!d,f=q?d.g:a,Z=re(()=>a?ve(a):null,[a]),Y=re(()=>d?ve(d.g):null,[d]),I=q?Y:Z,V=re(()=>{if(!d)return null;const{parent:o,dl30:w}=d.g.nodes,k=o.length,A=d.i,P=new Uint8Array(k);P[A]=1;for(let G=A+1;G<k;G++)P[o[G]]===1&&(P[G]=1);for(let G=o[A];G>0;G=o[G])P[G]=2;const L=Int32Array.from({length:k},(G,pe)=>pe).filter(G=>P[G]===1&&G!==A).sort((G,pe)=>(w[pe]||0)-(w[G]||0));return{mark:P,ids:Int32Array.from([A,...L])}},[d]);se(()=>{if(!q)return;const o=setTimeout(()=>U({i:d.i,n:Date.now(),zoom:2.2}),ye()?50:1e3);return()=>clearTimeout(o)},[q,d]);const r=o=>{s(o),S(o&&d?d.i:-1),U(null),v([!1,!1,!1,!1]),_("")},p=re(()=>f?f.nodes.id.map(o=>o.toLowerCase()):[],[f]),$=re(()=>{const o=H.trim().toLowerCase();if(!I||o.length<2)return[];const w=[];for(let k=0;k<I.n&&w.length<8;k++)I.order[k]>0&&p[I.order[k]].includes(o)&&w.push(I.order[k]);return w},[H,I,p]),n=re(()=>{if(!f)return[];const o=f.root.id.split("/")[0],w=new Map;return f.nodes.id.forEach((k,A)=>{if(!A)return;const P=k.split("/")[0];if(P===o)return;const L=w.get(P)??{n:0,dl:0};L.n++,L.dl+=f.nodes.dl30[A]||0,w.set(P,L)}),[...w.entries()].sort((k,A)=>A[1].dl-k[1].dl).slice(0,6)},[f]);if(!e)return t(Re,{});if(F)return t("div",{class:"wrap err",children:[t("h1",{children:"No galaxy to show"}),t("p",{children:F})]});const i=f==null?void 0:f.root,[c,u]=e.includes("/")?[e.split("/")[0],te(e)]:["",e],m=o=>{S(o),_(""),o>0&&U({i:o,n:Date.now()})},g=Ce({view:"galaxy",model:(a==null?void 0:a.root.id)??e}),E=i?q?`${a.root.id} in the ${i.id} galaxy, ${N(f.total)} models built on ${te(i.id)}:`:`${N(f.total)} models are built on ${i.id}. Here is its whole galaxy:`:"",D=!d&&(a!=null&&a.lineage.length)?a.lineage[a.lineage.length-1]:null,O=(d==null?void 0:d.i)??-1,l=I?[0,1,2,3].map(o=>I.byRel[o].length):[0,0,0,0],W=I?Array.from(I.order).filter(o=>o>0).slice(0,12):[],M=o=>J[X(f,o)];return t("div",{class:"galaxy",children:[t("div",{class:"wrap g-head",children:[t("div",{class:"crumbs",children:[t("a",{class:"chip",href:ie({view:"galaxy"}),onClick:o=>{o.preventDefault(),oe({view:"galaxy"})},children:"All galaxies"}),D&&t("a",{class:"chip chip-hot",href:ie({view:"galaxy",model:D}),onClick:o=>{o.preventDefault(),oe({view:"galaxy",model:D})},children:["Part of the ",te(D)," galaxy"]}),t("a",{class:"chip",href:ie({model:e}),onClick:o=>{o.preventDefault(),oe({model:e})},children:"Download history"})]}),t("h1",{class:"model-name",children:[c&&t(ae,{children:[t("span",{class:"org",children:[c,"/"]}),t("wbr",{})]}),t("span",{class:"hl",children:u})]}),t("p",{class:"g-lede",children:f?q?t(ae,{children:["A ",J[X(f,O)].one," of ",te(f.nodes.id[f.nodes.parent[O]]),", ",ue[I.depth[O]]," generation in the galaxy of ",te(i.id),", ",a.total?t(ae,{children:[t("b",{children:N(a.total)})," ",a.total===1?"model is":"models are"," built on it, highlighted below"]}):"with nothing built on it yet","."," ","The whole galaxy has ",t("b",{children:N(f.total)})," models, downloaded ",t("b",{children:de(i.fam_dl30)})," times in the last 30 days."]}):f.total?t(ae,{children:[t("b",{children:N(f.total)})," models are built on ",u,", directly or through other derivatives. Together with the original they were downloaded ",t("b",{children:de(i.fam_dl30)})," times in the last 30 days."]}):t(ae,{children:["No models on the Hub are built on ",u," yet."]}):"Mapping every model built on it…"}),d&&a&&a.total>0&&t("div",{class:"seg g-mode",role:"group","aria-label":"What to show",children:[t("button",{"aria-pressed":T,onClick:()=>r(!0),children:["In the ",te(d.g.root.id)," galaxy"]}),t("button",{"aria-pressed":!T,onClick:()=>r(!1),children:["Only what is built on it (",N(a.total),")"]})]})]}),t("div",{class:"wrap o-layout",children:[t("div",{class:"o-stage",children:[f&&I&&f.total>0?t(Ie,{g:f,L:I,focus:q?V:null,hidden:x,sel:y,hoverExt:R,onSel:S,flyTo:b},q?"ctx":"own"):t("div",{class:"o-sky o-empty",children:f?t("span",{children:"Nothing orbits this model yet."}):t("span",{class:"g-loading",children:"Mapping the galaxy…"})}),t("ul",{class:"o-key",children:[t("li",{children:[t("span",{class:"k-sun","aria-hidden":"true"}),i?te(i.id):u," in the center"]}),q&&t("li",{children:[t("span",{class:"k-focus","aria-hidden":"true"}),u," and what is built on it, highlighted"]}),t("li",{children:[t("span",{class:"k-ring","aria-hidden":"true"}),"one orbit per generation"]}),t("li",{children:[t("span",{class:"k-size","aria-hidden":"true"}),"bigger planet, more downloads"]}),t("li",{children:[t("span",{class:"k-line","aria-hidden":"true"}),"line to the model it was made from"]})]}),f&&I&&f.total>0&&t("div",{class:"g-foot",children:[I.n-1<f.total&&t("p",{class:"muted",children:["Showing the ",N(I.n-1)," most downloaded of ",N(f.total)," models."]}),t("div",{class:"w-actions g-actions",children:[t("button",{class:"btn primary",disabled:K,onClick:async()=>{j(!0);try{const o=await $e(f,I,q?V:null),w=document.createElement("a");w.href=URL.createObjectURL(o),w.download=`${f.root.id.replace("/","_")}-galaxy.png`,w.click(),setTimeout(()=>URL.revokeObjectURL(w.href),2e3)}finally{j(!1)}},children:K?"Drawing…":"Download image"}),t("a",{class:"btn",target:"_blank",rel:"noopener",href:`https://x.com/intent/post?text=${encodeURIComponent(E)}&url=${encodeURIComponent(g)}`,children:"Post on X"}),t("a",{class:"btn",target:"_blank",rel:"noopener",href:`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(g)}`,children:"LinkedIn"}),t("button",{class:"btn",onClick:()=>{var o;return(o=navigator.clipboard)==null?void 0:o.writeText(g)},children:"Copy link"}),t(Ae,{})]})]})]}),f&&I&&f.total>0&&t("aside",{class:"o-panel",children:[t("div",{class:"g-find",children:[t("input",{value:H,onInput:o=>_(o.target.value),placeholder:"Find a model in this galaxy","aria-label":"Find a model in this galaxy",spellcheck:!1,onKeyDown:o=>{o.key==="Enter"&&$.length&&m($[0]),o.key==="Escape"&&_("")}}),$.length>0&&t("ul",{class:"g-found",children:$.map(o=>t("li",{children:t("button",{onClick:()=>m(o),children:[t("span",{children:f.nodes.id[o]}),t("small",{children:[de(f.nodes.dl30[o]),"/mo"]})]})},o))})]}),y>0&&t("div",{class:"o-sel",children:[t("button",{class:"x","aria-label":"Close",onClick:()=>S(-1),children:"×"}),t("a",{class:"id",href:ie({model:f.nodes.id[y]}),onClick:o=>{o.preventDefault(),oe({model:f.nodes.id[y]})},children:f.nodes.id[y]}),t("span",{class:"g-rel",children:[t("i",{style:{background:M(y).color}}),M(y).of," ",te(f.nodes.id[f.nodes.parent[y]]),", ",ue[I.depth[y]]," generation"]}),t("span",{class:"n",children:[t("b",{children:N(f.nodes.dl30[y])})," downloads in the last 30 days"]}),y===O&&q?a.total>0&&t("span",{class:"n",children:[t("b",{children:N(a.total)})," models built on it"]}):I.sub[y]>1&&t("span",{class:"n",children:[t("b",{children:N(I.sub[y]-1)})," models built on it"]}),t("div",{class:"acts",children:[t("a",{class:"btn primary",href:ie({model:f.nodes.id[y]}),onClick:o=>{o.preventDefault(),oe({model:f.nodes.id[y]})},children:"Download history"}),y===O&&q?a.total>0&&t("button",{class:"btn",onClick:()=>r(!1),children:"Only what is built on it"}):(I.sub[y]>1||q)&&t("a",{class:"btn",href:ie({view:"galaxy",model:f.nodes.id[y]}),onClick:o=>{o.preventDefault(),oe({view:"galaxy",model:f.nodes.id[y]})},children:q?"Focus on it":"Its own galaxy"})]})]}),t("section",{children:[t("h2",{children:"By kind"}),t("p",{class:"o-note",children:"All generations. Click to show or hide."}),t("div",{class:"o-kinds",role:"group","aria-label":"Show or hide kinds of derivatives",children:be.filter(o=>l[o]>0).map(o=>t("button",{"aria-pressed":!x[o],onClick:()=>v(x.map((w,k)=>k===o?!w:w)),children:[t("i",{style:{background:J[o].color}}),t("span",{children:J[o].label}),t("b",{children:N(l[o])}),t("span",{class:"share",children:t("span",{style:{width:`${l[o]/(I.n-1)*100}%`,background:J[o].color}})})]},o))}),t("p",{class:"o-gens",children:I.gens.slice(1).map((o,w)=>o?t("span",{children:[t("b",{children:N(o)})," ",ue[w+1]," generation"]},w):null)})]}),t("section",{children:[t("h2",{children:"Most downloaded"}),t("ol",{class:"o-top",children:W.map(o=>t("li",{children:t("button",{class:y===o?"on":"",onClick:()=>m(o),onMouseEnter:()=>B(o),onMouseLeave:()=>B(-1),onFocus:()=>B(o),onBlur:()=>B(-1),children:[t("i",{style:{background:M(o).color}}),t("span",{class:"nm",children:f.nodes.id[o]}),t("span",{class:"v",children:de(f.nodes.dl30[o])})]})},o))})]}),n.length>0&&t("section",{children:[t("h2",{children:"Who builds on it"}),t("ol",{class:"o-top",children:n.map(([o,w])=>t("li",{children:t("a",{href:ie({author:o}),onClick:k=>{k.preventDefault(),oe({author:o})},children:[t("span",{class:"nm",children:o}),t("span",{class:"v",children:[N(w.n)," ",w.n===1?"model":"models"]})]})},o))})]})]})]})]})}export{ze as Galaxy};