1import{r as u,s as v,j as e,b0 as q,B as F}from"./index-CI4XbE8D.js";import{o as t,m as f}from"./orShell-BqFY2BVw.js";const N=36,M=24*N;function L(){const[n,a]=u.useState("list"),[x,_]=u.useState([]),[l,p]=u.useState([]),[m,r]=u.useState({}),[i,d]=u.useState(!0),[h,w]=u.useState(14),$=async()=>{d(!0);const s=new Date;s.setHours(0,0,0,0);const c=new Date(s);c.setDate(c.getDate()+h);const[{data:g},{data:y}]=await Promise.all([v.from("or_flight_schedule").select("*").gte("etd",s.toISOString()).lt("etd",c.toISOString()).order("etd",{ascending:!0}),v.from("or_aircraft").select("id, tail_number, type, category").eq("active",!0)]),b=Array.from(new Set((g??[]).map(k=>k.inquiry_id).filter(Boolean)));let j={};if(b.length){const{data:k}=await v.from("or_inquiries").select("id, ref_number, contact_name, pax, quoted_price, status").in("id",b);j=Object.fromEntries((k??[]).map(S=>[S.id,S]))}_(g??[]),p(y??[]),r(j),d(!1)};u.useEffect(()=>{$()},[h]),u.useEffect(()=>{const s=v.channel("or_flight_schedule_changes").on("postgres_changes",{event:"*",schema:"public",table:"or_flight_schedule"},()=>$()).subscribe();return()=>{v.removeChannel(s)}},[]);const o=u.useMemo(()=>{const s=new Map;for(const c of x){const g=c.etd.slice(0,10);s.has(c.aircraft_id)||s.set(c.aircraft_id,new Map);const y=s.get(c.aircraft_id);y.has(g)||y.set(g,[]),y.get(g).push(c)}return s},[x]);return e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-10",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-light",children:"Flight schedule"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"text-[11px] tracking-[0.22em] uppercase",style:{color:t.textMuted},children:[x.length," legs · next ",h,"d"]}),e.jsx("div",{className:"flex",children:[7,14,30].map(s=>e.jsxs("button",{onClick:()=>w(s),className:"px-3 py-1.5 text-[10px] tracking-[0.22em] uppercase",style:{background:h===s?t.gold:"transparent",color:h===s?"#0b0d10":t.textDim,border:`1px solid ${t.border}`},children:[s,"d"]},s))}),e.jsx("div",{className:"flex",children:["list","timeline"].map(s=>e.jsx("button",{onClick:()=>a(s),className:"px-3 py-1.5 text-[10px] tracking-[0.22em] uppercase",style:{background:n===s?t.gold:"transparent",color:n===s?"#0b0d10":t.textDim,border:`1px solid ${t.border}`},children:s},s))})]})]}),i?e.jsx("div",{className:"text-center py-20",style:{color:t.textMuted},children:"Loadingâ¦"}):x.length===0?e.jsx("div",{className:"text-center py-20",style:{color:t.textMuted,border:`1px dashed ${t.border}`},children:"No reserved flights yet. Accepted quotes will appear here automatically."}):n==="list"?e.jsx(R,{aircraft:l,grouped:o,inquiries:m}):e.jsx(T,{aircraft:l,rows:x,inquiries:m,days:h})]})}function R({aircraft:n,grouped:a,inquiries:x}){const _=n.filter(l=>a.has(l.id));return e.jsx("div",{className:"space-y-6",children:_.map(l=>e.jsxs("div",{style:{background:t.surface,border:`1px solid ${t.border}`},children:[e.jsxs("div",{className:"px-4 py-3 flex items-baseline justify-between",style:{borderBottom:`1px solid ${t.border}`},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontFamily:f,color:t.gold},children:l.tail_number}),e.jsx("span",{className:"ml-3 text-[11px] tracking-[0.22em] uppercase",style:{color:t.textDim},children:l.type})]}),e.jsx("span",{className:"text-[10px] tracking-[0.22em] uppercase",style:{color:t.textMuted},children:l.category})]}),Array.from(a.get(l.id).entries()).sort(([p],[m])=>p.localeCompare(m)).map(([p,m])=>e.jsxs("div",{style:{borderBottom:`1px solid ${t.border}`},children:[e.jsx("div",{className:"px-4 py-2 text-[10px] tracking-[0.22em] uppercase",style:{background:"rgba(255,255,255,0.02)",color:t.textDim},children:q(p)}),m.sort((r,i)=>r.etd.localeCompare(i.etd)).map(r=>{const i=r.inquiry_id?x[r.inquiry_id]:null;return e.jsxs("div",{className:"px-4 py-2.5 grid grid-cols-12 gap-3 text-sm items-center",style:{borderTop:`1px solid ${t.border}`},children:[e.jsxs("div",{className:"col-span-2",style:{fontFamily:f,color:t.textDim},children:[D(r.etd)," â ",D(r.eta)]}),e.jsxs("div",{className:"col-span-3",style:{fontFamily:f},children:[r.from_icao," â ",r.to_icao]}),e.jsx("div",{className:"col-span-2",children:e.jsx(H,{type:r.leg_type})}),e.jsx("div",{className:"col-span-3",style:{color:t.textDim},children:i?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontFamily:f,color:t.gold},children:i.ref_number})," · ",i.contact_name]}):e.jsx("span",{style:{color:t.textMuted},children:"â"})}),e.jsx("div",{className:"col-span-2 text-right",style:{fontFamily:f,color:t.text},children:i!=null&&i.quoted_price?`$${Math.round(Number(i.quoted_price)).toLocaleStr
1ing()}`:""})]},r.id)})]},p))]},l.id))})}function T({aircraft:n,rows:a,inquiries:x,days:_}){const l=new Date;l.setHours(0,0,0,0);const p=Array.from({length:_},(r,i)=>{const d=new Date(l);return d.setDate(d.getDate()+i),d}),m=n.filter(r=>a.some(i=>i.aircraft_id===r.id));return e.jsx("div",{className:"overflow-x-auto",style:{border:`1px solid ${t.border}`},children:e.jsxs("div",{className:"flex",style:{minWidth:m.length*220+60},children:[e.jsxs("div",{className:"shrink-0",style:{width:60,borderRight:`1px solid ${t.border}`,background:t.surface},children:[e.jsx("div",{style:{height:32}}),p.map(r=>e.jsxs("div",{style:{height:M,borderTop:`1px solid ${t.border}`,position:"relative"},children:[e.jsx("div",{className:"absolute top-1 left-1 text-[10px] tracking-[0.18em] uppercase",style:{color:t.textMuted},children:F(r)}),[6,12,18].map(i=>e.jsxs("div",{className:"absolute right-1 text-[9px]",style:{top:i*N-6,color:t.textMuted,fontFamily:f},children:[i,":00"]},i))]},r.toISOString()))]}),m.map(r=>{const i=a.filter(d=>d.aircraft_id===r.id);return e.jsxs("div",{className:"shrink-0",style:{width:220,borderRight:`1px solid ${t.border}`},children:[e.jsx("div",{className:"px-3 text-center text-[11px] tracking-[0.22em] uppercase",style:{height:32,lineHeight:"32px",background:t.surface,color:t.gold,fontFamily:f,borderBottom:`1px solid ${t.border}`},children:r.tail_number}),p.map((d,h)=>{const w=d.toISOString().slice(0,10),$=i.filter(o=>o.etd.slice(0,10)===w);return e.jsxs("div",{style:{height:M,borderTop:`1px solid ${t.border}`,position:"relative",background:h%2===0?"rgba(255,255,255,0.01)":"transparent"},children:[[0,6,12,18].map(o=>
1e.jsx("div",{className:"absolute left-0 right-0",style:{top:o*N,borderTop:`1px dashed ${t.border}`,opacity:.4}},o)),$.map(o=>{const s=new Date(o.etd),c=new Date(o.eta),g=(s.getHours()+s.getMinutes()/60)*N,y=Math.max(18,(c.getTime()-s.getTime())/36e5*N),b=o.inquiry_id?x[o.inquiry_id]:null,j=o.leg_type==="positioning";return e.jsxs("div",{title:`${o.from_icao}â${o.to_icao} ${D(o.etd)}-${D(o.eta)}${b?` · ${b.ref_number}`:""}`,className:"absolute left-1 right-1 px-1.5 py-0.5 overflow-hidden text-[10px]",style:{top:g,height:y,background:j?"rgba(155,159,166,0.15)":"rgba(201,169,107,0.18)",border:`1px solid ${j?t.textMuted:t.gold}`,color:j?t.textDim:t.gold,fontFamily:f},children:[e.jsxs("div",{children:[o.from_icao,"â",o.to_icao]}),b&&e.jsx("div",{style:{color:t.text},children:b.ref_number})]},o.id)})]},w)})]},r.id)})]})})}function H({type:n}){const a=n==="positioning";return e.jsx("span",{className:"px-2 py-0.5 text-[10px] tracking-[0.18em] uppercase",style:{border:`1px solid ${a?t.textMuted:t.gold}`,color:a?t.textDim:t.gold},children:n})}function D(n){const a=new Date(n);return`${String(a.getHours()).padStart(2,"0")}:${String(a.getMinutes()).padStart(2,"0")}`}export{L as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.