(globalThis.TURBOPACK_remote_chunk_loading_global_prj_Ea8QNpCs22Ye85AIRZ6hT1aa8n7z||(globalThis.TURBOPACK_remote_chunk_loading_global_prj_Ea8QNpCs22Ye85AIRZ6hT1aa8n7z=[])).push(["object"==typeof document?document.currentScript:void 0,86014,e=>{"use strict";let t,r,a,n;var i,o,l,s,c=e.i(43476),d=e.i(71645),u=e.i(18566);let f=(0,d.createContext)(null),p=f.Provider;var h=e.i(30086),m=e.i(70703),g=e.i(40875),b=e.i(49415),v=e.i(56669),y=e.i(75254);let x=(0,y.default)("skip-back",[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]]),_=(0,y.default)("skip-forward",[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]);var w=e.i(99039);function S({segments:e,overallWindow:t,scrubTime:r,onScrub:a,playing:n,onTogglePlay:i,onPrevLeg:o,onNextLeg:l,canPrevLeg:s,canNextLeg:d,onLive:u,activeSegment:f,variant:p="classic"}){var m;let g,y,C,k="flint"===p,N=(0,b.findActiveSegment)(e,Date.now()),A=N?.type!=="leg"||(0,b.hasArcDeparted)(N.leg)?Math.max(t.start,Math.min(t.end,Date.now())):t.start,R=r??A,T=function(e,t){let r=t.end-t.start;if(r{let a=t.end-t.start,n=a>0?((e.start+e.end)/2-t.start)/a*100:0;return(0,c.jsx)("div",{style:{position:"absolute",top:0,left:`${n}%`,transform:"translateX(-50%)",fontSize:14,lineHeight:1},title:"leg"===e.type?e.leg.identIata||e.leg.ident:`Layover at ${e.iata}`,role:"img","aria-label":"leg"===e.type?e.leg.identIata||e.leg.ident:`Layover at ${e.iata}`,children:"leg"===e.type?"✈":"⏱"},r)})}),(0,c.jsx)("input",{type:"range",min:t.start,max:t.end,step:1e3,value:R,onChange:e=>a(Number(e.target.value)),style:{width:"100%",height:8,borderRadius:4,background:T,appearance:"none",accentColor:"var(--border-color-interactive)",cursor:"pointer"},"aria-label":"Flight timeline scrubber"}),(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:8,gap:12},children:[(0,c.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,c.jsx)("button",{onClick:o,disabled:!s,"aria-label":"Previous leg",style:k?(0,w.roundStepStyle)(!s):j(!s),children:k?(0,c.jsx)(x,{size:14,"aria-hidden":"true"}):"⏮"}),(0,c.jsx)("button",{onClick:i,"aria-label":n?"Pause":"Play",style:k?(0,w.roundPlayStyle)(!1):j(!1),children:k?n?(0,c.jsx)(h.Pause,{size:16,"aria-hidden":"true"}):(0,c.jsx)(h.Play,{size:16,"aria-hidden":"true"}):n?"⏸":"▶"}),(0,c.jsx)("button",{onClick:l,disabled:!d,"aria-label":"Next leg",style:k?(0,w.roundStepStyle)(!d):j(!d),children:k?(0,c.jsx)(_,{size:14,"aria-hidden":"true"}):"⏭"}),(0,c.jsx)("button",{onClick:u,style:j(null==r),children:"Live"})]}),(0,c.jsxs)("div",{style:{fontSize:12,color:"var(--color-fg)",textAlign:"right"},children:[(0,c.jsx)("span",{style:{fontWeight:600},children:function(e){if(!e)return"";if("leg"===e.type){let{leg:t}=e,r=t.identIata||t.ident,a=`${t.origin.code} → ${t.destination.code}`;return`${r} \xb7 ${a}`}return`Layover at ${e.iata}`}(f)}),f&&(0,c.jsx)("span",{style:{color:"var(--color-fg-tertiary)",marginLeft:8},children:"leg"===f.type?(m=f.leg.flight?.origin.timezone??(0,v.getAirportByIata)(f.leg.origin.code)?.timezone,new Date(R).toLocaleTimeString("en-US",{timeZone:m,hour:"numeric",minute:"2-digit"})):`${y=Math.floor((g=Math.round((f.end-R)/6e4))/60),C=g%60,y>0?`${y}h ${C}m`:`${C}m`} remaining`})]})]})]})})}function j(e){return{background:e?"var(--color-surface-muted)":"var(--color-surface)",border:"1px solid var(--border-color-subtle)",borderRadius:6,width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",cursor:e?"default":"pointer",color:e?"var(--color-fg-disabled)":"var(--color-fg-interactive)",fontSize:12,padding:0}}let C=(0,m.default)(()=>e.A(58400),{loadableGenerated:{modules:[14270]},ssr:!1}),k=[];function N({airports:e,airportStatuses:t,state:r,chromeVariant:a="classic",fitInsets:n,onTimelineSwipeUp:i,onTimelineSwipeDown:o}){let l="flint"===a,{sidebarExtraAirports:s,sidebarExtraStatuses:u}=r,f=(0,d.useMemo)(()=>{let t=new Set;return[...e,...s].filter(e=>!t.has(e.iata)&&t.add(e.iata))},[e,s]),p=(0,d.useMemo)(()=>({...u,...t}),[u,t]),h=(0,d.useMemo)(()=>{if("flint"!==a||!r.isFlightActive)return null;let e=[r.displayFlightArc,...r.displaySiblingArcs].filter(e=>!!e);return 0===e.length?null:[...new Set(e.flatMap(e=>[e.origin.code,e.destination.code]))].sort()},[a,r.isFlightActive,r.displayFlightArc,r.displaySiblingArcs]),m=!!(r.isFlightActive&&r.overallWindow&&r.segments.length>0),v=r.activeSegment??(0,b.findActiveSegment)(r.segments,Date.now())??r.segments[0]??null,y=v?.type==="leg"&&v.leg.flight?.cancelled?"Cancelled":void 0,{segments:x,handleTimelineSeek:_}=r,w=r.flightArc??r.fadedFlightArc,j=x.find(e=>"leg"===e.type&&e.leg===w)?.start,A=(0,d.useMemo)(()=>l&&m?{key:x.map(e=>"leg"===e.type?`${e.leg.ident}|${e.leg.origin.code}|${e.leg.destination.code}`:e.iata).join(","),bands:x.map(e=>({start:e.start,end:e.end,kind:e.type})),departure:j,onSeek:_,statusLabel:y}:null,[l,m,x,j,_,y]);return(0,c.jsxs)("div",{className:`relative flex h-full w-full flex-col overflow-hidden ${"flint"===a?"":"pb-16 md:pb-0"}`,children:[(0,c.jsxs)("div",{className:"relative flex-1 overflow-hidden",children:[t&&(0,g.airportsOutage)(t)&&(0,c.jsx)("p",{role:"status","data-testid":"airport-status-outage",className:"absolute top-12 left-1/2 z-20 -translate-x-1/2 rounded-control border border-subtle bg-surface px-3 py-1.5 text-caption text-fg-secondary",children:"Airport delay status is unavailable right now."}),r.flightLoading&&(0,c.jsx)("div",{style:{position:"absolute",top:`calc(${l?58:48}px + var(--flint-top-inset, 0px))`,left:"50%",transform:"translateX(-50%)",zIndex:20,background:"rgba(255,255,255,0.95)",border:"1px solid #cdcdcd",borderRadius:8,padding:"6px 14px",fontSize:12,color:"#676767"},children:"Loading flight…"}),!l&&!r.flightLoading&&r.fadedFlightArc&&(0,c.jsxs)("div",{"data-testid":"faded-flight-pill",style:{position:"absolute",top:`calc(${l?58:48}px + var(--flint-top-inset, 0px))`,left:"50%",transform:"translateX(-50%)",zIndex:20,display:"flex",alignItems:"center",gap:6,background:"rgba(32,71,148,0.95)",color:"#fff",borderRadius:999,padding:"6px 6px 6px 12px",fontSize:12,fontFamily:"ui-monospace, monospace",boxShadow:"0 2px 8px rgba(0,0,0,0.25)"},children:[(0,c.jsxs)("button",{type:"button",onClick:r.reselectFadedFlight,style:{background:"none",border:"none",color:"#fff",cursor:"pointer",fontFamily:"inherit",fontSize:"inherit",fontWeight:700,padding:0},children:["↩ ",r.fadedFlightArc.identIata||r.fadedFlightArc.ident]}),(0,c.jsx)("button",{type:"button",onClick:r.dismissFadedFlight,"aria-label":"Dismiss flight",style:{background:"rgba(255,255,255,0.15)",border:"none",color:"#fff",cursor:"pointer",borderRadius:"50%",width:18,height:18,fontSize:11,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center"},children:"×"})]}),(0,c.jsx)(C,{chromeVariant:a,fitInsets:n,onTimelineSwipeUp:i,onTimelineSwipeDown:o,flightTimeline:A,visibleAirportIatas:h,airports:k,target:r.target,selectedAirportIata:r.selectedAirportIata,onAirportClick:r.handleAirportClick,onViewportChange:r.onViewportChange,trackAirports:r.filteredTrackAirports,pinOnlyAirports:f,pinOnlyStatuses:p,flightArc:r.displayFlightArc,siblingArcs:r.displaySiblingArcs,recenterFlightSignal:r.recenterFlightSignal,fadedFlightArc:l?null:r.fadedFlightArc,onReselectFlight:l?void 0:r.reselectFadedFlight,flightWindow:!l&&r.isFlightActive?r.overallWindow:null,weatherScrub:l?null:r.weatherScrubFraction,playing:r.playing,scrubFraction:r.scrubFraction,layoverMarker:r.layoverMarker,showReturnToContext:!l&&r.showReturnToContext,onReturnToContext:r.returnToContext,flightTimelineVisible:!l&&m})]}),!l&&m&&r.overallWindow&&(0,c.jsx)(S,{segments:r.segments,overallWindow:r.overallWindow,scrubTime:r.scrubTime,onScrub:r.handleScrub,playing:r.playing,onTogglePlay:r.handleTogglePlay,onPrevLeg:r.handlePrevLeg,onNextLeg:r.handleNextLeg,canPrevLeg:r.canPrevLeg,canNextLeg:r.canNextLeg,onLive:r.handleLive,activeSegment:r.activeSegment})]})}var A=e.i(52236),R=e.i(74271),T=e.i(67491),E=e.i(75202),P=e.i(74518);function L(e,t){let r=new URLSearchParams(e.toString());for(let e of P.SELECTION_KEYS)r.delete(e);for(let[e,a]of(0,P.selectionParams)(t))r.set(e,a);return r}function I(){let e=(0,u.useRouter)(),t=(0,u.usePathname)(),r=(0,u.useSearchParams)();return[(0,d.useMemo)(()=>(0,P.parseSelection)(r),[r]),(0,d.useCallback)(a=>{(0,E.stopPlayback)();let n=L(r,a).toString();e.replace(n?`${t}?${n}`:t,{scroll:!1})},[t,e,r])]}var $=e.i(25913),M=e.i(81140),O=e.i(30030),z=e.i(84606),D=e.i(96626),F=e.i(48425),U=e.i(86318),q=e.i(69340),W=e.i(10772),B=Object.defineProperty,H=(e,t)=>B(e,"name",{value:t,configurable:!0}),K="Tabs",[G,V]=(0,O.createContextScope)(K,[z.createRovingFocusGroupScope]),Y=(0,z.createRovingFocusGroupScope)(),[J,X]=G(K),Z=d.forwardRef(H(function(e,t){let{__scopeTabs:r,value:a,onValueChange:n,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:s="automatic",...d}=e,u=(0,U.useDirection)(l),[f,p]=(0,q.useControllableState)({prop:a,onChange:n,defaultProp:i??"",caller:K});return(0,c.jsx)(J,{scope:r,baseId:(0,W.useId)(),value:f,onValueChange:p,orientation:o,dir:u,activationMode:s,children:(0,c.jsx)(F.Primitive.div,{dir:u,"data-orientation":o,...d,ref:t})})},"Tabs")),Q=d.forwardRef(H(function(e,t){let{__scopeTabs:r,loop:a=!0,...n}=e,i=X("TabsList",r),o=Y(r);return(0,c.jsx)(z.Root,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:a,children:(0,c.jsx)(F.Primitive.div,{role:"tablist","aria-orientation":i.orientation,...n,ref:t})})},"TabsList")),ee=d.forwardRef(H(function(e,t){let{__scopeTabs:r,value:a,disabled:n=!1,...i}=e,o=X("TabsTrigger",r),l=Y(r),s=er(o.baseId,a),d=ea(o.baseId,a),u=a===o.value;return(0,c.jsx)(z.Item,{asChild:!0,...l,focusable:!n,active:u,children:(0,c.jsx)(F.Primitive.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":n?"":void 0,disabled:n,id:s,...i,ref:t,onMouseDown:(0,M.composeEventHandlers)(e.onMouseDown,e=>{n||0!==e.button||!1!==e.ctrlKey?e.preventDefault():o.onValueChange(a)}),onKeyDown:(0,M.composeEventHandlers)(e.onKeyDown,e=>{!n&&e.target===e.currentTarget&&[" ","Enter"].includes(e.key)&&o.onValueChange(a)}),onFocus:(0,M.composeEventHandlers)(e.onFocus,()=>{let e="manual"!==o.activationMode;u||n||!e||o.onValueChange(a)})})})},"TabsTrigger")),et=d.forwardRef(H(function(e,t){let{__scopeTabs:r,value:a,forceMount:n,children:i,...o}=e,l=X("TabsContent",r),s=er(l.baseId,a),u=ea(l.baseId,a),f=a===l.value,p=d.useRef(f);return d.useEffect(()=>{let e=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,c.jsx)(D.Presence,{present:n||f,children:({present:r})=>(0,c.jsx)(F.Primitive.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":s,hidden:!r,id:u,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:r&&i})})},"TabsContent"));function er(e,t){return`${e}-trigger-${t}`}function ea(e,t){return`${e}-content-${t}`}H(er,"makeTriggerId"),H(ea,"makeContentId"),e.s(["Content",0,et,"List",0,Q,"Root",0,Z,"Tabs",0,Z,"TabsContent",0,et,"TabsList",0,Q,"TabsTrigger",0,ee,"Trigger",0,ee,"createTabsScope",0,V],26209);var en=e.i(26209),en=en;function ei({className:e,orientation:t="horizontal",...r}){return(0,c.jsx)(en.Root,{"data-slot":"tabs","data-orientation":t,orientation:t,className:(0,A.cn)("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...r})}let eo=(0,$.cva)("group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function el({className:e,variant:t="default",...r}){return(0,c.jsx)(en.List,{"data-slot":"tabs-list","data-variant":t,className:(0,A.cn)(eo({variant:t}),e),...r})}function es({className:e,...t}){return(0,c.jsx)(en.Trigger,{"data-slot":"tabs-trigger",className:(0,A.cn)("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function ec({className:e,...t}){return(0,c.jsx)(en.Content,{"data-slot":"tabs-content",className:(0,A.cn)("flex-1 outline-none",e),...t})}var ed=e.i(463),eu=e.i(22016);let ef="airport-intelligence-pinned",ep=new Set;function eh(){try{let e=localStorage.getItem(ef);return new Set(e?JSON.parse(e):[])}catch{return new Set}}function em(e){try{localStorage.setItem(ef,JSON.stringify([...e]))}catch{}ep.forEach(e=>e())}function eg(){return eh()}function eb(e){em(e)}function ev(){let[e,t]=(0,d.useState)(()=>new Set);return(0,d.useEffect)(()=>{t(eh());let e=()=>t(eh());return ep.add(e),()=>{ep.delete(e)}},[]),[e,(0,d.useCallback)(e=>{let t=new Set(eh());t.has(e)?t.delete(e):t.add(e),em(t)},[])]}function ey(e){return e*Math.PI/180}function ex(e,t){let r=ey(t.lat-e.lat),a=ey(t.lng-e.lng);return 7917.6*Math.asin(Math.sqrt(Math.sin(r/2)**2+Math.cos(ey(e.lat))*Math.cos(ey(t.lat))*Math.sin(a/2)**2))}var e_=e.i(44311),ew=e.i(54834);let eS={Argentina:"AR",Australia:"AU",Austria:"AT",Belgium:"BE",Brazil:"BR",Canada:"CA",Chile:"CL",China:"CN",Colombia:"CO",Cuba:"CU","Czech Republic":"CZ",Denmark:"DK",Ecuador:"EC",Egypt:"EG",Ethiopia:"ET",Finland:"FI",France:"FR",Germany:"DE",Ghana:"GH",Greece:"GR",Hungary:"HU",India:"IN",Indonesia:"ID",Ireland:"IE",Israel:"IL",Italy:"IT",Japan:"JP",Jordan:"JO",Kenya:"KE",Kuwait:"KW",Malaysia:"MY",Mexico:"MX",Morocco:"MA",Netherlands:"NL","New Zealand":"NZ",Nigeria:"NG",Norway:"NO",Peru:"PE",Philippines:"PH",Poland:"PL",Portugal:"PT",Qatar:"QA","Saudi Arabia":"SA",Singapore:"SG","South Africa":"ZA","South Korea":"KR",Spain:"ES","Sri Lanka":"LK",Sweden:"SE",Switzerland:"CH",Taiwan:"TW",Thailand:"TH",Turkey:"TR",UAE:"AE",UK:"GB",US:"US",Uruguay:"UY",Vietnam:"VN"},ej="favorite";function eC(e){let t=e.iataCode&&(0,v.getAirportByIata)(e.iataCode)?.timezone||"UTC";return{iata:e.iataCode??"",icao:e.icaoCode??"",name:e.displayName,city:e.city,country:e.country,lat:e.latitude,lng:e.longitude,timezone:t,rank:999}}var ek=e.i(40889);let eN="airport-intelligence-remote-location-map",eA=function(e){let{client:t,map:r,isUnavailable:a}=e,n=null,i=new Set,o=new Map;function l(){return n||(n=t.fetchLocations().then(e=>({available:!0,locations:e}),e=>(a(e)||(n=null),{available:!1,locations:[]}))),n}async function s(e){await o.get(e.iata);let{available:a}=await l();if(!a||r.load()[e.iata]||i.has(e.iata))return;let n=eS[e.country]??null;if(n){i.add(e.iata);try{let a=await t.createLocation({featureId:`airport.${e.iata.toLowerCase()}`,featureSource:"twc-poi",latitude:e.lat,longitude:e.lng,displayName:e.name,city:e.city,country:e.country,countryCode:n,iataCode:e.iata,icaoCode:e.icao||void 0,tags:[ej]}),i=r.load();i[e.iata]=a.id,r.save(i)}catch{}finally{i.delete(e.iata)}}}async function c(e,a){let{available:n,locations:i}=await l();if(!n)return null;let o=r.load(),c={},d=new Set;for(let e of i)e.iataCode&&e.id&&e.tags?.includes(ej)&&(d.add(e.iataCode),o[e.iataCode]=e.id,c[e.iataCode]=eC(e));for(let t of(r.save(o),e.filter(e=>!d.has(e)))){let e;try{e=a(t)}catch{continue}e&&await s(e)}let u=[];if(t.fetchLegacyLocations&&t.deleteLegacyLocation){let e=[];try{e=await t.fetchLegacyLocations()}catch{}for(let a of e){if(!a.iataCode||!a.id||!a.tags?.includes(ej))continue;let e=a.iataCode;try{d.has(e)||r.load()[e]||await s(eC(a)),(d.has(e)||r.load()[e])&&(await t.deleteLegacyLocation(a.id),u.push(e),c[e]??=eC(a))}catch{}}}return{iatas:[...new Set([...e,...d,...u])],extras:c}}return{pinned:s,unpinned:function(e){let a=(async()=>{let{available:a}=await l();if(!a)return;let n=r.load()[e];if(n)try{await t.deleteLocation(n);let a=r.load();delete a[e],r.save(a)}catch{}})().finally(()=>{o.get(e)===a&&o.delete(e)});return o.set(e,a),a},syncOnLoad:c,reset:function(){n=null}}}({client:{fetchLocations:()=>(0,ek.fetchLocations)(),createLocation:e=>(0,ek.createLocation)(e),fetchLegacyLocations:()=>(0,ek.fetchLegacyLocations)(),deleteLegacyLocation:e=>(0,ek.deleteLegacyLocation)(e),deleteLocation:e=>(0,ek.deleteLocation)(e)},map:{load:function(){try{let e=localStorage.getItem(eN);return e?JSON.parse(e):{}}catch{return{}}},save:function(e){try{localStorage.setItem(eN,JSON.stringify(e))}catch{}}},isUnavailable:e=>e instanceof ek.UpsxUnavailableError}),eR=eA.pinned,eT=eA.unpinned,eE=eA.syncOnLoad;var eP=e.i(64891),eL=e.i(30929),eI=e.i(9875);let e$="airport-intelligence-extra";async function eM(e){let t=await (0,eP.loadAirport)(e),r=t?.resource;if(!r?.status)return null;let a=r.airport;return{airport:(0,v.getAirportByIata)(a.iata??e)??{iata:a.iata??e.toUpperCase(),icao:a.icao,name:a.name,city:a.city,state:a.state??void 0,country:a.country,lat:a.position.lat,lng:a.position.lon,timezone:a.timezone,rank:999},status:r.status}}function eO(e,t){return e&&t.icao?(0,g.airportStatusOf)(e,t.icao)??void 0:void 0}function ez(e,t){return!e.status!=!t.status?e.status?-1:1:(0,g.compareAirportLevels)(e.status?.level??"unknown",t.status?.level??"unknown")||e.airport.iata.localeCompare(t.airport.iata)}function eD(e,t){return"alpha"===e?(e,t)=>e.iata.localeCompare(t.iata):"severity"===e?(e,r)=>ez({airport:e,status:eO(t,e)},{airport:r,status:eO(t,r)}):(e,t)=>e.rank-t.rank}function eF({airports:t,pinnableAirports:r=t,maxHeight:a="100%",airportStatuses:n,showHeaders:i,sortBy:o="rank",onAirportSelect:l,extraAirports:s=[],extraStatuses:u={},pinnedExtraIatas:f=new Set,onPinExtra:p,onPinExtraQuiet:m,onUnpinExtra:b,onSelectExtra:y,highlightedIatas:x,selectedIata:_,rowVariant:w="classic",onRemoveAirport:S,emptyState:j,autoFocus:C=!1}){let k="flint"===w,N=(0,d.useRef)(new Set),R=(0,d.useMemo)(()=>l?(e,t)=>{e.icao&&N.current.add(e.icao),l(e,t)}:void 0,[l]),T=i&&!k,[E,P]=(0,d.useState)(""),[L,I]=ev(),[$,M]=(0,d.useState)(null),[O,z]=(0,d.useState)("idle"),D=(0,d.useRef)(0),F=(0,d.useRef)(void 0);(0,d.useEffect)(()=>()=>{D.current+=1,clearTimeout(F.current)},[]);let[U,q]=(0,d.useState)({}),[W,B]=(0,d.useState)({}),H=(0,d.useRef)(null),[K,G]=(0,d.useState)(!1),[V,Y]=(0,d.useState)("all"),[J,X]=(0,d.useState)(null),Z=(0,d.useRef)(r);Z.current=r,(0,d.useEffect)(()=>{let e={};try{let t=localStorage.getItem(e$);t&&(e=JSON.parse(t)),q(e)}catch{}eE([...eg()],t=>Z.current.find(e=>e.iata===t)??e[t]).then(t=>{if(t){eb(new Set(t.iatas)),q(e=>({...e,...t.extras}));try{localStorage.setItem(e$,JSON.stringify({...e,...t.extras}))}catch{}}});let t=Object.keys(e);t.length>0&&Promise.all(t.map(eM)).then(e=>{e.forEach(e=>{e&&(q(t=>({...t,[e.airport.iata]:e.airport})),B(t=>({...t,[e.airport.icao]:e.status})))})})},[]),(0,d.useEffect)(()=>{let e=H.current;if(!e)return;let t=()=>G(e.scrollHeight>e.clientHeight+8&&e.scrollTop+e.clientHeighte.removeEventListener("scroll",t)},[]);let Q=(0,d.useRef)(_);(0,d.useEffect)(()=>{let e=Q.current!==_;Q.current=_,e&&_&&"pinned"===V&&!L.has(_)&&Y("all")},[_,V,L]),(0,d.useEffect)(()=>{let e=H.current;if(!_||!e)return;let t=e.querySelector(`[data-iata="${_}"]`);t?.scrollIntoView({block:"nearest"})},[_,V]),(0,d.useEffect)(()=>{E&&!J&&e.A(46984).then(e=>X(e.airportIndex))},[E,J]);let ee=(0,d.useCallback)(e=>{let t=L.has(e),a=r.find(t=>t.iata===e)??U[e];if(t&&S&&a)return void S(a);if(t){if(eT(e),!r.some(t=>t.iata===e)){q(t=>{let r={...t};delete r[e];try{localStorage.setItem(e$,JSON.stringify(r))}catch{}return r});let t=U[e]?.icao;t&&B(e=>{let r={...e};return delete r[t],r})}}else{let t=r.find(t=>t.iata===e)??U[e];t&&eR(t)}I(e)},[L,r,U,I,S]),et=e=>{let t={iata:e.iata,icao:"",name:e.name,city:e.city,country:e.iso_cc,lat:0,lng:0,timezone:"UTC",rank:999};q(r=>{let a={...r,[e.iata]:t};try{localStorage.setItem(e$,JSON.stringify(a))}catch{}return a}),I(e.iata),eM(e.iata).then(e=>{e&&(q(t=>{let r={...t,[e.airport.iata]:e.airport};try{localStorage.setItem(e$,JSON.stringify(r))}catch{}return r}),B(t=>({...t,[e.airport.icao]:e.status})),eR(e.airport))})},er=(0,d.useCallback)(()=>{if($){M(null),z("idle");return}if("locating"===O)return;if(!("geolocation"in navigator))return void z("unsupported");z("locating");let e=++D.current,t=t=>{e===D.current&&(D.current+=1,clearTimeout(F.current),t())};F.current=setTimeout(()=>t(()=>z("timeout")),15e3),navigator.geolocation.getCurrentPosition(e=>t(()=>{M({lat:e.coords.latitude,lng:e.coords.longitude}),z("idle")}),e=>t(()=>z(e.code===e.PERMISSION_DENIED?"denied":e.code===e.POSITION_UNAVAILABLE?"unavailable":"timeout")),{maximumAge:3e5,timeout:15e3})},[$,O]),ea=(0,d.useMemo)(()=>{if(!_)return x;let e=new Set(x??[]);return e.add(_),e},[x,_]),en=_?r.find(e=>e.iata===_)?.icao:void 0;en&&N.current.add(en);let ei=(0,g.hasAirportStatuses)(n&&Object.fromEntries(Object.entries(n).filter(([e])=>!N.current.has(e)))),eo=(0,d.useMemo)(()=>{let e,a,i=E.toLowerCase().trim();return[...i?(e=i.toLowerCase().trim())?r.filter(t=>t.iata.toLowerCase().includes(e)||t.city.toLowerCase().includes(e)||t.name.toLowerCase().includes(e)||(0,v.countryMatches)(t.country,e)):[]:k&&$?(a=e=>(0,eL.greatCircleDistanceMeters)([$.lng,$.lat],[e.lng,e.lat]),[...r].sort((e,t)=>a(e)-a(t))).slice(0,12):t].sort($?(e,t)=>ex($,e)-ex($,t):eD(o,n))},[t,r,E,o,ei,$,k]),el=(0,d.useMemo)(()=>r.filter(e=>L.has(e.iata)).sort(eD(o,n)),[r,L,o,n]),es=(0,d.useMemo)(()=>s.filter(e=>f.has(e.iata)).sort(eD(o,u)),[s,f,o,u]),ec=(0,d.useMemo)(()=>Object.values(U).filter(e=>L.has(e.iata)).sort(eD(o,W)),[U,L,o,W]),eu=(0,d.useMemo)(()=>{let e=new Set,t=[];for(let r of el)e.has(r.iata)||(e.add(r.iata),t.push({airport:r,status:eO(n,r),onSelect:R?()=>R(r):void 0,onTogglePin:()=>ee(r.iata)}));for(let r of ec)e.has(r.iata)||(e.add(r.iata),t.push({airport:r,status:eO(W,r),onSelect:R&&0!==r.lat?()=>R(r):p?()=>p(r.iata,{known:{name:r.name,city:r.city}}):void 0,onTogglePin:()=>ee(r.iata)}));for(let r of es)e.has(r.iata)||(e.add(r.iata),t.push({airport:r,status:eO(u,r),onSelect:y?()=>y(r):void 0,onTogglePin:()=>b?.(r.iata)}));return t.sort((e,t)=>"alpha"===o?e.airport.iata.localeCompare(t.airport.iata):"severity"===o?ez(e,t):e.airport.rank-t.airport.rank),t},[el,ec,es,n,W,u,R,p,y,b,ee,o]);(0,d.useEffect)(()=>{"pinned"===V&&0===eu.length&&Y("all")},[V,eu.length]);let ef=(0,d.useMemo)(()=>{let e=E.toLowerCase().trim();return e?eu.filter(t=>t.airport.iata.toLowerCase().includes(e)||t.airport.city.toLowerCase().includes(e)||t.airport.name.toLowerCase().includes(e)||(0,v.countryMatches)(t.airport.country,e)):eu},[eu,E]),ep=(0,d.useMemo)(()=>{var e;let t;return J?(e=new Set(r.map(e=>e.iata)),(t=E.toLowerCase().trim())?J.filter(r=>!e.has(r.iata)&&(r.iata.toLowerCase().includes(t)||r.name.toLowerCase().includes(t)||r.city.toLowerCase().includes(t)||r.iso_cc.toLowerCase().includes(t))).slice(0,6):[]):[]},[E,J,r]),eh="denied"===O?"Location access was denied.":"unsupported"===O?"Location isn’t available in this browser.":"unavailable"===O?"Your device couldn’t find your location. Check that location services are on.":"timeout"===O?"Couldn’t get your location. Please try again.":null;return(0,c.jsxs)("div",{className:"flex h-full flex-col",children:[k?(0,c.jsxs)("div",{className:"shrink-0 px-4 pt-3",children:[(0,c.jsxs)("div",{className:"flex h-8.75 items-center gap-inline-sm rounded-full border-[1.5px] border-transparent bg-surface pr-1 pl-3.5 text-fg-tertiary hover-ring transition-hover focus-within:border-interactive focus-within:ring-4 focus-within:ring-interactive/20",children:[(0,c.jsx)(h.Search,{size:16,"aria-hidden":!0,className:"shrink-0"}),(0,c.jsx)("input",{type:"search","data-testid":"airport-search-input","aria-label":"Search airports",placeholder:"Search airports",value:E,autoFocus:C,enterKeyHint:"search",onChange:e=>P(e.target.value),className:"h-full min-w-0 flex-1 bg-transparent text-search text-fg outline-none placeholder:text-fg-tertiary [&::-webkit-search-cancel-button]:hidden"}),E&&(0,c.jsx)("button",{type:"button",onClick:()=>P(""),"aria-label":"Clear search",className:"flex size-7 shrink-0 press-92 items-center justify-center rounded-full text-fg-tertiary hover:text-fg focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none",children:(0,c.jsx)(h.X,{size:14,"aria-hidden":"true"})}),(0,c.jsx)("button",{type:"button","data-testid":"airport-search-nearby",onClick:er,disabled:"locating"===O,"aria-busy":"locating"===O||void 0,"aria-label":"Nearest airports first","aria-pressed":!!$,title:"Nearest airports first",className:(0,A.cn)("flex size-7 shrink-0 press-92 items-center justify-center rounded-full focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none disabled:opacity-60",$?"bg-interactive text-fg-on-interactive":"text-fg-secondary hover:bg-surface-muted hover:text-fg"),children:(0,c.jsx)(ed.LocateFixed,{size:15,"aria-hidden":"true"})})]}),eh&&(0,c.jsx)("p",{role:"status",className:"mt-1.5 px-3.5 text-caption text-fg-secondary",children:eh})]}):(0,c.jsxs)("div",{className:"px-4 py-3",style:{borderBottom:"1px solid var(--border-color-subtle)"},children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,c.jsxs)("svg",{className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-fg-tertiary)",strokeWidth:"2",children:[(0,c.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,c.jsx)("path",{d:"M21 21l-4.35-4.35"})]}),(0,c.jsx)("input",{type:"text",placeholder:"Search airports…",value:E,onChange:e=>P(e.target.value),className:"w-full rounded-md py-2 pr-8 pl-9 text-sm transition-colors outline-none",style:{backgroundColor:"var(--color-surface-sunken)",color:"var(--color-fg)",border:"1px solid var(--border-color-subtle)"}}),E&&(0,c.jsx)("button",{onClick:()=>P(""),"aria-label":"Clear search",className:"absolute top-1/2 right-2 -translate-y-1/2",style:{background:"transparent",border:"none",cursor:"pointer",color:"var(--color-fg-tertiary)",padding:2,display:"flex"},children:(0,c.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,c.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,c.jsx)("button",{onClick:er,disabled:"locating"===O,"aria-label":$?"Sorting by nearby airports — click to reset":"Sort by nearby airports","aria-pressed":!!$,title:"Sort by nearby airports",className:"flex shrink-0 items-center justify-center rounded-md p-2 transition-colors disabled:opacity-60",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:$?"var(--color-interactive)":"var(--color-surface-sunken)",color:$?"var(--color-fg-on-solid)":"var(--color-fg-secondary)"},children:(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,c.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"5"}),(0,c.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"22"}),(0,c.jsx)("line",{x1:"2",y1:"12",x2:"5",y2:"12"}),(0,c.jsx)("line",{x1:"19",y1:"12",x2:"22",y2:"12"})]})})]}),"denied"===O&&(0,c.jsx)("p",{className:"mt-1.5 text-xs",style:{color:"var(--color-fg-tertiary)"},children:"Location access was denied."}),"unsupported"===O&&(0,c.jsx)("p",{className:"mt-1.5 text-xs",style:{color:"var(--color-fg-tertiary)"},children:"Location isn't available in this browser."}),"unavailable"===O&&(0,c.jsx)("p",{className:"mt-1.5 text-xs",style:{color:"var(--color-fg-tertiary)"},children:"Your device couldn't find your location. Check that location services are on."}),"timeout"===O&&(0,c.jsx)("p",{className:"mt-1.5 text-xs",style:{color:"var(--color-fg-tertiary)"},children:"Couldn't get your location. Please try again."})]}),(0,c.jsx)("div",{className:`flex min-h-0 flex-1 flex-col ${T?"overflow-x-auto":""}`,children:(0,c.jsxs)("div",{className:`flex min-h-0 flex-1 flex-col ${T?"min-w-[840px] md:min-w-0":""}`,children:[T&&(0,c.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2",style:{borderBottom:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)",flexShrink:0},children:[(0,c.jsx)("div",{style:{width:64,flexShrink:0},children:(0,c.jsx)("span",{className:"text-xs font-semibold tracking-wider uppercase",style:{color:"var(--color-fg-tertiary)"},children:"Airport"})}),(0,c.jsx)("div",{className:"min-w-0",style:{flex:"1 1 0%"}}),(0,c.jsx)("div",{style:{width:130,flexShrink:0},children:(0,c.jsx)("span",{className:"text-xs font-semibold tracking-wider uppercase",style:{color:"var(--color-fg-tertiary)"},children:"City"})}),(0,c.jsx)("div",{style:{width:180,flexShrink:0},children:(0,c.jsx)("span",{className:"text-xs font-semibold tracking-wider uppercase",style:{color:"var(--color-fg-tertiary)"},children:"Time Zone"})}),(0,c.jsx)("div",{style:{width:140,flexShrink:0},children:(0,c.jsx)("span",{className:"text-xs font-semibold tracking-wider uppercase",style:{color:"var(--color-fg-tertiary)"},children:"Departures"})}),(0,c.jsx)("div",{style:{width:140,flexShrink:0},children:(0,c.jsx)("span",{className:"text-xs font-semibold tracking-wider uppercase",style:{color:"var(--color-fg-tertiary)"},children:"Arrivals"})}),(0,c.jsx)("div",{style:{width:18,flexShrink:0}}),(0,c.jsx)("div",{style:{width:13,flexShrink:0}}),(0,c.jsx)("div",{style:{width:14,flexShrink:0}})]}),!k&&eu.length>0&&(0,c.jsxs)("div",{className:"flex items-center gap-1 px-4 py-2",style:{borderBottom:"1px solid var(--border-color-subtle)",flexShrink:0},children:[(0,c.jsx)("button",{type:"button",onClick:()=>Y("all"),className:"rounded-md px-2.5 py-1 text-xs font-semibold transition-colors",style:{backgroundColor:"all"===V?"var(--color-interactive)":"transparent",color:"all"===V?"var(--color-fg-on-solid)":"var(--color-fg-secondary)"},children:"All"}),(0,c.jsxs)("button",{type:"button",onClick:()=>Y("pinned"),className:"rounded-md px-2.5 py-1 text-xs font-semibold transition-colors",style:{backgroundColor:"pinned"===V?"var(--color-interactive)":"transparent",color:"pinned"===V?"var(--color-fg-on-solid)":"var(--color-fg-secondary)"},children:["Pinned (",eu.length,")"]})]}),(0,c.jsxs)("div",{style:{position:"relative",flex:1,minHeight:0},children:[(0,c.jsx)("div",{ref:H,className:(0,A.cn)("overflow-y-auto",k&&"scrollbar-none scroll-pt-3 [mask-image:linear-gradient(to_bottom,transparent,black_12px)] pt-3"),style:{maxHeight:a,height:"100%"},children:"pinned"===V?0===ef.length?(0,c.jsx)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:(0,c.jsxs)("p",{className:"text-sm",style:{color:"var(--color-fg-secondary)"},children:["No pinned airports match “",E.trim(),"”."]})}):(0,c.jsx)("ul",{className:k?"space-y-2 px-4 pt-2 pb-4":void 0,children:ef.map(e=>(0,c.jsx)("li",{"data-iata":e.airport.iata,children:(0,c.jsx)(ew.default,{airport:e.airport,status:e.status,onSelect:e.onSelect,pinned:!0,onTogglePin:e.onTogglePin,highlighted:ea?.has(e.airport.iata)})},e.airport.iata))}):(0,c.jsxs)(c.Fragment,{children:[k&&$&&!E.trim()&&eo.length>0&&(0,c.jsx)("p",{className:"px-4 pb-2 text-overline text-fg-tertiary",children:"Nearest to you"}),(0,c.jsx)(e_.default,{rowVariant:w,emptyState:E.trim()?void 0:j,airports:eo,airportStatuses:n,onAirportSelect:R?e=>{0===e.lat&&p?p(e.iata,{known:{name:e.name,city:e.city}}):R(e,{searched:!!E.trim()}),P("")}:void 0,pinnedIatas:L,onTogglePin:ee,onRemoveAirport:S,highlightedIatas:ea,hideEmptyState:!!E.trim()}),E.trim()&&0===eo.length&&0===ep.length&&(0,c.jsx)("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:(0,c.jsxs)("p",{className:"max-w-full text-sm wrap-anywhere",style:{color:"var(--color-fg-secondary)"},children:["No airports found for “",E.trim(),"”."]})}),k&&ep.length>0&&(0,c.jsxs)("div",{"data-testid":"airport-search-more",children:[(0,c.jsx)("p",{className:"px-4 pt-1 pb-2 text-overline text-fg-tertiary",children:"More airports"}),(0,c.jsx)("ul",{className:"space-y-2 px-4 pb-4",children:ep.map(e=>(0,c.jsx)("li",{children:(0,c.jsxs)("button",{type:"button",onClick:()=>{p?p(e.iata,{known:{name:e.name,city:e.city}}):et(e),P("")},className:"flex min-h-16 w-full press-97 items-center gap-3 rounded-card bg-surface py-1.5 pr-4 pl-4 text-left hover-ring focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none",children:[(0,c.jsx)("span",{className:"w-13 shrink-0 text-route text-fg",children:e.iata}),(0,c.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,c.jsx)("span",{className:"block truncate text-row-title text-fg",children:e.city?`${e.city}, ${e.iso_cc}`:e.iso_cc}),(0,c.jsx)("span",{className:"mt-0.75 block truncate text-row-note text-fg-secondary",children:e.name})]})]})},e.iata))})]}),!k&&ep.length>0&&(0,c.jsxs)("div",{style:{borderTop:"2px solid var(--border-color-subtle)"},children:[(0,c.jsxs)("div",{className:"flex items-center gap-1.5 px-4 py-1.5",style:{backgroundColor:"var(--color-surface-sunken)",borderBottom:"1px solid var(--border-color-subtle)"},children:[(0,c.jsxs)("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-fg-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,c.jsx)("path",{d:"M21 21l-4.35-4.35"})]}),(0,c.jsx)("span",{className:"text-xs font-semibold tracking-wider uppercase",style:{color:"var(--color-fg-tertiary)"},children:"More airports"})]}),(0,c.jsx)("ul",{children:ep.map(e=>(0,c.jsx)("li",{children:(0,c.jsx)(eU,{entry:e,isPinned:f.has(e.iata)||L.has(e.iata),onPin:()=>{f.has(e.iata)?b?.(e.iata):L.has(e.iata)?ee(e.iata):m?m(e.iata):et(e)},onNavigate:p?()=>{p(e.iata,{known:{name:e.name,city:e.city}}),P("")}:void 0})},e.iata))})]})]})}),K&&(0,c.jsx)("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:72,background:"linear-gradient(to bottom, transparent, var(--color-surface))",pointerEvents:"none"}})]})]})})]})}function eU({entry:e,isPinned:t,onPin:r,onNavigate:a}){let n="group flex items-center gap-3 px-4 py-3 transition-colors hover:bg-surface-sunken",i={borderBottom:"1px solid var(--border-color-subtle)"};if(a)return(0,c.jsxs)("div",{onClick:a,className:`cursor-pointer ${n}`,style:i,children:[(0,c.jsxs)("div",{style:{width:64,flexShrink:0},className:"flex items-center gap-1.5",children:[(0,c.jsx)("div",{style:{width:14,flexShrink:0}}),(0,c.jsx)("span",{className:"font-mono text-sm font-bold",style:{color:"var(--color-fg-interactive)"},children:e.iata})]}),(0,c.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,c.jsx)("p",{className:"truncate text-sm",style:{color:"var(--color-fg)"},children:e.name}),(0,c.jsx)("p",{className:"text-xs",style:{color:"var(--color-fg-secondary)"},children:e.city?`${e.city}, ${e.iso_cc}`:e.iso_cc})]}),(0,c.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),r()},className:`-m-1 flex-shrink-0 rounded p-1 transition-colors hover:bg-surface-muted ${t?"":"opacity-0 group-hover:opacity-100"}`,style:{color:t?"var(--color-fg-interactive)":"var(--color-fg-disabled)"},"aria-label":`${t?"Unpin":"Pin"} airport ${e.iata}`,children:(0,c.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),(0,c.jsx)("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17z"})]})})]});let o=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{style:{width:64,flexShrink:0},className:"flex items-center gap-1.5",children:[(0,c.jsx)("div",{style:{width:14,flexShrink:0}}),(0,c.jsx)("span",{className:"font-mono text-sm font-bold",style:{color:"var(--color-fg-interactive)"},children:e.iata})]}),(0,c.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,c.jsx)("p",{className:"truncate text-sm",style:{color:"var(--color-fg)"},children:e.name}),(0,c.jsx)("p",{className:"text-xs",style:{color:"var(--color-fg-secondary)"},children:e.city?`${e.city}, ${e.iso_cc}`:e.iso_cc})]}),(0,c.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),r()},className:`-m-1 flex-shrink-0 rounded p-1 transition-colors hover:bg-surface-muted ${t?"":"opacity-0 group-hover:opacity-100"}`,style:{color:t?"var(--color-fg-interactive)":"var(--color-fg-disabled)"},"aria-label":`${t?"Unpin":"Pin"} airport ${e.iata}`,children:(0,c.jsxs)("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"22"}),(0,c.jsx)("path",{d:"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V17z"})]})}),(0,c.jsx)("div",{className:"flex-shrink-0 opacity-0 transition-opacity group-hover:opacity-100",style:{color:"var(--color-fg-disabled)"},children:(0,c.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,c.jsx)("path",{d:"M9 18l6-6-6-6"})})})]});return e.icao?(0,c.jsx)(eu.default,{href:`${(0,eI.scopeFor)()}?icao=${e.icao}`,className:n,style:i,children:o}):(0,c.jsx)("div",{className:n,style:i,children:o})}var eq=e.i(73052),eW=e.i(84275),eB=e.i(38160),eH=e.i(2194);function eK(e){let{out:t,in:r}=(0,eW.legGateTimes)(e),a=e=>e&&Date.parse(e)||0;return Math.max(a(r.actual),a(t.actual),a(r.estimated),a(t.estimated))}var eG=e.i(2052),eV=e.i(67512);function eY(e){let t=(0,eW.legBookedTimes)(e);return!!t.departure&&!!t.arrival}function eJ(e){return e.legs.length>0&&e.legs.every(eY)}function eX(e){let t;if(!eY(e))throw Error(`legToUpsx: leg ${e.id} has no concrete departure/arrival time — check itineraryIsSyncable before mapping.`);let{airlineIata:r,flightNumber:a}=(t=e.identIata.match(/^([A-Z0-9]{2})(\d+)$/))?{airlineIata:t[1],flightNumber:t[2]}:{},n=(0,eW.legBookedTimes)(e);return{departure:e.originIata??void 0,arrival:e.destinationIata??void 0,departureDate:n.departure,arrivalDate:n.arrival,flightDetails:{airlineIata:r,flightNumber:a,identIcao:e.identIcao??void 0,faFlightId:e.faFlightId??void 0}}}function eZ(e){if(!function(e){let t=e.legs.filter(e=>"return"===e.journeyLabel).map(e=>(0,eW.legBookedTimes)(e).departure).filter(e=>!!e);if(0===t.length)return!0;let r=t.reduce((e,t)=>e"return"===e.journeyLabel),r=e.legs.filter(e=>"return"!==e.journeyLabel);return{name:e.name,journeys:[{label:"outbound",legs:r.map(eX)},...t.length>0?[{label:"return",legs:t.map(eX)}]:[]]}}function eQ(e){let t=e.journeys.flatMap(t=>{let r=null,a=null;return t.legs.map(n=>{var i,o;let l,s=n.flightDetails?.airlineIata&&n.flightDetails?.flightNumber?`${n.flightDetails.airlineIata}${n.flightDetails.flightNumber}`:"",c=n.id??(0,eV.newId)(),d=a&&n.departure&&n.departure===a?r:null;return r=c,a=n.arrival??null,{id:c,identIata:s,identIcao:n.flightDetails?.identIcao??null,faFlightId:n.flightDetails?.faFlightId??null,scheduledDate:(i=n.departureDate,(l=(o=n.departure??null)?(0,v.getAirportByIata)(o)?.timezone:void 0)?(0,eG.localDateStr)(i,l):i.slice(0,10)),originIata:n.departure??null,destinationIata:n.arrival??null,scheduledDepartureAt:n.departureDate,scheduledArrivalAt:n.arrivalDate,snapshot:null,dataSource:"schedule",addedAt:e.createdAt,journeyLabel:t.label,connectedToLegId:d}})});return{id:e.id,name:e.name??"",legs:t,createdAt:e.createdAt,updatedAt:e.updatedAt}}var e0=e.i(96615);let e1="seen:",e2="del:",e5="meta:",e4=`${e5}platform`,e3=`${e5}twc-merged`;function e6(e){return 0===e.legs.length?null:e.legs.map(e=>[e.identIata,e.scheduledDate,e.originIata??"",e.destinationIata??""].join("|")).sort().join(";")}function e8(e,t){let r=new Date(t-864e5).toISOString().slice(0,10);return e.legs.some(e=>e.scheduledDate>=r)}function e9(e){let t=[`${e.identIata}|${e.scheduledDate}`];return e.faFlightId&&t.push(`fa:${e.faFlightId}`),t}let e7="airport-intelligence-remote-trip-map",te="airport-intelligence-remote-trip-owner";function tt(e){try{e?localStorage.setItem(te,e):localStorage.removeItem(te)}catch{}}function tr(){try{let e=localStorage.getItem(e7);return e?JSON.parse(e):{}}catch{return{}}}function ta(e){try{localStorage.setItem(e7,JSON.stringify(e))}catch{}}let tn=function(e){let{client:t,map:r}=e,a=e.now??Date.now,n=null;async function i(r,n){let i;try{i=await e.sharedClient.fetchTrips()}catch{return!1}let o=new Set;for(let e of[...r.flatMap(e=>eQ(e).legs),...n.flatMap(e=>e.legs)])for(let t of e9(e))o.add(t);let l=!0;for(let e of i){let n=eQ(e);if(e8(n,a())&&!n.legs.every(e=>e9(e).some(e=>o.has(e)))){try{r.push(await t.createTrip({name:e.name,journeys:e.journeys.map(e=>({label:e.label,legs:e.legs.map(e=>{let t={...e};return delete t.id,t})}))}))}catch{l=!1;continue}for(let e of n.legs)for(let t of e9(e))o.add(t)}}return l}async function o(n){try{let l=await t.fetchTrips(),s=r.load();s[e4]!==e0.UPSX_TRIPS_PLATFORM&&(s={[e4]:e0.UPSX_TRIPS_PLATFORM}),e.sharedClient&&!s[e3]&&await i(l,n)&&(s[e3]="1");let c=Object.keys(s).filter(e=>e.startsWith(e2)).map(e=>e.slice(e2.length)),d=new Set(l.map(e=>e.id));for(let e of c){if(d.has(e))try{await t.deleteTrip(e)}catch{continue}delete s[e2+e]}let u=new Set(Object.keys(s).filter(e=>e.startsWith(e2)).map(e=>e.slice(e2.length))),f=l.filter(e=>!u.has(e.id)&&!c.includes(e.id)),p=function(e,t){let r=new Map;for(let e of t)for(let t of e.legs){if(!(0,eH.hasLiveData)(t))continue;let e=(0,eH.flightKey)(t),a=r.get(e);(!a||eK(t)>=eK(a))&&r.set(e,t)}return 0===r.size?e:e.map(e=>({...e,legs:e.legs.map(e=>{if((0,eH.hasLiveData)(e))return e;let t=r.get((0,eH.flightKey)(e));return t?.snapshot?{...e,snapshot:t.snapshot,refreshedAt:t.refreshedAt,dataSource:t.dataSource,faFlightId:e.faFlightId??t.faFlightId,identIcao:e.identIcao??t.identIcao,previousGateOrigin:t.previousGateOrigin,previousGateDestination:t.previousGateDestination,gateChangedAt:t.gateChangedAt}:e})}))}(f.map(eQ),n);var o=s;for(let e of p){let t=n.find(t=>t.id===e.id||o[t.id]===e.id);if(!t)continue;let r=new Map;for(let e of t.legs)r.set((0,eH.flightKey)(e),e.id);for(let t of e.legs){let e=r.get((0,eH.flightKey)(t));e&&(t.id=e)}}let h=new Set(Object.keys(s).filter(e=>e.startsWith(e1)).map(e=>e.slice(e1.length)));for(let e of p)s[e.id]=e.id,s[e1+e.id]="1";let m=new Set(p.map(e=>e.id)),g=[...p];for(let e of n){let n=s[e.id];if(!(n&&m.has(n))){if(n){if(h.has(n)&&e8(e,a())){for(let e of Object.keys(s))s[e]===n&&delete s[e];delete s[e1+n];continue}g.push(e);continue}if(eJ(e))try{let a=await t.createTrip(eZ(e));s[e.id]=a.id,s[a.id]=a.id,r.save(s),g.push(eQ(a));continue}catch{}g.push(e)}}r.save(s);let b=e=>e.legs.filter(e=>e.snapshot).length,v=new Map;for(let e of g){let t=e6(e);if(null===t)continue;let r=v.get(t);(!r||b(e)>b(r))&&v.set(t,e)}return g.filter(e=>{let t=e6(e);return null===t||v.get(t)===e})}catch(t){if(e.isSignedOut?.(t))throw t;return null}}return{pull:e=>n??=o(e).finally(()=>{n=null}),async push(e){if(!eJ(e))return;let a=r.load(),n=a[e.id];try{if(n)await t.updateTrip(n,eZ(e));else{let n=await t.createTrip(eZ(e));a[e.id]=n.id,r.save(a)}}catch{}},async remove(e){let a=r.load(),n=a[e];if(n){a[e2+n]="1",r.save(a);try{await t.deleteTrip(n);let e=r.load();for(let t of Object.keys(e))e[t]===n&&delete e[t];delete e[e1+n],delete e[e2+n],r.save(e)}catch{}}},cancelRemove(e){let t=r.load(),a=t[e];a&&t[e2+a]&&(delete t[e2+a],r.save(t))}}}({client:{fetchTrips:()=>(0,ek.fetchTrips)(),createTrip:e=>(0,ek.createTrip)(e),updateTrip:(e,t)=>(0,ek.updateTrip)(e,t),deleteTrip:e=>(0,ek.deleteTrip)(e)},sharedClient:{fetchTrips:()=>(0,ek.fetchSharedTrips)()},map:{load:tr,save:ta},isSignedOut:e=>e instanceof ek.UpsxUnavailableError});async function ti(e){let t,r=function(){try{return localStorage.getItem(te)}catch{return null}}(),a=null;if(r){try{a=await (0,ek.fetchAccountId)()}catch(e){if(!(e instanceof ek.UpsxUnavailableError))return null}a&&a!==r&&((0,eq.saveItineraries)([]),ta({}),tt(null),e=[])}try{t=await tn.pull(e)}catch{return function(){var e;let t,r=(0,eq.loadItineraries)(),a=(e=r,t=new Set(Object.keys(tr()).filter(e=>!e.startsWith(e1)&&!e.startsWith(e2)&&!e.startsWith(e5))),e.filter(e=>!t.has(e.id)));a.length!==r.length&&(0,eq.saveItineraries)(a);try{localStorage.removeItem(e7)}catch{}tt(null)}(),null}return t&&(a?tt(a):(0,ek.fetchAccountId)().then(tt,()=>{})),t}var to=e.i(47167);e.i(71725);var tl=e.i(10751),ts=e.i(27629),tc=e.i(6658),td=e.i(11084),tu=e.i(55294),tf=e.i(82697),tp=e.i(57556),th=e.i(21291),tm=e.i(55529),tg=e.i(55104),tb=e.i(47448),tv=e.i(37202),ty=e.i(7746);let tx={low:{label:"Low",color:"var(--color-fg-success)",bg:"var(--color-success-subtle)"},elevated:{label:"Elevated",color:"var(--color-fg-warning)",bg:"var(--color-warning-subtle)"},high:{label:"High",color:"var(--color-fg-danger)",bg:"var(--color-danger-subtle)"}},t_={live:"Based on current conditions",forecast:"Based on forecast","beyond-forecast":"Beyond forecast range"},tw=e=>e.factors.slice(0,3),tS=(e,t)=>!!e&&tw(e).some(e=>e.kind===t);function tj({risk:e,inboundNote:t}){if("unknown"===e.level)return null;let r=tx[e.level],a=tw(e);return(0,c.jsxs)("div",{"data-testid":"weather-risk","data-risk-level":e.level,className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-xs",title:`${t_[e.horizon]} \xb7 ${e.confidence} confidence`,children:[(0,c.jsxs)("span",{className:"rounded px-1.5 py-0.5 font-bold tracking-wide uppercase",style:{color:r.color,backgroundColor:r.bg},children:["Delay risk: ",r.label]}),a.map(e=>(0,c.jsx)("span",{title:"inbound-late"===e.kind?t:void 0,className:"rounded-full px-2 py-0.5",style:{color:"var(--color-fg-secondary)",backgroundColor:"var(--color-surface-muted)",border:"1px solid var(--border-color-subtle)"},children:e.label},`${e.kind}-${e.end}`))]})}var tC=e.i(75787);function tk({changes:e}){return 0===e.length?null:(0,c.jsx)("div",{"data-testid":"gate-change",className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-xs",children:e.map(e=>(0,c.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-semibold",style:{color:"var(--color-fg-warning)",backgroundColor:"var(--color-warning-subtle)",border:"1px solid var(--border-color-warning-subtle)"},children:[(0,c.jsx)(tC.DoorOpen,{size:12,"aria-hidden":"true"}),e.label," gate changed: ",e.to," (was ",e.from,")"]},e.label))})}var tN=e.i(46470),tA=e.i(76818),tR=e.i(7212);function tT({stats:e,omitBaseline:t=!1}){let r=e.flight&&e.flight.n>=tR.MIN_FLIGHT_N?e.flight:null,a=e.route&&e.route.n>=tR.MIN_ROUTE_N?e.route:null,n=r??a,i=e.recent&&e.recent.n>0?e.recent:null,o=n&&!t;if(!o&&!i)return null;let l=[];if(o){let t=n.cancelled>0?`, ${n.cancelled} cancelled`:"";l.push(`${r?"Late on":"Route late on"} ${n.late} of ${n.n} flights (${e.windowLabel}${t})`)}if(i){let e=i.cancelled>0?`, ${i.cancelled} cancelled`:"";l.push(`Last ${i.days} days: late on ${i.lateArrivals} of ${i.n}${e}`)}return(0,c.jsx)("p",{"data-testid":"flight-history",className:"mt-1 text-xs",style:{color:"var(--color-fg-secondary)"},title:"Late = cancelled or arrived 15+ minutes behind schedule. Source: BTS On-Time Performance.",children:l.join(" · ")})}var tE=e.i(97510),tP=e.i(31590),tL=e.i(81789),tI=e.i(70053),t$=e.i(51871),tM=e.i(22786),tO=e.i(42132),tz=e.i(2586);let tD={neutral:"var(--color-fg-secondary)",info:"var(--color-fg-info)",success:"var(--color-fg-success)",warning:"var(--color-fg-warning)",danger:"var(--color-fg-danger)"};function tF(e,t){if(!e)return"—";try{return new Intl.DateTimeFormat("en-US",{timeZone:t,hour:"numeric",minute:"2-digit",hour12:!0}).format(new Date(e))}catch{return"—"}}function tU(e,t){if(!e)return"";try{return new Intl.DateTimeFormat("en-US",{timeZone:t,month:"short",day:"numeric"}).format(new Date(e))}catch{return""}}function tq(e){if(e0,_=!!y?.late&&(y.minutes??0)>0,w=l?.inbound??null,S=w?.delay.arrivalMinutes??null,j=w?.times.gateIn.best??null,C=l?.status==="airborne",k=l?.progressPercent,N=l?.position?.altitudeFt??null,A=l?.position?.groundspeedKt??null,R=(0,tb.useAirportTimezone)(e.originIata),T=(0,tb.useAirportTimezone)(e.destinationIata),E=l?.origin.timezone??R,P=l?.destination.timezone??T,L=l?null:(0,tm.bookedFlightOverview)(e,s??0,void 0,t=>t===e.originIata?R:T),I=l?tF(g,E):L?.departure.time??"—",$=l?tF(b,P):L?.arrival.time??"—",M=w&&j?`${w.ident.iata??w.ident.icao}${w.origin.iata?` from ${w.origin.iata}`:""} ${"landed"===w.status||"arrived"===w.status?"landed":"arrives"} ${tF(j,E)}${w.late&&null!=S&&S>0?` (+${S}m late)`:" on time"}`:null,O=(0,th.useLegRisk)(e),z=(0,tN.useGateChanges)(e),D=(0,tN.useInboundMemory)(e),F=(o=(0,tP.knownDelayMinutes)(e),(0,tE.shouldShowRisk)(O,o)),U=function(e,t={}){(0,t$.useStoreVersion)();let r=tM.WEATHER_RISK_ENABLED&&(t.withRecent??!1),{data:a}=(0,tL.useFlightResource)(r?(0,tL.legRef)(e):null);if(!tM.WEATHER_RISK_ENABLED)return null;let n=r?a?.history:e?(0,tL.v1HistoryFor)(e):null;return n?(0,tI.historyStatsFromV1)(n):null}(e,{withRecent:!0}),q=(0,th.useLegRisk)(n??null),W=(0,td.useWeatherConnectionAccess)(),B=!!a&&(q?.level==="elevated"||q?.level==="high"||O?.level==="high"),H=a&&W?(0,tO.escalateConnection)(a,q,O):a,K=H?tv.RISK_CONFIG[H.riskLevel]:null,G="return"===e.journeyLabel?(0,c.jsx)("span",{className:"rounded px-1.5 py-0.5 text-xs font-bold tracking-wide uppercase",style:{color:"var(--color-fg-interactive)",backgroundColor:"var(--color-interactive-subtle)"},children:"Return"}):null,V=H&&K?(0,c.jsxs)("div",{"data-testid":"connection-risk","data-risk-level":H.riskLevel,"data-weather-adjusted":H.weatherAdjusted?"true":"false",className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 px-4 py-1.5 text-xs",style:{backgroundColor:K.bg},children:[(0,c.jsx)("span",{className:"font-bold tracking-wider uppercase",style:{color:K.color},children:K.label}),(0,c.jsxs)("span",{style:{color:"var(--color-fg-secondary)"},children:["Layover"," ",(0,c.jsx)("span",{className:"font-semibold",style:{color:K.color},children:tq(H.estimatedLayoverMinutes)})]}),(0,c.jsxs)("span",{style:{color:"var(--color-fg-disabled)"},children:["MCT ",tq(H.minimumConnectionMinutes)]}),H.weatherAdjusted&&H.baseRiskLevel&&(0,c.jsxs)("span",{style:{color:"var(--color-fg-secondary)"},children:["Was ",tv.RISK_CONFIG[H.baseRiskLevel].label," · ","budgeting ",H.extraDelayMinutes,"m for delay risk",H.weatherFactors?.[0]&&` (${H.weatherFactors[0].label})`]}),!W&&B&&(0,c.jsx)("span",{style:{color:"var(--color-fg-interactive)"},children:"Delay risk could affect this connection — sign in for weather-aware connection risk"})]}):null;if("intent"===e.dataSource)return(0,c.jsxs)("div",{"data-testid":"leg-row","data-ident-iata":e.identIata,"data-origin-iata":e.originIata??"","data-destination-iata":e.destinationIata??"","data-fa-flight-id":e.faFlightId??"","data-scheduled-date":e.scheduledDate,"data-data-source":e.dataSource,className:"overflow-hidden rounded-lg",style:{backgroundColor:"var(--color-surface)",border:"1px solid var(--border-color-subtle)"},children:[V,(0,c.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-y-1 px-3 py-2",children:[(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,c.jsx)("span",{className:"font-mono text-sm font-bold",style:{color:"var(--color-fg)"},children:e.identIata}),(0,c.jsx)("span",{className:"text-xs",style:{color:"var(--color-fg-tertiary)"},children:e.scheduledDate}),e.originIata&&e.destinationIata&&(0,c.jsxs)("span",{className:"font-mono text-xs",style:{color:"var(--color-fg-secondary)"},children:[e.originIata," → ",e.destinationIata]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-3",children:[G,(0,c.jsx)("span",{className:"rounded-md px-2 py-1 text-xs",style:{backgroundColor:"var(--color-surface-muted)",color:"var(--color-fg-tertiary)",border:"1px solid var(--border-color-subtle)"},children:"Data available closer to departure"}),t&&(0,c.jsx)("button",{type:"button",onClick:t,className:"rounded p-1 text-xs transition-colors hover:bg-danger-subtle",style:{color:"var(--color-fg-tertiary)"},"aria-label":"Remove leg",children:(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M3 6h18"}),(0,c.jsx)("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,c.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})]})})]})]}),i&&(0,c.jsx)("div",{className:"px-3 py-1.5",style:{borderTop:"1px solid var(--border-color-subtle)"},children:i})]});let Y=g?tU(g,E):null,J=b?tU(b,P):null,X=l?.origin.gate??null,Z=l?.destination.gate??null,Q=l?.origin.terminal??null,ee=l?.destination.terminal??null,et=!!l&&(0,ty.isGateChangeFreshV1)(e.gateChangedAt,l.status,s??void 0),er=et&&!!e.previousGateOrigin&&e.previousGateOrigin!==X,ea=et&&!!e.previousGateDestination&&e.previousGateDestination!==Z,en=!!(Q||X),ei=!!(ee||Z),eo=[...er&&e.previousGateOrigin&&X?[{label:"Departure",from:e.previousGateOrigin,to:X}]:[],...ea&&e.previousGateDestination&&Z?[{label:"Arrival",from:e.previousGateDestination,to:Z}]:[]],el=eo.length>0?eo:z,es=en||ei?(0,c.jsxs)("span",{children:["Gate"," ",en&&[Q&&`T${Q}`,X].filter(Boolean).join(" · "),en&&ei&&" → ",ei&&[ee&&`T${ee}`,Z].filter(Boolean).join(" · ")]}):null,ec=[function(e){try{return new Intl.DateTimeFormat("en-US",{weekday:"short",month:"short",day:"numeric",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}catch{return e}}(e.scheduledDate),l?.aircraft.type,l?.aircraft.registration,J&&J!==Y?`Arrives ${J}`:null].filter(Boolean),ed=(e,t)=>{if(!e)return(0,c.jsx)("span",{className:"font-mono text-sm",style:{color:"var(--color-fg-tertiary)"},children:"—"});let r="font-mono text-sm font-bold hover:underline",a={color:"var(--color-fg-interactive)"};return p?(0,c.jsx)("button",{type:"button",className:r,style:a,onClick:t=>{t.stopPropagation(),p(e)},children:e}):t?(0,c.jsx)(eu.default,{href:`${(0,eI.scopeFor)()}?icao=${t}`,className:r,style:a,onClick:e=>e.stopPropagation(),children:e}):(0,c.jsx)("span",{className:"font-mono text-sm font-bold",children:e})};return(0,c.jsxs)("div",{"data-testid":"leg-row","data-ident-iata":e.identIata,"data-origin-iata":e.originIata??"","data-destination-iata":e.destinationIata??"","data-fa-flight-id":e.faFlightId??"","data-scheduled-date":e.scheduledDate,"data-data-source":e.dataSource,className:"overflow-hidden rounded-lg",style:{backgroundColor:"var(--color-surface)",border:"1px solid var(--border-color-subtle)"},children:[V,(0,c.jsxs)("div",{className:"px-3 py-2",style:{cursor:r?"pointer":void 0},onClick:r,role:r?"button":void 0,tabIndex:r?0:void 0,onKeyDown:r?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),r())}:void 0,children:[(0,c.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[(0,c.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[(0,c.jsx)("span",{className:"font-mono text-sm font-bold",style:{color:"var(--color-fg)"},children:e.identIata}),ed(e.originIata,(0,tc.legOriginIcao)(e)),(0,c.jsx)("span",{className:"font-mono text-xs",style:{color:"var(--color-fg-secondary)"},children:I}),(0,c.jsx)("svg",{width:"12",height:"10",viewBox:"0 0 12 10",fill:"none",stroke:"var(--color-fg-disabled)",strokeWidth:"1.5",className:"shrink-0",children:(0,c.jsx)("path",{d:"M1 5h10M8 2l3 3-3 3"})}),ed(e.destinationIata,(0,tc.legDestinationIcao)(e)),(0,c.jsx)("span",{className:"font-mono text-xs",style:{color:"var(--color-fg-secondary)"},children:$})]}),(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[G,(l?.diverted||l?.status==="diverted")&&(0,c.jsx)("span",{className:"rounded px-1.5 py-0.5 text-xs font-bold tracking-wide uppercase",style:{color:"var(--color-fg-on-solid)",backgroundColor:"var(--color-danger)"},children:"Diverted"}),(l?.cancelled||l?.status==="cancelled")&&(0,c.jsx)("span",{className:"rounded px-1.5 py-0.5 text-xs font-bold tracking-wide uppercase",style:{color:"var(--color-fg-on-solid)",backgroundColor:"var(--color-danger)"},children:"Cancelled"}),m&&(0,c.jsx)("span",{className:"text-xs font-semibold",style:{color:tD[m.tone]},children:m.label}),x&&v&&(0,c.jsxs)("span",{className:"font-mono text-xs font-bold",style:{color:tD[v.tone]},title:"Departure delay",children:["Dep +",v.minutes,"m"]}),_&&y&&(0,c.jsxs)("span",{className:"font-mono text-xs font-bold",style:{color:tD[y.tone]},title:"Arrival delay",children:["Arr +",y.minutes,"m"]}),t&&(0,c.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),t()},className:"rounded p-1 text-xs transition-colors hover:bg-danger-subtle",style:{color:"var(--color-fg-tertiary)"},"aria-label":"Remove leg",children:(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M3 6h18"}),(0,c.jsx)("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,c.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})]})})]})]}),h&&(0,c.jsxs)("p",{"data-testid":"leg-countdown","data-phase":h.end,className:"mt-1 text-xs",style:{color:"var(--color-fg-secondary)"},children:[(0,c.jsx)("span",{className:"font-bold",style:{color:"var(--color-fg)"},children:h.text}),h.detail&&(0,c.jsxs)(c.Fragment,{children:[" · ",(0,c.jsx)("span",{style:h.late?{color:"var(--color-fg-warning)",fontWeight:600}:void 0,children:h.detail})]})]}),C&&(null!=k||null!=N)&&(0,c.jsxs)("div",{className:"mt-1.5",children:[null!=k&&(0,c.jsx)("div",{className:"h-1 w-full overflow-hidden rounded-full",style:{backgroundColor:"var(--color-surface-muted)"},children:(0,c.jsx)("div",{className:"h-full rounded-full",style:{width:`${Math.max(0,Math.min(100,k))}%`,backgroundColor:"var(--color-interactive)"}})}),(0,c.jsx)("p",{className:"mt-0.5 text-xs",style:{color:"var(--color-fg-tertiary)"},children:[null!=k?`${Math.round(k)}% complete`:null,null!=N?`${Math.round(N).toLocaleString()} ft`:null,null!=A?`${Math.round(A)} kts`:null].filter(Boolean).join(" · ")})]}),(ec.length>0||es)&&(0,c.jsxs)("p",{className:"mt-0.5 text-xs",style:{color:"var(--color-fg-secondary)"},children:[ec.join(" · "),ec.length>0&&es&&" · ",es]}),(0,c.jsx)(tk,{changes:el}),F&&O&&(0,c.jsx)(tj,{risk:O,inboundNote:M??void 0}),U&&(0,c.jsx)(tT,{stats:U,omitBaseline:F&&tS(O,"history")}),x&&M&&!(F&&tS(O,"inbound-late"))&&(0,c.jsxs)("p",{className:"mt-1 text-xs",style:{color:"var(--color-fg-secondary)"},children:["Aircraft's previous flight ",M]}),D&&(0,tP.knownDelayLevel)(e)&&(0,c.jsxs)("p",{"data-testid":"remembered-inbound",className:"mt-1 text-xs",style:{color:"var(--color-fg-secondary)"},children:["Aircraft's previous flight"," ",(0,tA.describeInboundMemory)(D)]})]}),i&&(0,c.jsx)("div",{className:"px-3 py-1.5",style:{borderTop:"1px solid var(--border-color-subtle)"},children:i})]})}function tB({chains:e,onRemove:t,onSelect:r,removableLegIds:a,renderTailAction:n,renderLegAction:i}){let o=e=>t&&(!a||a.has(e))?()=>t(e):void 0;return(0,c.jsx)(c.Fragment,{children:e.map((e,t)=>{let a=e[e.length-1];return(0,c.jsxs)("div",{className:t>0?"mt-3":"",children:[(0,c.jsx)(tW,{leg:e[0],onRemove:o(e[0].id),onSelect:r?()=>r(e[0]):void 0,trailingAction:i?i(e[0]):1===e.length?n?.(a):void 0}),e.length>1&&(0,c.jsx)("div",{className:"mt-1 ml-4",children:e.slice(1).map((t,l)=>{let s=e[l],d=(0,eW.analyzeConnection)(s,t),u=l===e.length-2;return(0,c.jsxs)("div",{className:"flex",children:[(0,c.jsxs)("div",{className:"relative mr-2 shrink-0",style:{width:14},children:[(0,c.jsx)("div",{style:{position:"absolute",left:0,top:0,bottom:u?"auto":0,height:u?18:void 0,width:2,backgroundColor:"var(--color-interactive-subtle)"}}),(0,c.jsx)("div",{style:{position:"absolute",left:0,top:16,right:0,height:2,backgroundColor:"var(--color-interactive-subtle)"}})]}),(0,c.jsx)("div",{className:"min-w-0 flex-1",style:{paddingBottom:4*!u},children:(0,c.jsx)(tW,{leg:t,arrivingLeg:s,connectionRisk:d,onRemove:o(t.id),onSelect:r?()=>r(t):void 0,trailingAction:i?i(t):u?n?.(a):void 0})})]},t.id)})})]},e[0].id)})})}let tH={AA:"American Airlines",DL:"Delta Air Lines",UA:"United Airlines",WN:"Southwest Airlines",B6:"JetBlue Airways",AS:"Alaska Airlines",NK:"Spirit Airlines",F9:"Frontier Airlines",G4:"Allegiant Air",SY:"Sun Country Airlines",HA:"Hawaiian Airlines",OO:"SkyWest Airlines",OH:"PSA Airlines",YX:"Midwest Express",YV:"Mesa Airlines",CP:"Compass Airlines",MQ:"Envoy Air",ZW:"Air Wisconsin",AC:"Air Canada",WS:"WestJet",PD:"Porter Airlines",AM:"Aeroméxico",LA:"LATAM Airlines",AV:"Avianca",CM:"Copa Airlines",Y4:"Volaris",VB:"VivaAerobus",BA:"British Airways",LH:"Lufthansa",AF:"Air France",KL:"KLM",IB:"Iberia",AZ:"ITA Airways",SK:"Scandinavian Airlines",AY:"Finnair",LX:"Swiss International",OS:"Austrian Airlines",SN:"Brussels Airlines",TP:"TAP Air Portugal",U2:"easyJet",FR:"Ryanair",VY:"Vueling",W6:"Wizz Air",EK:"Emirates",EY:"Etihad Airways",QR:"Qatar Airways",TK:"Turkish Airlines",MS:"EgyptAir",ET:"Ethiopian Airlines",SA:"South African Airways",SQ:"Singapore Airlines",CX:"Cathay Pacific",NH:"All Nippon Airways",JL:"Japan Airlines",KE:"Korean Air",OZ:"Asiana Airlines",MH:"Malaysia Airlines",TG:"Thai Airways",GA:"Garuda Indonesia",AI:"Air India",QF:"Qantas",NZ:"Air New Zealand",CA:"Air China",MU:"China Eastern",CZ:"China Southern",HU:"Hainan Airlines",FX:"FedEx Express","5X":"UPS Airlines"};function tK(e){return tH[e.toUpperCase()]}var tG=e.i(47401),tV=e.i(30374);async function tY(e,t,r){var a=await Promise.all([-1,0,1,2].map(e=>{let r;return(r=new Date(`${t}T00:00:00Z`)).setUTCDate(r.getUTCDate()+e),r.toISOString().slice(0,10)}).map(t=>tV.v1.searchFlights({ident:e,date:t,origin:r})));let n=new Map;for(let e of a)if(e.ok)for(let t of e.data.matches)n.set(t.id,t);return{matches:[...n.values()],failed:a.length>0&&a.every(e=>!e.ok)}}function tJ(e,t){let r=t.trim().toUpperCase();return e.icao.toUpperCase()===r||e.iata?.toUpperCase()===r}var tX=e.i(83086),tZ=e.i(66691),tQ=e.i(93549);let t0=["AI import from screenshots and booking emails","Unlimited flight tracking","Your flights saved to your weather.com account"];function t1(){return(0,c.jsxs)("div",{"data-testid":"import-sign-in-gate",className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 rounded-lg px-6 py-8 text-center",style:{backgroundColor:"var(--color-interactive-subtle)",border:"1px solid var(--border-color-subtle)"},children:[(0,c.jsx)(tX.Sparkles,{"aria-hidden":!0,className:"size-6",style:{color:"var(--color-fg-interactive)"}}),(0,c.jsxs)("div",{children:[(0,c.jsx)("h3",{className:"text-base font-semibold",style:{color:"var(--color-fg)"},children:"Sign in to import your flights"}),(0,c.jsx)("p",{className:"mt-1 text-sm",style:{color:"var(--color-fg-secondary)"},children:"Snap a screenshot of your booking and we'll add the flights for you. Signing in is free."})]}),(0,c.jsx)("ul",{className:"m-0 flex list-none flex-col gap-1.5 p-0 text-left",children:t0.map(e=>(0,c.jsxs)("li",{className:"flex items-center gap-2 text-sm",style:{color:"var(--color-fg)"},children:[(0,c.jsx)(h.Check,{"aria-hidden":!0,className:"size-4 shrink-0",style:{color:"var(--color-fg-interactive)"}}),e]},e))}),(0,c.jsx)(tZ.Button,{asChild:!0,children:(0,c.jsx)(tQ.default,{children:"Sign in"})})]})}var t2=e.i(59737),t5=e.i(19749);let t4="airport-intelligence-import-email";function t3(e,t){return!!e&&new Date(e).getTime()setTimeout(e,a)),t.aborted)throw new DOMException("Aborted","AbortError");r=await e()}return r}function t9(e){let t=e.trim().toUpperCase().split(/\s+/).filter(Boolean),r=t.find(e=>/^[A-Z]{3}$/.test(e));return{ident:(r?t.filter(e=>e!==r):t).join(""),airport:r??null}}function t7(e){return e.replace(/^([A-Z]{2,3})0*(\d+)$/,"$1$2")}function re(e,t){let{ident:r}=t9(e);return!!r&&!!(/^[A-Z]{2,3}\d{1,4}$/.test(r)||t&&/^\d{1,4}$/.test(r))}function rt(e,t,r,a){return e===a?0:e.startsWith(a)?1:t.startsWith(a)||r.startsWith(a)?2:3}function rr({raw:e,onSelect:t,highlighted:r,onHover:a,id:n}){let i,o,l=(i=e.origin).iata??i.icao,s=(0,tb.useAirportTimezone)(l),d=new Intl.DateTimeFormat("en-US",{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZone:s}).format(new Date(e.scheduledDepartureAt)),u=(o=e.destination).iata??o.icao;return(0,c.jsx)("button",{type:"button",id:n,role:"option","aria-selected":r,onClick:t,onMouseEnter:a,className:"flex w-full items-center justify-between rounded-md px-3 py-2.5 text-left transition-colors hover:bg-interactive-subtle",style:{borderBottom:"1px solid var(--border-color-subtle)",backgroundColor:r?"var(--color-interactive-subtle)":void 0},children:(0,c.jsxs)("div",{className:"flex items-center gap-3",children:[(0,c.jsxs)("span",{className:"font-mono text-xs font-semibold",style:{color:"var(--color-fg)"},children:[l," → ",u]}),(0,c.jsx)("span",{className:"text-xs",style:{color:"var(--color-fg-secondary)"},children:d})]})})}function ra({size:e=16}){return(0,c.jsxs)("svg",{className:"animate-spin",width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[(0,c.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),(0,c.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function rn(e){return(0,eG.localDateStr)(new Date().toISOString(),e)}function ri(e){return new Date(`${e}T00:00:00Z`).toLocaleDateString("en-US",{timeZone:"UTC",month:"short",day:"numeric"})}function ro({value:e,onChange:t,min:r,actualToday:a}){let n,[i,o]=(0,d.useState)(!1),l=r===a,s=((n=new Date(`${r}T00:00:00Z`)).setUTCDate(n.getUTCDate()+1),n.toISOString().split("T")[0]??r),u=e===r,f=e===s,p=l?"Today":ri(r),h=l?"Tomorrow":ri(s),m=e=>({padding:"5px 12px",fontSize:12,fontWeight:600,borderRadius:5,cursor:"pointer",border:"none",backgroundColor:e?"var(--color-interactive)":"transparent",color:e?"var(--color-fg-on-solid)":"var(--color-fg-secondary)",transition:"background-color 0.15s, color 0.15s"});return(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)("div",{className:"flex items-center gap-1 rounded-md p-0.5",style:{backgroundColor:"var(--color-interactive-subtle)"},children:[(0,c.jsx)("button",{type:"button","data-testid":"date-tab-today",style:m(u),onClick:()=>{o(!1),t(r)},children:p}),(0,c.jsx)("button",{type:"button","data-testid":"date-tab-tomorrow",style:m(f),onClick:()=>{o(!1),t(s)},children:h}),(0,c.jsx)("button",{type:"button",style:m(!u&&!f),onClick:()=>o(!0),children:"Pick a date"})]}),(i||!u&&!f)&&(0,c.jsx)("input",{type:"date",value:e,min:r,onChange:e=>e.target.value&&t(e.target.value),className:"rounded-md border px-2 py-1 text-sm outline-none focus:border-interactive",style:{borderColor:"var(--border-color-subtle)",color:"var(--color-fg)"}})]})}function rl({onStageLeg:t,onClose:r,initialOrigin:a,initialDate:n,earliestDeparture:i,modeSelector:o,anonymousGateActive:l}){let s,u,f,p,h,m=new Date().toISOString().split("T")[0]??"",g=!!a,[b,y]=(0,d.useState)("search"),[x,_]=(0,d.useState)(""),[w,S]=(0,d.useState)(a??""),j=(0,tb.useAirportTimezone)(w),[C,k]=(0,d.useState)(""),[N,A]=(0,d.useState)(null),[R,T]=(0,d.useState)(n??m),[E,P]=(0,d.useState)(!1),[L,I]=(0,d.useState)(null),[$,M]=(0,d.useState)(0),O=(0,d.useRef)(null),z=(0,d.useRef)(null),[D,F]=(0,d.useState)([]),[U,q]=(0,d.useState)(!1),[W,B]=(0,d.useState)(""),[H,K]=(0,d.useState)(""),[G,V]=(0,d.useState)(""),[Y,J]=(0,d.useState)([]),[X,Z]=(0,d.useState)(null),[Q,ee]=(0,d.useState)(null),[et,er]=(0,d.useState)("search"),[ea,en]=(0,d.useState)({error:L,tab:et});ea.error!==L&&en({error:L,tab:et});let eo=L&&("search"!==b||ea.tab===et),[ec,ed]=(0,d.useState)(()=>{try{return localStorage.getItem(t4)??""}catch{return""}}),[eu,ef]=(0,d.useState)([]),[ep,eh]=(0,d.useState)("idle"),em=(0,d.useRef)(null),[eg,eb]=(0,d.useState)(!1),ev=(0,d.useRef)(null),ey=(0,d.useRef)(null),[ex,e_]=(0,d.useState)(!1),ew=(0,d.useRef)(null),[eS,ej]=(0,d.useState)(!1);(0,d.useEffect)(()=>{ej((0,t5.canCaptureScreen)())},[]);let[eC,ek]=(0,d.useState)(!1);(0,d.useEffect)(()=>{let e=window.matchMedia("(max-width: 639px)");ek(e.matches);let t=e=>ek(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),(0,d.useEffect)(()=>()=>{em.current?.abort(),ey.current?.abort()},[]),(0,d.useEffect)(()=>{O.current?.focus()},[w]),(0,d.useEffect)(()=>{M(0)},[x,w,N]),(0,d.useEffect)(()=>{let e=z.current?.children[$];e?.scrollIntoView({block:"nearest"})},[$]),(0,d.useEffect)(()=>{if(x.length>=2&&!X){e.A(46984).then(e=>Z(e.airportIndex));let t=new Map;for(let e of v.airportsList)e.city&&t.set(e.iata,e.city);ee(t)}},[x,X]);let eN=(0,d.useCallback)(()=>{F([]),J([]),I(null)},[]),eA=(0,d.useRef)(null),eR=(0,d.useRef)(null),eT=(0,d.useRef)(null);(0,d.useEffect)(()=>()=>{eA.current?.abort(),eR.current?.abort(),eT.current?.abort()},[]);let eE=(0,d.useCallback)(async(e,t,r)=>{eA.current?.abort();let a=new AbortController;eA.current=a;let{signal:n}=a;eN(),P(!0);try{let[a,i]=await Promise.all([(0,tV.icaoOf)(e),t?(0,tV.icaoOf)(t):null]);if(n.aborted)return;if(!a||t&&!i){let a=t?` to ${t}`:"";I(`No flights scheduled from ${e}${a} on ${r}`);return}let o=await t8(()=>tV.v1.dayDepartures(a,r,i??void 0),n);if(n.aborted)return;if(!o.ok&&"parse"===o.reason)throw Error("Schedule answer is not JSON");let l=o.ok?o.data.flights.map(e=>({...e,origin:o.data.origin})):[];if(l.length>0){J(l),P(!1);return}if(o.ok||"http"===o.reason&&o.status{let{ident:t,airport:r}=t9(N&&/^\d{1,4}$/.test(e.trim())?`${N.iata} ${e}`:e);if(!t)return;eR.current?.abort();let a=new AbortController;eR.current=a;let{signal:n}=a;eN(),P(!0);try{let e=r||w||null,a=e?await (0,tV.icaoOf)(e):null,i=(0,eG.localDateStr)(new Date().toISOString(),Intl.DateTimeFormat().resolvedOptions().timeZone),{matches:o,failed:l}=await tY(t,i,a??void 0);if(n.aborted)return;if(l)throw Error("Flight search failed");let s=o.filter(t=>!e||a||tJ(t.origin,e)).sort((e,t)=>e.scheduledDepartureAt.localeCompare(t.scheduledDepartureAt));0===s.length?I(`No flights found for "${t}"`):F(s)}catch{if(n.aborted)return;I(`Could not find flight "${t}"`)}finally{n.aborted||P(!1)}},[N,w,eN]);(0,d.useEffect)(()=>{if(!re(x,N?.iata))return void F([]);let e=setTimeout(()=>eP(x),400);return()=>clearTimeout(e)},[x,N,eP]);let eL=(0,d.useCallback)(async(e,t,r,a)=>{let n=t.trim().toUpperCase(),i=r.trim().toUpperCase();if(!e||!/^[A-Z]{3}$/.test(n)||!/^[A-Z]{3}$/.test(i)||!a)return void I("Enter a valid departure airport, arrival airport (3-letter codes), and date.");let o=t7(e);eT.current?.abort();let l=new AbortController;eT.current=l;let{signal:s}=l;eN(),P(!0);try{let[t,r]=await Promise.all([(0,tV.icaoOf)(n),(0,tV.icaoOf)(i)]);if(s.aborted)return;let l=t&&r?await tV.v1.dayDepartures(t,a,r):null;if(s.aborted)return;if(l&&!l.ok)throw Error("Schedule lookup failed");let c=l?l.data.flights.filter(e=>[e.ident,...e.operating?[e.operating]:[],...e.codeshares].some(e=>[e.icao,e.iata].some(e=>e&&t7(e.toUpperCase())===o))).map(e=>({...e,origin:l.data.origin})):[];0===c.length?I(`No ${e} flight found from ${n} to ${i} on ${a}.`):(F(c),q(!1))}catch{if(s.aborted)return;I("Could not search by date — please try again.")}finally{s.aborted||P(!1)}},[eN]),eI=async e=>{let r,a,n,i,o=null;e.id&&(P(!0),o=await (0,tL.loadFlight)(e.id),P(!1));let l=o?.data?.origin.timezone??await (0,tb.resolveAirportTimezone)((r=e.origin).iata??r.icao),s=(0,eG.localDateStr)(e.scheduledDepartureAt,l),c=g?w.toUpperCase():(a=e.origin).iata??a.icao,d={id:(0,eV.newId)(),identIata:((n=e.ident).iata??n.icao)||t9(x).ident,identIcao:e.ident.icao||null,faFlightId:null,flightId:e.id,scheduledDate:s??"",originIata:c,destinationIata:(i=e.destination).iata??i.icao,scheduledDepartureAt:e.scheduledDepartureAt,scheduledArrivalAt:e.scheduledArrivalAt??null,snapshot:null,dataSource:"live"===e.resolution?"live":"schedule",addedAt:new Date().toISOString()};t([o?.data?{...(0,tG.mergeSnapshotIntoLeg)(d,o.data),originIata:c}:d])},e$=e=>{if(_(""),!w)return void S(e);k(e);let t=n??rn(j);T(t),eE(w,e,t),y("results")},eM=e=>{A(e),_("")},eO=async e=>{let r=new AbortController;ey.current=r,eb(!0),I(null);let a=await (0,t5.readBookingImage)(e,r.signal);a.ok?(a.legs.length>0&&t(a.legs),a.landed.length>0&&I((0,t5.landedImportMessage)(a.landed,0===a.legs.length))):a.aborted||I(a.message),r.signal.aborted||eb(!1)},ez=async()=>{let e=await (0,t5.imageFromClipboard)();e.ok?await eO(e.file):e.message&&I(e.message)},eD=async()=>{let e=await (0,t5.imageFromScreen)();e.ok?await eO(e.file):e.message&&I(e.message)},eF=async e=>{let r=(0,t2.legsFromImport)(e);0!==r.length&&(ef(t=>t.filter(t=>t!==e)),t(r))},eU=re(x,N?.iata),eq=eU?[]:function(e,t,r,a){let n=e.trim().toUpperCase();if(!n)return[];let i=[];for(let t of function(e,t=5){let r=e.trim().toUpperCase();if(!r)return[];let a=(e,t)=>e===r?0:e.startsWith(r)?1:t.toUpperCase().startsWith(r)?2:3;return Object.entries(tH).filter(([e,t])=>e.includes(r)||t.toUpperCase().includes(r)).sort((e,t)=>a(e[0],e[1])-a(t[0],t[1])).slice(0,t).map(([e,t])=>({iata:e,name:t}))}(e,8))i.push({item:{kind:"airline",iata:t.iata,name:t.name},rank:rt(t.iata,t.name.toUpperCase(),"",n)});let o=t.toUpperCase();if(n.length>=2&&r)for(let e of r){let t=e.iata.toUpperCase();if(t===o)continue;let r=e.name.toUpperCase(),l=a?.get(e.iata)?.toUpperCase()??"";(t.includes(n)||r.includes(n)||l.includes(n))&&i.push({item:{kind:"airport",iata:e.iata,name:e.name,subtitle:a?.get(e.iata)??""},rank:rt(t,r,l,n)})}return i.sort((e,t)=>e.rank-t.rank).slice(0,8).map(e=>e.item)}(x,w,X,Q),eW=x?[]:[...v.airportsList].filter(e=>e.iata!==w.toUpperCase()).sort((e,t)=>e.rank-t.rank).slice(0,6).map(e=>({kind:"airport",iata:e.iata,name:e.name,subtitle:e.city})),eB=D.filter(e=>!(e.past??t3(e.scheduledArrivalAt,Date.now()))&&(!w||!!tJ(e.origin,w))&&(!i||new Date(e.scheduledDepartureAt).getTime()>=new Date(i).getTime())),eH=eU?eB:x?eq:eW;return(0,c.jsxs)("div",{className:"flex h-full flex-col",children:[("results"===b||r)&&(0,c.jsxs)("div",{className:"flex shrink-0 items-center justify-between px-3 pt-3 pb-2",style:{borderBottom:"1px solid var(--border-color-subtle)"},children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:["results"===b&&(0,c.jsx)("button",{type:"button",onClick:()=>{A(null),I(null),y("search")},className:"text-xs font-semibold",style:{color:"var(--color-fg-interactive)"},children:"‹ Back"}),(0,c.jsx)("span",{className:"text-sm font-semibold",style:{color:"var(--color-fg)"},children:"results"===b&&(C?`${w} → ${C}`:`Departures from ${w}`)})]}),r&&(0,c.jsx)("button",{type:"button",onClick:r,className:"rounded p-1 transition-colors hover:bg-interactive-subtle",style:{color:"var(--color-fg-tertiary)"},"aria-label":"Close search",children:(0,c.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,c.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col p-3",children:["search"===b&&(0,c.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,c.jsxs)("div",{className:"mb-3 flex shrink-0 items-center gap-2",children:[(0,c.jsx)(ei,{value:et,onValueChange:e=>er(e),className:"shrink-0",children:(0,c.jsxs)(el,{children:[(0,c.jsx)(es,{"data-testid":"search-tab-search",value:"search",children:"Search"}),(0,c.jsx)(es,{"data-testid":"search-tab-import",value:"import",children:"Import"})]})}),o&&"search"===et&&o]}),(0,c.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:["search"===et&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 rounded-md border px-2 py-1.5",style:{borderColor:"var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:[N&&(0,c.jsxs)("span",{className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-bold",style:{backgroundColor:"var(--color-interactive-subtle)",color:"var(--color-fg-interactive)"},children:[N.iata,(0,c.jsx)("button",{type:"button","aria-label":`Remove ${N.name}`,onClick:()=>A(null),style:{color:"var(--color-fg-interactive)"},children:"×"})]}),w&&(0,c.jsxs)("span",{"data-testid":"origin-chip","data-origin":w,className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-bold",style:{backgroundColor:"var(--color-interactive-subtle)",color:"var(--color-fg-interactive)"},children:[w,!g&&(0,c.jsx)("button",{type:"button","aria-label":`Remove ${w}`,onClick:()=>{g||(S(""),k(""),J([]))},style:{color:"var(--color-fg-interactive)"},children:"×"})]}),(0,c.jsx)("input",{ref:O,"data-testid":"flight-search-input",type:"text",value:x,onChange:e=>_(e.target.value),onKeyDown:e=>{if(0!==eH.length){if("ArrowDown"===e.key)e.preventDefault(),M(e=>(e+1)%eH.length);else if("ArrowUp"===e.key)e.preventDefault(),M(e=>(e-1+eH.length)%eH.length);else if("Enter"===e.key){let t=eH[$];if(!t)return;e.preventDefault(),eU?eI(t):"airline"===t.kind?eM(t):e$(t.iata)}}},placeholder:w?"Arrival airport, city, or flight number":"United, DEN, or DL 1242",spellCheck:!1,autoComplete:"off",role:"combobox","aria-expanded":eH.length>0,"aria-controls":eH.length>0?"flight-search-listbox":void 0,"aria-activedescendant":eH.length>0?`search-option-${$}`:void 0,className:"min-w-0 flex-1 border-none py-1 font-mono text-sm outline-none",style:{color:"var(--color-fg)"}})]}),eU&&(0,c.jsxs)("div",{className:"mt-3",children:[E&&(0,c.jsx)("p",{className:"animate-pulse text-xs",style:{color:"var(--color-fg-tertiary)"},children:"Looking up flight…"}),!E&&!U&&(0,c.jsx)("button",{type:"button","data-testid":"open-date-search",onClick:()=>{let e,t,r=D[0],a=r?(e=r.origin).iata??e.icao:"",n=r?(t=r.destination).iata??t.icao:"";B(w||a),K(n),V(R||m),q(!0)},className:"mb-2 block text-xs font-semibold",style:{color:"var(--color-fg-interactive)"},children:eB.length>0?"Looking for a different date?":"Flight not listed? Search by date instead"}),U&&(0,c.jsxs)("div",{className:"mb-2 flex flex-wrap items-end gap-2 rounded-md p-2",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:[!w&&(0,c.jsxs)("label",{className:"flex flex-col text-xs",style:{color:"var(--color-fg-secondary)"},children:["Departure airport",(0,c.jsx)("input",{"data-testid":"date-search-origin",type:"text",value:W,onChange:e=>B(e.target.value.toUpperCase()),placeholder:"ATL",maxLength:3,spellCheck:!1,autoComplete:"off",className:"mt-0.5 w-16 rounded-md border px-2 py-1 font-mono text-sm outline-none focus:border-interactive",style:{borderColor:"var(--border-color-subtle)",color:"var(--color-fg)"}})]}),(0,c.jsxs)("label",{className:"flex flex-col text-xs",style:{color:"var(--color-fg-secondary)"},children:["Arrival airport",(0,c.jsx)("input",{"data-testid":"date-search-destination",type:"text",value:H,onChange:e=>K(e.target.value.toUpperCase()),placeholder:"LGA",maxLength:3,spellCheck:!1,autoComplete:"off",className:"mt-0.5 w-16 rounded-md border px-2 py-1 font-mono text-sm outline-none focus:border-interactive",style:{borderColor:"var(--border-color-subtle)",color:"var(--color-fg)"}})]}),(0,c.jsxs)("label",{className:"flex flex-col text-xs",style:{color:"var(--color-fg-secondary)"},children:["Date",(0,c.jsx)("input",{"data-testid":"date-search-date",type:"date",value:G,onChange:e=>V(e.target.value),className:"mt-0.5 rounded-md border px-2 py-1 text-sm outline-none focus:border-interactive",style:{borderColor:"var(--border-color-subtle)",color:"var(--color-fg)"}})]}),(0,c.jsx)("button",{type:"button","data-testid":"date-search-submit",onClick:()=>eL(t9(N&&/^\d{1,4}$/.test(x.trim())?`${N.iata} ${x}`:x).ident,w||W,H,G),className:"rounded-md px-3 py-1.5 text-xs font-semibold text-white",style:{backgroundColor:"var(--color-interactive)"},children:"Search"})]}),!E&&eB.length>0&&(0,c.jsx)("div",{ref:z,id:"flight-search-listbox",role:"listbox",className:"max-h-48 overflow-y-auto rounded-md",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:eB.map((e,t)=>(0,c.jsx)(rr,{id:`search-option-${t}`,raw:e,highlighted:t===$,onHover:()=>M(t),onSelect:()=>eI(e)},e.id??`candidate-${t}`))})]}),!eU&&(x?eq:eW).length>0&&(0,c.jsxs)("div",{className:"mt-3",children:[!x&&(0,c.jsx)("p",{className:"mb-2 text-xs font-semibold tracking-wide uppercase",style:{color:"var(--color-fg-tertiary)"},children:w?"Popular destinations":"Popular"}),(0,c.jsx)("div",{ref:z,id:"flight-search-listbox",role:"listbox",className:"max-h-56 overflow-y-auto rounded-md",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:(x?eq:eW).map((e,t)=>(0,c.jsxs)("button",{type:"button",id:`search-option-${t}`,"data-testid":"search-suggestion","data-iata":e.iata,"data-kind":e.kind,role:"option","aria-selected":t===$,onMouseEnter:()=>M(t),onClick:()=>"airline"===e.kind?eM(e):e$(e.iata),className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-interactive-subtle",style:{borderBottom:"1px solid var(--border-color-subtle)",backgroundColor:t===$?"var(--color-interactive-subtle)":void 0},children:[(0,c.jsx)("span",{className:"font-mono font-bold",style:{color:"var(--color-fg-interactive)"},children:e.iata}),(0,c.jsx)("span",{className:"truncate",style:{color:"var(--color-fg-secondary)"},children:e.name}),"airport"===e.kind&&e.subtitle&&(0,c.jsx)("span",{className:"ml-auto shrink-0 text-xs",style:{color:"var(--color-fg-tertiary)"},children:e.subtitle})]},`${e.kind}-${e.iata}`))})]}),!eU&&x.trim().length>=2&&0===eq.length&&(0,c.jsx)("p",{className:"mt-3 text-sm",style:{color:"var(--color-fg-tertiary)"},children:"No matches — try an airport code, airline, or flight number."})]}),"import"===et&&l&&(0,c.jsx)(t1,{}),"import"===et&&!l&&(0,c.jsx)("div",{className:"flex h-full min-h-0 flex-col",children:(0,c.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,c.jsxs)("div",{className:"mb-3 shrink-0 rounded-lg px-3 py-2.5",style:{backgroundColor:"var(--color-interactive-subtle)",border:"1px solid var(--border-color-subtle)"},children:[(0,c.jsxs)("p",{className:"mb-1.5 flex items-center gap-1 text-xs font-semibold",style:{color:"var(--color-fg)"},children:[(0,c.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"var(--color-fg-interactive)",children:(0,c.jsx)("path",{d:"M12 2l1.8 6.2L20 10l-6.2 1.8L12 18l-1.8-6.2L4 10l6.2-1.8z"})}),"AI-powered flight import"]}),(0,c.jsx)("p",{className:"mb-2 text-xs leading-relaxed",style:{color:"var(--color-fg-secondary)"},children:"Extract flight details from a screenshot or photo of your booking confirmation or itinerary email."}),!1]}),!1,(0,c.jsx)("input",{ref:ev,type:"file",accept:"image/jpeg,image/jpg,image/png,image/webp,image/heic,image/heif",className:"hidden",onChange:e=>{let t=e.target.files?.[0];e.target.value="",t&&eO(t)}}),(0,c.jsx)("input",{ref:ew,type:"file",accept:"image/*",capture:"environment",className:"hidden",onChange:e=>{let t=e.target.files?.[0];e.target.value="",t&&eO(t)}}),eg?(0,c.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 rounded-md",style:{backgroundColor:"var(--color-interactive-subtle)"},children:[(0,c.jsxs)("span",{className:"flex items-center gap-2 text-xs",style:{color:"var(--color-fg-tertiary)"},children:[(0,c.jsx)(ra,{size:14}),"Reading screenshot…"]}),(0,c.jsx)("button",{type:"button",onClick:()=>{ey.current?.abort(),eb(!1),I(null)},className:"text-xs font-semibold",style:{color:"var(--color-fg-interactive)"},children:"Cancel"})]}):(0,c.jsxs)("div",{onDragOver:e=>{e.preventDefault(),e_(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||e_(!1)},onDrop:e=>{e.preventDefault(),e_(!1);let t=(0,t5.imageIn)(e.dataTransfer);t&&eO(t)},onPaste:e=>{let t=(0,t5.imageIn)(e.clipboardData);t&&(e.preventDefault(),eO(t))},tabIndex:0,className:"flex w-full flex-1 flex-col items-center justify-center gap-2 rounded-md text-center transition-colors outline-none",style:{border:`1px dashed ${ex?"var(--border-color-interactive)":"var(--border-color-info-subtle)"}`,backgroundColor:ex?"var(--color-interactive-subtle)":"transparent"},children:[(0,c.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-interactive)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,c.jsx)("path",{d:"M17 8l-5-5-5 5"}),(0,c.jsx)("path",{d:"M12 3v12"})]}),(0,c.jsx)("span",{className:"text-xs",style:{color:"var(--color-fg-tertiary)"},children:ex?"Drop to import":eC?"Choose a photo, or take one of your itinerary":'Drag & drop a screenshot, or click "Import from clipboard"'}),(0,c.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[(0,c.jsxs)("div",{className:"flex gap-2",children:[(0,c.jsx)("button",{type:"button",onClick:()=>ev.current?.click(),className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-colors",style:{color:"var(--color-fg-interactive)",border:"1px solid var(--border-color-info-subtle)",backgroundColor:"var(--color-interactive-subtle)"},children:"Import from file"}),!eC&&(0,c.jsx)("button",{type:"button",onClick:ez,className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-colors",style:{color:"var(--color-fg-interactive)",border:"1px solid var(--border-color-info-subtle)",backgroundColor:"var(--color-interactive-subtle)"},children:"Import from clipboard"}),eC?(0,c.jsx)("button",{type:"button",onClick:()=>ew.current?.click(),className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-colors",style:{color:"var(--color-fg-interactive)",border:"1px solid var(--border-color-info-subtle)",backgroundColor:"var(--color-interactive-subtle)"},children:"Take photo"}):eS&&(0,c.jsx)("button",{type:"button",onClick:eD,className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-colors",style:{color:"var(--color-fg-interactive)",border:"1px solid var(--border-color-info-subtle)",backgroundColor:"var(--color-interactive-subtle)"},children:"Take screenshot"})]}),eS&&!eC&&(0,c.jsx)("p",{className:"text-center text-xs",style:{color:"var(--color-fg-tertiary)"},children:"Choose a window or the whole screen, not a browser tab — picking a tab switches you to it"})]})]}),eu.length>0&&(0,c.jsxs)("div",{className:"mt-3",children:[(0,c.jsxs)("p",{className:"mb-2 text-xs font-semibold",style:{color:"var(--color-fg-tertiary)"},children:["Found ",eu.length," booking",1!==eu.length?"s":"",":"]}),(0,c.jsx)("div",{className:"max-h-64 space-y-2 overflow-y-auto",style:{scrollbarWidth:"thin"},children:eu.map((e,t)=>{let r=e.legs;if(0===r.length)return null;let a=e.confidencePercent;return(0,c.jsxs)("div",{className:"rounded-md border p-3",style:{borderColor:"var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:[(0,c.jsxs)("div",{className:"mb-2 flex items-start justify-between gap-2",children:[(0,c.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,c.jsx)("p",{className:"truncate text-xs font-semibold",style:{color:"var(--color-fg)"},children:e.subject}),(0,c.jsxs)("p",{className:"mt-0.5 text-xs",style:{color:"var(--color-fg-tertiary)"},children:[r.length," flight",1!==r.length?"s":"",aeF(e),className:"shrink-0 rounded-md px-3 py-1.5 text-xs font-semibold text-white transition-colors hover:opacity-90",style:{backgroundColor:"var(--color-interactive)"},children:"Import"})]}),(0,c.jsx)("div",{className:"space-y-1",children:r.map((t,r)=>(0,c.jsxs)("div",{className:"flex items-center gap-2 text-xs",style:{color:"var(--color-fg-secondary)"},children:[(0,c.jsx)("span",{className:"font-mono font-semibold",style:{color:"var(--color-fg)"},children:t.ident.iata??t.ident.icao}),(0,c.jsxs)("span",{children:[t.origin.iata??t.origin.icao," →"," ",t.destination.iata??t.destination.icao]}),(0,c.jsx)("span",{style:{color:"var(--color-fg-tertiary)"},children:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(new Date(t.scheduledDepartureAt))}),e.passengerName&&(0,c.jsx)("span",{style:{color:"var(--color-fg-tertiary)"},children:e.passengerName})]},r))})]},e.messageId??`extraction-${t}`)})})]})]})})]})]}),"results"===b&&(0,c.jsxs)("div",{children:[(0,c.jsx)(ro,{value:R,min:i?(0,eG.localDateStr)(i,j):rn(j),actualToday:rn(j),onChange:e=>{T(e),eE(w,C||null,e)}}),E&&(0,c.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-sm",style:{color:"var(--color-fg-tertiary)"},children:[(0,c.jsx)(ra,{}),"Finding flights…"]}),!E&&Y.length>0&&(s=i?new Date(i).getTime():0,u=Date.now(),f=[...new Set(Y.map(e=>{let t;return((t=e.ident).iata??t.icao).slice(0,2)}).filter(Boolean))].sort(),p=Y.filter(e=>{let t,r;if(t3(e.scheduledArrivalAt,u)||g&&((t=e.destination).iata??t.icao).toUpperCase()===w.toUpperCase()||N&&!((r=e.ident).iata??r.icao).startsWith(N.iata))return!1;let a=new Date(e.scheduledDepartureAt).getTime();return!s||!a||!(a1&&(0,c.jsxs)("div",{className:"mb-2 flex flex-wrap gap-1.5",children:[(0,c.jsx)("button",{type:"button",onClick:()=>A(null),className:"rounded-full px-2.5 py-1 text-xs font-semibold",style:{backgroundColor:N?"var(--color-surface-muted)":"var(--color-interactive)",color:N?"var(--color-fg-secondary)":"var(--color-fg-on-solid)"},children:"All airlines"}),f.map(e=>(0,c.jsx)("button",{type:"button",onClick:()=>A(t=>t?.iata===e?null:{iata:e,name:tK(e)??e}),className:"rounded-full px-2.5 py-1 text-xs font-semibold",style:{backgroundColor:N?.iata===e?"var(--color-interactive)":"var(--color-surface-muted)",color:N?.iata===e?"var(--color-fg-on-solid)":"var(--color-fg-secondary)"},children:e},e))]}),0===p.length?(0,c.jsx)("p",{className:"text-sm",style:{color:"var(--color-fg-tertiary)"},children:N?`No ${N.iata} flights among these results — try "All airlines."`:h?"No more flights today — try tomorrow.":"No remaining flights for this date — all were already departed, cancelled, or diverted."}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("p",{className:"mb-2 text-xs font-semibold",style:{color:"var(--color-fg-tertiary)"},children:[p.length," flight",1!==p.length?"s":""]}),(0,c.jsx)("div",{className:"max-h-96 overflow-y-auto rounded-md",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:p.map((e,r)=>{let a,n,i,o,l,s,d;return(0,c.jsxs)("button",{type:"button","data-testid":"route-result","data-ident":(a=e.ident).iata??a.icao,"data-fa-flight-id":"","data-origin":((n=e.origin).iata??n.icao)||w,"data-destination":(i=e.destination).iata??i.icao,"data-scheduled-out":e.scheduledDepartureAt,"data-scheduled-in":e.scheduledArrivalAt??"",onClick:()=>{let r,a,n,i,o;return r=(0,eG.localDateStr)(e.scheduledDepartureAt,j),n=g?w.toUpperCase():(a=e.origin).iata??a.icao,void t([{id:(0,eV.newId)(),identIata:(i=e.ident).iata??i.icao,identIcao:e.ident.icao,faFlightId:null,flightId:e.id,scheduledDate:r??"",originIata:n,destinationIata:(o=e.destination).iata??o.icao,scheduledDepartureAt:e.scheduledDepartureAt,scheduledArrivalAt:e.scheduledArrivalAt,snapshot:null,dataSource:"schedule",addedAt:new Date().toISOString()}])},className:"flex w-full items-start justify-between gap-3 px-3 py-2.5 text-left transition-colors hover:bg-interactive-subtle",style:{borderBottom:"1px solid var(--border-color-subtle)"},children:[(0,c.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)("span",{className:"shrink-0 font-mono text-sm font-bold",style:{color:"var(--color-fg)"},children:(o=e.ident).iata??o.icao}),((l=e.destination).iata??l.icao)&&(0,c.jsxs)("span",{className:"shrink-0 font-mono text-xs font-semibold",style:{color:"var(--color-fg-interactive)"},children:["→ ",(s=e.destination).iata??s.icao]}),e.destination.name&&(0,c.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",style:{color:"var(--color-fg-secondary)"},children:e.destination.name})]}),e.destination.city&&(0,c.jsx)("p",{className:"mt-0.5 truncate text-xs",style:{color:"var(--color-fg-tertiary)"},children:e.destination.city})]}),(0,c.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-0.5 pt-0.5 text-right",children:[(0,c.jsx)("span",{className:"text-xs font-semibold whitespace-nowrap",style:{color:"var(--color-fg-secondary)"},children:new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(new Date(e.scheduledDepartureAt))}),(0,c.jsxs)("span",{className:"text-xs whitespace-nowrap",style:{color:"var(--color-fg-tertiary)"},children:[new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:j}).format(new Date(e.scheduledDepartureAt))," ",((d=e.origin).iata??d.icao)||w]})]})]},`${e.ident.icao}-${r}`)})})]})]})),!E&&0===Y.length&&!L&&(0,c.jsx)("p",{className:"mt-3 text-sm",style:{color:"var(--color-fg-tertiary)"},children:"No scheduled flights found."})]}),eo&&(0,c.jsx)("p",{className:"mt-3 text-sm",style:{color:"var(--color-fg-danger)"},children:L})]})]})}var rs=e.i(82879),rc=e.i(94527),rd=e.i(98617);let ru={dismissible:!1,handleOnly:!0,modal:!1};function rf({...e}){return(0,c.jsx)(rc.Drawer.Root,{"data-slot":"drawer",...e})}function rp({...e}){return(0,c.jsx)(rc.Drawer.Trigger,{"data-slot":"drawer-trigger",...e})}function rh({...e}){return(0,c.jsx)(rc.Drawer.Portal,{"data-slot":"drawer-portal",...e})}function rm({...e}){return(0,c.jsx)(rc.Drawer.Close,{"data-slot":"drawer-close",...e})}function rg({className:e,...t}){return(0,c.jsx)(rc.Drawer.Overlay,{"data-slot":"drawer-overlay",className:(0,A.cn)("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...t})}function rb({effect:e}){return d.useEffect(e,[]),null}function rv({className:e,overlayClassName:t,overlayStyle:r,showCloseButton:a=!0,onCollapse:n,style:i,children:o,variant:l="classic",...s}){let u,[f,p]=d.useState(.8),m=d.useRef(null),g=void 0!==n;if("flint"===l)return(0,c.jsxs)(rh,{"data-slot":"drawer-portal",children:[(0,c.jsx)(rc.Drawer.Overlay,{"data-slot":"drawer-overlay",className:(0,A.cn)(rd.phoneSheetOverlayClass,t),style:r}),(0,c.jsxs)(rc.Drawer.Content,{"data-slot":"drawer-content","data-variant":"flint",className:(0,A.cn)(rd.phoneSheetClass,e),style:{...rd.phoneSheetStyle,...i},...s,children:[(0,c.jsx)(rd.SheetGrabber,{}),o]})]});let b=()=>{m.current=null,f<.2 fixed z-50 flex h-auto flex-col bg-surface data->{p(.8);let e=requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"});return()=>cancelAnimationFrame(e)}}),g?(0,c.jsx)("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize","aria-valuemin":Math.round(25),"aria-valuemax":Math.round(90),"aria-valuenow":Math.round(100*f),tabIndex:0,className:"flex h-8 shrink-0 cursor-row-resize touch-none items-center justify-center",onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),m.current={startY:e.clientY,startHeight:f}},onPointerMove:e=>{let t=m.current;if(!t)return;let r=(t.startY-e.clientY)/window.innerHeight;p(Math.min(.9,Math.max(0,t.startHeight+r)))},onPointerUp:b,onPointerCancel:b,onKeyDown:e=>{"ArrowUp"===e.key?(e.preventDefault(),p(e=>Math.min(.9,e+.05))):"ArrowDown"===e.key&&(e.preventDefault(),p(e=>Math.max(.25,e-.05)))},children:(0,c.jsx)("div",{className:"h-2 w-[100px] rounded-full bg-muted"})}):(0,c.jsx)("div",{className:"mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full bg-muted group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),a&&(u="absolute top-1 right-1 z-10 hidden size-11 cursor-pointer items-center justify-center rounded-full text-muted-foreground hover:text-foreground group-data-[vaul-drawer-direction=bottom]/drawer-content:flex",n?(0,c.jsx)("button",{type:"button","aria-label":"Close",onClick:n,className:u,children:(0,c.jsx)(h.X,{className:"size-5"})}):(0,c.jsx)(rm,{"aria-label":"Close",className:u,children:(0,c.jsx)(h.X,{className:"size-5"})})),o]})]})}function ry({className:e,...t}){return(0,c.jsx)(rc.Drawer.Title,{"data-slot":"drawer-title",className:(0,A.cn)("font-semibold text-foreground",e),...t})}var rx=e.i(35120),r_=e.i(74205);function rw({phone:e,classic:t=!1,variant:r="limit",onClose:a}){let n=(0,r_.upgradeTitle)(r),i=t?void 0:"sheet-motion",o=(0,c.jsx)(r_.default,{variant:r,onClose:a}),l=e=>(0,c.jsx)(r_.default,{variant:r,onClose:a,Title:e});return e&&!rx.PREMIUM_ENABLED?(0,c.jsx)(rv,{showCloseButton:!1,"aria-describedby":void 0,variant:t?"classic":"flint",style:t?{bottom:64}:void 0,children:(0,c.jsx)("div",{className:t?"px-4 pt-1 pb-4":"min-h-0 flex-1 overflow-y-auto",children:l(ry)})}):e?(0,c.jsxs)(rv,{showCloseButton:!1,onCollapse:t?a:void 0,"aria-describedby":void 0,overlayClassName:i,className:i,style:{height:"80vh"},children:[(0,c.jsx)(ry,{className:"sr-only",children:n}),(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o})]}):rx.PREMIUM_ENABLED?(0,c.jsxs)(rs.DialogContent,{showCloseButton:!1,"aria-describedby":void 0,className:"w-[95vw] max-w-xl gap-0 border-none bg-transparent p-0 shadow-none",children:[(0,c.jsx)(rs.DialogTitle,{className:"sr-only",children:n}),o]}):(0,c.jsx)(rs.DialogContent,{variant:"flint",showCloseButton:!1,"aria-describedby":void 0,children:l(rs.DialogTitle)})}function rS({itinerary:e,onAddLeg:t,trigger:r,initialChainLeg:a,defaultOpen:n,onCloseWithoutAdding:i,onNewTripCommitted:o,remainingFreeLegs:l}){let[s,u]=(0,d.useState)(n??!1),[f,p]=(0,d.useState)("search"),[h,m]=(0,d.useState)(()=>window.matchMedia("(max-width: 639px)").matches);(0,d.useEffect)(()=>{let e=window.matchMedia("(max-width: 639px)");m(e.matches);let t=e=>m(e.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]);let[g,b]=(0,d.useState)([]),[y,x]=(0,d.useState)(a?"connector":"new"),[_,w]=(0,d.useState)(a?.id??null),[S,j]=(0,d.useState)(!1),[C,k]=(0,d.useState)(null),N=[...a?(0,eW.buildLegChains)(e).find(e=>e.some(e=>e.id===a.id))??[a]:[],...g],A=(0,eW.buildLegChains)({...e,legs:N}),R=A.map(e=>e[e.length-1]),T=new Set(g.map(e=>e.id)),E=_??R[0]?.id??null,P=E?N.find(e=>e.id===E)??null:null,L=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=L.current;e&&0!==e.getClientRects().length&&(e.scrollTop=e.scrollHeight)},[g.length,f]);let I=t=>{t?(b([]),x(a?"connector":"new"),w(a?.id??null),p("search"),j(!1),k(null)):0===e.legs.length&&i?.(),u(t)},$="connector"===y,M=$?P?.destinationIata??null:null,O=$&&P?(0,eW.legGateTimes)(P).in.best:null,z=O?(0,eG.localDateStr)(O,M&&(0,v.getAirportByIata)(M)?.timezone||"UTC"):$?P?.scheduledDate??null:null,D=N.some(e=>"return"!==e.journeyLabel),F=N.some(e=>"return"===e.journeyLabel);return 0===l&&0===g.length?h?(0,c.jsxs)(rf,{...ru,open:s,onOpenChange:I,children:[(0,c.jsx)(rp,{asChild:!0,children:r}),(0,c.jsx)(rw,{phone:!0,classic:!0,onClose:()=>I(!1)})]}):(0,c.jsxs)(rs.Dialog,{open:s,onOpenChange:I,children:[(0,c.jsx)(rs.DialogTrigger,{asChild:!0,children:r}),(0,c.jsx)(rw,{phone:!1,classic:!0,onClose:()=>I(!1)})]}):(0,c.jsxs)(rs.Dialog,{open:s,onOpenChange:I,children:[(0,c.jsx)(rs.DialogTrigger,{asChild:!0,children:r}),(0,c.jsxs)(rs.DialogContent,{showCloseButton:!1,onEscapeKeyDown:e=>{g.length>0&&e.preventDefault()},onInteractOutside:e=>{g.length>0&&e.preventDefault()},className:"top-[8vh] flex h-[min(75vh,600px)] w-[95vw] translate-y-0 flex-col overflow-hidden rounded-lg p-0 shadow-lg sm:max-w-4xl sm:flex-row",style:{border:"1px solid var(--border-color-info-subtle)",backgroundColor:"var(--color-surface-sunken)"},children:[(0,c.jsx)(rs.DialogTitle,{className:"sr-only",children:"Add a flight"}),(0,c.jsx)("div",{className:"flex shrink-0 items-center gap-1 p-2 sm:hidden",style:{borderBottom:"1px solid var(--border-color-subtle)"},children:[["search","Add a flight"],["chain",`Flights${N.length>0?` (${N.length})`:""}`]].map(([e,t])=>(0,c.jsx)("button",{type:"button",onClick:()=>p(e),className:"flex-1 rounded-md px-3 py-1.5 text-xs font-semibold transition-colors",style:{backgroundColor:f===e?"var(--color-interactive)":"var(--color-interactive-subtle)",color:f===e?"var(--color-fg-on-solid)":"var(--color-fg-secondary)"},children:t},e))}),(0,c.jsxs)("div",{className:`min-h-0 min-w-0 flex-1 flex-col p-3 sm:flex ${"search"===f?"flex":"hidden"}`,children:[(0,c.jsx)("p",{className:"mb-2 hidden shrink-0 text-xs font-semibold tracking-wide uppercase sm:block",style:{color:"var(--color-fg-tertiary)"},children:"Add a flight"}),!$&&D&&!F&&(0,c.jsxs)("label",{className:"mb-2 flex shrink-0 items-center gap-2 text-xs font-medium",style:{color:"var(--color-fg)"},children:[(0,c.jsx)("input",{type:"checkbox",checked:S,onChange:e=>{k(null),j(e.target.checked)}}),"This is the return flight"]}),(0,c.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto rounded-lg",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:(0,c.jsx)(rl,{onStageLeg:e=>{if(0===e.length)return;if(e.length>1){let t=S?e.map(e=>({...e,journeyLabel:"return"})):e;b(e=>[...e,...t]),w(e[e.length-1].id);return}let[t]=e,r="connector"===y?E:null,a="connector"===y?P?.journeyLabel:S?"return":void 0;b(e=>[...e,{...t,connectedToLegId:r,journeyLabel:a}]),w(t.id),x("connector")},initialOrigin:M??void 0,initialDate:z??void 0,earliestDeparture:O??void 0,anonymousGateActive:null!==l,modeSelector:R.length>0&&(0,c.jsxs)("select",{value:$?E??"new":"new",onChange:e=>{if(j(!1),k(null),"new"===e.target.value){x("new"),w(null);return}x("connector"),w(e.target.value)},className:"shrink-0 rounded-md px-2 py-1.5 text-xs font-semibold",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)",color:"var(--color-fg)"},children:[(0,c.jsx)("option",{value:"new",children:"New flight"}),R.map(e=>{let t=function(e){let t=(0,eW.legGateTimes)(e).in.best;if(!t)return"";let r=e.snapshot?.destination.timezone||e.destinationIata&&(0,v.getAirportByIata)(e.destinationIata)?.timezone||"UTC";try{return new Intl.DateTimeFormat("en-US",{timeZone:r,month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}).format(new Date(t))}catch{return""}}(e);return(0,c.jsxs)("option",{value:e.id,children:["Connect from ",e.identIata," → ",e.destinationIata,t?` (${t})`:""]},e.id)})]})},$?E??"connector":_??"new")})]}),(0,c.jsxs)("div",{className:`flex min-h-0 w-full flex-col border-t border-subtle sm:w-72 sm:flex-none sm:border-t-0 sm:border-l ${"chain"===f?"flex-1":"flex-none"}`,children:[(0,c.jsxs)("div",{className:`min-h-0 flex-1 flex-col p-3 sm:flex ${"chain"===f?"flex":"hidden"}`,children:[(0,c.jsx)("p",{className:"mb-2 hidden shrink-0 text-xs font-semibold tracking-wide uppercase sm:block",style:{color:"var(--color-fg-tertiary)"},children:"Flights"}),(0,c.jsx)("div",{ref:L,className:"min-h-0 flex-1 space-y-2 overflow-y-auto rounded-lg p-2",style:{border:"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface)"},children:N.length>0?(0,c.jsx)(tB,{chains:A,onRemove:e=>{k(null),b(t=>t.filter(t=>t.id!==e).map(t=>t.connectedToLegId===e?{...t,connectedToLegId:null}:t)),w(t=>t===e?a?.id??null:t)},removableLegIds:T,renderLegAction:e=>{if(!T.has(e.id))return null;if(e.connectedToLegId)return(0,c.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void b(e=>e.map(e=>e.id===t?{...e,connectedToLegId:null}:e))},className:"text-xs font-semibold hover:underline",style:{color:"var(--color-fg-interactive)"},children:"✕ Disconnect from previous flight"});let t=N.findIndex(t=>t.id===e.id),r=t>0?N[t-1]:null;return r?(0,c.jsx)("button",{type:"button",onClick:()=>{var t,a;return t=e.id,a=r.id,void(b(e=>e.map(e=>e.id===t?{...e,connectedToLegId:a}:e)),w(t))},className:"text-xs font-semibold hover:underline",style:{color:"var(--color-fg-interactive)"},children:"+ Connect to previous flight"}):null}}):(0,c.jsx)("p",{className:"text-xs",style:{color:"var(--color-fg-tertiary)"},children:"No flights added yet."})})]}),(0,c.jsxs)("div",{className:"flex flex-col gap-2 p-3",style:{borderTop:"1px solid var(--border-color-subtle)"},children:[C&&(0,c.jsx)("p",{className:"text-xs font-medium",style:{color:"var(--color-fg-danger)"},children:C}),(0,c.jsx)("button",{type:"button","data-testid":"commit-staged-button",onClick:()=>{let r=g.filter(e=>"return"===e.journeyLabel).map(e=>(0,eW.legBookedTimes)(e).departure).filter(e=>!!e).sort()[0],a={...e,legs:[...e.legs,...g.filter(e=>"return"!==e.journeyLabel)]};if(r&&!(0,eW.returnDepartureIsValid)(a,r))return void k("The return flight must depart after the outbound trip’s last arrival.");if(null!==l&&g.length>l)return void k((0,tu.capReachedMessage)(l,g.length));k(null);let n=0===e.legs.length,i=0;try{for(let r of g)t(e.id,r),i++;if(n&&g.length>0){let t=(0,ts.pickPrimaryChain)((0,eW.buildLegChains)({...e,legs:g}));t&&o?.(e.id,t)}b([]),u(!1)}catch(e){console.error("[AddFlightModal] failed to commit staged legs",e),b(e=>e.slice(i)),k(i>0?`Added ${i} of ${g.length} flights, then something went wrong — try adding the rest again.`:"Something went wrong adding these flights — please try again.")}},disabled:0===g.length,className:"rounded-md py-2 text-sm font-semibold text-white transition-colors",style:{backgroundColor:0===g.length?"var(--color-fg-disabled)":"var(--color-interactive)"},children:g.length>0?`Add ${g.length} flight${1!==g.length?"s":""}`:"OK"}),(0,c.jsx)("button",{type:"button",onClick:()=>{0===e.legs.length&&i?.(),b([]),k(null),u(!1)},className:"rounded-md py-2 text-sm font-semibold transition-colors hover:bg-interactive-subtle",style:{color:"var(--color-fg-interactive)",border:"1px solid var(--border-color-info-subtle)"},children:"Cancel"})]})]})]})]})}function rj(e){if(!e)return"—";try{return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(new Date(e))}catch{return"—"}}function rC({itinerary:e,onAddLeg:t,onRemoveLeg:r,onDeleteItinerary:a,onRename:n,onSelectLeg:i,isSelected:o,onSelect:l,defaultExpanded:s,autoOpenAddFlight:u,onNewTripCommitted:f,remainingFreeLegs:p}){let[h,m]=(0,d.useState)(!1),[g,b]=(0,d.useState)(e.name),[v,y]=(0,d.useState)(s??!1),x=(0,tg.useRefreshState)(),_=e.legs,w=(0,eW.isItineraryPast)(e),S=(0,eW.buildLegChains)(e),j=S.reduce((e,t)=>e+Math.max(0,t.length-1),0),C=_[0],k=_[_.length-1],N=S.filter(e=>e.length>0).map(e=>{let t=[];return e[0].originIata&&t.push(e[0].originIata),e.forEach(e=>{e.destinationIata&&t.push(e.destinationIata)}),t.join(" → ")}),A=C?.snapshot?.times.gateOut.scheduled??C?.scheduledDepartureAt??(C?`${C.scheduledDate}T00:00:00Z`:null),R=k?.snapshot?.times.gateIn.scheduled??k?.scheduledArrivalAt??k?.snapshot?.times.gateOut.scheduled??k?.scheduledDepartureAt??(k?`${k.scheduledDate}T00:00:00Z`:null),T=Date.now(),E=(0,tm.worstChip)(_.map(e=>(0,tm.legFlightChip)(e,T,x))),P=(0,th.useLegsRisk)(_),L=(0,td.useWeatherConnectionAccess)(),I=(0,d.useMemo)(()=>(0,tp.summarizeTripRisk)((0,eW.buildLegChains)(e),e=>P.get(e.id)??null,{weatherConnections:L}),[e,P,L]),$=()=>{let t=g.trim();t&&t!==e.name?n(e.id,t):b(e.name),m(!1)};return(0,c.jsxs)("div",{className:"overflow-hidden rounded-lg",style:{border:o?"1px solid var(--border-color-interactive)":"1px solid var(--border-color-subtle)",backgroundColor:"var(--color-surface-sunken)"},children:[(0,c.jsxs)("div",{onClick:()=>l?.(e.id),className:"flex items-center gap-2 rounded-t-lg px-3 py-2",style:{borderBottom:v?"1px solid var(--border-color-subtle)":void 0,backgroundColor:"var(--color-surface)",cursor:l?"pointer":void 0},children:[(0,c.jsx)("button",{onClick:e=>{e.stopPropagation(),y(e=>!e)},className:"shrink-0 rounded p-0.5 transition-colors hover:bg-surface-muted","aria-label":v?"Collapse itinerary":"Expand itinerary",children:(0,c.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-fg-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"transform 0.15s ease",transform:v?"rotate(0deg)":"rotate(-90deg)"},children:(0,c.jsx)("path",{d:"M6 9l6 6 6-6"})})}),(0,c.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,c.jsxs)("p",{className:"truncate text-xs",style:{color:"var(--color-fg-tertiary)"},children:[N.length>0&&(0,c.jsxs)("span",{className:"font-mono",style:{color:"var(--color-fg-secondary)"},children:[N.join(", ")," · "]}),_.length," leg",1!==_.length?"s":"",j>0?` \xb7 ${j} connection${1!==j?"s":""}`:""]}),h?(0,c.jsx)("input",{type:"text",value:g,onChange:e=>b(e.target.value),onBlur:$,onKeyDown:t=>{"Enter"===t.key&&$(),"Escape"===t.key&&(b(e.name),m(!1))},onClick:e=>e.stopPropagation(),className:"w-full min-w-0 rounded border border-interactive px-2 py-1 text-sm font-semibold outline-none",style:{color:"var(--color-fg)"},autoFocus:!0}):(0,c.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),m(!0)},"aria-label":`Rename "${e.name}"`,className:"block w-full truncate rounded text-left text-sm font-semibold hover:underline",style:{color:"var(--color-fg)"},title:"Click to rename",children:e.name})]}),(0,c.jsxs)("div",{className:"min-w-0 shrink text-right",children:[A&&(0,c.jsxs)("p",{className:"truncate text-xs",style:{color:"var(--color-fg-tertiary)"},children:[rj(A),R&&R!==A?` – ${rj(R)}`:""]}),(E||I.delay||I.connection)&&(0,c.jsxs)("div",{className:"flex min-w-0 items-center justify-end gap-1 sm:gap-1.5",children:[(0,c.jsx)(tf.default,{summary:I}),E&&(0,c.jsx)("p",{className:"min-w-0 truncate text-xs font-semibold",style:{color:tD[E.tone]},children:E.label})]})]}),(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-1",onClick:e=>e.stopPropagation(),children:[!w&&(0,c.jsx)(rS,{itinerary:e,onAddLeg:t,remainingFreeLegs:p,defaultOpen:u,onCloseWithoutAdding:()=>a(e.id),onNewTripCommitted:f,trigger:(0,c.jsx)("button",{type:"button",hidden:!0,"aria-hidden":!0,tabIndex:-1})}),(0,c.jsx)("button",{onClick:()=>a(e.id),className:"rounded p-1.5 transition-colors hover:bg-danger-subtle hover:text-fg-danger","aria-label":"Delete itinerary",style:{color:"var(--color-fg-tertiary)"},children:(0,c.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,c.jsx)("path",{d:"M3 6h18"}),(0,c.jsx)("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),(0,c.jsx)("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"})]})})]})]}),v&&(0,c.jsx)("div",{className:"p-3",children:0===_.length?(0,c.jsx)("p",{className:"w-full rounded-lg py-6 text-center text-sm",style:{color:"var(--color-fg-tertiary)",border:"1px dashed var(--border-color-subtle)"},children:"No flights yet — use “+ Add Flight” above"}):(0,c.jsx)(tB,{chains:S,onRemove:t=>r(e.id,t),onSelect:i,renderTailAction:r=>w||!r.destinationIata?null:(0,c.jsx)(rS,{itinerary:e,onAddLeg:t,remainingFreeLegs:p,initialChainLeg:r,trigger:(0,c.jsx)("button",{type:"button",className:"rounded-md px-2 py-0.5 text-xs font-medium transition-colors hover:bg-interactive-subtle",style:{color:"var(--color-fg-interactive)",border:"1px solid var(--border-color-info-subtle)"},children:"+ Connecting Flight"})})})})]})}function rk({itineraries:e,onAddLeg:t,onRemoveLeg:r,onDeleteItinerary:a,onRename:n,onSelectLeg:i,selectedItineraryId:o,onSelectItinerary:l,onNewItinerary:s,lastRefresh:d,autoExpandItineraryId:u,autoOpenAddFlightItineraryId:f,onNewTripCommitted:p,remainingFreeLegs:h}){let m=e.filter(e=>!(0,eW.isItineraryPast)(e)),g=e.filter(e=>(0,eW.isItineraryPast)(e)),b=e=>(0,c.jsx)(rC,{itinerary:e,isSelected:e.id===o,onSelect:l,onAddLeg:t,onRemoveLeg:r,onDeleteItinerary:a,onRename:n,onSelectLeg:t=>i(e.id,t),defaultExpanded:e.id===u,autoOpenAddFlight:e.id===f,onNewTripCommitted:p,remainingFreeLegs:h},e.id);return(0,c.jsxs)("div",{className:"space-y-3",children:[0===e.length?(0,c.jsxs)("div",{className:"rounded-lg py-12 text-center",style:{border:"1px dashed var(--border-color-subtle)",backgroundColor:"var(--color-surface-sunken)"},children:[(0,c.jsx)("p",{className:"mb-3 text-sm",style:{color:"var(--color-fg-tertiary)"},children:"No flights yet. Create one to start tracking flights."}),(0,c.jsx)("button",{onClick:s,className:"rounded-md px-4 py-2 text-sm font-semibold transition-colors hover:opacity-90",style:{backgroundColor:"var(--color-interactive)",color:"var(--color-fg-on-solid)"},children:"Create Trip"})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{className:"space-y-2",children:m.map(b)}),g.length>0&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)("p",{className:"pt-2 text-xs font-semibold tracking-wide uppercase",style:{color:"var(--color-fg-tertiary)"},children:"Past Flights"}),(0,c.jsx)("div",{className:"space-y-2",style:{opacity:.65},children:g.map(b)})]})]}),(0,c.jsx)("div",{className:"flex items-center justify-end",children:d&&(0,c.jsxs)("span",{className:"text-xs",style:{color:"var(--color-fg-disabled)"},children:["Updated"," ",new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}).format(d)]})})]})}var rN=e.i(93086),rA=e.i(79764),rR=e.i(72928),rT=e.i(84209),rE=e.i(7146),rP=e.i(67795),rL=e.i(10845);let rI={info:"bg-interactive",success:"bg-success",danger:"bg-danger",warning:"bg-warning",neutral:"bg-fg-tertiary"};function r$({label:e,selected:t,onClick:r,tone:a,dotColor:n,testId:i,children:o}){return(0,c.jsxs)("button",{type:"button","data-testid":i,"data-selected":t||void 0,"aria-label":e,"aria-current":t||void 0,title:e,onClick:r,className:(0,A.cn)("relative flex size-14 shrink-0 press-97 items-center justify-center rounded-2xl bg-surface text-fg hover-ring focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none",t&&"selected-ring"),children:[o,(a||n)&&(0,c.jsx)("span",{"data-testid":"flint-rail-tile-dot","aria-hidden":"true",className:(0,A.cn)("absolute -right-1 -bottom-1 size-3 rounded-full",!n&&a&&rI[a]),style:n?{backgroundColor:n}:void 0})]})}function rM(e){let t=(0,tg.useRefreshState)(),{itineraries:r,onSelectLeg:a,selectedLegId:n,onNewItinerary:i}=e,o=Date.now(),l=(0,eW.sortedTripGroups)(r,o),s=(0,rN.pastTrips)(l.filter(e=>(0,eW.isGroupPast)(e,o))),[u,f]=(0,d.useState)(!1);return(0,rN.useProvidePastFlightsFor)(e,()=>f(!0)),(0,c.jsxs)("div",{"data-testid":"flint-flight-rail",className:"flex w-full flex-1 flex-col items-center gap-2",children:[l.filter(e=>!(0,eW.isGroupPast)(e,o)||e.legs.some(e=>e.id===n)).map(r=>{let{itinerary:i,legs:l}=r,s=l.map((r,s)=>{let d=(0,rE.splitFlightIdent)(r.identIata),u=r.originIata??"—",f=r.destinationIata??"—",p=`${r.identIata} ${u} to ${f}`,h=s>0?(0,eW.analyzeConnection)(l[s-1],r):null;return(0,c.jsxs)("div",{className:"contents",children:[h&&(0,c.jsx)("span",{"data-testid":"flint-rail-layover",className:"text-caption leading-none text-fg-tertiary",children:(0,rT.formatMinutes)(h.estimatedLayoverMinutes)}),(0,c.jsx)(rL.TripMenu,{name:r.identIata,buttonLabel:p,multi:!1,onRemove:()=>(0,rN.removeWithUndo)(e,i.id,[r],(0,rN.flightName)(r)),withButton:!1,children:()=>(0,c.jsx)("span",{className:"contents",children:(0,c.jsx)(r$,{testId:"flint-rail-tile",label:p,selected:r.id===n,onClick:()=>a(i.id,r),tone:(0,tm.legFlightChip)(r,o,t)?.tone,children:(0,c.jsx)(rP.default,{iata:d?.airline??r.identIata.slice(0,2),size:36})})})})]},r.id)});return 1===l.length?(0,c.jsx)("div",{className:"contents",children:s},r.key):(0,c.jsx)("div",{"data-testid":"flint-rail-trip","aria-label":i.name,role:"group",className:"flex flex-col items-center gap-1.5 border-l-2 border-strong pl-1.5",children:s},r.key)}),(0,c.jsx)("button",{type:"button",onClick:i,"data-testid":"flint-rail-add","aria-label":"Add a flight",title:"Add a flight",className:"flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-muted text-fg-secondary transition-colors hover:text-fg focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none",children:(0,c.jsx)(h.Plus,{size:20,"aria-hidden":"true"})}),(0,c.jsx)("div",{className:"sticky bottom-0 mt-auto flex w-full justify-center bg-gradient-to-t from-canvas from-65% to-transparent pt-6",children:(0,c.jsx)("button",{type:"button","data-testid":"flint-rail-past","aria-label":(0,rR.pastFlightsLabel)((0,rR.countLegs)(s),"spoken"),title:(0,rR.pastFlightsLabel)((0,rR.countLegs)(s),"visible"),onClick:()=>f(!0),className:"flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-muted text-fg-secondary transition-colors hover:text-fg focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none",children:(0,c.jsx)(h.PastFlights,{size:20,"aria-hidden":"true"})})}),(0,c.jsx)(rN.PastFlightsSheet,{open:u,onOpenChange:f,past:s,list:e})]})}var rO=e.i(70499);let rz="flights.installHintDismissedAt";function rD(){var e;let[t,r]=(0,d.useState)(!1),[a,n]=(0,d.useState)(!1),[i,o]=(0,d.useState)(!1),[l,s]=(0,d.useState)(!0),[u,f]=(0,d.useState)(null);(0,d.useEffect)(()=>{var e,t;n(window.matchMedia("(display-mode: standalone)").matches||!0===navigator.standalone),o((e=navigator.userAgent,t=navigator.maxTouchPoints,/iPad|iPhone|iPod/.test(e)||/Macintosh/.test(e)&&t>1));try{s(function(e,t=Date.now()){let r=Number(e);return Number.isFinite(r)&&r>0&&t-r{e.preventDefault(),f(e)};return window.addEventListener("beforeinstallprompt",a),r(!0),()=>window.removeEventListener("beforeinstallprompt",a)},[]);let p=(e={standalone:a,ios:i,hasPrompt:!!u}).standalone?"none":e.ios?"ios":e.hasPrompt?"prompt":"none";if(!t||l||"none"===p)return null;let h=()=>{s(!0);try{localStorage.setItem(rz,String(Date.now()))}catch{}};return(0,c.jsxs)("div",{"data-testid":"install-hint",className:"flex items-center justify-between gap-3 rounded-lg px-3 py-2 text-xs",style:{backgroundColor:"var(--color-interactive-subtle)",color:"var(--color-fg-interactive)"},children:[(0,c.jsx)("span",{children:"ios"===p?"Get flight alerts: tap Share, then “Add to Home Screen”.":"Install Flights on your device for quicker access and flight alerts."}),(0,c.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:["prompt"===p&&u&&(0,c.jsx)("button",{type:"button",className:"rounded px-2 py-1 font-semibold text-white",style:{backgroundColor:"var(--color-interactive)"},onClick:()=>{u.prompt().then(()=>u.userChoice).then(e=>{"accepted"===e.outcome&&h(),f(null)})},children:"Install"}),(0,c.jsx)("button",{type:"button",className:"rounded px-1.5 py-1 hover:bg-surface/60","aria-label":"Dismiss install hint",onClick:h,children:"✕"})]})]})}var rF=e.i(6191),rU=e.i(24944),rq=e.i(80637),rW=e.i(55299);function rB({autoCreateSignal:t,onAutoCreateHandled:r,onFlightSelected:a,autoSelectDoneRef:n,listVariant:i="classic",onRefresh:o,freemiumGate:l=!0}){let s=(0,u.useRouter)(),f=(0,u.usePathname)(),p=(0,u.useSearchParams)(),[h,m]=(0,d.useState)([]),[g,b]=(0,d.useState)(!1),[v,y]=(0,d.useState)(null),x=(0,d.useRef)(!0),_=(0,d.useRef)([]),w=(0,d.useRef)(!1),[S,j]=(0,d.useState)(!1),C=(0,d.useRef)({}),k=e=>{C.current=Object.fromEntries(e.map(e=>[e.id,e.updatedAt]))},[N,A]=(0,d.useState)(null),[R,T]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(null===N&&null===R)return;let e=setTimeout(()=>{A(null),T(null)},0);return()=>clearTimeout(e)},[N,R]);let I="classic"!==i,[$,M]=(0,d.useState)(!1),[O,z]=(0,d.useState)(null),[D,F]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=!1;return(0,rU.pruneTripNotes)(),(async()=>{let t=(0,eq.loadItineraries)(),r=await ti(t);if(e)return;x.current=!0;let a=null===r?(0,eq.loadItineraries)():r;null===r?m(a):(w.current=!0,j(!0),m(r),(0,eq.saveItineraries)(r),k(r)),(0,rW.pruneStoredAlerts)(a,!0),b(!0)})(),()=>{e=!0}},[]),(0,d.useEffect)(()=>{if(!g)return;let e=e=>{if(!(0,eB.isItinerariesStorageKey)(e.key))return;let t=(0,eq.loadItineraries)();x.current=!0,C.current=Object.fromEntries(t.map(e=>[e.id,e.updatedAt])),m(t)};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[g]),(0,d.useEffect)(()=>{if(!g)return;let e=!1,t=async()=>{if(!document.hidden&&!e&&w.current){e=!0;try{let e=(0,eq.loadItineraries)(),t=await ti(e),r=JSON.stringify((0,eq.loadItineraries)());if(null===t||r!==JSON.stringify(e)||JSON.stringify(t)===r)return;x.current=!0,m(t),(0,eq.saveItineraries)(t),k(t),(0,rW.pruneStoredAlerts)(t,!0)}finally{e=!1}}};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[g]),(0,d.useEffect)(()=>{0===h.length?F(null):h.some(e=>e.id===D)||F(h[0].id)},[h,D]);let U=(0,d.useRef)(!1),q=(0,d.useRef)(!1);(0,d.useEffect)(()=>{if(!g||U.current)return;U.current=!0;let e=(0,P.parseSelection)(p);if(e?.kind!=="flight-leg")return;let t=h.find(t=>t.legs.some(t=>(0,ts.legMatchesSelection)(t,e)));t&&(F(t.id),A(t.id))},[g,h,p]),(0,d.useEffect)(()=>{_.current=h,g&&(0,tg.setDataAt)((0,rF.newestDataAt)(h.flatMap(e=>e.legs)))},[h,g]),(0,d.useEffect)(()=>{e.A(52498).then(()=>void 0).catch(()=>{})},[]),(0,d.useEffect)(()=>{if(x.current){x.current=!1;return}if((0,eq.saveItineraries)(h),w.current)for(let e of h)C.current[e.id]!==e.updatedAt&&(C.current[e.id]=e.updatedAt,tn.push(e))},[h]);let W=(0,d.useCallback)(async()=>{let e=_.current,t=new Date().toISOString().split("T")[0],r=(0,tG.refreshableLegs)(e,t);if(0===r.length){(0,tg.recordRefreshCycle)({asked:0,answered:0}),y(new Date);return}let a=await Promise.all(r.map(({itId:e,leg:t})=>(0,tL.refreshLegSnapshot)(t).then(r=>!!r&&(m(a=>a.map(a=>a.id!==e?a:{...a,legs:a.legs.map(e=>e.id===t.id?(0,tG.mergeSnapshotIntoLeg)(e,r):e),updatedAt:new Date().toISOString()})),!0)).catch(()=>!1)));if((0,tg.recordRefreshCycle)({asked:a.length,answered:a.filter(Boolean).length}),a.some(Boolean))y(new Date);else{let t=Math.max(0,...e.map(e=>Date.parse(e.updatedAt)||0));t>0&&y(e=>e??new Date(t))}},[]),B=(0,d.useRef)(o);B.current=o,(0,d.useEffect)(()=>{v&&B.current?.({at:v,legs:_.current.reduce((e,t)=>e+t.legs.length,0)})},[v]),(0,d.useEffect)(()=>{if(!g)return;W();let e=null,t=()=>{e||(e=setInterval(W,12e4))},r=()=>{e&&(clearInterval(e),e=null)},a=()=>{document.hidden?r():(W(),t())};return t(),document.addEventListener("visibilitychange",a),()=>{r(),document.removeEventListener("visibilitychange",a)}},[g,W]);let H=(e,t)=>{m(r=>r.map(r=>r.id===e?(0,eW.addLegToItinerary)(r,t):r))},K=(e,t)=>{let r=e=>(0,rq.tripNotesKey)(e.identIata,e.scheduledDate),a=new Set(t.flatMap(e=>e.legs).map(r));(0,rU.forgetTripNotes)(e.map(r).filter(e=>!a.has(e))),(0,rW.removeStoredAlertsOfLegs)(e,t)},G=(0,P.parseSelection)(p),V=G?.kind==="flight-leg"?[...h.filter(e=>e.id===D),...h.filter(e=>e.id!==D)].flatMap(e=>e.legs).find(e=>(0,ts.legMatchesSelection)(e,G))?.id??null:null,Y=(e,t,r=!0)=>{let a=h.find(t=>t.id===e)?.legs.find(e=>e.id===t);if(a&&a.id===V){(0,E.stopPlayback)();let e=L(p,null);e.delete("siblings");let t=e.toString();s.replace(t?`${f}?${t}`:f,{scroll:!1})}a&&r&&K([a],h.map(r=>r.id===e?(0,eW.removeLegFromItinerary)(r,t):r)),m(r=>r.map(r=>r.id===e?(0,eW.removeLegFromItinerary)(r,t):r))},J=(e,t=!0)=>{let r,a=h.find(t=>t.id===e);if(a&&(r=(0,P.parseSelection)(p),r?.kind==="trip"?r.itineraryId===a.id:r?.kind==="flight-leg"&&a.legs.some(e=>(0,ts.legMatchesSelection)(e,r)))){(0,E.stopPlayback)();let e=L(p,null).toString();s.replace(e?`${f}?${e}`:f,{scroll:!1})}a&&t&&K(a.legs,(0,eW.deleteItinerary)(h,e)),m(t=>(0,eW.deleteItinerary)(t,e)),delete C.current[e],w.current&&tn.remove(e)},X=()=>{if(I){z(null),M(!0);return}let e=(0,eW.createItinerary)(eW.DEFAULT_ITINERARY_NAME);m(t=>[...t,e]),A(e.id),T(e.id)};(0,d.useEffect)(()=>{t&&g&&(X(),r?.())},[t,g]);let Z=(0,d.useCallback)((e,t)=>{let r=e.faFlightId??e.identIcao??e.identIata,n=L(p,{kind:"flight-leg",identIcao:r,originIcao:(0,tc.legOriginIcao)(e),destinationIcao:(0,tc.legDestinationIcao)(e),date:e.scheduledDate||null}),i=(0,ts.buildSiblingsParam)(t);i?n.set("siblings",i):n.delete("siblings"),(0,E.stopPlayback)(),s.replace(`${f}?${n.toString()}`,{scroll:!1}),a?.(r)},[f,s,p,a]),Q=(e,t)=>{F(e);let[r,...a]=t;r&&Z(r,a)},ee=(e,t)=>{F(e);let r=h.find(t=>t.id===e),a=((r&&(0,eW.buildLegChains)(r).find(e=>e.some(e=>e.id===t.id)))??[t]).filter(e=>e.id!==t.id);Z(t,a)},et=(0,d.useMemo)(()=>(0,eW.sortItinerariesByUpcoming)(h),[h]);if((0,d.useEffect)(()=>{let e=n??q;if(!g||e.current||(e.current=!0,(0,P.parseSelection)(p)))return;let t=Date.now();for(let e of et){if((0,eW.isItineraryPast)(e,t))break;let r=(0,ts.pickPrimaryChain)((0,eW.buildLegChains)(e),t);if(!r)continue;let[a,...n]=r;F(e.id),Z(a,n);return}},[g,et,p,Z,n]),!g)return null;let er=(0,tu.gatedRemainingFreeLegs)(h,S,l),ea="flint-carousel"===i?rA.default:"flint-rail"===i?rM:"flint"===i?rN.default:rk;return(0,c.jsx)(td.ConnectionAccessProvider,{value:null===er,children:(0,c.jsxs)("div",{className:"flint-rail"===i?"flex min-h-0 w-full flex-1 flex-col":"flint"===i||"flint-carousel"===i?"flex flex-1 flex-col":"space-y-3",children:["flint-carousel"!==i&&"flint-rail"!==i&&h.some(e=>e.legs.length>0)&&(0,c.jsx)(rD,{}),(0,c.jsx)(ea,{itineraries:et,remainingFreeLegs:er,onAddLeg:H,onRemoveLeg:Y,onDeleteItinerary:J,onRemoveUndoable:(e,t)=>{let r=h.find(t=>t.id===e);if(!r)return null;let a=r.legs.filter(e=>t.includes(e.id)),n=a.length>=r.legs.length;if(n)J(e,!1);else for(let t of a)Y(e,t.id,!1);return{undo:()=>{let t;n&&tn.cancelRemove(e),t={...r,updatedAt:new Date().toISOString()},m(e=>e.some(e=>e.id===r.id)?e.map(e=>e.id===r.id?t:e):[...e,t])},finish:()=>K(a,_.current)}},onRename:(e,t)=>{m(r=>r.map(r=>r.id===e?{...r,name:t,updatedAt:new Date().toISOString()}:r))},onSelectLeg:ee,selectedItineraryId:D,selectedLegId:V,onSelectItinerary:e=>{F(e);let t=h.find(t=>t.id===e);if(!t)return;let r=(0,ts.pickPrimaryChain)((0,eW.buildLegChains)(t));if(!r)return;let[a,...n]=r;Z(a,n)},onNewItinerary:X,lastRefresh:v,autoExpandItineraryId:N,autoOpenAddFlightItineraryId:R,onNewTripCommitted:Q,onAddConnecting:I?(e,t)=>{z({itineraryId:e,leg:t}),M(!0)}:void 0}),I&&(0,c.jsx)(rO.default,{open:$,onOpenChange:M,itineraries:h,remainingFreeLegs:er,onTrack:e=>{if(null!==er&&ere.id===t),i=a&&n?(0,eW.connectLeg)(n,r.id,a):null;return!!i&&(H(t,i.leg),!0)}let t=e.reduce((e,t)=>(0,eW.addLegToItinerary)(e,t),(0,eW.createItinerary)(eW.DEFAULT_ITINERARY_NAME));return m(e=>[...e,t]),Q(t.id,e),!0},onLiveFlight:(e,t)=>m(r=>r.map(r=>r.legs.some(t=>t.id===e)?{...r,legs:r.legs.map(r=>r.id===e?(0,tG.mergeSnapshotIntoLeg)(r,t):r),updatedAt:new Date().toISOString()}:r)),onView:e=>{let t=h.find(t=>t.legs.some(t=>t.id===e.id));t&&ee(t.id,e)},connectFrom:O?.leg??null})]})})}var rH=e.i(48322);function rK({compact:e=!1,onSearch:t}){let r="Search for an airport to keep an eye on its delays. The airports of your flights show here too.";return e?(0,c.jsxs)("section",{"data-testid":"airports-empty",className:"flex flex-col items-center justify-center gap-stack-xs px-6 py-4 text-center",children:[(0,c.jsx)("button",{type:"button","data-testid":"flint-find-airport","aria-label":"Search airports",onClick:t,className:"mb-stack-xs flex size-12 press-90 items-center justify-center rounded-card bg-surface-muted text-fg hover:bg-fg/10 focus-visible:ring-2 focus-visible:ring-focus focus-visible:outline-none",children:(0,c.jsx)(h.Search,{size:22,"aria-hidden":!0})}),(0,c.jsx)("h2",{className:"text-title text-fg",children:"No airports yet"}),(0,c.jsx)("p",{className:"max-w-72 text-body-sm text-fg-secondary",children:r})]}):(0,c.jsxs)("section",{"data-testid":"airports-empty",className:"mx-4 rounded-card border border-dashed border-subtle px-6 py-8 text-center",children:[(0,c.jsx)("h2",{className:"text-body-strong text-fg",children:"No airports yet"}),(0,c.jsx)("p",{className:"mt-1 text-body-sm text-fg-secondary",children:r})]})}let rG=(0,A.cn)(R.segmentItem,"border-0 text-fg-secondary after:hidden data-[state=active]:bg-surface data-[state=active]:text-fg data-[state=active]:shadow-sm dark:data-[state=active]:bg-surface dark:data-[state=active]:text-fg"),rV=(0,A.cn)(rG,"data-[state=active]:bg-transparent data-[state=active]:shadow-none group-data-[variant=default]/tabs-list:data-[state=active]:shadow-none dark:data-[state=active]:bg-transparent");function rY({airports:e,pinnableAirports:t=e,airportStatuses:r,value:a,flightsStatus:n,onValueChange:i,onSelectAirport:o,onSelectExtraAirport:l,autoCreateFlightSignal:s,onAutoCreateFlightHandled:u,selectedIata:f,highlightedIatas:p,hideTabList:h,onFlightSelected:m,autoSelectDoneRef:g,flightListVariant:b="classic",airportListVariant:v="classic",freemiumGate:y=!0,onFlightsRefresh:x,onRemoveAirport:_}){let[,w]=I(),[S,j]=(0,d.useState)("flights"),C=a??S,[k,N]=(0,d.useState)(!1),E="classic"!==b,[P,L]=(0,d.useState)(()=>new Set([C]));P.has(C)||L(new Set([...P,C]));let[$,M]=(0,d.useState)(!1),O=(0,d.useRef)(C);$||C===O.current||M(!0);let z=e=>E?{forceMount:!!P.has(e)||void 0,style:{"--page-dir":"flights"===e?-1:1},className:(0,A.cn)("data-[state=inactive]:hidden",$&&"data-[state=active]:animate-page-in")}:{};return(0,c.jsxs)(ei,{value:C,onValueChange:i??j,className:"h-full min-h-0 gap-0",children:[(!h||"flights"===C)&&(0,c.jsxs)("div",{className:(0,A.cn)("mx-4 flex items-center gap-2",E?"mt-4":"mt-2",h?"justify-end":"justify-between"),children:[!h&&(0,c.jsxs)(el,{className:(0,A.cn)("shrink-0",E?(0,A.cn)("h-auto w-full",R.segmentTrack):"w-fit",E&&"relative"),children:[E&&(0,c.jsx)(T.SegmentPill,{className:R.segmentPill}),(0,c.jsxs)(es,{value:"flights",className:(0,A.cn)(E&&rV),title:n?.level?(0,rH.statusDescription)(n.level,n.label):void 0,children:[E?"My flights":"Flights",n?.level&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(rH.default,{level:n.level,className:"ml-1.5"}),(0,c.jsxs)("span",{className:"sr-only",children:[","," ",(0,rH.statusDescription)(n.level,n.label)]})]})]}),(0,c.jsx)(es,{value:"airports",className:(0,A.cn)(E&&rV),children:"Airports"})]}),"flights"===C&&!E&&(0,c.jsx)("button",{"data-testid":"new-itinerary-button",onClick:()=>N(!0),className:"text-xs font-semibold",style:{color:"var(--color-fg-interactive)"},children:"+ Add Flight"})]}),(0,c.jsx)(ec,{value:"airports",...z("airports"),className:(0,A.cn)("min-h-0 overflow-hidden",z("airports").className),children:(0,c.jsx)("div",{className:(0,A.cn)("h-full overflow-y-auto",E&&"scrollbar-none"),children:(0,c.jsx)(eF,{rowVariant:v,airports:e,pinnableAirports:t,airportStatuses:r,showHeaders:!0,sortBy:"severity",onAirportSelect:(e,t)=>o?o(e,{fly:t?.searched??!1}):w({kind:"airport",icao:e.icao}),onPinExtra:l,selectedIata:f,highlightedIatas:p,onRemoveAirport:_,emptyState:"flint"===v?(0,c.jsx)(rK,{}):void 0})})}),(0,c.jsx)(ec,{value:"flights",...z("flights"),className:(0,A.cn)("min-h-0 overflow-y-auto",E&&"scrollbar-none","flint"===b&&"flex flex-col",z("flights").className),children:(0,c.jsx)("div",{className:(0,A.cn)("flint"===b?"flex flex-1 flex-col px-4 pt-2.5 pb-4":"px-4 py-3"),children:(0,c.jsx)(rB,{autoCreateSignal:s||k,onAutoCreateHandled:()=>{u?.(),N(!1)},onFlightSelected:m,autoSelectDoneRef:g,listVariant:b,onRefresh:x,freemiumGate:y})})})]})}var rJ=e.i(60116),rX=d,rZ="__remote_components_shadowroot_",rQ=[{global:"__remote_component_scopes__",prop:"scopes"},{global:"__remote_components_turbopack_chunk_loader_promise__",prop:"chunkCache"},{global:"__remote_script_entrypoint_mount__",prop:"mountFns"},{global:"__remote_script_entrypoint_unmount__",prop:"unmountFns"},{global:"__remote_bundle_url__",prop:"bundleUrls"},{global:"__rc_module_registry__",prop:"moduleRegistry"},{global:"__remote_component_host_shared_modules__",prop:"hostSharedModules"},{global:"__remote_next_css__",prop:"cssCache"}];function r0(){let e=globalThis,t=e.__remote_components__;if(t)return t;let r={scopes:new Map,chunkCache:{},mountFns:{},unmountFns:{},bundleUrls:{},moduleRegistry:{},dispatcherRuntime:void 0,hostSharedModules:{},cssCache:{},pageComponentCache:{},shadowRoots:{}};for(let{global:t,prop:a}of rQ){let n=e[t];null!=n&&(r[a]=n),e[t]=r[a]}for(let t of Object.keys(e))if(t.startsWith(rZ)){let a=t.slice(rZ.length);r.shadowRoots[a]=e[t],delete e[t]}return e.__remote_components__=r,r}var r1=e.i(93547);function r2(e){try{return new URL(e,location.href).pathname===r1.RC_PROTECTED_REMOTE_FETCH_PATHNAME}catch{return!1}}function r5(e){return e instanceof DOMException&&"AbortError"===e.name||null!==e&&"object"==typeof e&&"name"in e&&"AbortError"===e.name&&"message"in e&&"string"==typeof e.message&&("number"==typeof e.code||e.constructor?.name==="DOMException")}var r4=class extends Error{code="REMOTE_COMPONENTS_ERROR";constructor(e,t){super(e,t),this.name="RemoteComponentsError"}};async function r3(e,t,r){if(r2(t.href)&&r){let a=await r.text().catch(()=>"");return function(e,t,r,a){if(404===r)return new r4(`Could not proxy the request to "${e}" \u2014 the proxy endpoint "${r1.RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404. The host server needs middleware or a route that handles "${r1.RC_PROTECTED_REMOTE_FETCH_PATHNAME}". Proxying requires two pieces: 1. resolveClientUrl={routeThroughHostProxy} on 2. Middleware or a route for "${r1.RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server Docs: ${r1.CORS_DOCS_URL}`);if(403===r){let e=a?` ${a}`:"";return new r4(`Proxied request to "${t}" was forbidden.${e} See: ${r1.CORS_DOCS_URL}`)}return new r4(`Proxied request for "${e}" via "${t}" failed with status ${r}. See: ${r1.CORS_DOCS_URL}`)}(e,t.href,r.status,a)}let a=function(e,{status:t,statusText:r},a="Is the URL correct and accessible?"){return new r4(`Failed to fetch Remote Component from "${e}". ${a}`,{cause:Error(`${t} ${r}`)})}(e,r??{status:0,statusText:"No Response"});if(!r)return a;try{let e=await r.text(),t=new DOMParser().parseFromString(e,"text/html").querySelector("template[data-next-error-message]"),a=t?.getAttribute("data-next-error-message");if(a){let e=new r4(a),r=t?.getAttribute("data-next-error-stack");return r&&(e.stack=r),e}}catch(e){if(r5(e))throw e}return a}function r6(e,t,r){return new r4(`Failed to load ${e} "${t}" via proxy "${r}". Ensure withRemoteComponentsHostProxy middleware is configured, "${r1.RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${r1.CORS_DOCS_URL}`)}var r8="remote-components",r9="true"===localStorage.getItem("RC_DEBUG")||void 0!==to.default&&"true"===to.default.env.RC_DEBUG;function r7(e,t){r9&&console.debug(`[${r8}:${e}]: ${t}`)}function ae(e,t){console.warn(`[${r8}:${e}]: ${t}`)}function at(e,t,r){console.error(new r4(`[${r8}:${e}]: ${t}`,{cause:r}))}function ar(e,t){try{let r="string"==typeof t?new URL(t):t;if("u"{if("resolved"!==r.status){e.protocol===aa&&r.required&&at("SharedBroker",`Remote Component "${e.bundle}" requires shared module "${r.specifier}", but the host does not provide it. Add it to the host shared modules through \`withRemoteComponentsConfig({ shared: [...] })\` or the \`shared\` prop. This diagnostic runs when both host and remote support the shared-module manifest in remote-components >=0.5.0. The remote may load its bundled copy during the compatibility window; this will become a load error after remote-components .*?)\[(?[^\]]+)\](?:%20| )(?.+)/,ap=/\/_next\/\[.+\](?:%20| )/,ah=/(?[e,t])):void 0;return Object.assign(({config:r,src:n,width:i,quality:o})=>{let l=o??75,s=ab(e)?.url.origin??"",c=s&&s!==location.origin?`${s}${r.path??"/_next/image"}`:r.path??`${s}/_next/image`;if(!("string"==typeof n&&n.startsWith("/")&&!n.startsWith("//"))){let e=`${c}?url=${encodeURIComponent(n)}&w=${i}&q=${l}`;return t?.(e)??e}let d=function(e){let t=e.indexOf("?");if(-1===t)return{deploymentId:void 0,src:e};let r=new URLSearchParams(e.slice(t+1)),a=r.get("dpl")||void 0;if(!a)return{deploymentId:void 0,src:e};r.delete("dpl");let n=r.toString();return{deploymentId:a,src:`${e.slice(0,t)}${n?`?${n}`:""}`}}(n),u=d.deploymentId??a?.get(d.src),f=u?`&dpl=${encodeURIComponent(u)}`:"",p=`${c}?url=${encodeURIComponent(d.src)}&w=${i}&q=${l}${f}`;return t?.(p)??p},{__next_img_default:!0})}function a_(e){window.dispatchEvent(new CustomEvent("remote-components:navigate",{detail:e}))}var aw={react:"/react/index.js","react/jsx-dev-runtime":"/react/jsx-dev-runtime.js","react/jsx-runtime":"/react/jsx-runtime.js","react-dom":"/react-dom/index.js","react-dom/client":"/react-dom/client.js"};async function aS(e,t){await Promise.all(e.map(e=>new Promise((r,a)=>{let n=new URL(e.src.replace(ap,"/_next/"),location.origin).href,i=new URL(t?.(n)??n,location.href).href;if(Array.from(document.querySelectorAll("script[src]")).some(e=>e.src===i))return void r();let o=document.createElement("script");o.onload=()=>r(),o.onerror=()=>{r2(i)?a(r6("script",n,i)):(ar("ScriptLoader",n),a(new r4(`Failed to load