1import{C as P,r as c,j as e,L as M,B as R}from"./main-Da2vmelg.js";const L="label";function C(a,t){typeof a=="function"?a(t):a&&(a.current=t)}function _(a,t){const r=a.options;r&&t&&Object.assign(r,t)}function k(a,t){a.labels=t}function D(a,t,r=L){const l=[];a.datasets=t.map(s=>{const n=a.datasets.find(d=>d[r]===s[r]);return!n||!s.data||l.includes(n)?{...s}:(l.push(n),Object.assign(n,s),n)})}function H(a,t=L){const r={labels:[],datasets:[]};return k(r,a.labels),D(r,a.datasets,t),r}function O(a,t){const{height:r=150,width:l=300,redraw:s=!1,datasetIdKey:n,type:d,data:u,options:x,plugins:p=[],fallbackContent:b,updateMode:j,...y}=a,m=c.useRef(null),o=c.useRef(null),h=()=>{m.current&&(o.current=new P(m.current,{type:d,data:H(u,n),options:x&&{...x},plugins:p}),C(t,o.current))},f=()=>{C(t,null),o.current&&(o.current.destroy(),o.current=null)};return c.useEffect(()=>{!s&&o.current&&x&&_(o.current,x)},[s,x]),c.useEffect(()=>{!s&&o.current&&k(o.current.config.data,u.labels)},[s,u.labels]),c.useEffect(()=>{!s&&o.current&&u.datasets&&D(o.current.config.data,u.datasets,n)},[s,u.datasets]),c.useEffect(()=>
1{o.current&&(s?(f(),setTimeout(h)):o.current.update(j))},[s,x,u.labels,u.datasets,j]),c.useEffect(()=>{o.current&&(f(),setTimeout(h))},[d]),c.useEffect(()=>(h(),()=>f()),[]),e.jsx("canvas",{ref:m,role:"img",height:r,width:l,...y,children:b})}const V=c.forwardRef(O);function T(a,t){return P.register(t),c.forwardRef((r,l)=>e.jsx(V,{...r,ref:l,type:a}))}const F=T("line",M),I=T("bar",R),N=7e4,w=15e4,S=[.45,.45,.45,.45,.5,.55,.6,.65,.6,.55,.52,.5,.48,.46,.42,.38,.35,.4,.42,.46,.48,.5,.48,.46],Y=[.01,.008,.006,.006,.01,.02,.04,.065,.07,.06,.055,.058,.062,.06,.058,.065,.072,.068,.055,.045,.038,.03,.022,.015];async function U(){try{const t=await fetch("https://api.census.gov/data/2022/acs/acs5?get=B01003_001E&for=county:019,129&in=state:37");if(!t.ok)throw new Error("Census API error");const l=(await t.json()).slice(1).reduce((s,n)=>s+parseInt(n[0],10),0);if(!l||isNaN(l))throw new Error("Bad data");return{population:l,live:!0}}catch{return{population:w,live:!1}}}function $(a,t,r,l){const s=[],n=[],d=[],u=new Date().getFullYear();for(let x=0;x<=l;x++){s.push(String(u+x));const p=Math.pow(1+t/100,x);n.push(Math.round(a*p*r)),d.push(Math.round(w*p))}return{labels:s,trafficValues:n,popValues:d}}function G(a){const t=Array.from({length:24},(s,n)=>`${n}:00`),r=[],l=[];for(let s=0;s<24;s++){const n=Math.round(a*Y[s]);r.push(Math.round(n*S[s])),l.push(Math.round(n*(1-S[s])))}return{hours:t,eb:r,wb:l}}function v({label:a,min:t,max:r,step:l,value:s,unit:n,onChange:d}){return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex justify-between text-sm font-medium text-gray-700",children:[e.jsx("span",{children:a}),e.jsxs("span",{className:"text-blue-600 font-semibold",children:[s,n]})]}),e.jsx("input",{type:"range",min:t,max:r,step:l,value:s,onChange:u=>d(Number(u.target.value)),className:"w-full accent-blue-600"}),e.jsxs("div",{className:"flex justify-between text-xs text-gray-400",children:[e.jsxs("span",{children:[t,n]}),e.jsxs("span",{children:[r,n]})]})]})}function K(){const[a,t]=c.useState(!1),[r,l]=c.useState(3),[s,n]=c.useState(1),[d,u]=c.useState(10),[x,p]=c.useState(w),[b,j]=c.useState(!1),[y,m]=c.useState(!0);c.useEffect(()=>{t(!0),U().then(({population:i,live:g})=>{p(i),j(g),m(!1)})},[]);const o=$(N,r,s,d),h=G(Math.round(N*s)),f={labels:o.labels,datasets:[{label:"Projected Traffic (vehicles/day)",data:o.trafficValues,borderColor:"rgb(59, 130, 246)",backgroundColor:"rgba(59, 130, 246, 0.15)",fill:!0,tension:.3,yAxisID:"y"},{label:"Population Growth",data:o.popValues,borderColor:"rgb(16, 185, 129)",backgroundColor:"rgba(16, 185, 129, 0.08)",fill:!0,tension:.3,yAxisID:"y1"}]},E={labels:h.hours,datasets:[{label:"Eastbound",data:h.eb,backgroundColor:"rgba(59, 130, 246, 0.8)",borderRadius:3},{label:"Westbound",data:h.wb,backgroundColor:"rgba(245, 158, 11, 0.8)",borderRadius:3}]},B=o.trafficValues[d]??N,A=h.eb.reduce((i,g)=>i+g,0)+h.wb.reduce((i,g)=>i+g,0);return e.jsx("div",{className:"min-h-screen bg-gray-50",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Cape Fear Traffic & Growth Dashboard"}),e.jsx("p",{className:"text-gray-500 mt-1",children:"Brunswick & New Hanover Counties, NC â Corridor Traffic Analysis"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:[e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Base Daily Traffic"}),e.jsx("p",{className:"text-2xl font-bold text-gray-900",children:N.toLocaleString()}),e.jsx("p",{className:"text-sm text-gray-400",children:"vehicles / day"})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6",children:[e.jsxs("p",{className:"text-sm text-gray-500",children:["Projected Traffic (Year ",d,")"]}),e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:B.toLocaleString()}),e.jsx("p",{className:"text-sm text-gray-400",children:"vehicles / day"})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Combined Population"}),e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:y?"â":x.toLocaleStr
1ing()}),e.jsx("p",{className:"text-sm text-gray-400",children:"Brunswick + New Hanover"})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Census Data Source"}),e.jsx("p",{className:"text-lg font-bold",children:y?e.jsx("span",{className:"text-gray-400",children:"Loadingâ¦"}):b?e.jsx("span",{className:"text-emerald-600",children:"â Live (ACS 2022)"}):e.jsx("span",{className:"text-amber-500",children:"â Estimated"})}),e.jsx("p",{className:"text-sm text-gray-400",children:b?"US Census Bureau API":"Fallback: 150,000"})]})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6 mb-8",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-6",children:"Projection Parameters"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:[e.jsx(v,{label:"Population Growth Rate",min:.5,max:10,step:.5,value:r,unit:"%",onChange:l}),e.jsx(v,{label:"Conversion Factor",min:.5,max:2,step:.05,value:s,unit:"Ã",onCh
1ange:n}),e.jsx(v,{label:"Projection Horizon",min:1,max:25,step:1,value:d,unit:" yrs",onChange:u})]})]}),a&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6 lg:col-span-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Traffic Growth Projection"}),e.jsx(F,{data:f,options:{responsive:!0,interaction:{mode:"index",intersect:!1},plugins:{legend:{position:"top"},tooltip:{callbacks:{label:i=>`${i.dataset.label}: ${i.parsed.y.toLocaleString()}`}}},scales:{y:{type:"linear",position:"left",title:{display:!0,text:"Vehicles / Day"},ticks:{callback:i=>Number(i).toLocaleString()}},y1:{type:"linear",position:"right",grid:{drawOnChartArea:!1},title:{display:!0,text:"Population"},ticks:{callback:i=>Number(i).toLocaleString()}}}}})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6 lg:col-span-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Hourly Traffic Distribution (EB / WB)"}),e.jsxs("span",{className:"text-sm text-gray-500",children:["Daily total: ",A.toLocaleString()," vehicles"]})]}),e.jsx(I,{data:E,options:{responsive:!0,plugins:{legend:{position:"top"},tooltip:{callbacks:{label:i=>`${i.dataset.label}: ${i.parsed.y.toLocaleString()} vehicles`}}},scales:{x:{stacked:!1,title:{display:!0,text:"Hour of Day"}},y:{beginAtZero:!0,title:{display:!0,text:"Vehicles"},ticks:{callback:i=>Number(i).toLocaleString()}}}}})]})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm p-6 mt-8",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Sources"}),e.jsxs("ul",{className:"space-y-3 text-sm text-gray-700",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500 mt-0.5",children:"â¢"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"U.S. Census Bureau â American Community Survey (ACS) 5-Year Estimates (2022)"}),e.jsx("br",{}),e.jsx("a",{href:"https://www.census.gov/programs-surveys/acs",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"census.gov/programs-surveys/acs"}),e.jsx("span",{className:"text-gray-400 ml-2",children:"â Population data for Brunswick & New Hanover Counties"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500 mt-0.5",children:"â¢"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"U.S. Census Bureau API"}),e.jsx("br",{}),e.jsx("a",{href:"https://api.census.gov/data.html",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"api.census.gov/data.html"}),e.jsx("span",{className:"text-gray-400 ml-2",children:"â Live population data endpoint"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500 mt-0.5",children:"â¢"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"NCDOT (North Carolina Department of Transportation) â Traffic Volume Maps"}),e.jsx("br",{}),e.jsx("a",{href:"https://connect.ncdot.gov/resources/State-Mapping/Pages/Traffic-Volume-Maps.aspx",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"connect.ncdot.gov/resources/State-Mapping/Pages/Traffic-Volume-Maps.aspx"}),e.jsx("span",{className:"text-gray-400 ml-2",children:"â Base traffic counts and corridor volume data"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-blue-500 mt-0.5",children:"â¢"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium",children:"Cape Fear Region Metropolitan Planning Organization (MPO)"}),e.jsx("br",{}),e.jsx("a",{href:"https://wmpo.org/",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"wmpo.org"}),e.jsx("span",{className:"text-gray-400 ml-2",children:"â Regional transportation planning and growth projections"})]})]})]})]})]})})}export{K as component};
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.