import{$ as e,C as t,D as n,E as ee,I as r,J as i,L as a,O as o,S as s,U as c,W as l,X as u,Z as d,_ as f,b as p,et as m,g as h,m as g,p as _,q as v,r as y,v as b,w as x,x as S}from"./app-CY2j0yOT.js";import{t as C}from"./i18n-Dq60tUKI.js";import{t as w}from"./AppLayout-BH1wkM30.js";import{t as T}from"./EmptyState-CWbxH8t8.js";import{t as E}from"./TopicCard-CeO7Os5R.js";var D={class:`mx-auto max-w-3xl`},O={class:`mb-4 text-2xl font-extrabold tracking-tight`},k=[`placeholder`],A={type:`submit`,class:`rounded-c bg-primary px-5 py-2.5 text-sm font-semibold text-white hover:bg-primary-600`},j={class:`mt-3 flex flex-wrap items-center gap-2`},M={value:``},N=[`value`],P=[`placeholder`],F={value:`all`},I={value:`week`},L={value:`month`},R={value:`year`},z={value:`relevance`},B={value:`recent`},V={value:`replies`},H={key:0,class:`mt-3 text-sm text-ink-muted`},U={key:0},W={key:1,class:`ml-1 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-bold text-primary`},G={key:1,class:`mt-5 space-y-3`},K={key:3,class:`mt-10 text-center text-ink-muted`},q=`rounded-lg border-line bg-surface-2 text-sm text-ink focus:border-primary focus:ring-primary`,J=o({__name:`Search`,props:{q:{},results:{},mode:{},filters:{},categories:{}},setup(o){let J=o,Y=i(J.q),X=v({...J.filters});function Z(){let e={q:Y.value.trim()};X.category&&(e.category=X.category),X.author.trim()&&(e.author=X.author.trim()),X.when&&X.when!==`all`&&(e.when=X.when),X.sort&&X.sort!==`relevance`&&(e.sort=X.sort),m.get(`/search`,e,{preserveState:!0,preserveScroll:!0})}function Q(){X.category=``,X.author=``,X.when=`all`,X.sort=`relevance`,Z()}let $=p(()=>+!!X.category+ +!!X.author.trim()+(X.when===`all`?0:1));return(i,p)=>(r(),x(b,null,[n(u(y),{title:o.q?u(C)(`Search: {q}`,{q:o.q}):u(C)(`Search`)},null,8,[`title`]),n(w,null,{default:c(()=>[S(`div`,D,[S(`h1`,O,e(u(C)(`Search`)),1),S(`form`,{class:`flex gap-2`,onSubmit:f(Z,[`prevent`])},[l(S(`input`,{"onUpdate:modelValue":p[0]||=e=>Y.value=e,type:`search`,autofocus:``,placeholder:u(C)(`Search the community…`),class:`flex-1 rounded-c border-line bg-surface-2 text-ink placeholder:text-ink-muted focus:border-primary focus:ring-primary`},null,8,k),[[g,Y.value]]),S(`button`,A,e(u(C)(`Search`)),1)],32),S(`div`,j,[l(S(`select`,{"onUpdate:modelValue":p[1]||=e=>X.category=e,class:d(q),onChange:Z},[S(`option`,M,e(u(C)(`All categories`)),1),(r(!0),x(b,null,a(o.categories,t=>(r(),x(`option`,{key:t.slug,value:t.slug},e(t.name),9,N))),128))],544),[[_,X.category]]),l(S(`input`,{"onUpdate:modelValue":p[2]||=e=>X.author=e,type:`text`,placeholder:u(C)(`Author`),class:d([q,`w-36`]),onKeyup:h(Z,[`enter`])},null,40,P),[[g,X.author]]),l(S(`select`,{"onUpdate:modelValue":p[3]||=e=>X.when=e,class:d(q),onChange:Z},[S(`option`,F,e(u(C)(`Any time`)),1),S(`option`,I,e(u(C)(`Past week`)),1),S(`option`,L,e(u(C)(`Past month`)),1),S(`option`,R,e(u(C)(`Past year`)),1)],544),[[_,X.when]]),l(S(`select`,{"onUpdate:modelValue":p[4]||=e=>X.sort=e,class:d(q),onChange:Z},[S(`option`,z,e(u(C)(`Relevance`)),1),S(`option`,B,e(u(C)(`Newest`)),1),S(`option`,V,e(u(C)(`Most replies`)),1)],544),[[_,X.sort]]),$.value||X.sort!==`relevance`?(r(),x(`button`,{key:0,type:`button`,class:`text-sm font-semibold text-ink-2 hover:text-ink`,onClick:Q},e(u(C)(`Clear`)),1)):t(``,!0)]),o.q||$.value?(r(),x(`p`,H,[ee(e(o.results.length===1?u(C)(`{n} result`,{n:o.results.length}):u(C)(`{n} results`,{n:o.results.length}))+` `,1),o.q?(r(),x(`span`,U,e(u(C)(`for “{q}”`,{q:o.q})),1)):t(``,!0),o.q&&o.mode===`semantic`?(r(),x(`span`,W,e(u(C)(`✦ semantic`)),1)):t(``,!0)])):t(``,!0),o.results.length?(r(),x(`div`,G,[(r(!0),x(b,null,a(o.results,e=>(r(),s(E,{key:e.id,topic:e},null,8,[`topic`]))),128))])):o.q||$.value?(r(),s(T,{key:2,class:`mt-10`,title:u(C)(`No matching discussions`),body:u(C)(`Try different words or relax your filters — or start a new topic and let the community (and the assistant) help.`)},null,8,[`title`,`body`])):(r(),x(`p`,K,e(u(C)(`Type a question or a few keywords — or filter by category, author and date — to search every discussion.`)),1))])]),_:1})],64))}});export{J as default};