1import{F as st,c as at,n as rt,r as b,o as Ce,p as U,s as R,j as e,B as j,S as it,f as lt,g as nt,h as ot,k as ke,J as Te,L as S,Q as Pe,a4 as De,V as dt,H as ct,W as ut,bK as mt,D as pt,t as ht,v as xt,w as gt,A as ft,I as A,T as bt}from"./index-BtgOf3Tb.js";import{B as F}from"./badge-CaVOQWHq.js";import{C as H,a as _t,b as jt,d as vt,c as Z}from"./card-DK9lVuyV.js";import{C as wt}from"./checkbox-AUUl_DcP.js";import{A as yt,a as Nt,b as St,c as Ct,d as kt,e as Tt,f as Pt,g as Dt}from"./alert-dialog-Be1YTd2J.js";import{D as he,a as xe,b as ge,c as Q,d as fe,e as Oe}from"./dropdown-menu-Cs5x9qEK.js";import{L as w}from"./label-BUfYQ1iF.js";import{P as qt}from"./progress-Die-PVfx.js";import{S as qe}from"./switch-CUt_GKG5.js";import{T as Rt,a as Ft,b as Re,c as k,d as Et,e as T}from"./table-CjGn1ZHf.js";import{T as ne,a as O}from"./toggle-group-DtdXBWpW.js";import{d as Lt,c as Mt}from"./csvExport-DGeb1_Jv.js";import{h as At,f as Ot,p as Bt}from"./format-CMRCYCFK.js";import{P as $t}from"./plus-D8vmfie7.js";import{D as It}from"./download-B7p4mmmt.js";import{L as Kt}from"./list-DRbIZMpc.js";import{L as Qt}from"./layout-grid-CU_alA3s.js";import{E as Vt}from"./ellipsis-ClHKRhER.js";import{S as Fe}from"./square-pen-D1eK_sNa.js";import{T as Ee}from"./trash-2-BKpiQMJj.js";import"./index-DVhoNDI0.js";import"./circle-Ywp-j8k9.js";import"./format-CNHAi9qg.js";import"./getDefaultOptions-CtYL33aX.js";import"./index-Db98vg4S.js";import"./addDays-B8OzzthF.js";const p=R,oe=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),de=a=>Ot(a,{month:"short",day:"numeric",year:"numeric"}),Le=(a,c)=>At(a,c),Be=[{value:"planning",label:"Planning"},{value:"pre_sale",label:"Pre-Sale"},{value:"on_sale",label:"On Sale"},{value:"sold_out",label:"Sold Out"},{value:"completed",label:"Completed"},{value:"cancelled",label:"Cancelled"},{value:"draft",label:"Draft"}],Wt=[{value:"planning",label:"Planning",description:"Keep internal while the trip is being built."},{value:"pre_sale",label:"Pre-Sale",description:"Early interest or soft launch."},{value:"on_sale",label:"On Sale",description:"Open for selling and booking."},{value:"sold_out",label:"Sold Out",description:"No more availability."},{value:"completed",label:"Completed",description:"Move to past trips."}],ue={planning:{label:"Planning",className:"border-slate-200 bg-slate-50 text-slate-700"},pre_sale:{label:"Pre-Sale",className:"border-sky-200 bg-sky-50 text-sky-700"},on_sale:{label:"On Sale",className:"border-emerald-200 bg-emerald-50 text-emerald-700"},active:{label:"On Sale",className:"border-emerald-200 bg-emerald-50 text-emerald-700"},sold_out:{label:"Sold Out",className:"border-violet-200 bg-violet-50 text-violet-700"},completed:{label:"Completed",className:"border-stone-200 bg-stone-50 text-stone-700"},cancelled:{label:"Cancelled",className:"border-red-200 bg-red-50 text-red-700"},draft:{label:"Draft",className:"border-slate-200 bg-white text-slate-600"}},me=a=>Bt(a),Me=a=>{var c;return((c=me(a))==null?void 0:c.getTime())??Number.MAX_SAFE_INTEGER},zt=a=>{if(String(a.status||"").toLowerCase()==="completed")return"past";const o=new Date;o.setHours(0,0,0,0);const m=me(a.start_date),v=me(a.end_date);return v&&v<o?"past":m&&m<=o&&(!v||v>=o)?"current":m&&m>o?"upcoming":"unscheduled"},pe=a=>{const c=String(a.status||(a.is_public?"on_sale":"planning")).toLowerCase();return c==="active"?"on_sale":ue[c]?c:"planning"},Ut=(a,c)=>{const o=pe(a);return o==="completed"?"Past":o==="cancelled"?"Cancelled":o==="pre_sale"||o==="on_sale"||o==="sold_out"?"Selling":o==="planning"||o==="draft"?"Planning":c},ce=a=>({name:"",description:"",base_price:"",deposit_amount:"",event_year:String(a),event_start_date:"",event_end_date:"",status:"planning",hero_image_url:"",max_capacity:"",is_public:!0,is_featured_homepage:!1,resort_ids:[]}),Ht=a=>({name:a.name,description:a.description||"",base_price:a.base_price?String(a.base_price):"",deposit_amount:"",event_year:a.event_year?String(a.event_year):"",event_start_date:a.start_date||"",event_end_date:a.end_date||"",status:a.status||(a.is_public?"on_sale":"planning"),hero_image_url:a.hero_image_url||"",max_capacity:a.max_capacity?String(a.max_capacity):"",is_public:!!a.is_public,is_featured_homepage:!!a.is_featured_homepage,resort_ids:(a.trip_resorts||[]).map(c=>{var o;return((o=c.resorts)==null?void 0:o.id)??c.resort_id}).filter(c=>typeof c=="number")}),ws=()=>{const{activeYear:a,availableYears:c}=st(),{toast:o}=at(),m=rt(),[v,N]=b.useState(!1),[E,ee]=b.useState(null),[B,Y]=b.useState(null),[be,$e]=b.useState("table"),[V,Ie]=b.useState("upcoming"),[G,Ke]=b.useState("all"),[_e,Qe]=b.useState(!1),[d,f]=b.useState(()=>ce(a)),[x,Ve]=b.useState("all"),[te,We]=b.useState("asc"),ze=b.useMemo(()=>Array.from(new Set([...c,a])).sort((t,s)=>t-s),[c,a]);b.useEffect(()=>{const t=window.matchMedia("(max-width: 767px)"),s=()=>Qe(t.matches);
1return s(),t.addEventListener("change",s),()=>t.removeEventListener("change",s)},[]);const{data:je=[]}=Ce({queryKey:["product-lines"],queryFn:async()=>{const{data:t,error:s}=await p.from("product_lines").select("id, name, trademark").eq("active",!0).order("sort_order");if(s)throw s;return t??[]}}),{data:$,isLoading:Ue,error:ve}=Ce({queryKey:["lpt-trips-dashboard",x],queryFn:async()=>{let t=p.from("trips").select("id,legacy_package_id,name,description,base_price,event_year,start_date,end_date,hero_image_url,max_capacity,status,is_public,is_featured_homepage,product_line_id,product_lines(id,name,trademark)").order("start_date",{ascending:!0,nullsFirst:!1});x!=="all"&&(t=t.eq("event_year",x));const s=await t;if(s.error)throw s.error;const r=(s.data||[]).map(l=>l.id),[i,n,u,h,g,P,L,M]=await Promise.all([r.length?p.from("trip_resorts").select("trip_id, resort_id").in("trip_id",r):Promise.resolve({data:[],error:null}),R.from("resorts").select("id, name, hero_image_url"),r.length?p.from("bookings").select("id, trip_id, package_id, amount, status, payment_status").in("trip_id",r):Promise.resolve({data:[],error:null}),R.from("rooms").select("id, resort_id"),r.length?p.from("trip_packages").select("trip_id, resort_id").in("trip_id",r):Promise.resolve({data:[],error:null}),x!=="all"?R.from("flights").select("id",{count:"exact",head:!0}).eq("event_year",x):R.from("flights").select("id",{count:"exact",head:!0}),x!=="all"?R.from("airport_transfers").select("id",{count:"exact",head:!0}).eq("event_year",x):R.from("airport_transfers").select("id",{count:"exact",head:!0}),R.from("contacts").select("id",{count:"exact",head:!0})]);if(i.error)throw i.error;if(n.error)throw n.error;if(u.error)throw u.error;if(h.error)throw h.error;if(g.error)throw g.error;const D=new Map((n.data||[]).map(l=>[l.id,l])),q=new Map;(i.data||[]).forEach(l=>{const y=q.get(l.trip_id)||[];y.push({resort_id:l.resort_id,resorts:D.get(l.resort_id)||null}),q.set(l.trip_id,y)});const C=new Map;(h.data||[]).forEach(l=>{l.resort_id&&C.set(l.resort_id,(C.get(l.resort_id)||0)+1)});const I=new Map;(g.data||[]).forEach(l=>{if(!l.trip_id||!l.resort_id)return;const y=I.get(l.trip_id)||[];y.push(l.resort_id),I.set(l.trip_id,y)});const _=new Map;return(u.data||[]).forEach(l=>{if(!l.trip_id)return;const y=_.get(l.trip_id)||[];y.push({id:l.id,amount:l.amount,status:l.status,payment_status:l.payment_status}),_.set(l.trip_id,y)}),{trips:(s.data||[]).map(l=>{const y=q.get(l.id)||[],Se=new Set([...y.map(le=>le.resort_id).filter(Boolean),...I.get(l.id)||[]]),Ze=Se.size,et=Array.from(Se).reduce((le,tt)=>le+(C.get(tt)||0),0);return{...l,trip_resorts:y,bookings:_.get(l.id)||[],property_count:Ze,room_count:et}}),resorts:n.data||[],roomCount:(h.data||[]).length,flightCount:P.count||0,transferCount:L.count||0,clientCount:M.count||0}}}),se=($==null?void 0:$.trips)||[],we=($==null?void 0:$.resorts)||[],ae=U({mutationFn:async()=>{const t={name:d.name.trim(),description:d.description.trim()||null,base_price:d.base_price?Number(d.base_price):null,deposit_amount:d.deposit_amount?Number(d.deposit_amount):null,hero_image_url:d.hero_image_url.trim()||null,event_year:d.event_year?Number(d.event_year):a,start_date:d.event_start_date||null,end_date:d.event_end_date||null,max_capacity:d.max_capacity?Number(d.max_capacity):null,status:d.status||"planning",is_public:d.is_public,is_featured_homepage:d.is_featured_homepage};if(!t.name)throw new Error("Trip name is required.");if(!t.event_year||Number.isNaN(t.event_year))throw new Error("Trip year is required.");const s=E?await p.from("trips").update(t).eq("id",E.id).select("id").single():await p.from("trips").insert(t).select("id").single();if(s.error)throw s.error;const r=s.data.id,i=d.resort_ids.length>0?d.resort_ids:E?(E.trip_resorts||[]).map(u=>{var h;return((h=u.resorts)==null?void 0:h.id)??u.resort_id}).filter(u=>typeof u=="number"):[],n=await p.from("trip_resorts").delete().eq("trip_id",r);if(n.error)throw n.error;if(i.length>0){const u=await p.from("trip_resorts").insert(i.map(h=>({trip_id:r,resort_id:h})));if(u.error)throw u.error}return r},onSuccess:t=>
1{m.invalidateQueries({queryKey:["lpt-trips-dashboard"]}),m.invalidateQueries({queryKey:["lpt-trip-view",t]}),o({title:E?"Trip updated":"Trip created"}),N(!1),ee(null),f(ce(a))},onError:t=>{o({title:"Trip save failed",description:t.message,variant:"destructive"})}}),W=U({mutationFn:async({trip:t,status:s})=>{const r=s==="on_sale"||s==="pre_sale"||s==="sold_out",i=await p.from("trips").update({status:s,is_public:r,updated_at:new Date().toISOString()}).eq("id",t.id).select("id, status").single();if(i.error)throw i.error;return i.data},onSuccess:t=>{m.invalidateQueries({queryKey:["lpt-trips-dashboard"]}),m.invalidateQueries({queryKey:["lpt-trip-view",t.id]}),o({title:"Trip updated"})},onError:t=>{o({title:"Trip update failed",description:t.message,variant:"destructive"})}}),J=U({mutationFn:async({trip:t,featured:s})=>{if(s){const n=await p.from("trips").update({is_featured_homepage:!1}).neq("id",t.id).eq("is_featured_homepage",!0);if(n.error)throw n.error}const r={is_featured_homepage:s,updated_at:new Date().toISOString()};if(s&&!t.is_public){r.is_public=!0;const n=String(t.status||"").toLowerCase();n!=="sold_out"&&n!=="pre_sale"&&n!=="on_sale"&&(r.status="on_sale")}const i=await p.from("trips").update(r).eq("id",t.id).select("id, is_featured_homepage, is_public").single();if(i.error)throw i.error;if(s){const n=await p.from("trip_packages").update({is_public:!0}).eq("trip_id",t.id).eq("is_active",!0);if(n.error)throw n.error}return i.data},onSuccess:t=>{m.invalidateQueries({queryKey:["lpt-trips-dashboard"]}),m.invalidateQueries({queryKey:["lpt-trip-view",t.id]}),m.invalidateQueries({queryKey:["lpt-homepage-featured-trip"]}),m.invalidateQueries({queryKey:["lpt-homepage-on-sale-trips"]}),o({title:t.is_featured_homepage?"Signature Week featured on homepage":"Removed as Signature Week feature",description:t.is_featured_homepage?"This trip now fills the large Signature Week layout on the public site.":void 0})},onError:t=>{o({title:"Could not update Signature feature",description:t.message,variant:"destructive"})}}),X=U({mutationFn:async({trip:t,publish:s})=>{const r=String(t.status||"").toLowerCase(),i=s?r==="sold_out"||r==="pre_sale"?r:"on_sale":r==="on_sale"||r==="pre_sale"?"planning":r||"planning",n=await p.from("trips").update({is_public:s,status:i,updated_at:new Date().toISOString()}).eq("id",t.id).select("id, is_public, status").single();if(n.error)throw n.error;if(s){const u=await p.from("trip_packages").update({is_public:!0}).eq("trip_id",t.id).eq("is_active",!0);if(u.error)throw u.error}return n.data},onSuccess:t=>{m.invalidateQueries({queryKey:["lpt-trips-dashboard"]}),m.invalidateQueries({queryKey:["lpt-trip-view",t.id]}),m.invalidateQueries({queryKey:["lpt-homepage-featured-trip"]}),m.invalidateQueries({queryKey:["lpt-homepage-on-sale-trips"]}),o({title:t.is_public?"Published to web":"Unpublished from web"})},onError:t=>{o({title:"Could not update web visibility",description:t.message,variant:"destructive"})}}),re=U({mutationFn:async t=>{if((t.bookings||[]).filter(g=>g.status!=="cancelled").length>0)throw new Error("This trip has active bookings. Cancel those bookings before deleting the trip.");const{data:r}=await p.from("trip_packages").select("id").eq("trip_id",t.id),i=(r||[]).map(g=>g.id);if(i.length>0){const g=await p.from("trip_package_rooms").delete().in("trip_package_id",i);if(g.error)throw g.error}const n=await p.from("trip_packages").delete().eq("trip_id",t.id);if(n.error)throw n.error;const u=await p.from("trip_resorts").delete().eq("trip_id",t.id);if(u.error)throw u.error;await p.from("client_groups").update({trip_id:null}).eq("trip_id",t.id);const h=await p.from("trips").delete().eq("id",t.id);if(h.error)throw h.error},onSuccess:()=>{m.invalidateQueries({queryKey:["lpt-trips-dashboard"]}),o({title:"Trip deleted"})},onError:t=>{o({title:"Trip delete failed",description:t.message,variant:"destructive"})}}),He=()=>{ee(null),f(ce(x!=="all"?x:a)),N(!0)},ye=t=>{ee(t),f(Ht(t)),N(!0)},Ye=(t,s)=>{f(r=>({...r,resort_ids:s?[...new Set([...r.resort_ids,t])]:r.resort_ids.filter(i=>i!==t)}))},Ne=b.useMemo(()=>se.map(t=>{var C,I;const s=(t.bookings||[]).filter(_=>
1_.status!=="cancelled"),r=s.reduce((_,l)=>_+(Number(l.amount)||0),0),i=s.filter(_=>_.payment_status==="paid").length,n=(t.trip_resorts||[]).map(_=>{var l;return(l=_.resorts)==null?void 0:l.name}).filter(Boolean),u=t.property_count??n.length,h=t.room_count??0,g=s.length?Math.round(i/s.length*100):0,P=((I=(C=(t.trip_resorts||[]).find(_=>{var l;return(l=_.resorts)==null?void 0:l.hero_image_url}))==null?void 0:C.resorts)==null?void 0:I.hero_image_url)||null,L=t.hero_image_url||P,M=zt(t),D=pe(t),q=ue[D]||ue.planning;return{trip:t,bookings:s,revenue:r,paid:i,resorts:n,propertyCount:u,roomCount:h,progress:g,heroImageUrl:L,timeframe:M,status:q}}),[se]),z=b.useMemo(()=>{let t=Ne;return V==="past"?t=t.filter(s=>s.timeframe==="past"):V!=="all"&&(t=t.filter(s=>s.timeframe!=="past")),G!=="all"&&(t=t.filter(s=>s.trip.product_line_id===G)),[...t].sort((s,r)=>{const i=Me(s.trip.start_date)-Me(r.trip.start_date);return i!==0?te==="asc"?i:-i:s.trip.name.localeCompare(r.trip.name)})},[te,V,G,Ne]),Ge=()=>{We(t=>t==="asc"?"desc":"asc")},Je=()=>{const t=z.map(({trip:i,bookings:n,revenue:u,paid:h,resorts:g,propertyCount:P,roomCount:L,status:M,timeframe:D})=>{var q,C;return{Trip:i.name,Dates:Le(i.start_date,i.end_date),Year:i.event_year||"",Line:((q=i.product_lines)==null?void 0:q.trademark)||((C=i.product_lines)==null?void 0:C.name)||"",Lodging:g.join("; "),Properties:P,Rooms:L,Bookings:n.length,Revenue:u,Paid:`${h}/${n.length}`,Status:M.label,Phase:D,Public:i.is_public?"Yes":"No",Featured:i.is_featured_homepage?"Yes":"No"}}),s=["Trip","Dates","Year","Line","Lodging","Properties","Rooms","Bookings","Revenue","Paid","Status","Phase","Public","Featured"],r=x==="all"?"all-years":x;Lt(Mt(t,s),`trips-${r}-${new Date().toISOString().split("T")[0]}.csv`),o({title:"Export complete",description:`Exported ${t.length} visible trips.`})},Xe=_e?"cards":be,ie=(t,s)=>{pe(t)===s||W.isPending||W.mutate({trip:t,status:s})};return Ue?e.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading trips..."}):ve?e.jsx("div",{className:"p-6",children:e.jsx(H,{children:e.jsxs(_t,{children:[e.jsx(jt,{children:"Trips could not load"}),e.jsx(vt,{children:ve.message})]})})}):e.jsxs("div",{className:"w-full px-4 py-6 space-y-6 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsx("div",{children:e.jsx("h1",{className:"text-3xl font-bold",children:"Trips"})}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsxs(j,{onClick:He,children:[e.jsx($t,{className:"mr-2 h-4 w-4"}),"Add Trip"]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded-md border bg-muted/30 p-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold",children:"Active year"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:x==="all"?"Showing all trip years":`Showing ${x} trips`})]}),e.jsxs(ne,{type:"single",value:String(x),onValueChange:t=>{t&&Ve(t==="all"?"all":Number(t))},className:"flex-wrap justify-start",children:[ze.map(t=>e.jsx(O,{value:String(t),"aria-label":`Year ${t}`,className:"border border-transparent data-[state=on]:border-primary data-[state=on]:bg-primary data-[state=on]:text-primary-foreground data-[state=on]:shadow-sm",children:t},t)),e.jsx(O,{value:"all","aria-label":"All years",className:"border border-transparent data-[state=on]:border-primary data-[state=on]:bg-primary data-[state=on]:text-primary-foreground data-[state=on]:shadow-sm",children:"All Years"})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Trip List"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:_e?"Mobile view uses trip cards for easier scanning.":"Switch between a fast operations table and visual trip cards."})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs(j,{variant:"outline",size:"sm",onClick:Je,disabled:z.length===0,children:[e.jsx(It,{className:"mr-2 h-4 w-4"}),"Export"]}),e.jsxs(ne,{type:"single",value:V,onValueChange:t=>{(t==="upcoming"||t==="past"||t==="all")&&Ie(t)},className:"justify-start",children:[e.jsx(O,{value:"upcoming","aria-label":"Upcoming trips",children:"Upcoming"}),e.jsx(O,{value:"past","aria-label":"Past trips",children:"Past"}),e.jsx(O,{value:"all","aria-label":"All trips",children:"All"})]}),je.length>0&&e.jsxs(it,{value:G,onValueChange:Ke,children:[e.jsx(lt,{className:"h-9 w-[160px] text-sm",children:e.jsx(nt,{placeholder:"All product lines"})}),e.jsxs(ot,{children:[e.jsx(ke,{value:"all",children:"All Lines"}),je.map(t=>e.jsx(ke,{value:t.id,children:t.trademark??t.name},t.id))]})]}),e.jsxs(ne,{type:"single",value:be,onValueChange:t=>{(t==="table"||t==="cards")&&$e(t)},className:"hidden justify-start md:flex",children:[e.jsxs(O,{value:"table","aria-label":"Table view",children:[e.jsx(Kt,{className:"mr-2 h-4 w-4"}),"Table"]}),e.jsxs(O,{value:"cards","aria-label":"Card view",children:[e.jsx(Qt,{className:"mr-2 h-4 w-4"}),"Cards"]})]})]})]}),e.jsx("div",{children:se.length===0?e.jsx(H,{children:e.jsxs(Z,{className:"py-10 text-center",children:[e.jsx(Te,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground
1/60"}),e.jsxs("h2",{className:"font-semibold",children:["No trips yet for ",x==="all"?"any year":x]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Create the first trip from Packages, then link lodging and room inventory."})]})}):z.length===0?e.jsx(H,{children:e.jsxs(Z,{className:"py-10 text-center",children:[e.jsx(Te,{className:"mx-auto mb-3 h-10 w-10 text-muted-foreground/60"}),e.jsxs("h2",{className:"font-semibold",children:["No ",V," trips for ",x==="all"?"any year":x]}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Change the filter or add trip dates and statuses."})]})}):Xe==="table"?e.jsx(H,{className:"overflow-hidden",children:e.jsx(Z,{className:"overflow-x-auto p-0",children:e.jsxs(Rt,{className:"min-w-[1040px] table-auto",children:[e.jsx(Ft,{children:e.jsxs(Re,{children:[e.jsx(k,{className:"min-w-[360px]",children:"Trip"}),e.jsx(k,{className:"w-[190px] whitespace-nowrap",children:e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:Ge,children:["Dates",e.jsx("span",{className:"text-[10px] tabular-nums",children:te==="asc"?"â":"â"})]})}),e.jsx(k,{className:"w-[64px] px-2 text-right",children:"Props"}),e.jsx(k,{className:"w-[64px] px-2 text-right",children:"Rooms"}),e.jsx(k,{className:"w-[52px] px-2 text-right",children:"Bkgs"}),e.jsx(k,{className:"w-[88px] px-2 text-right",children:"Revenue"}),e.jsx(k,{className:"w-[52px] px-2 text-right",children:"Paid"}),e.jsx(k,{className:"w-[110px]",children:"Status"}),e.jsx(k,{className:"w-[148px] text-right",children:"Actions"})]})}),e.jsx(Et,{children:z.map(({trip:t,bookings:s,revenue:r,paid:i,propertyCount:n,roomCount:u,status:h})=>e.jsxs(Re,{children:[e.jsx(T,{className:"align-top",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("button",{type:"button",className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-xs font-bold shadow-sm transition-opacity hover:opacity-90 disabled:opacity-50 ${t.is_featured_homepage?"bg-amber-500 text-white hover:bg-amber-600 ring-2 ring-amber-300 ring-offset-1":"bg-muted text-muted-foreground hover:bg-muted/80 border border-border"}`,disabled:J.isPending,onClick:()=>J.mutate({trip:t,featured:!t.is_featured_homepage}),title:t.is_featured_homepage?"Signature Week on homepage â click to remove":"Set as Signature Week (large homepage feature)","aria-label":t.is_featured_homepage?"Remove Signature Week feature":"Feature as Signature Week on homepage",children:"S"}),e.jsx("button",{type:"button",className:`mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-xs font-bold text-white shadow-sm transition-opacity hover:opacity-90 disabled:opacity-50 ${t.is_public?"bg-emerald-500 hover:bg-emerald-600":"bg-red-500 hover:bg-red-600"}`,disabled:X.isPending,onClick:()=>X.mutate({trip:t,publish:!t.is_public}),title:t.is_public?"Published to web â click to unpublish":"Not published â click to publish to web","aria-label":t.is_public?"Unpublish trip from web":"Publish trip to web",children:"P"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(S,{to:`/admin/trips/${t.id}`,className:"block max-w-[460px] whitespace-normal text-base font-semibold leading-snug hover:text-primary",title:t.name,children:t.name}),t.product_lines&&e.jsx(F,{variant:"outline",className:"text-[10px] mt-0.5 mr-1",children:t.product_lines.trademark??t.product_lines.name})]})]})}),e.jsx(T,{className:"whitespace-nowrap text-sm tabular-nums",children:Le(t.start_date,t.end_date)}),e.jsx(T,{className:"px-2 text-right tabular-nums",children:n}),e.jsx(T,{className:"px-2 text-right tabular-nums",children:u}),e.jsx(T,{className:"px-2 text-right tabular-nums",children:s.length}),e.jsx(T,{className:"px-2 text-right tabular-nums",children:oe.format(r)}),e.jsxs(T,{className:"px-2 text-right tabular-nums",children:[i,"/",s.length]}),e.jsx(T,{children:e.jsx(Ae,{trip:t,status:h,disabled:W.isPending,onChange:ie})}),e.jsx(T,{children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(j,{asChild:!0,size:"sm",children:e.jsx(S,{to:`/admin/trips/${t.id}`,children:"View"})}),e.jsxs(he,{children:[e.jsx(xe,{asChild:!0,children:e.jsx(j,{variant:"outline",size:"icon",children:e.jsx(Vt,{className:"h-4 w-4"})})}),e.jsxs(ge,{align:"end",children:[e.jsx(Q,{asChild:!0,children:e.jsxs(S,{to:`/admin/trips/${t.id}/running-order`,children:[e.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Running Order"]})}),e.jsx(Q,{asChild:!0,children:e.jsxs(S,{to:`/admin/trips/${t.id}/builder`,children:[e.jsx(De,{className:"mr-2 h-4 w-4"}),"Trip Builder"]})}),e.jsxs(Q,{onClick:()=>ye(t),children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Edit Trip"]}),e.jsx(fe,{}),e.jsxs(Q,{onClick:()=>Y(t),disabled:re.isPending,className:"text-destructive focus:text-destructive",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"Delete Trip"]})]})]})]})})]},t.id))})]})})}):e.jsx("div",{className:"grid gap-4",children:z.map(({trip:t,bookings:s,revenue:r,paid:i,resorts:n,propertyCount:u,roomCount:h,progress:g,heroImageUrl:P,timeframe:L,status:M})=>e.jsx(H,{className:"overflow-hidden",children:e.jsxs("div",{className:"grid lg:grid-cols-[280px_1fr]",children:[e.jsxs(S,{to:`/admin/trips/${t.id}`,className:"group relative block h-48 overflow-hidden bg-muted lg:h-auto","aria-label":`View ${t.name}`,children:[P?e.jsx("img",{src:P,alt:t.name,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105",loading:"lazy"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-[#0f241d] text-center text-[#d8b46a]",children:e.jsxs("div",{children:[e.jsx(dt,{className:"mx-auto mb-3 h-9 w-9"}),e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.24em]",children:"Luxury Pickle Travel"})]})}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-4",children:e.jsx("p",{className:"text-sm font-medium text-white",children:de(t.
1start_date)})})]}),e.jsxs(Z,{className:"p-4 sm:p-5",children:[e.jsxs("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold leading-tight sm:text-xl",children:t.name}),e.jsx(Ae,{trip:t,status:M,disabled:W.isPending,onChange:ie}),e.jsx(Yt,{trip:t,timeframe:L,disabled:W.isPending,onChange:ie}),e.jsx(F,{variant:"outline",children:"Trip"}),t.is_featured_homepage&&e.jsxs(F,{className:"border-amber-200 bg-amber-50 text-amber-800",children:[e.jsx(ct,{className:"mr-1 h-3 w-3 fill-current"}),"Signature"]}),t.is_public&&e.jsx(F,{className:"border-emerald-200 bg-emerald-50 text-emerald-800",children:"Published"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[de(t.start_date)," to ",de(t.end_date)]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.length>0?n.map(D=>e.jsxs(F,{variant:"secondary",children:[e.jsx(ut,{className:"mr-1 h-3 w-3"}),D]},D)):e.jsx(F,{variant:"outline",children:"No lodging linked"})})]}),e.jsxs("div",{className:"grid w-full grid-cols-2 gap-2 sm:gap-3 lg:w-[420px]",children:[e.jsx(K,{label:"Properties",value:u.toString()}),e.jsx(K,{label:"Rooms",value:h.toString()}),e.jsx(K,{label:"Bookings",value:s.length.toString()}),e.jsx(K,{label:"Revenue",value:oe.format(r)}),e.jsx(K,{label:"Paid",value:`${i}/${s.length}`}),e.jsx(K,{label:"Price",value:t.base_price?oe.format(t.base_price):"TBD"})]})]}),e.jsxs("div",{className:"mt-5 grid gap-4 lg:grid-cols-[1fr_auto] lg:items-center",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Payment completion"}),e.jsxs("span",{className:"font-medium",children:[g,"%"]})]}),e.jsx(qt,{value:g})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap",children:[e.jsxs("button",{type:"button",className:`inline-flex h-9 items-center justify-center gap-1.5 rounded-full px-3 text-xs font-bold shadow-sm transition-opacity hover:opacity-90 disabled:opacity-50 ${t.is_featured_homepage?"bg-amber-500 text-white hover:bg-amber-600":"border border-border bg-muted text-muted-foreground hover:bg-muted/80"}`,disabled:J.isPending,onClick:()=>J.mutate({trip:t,featured:!t.is_featured_homepage}),title:t.is_featured_homepage?"Signature Week on homepage â click to remove":"Set as Signature Week (large homepage feature)",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-black/10 text-[10px]",children:"S"}),t.is_featured_homepage?"Signature":"Make Signature"]}),e.jsx("button",{type:"button",className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-xs font-bold text-white shadow-sm transition-opacity hover:opacity-90 disabled:opacity-50 ${t.is_public?"bg-emerald-500 hover:bg-emerald-600":"bg-red-500 hover:bg-red-600"}`,disabled:X.isPending,onClick:()=>X.mutate({trip:t,publish:!t.is_public}),title:t.is_public?"Published to web â click to unpublish":"Not published â click to publish to web","aria-label":t.is_public?"Unpublish trip from web":"Publish trip to web",children:"P"}),e.jsx(j,{asChild:!0,size:"sm",className:"w-full sm:w-auto",children:e.jsxs(S,{to:`/admin/trips/${t.id}`,children:["View Trip",e.jsx(De,{className:"ml-1 h-4 w-4"})]})}),e.jsx(j,{asChild:!0,variant:"outline",size:"sm",className:"w-full sm:w-auto",children:e.jsxs(S,{to:`/admin/trips/${t.id}/running-order`,children:[e.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Running Order"]})}),e.jsx(j,{asChild:!0,variant:"outline",size:"sm",className:"w-full sm:w-auto",children:e.jsx(S,{to:`/admin/trips/${t.id}/builder`,children:"Builder"})}),e.jsx(j,{asChild:!0,variant:"outline",size:"sm",className:"w-full sm:w-auto",children:e.jsx(S,{to:"/admin/bookings",children:"Bookings"})}),e.jsx(j,{asChild:!0,variant:"outline",size:"sm",className:"w-full sm:w-auto",children:e.jsxs(S,{to:"/admin/rooms",children:[e.jsx(mt,{className:"mr-2 h-4 w-4"}),"Rooms"]})}),e.jsxs(j,{variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>ye(t),children:[e.jsx(Fe,{className:"mr-2 h-4 w-4"}),"Edit Trip"]}),e.jsxs(j,{variant:"outline",size:"sm",className:"w-full sm:w-auto text-destructive hover:bg-destructive hover:text-destructive-foreground",onClick:()=>Y(t),disabled:re.isPending,children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})]})]})},t.id))})}),e.jsx(yt,{open:!!B,onOpenChange:t=>{t||Y(null)},children:e.jsxs(Nt,{children:[e.jsxs(St,{children:[e.jsx(Ct,{children:"Delete trip?"}),e.jsxs(kt,{children:["This will permanently delete ",e.jsx("strong",{children:B==null?void 0:B.name})," and all its packages, room assignments, and resort links. Active bookings must be cancelled first. This cannot be undone."]})]}),e.jsxs(Tt,{children:[e.jsx(Pt,{children:"Cancel"}),e.jsx(Dt,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{B&&re.mutate(B,{onSettled:()=>Y(null)})},children:"Delete Trip"})]})]})}),e.jsx(pt,{open:v,onOpenChange:N,children:e.jsxs(ht,{className:"max-h-[90vh] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(xt,{children:[e.jsx(gt,{children:E?"Edit Trip":"Create Trip"}),e.jsx(ft,{children:"This creates the internal trip record. Unique packages are managed inside the trip view."})]}),e.jsxs("form",{className:"space-y-5",onSubmit:t=>{t.preventDefault(),ae.mutate()},children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(w,{htmlFor:"trip-name",children:"Trip name"}),e.jsx(A,{id:"trip-name",value:d.name,onChange:t=>f(s=>({...s,name:t.target.value})),placeholder:"Paris Pickleball Grand Week"})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"trip-price",children:"Starting price"}),e.jsx(A,{id:"trip-price",type:"number",min:"0",value:d.base_price,onChange:t=>f(s=>({...s,base_price:t.target.value})),placeholder:"14500"})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"trip-year",children:"Event year"}),e.jsx(A,{id:"trip-year",type:"number",value:d.event_year,onChange:t=>f(s=>({...s,event_year:t.target.value})),placeholder:"2027"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Sets which year this trip is filed under. Not tied to the top-nav year switcher."})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"trip-capacity",children:"Max capacity"}),e.jsx(A,{id:"trip-capacity",type:"number",min:"0",value:d.max_capacity,onChange:t=>f(s=>({...s,max_capacity:t.target.value})),placeholder:"40"})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"trip-start",children:"Start date"}),e.jsx(A,{id:"trip-start",type:"date",value:d.event_start_date,onChange:t=>f(s=>({...s,event_start_date:t.target.value}))})]}),e.jsxs("div",{children:[e.jsx(w,{htmlFor:"trip-end",children:"End date"}),e.jsx(A,{id:"trip-end",type:"date",value:d.event_end_date,onChange:t=>f(s=>({...s,event_end_date:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(w,{htmlFor:"trip-hero-image",children:"Hero image URL"}),e.jsx(A,{id:"trip-hero-image",value:d.hero_image_url,onChange:t=>f(s=>({...s,hero_image_url:t.target.value})),placeholder:"https://..."}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Used on the trip card and public trip landing page. If empty, cards use the first linked lodging image when available."})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(w,{htmlFor:"trip-description",children:"Description"}),e.jsx(bt,{id:"trip-description",value:d.description,onChange:t=>f(s=>({...s,description:t.target.value})),placeholder:"Luxury trip description for public offer and internal ops.",rows:4})]})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsx(w,{htmlFor:"trip-status",children:"Trip status"}),e.jsx("select",{id:"trip-status",className:"mt-2 h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm focus:outline-none focus:ring-2 focus:ring-ring",value:d.status,onChange:t=>f(s=>({...s,status:t.target.value})),children:Be.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Used for the trip list, operating dashboard, and sales pipeline."})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[e.jsxs("div",{children:[e.jsx(w,{htmlFor:"trip-public",children:"Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show this trip on the public website."})]}),e.jsx(qe,{id:"trip-public",checked:d.is_public,onCheckedChange:t=>f(s=>({...s,is_public:t}))})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border p-3",children:[e.jsxs("div",{children:[e.jsx(w,{htmlFor:"trip-featured",children:"Signature Week on homepage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Features this trip in the large Signature Week layout on the public homepage. Only one at a time."})]}),e.jsx(qe,{id:"trip-featured",checked:d.is_featured_homepage,onCheckedChange:t=>f(s=>({...s,is_featured_homepage:t}))})]})]}),e.jsxs("div",{children:[e.jsx(w,{children:"Hotels, resorts, or properties"}),e.jsx("div",{className:"mt-2 grid gap-2 rounded-md border p-3 md:grid-cols-2",children:we.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No lodging records yet. Add hotels in Resorts."}):we.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md p-2 hover:bg-muted/50",children:[e.jsx(wt,{checked:d.resort_ids.includes(t.id),onCheckedChange:s=>Ye(t.id,s===!0)}),e.jsx("span",{className:"text-sm",children:t.name})]},t.id))})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(j,{type:"submit",disabled:ae.isPending,children:ae.isPending?"Saving...":E?"Save Trip":"Create Trip"})]})]})]})})]})},Ae=({trip:a,status:c,disabled:o,onChange:m})=>e.jsxs(he,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("button",{type:"button",disabled:o,className:"rounded-full text-left transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-60",title:"Change trip status",children:e.jsx(F,{variant:"outline",className:`${c.className} cursor-pointer`,children:c.label})})}),e.jsxs(ge,{align:"start",className:"w-44",children:[e.jsx(Oe,{children:"Status"}),e.jsx(fe,{}),Be.map(v=>e.jsx(Q,{onClick:()=>m(a,v.value),className:"cursor-pointer",children:v.label},v.value))]})]}),Yt=({trip:a,timeframe:c,disabled:o,onChange:m})=>{const v=Ut(a,c);return e.jsxs(he,{children:[e.jsx(xe,{asChild:!0,children:e.jsx("button",{type:"button",disabled:o,className:"rounded-full text-left transition-opacity hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-60",title:"Change trip phase",children:e.jsx(F,{variant:"secondary",className:"cursor-pointer capitalize",children:v})})}),e.jsxs(ge,{align:"start",className:"w-64",children:[e.jsx(Oe,{children:"Phase"}),e.jsx(fe,{}),Wt.map(N=>e.jsxs(Q,{onClick:()=>
1m(a,N.value),className:"flex cursor-pointer flex-col items-start gap-0.5",children:[e.jsx("span",{children:N.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:N.description})]},N.value))]})]})},K=({label:a,value:c})=>e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:a}),e.jsx("div",{className:"font-semibold",children:c})]});export{ws 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.