import{r as e,j as s}from"./vendor-react-Dp9pL_Wn.js";import{a0 as t,aH as a,a9 as r,a6 as n,a8 as l,_ as i,a1 as o}from"./index-DhMXk6CR.js";import{Q as d}from"./c6eedc03a-CsEFTfjy.js";import"./vendor-infra-DayZK7Ds.js";import"./vendor-zod-0xcuG3aM.js";import"./vendor-router-qG5OCEmI.js";import"./vendor-intl-D2wGIp4M.js";import"./vendor-base-5_f7mmWg.js";import"./vendor-ant-cds-bBedrtIN.js";import"./vendor-base-ui-DNypCIlh.js";import"./vendor-radix-Ch96tRrt.js";import"./vendor-virtual-DRz8lJfQ.js";import"./vendor-query-BwvgHhJ1.js";import"./vendor-zustand-BeF8W8xk.js";import"./caf7c7e06-DJYXCm3T.js";import"./vendor-lodash-BvMLws5K.js";import"./vendor-icons-CokWnmlw.js";import"./vendor-motion-EDlUw66k.js";import"./c5669b8e4-DFSq88jr.js";import"./vendor-luxon-CZxT8ieM.js";import"./c5f4e1303-CiyIFgnl.js";import"./cbaad2c48-DaP34LG2.js";import"./vendor-growthbook-C66YtMMX.js";import"./vendor-zod-v3-CZy0YPWu.js";const c={height:"var(--cds-pad-md)"},m=e.memo(function({day:e}){const t=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((a,r)=>{const i=0===r,o=r===e.stops.length-1;return s.jsxs("li",{className:"flex gap-md",children:[t&&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:a.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:a.name}),a.blurb&&s.jsx("span",{className:l,children:a.blurb})]})]},`${a.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:t},children:[i?s.jsxs(a.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(a.List,{children:n.days.map((e,t)=>s.jsx(a.Tab,{value:String(t),children:e.day_label||`Day ${t+1}`},`${e.day_label}-${t}`))})})}),s.jsx(a.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,t=u(s.name);return t?{name:t,time:u(s.time),blurb:u(s.blurb)}:null}function j(e){if(!e||"object"!=typeof e)return null;const s=e,t=Array.isArray(s.stops)?s.stops.map(x).filter(e=>null!==e).slice(0,12):[];return 0===t.length?null:{day_label:u(s.day_label)??"",stops:t}}const f=e.memo(function(){return s.jsxs("div",{className:"flex flex-col gap-4 bg-surface-2 p-lg font-ui",style:{borderRadius:t},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:t,isStreaming:a,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 t=s,a=Array.isArray(t.days)?t.days.map(j).filter(e=>null!==e).slice(0,7):[];return 0===a.length?null:{title:u(t.title),days:a,summary:u(t.summary)}}(r??t),[r,t]);e.useEffect(()=>{a||m(x?"rendered":"blank")},[a,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})}):a?s.jsx(f,{}):null});export{h as default};
