1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4866],{4402:()=>{},19141:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>d});var r=a(37876),s=a(48230),n=a.n(s),i=a(14232),l=a(89099),o=a(28168);function d(){let e=(0,l.useRouter)(),t=(0,i.useRef)(null),[a,s]=(0,i.useState)(null),[d,u]=(0,i.useState)(""),[c,h]=(0,i.useState)("40"),[m,g]=(0,i.useState)("0"),[p,x]=(0,i.useState)(""),[f,b]=(0,i.useState)(!1),w=(0,i.useRef)(null);async function N(t){if(t.preventDefault(),!a)return void x("Tap the map where you saw the train.");b(!0),x(""),w.current||=`web:${crypto.randomUUID()}`;try{let t=await fetch("/api/freight/sightings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,bearing:Number(d),speed_kmh:Number(c),observed_at:new Date(Date.now()-6e4*Number(m)).toISOString(),source_id:w.current,description:"User-reported freight sighting"})}),r=await t.json();if(!t.ok)throw Error(r.error||"Could not submit sighting.");await e.push(r.tracked_train_id?`/?train=freight:${r.tracked_train_id}`:"/freight/")}catch(e){x(e.message),b(!1)}}return(0,i.useEffect)(()=>{w.current=null},[a,d,c,m]),(0,i.useEffect)(()=>{let e=new o.A.Map({container:t.current,style:"https://tiles.openfreemap.org/styles/positron",center:[-80,40],zoom:4});e.addControl(new o.A.NavigationControl),e.addControl(new o.A.GeolocateControl({positionOptions:{enableHighAccuracy:!0}}));let a=new o.A.Marker({color:"#b45309"});return e.on("click",t=>{s({latitude:t.lngLat.lat,longitude:t.lngLat.lng}),a.setLngLat(t.lngLat).addTo(e)}),()=>e.remove()},[]),(0,r.jsxs)("main",{className:"mx-auto max-w-3xl px-4 py-8",children:[(0,r.jsx)(n(),{href:"/",className:"text-sm text-blue-800",children:"â Back to map"}),(0,r.jsx)("h1",{className:"mt-4 text-2xl font-bold",children:"Report a freight train"}),(0,r.jsx)("p",{className:"my-3 text-sm text-gray-600",children:"Tap the railway where you saw the train, then enter its direction and estimated speed. We predict its position for three hours after the sighting."}),(0,r.jsx)("div",{ref:t,"aria-label":"Choose sighting location",className:"h-80 overflow-hidden rounded-xl"}),(0,r.jsx)("p",{className:"my-2 text-sm",children:a?`${a.latitude.toFixed(5)}, ${a.longitude.toFixed(5)}`:"Tap the map to place your sighting."}),(0,r.jsxs)("form",{onSubmit:N,className:"mt-5 grid gap-4 sm:grid-cols-2",children:[(0,r.jsxs)("label",{className:"text-sm",children:["Direction of travel",(0,r.jsxs)("select",{required:!0,value:d,onChange:e=>u(e.target.value),className:"mt-1 block w-full rounded border-gray-300",children:[(0,r.jsx)("option",{value:"",children:"Choose direction"}),["North","Northeast","East","Southeast","South","Southwest","West","Northwest"].map((e,t)=>(0,r.jsx)("option",{value:45*t,children:e},e))]})]}),(0,r.jsxs)("label",{className:"text-sm",children:["Estimated speed (km/h)",(0,r.jsx)("input",{required:!0,type:"number",min:"0",max:"200",value:c,onChange:e=>h(e.target.value),className:"mt-1 block w-full rounded border-gray-300"}),(0,r.jsx)("span",{className:"text-xs text-gray-500",children:"40 km/h is a starting estimate. Enter 0 if stopped."})]}),(0,r.jsxs)("label",{className:"text-sm",children:["Minutes since sighting",(0,r.jsx)("input",{required:!0,type:"number",min:"0",max:"179",value:m,onChange:e=>g(e.target.value),className:"mt-1 block w-full rounded border-gray-300"})]}),(0,r.jsx)("button",{disabled:f,className:"self-end rounded-lg bg-amber-800 px-5 py-3 text-sm font-semibold text-white disabled:opacity-50",children:f?"Submittingâ¦":"Add sighting to map"}),p&&(0,r.jsx)("p",{role:"alert",className:"text-sm text-red-700 sm:col-span-2",children:p})]})]})}a(4402)},28168:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});var r=a(31198),s=a.n(r);"unavailable"===s().getRTLTextPluginStatus()&&s().setRTLTextPlugin("/vendor/mapbox-gl-rtl-text/0.2.3.min.js",!0).catch(e=>console.error("Unable to initialize right-to-left map labels",e));let n=s()},72196:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/freight/report",function(){return a(19141)}])}},e=>{e.O(0,[3368,1808,636,6593,8792],()=>e(e.s=72196)),_N_E=e.O()}]);
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.