PageSourceSearch

https://rustrepo.com/_next/static/chunks/app/search/page-42421c092d4f9074.js

js rustrepo.com collected 2026-10-04 02:08:31 UTC 17,398 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[959],{6804:(e,r,t)=>{Promise.resolve().then(t.bind(t,8767))},8767:(e,r,t)=>{"use strict";t.d(r,{SearchPageClient:()=>y});var s=t(5155),o=t(2115),a=t(6046),n=t(8173),i=t.n(n),l=t(9659),d=t(3561),c=t(6835);let u=[{id:"active",name:"Active",color:"bg-green-500"},{id:"maintained",name:"Maintained",color:"bg-blue-500"},{id:"inactive",name:"Inactive",color:"bg-yellow-500"},{id:"archived",name:"Archived",color:"bg-red-500"}];function m(e){let{className:r}=e;return(0,s.jsx)("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function x(e){let{className:r}=e;return(0,s.jsx)("svg",{className:r,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})})}function h(e){let{className:r}=e;return(0,s.jsx)("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z"})})}function g(e){let{className:r}=e;return(0,s.jsx)("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})})}function p(e){let{className:r}=e;return(0,s.jsx)("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.75 19.5L8.25 12l7.5-7.5"})})}function v(e){let{className:r}=e;return(0,s.jsx)("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})})}function f(e){let{className:r}=e;return(0,s.jsx)("svg",{className:r,fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}function b(e){let{currentPage:r,totalPages:t,onPageChange:o}=e;return t<=1?null:(0,s.jsxs)("div",{className:"flex items-center justify-center gap-1",children:[(0,s.jsx)("button",{onClick:()=>o(r-1),disabled:1===r,className:"flex h-9 w-9 cursor-pointer items-center justify-center rounded-lg border border-border bg-surface text-foreground-muted transition-colors hover:bg-surface-overlay disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Previous page",children:(0,s.jsx)(p,{className:"h-4 w-4"})}),(()=>{let e=[];
1if(t>7){e.push(1),r>3&&e.push("...");let s=Math.max(2,r-1),o=Math.min(t-1,r+1);for(let r=s;r<=o;r++)e.push(r);r<t-2&&e.push("..."),e.push(t)}else for(let r=1;r<=t;r++)e.push(r);return e})().map((e,t)=>"..."===e?(0,s.jsx)("span",{className:"px-2 text-foreground-muted",children:"..."},"ellipsis-".concat(t)):(0,s.jsx)("button",{onClick:()=>o(e),className:"flex h-9 min-w-[36px] cursor-pointer items-center justify-center rounded-lg px-3 text-sm font-medium transition-colors ".concat(r===e?"bg-primary-500 text-white":"border border-border bg-surface text-foreground-muted hover:bg-surface-overlay"),children:e},e)),(0,s.jsx)("button",{onClick:()=>o(r+1),disabled:r===t,className:"flex h-9 w-9 cursor-pointer items-center justify-center rounded-lg border border-border bg-surface text-foreground-muted transition-colors hover:bg-surface-overlay disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Next page",children:(0,s.jsx)(v,{className:"h-4 w-4"})})]})}function j(e){var r,t,n,p,v,j;let{categories:y,allResources:N}=e,S=(0,a.useSearchParams)(),w=(0,a.useRouter)(),{addBookmark:k,removeBookmark:C,isBookmarked:L,addToComparison:M,removeFromComparison:z,isInComparison:A,preferences:B}=(0,c.g)(),P=(null==S?void 0:S.get("q"))||"",H=parseInt((null==S?void 0:S.get("page"))||"1"),V=(null==S?void 0:S.get("sort"))||"stars",[I,W]=(0,o.useState)(P),[E,R]=(0,o.useState)(H),[_,F]=(0,o.useState)(V),[T,q]=(0,o.useState)("grid"),[D,G]=(0,o.useState)((null==S?void 0:S.get("subcategory"))||""),[O,U]=(0,o.useState)({categories:(null==S?void 0:null===(r=S.get("category"))||void 0===r?void 0:r.split(",").filter(Boolean))||[],activityStatus:(null==S?void 0:null===(t=S.get("status"))||void 0===t?void 0:t.split(",").filter(Boolean))||[],minStars:(null==S?void 0:S.get("minStars"))?parseInt(S.get("minStars")):void 0,maxStars:(null==S?void 0:S.get("maxStars"))?parseInt(S.get("maxStars")):void 0}),[Z,J]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=(null==S?void 0:S.get("q"))||"",r=parseInt((null==S?void 0:S.get("page"))||"1"),t=(null==S?void 0:S.get("sort"))||"stars";e!==I&&W(e),r!==E&&R(r),t!==_&&F(t)},[S]);let K=(0,o.useMemo)(()=>{var e,r;let t=[...N];if(I.trim()){let e=I.toLowerCase();t=t.filter(r=>{var t;return r.name.toLowerCase().includes(e)||(null===(t=r.description)||void 0===t?void 0:t.toLowerCase().includes(e))||r.tags.some(r=>r.toLowerCase().includes(e))||r.category.toLowerCase().includes(e)})}switch((null===(e=O.categories)||void 0===e?void 0:e.length)&&(t=t.filter(e=>O.categories.includes(e.category))),D&&(t=t.filter(e=>e.subcategory.toLowerCase()===D.toLowerCase())),(null===(r=O.activityStatus)||void 0===r?void 0:r.length)&&(t=t.filter(e=>O.activityStatus.includes(e.activityStatus))),void 0!==O.minStars&&(t=t.filter(e=>{var r;return((null===(r=e.github)||void 0===r?void 0:r.stars)||0)>=O.minStars})),void 0!==O.maxStars&&(t=t.filter(e=>{var r;return((null===(r=e.github)||void 0===r?void 0:r.stars)||0)<=O.maxStars})),_){case"stars":t.sort((e,r)=>{var t,s;return((null===(t=r.github)||void 0===t?void 0:t.stars)||0)-((null===(s=e.github)||void 0===s?void 0:s.stars)||0)});break;case"recent":t.sort((e,r)=>{var t,s;return new Date((null===(t=r.github)||void 0===t?void 0:t.lastCommit)||0).getTime()-new Date((null===(s=e.github)||void 0===s?void 0:s.lastCommit)||0).getTime()});break;case"name":t.sort((e,r)=>e.name.localeCompare(r.name));break;case"trending":t.sort((e,r)=>(r.trendScore||0)-(e.trendScore||0))}return t},[N,I,O,_,D]),Q=Math.ceil(K.length/24),X=(0,o.useMemo)(()=>{let e=(E-1)*24;return K.slice(e,e+24)},[K,E]),Y=(0,o.useCallback)((e,r,t,s,o)=>{var a,n;let i=new URLSearchParams;e&&i.set("q",e),(null===(a=r.categories)||void 0===a?void 0:a.length)&&i.set("category",r.categories.join(",")),o&&i.set("subcategory",o),(null===(n=r.activityStatus)||void 0===n?void 0:n.length)&&i.set("status",r.activityStatus.join(",")),r.minStars&&i.set("minStars",r.minStars.toString()),r.maxStars&&i.set("maxStars",r.maxStars.toString()),t>1&&i.set("page",t.toString()),"stars"!==s&&i.set("sort",s),w.push("/search/?".concat(i.toString()),{scroll:!1})},[w]),$=(e,r)=>{let t={...O,[e]:r};U(t),R(1),Y(I,t,1,_,D)},ee=e=>{F(e),R(1),Y(I,O,1,e,D)},er=e=>{let r=O.categories||[];$("categories",r.includes(e)?r.filter(r=>r!==e):[...r,e])},et=e=>{let r=O.activityStatus||[];$("activityStatus",r.includes(e)?r.filter(r=>r!==e):[...r,e])},es=()=>{U({}),W(""),G(""),R(1),F("stars"),w.push("/search/")},eo=e=>{L(e)?C(e):k(e)},ea=e=>{A(e)?z(e):M(e)},en=((null===(n=O.categories)||void 0===n?void 0:n.length)||0)>0||((null===(p=O.activityStatus)||void 0===p?void 0:p.length)||0)>0||void 0!==O.minStars||void 0!==O.maxStars,ei=((null===(v=O.categories)||void 0===v?void 0:v.length)||0)+((null===(j=O.activityStatus)||void 0===j?void 0:j.length)||0)+(O.minStars?1:0)+(O.maxStars?1:0),el=(0,o.useMemo)(()=>[...y].sort((e,r)=>(r.resourceCount||0)-(e.resourceCount||0)),[y]);return(0,s.jsxs)(l.PE,{categories:y,showSidebar:!1,allResources:N,children:[(0,s.jsxs)("header",{className:"mb-6",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold text-foreground sm:text-3xl",children:"Search Resources"}),(0,s.jsxs)("p",{className:"mt-1 text-foreground-muted",children:["Explore ",N.length.toLocaleStr
1ing()," Rust libraries, tools, and applications"]})]}),(0,s.jsxs)("div",{className:"mb-6 space-y-4",children:[(0,s.jsx)("form",{onSubmit:e=>{e.preventDefault(),R(1),Y(I,O,1,_,D)},children:(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(m,{className:"absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-foreground-subtle"}),(0,s.jsx)("input",{type:"text",value:I,onChange:e=>W(e.target.value),placeholder:"Search by name, description, or tags...",className:"w-full rounded-xl border border-border bg-surface py-3 pl-12 pr-4 text-foreground placeholder:text-foreground-subtle focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20"}),I&&(0,s.jsx)("button",{type:"button",onClick:()=>{W(""),R(1),Y("",O,1,_,D)},className:"absolute right-3 top-1/2 -translate-y-1/2 cursor-pointer rounded-full p-1 text-foreground-subtle hover:bg-surface-overlay hover:text-foreground",children:(0,s.jsx)(f,{className:"h-4 w-4"})})]}),(0,s.jsx)("button",{type:"submit",className:"cursor-pointer rounded-xl bg-primary-500 px-6 py-3 font-medium text-white transition-colors hover:bg-primary-600",children:"Search"}),(0,s.jsxs)("button",{type:"button",onClick:()=>J(!Z),className:"flex cursor-pointer items-center gap-2 rounded-xl border px-4 py-3 transition-colors ".concat(en?"border-primary-500 bg-primary-500/10 text-primary-500":"border-border bg-surface text-foreground hover:border-primary-500/50"),children:[(0,s.jsx)(x,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Filters"}),ei>0&&(0,s.jsx)("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary-500 text-xs text-white",children:ei})]})]})}),Z&&(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-surface-elevated p-5",children:[(0,s.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,s.jsx)("h3",{className:"font-semibold text-foreground",children:"Filters"}),en&&(0,s.jsx)("button",{onClick:es,className:"cursor-pointer text-sm text-primary-500 hover:underline",children:"Clear all"})]}),(0,s.jsxs)("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-3 text-sm font-medium text-foreground",children:"Activity Status"}),(0,s.jsx)("div",{className:"space-y-2",children:u.map(e=>{var r;return(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:(null===(r=O.activityStatus)||void 0===r?void 0:r.includes(e.id))||!1,onChange:()=>et(e.id),className:"h-4 w-4 cursor-pointer rounded border-border text-primary-500 focus:ring-primary-500"}),(0,s.jsx)("span",{className:"h-2 w-2 rounded-full ".concat(e.color)}),(0,s.jsx)("span",{className:"text-sm text-foreground",children:e.name})]},e.id)})})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"mb-3 text-sm font-medium text-foreground",children:"GitHub Stars"}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"number",placeholder:"Min",value:O.minStars||"",onChange:e=>$("minStars",e.target.value?parseInt(e.target.value):void 0),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm text-foreground"}),(0,s.jsx)("span",{className:"text-foreground-muted",children:"-"}),(0,s.jsx)("input",{type:"number",placeholder:"Max",value:O.maxStars||"",onChange:e=>$("maxStars",e.target.value?parseInt(e.target.value):void 0),className:"w-full rounded-lg border border-border bg-surface px-3 py-2 text-sm text-foreground"})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:[100,1e3,5e3,1e4].map(e=>(0,s.jsx)("button",{onClick:()=>$("minStars",e),className:"cursor-pointer rounded-full px-2 py-0.5 text-xs transition-colors ".concat(O.minStars===e?"bg-primary-500 text-white":"bg-surface-overlay text-foreground-muted hover:text-foreground"),children:e>=1e3?"".concat(e/1e3,"k+"):"".concat(e,"+")},e))})]})]}),(0,s.jsxs)("div",{className:"sm:col-span-2",children:[(0,s.jsx)("h4",{className:"mb-3 text-sm font-medium text-foreground",children:"Categories"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2 max-h-40 overflow-y-auto",children:el.map(e=>{var r;return(0,s.jsxs)("button",{onClick:()=>er(e.id),className:"cursor-pointer rounded-full px-3 py-1 text-xs font-medium transition-colors ".concat((null===(r=O.categories)||void 0===r?void 0:r.includes(e.id))?"bg-primary-500 text-white":"bg-surface-overlay text-foreground-muted hover:bg-surface-overlay/80 hover:text-foreground"),children:[e.name," (",e.resourceCount||0,")"]},e.id)})})]})]})]})]}),(0,s.jsxs)("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)("p",{className:"text-sm text-foreground-muted",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:K.length.toLocaleStr
1ing()})," results",I&&(0,s.jsxs)(s.Fragment,{children:[' for "',(0,s.jsx)("span",{className:"font-medium text-foreground",children:I}),'"']}),E>1&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 Page ",E," of ",Q]})]}),D&&(0,s.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-primary-500/10 px-3 py-1 text-xs font-medium text-primary-500",children:["Subcategory: ",D,(0,s.jsx)("button",{onClick:()=>{G(""),Y(I,O,1,_,"")},className:"ml-1 cursor-pointer rounded-full p-0.5 hover:bg-primary-500/20",children:(0,s.jsx)(f,{className:"h-3 w-3"})})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm text-foreground-muted",children:"Sort:"}),(0,s.jsxs)("select",{value:_,onChange:e=>ee(e.target.value),className:"cursor-pointer rounded-lg border border-border bg-surface px-3 py-1.5 text-sm text-foreground",children:[(0,s.jsx)("option",{value:"stars",children:"Most Stars"}),(0,s.jsx)("option",{value:"trending",children:"Trending"}),(0,s.jsx)("option",{value:"recent",children:"Recently Updated"}),(0,s.jsx)("option",{value:"name",children:"Name A-Z"})]})]}),(0,s.jsxs)("div",{className:"flex rounded-lg border border-border bg-surface p-0.5",children:[(0,s.jsx)("button",{onClick:()=>q("grid"),className:"cursor-pointer rounded-md p-1.5 transition-colors ".concat("grid"===T?"bg-primary-500 text-white":"text-foreground-muted hover:text-foreground"),"aria-label":"Grid view",children:(0,s.jsx)(h,{className:"h-4 w-4"})}),(0,s.jsx)("button",{onClick:()=>q("list"),className:"cursor-pointer rounded-md p-1.5 transition-colors ".concat("list"===T?"bg-primary-500 text-white":"text-foreground-muted hover:text-foreground"),"aria-label":"List view",children:(0,s.jsx)(g,{className:"h-4 w-4"})})]})]})]}),X.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"grid"===T?"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4":"flex flex-col gap-3",children:X.map(e=>(0,s.jsx)(d.z,{resource:e,variant:"list"===T?"detailed":"compact",isBookmarked:L(e.id),isSelected:A(e.id),onBookmark:eo,onCompare:ea},e.id))}),(0,s.jsx)("div",{className:"mt-8",children:(0,s.jsx)(b,{currentPage:E,totalPages:Q,onPageChange:e=>{R(e),Y(I,O,e,_,D),window.scrollTo({top:0,behavior:"smooth"})}})})]}):(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-surface-elevated py-16 text-center",children:[(0,s.jsx)(m,{className:"mx-auto h-12 w-12 text-foreground-subtle"}),(0,s.jsx)("h3",{className:"mt-4 text-lg font-medium text-foreground",children:"No results found"}),(0,s.jsx)("p",{className:"mt-2 text-foreground-muted",children:I?'No resources match "'.concat(I,'"'):"Try adjusting your filters"}),(en||I)&&(0,s.jsx)("button",{onClick:es,className:"mt-4 cursor-pointer text-primary-500 hover:underline",children:"Clear all filters"})]}),B.comparisonList.length>0&&(0,s.jsx)("div",{className:"fixed bottom-6 right-6 z-50",children:(0,s.jsxs)(i(),{href:"/compare/?ids=".concat(B.comparisonList.join(",")),className:"flex cursor-pointer items-center gap-2 rounded-xl bg-primary-500 px-4 py-3 font-medium text-white shadow-lg transition-colors hover:bg-primary-600",children:["Compare (",B.comparisonList.length,")"]})})]})}function y(e){return(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)("div",{className:"flex min-h-screen items-center justify-center",children:(0,s.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary-500 border-t-transparent"})}),children:(0,s.jsx)(j,{...e})})}}},e=>{var r=r=>e(e.s=r);e.O(0,[173,659,835,561,441,517,358],()=>r(6804)),_N_E=e.O()}]);

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.