PageSourceSearch

https://www.alleba.com/assets/category-view-i9pxD7yx.js

js alleba.com collected 2026-10-02 02:36:47 UTC 16,721 bytes, 1 lines download raw bytes

1import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-Biaal4sZ.js";import{n,t as r}from"./createServerFn-Bk23-1SV.js";import{t as i}from"./link-C4uCqMsc.js";import{t as a}from"./jsx-runtime-By8HlURe.js";import{t as o}from"./auth-middleware-JDjVgB0Q.js";import{n as s}from"./client-BCY0Revy.js";import{t as c}from"./useQuery-Bk0o1c0V.js";import{t as l}from"./search-gisWYDL1.js";import{t as u}from"./useIsAdmin-BTpL-uBn.js";import{t as d}from"./input-Biu6TUDg.js";import{t as f}from"./heritage-credit-C3FM7Gfu.js";var p=e(t(),1),m=r({method:`POST`}).handler(n(`81478c4a8eb15a0f7ddfb4ef72510e3ae5f337d8389792513d37280fe2f55068`)),h=r({method:`POST`}).middleware([o]).handler(n(`49f451add4de5f27529c330d47d73210130f199d18954a7ef7a0bcca72f74feb`)),g=1800*1e3,_=`alleba:searchlog`;function v(){if(typeof window>`u`)return{};try{let e=window.sessionStorage.getItem(_);return e?JSON.parse(e):{}}catch{return{}}}function y(e){let t=e.trim().toLowerCase().replace(/\s+/g,` `);if(!t||typeof window>`u`)return!1;let n=Date.now(),r=v(),i={};for(let[e,t]of Object.entries(r))n-t<g&&(i[e]=t);if(i[t])return!1;i[t]=n;try{window.sessionStorage.setItem(_,JSON.stringify(i))}catch{}return!0}var b=new Set([`the`,`of`,`in`,`a`,`an`,`for`,`and`,`or`,`to`,`on`,`at`,`is`,`are`,`where`,`what`,`who`,`how`]);function x(e){return e.replace(/[,()%]/g,` `).replace(/\s+/g,` `).trim()}function S(e){let t=e.replace(/(ies|es|s)$/i,``);return t.length>=3?t:e}function C(e){let t=x(e).toLowerCase();if(!t)return[];let n=t.split(` `).filter(Boolean),r=n.filter(e=>!b.has(e)),i=r.length>0?r:n,a=[];for(let e of i){let t=S(e);t.length>=2&&!a.includes(t)&&a.push(t)}return a.slice(0,6)}function w(e){return`title.ilike.%${e}%,description.ilike.%${e}%,keywords.ilike.%${e}%,url.ilike.%${e}%`}function T(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return RegExp(`(^|[^a-z0-9])${t}(s|es|ies)?([^a-z0-9]|$)`,`i`)}function E(e,t,n){let r=x(t).toLowerCase(),i=n.map(T),a=e=>{let t=(e.title??``).toLowerCase(),a=(e.description??``).toLowerCase(),o=(e.url??``).toLowerCase(),s=0;r&&t.includes(r)&&(s+=100);for(let e=0;e<n.length;e++){let r=n[e],c=i[e];c.test(t)?s+=10:c.test(a)?s+=4:c.test(o)?s+=2:t.includes(r)?s+=3:a.includes(r)?s+=1:o.includes(r)&&(s+=.5)}let c=t.replace(/[^a-z0-9\s]/g,` `).split(/\s+/).filter(Boolean),l=c.filter(e=>!i.some(t=>t.test(e))).length;return c.length>0&&(s+=8/(1+l)),s};return e.map((e,t)=>({r:e,i:t,s:a(e)})).sort((e,t)=>t.s-e.s||(t.r.hits??0)-(e.r.hits??0)||e.i-t.i).map(e=>e.r)}var D=a(),O=20;function k(e){return e.split(`/`).map(e=>e.trim().replace(/\s+/g,`_`).replace(/[^A-Za-z0-9_-]/g,``)).filter(Boolean).join(`/`)}function A(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e.replace(/^https?:\/\//,``).split(`/`)[0]??e}}function j({onTermChange:e}){let[t,n]=(0,p.useState)(``);return(0,p.useEffect)(()=>{let n=setTimeout(()=>{e(t.trim())},300);return()=>clearTimeout(n)},[t,e]),(0,D.jsxs)(`div`,{className:`relative w-full sm:max-w-sm`,children:[(0,D.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":!0}),(0,D.jsx)(d,{id:`cat-search`,type:`search`,value:t,onChange:e=>n(e.target.value),placeholder:`Search sites in this category…`,"aria-label":`Filter sites in this category`,className:`pl-9`})]})}function M({term:e,category:t,related:n}){let[r,a]=(0,p.useState)(1),o=(0,p.useRef)(null),l=(0,p.useMemo)(()=>[t,...n].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),[t,n]),d=l.map(e=>e.id).sort().join(`,`),{data:f}=c({queryKey:[`dir-cat-scope`,d],staleTime:30*6e4,enabled:e.length>=3,queryFn:async()=>{let e=new Set(l.map(e=>e.id)),t=new Map;for(let n of l){let{data:r}=await s.from(`directory_categories`).select(`id, full_name`).like(`full_name`,`${n.full_name}/%`).limit(2e3);for(let n of r??[])e.add(n.id),t.set(n.id,n.full_name)}for(let e of l)t.set(e.id,e.full_name);return{ids:[...e],names:t}}}),{data:h,isFetching:g}=c({queryKey:[`dir-cat-search`,d,e.toLowerCase()],staleTime:5*6e4,enabled:e.length>=3&&!!f,queryFn:async()=>{let t=C(e);if(t.length===0||!f)return[];let n=f.ids,r=new Map;for(let e=0;e<n.length;e+=100){let t=n.slice(e,e+100);for(let e=0;;e+=1e3){let{data:n,error:i}=await s.from(`directory_link_categories`).select(`category_id, link_id`).in(`category_id`,t).range(e,e+999);if(i)throw i;let a=n??[];
1for(let e of a)r.has(e.link_id)||r.set(e.link_id,e.category_id);if(a.length<1e3)break}}if(r.size===0)return[];let i=new Map,a=[...r.keys()];for(let e=0;e<a.length;e+=100){let n=a.slice(e,e+100),o=s.from(`directory_links`).select(`id, title, url, description, hits`).in(`id`,n).eq(`status`,`approved`).eq(`is_dead`,!1);for(let e of t)o=o.or(w(e));let{data:c,error:l}=await o.limit(200);if(l)throw l;for(let e of c??[])i.has(e.id)||i.set(e.id,{...e,from:f.names.get(r.get(e.id)??``)??``})}return E([...i.values()],e,t).slice(0,200)}}),{isAdmin:_,isLinkManager:v}=u(),b=_||v;(0,p.useEffect)(()=>{if(e.length<3||!h||b)return;let n=setTimeout(()=>{let n=`[${t.full_name}] ${e}`.slice(0,120);y(n)&&m({data:{query:n,resultsCount:h.length}}).catch(()=>{})},1200);return()=>clearTimeout(n)},[e,h,t.full_name,b]),(0,p.useEffect)(()=>{a(1)},[e]);let x=h?.length??0,S=Math.max(1,Math.ceil(x/O)),T=Math.min(r,S),j=(T-1)*O,M=(h??[]).slice(j,j+O);function N(e){a(Math.min(Math.max(1,e),S));let t=o.current;t&&requestAnimationFrame(()=>{let e=t.getBoundingClientRect().top+window.scrollY-96;window.scrollY>e&&window.scrollTo({top:e,behavior:`instant`})})}return e.length<3?null:(0,D.jsx)(`section`,{ref:o,className:`mt-6 max-w-2xl scroll-mt-24 pt-6`,children:g&&!h?(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Searching…`}):h&&h.length>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`p`,{className:`label-mono text-muted-foreground`,children:S>1?`Showing ${j+1}–${Math.min(j+O,x)} of ${x} matches in the category`:`${x} ${x===1?`match`:`matches`} in the category`}),(0,D.jsx)(`ul`,{className:`mt-4 divide-y divide-border/60`,children:M.map(e=>(0,D.jsxs)(`li`,{className:`py-4`,children:[(0,D.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`font-semibold text-primary underline underline-offset-2`,children:e.title}),e.description?(0,D.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-foreground/80`,children:e.description}):null,(0,D.jsxs)(`p`,{className:`label-mono mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-muted-foreground`,children:[(0,D.jsx)(`span`,{className:`truncate`,children:A(e.url)}),e.from?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,D.jsx)(i,{to:`/$`,params:{_splat:`${k(e.from)}/`},className:`truncate hover:text-primary hover:underline`,children:e.from.split(`/`).slice(-2).join(` › `)}
1)]}):null]})]},e.id))}),S>1?(0,D.jsxs)(`nav`,{"aria-label":`Search results pages`,className:`mt-5 flex flex-wrap items-center justify-between gap-3 border-t border-border pt-4`,children:[(0,D.jsxs)(`p`,{className:`label-mono text-muted-foreground`,children:[`Showing `,j+1,`–`,Math.min(j+O,x),` of `,x]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsx)(`button`,{type:`button`,onClick:()=>N(T-1),disabled:T===1,className:`rounded-md border border-border px-2 py-1 text-xs disabled:opacity-40`,children:`Previous`}),Array.from({length:S},(e,t)=>t+1).map(e=>(0,D.jsx)(`button`,{type:`button`,onClick:()=>N(e),"aria-current":e===T?`page`:void 0,className:e===T?`rounded-md border border-primary bg-primary px-2 py-1 text-xs text-primary-foreground`:`rounded-md border border-border px-2 py-1 text-xs hover:border-primary`,children:e},e)),(0,D.jsx)(`button`,{type:`button`,onClick:()=>N(T+1),disabled:T===S,className:`rounded-md border border-border px-2 py-1 text-xs disabled:opacity-40`,children:`Next`})]})]}):null]}):(0,D.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No sites in this category match that.`,` `,(0,D.jsx)(i,{to:`/dir.html`,search:{q:e},className:`text-primary underline`,children:`Search all of Alleba`}),`.`]})})}function N(e){return e.split(`/`).map(e=>e.trim().replace(/\s+/g,`_`).replace(/[^A-Za-z0-9_-]/g,``)).filter(Boolean).join(`/`)}function P(e){return`${e.replace(/\/+$/,``)}/`}function F({category:e,className:t,title:n,children:r}){return(0,D.jsx)(i,{to:`/$`,params:{_splat:P(e.legacy_path||N(e.full_name))},className:t,title:n,children:r})}function I(e,t){let n=e.split(`/`).map(e=>e.trim()).filter(Boolean),r=new Set(t.split(`/`).map(e=>e.trim().toLowerCase()).filter(Boolean));for(let e=n.length-1;e>=0;e--){let t=n[e];if(!r.has(t.toLowerCase()))return t}return n[n.length-1]??e}function L({legacyPath:e}){let t=e.replace(/\/+$/,``),[n,r]=(0,p.useState)(``),a=n.length>=3,{data:o,isLoading:l}=c({queryKey:[`dir-category-legacy`,t.toLowerCase()],staleTime:30*6e4,gcTime:60*6e4,queryFn:async()=>{let{data:e,error:n}=await s.from(`directory_categories`).select(`id, name, full_name, slug, legacy_path, link_count, ai_summary, ai_summary_generated_at`).ilike(`legacy_path`,t).maybeSingle();if(n)throw n;if(!e)return null;let r=[],i=1e3;for(let t=0;t<10;t++){let{data:n,error:a}=await s.from(`directory_categories`).select(`id, name, full_name, slug, legacy_path, parent_id, link_count, is_pinned`).like(`full_name`,`${e.full_name}/%`).order(`full_name`).range(t*i,t*i+i-1);if(a)throw a;if(r.push(...n??[]),(n??[]).length<i)break}let{data:a}=await s.from(`directory_link_categories`).select(`directory_links(id, title, url, description, hits, is_dead, status, last_checked_at)`).eq(`category_id`,e.id).limit(300),o=r,c=o.filter(t=>t.parent_id===e.id).map(e=>({...e,has_kids:o.some(t=>t.parent_id===e.id),link_count:o.filter(t=>t.full_name===e.full_name||t.full_name.startsWith(`${e.full_name}/`)).reduce((e,t)=>e+(t.link_count??0),0)})).sort((e,t)=>e.name.localeCompare(t.name)),{data:l}=await s.from(`directory_category_relations`).select(`category_id, label, related:directory_categories!directory_category_relations_related_id_fkey(id, name, slug, full_name, legacy_path, link_count)`).in(`category_id`,[e.id,...c.map(e=>e.id)]).limit(2e3),u=l??[],d=u.filter(t=>t.category_id===e.id&&t.related).map(e=>({...e.related,rel_label:e.label})).sort((e,t)=>e.full_name.localeCompare(t.full_name)),f=new Set(c.filter(e=>/^[A-Za-z0-9]$/.test(e.name.trim())||/^(complete category listing|most popular)$/i.test(e.name.trim())).map(e=>e.id)),p=new Set(u.filter(e=>f.has(e.category_id)&&e.related).map(e=>e.related.id));c=c.filter(e=>!p.has(e.id)).map(e=>{if(e.link_count>0)return e;let t=u.filter(t=>t.category_id===e.id&&t.related);return t.length===0?e:{...e,link_count:t.reduce((e,t)=>e+(t.related.link_count??0),0)}});let m=(a??[]).map(e=>e.directory_links).filter(e=>e&&e.status===`approved`&&!e.is_dead).sort((e,t)=>(t.hits??0)-(e.hits??0));return{cat:e,subs:c,related:d,links:m}}}),u=t?t.split(`/`).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),label:e.replace(/_/g,` `)})):[];return(0,D.jsxs)(`main`,{className:`mx-auto max-w-5xl px-4 py-14`,children:[(0,D.jsxs)(`nav`,{className:`label-mono text-muted-foreground`,children:[(0,D.jsx)(i,{to:`/dir.html`,className:`hover:text-primary`,children:`Directory`}),u.map(e=>(0,D.jsxs)(`span`,{children:[` / `,(0,D.jsx)(i,{to:`/$`,params:{_splat:P(e.path)},className:`hover:text-primary`,children:e.label})]},e.path))]}),l?(0,D.jsx)(`p`,{className:`mt-10 text-muted-foreground`,children:`Loading…`}):o?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`h1`,{className:`mt-2 text-4xl font-extrabold`,children:o.cat.name}),(0,D.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:o.cat.full_name}),o.cat.ai_summary?(0,D.jsxs)(`div`,{className:`mt-8 border-l-2 border-border pl-6`,children:[(0,D.jsx)(`p`,{className:`text-base leading-relaxed text-foreground
1/80 italic`,children:o.cat.ai_summary}),(0,D.jsxs)(`p`,{className:`label-mono mt-4 text-muted-foreground`,children:[o.cat.ai_summary_generated_at?`Updated ${new Date(o.cat.ai_summary_generated_at).toLocaleDateString(`en-PH`,{month:`short`,year:`numeric`})} — `:null,`curated and reviewed by our editors`]})]}):null,o.cat.full_name===`Government`?(0,D.jsxs)(`div`,{className:`mt-8 rounded-xl border border-accent/40 bg-accent/5 p-5`,children:[(0,D.jsx)(`p`,{className:`label-mono text-primary`,children:`Official services`}),(0,D.jsx)(`h2`,{className:`mt-1 text-xl font-bold`,children:(0,D.jsx)(i,{to:`/$`,params:{_splat:P(`Government/Citizen_Services`)},className:`text-primary underline underline-offset-2`,children:`Citizen Services`})}),(0,D.jsx)(`p`,{className:`mt-2 text-sm text-foreground/80`,children:`Direct links to the government portals Filipinos use most — passport, PSA, national ID, NBI, SSS, PhilHealth, Pag-IBIG, BIR, LTO and more.`})]}):null,(0,D.jsx)(`div`,{className:`rule-double mt-8 pt-4`,children:(0,D.jsx)(`div`,{className:`flex justify-start`,children:(0,D.jsx)(`div`,{className:`w-full sm:max-w-xs`,children:(0,D.jsx)(j,{onTermChange:r})})})}),a?null:(0,D.jsx)(D.Fragment,{children:(()=>{let e=e=>/^[A-Za-z0-9]$/.test(e.trim())||/^0-9$/i.test(e.trim()),t=e=>/^(complete category listing|most popular)$/i.test(e.trim()),n=o.subs.filter(t=>e(t.name)).sort((e,t)=>(e.name.trim()===`0-9`?``:e.name).localeCompare(t.name.trim()===`0-9`?``:t.name)),r=o.subs.filter(e=>t(e.name)),i=o.subs.filter(n=>!e(n.name)&&!t(n.name));return(0,D.jsxs)(D.Fragment,{children:[n.length>0||r.length>0?(0,D.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-x-3 gap-y-2 text-sm`,children:[n.map(e=>(0,D.jsx)(F,{category:e,className:`font-semibold uppercase hover:text-primary`,title:`${e.link_count} links`,children:e.name},e.id)),r.map((e,t)=>(0,D.jsxs)(`span`,{className:`flex items-center gap-3`,children:[t>0?(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:`|`}):null,(0,D.jsx)(F,{category:e,className:`font-medium hover:text-primary`,children:e.name})]},e.id))]}):null,(()=>{let e=new Set([`Executive Branch`,`Judicial Branch`,`Legislative Branch`].map(e=>e.toLowerCase())),t=i.filter(t=>e.has(t.name.toLowerCase())),n=i.filter(t=>!e.has(t.name.toLowerCase())),r=n.filter(e=>e.is_pinned).map(e=>({...e,isRef:!1,label:e.name})).sort((e,t)=>e.label.localeCompare(t.label)),a=n.filter(e=>!e.is_pinned),s=[...o.related.map(e=>({...e,isRef:!0,label:e.rel_label?.trim()||I(e.full_name,o.cat.full_name)})),...a.map(e=>({...e,isRef:!1,label:e.name}))].sort((e,t)=>e.label.localeCompare(t.label,void 0,{sensitivity:`base`})),c=(e,t)=>(0,D.jsx)(`ul`,{className:t,children:e.map(e=>(0,D.jsxs)(`li`,{children:[(0,D.jsx)(F,{category:e,title:e.full_name.replace(/\//g,` › `),className:`hover:text-primary`,children:(0,D.jsxs)(`span`,{className:`font-semibold`,children:[e.label??e.name,e.isRef?(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:`@`}):null]})}),` `,e.isRef?null:(0,D.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.link_count,`)`]})]},`${e.id}-${e.isRef?`ref`:`sub`}`))}),l=`mt-6 grid list-disc gap-x-10 gap-y-1 pl-5 text-sm marker:text-muted-foreground sm:grid-cols-2`;return(0,D.jsxs)(D.Fragment,{children:[t.length>0?c(t,`mt-4 grid list-disc gap-y-1 pl-5 text-sm marker:text-muted-foreground sm:max-w-sm`):null,r.length>0?c(r,l):null,s.length>0?c(s,l):null]})})()]})})()}),a||o.links.length>0?(0,D.jsxs)(`section`,{className:`mt-10`,children:[a?null:(0,D.jsxs)(`p`,{className:`label-mono text-muted-foreground`,children:[o.links.length,` sites`]}),a?(0,D.jsx)(M,{term:n,category:{id:o.cat.id,full_name:o.cat.full_name},related:(o.related??[]).map(e=>({id:e.id,full_name:e.full_name}))}):(0,D.jsx)(`ul`,{className:`mt-5 space-y-6`,children:o.links.map(e=>(0,D.jsxs)(`li`,{className:`border-l-2 border-border pl-4`,children:[(0,D.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer nofollow`,className:`font-semibold text-primary underline underline-offset-2`,children:e.title}),e.description?(0,D.jsx)(`p`,{className:`mt-1 text-sm text-foreground
1/80`,children:e.description}):null,(0,D.jsxs)(`p`,{className:`label-mono mt-1 text-muted-foreground`,children:[e.url.replace(/^https?:\/\//,``),e.last_checked_at?(0,D.jsxs)(`span`,{title:`This link is checked periodically for liveness`,children:[` `,`· checked `,new Date(e.last_checked_at).toLocaleDateString(`en-PH`,{month:`short`,year:`numeric`})]}):null]})]},e.id))})]}):null]}):(0,D.jsxs)(`div`,{className:`card-block mt-10 p-8`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-extrabold`,children:`Category not found`}),(0,D.jsxs)(`p`,{className:`mt-2 text-muted-foreground`,children:[`This part of the archive is not available.`,` `,(0,D.jsx)(i,{to:`/dir.html`,className:`text-primary underline`,children:`Back to the directory`}),`.`]})]}),(0,D.jsx)(f,{withLogo:!0})]})}export{N as a,w as c,m as d,P as i,y as l,L as n,C as o,I as r,E as s,F as t,h as u};

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.