PageSourceSearch

https://theonlinecitizen.com/_next/static/chunks/5024.bac1f9e6e8e5f8ca.js

js theonlinecitizen.com collected 2026-09-24 18:34:08 UTC 9,349 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5024],{5024:(e,t,n)=>{n.r(t),n.d(t,{default:()=>b});var a=n(5155),l=n(8661),i=n.n(l),r=n(2619),o=n.n(r),s=n(3903),c=n(2115),d=n(5375);n(28);var u=n(5554);let m="/fallback-image.jpg",f="/api/feed/latest",x=new Set(["opinion","opinions","editorial","editorials","letter","letters","commentary"]),h=async e=>{let t=await fetch(e),n=await t.json().catch(()=>({}));if(!t.ok)throw Error((null==n?void 0:n.error)||(null==n?void 0:n.message)||"Fetch failed: ".concat(t.status));return n};function g(e){let t=new Set,n=[];for(let a of e){let e=(null==a?void 0:a.attributes)||a||{},l=(null==e?void 0:e.documentId)||(null==e?void 0:e.document_id)||(null==e?void 0:e.documentID)||"".concat((null==e?void 0:e.publication)||"unknown",":").concat((null==e?void 0:e.id)||"",":").concat((null==e?void 0:e.slug)||"");!l||t.has(l)||(t.add(l),n.push(a))}return n}function p(e){let{heading:t="Latest News",category:n,fallbackData:l}=e,r="".concat(f,"?page=1&limit=").concat(30)+(n?"&category=".concat(encodeURIComponent(n)):""),{data:p,error:b,isLoading:v}=(0,s.Ay)(r,h,{fallbackData:l,refreshInterval:3e5,dedupingInterval:12e4,revalidateOnFocus:!1,revalidateOnReconnect:!1}),[j,w]=(0,c.useState)([]),[y,N]=(0,c.useState)(2),[k,S]=(0,c.useState)(!0),[E,C]=(0,c.useState)(!1),L=(0,c.useRef)(null),A=(0,c.useRef)(!0),I=(0,c.useRef)(!1),M=(0,c.useRef)(2),R=(0,c.useRef)(0);(0,c.useEffect)(()=>{A.current=k},[k]),(0,c.useEffect)(()=>{I.current=E},[E]),(0,c.useEffect)(()=>{M.current=y},[y]);let[_,z]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let e=()=>z(!0);return window.addEventListener("scroll",e,{passive:!0,once:!0}),()=>window.removeEventListener("scroll",e)},[]),(0,c.useEffect)(()=>{let e=Array.isArray(null==p?void 0:p.items)?p.items:[];e.length&&(w(t=>g([...e,...t]).slice(0,300)),N(2),S(!!(null==p?void 0:p.hasMore)))},[null==p?void 0:p.page,null==p?void 0:p.limit,null==p?void 0:p.hasMore]);let D=(0,c.useMemo)(()=>j.slice(0,300),[j]);async function U(){if(!I.current&&A.current){if(R.current>=300)return void S(!1);I.current=!0,C(!0);try{let e=M.current,t="".concat(f,"?page=").concat(e,"&limit=").concat(30)+(n?"&category=".concat(encodeURIComponent(n)):""),a=await h(t),l=Array.isArray(null==a?void 0:a.items)?a.items:[],i=!!(null==a?void 0:a.hasMore);w(e=>g([...e,...l]).slice(0,300));let r=Math.min(300,R.current+((null==l?void 0:l.length)||0));S(i&&((null==l?void 0:l.length)||0)>0&&r<300),N(e=>e+1)}catch(e){S(!1)}finally{I.current=!1,C(!1)}}}return(0,c.useEffect)(()=>{R.current=D.length},[D.length]),(0,c.useEffect)(()=>{if(!L.current||!k||!_)return;let e=new IntersectionObserver(e=>{var t;(null==(t=e[0])?void 0:t.isIntersecting)&&U()},{root:null,rootMargin:"180px 0px",threshold:.01});return e.observe(L.current),()=>e.disconnect()},[k,_,n]),(0,a.jsxs)("section",{className:"jsx-6447a51d6009f616 recent-post-area py-4 px-3 px-md-4",children:[(0,a.jsx)("div",{className:"jsx-6447a51d6009f616 d-flex justify-content-between align-items-center mb-4 border-bottom pb-2",children:(0,a.jsx)("h2",{className:"jsx-6447a51d6009f616 h5 mb-0",children:t})}),v&&(0,a.jsx)("div",{style:{paddingBottom:"0.75rem"},className:"jsx-6447a51d6009f616 text-muted small",children:"Loading…"}),b&&(0,a.jsx)("div",{style:{paddingBottom:"0.75rem"},className:"jsx-6447a51d6009f616 text-danger small",children:"Failed to load."}),(0,a.jsx)("div",{style:{rowGap:"12px"},className:"jsx-6447a51d6009f616 d-flex flex-column",children:D.map(e=>{let{id:t,title:n,slug:l,Excerpt:i,publishedAt:r,imageUrl:s,categories:c,origin:f,accent:h}=function(e){let t=(null==e?void 0:e.attributes)||e||{},n=Array.isArray(t.categories)?t.categories:[],a=t.publication_date||t.publishedAt||t.createdAt||"",l=t.title||t.Title||"",i=t.Excerpt||t.excerpt||"",r=t.imageUrl||m,o=t.origin||t.publication||"root",s=t.accent||"#666";return{id:t.id||(null==e?void 0:e.id),title:l,slug:t.slug||"",Excerpt:i,publishedAt:a,imageUrl:r,categories:n,origin:o,accent:s}}(e),g=(c||[]).find(e=>x.has(String((null==e?void 0:e.slug)||"").toLowerCase())),p=(c||[]).find(e=>!x.has(String((null==e?void 0:e.slug)||"").toLowerCase()))||(null==c?void 0:c[0])||{slug:"news",name:"News"},b=String((null==p?void 0:p.slug)||"news").toLowerCase(),v=b.toUpperCase(),j=(null==g?void 0:g.slug)?String(g.slug).toLowerCase():null,w=j?j.toUpperCase():null,y="/category/".concat(b),N=j?"/category/".concat(j):null,k=(0,d.y)({origin:f,slug:l,publishedAt:r,categories:c}),S=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,n=String(e||"").trim().split(/\s+/);return n[0]?n.length<=t?e:n.slice(0,t).join(" ")+"…":""}(i,60),E=!!j,C=(0,u.el)(f);return(0,a.jsx)("article",{className:"jsx-6447a51d6009f616 card-borderless",children:(0,a.jsxs)("div",{className:"jsx-6447a51d6009f616 d-flex align-items-stretch position-relative gap-3",children:[(0,a.jsx)("div",{className:"jsx-6447a51d6009f616 thumb-col flex-shrink-0",children:(0,a.jsx)(o(),{href:k,prefetch:!1,className:"d-block position-relative text-decoration-none",children:(0,a.jsxs)("div",{className:"jsx-6447a51d6009f616 thumb-inner rounded overflow-hidden",children:[(0,a.jsx)("img",{src:s||m,alt:n||"Article image",loading:"lazy",decoding:"async",onError:e=>{let t=e.currentTarget;"1"!==t.dataset.fallback&&(t.dataset.fallback="1",t.src=m)},className:"jsx-6447a51d6009f616 thumb-img"}),!E&&(null==p?void 0:p.name)&&(0,a.jsx)("span",{"aria-label":"Category ".concat(p.name),className:"jsx-6447a51d6009f616 badge-cat",children:p.name})]})})}),(0,a.jsxs)("div",{className:"jsx-6447a51d6009f616 d-flex flex-column flex-grow-1 minw-0 position-relative",children:[(0,a.jsx)("h3",{style:{"--barColor":C},className:"jsx-6447a51d6009f616 mb-1 fw-semibold lh-sm post-title with-origin-bar",children:(0,a.jsx)(o(),{href:k,prefetch:!1,className:"text-reset text-decoration-none",children:n})}),S&&(0,a.jsx)("p",{className:"jsx-6447a51d6009f616 mb-2 text-muted post-excerpt",children:S}),(0,a.jsxs)("div",{className:"jsx-6447a51d6009f616 mt-auto d-flex align-items-center justify-content-between small",children:[(0,a.jsxs)("div",{className:"jsx-6447a51d6009f616 d-flex align-items-center",children:[(0,a.jsx)(o(),{href:y,prefetch:!1,className:"badge-cat-label me-1",children:v}),w&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"jsx-6447a51d6009f616 mx-1 text-muted",children:"|"}),N?(0,a.jsx)(o(),{href:N,prefetch:!1,className:"opinion-accent text-decoration-none",style:{color:h},children:w}):(0,a.jsx)("span",{style:{color:h},className:"jsx-6447a51d6009f616 opinion-accent",children:w})]})]}),(0,a.jsx)("span",{className:"jsx-6447a51d6009f616 text-muted",children:r?new Date(r).toLocaleDateString("en-GB",{timeZone:"Asia/Singapore",day:"numeric",month:"long",year:"numeric"}):""})]})]})]})},t||function(e){let t=(null==e?void 0:e.attributes)||e||{};
1return String((null==t?void 0:t.documentId)||(null==t?void 0:t.document_id)||(null==t?void 0:t.documentID)||"".concat((null==t?void 0:t.origin)||"unknown",":").concat((null==t?void 0:t.id)||"",":").concat((null==t?void 0:t.slug)||"")||Math.random())}(e))})}),(0,a.jsx)("div",{ref:L,style:{height:"2.75rem"},className:"jsx-6447a51d6009f616 mt-4 d-flex align-items-center justify-content-center text-muted",children:E?"Loading more…":k?D.length?"":"Loading…":"No more posts".concat(D.length>=300?" (max ".concat(300,")"):"")}),(0,a.jsx)(i(),{id:"6447a51d6009f616",children:'html{max-width:100%;overflow-x:hidden;overscroll-behavior-x:none;touch-action:pan-y}.minw-0.jsx-6447a51d6009f616{min-width:0}.thumb-col.jsx-6447a51d6009f616{flex:0 0 clamp(180px,34%,320px);max-width:clamp(180px,34%,320px)}.thumb-inner.jsx-6447a51d6009f616{position:relative;width:100%;aspect-ratio:16/9;background:#f2f2f2}.thumb-img.jsx-6447a51d6009f616{width:100%;height:100%;object-fit:cover;display:block}.badge-cat.jsx-6447a51d6009f616{position:absolute;left:0;bottom:0;margin:.4rem;padding:.3rem .6rem;background:rgba(0,0,0,.75);color:#fff;text-transform:uppercase;font-weight:600;font-size:.72rem;border-radius:.3rem;pointer-events:none}.post-title.jsx-6447a51d6009f616{font-size:clamp(1.05rem,1.9vw,1.35rem);display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}.with-origin-bar{position:relative;padding-left:12px}.with-origin-bar::before{content:"";position:absolute;left:0;top:.15em;bottom:.15em;width:4px;border-radius:3px;background:var(--barColor,'.concat("#b80004",")}.post-excerpt.jsx-6447a51d6009f616{font-size:clamp(.92rem,1.5vw,1rem);line-height:1.35;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;margin-bottom:.25rem}.badge-cat-label.jsx-6447a51d6009f616{display:inline-block;background:#f1f1f1;color:#555;font-size:.68rem;font-weight:600;text-transform:uppercase;padding:.18rem .45rem;border-radius:.25rem;line-height:1;text-decoration:none}.badge-cat-label.jsx-6447a51d6009f616:hover{background:#e0e0e0;color:#000;text-decoration:none}.opinion-accent.jsx-6447a51d6009f616:hover{filter:brightness(.9)}.card-borderless.jsx-6447a51d6009f616{border:0;background:transparent}")})]})}function b(e){let{initialArticles:t}=e,n={items:t,hasMore:(null==t?void 0:t.length)>=30};return(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsx)(p,{heading:"Latest News",fallbackData:n})})}}}]);

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.