1import{b as v,a5 as w,r as m,j as e,h as N}from"./index-D43MT5hw.js";import{S as $,n as S}from"./SearchBox-D5Uu74eF.js";const k=()=>{const{domain:u}=v(),[x]=w(),c=x.get("query")||"",l=x.get("category")||"all",[o,i]=m.useState([]),[d,b]=m.useState(!1),g=s=>{const a=s.company?.domain,t=s.company?.domain_prefix;return a?t?`https://${t}.${a}/`:`https://${a}/`:null},f=(s,a)=>{if(!a||s==="#")return s;const t=s.includes("?")?"&":"?";return`${s}${t}title=${encodeURIComponent(a)}`},p=s=>s?.slug||s?.id,r=(s,a)=>{const t=s.endsWith("/")?s:`${s}/`,n=a.startsWith("/")?a.slice(1):a;return`${t}${n}`},j=s=>{const a=s?.raw??s,t=g(a);if(!t)return"#";const n=p(a);switch(a.module){case"news":return n?r(t,`news-detail/${n}`):r(t,"news-list");case"pages":return n?r(t,`pages-detail/${n}`):r(t,"pages");case"tenders":return r(t,"tenders");case"job_postings":return r(t,`job-detail/${n}`);case"cabinet_members":return r(t,"cabinet-member");case"employees":return r(t,"secretaries");case"contacts":return r(t,"contacts");case"codes":return n?r(t,`rules-regulation/${n}`):r(t,"rules_and_regulations");case"department_notifications":return n?r(t,`notifications/${n}`):r(t,"notifications");case"events":return r(t,"events");case"services":return r(t,"services");case"auctions":return r(t,"auctions");default:return"#"}},h=s=>s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),y=s=>{switch(s){case"news":return{accent:"bg-blue-600",badge:"bg-blue-50 text-blue-700 border-blue-100"};case"pages":return{accent:"bg-violet-600",badge:"bg-violet-50 text-violet-700 border-violet-100"};case"tenders":return{accent:"bg-amber-500",badge:"bg-amber-50 text-amber-700 border-amber-100"};case"job_postings":return{accent:"bg-emerald-600",badge:"bg-emerald-50 text-emerald-700 border-emerald-100"};case"cabinet_members":return{accent:"bg-rose-600",badge:"bg-rose-50 text-rose-700 border-rose-100"};case"employees":return{accent:"bg-cyan-600",badge:"bg-cyan-50 text-cyan-700 border-cyan-100"};case"contacts":return{accent:"bg-fuchsia-600",badge:"bg-fuchsia-50 text-fuchsia-700 border-fuchsia-100"};default:return{accent:"bg-slate-500",badge:"bg-slate-50 text-slate-700 border-slate-100"}}};return m.useEffect(()=>{(async()=>{if(!c.trim()){i([]);return}try{b(!0);const a=await N.getSearchInHome(u,c,l==="all"?void 0:l);i(S(a?.data||[]))}catch(a){console.error("Search fetch failed:",a),i([])}finally{b(!1)}})()},[c,l,u]),e.jsx("div",{className:"min-h-screen bg-slate-50",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8 md:px-6 lg:px-8",children:[e.jsx("div",{className:"mb-6 rounded-2xl border border-slate-200 bg-white px-6 py-5 shadow-sm",children:e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-end md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-slate-900",children:"Search Results"}),e.jsxs("p",{className:"mt-1 text-sm text-slate-600",children:["Results for"," ",e.jsxs("span",{className:"font-semibold text-slate-900",children:['"',c,'"']}),l!=="all"&&e.jsxs(e.Fragment,{children:[" ","in"," ",e.jsx("span",{className:"font-semibold text-slate-900",children:h(l)})]})]})]}),!d&&e.jsxs("div",{className:"inline-flex w-fit items-center rounded-full border border-slate-200 bg-slate-50 px-3 py-1.5 text-sm font-medium text-slate-700",children:[o.length," result",o.length!==1?"s":""]})]})}),e.jsx("div",{className:"mb-4",children:e.jsx($,{defaultQuery:c,defaultCategory:l,className:"mb-8",width:""})}),d&&e.jsx("div",{className:"space-y-4",children:[...Array(5)].map((s,a)=>e.jsx("div",{className:"rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"mb-3 h-4 w-24 rounded bg-slate-200"}),e.jsx("div",{className:"mb-2 h-5 w-2/3 rounded bg-slate-200"}),e.jsx("div",{className:"h-4 w-1/3 rounded bg-slate-100"})]})},a))}),!d&&o.length===0&&e.jsxs("div",{className:"rounded-2xl border border-dashed border-slate-300 bg-white px-6 py-14 text-center",children:[e.jsx("div",{className:"mx-auto mb-3 flex h-12 w-12 items-center justify-center rounded-full bg-slate-100 text-slate-500",children:"ð"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-900",children:"No results found"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Try a different keyword or change the category."})]}),!d&&o.length>0&&e.jsx("div",{className:"space-y-4",children:o.map((s,a)=>{const t=f(j(s),s.title),n=y(s.module);return e.jsxs("div",{className:"group relative overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm transition hover:border-slate-300 hover:shadow-md",children:[e.jsx("div",{className:`absolute left-0 top-0 h-full w-1 ${n.accent}`}),e.jsxs("div",{className:"flex flex-col gap-4 p-5 md:flex-row md:items-center md:justify-between md:pl-6",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:e.jsx("span",{className:`inline-flex rounded-full border px-2.5 py-1 text-xs font-medium ${n.badge}`,children:h(s.module)})}),e.jsx("h2",{className:"text-lg font-semibold text-slate-900 transition-colors group-hover:text-slate-700",children:s.title}),s.companyTitle&&e.jsxs("p",{className:"mt-1 text-sm text-slate-500",children:["Department:"," ",e.jsx("span",{className:"font-medium text-slate-700",children:s.companyTitle})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-3",children:e.jsx("button",{onClick:()=>{window.open(t,"_blank","noopener,noreferrer")},className:"inline-flex items-center rounded-xl bg-slate-900 px-4 py-2 text-sm font-medium text-white transition hover:bg-slate-800",children:"View"})})]})]},`${s.module}-${s.slug||s.title}-${a}`)})})]})})};export{k 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.