import{r as e,j as s}from"./vendor-react-Dp9pL_Wn.js";import{a5 as a,aM as t,ae as r,ab as n,ad as l,a3 as i,a6 as o}from"./index-XoaBlZfC.js";import{a1 as d}from"./c2ee0272b-DPDuX889.js";import"./vendor-infra-DayZK7Ds.js";import"./vendor-zod-B8MhECV7.js";import"./vendor-router-qG5OCEmI.js";import"./vendor-intl-D2wGIp4M.js";import"./vendor-base-5_f7mmWg.js";import"./vendor-ant-cds-BLsR_p72.js";import"./vendor-base-ui-N1VQ4ctE.js";import"./vendor-radix-Dv3qPI0v.js";import"./vendor-virtual-DRz8lJfQ.js";import"./vendor-query-CRl6sF7K.js";import"./vendor-zustand-BeF8W8xk.js";import"./c9a5287df-D_Z7ffFR.js";import"./vendor-icons-DGChWNxR.js";import"./vendor-motion-EDlUw66k.js";import"./vendor-lodash-BvMLws5K.js";import"./vendor-luxon-CZxT8ieM.js";import"./c51e217b4-CQax1dv1.js";import"./c627fcdb6-1_bsVTpt.js";import"./vendor-growthbook-HDTqppl-.js";import"./vendor-zod-v3-CZy0YPWu.js";const c={height:"var(--cds-pad-md)"},m=e.memo(function({day:e}){const a=e.stops.some(e=>e.time);return s.jsx("ol",{role:"list",className:"flex flex-col pb-xl pl-xl pr-xl pt-md",children:e.stops.map((t,r)=>{const i=0===r,o=r===e.stops.length-1;return s.jsxs("li",{className:"flex gap-md",children:[a&&s.jsx("span",{className:"flex w-16 shrink-0 items-start justify-end pt-md",children:s.jsx("span",{className:"flex min-h-6 items-center justify-end text-right text-footnote tabular-nums text-secondary",children:t.time})}),s.jsxs("div",{className:"flex shrink-0 flex-col items-center",children:[s.jsx("span",{className:"w-px "+(i?"invisible":"bg-alpha-2"),style:c}),s.jsx("span",{className:"flex h-6 items-center",children:s.jsx("span",{className:"size-2 rounded-full bg-alpha-3"})}),s.jsx("span",{className:"w-px flex-1 "+(o?"invisible":"bg-alpha-2")})]}),s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-xs pt-md "+(o?"pb-sm":"pb-md"),children:[s.jsx("span",{className:`flex min-h-6 items-center ${n}`,children:t.name}),t.blurb&&s.jsx("span",{className:l,children:t.blurb})]})]},`${t.name}-${r}`)})})}),p=e.memo(function({data:n,onDayChange:l}){const i=n.days.length>1,[o,d]=e.useState(0);e.useEffect(()=>{o>n.days.length-1&&d(0)},[o,n.days.length]);const c=n.days[o]??n.days[0],p=e.useCallback(e=>{const s=Number(e);d(s),l?.(s)},[l]);return s.jsxs("div",{className:"relative overflow-hidden bg-surface-2 font-ui",style:{borderRadius:a},children:[i?s.jsxs(t.Root,{value:String(o),onValueChange:p,children:[s.jsx("div",{className:"border-b px-lg pb-[calc(var(--cds-pad-lg)-1px)] pt-lg",children:s.jsx("div",{className:"-mx-pad-lg -my-2 overflow-x-auto px-lg py-2",children:s.jsx(t.List,{children:n.days.map((e,a)=>s.jsx(t.Tab,{value:String(a),children:e.day_label||`Day ${a+1}`},`${e.day_label}-${a}`))})})}),s.jsx(t.Panel,{value:String(o),children:s.jsx(m,{day:c})})]}):s.jsx(m,{day:c}),s.jsx(r,{})]})});function u(e){return"string"==typeof e?e:void 0}function x(e){if(!e||"object"!=typeof e)return null;const s=e,a=u(s.name);return a?{name:a,time:u(s.time),blurb:u(s.blurb)}:null}function f(e){if(!e||"object"!=typeof e)return null;const s=e,a=Array.isArray(s.stops)?s.stops.map(x).filter(e=>null!==e).slice(0,12):[];return 0===a.length?null:{day_label:u(s.day_label)??"",stops:a}}const j=e.memo(function(){return s.jsxs("div",{className:"flex flex-col gap-4 bg-surface-2 p-lg font-ui",style:{borderRadius:a},children:[s.jsx(o,{width:"40%",height:22}),s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx(o,{width:"85%",height:48}),s.jsx(o,{width:"80%",height:48}),s.jsx(o,{width:"75%",height:48})]})]})}),h=e.memo(function({input:a,isStreaming:t,partialJson:r,conversationUuid:n,disableAnalytics:l}){const{shownRef:o,trackClick:c,trackRender:m}=i("itinerary",n,l),x=e.useMemo(()=>function(e){let s;if("string"==typeof e)try{s=d(e)}catch{return null}else{if(!e||"object"!=typeof e)return null;s=e}if(!s||"object"!=typeof s)return null;const a=s,t=Array.isArray(a.days)?a.days.map(f).filter(e=>null!==e).slice(0,7):[];return 0===t.length?null:{title:u(a.title),days:t,summary:u(a.summary)}}(r??a),[r,a]);e.useEffect(()=>{t||m(x?"rendered":"blank")},[t,x,m]);const h=e.useCallback(()=>c("day_tab"),[c]);return x?s.jsx("div",{ref:o,children:s.jsx(p,{data:x,onDayChange:h})}):t?s.jsx(j,{}):null});export{h as default};
