1import{j as e,ax as K,r,t as E,ay as O,az as F,v as M,aA as W,aB as X,_ as S,a5 as T,a6 as _,aC as J,P as V,I as Z,a as ee,T as w,M as te,m as se,B as L,X as oe,aD as re,U as ae,C as P,aE as ne,aF as ce,aG as le,V as ie,aH as ue,c as me,an as de}from"./index-DGomepWC.js";import{P as fe,a as he,b as pe}from"./post-DsRXleM8.js";import{P as k,a as xe,H as ge}from"./lemmy-sort-K2txraIi.js";import{P as be}from"./page-title-BNX8VxUJ.js";import{S as Se}from"./sticky-filter-bar-B2TvT5SZ.js";import{S as je}from"./search-bar-TRXcUReb.js";import{u as Pe}from"./use-reduced-motion-BYZIowLO.js";import{u as ye}from"./use-pagination-DsUI0ev7.js";import{N as Ne}from"./no-posts-message-Ctdq39pt.js";import"./index-BjBZgwZU.js";import"./progressive-image-B2oSGI7T.js";import"./nsfw-revealed-posts-DsvRbQpW.js";import"./community-sidebar-DtDR1A9p.js";import"./hooks-Btm-G8gV.js";import"./EasterEggBox-D5kmZdE_.js";import"./post-buttons-CffSRobK.js";import"./index-lj7FE3e9.js";import"./remove-md-_dnXZpEl.js";import"./person-avatar-Du35AwtW.js";function Ce(){return e.jsxs(Se,{className:"max-md:hidden",children:[e.jsx(k,{align:"start",variant:"button"}),e.jsx(xe,{align:"start",variant:"button"})]})}const Re=r.memo(s=>e.jsxs(P,{className:"px-0",children:[e.jsx(pe,{...s,featuredContext:"home"}),e.jsx(e.Fragment,{})]}));function Be(s,a){var d,x;const n=r.useRef(null),c=r.useRef(0),l=r.useRef(0),{tabBar:i,header:o,toolbar:u,newPostButton:m}=r.useMemo(()=>{const g=document.querySelector("ion-tab-bar"),f=document.querySelector("ion-header.dismissable"),h=document.querySelector("ion-toolbar.dismissable"),p=document.querySelector(".new-post-button");return{tabBar:g,header:f,toolbar:h,newPostButton:p}},[a]),y=r.useCallback(g=>{if(n.current===null||!a)return;const f=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--ion-safe-area-top").trim(),10);if(o&&u&&i&&m){const h=S.isNumber(f)?o.offsetHeight-f:o.offsetHeight,p=Math.max(g.currentTarget.scrollTop,0),b=p-n.current;n.current=p,c.current=S.clamp(c.current+b/h,0,1),l.current=S.clamp(c.current+b/i.offsetHeight,0,1),o.style.transform="translate(0, -".concat(c.current*h,"px)"),u.style.opacity=String(1-c.current),i.style.transform="translate(0, ".concat(l.current*100,"%)"),m.style.opacity=String(1-c.current)}},[a,o,u,i,m]),j=r.useRef((d=s==null?void 0:s.scrollTop)!=null?d:0);return j.current=(x=s==null?void 0:s.scrollTop)!=null?x:0,r.useEffect(()=>{a?n.current=j.current:(n.current=0,c.current=0,l.current=0,o&&i&&u&&m&&(o.style.transform="translate(0)",u.style.opacity="1",i.style.transform="translate(0)",m.style.opacity="1"))},[a,i,o,u,m]),{scrollHandler:y}}function Ae(){const s=de("/home"),[a,n]=r.useState(!1);return r.useEffect(()=>{if(s)n(!1);else{const c=S.debounce(()=>{n(!0)},100);return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)}},[s]),a}function He({children:s}){const a=Ae(),n=E();return e.jsx(me,{scrollY:a,fullscreen:n.maxMd,children:s})}function We(){var A;const s=K(),[a,n]=r.useState(""),c=E(),{postSort:l,suggestedPostSort:i}=O(),o=F(t=>t.listingType),u=F(t=>t.setPostSort),m=M(t=>t.paginationMode),j=M(t=>t.hideSubscribedFromLocalAll)&&(o==="Local"||o==="All"),d=W({sort:l,type:o}),x=X("local",{sort:l,type:o},d),{hasNextPage:g,fetchNextPage:f,isFetchingNextPage:h,isRefetching:p}=d,b=()=>Promise.all([d.refetch(),x.refetch()]),{flatData:N,onEndReached:q,paginationControls:z}=ye({pages:(A=d.data)==null?void 0:A.pages,getItems:t=>t.posts,fetchNextPage:f,hasNextPage:g,isFetchingNextPage:h,mode:m,listKey:l+o}),C=r.useMemo(()=>S.uniq(N),[N]),R=x.data,v=T(t=>t.getCachePrefixer),Y=T(t=>{var H,I;return((I=(H=_(t.getSelectedAccount()))==null?void 0:H.postCount)!=null?I:0)>0}),D=J(t=>R?!(v()(R)in t.posts):!1),B=r.useRef(null),[Q,U]=r.useState(!1),$=Pe(),G=Be(B.current,Q&&c.maxMd&&!$);return e.jsxs(V,{className:"home-page",children:[e.jsx(be,{}),e.jsxs(Z,{className:"backdrop-blur-xs bg-gradient-to-b from-20% from-background to-background/30 dismissable",children:[e.jsxs(ee,{"data-tauri-drag-region":!0,className:"dismissable",children:[e.jsxs(w,{side:"left",children:[e.jsx(te,{}),e.jsx(ge,{})]}),e.jsx(je,{onValueChange:n,value:a,onSubmit:t=>{s.push(se("/home/s","?q=".concat(t!=null?t:a)))},className:"max-md:hidden","data-testid":"home-search-bar"}),e.jsxs(w,{side:"right",children:[e.jsx(L,{size:"icon",variant:"ghost",asChild:!0,children:e.jsx(oe,{to:"/home/s",className:"text-muted-foreground md:hidden","data-testid":"home-search-link",children:e.jsx(re,{className:"text-2xl"})})}),e.jsx(k,{align:"end",className:"md:hidden"}),e.jsx(ae,{})]})]}),e.jsxs(P,{className:"absolute mt-2 inset-x-0 new-post-button",children:[e.jsx("div",{className:"flex flex-row justify-center flex-1",children:D&&e.jsxs(L,{variant:"outline",size:"sm",className:"absolute",onClick:()=>{b(),le("/home/")},children:["New posts",p?e.jsx(ne,{className:"animate-spin"}):e.jsx(ce,{})]})}),e.jsx(e.Fragment,{})]})]}),e.jsxs(He,{children:[e.jsx(fe,{children:e.jsx(ie,{listKey:l+o,onFocusChange:U,ref:B,estimatedItemSize:450,data:C,placeholder:e.jsxs(P,{className:"px-0",children:[e.jsx(he,{}),e.jsx(e.Fragment,{})]}),header:[e.jsx(Ce,{},"header")],noItems:C.length===0&&!d.isFetching,noItemsComponent:e.jsx(Ne,{postSort:l,suggestedPostSort:i,setPostSort:u,showSortHint:Y}),paginationControls:z,renderItem:({item:t})=>e.jsx(Re,{apId:t,hideIfSubscribed:j},t),scrollHost:!0,fullscreen:!0,onEndReached:q,onScroll:G.scrollHandler,refresh:b})}),e.jsxs(P,{className:"max-md:hidden absolute top-0 right-0 left-0",children:[e.jsx("div",{className:"flex-1"}),e.jsx(ue,{})]})]})]})}export{We as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.