1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6011],{4402:()=>{},46011:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>f});var s=r(37876),n=r(28168),a=r(14232);r(4402);var l=r(10880),i=r(48166),o=r(74880),c=r(78240),u=r(91482),d=r(59025),m=r(59531),h=r(10714),p=r(21691);let g="trainsfyi_map_banner_dismissed",f=({initialCenter:e=[40.7128,-74.006],initialZoom:t=5,height:r=600,agencys:f=[],interactive:x=!0,disableChrome:b=!1,onTrainsUpdate:v=null,preview:w=!1})=>{let{trains:y,isLoading:k}=(0,c.e9)(w),{networks:C}=(0,c.xM)(),[N,j]=(0,a.useState)(!1),_=(0,a.useRef)(null),M=(0,a.useRef)(null),[,E]=(0,a.useState)(!1),[z,S]=(0,a.useState)(!0),A=(0,a.useMemo)(()=>o.Y.getAllNetworks(),[]),L=(0,a.useMemo)(()=>{let e=new Map(A.map(e=>[e.slug?.toLowerCase(),e]));return C.forEach(t=>{let r=t.slug?.toLowerCase();r&&!e.has(r)&&e.set(r,t)}),e},[A,C]),{units:T,convertSpeed:B,formatSpeed:G}=(0,i.t)();(0,a.useEffect)(()=>{S("true"===localStorage.getItem(g))},[]);let I=(0,a.useCallback)(()=>{S(!0),localStorage.setItem(g,"true")},[]),D=(0,a.useMemo)(()=>{let e=y?.trains?[...y.trains]:[];return f.length>0?e.filter(e=>f.includes(e.agency)):e},[y,f]);(0,a.useEffect)(()=>{if(_.current&&!M.current){let r=w?(0,m.Ec)():(0,m.pI)();M.current=new n.A.Map({container:_.current,style:r,center:[e[1],e[0]],zoom:t,antialias:!0,interactive:x,attributionControl:!b}),M.current.on("load",()=>{(M.current.getCenter().lng!==e[1]||M.current.getCenter().lat!==e[0])&&M.current.setCenter([e[1],e[0]]),M.current.getZoom()!==t&&M.current.setZoom(t),w||(0,m.z7)(M.current),(0,u.hB)(M.current,b?null:h.A),b||(0,d.E)(M.current,E,{initialMode:"2d"}),(0,p.MB)(M.current),j(!0)})}return()=>{M.current&&(M.current.remove(),M.current=null)}},[e,t,w]);let F=(0,a.useCallback)(()=>{if(!N||!M.current)return;let e=D.map(e=>{let t=L.get(e.agency?.toLowerCase()),r=t?.color||"#000000",s=t?.darkerColor||"#000000",n=e.normalized,a="N/A";
1return n?.speed?.has_speed&&(a=G(B(n.speed.value,n.speed.unit,T),(0,l.rT)(T))),{type:"Feature",geometry:{type:"Point",coordinates:[e.lng,e.lat]},properties:{id:e.id,vid:e.vid,color:r,borderColor:s,name:e.name,train_number:e.train_number,agency:e.agency,spd:a,org:e.org,dst:e.dst,updated_ago:e.updated_ago,gtfs:JSON.stringify(e.gtfs||{}),direction:e.dir,vehicleClassificationText:n?.vehicle?.type?.name||"Train",isGhost:"ghost"===e.position_source||e.isGhost||!1}}}),t=M.current.getSource("trains");t&&(t.setData({type:"FeatureCollection",features:e}),(0,p.pt)(e))},[N,D,L,T,B,G]);return(0,a.useEffect)(()=>{N&&M.current&&y?.trains&&(F(),v&&v())},[N,y,F,v]),(0,a.useEffect)(()=>{N&&M.current&&M.current.resize()},[N]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{M.current&&M.current.resize()},100);return()=>clearTimeout(e)},[]),(0,s.jsxs)("div",{className:"relative",style:{height:null==r?"100%":`${r}px`,width:"100%"},children:[(0,s.jsx)("div",{ref:_,style:{height:"100%",width:"100%"}}),k&&!b&&(0,s.jsxs)("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-10 bg-white/90 backdrop-blur-sm rounded-full px-4 py-2 shadow-lg flex items-center gap-2 animate-fade-in",children:[(0,s.jsx)("div",{className:"relative w-5 h-5",children:(0,s.jsx)("div",{className:"absolute inset-0 rounded-full border-2 border-gray-200 border-t-blue-600 animate-spin"})}),(0,s.jsx)("span",{className:"text-sm text-gray-700 font-medium",children:"Loading trainsâ¦"})]}),!z&&!b&&(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-black/75 backdrop-blur-sm text-white px-4 py-3",children:(0,s.jsxs)("div",{className:"mx-auto max-w-3xl flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Map updates every 30 seconds"}),(0,s.jsx)("p",{className:"text-xs text-white/80 mt-0.5",children:"Get live tracking updated every 20 seconds with the trains.fyi app."})]}),(0,s.jsxs)("a",{href:"/ios/",target:"_blank",rel:"noopener noreferrer",className:"shrink-0 inline-flex items-center gap-1.5 bg-white text-black text-xs font-semibold px-3 py-1.5 rounded-lg hover:bg-gray-100 transition-colors",children:[(0,s.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.8-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),"App Store"]}),(0,s.jsx)("button",{onClick:I,className:"shrink-0 p-1 hover:bg-white/20 rounded transition-colors","aria-label":"Dismiss",children:(0,s.jsx)("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]})})]})}}}]);
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.