PageSourceSearch

https://herald-local-pulse.base44.app/assets/LocalRedirect-Cr1qRWHa.js

js herald-local-pulse.base44.app collected 2026-10-03 03:15:26 UTC 11,180 bytes, 1 lines download raw bytes

1import{n as oe,ag as re,U as K,r as o,o as f,a1 as k,ab as y,aK as B,a8 as P,M as W,j as t,ad as ne,J as z,q as V,X as ie,L as ce,N as de}from"./index-B-aW8nfO.js";import{f as xe}from"./fetchAll-iQJvW09h.js";import{d as me}from"./geographyRoutes-DtaCb-Sx.js";import{g as ue}from"./geography-DRN2bBd4.js";import{E as O}from"./earth-BVBuYz9T.js";import{F as Z}from"./flag-AYgPfZGw.js";import{B as q}from"./building-2-CVoeb6NZ.js";import{S as U}from"./search-CoMiMp_X.js";function g(l){return l?/county$/i.test(l)?l:`${l} County`:""}const H=Object.entries(y).map(([l,x])=>({abbr:l,name:x,region:ue(l)})).sort((l,x)=>l.name.localeCompare(x.name)),be=["Northeast","Midwest","South","West"],he={"New England":"Northeast","Mid-Atlantic":"Northeast",Midwest:"Midwest","Upper Midwest":"Midwest","Ohio Valley":"Midwest","Tennessee Valley":"Midwest",Heartland:"Midwest",Southeast:"South","South Central":"South","Gulf Coast":"South",Appalachia:"South",Rockies:"West",Southwest:"West","West Coast":"West","Pacific Northwest":"West",Alaska:"West",Hawaii:"West"};function pe({buttonOnly:l=!1,triggerLabel:x="Choose location"}){const{pathname:m}=oe(),J=re(),{location:a,changeLocation:Q}=K(),[_,u]=o.useState(!1),[b,F]=o.useState(""),[I,j]=o.useState([]),[$,L]=o.useState(!1),[h,M]=o.useState(""),[n,A]=o.useState(""),[i,w]=o.useState(""),[N,p]=o.useState(""),[v,E]=o.useState([]),R=o.useRef(null);o.useEffect(()=>{u(!1),F(""),j([])},[m]),o.useEffect(()=>{_&&(M(""),A(""),w(""),p(""),E([]))},[_]),o.useEffect(()=>{if(!n){E([]),w(""),p("");return}(async()=>{const e=await xe("Location",{state_abbr:n},"-population",500).catch(()=>[]);E(me(e)),w(""),p("")})()},[n]),o.useEffect(()=>{clearTimeout(R.current);const e=b.trim();if(e.length<2){j([]),L(!1);return}return L(!0),R.current=setTimeout(async()=>{try{const r=/^\d{5}$/.test(e);let c=[];if(r&&(c=await f.entities.Location.filter({zip:e},"-population",30).catch(()=>[]),!c.length)){const s=await f.functions.invoke("resolveZip",{zip:e}).catch(()=>null),d=(s==null?void 0:s.data)||s||{};c=Array.isArray(d.locations)?d.locations:[]}const[se,ae,le]=await Promise.all([r?Promise.resolve([]):f.entities.Location.filter({city:{$regex:e,$options:"i"}},"-population",30).catch(()=>[]),r?Promise.resolve([]):f.entities.Location.filter({county:{$regex:e.replace(/\s+county$/i,""),$options:"i"}},"-population",50).catch(()=>[]),r?Promise.resolve([]):f.entities.Location.filter({state:{$regex:e,$options:"i"}},"-population",30).catch(()=>[])]),S=[],C=new Set;for(const s of[...c,...se]){if(!(s!=null&&s.city)||!(s!=null&&s.state_abbr))continue;const d=`city:${s.state_abbr}:${s.city.toLowerCase()}`;C.has(d)||(C.add(d),S.push({type:"city",label:`${s.city}, ${s.state_abbr}`,detail:s.county?g(s.county):y[s.state_abbr],to:k(s.state_abbr,s.city),location:s}))}for(const s of ae){if(!s.county||!s.state_abbr)continue;const d=`county:${s.state_abbr}:${s.county.toLowerCase()}`;C.has(d)||(C.add(d),S.push({type:"county",label:`${g(s.county)}, ${s.state_abbr}`,detail:"County coverage",to:B(s.state_abbr,s.county)}))}const G=new Set;for(const s of le)!s.state_abbr||G.has(s.state_abbr)||(G.add(s.state_abbr),S.push({type:"state",label:y[s.state_abbr]||s.state,detail:"Statewide coverage",to:P(s.state_abbr)}));j(S.slice(0,28))}catch{j([])}L(!1)},220),()=>clearTimeout(R.current)},[b]);const X=o.useMemo(()=>[...new Set(v.map(e=>String(e.county||"").replace(/\s+County$/i,"")).filter(Boolean))].sort(),[v]),D=o.useMemo(()=>v.filter(e=>!i||String(e.county||"").replace(/\s+County$/i,"")===i).map(e=>e.city).filter(Boolean).filter((e,r,c)=>c.indexOf(e)===r).sort(),[v,i]),Y=o.useMemo(()=>h?H.filter(e=>he[e.region]===h):H,[h]),ee=o.useMemo(()=>{const e=[{label:"National",to:"/",icon:O}];return m==="/"||m==="/states"||(a!=null&&a.state_abbr&&e.push({label:a.state||y[a.state_abbr],to:P(a.state_abbr),icon:Z}),a!=null&&a.state_abbr&&(a!=null&&a.county)&&e.push({label:g(a.county),to:B(a.state_abbr,a.county),icon:q}),a!=null&&a.state_abbr&&(a!=null&&a.city)&&e.push({label:a.city,to:k(a.state_abbr,a.city),icon:W})),e},[a,m]),T=(e,r)=>{r&&Q(r,"city"),u(!1),J(e)},te=e=>e==="state"?Z:e==="county"?q:W;return t.jsxs("div",{className:l?"contents":"border-b border-emerald-100 bg-white",children:[l?t.jsxs("button",{onClick:()=>u(!0),className:"shrink-0 inline-flex items-center gap-2 rounded-xl bg-emerald-950 text-white px-3 py-2 text-xs md:text-sm font-semibold hover:bg-emerald-900","aria-label":"Choose news location",children:[t.jsx(U,{className:"w-4 h-4 text-amber-400"}),t.jsx("span",{children:x})]}):t.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 md:px-6 py-2.5 flex items-center gap-2",children:[t.jsx("div",{className:"flex items-center gap-1.5 min-w-0 overflow-x-auto no-scrollbar flex-1",children:ee.map((e,r)=>{const c=e.icon;return t.jsxs(ne.Fragment,{children:[r>0&&t.jsx(z,{className:"w-3.5 h-3.5 text-slate-300 shrink-0"}),t.jsxs(V,{to:e.to,className:"inline-flex items-center gap-1.5 whitespace-nowrap rounded-lg px-2.5 py-1.5 text-xs md:text-sm font-semibold text-emerald-900 hover:bg-emerald-50",children:[t.jsx(c,{className:"w-3.5 h-3.5 text-amber-500"}),e.label]})]},`${e.label}-${e.to}`)})}),t.jsxs("button",{onClick:()=>u(!0),className:"shrink-0 inline-flex items-center gap-2 rounded-xl bg-emerald-950 text-white px-3 py-2 text-xs md:text-sm font-semibold",children:[t.jsx(U,{className:"w-4 h-4 text-amber-400"}),"Choose location"]})]}),_&&t.jsx("div",{className:"fixed inset-0 z-[120] bg-black/30 backdrop-blur-sm p-3 md:p-8",onClick:()=>u(!1),children:t.jsxs("div",{className:"mx-auto max-w-2xl rounded-2xl bg-white shadow-2xl overflow-hidden",onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{className:"p-4 border-b border-emerald-100 flex items-center gap-3",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(U,{className:"absolute left-3.5 to
1p-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"}),t.jsx("input",{autoFocus:!0,value:b,onChange:e=>F(e.target.value),placeholder:"Search city, county, state or ZIP",className:"w-full rounded-xl border border-emerald-200 pl-10 pr-4 py-3 text-base outline-none focus:border-emerald-600"})]}),t.jsx("button",{onClick:()=>u(!1),className:"p-2 rounded-lg hover:bg-slate-100","aria-label":"Close",children:t.jsx(ie,{className:"w-5 h-5"})})]}),t.jsxs("div",{className:"max-h-[76vh] overflow-y-auto p-4 space-y-4",children:[!b.trim()&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("button",{onClick:()=>T("/"),className:"rounded-xl border border-emerald-100 px-3 py-3 text-left hover:bg-emerald-50",children:[t.jsxs("div",{className:"flex items-center gap-2 font-bold text-emerald-950",children:[t.jsx(O,{className:"w-4 h-4 text-amber-500"}),"National"]}),t.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"All U.S. coverage"})]}),t.jsxs("button",{onClick:()=>M(""),className:"rounded-xl border border-emerald-100 px-3 py-3 text-left hover:bg-emerald-50",children:[t.jsx("div",{className:"font-bold text-emerald-950",children:"Browse all states"}),t.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"State, county or city"})]})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[10px] uppercase tracking-widest font-bold text-slate-500 mb-2",children:"Region"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:be.map(e=>t.jsx("button",{onClick:()=>{M(h===e?"":e),A("")},className:`rounded-full px-3 py-1.5 text-xs font-semibold border ${h===e?"bg-emerald-950 text-white border-emerald-950":"border-emerald-200 text-emerald-900"}`,children:e},e))})]}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[t.jsxs("label",{className:"text-xs font-bold text-emerald-950",children:["State",t.jsxs("select",{value:n,onChange:e=>A(e.target.value),className:"mt-1 block w-full rounded-xl border border-emerald-200 bg-white px-3 py-2.5 text-sm font-normal",children:[t.jsx("option",{value:"",children:"Select state"}),Y.map(e=>t.jsx("option",{value:e.abbr,children:e.name},e.abbr))]})]}),t.jsxs("label",{className:"text-xs font-bold text-emerald-950",children:["County",t.jsxs("select",{disabled:!n,value:i,onChange:e=>{w(e.target.value),p("")},className:"mt-1 block w-full rounded-xl border border-emerald-200 bg-white px-3 py-2.5 text-sm font-normal disabled:bg-slate-50",children:[t.jsx("option",{value:"",children:"All counties"}),X.map(e=>t.jsx("option",{value:e,children:g(e)},e))]})]}),t.jsxs("label",{className:"text-xs font-bold text-emerald-950",children:["City",t.jsxs("select",{disabled:!n,value:N,onChange:e=>p(e.target.value),className:"mt-1 block w-full rounded-xl border border-emerald-200 bg-white px-3 py-2.5 text-sm font-normal disabled:bg-slate-50",children:[t.jsx("option",{value:"",children:"All cities"}),D.map(e=>t.jsx("option",{value:e,children:e},e))]})]})]}),n&&t.jsxs("button",{onClick:()=>T(N?k(n,N):i?B(n,i):P(n)),className:"w-full rounded-xl bg-amber-500 px-4 py-3 font-bold text-emerald-950",children:["Go to ",N||(i?g(i):y[n])]})]}),$&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-sm text-slate-500",children:[t.jsx(ce,{className:"w-4 h-4 animate-spin"}),"Searching locations…"]}),!$&&b.trim().length>=2&&I.map(e=>{const r=te(e.type);return t.jsxs("button",{onClick:()=>T(e.to,e.location),className:"w-full flex items-center gap-3 rounded-xl px-3 py-3 hover:bg-emerald-50 text-left",children:[t.jsx(r,{className:"w-5 h-5 text-amber-500 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-semibold text-emerald-950 truncate",children:e.label}),t.jsx("p",{className:"text-xs text-slate-500 truncate",children:e.detail})]}),t.jsx(z,{className:"w-4 h-4 text-slate-300 ml-auto shrink-0"})]},`${e.type}-${e.to}`)}),!$&&b.trim().length>=2&&I.length===0&&t.jsx("p",{className:"py-8 px-4 text-center text-sm text-slate-500",children:"No match found. Use the state, county and city selectors instead."})]})]})})]})}function Ce(){const{location:l,loading:x,hasSavedLocation:m}=K();return x?t.jsx("div",{className:"max-w-xl mx-auto px-4 py-16 text-center text-muted-foreground",children:"Loading…"}):m&&(l!=null&&l.state_abbr)&&(l!=null&&l.city)?t.jsx(de,{to:k(l.state_abbr,l.city),replace:!0}):t.jsx("div",{className:"max-w-xl mx-auto px-5 pt-8 pb-24",children:t.jsxs("div",{className:"rounded-3xl border border-emerald-100 bg-white p-6 shadow-sm text-center",children:[t.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-emerald-950",children:t.jsx(W,{className:"w-6 h-6 text-amber-400"})}),t.jsx("h1",{className:"font-heading font-extrabold text-2xl text-emerald-950",children:"Choose your local edition"}),t.jsx("p",{className:"mt-2 text-sm leading-relaxed text-slate-600",children:"Country Herald will not guess y
1our hometown. Choose a city, county, state or ZIP to set the local news, weather and events you want to see."}),t.jsx("div",{className:"mt-5 flex justify-center",children:t.jsx(pe,{buttonOnly:!0,triggerLabel:"Choose location"})}),t.jsxs(V,{to:"/states",className:"mt-5 inline-flex items-center gap-1.5 text-sm font-semibold text-emerald-700 hover:underline",children:[t.jsx(O,{className:"w-4 h-4"})," Browse all states"]})]})})}export{Ce 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.