1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7272],{5425:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/history",function(){return n(17817)}])},17817:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>ed});var i=n(74848),o=n(96540),s=n(23534),r=n(44794);let a=e=>{let{title:t="Chat History",subtitle:n="All your recent chats"}=e;return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:r.YK[1],alignItems:"center",textAlign:"center"},children:[(0,i.jsx)("h1",{style:{fontFamily:r.Wx,fontSize:r.Il.size["2xl"],fontStyle:"normal",fontWeight:r.Il.weight.semibold,color:r.AH.text,margin:0,lineHeight:"normal",textAlign:"center"},children:t}),(0,i.jsx)("p",{style:{fontFamily:r.Wx,fontSize:r.Il.size.base,fontStyle:"normal",fontWeight:r.Il.weight.regular,color:r.AH.secondary,margin:0,lineHeight:"normal"},children:n})]})},l=e=>{let{width:t=20,height:n=20}=e;return(0,i.jsx)("img",{src:"/assets/images/icons/search_history.svg",alt:"Search",width:t,height:n,style:{display:"block",objectFit:"contain"}})},d={position:"relative",width:"100%",height:"52px",backgroundColor:r.t0.primary,border:"".concat(r.sJ.width.thin," solid ").concat(r.Vo.light),borderRadius:r.sJ.radius.lg,boxShadow:"4px 4px 16px 0px rgba(224, 134, 1, 0.12)",overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"center"},c={display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",paddingLeft:r.YK[3],paddingRight:r.YK[2]},u=()=>{let e=(0,o.useRef)(null),t=(0,o.useCallback)(()=>{var t;null===(t=e.current)||void 0===t||t.focus()},[]);return{inputRef:e,focusInput:t}},p=e=>({flex:1,minWidth:0,border:"none",backgroundColor:"transparent",fontFamily:r.Wx,fontSize:r.Il.size.sm,fontWeight:r.Il.weight.regular,color:e?r.AH.primary:r.AH.placeholder,outline:"none",padding:0}),h={padding:r.YK[2],border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:r.sJ.radius.sm,flexShrink:0},m=e=>{let{value:t,onChange:n,placeholder:s="Search History",icon:r=l}=e,{inputRef:a,focusInput:m}=u(),g=(0,o.useCallback)(e=>{n(e.target.value)},[n]);return(0,i.jsx)("div",{style:d,children:(0,i.jsxs)("div",{style:c,children:[(0,i.jsx)("input",{ref:a,type:"text",placeholder:s,value:t,onChange:g,style:p(!!t)}),(0,i.jsx)("button",{type:"button",style:h,onClick:m,"aria-label":"Focus search input",children:(0,i.jsx)(r,{width:20,height:20})})]})})};var g=n(84244);let y=e=>{let t=null;if(e.lastUpdateTime)t=new Date(e.lastUpdateTime);else if(e.last_update_time){let n=e.last_update_time;t=new Date(n>1e12?n:1e3*n)}else e.timestamp&&(t=new Date(1e3*e.timestamp));if(t&&!isNaN(t.getTime()))return(0,g.GP)(t,"MMM d");if(e.aiReply)try{let t=e.aiReply.match(/^([A-Za-z]{3}\s+\d{1,2}),\s+\d{4}$/);if(t)return t[1];if(e.aiReply.match(/^[A-Za-z]{3}\s+\d{1,2}$/))return e.aiReply}catch(e){}if(e.footer)try{let t=new Date(e.footer);if(!isNaN(t.getTime()))return(0,g.GP)(t,"MMM d")}catch(e){}return""},x=e=>{let t=null;if(e.lastUpdateTime)t=new Date(e.lastUpdateTime);else if(e.last_update_time){let n=e.last_update_time;t=new Date(n>1e12?n:1e3*n)}else if(e.timestamp)t=new Date(1e3*e.timestamp);else if(e.footer)try{let n=new Date(e.footer);isNaN(n.getTime())||(t=n)}catch(e){}return t&&!isNaN(t.getTime())?(0,g.GP)(t,"h:mm a"):""},f=e=>e.title?e.title:e.input?e.input:"Untitled chat",v=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:150;if(e.title&&e.aiReply||e.input&&e.aiReply){let n=e.aiReply.trim();return n.length>t?"".concat(n.substring(0,t),"..."):n}},b=(e,t)=>{if(!t.trim())return e;let n=t.toLowerCase();return e.filter(e=>"".concat(e.input," ").concat(e.title||""," ").concat(e.aiReply||"").toLowerCase().includes(n))};var j=n(29965),w=n.n(j);let C=e=>{let{title:t,description:n,maxLines:o=2,maxWidth:s}=e;return(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:r.YK[1],flexShrink:1,...s?{maxWidth:s}:{}},className:"md:max-w-[460px] max-w-[180px]",children:[(0,i.jsx)("p",{style:{color:r.AH.primary,textOverflow:"ellipsis",fontFamily:r.Wx,fontSize:r.Il.size.base,fontStyle:"normal",fontWeight:r.Il.weight.medium,lineHeight:"normal",margin:0,overflow:"hidden",
1whiteSpace:"nowrap"},children:t}),n&&(0,i.jsx)("p",{style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:o,overflow:"hidden",color:r.AH.secondary,textOverflow:"ellipsis",fontFamily:r.Wx,fontSize:r.Il.size.sm,fontStyle:"normal",fontWeight:r.Il.weight.regular,lineHeight:"normal",margin:0},children:n})]})},N=e=>{let{date:t,time:n}=e;return t||n?(0,i.jsxs)("span",{style:{color:"#000",fontFamily:r.Wx,fontSize:r.Il.size.base,fontStyle:"normal",fontWeight:r.Il.weight.regular,lineHeight:"normal"},children:[n&&(0,i.jsxs)(i.Fragment,{children:[n,(0,i.jsx)("span",{style:{margin:"0 ".concat(r.YK[1])},children:"\xb7"})]}),t]}):null};var I=n(86753),H=n(18019);let k=I.bL,S=I.l9;I.YJ,I.ZL,I.Pb,I.z6,o.forwardRef((e,t)=>{let{className:n,inset:o,children:s,...r}=e;return(0,i.jsxs)(I.ZP,{ref:t,className:(0,H.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",o&&"pl-8",n),...r,children:[s,(0,i.jsx)("span",{className:"ml-auto h-4 w-4",children:"â¶"})]})}).displayName=I.ZP.displayName,o.forwardRef((e,t)=>{let{className:n,...o}=e;return(0,i.jsx)(I.G5,{ref:t,className:(0,H.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...o})}).displayName=I.G5.displayName;let D=o.forwardRef((e,t)=>{let{className:n,sideOffset:o=4,...s}=e;return(0,i.jsx)(I.ZL,{children:(0,i.jsx)(I.UC,{ref:t,sideOffset:o,className:(0,H.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n),...s})})});D.displayName=I.UC.displayName;let R=o.forwardRef((e,t)=>{let{className:n,inset:o,...s}=e;return(0,i.jsx)(I.q7,{ref:t,className:(0,H.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o&&"pl-8",n),...s})});R.displayName=I.q7.displayName,o.forwardRef((e,t)=>{let{className:n,children:o,checked:s,...r}=e;return(0,i.jsxs)(I.H_,{ref:t,className:(0,H.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),checked:s,...r,children:[(0,i.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,i.jsx)(I.VF,{children:"â"})}),o]})}).displayName=I.H_.displayName,o.forwardRef((e,t)=>{let{className:n,children:o,...s}=e;return(0,i.jsxs)(I.hN,{ref:t,className:(0,H.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n),...s,children:[(0,i.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,i.jsx)(I.VF,{children:(0,i.jsx)("div",{className:"h-2 w-2 rounded-full bg-current"})})}),o]})}).displayName=I.hN.displayName,o.forwardRef((e,t)=>{let{className:n,inset:o,...s}=e;return(0,i.jsx)(I.JU,{ref:t,className:(0,H.cn)("px-2 py-1.5 text-sm font-semibold",o&&"pl-8",n),...s})}).displayName=I.JU.displayName,o.forwardRef((e,t)=>{let{className:n,...o}=e;return(0,i.jsx)(I.wv,{ref:t,className:(0,H.cn)("-mx-1 my-1 h-px bg-muted",n),...o})}).displayName=I.wv.displayName;let z={padding:r.YK[2],border:"none",background:r.t0.primary,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:r.sJ.radiu
1s.sm},_={backgroundColor:r.t0.primary,border:"".concat(r.sJ.width.thin," solid ").concat(r.Vo.base),borderRadius:r.sJ.radius.sm,padding:r.YK[1],minWidth:"120px"},E=e=>{let{src:t,children:n}=e;return n?(0,i.jsx)(i.Fragment,{children:n}):t?(0,i.jsx)("img",{src:t,alt:"",width:16,height:16,style:{display:"block",objectFit:"contain",flexShrink:0},onError:e=>{e.currentTarget.style.display="none"}}):null},F=e=>{let{items:t,trigger:n,align:o="end",triggerClassName:s,triggerStyle:a,contentClassName:l,contentStyle:d,onTriggerClick:c,minWidth:u="120px",sideOffset:p=4}=e,h=e=>{e.disabled||e.onClick()};return 0===t.length?null:(0,i.jsxs)(k,{children:[(0,i.jsx)(S,{onClick:e=>{e.stopPropagation(),null==c||c(e)},style:{...z,...a},className:s,"aria-label":"More options",children:n}),(0,i.jsx)(D,{align:o,sideOffset:p,style:{..._,minWidth:u,...d},className:l,children:t.map((e,t)=>(0,i.jsxs)(R,{onSelect:()=>h(e),disabled:e.disabled,className:(0,H.cn)("destructive"===e.variant?"text-destructive focus:text-destructive":"","gap-2"),style:{fontFamily:r.Wx,fontSize:r.Il.size.sm,color:"destructive"===e.variant?void 0:r.AH.primary},children:[(0,i.jsx)(E,{src:e.iconSrc,children:e.icon}),(0,i.jsx)("span",{children:e.label})]},t))})]})},K=()=>(0,i.jsx)("img",{src:"/assets/images/icons/ellipsis.svg",alt:"More options",width:24,height:24,style:{display:"block",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none"}}),T=e=>{let{onShare:t,onDelete:n}=e,o=[...t?[{label:"Share",onClick:t,iconSrc:"/assets/images/icons/share.svg"}]:[],...n?[{label:"Delete",onClick:n,iconSrc:"/assets/images/icons/trash.svg"}]:[]];return 0===o.length?null:(0,i.jsx)(F,{items:o,trigger:(0,i.jsx)(K,{}),align:"end",onTriggerClick:e=>{e.stopPropagation()}})},W=e=>{let{title:t,description:n,date:o,time:s,onShare:a,onDelete:l}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"flex flex-col gap-2 w-full md:hidden",children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:r.YK[2],flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:"32px",height:"32px",marginTop:"8px"},children:(0,i.jsx)(w(),{src:"/assets/images/icons/messages.svg",alt:"Messages icon",width:32,height:32,unoptimized:!0,style:{width:"32px",height:"32px",objectFit:"contain"}})}),(0,i.jsx)(C,{title:t,description:n})]}),(0,i.jsx)(T,{onShare:a,onDelete:l})]}),(0,i.jsx)("div",{style:{display:"flex",justifyContent:"flex-start",width:"100%",paddingLeft:"40px"},children:(0,i.jsx)(N,{date:o||"",time:s||void 0})})]}),(0,i.jsxs)("div",{className:"hidden md:flex md:items-center md:justify-between w-full",children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:r.YK[2],flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:"32px",height:"32px",marginTop:"8px"},children:(0,i.jsx)(w(),{src:"/assets/images/icons/messages.svg",alt:"Messages icon",width:32,height:32,unoptimized:!0,style:{width:"32px",height:"32px",objectFit:"contain"}})}),(0,i.jsx)(C,{title:t,description:n})]}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:r.YK[1],flexShrink:0},children:[(0,i.jsx)(N,{date:o||"",time:s||void 0}),(0,i.jsx)(T,{onShare:a,onDelete:l})]})]})]})},Y=e=>{let{entry:t,index:n,totalEntries:s,onClick:a,onShare:l,onDelete:d}=e,[c,u]=(0,o.useState)(!1),p=f(t),h=v(t),m=y(t),g=x(t);return(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:r.YK[1],paddingRight:r.YK[1],paddingTop:r.YK[4],paddingBottom:r.YK[4],borderRadius:r.sJ.radius.md,borderBottom:n<s-1?"".concat(r.sJ.width.thin," solid ").concat(r.Vo.light):"none",borderLeft:"none",borderRight:"none",borderTop:"none",cursor:"pointer",transition:"background-color 0.2s",width:"100%",backgroundColor:c?r.I8.tertiary:r.t0.primary},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onClick:e=>{var t;let n=e.target,i=n.closest('button, [role="menuitem"], [data-radix-dropdown-menu-trigger], [data-radix-dropdown-menu-content]');if((null==i?void 0:i.getAttribute("aria-label"))==="More options"||(null==i?void 0:i.closest('button[aria-label="More options"]'))||n.closest('[role="menuitem"]')||n.closest("[data-radix-dropdown-menu-trigger]")||n.closest("[data-radix-dropdown-menu-content]")||"IMG"===n.tagName&&(null===(t=n.getAttribute("src"))||void 0===t?void 0:t.includes("ellipsis"))||n.closest('img[src*="ellipsis"]')){e.preventDefault(),e.stopPropagation();return}a()},children:(0,i.jsx)(W,{title:p,description:h,date:m,time:g,onShare:l?()=>{u(!1),null==l||l(n)}:void 0,onDelete:d?()=>{u(!1),null==d||d(n)}:void 0})})};var L=n(45703),M=n.n(L);let A=()=>(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:r.YK[0],width:"100%",alignItems:"flex-start"},className:"jsx-4a5a7705e3596425 w-full md:w-[761px]",children:[[1,2,3,4,5].map(e=>(0,i.jsx)("div",{style:{display:"flex",width:"100%",padding:r.YK[4],flexDirection:"column",alignItems:"flex-start",ga
1p:"11px",borderRadius:"6px",borderBottom:e<5?"1px solid ".concat(r.t0.shade):"none"},className:"jsx-4a5a7705e3596425 w-full md:w-[761px]",children:(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},className:"jsx-4a5a7705e3596425",children:[(0,i.jsx)("div",{style:{flex:1,minWidth:0,maxWidth:"460px"},className:"jsx-4a5a7705e3596425 md:max-w-[460px] max-w-[180px]",children:(0,i.jsx)("div",{style:{height:"20px",backgroundColor:r.t0.shade,borderRadius:"4px",width:e%2==0?"80%":"60%",animation:"pulse 1.5s ease-in-out infinite"},className:"jsx-4a5a7705e3596425"})}),(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:r.YK[3],flexShrink:0},className:"jsx-4a5a7705e3596425",children:[(0,i.jsx)("div",{style:{height:"16px",width:"80px",backgroundColor:r.t0.shade,borderRadius:"4px",animation:"pulse 1.5s ease-in-out infinite"},className:"jsx-4a5a7705e3596425"}),(0,i.jsx)("div",{style:{height:"24px",width:"24px",backgroundColor:r.t0.shade,borderRadius:"4px",animation:"pulse 1.5s ease-in-out infinite"},className:"jsx-4a5a7705e3596425"})]})]})},e)),(0,i.jsx)(M(),{id:"4a5a7705e3596425",children:"@-webkit-keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}@-moz-keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}@-o-keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}@keyframes pulse{0%,100%{opacity:1}50%{opacity:.5}}"})]}),P=e=>{var t;let{entries:n,searchQuery:o,isLoading:s=!1,onEntryClick:a,onShare:l,onDelete:d}=e;return(console.log("\uD83D\uDCCB [HistoryList] Received props:",{entriesCount:n.length,isLoading:s,searchQuery:o,hasEntries:n.length>0,firstEntry:n[0]?{title:n[0].title,conversationId:null===(t=n[0])||void 0===t?void 0:t.conversationId}:null}),s)?(console.log("â³ [HistoryList] Showing loading placeholder"),(0,i.jsx)(A,{})):0===n.length?(console.log("â ï¸ [HistoryList] No entries, showing empty state"),(0,i.jsx)("div",{style:{padding:r.YK[8],textAlign:"center",color:r.AH.tertiary,fontFamily:r.Wx,fontSize:r.Il.size.base},children:o?"No chats found matching your search.":"No chat history yet. Start a new chat to see your conversations here."})):(console.log("â
[HistoryList] Rendering entries:",n.length),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:r.YK[0],width:"100%",alignItems:"flex-start"},className:"w-full md:w-[761px]",children:n.map((e,t)=>(console.log("\uD83D\uDCDD [HistoryList] Rendering entry ".concat(t,":"),{title:e.title,conversationId:null==e?void 0:e.conversationId}),(0,i.jsx)(Y,{entry:e,index:t,totalEntries:n.length,onClick:()=>a(t),onShare:l,onDelete:d},t)))}))};var O=n(86715),U=n(97665),G=n(82309),J=n(59836),q=n(87134);let B=(0,J.v)()((0,q.Zr)(e=>({searchHistory:[],addSearchEntry:function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"",a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"text",l=arguments.length>7&&void 0!==arguments[7]&&arguments[7],d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,c=arguments.length>9&&void 0!==arguments[9]?arguments[9]:[],u=arguments.length>10&&void 0!==arguments[10]?arguments[10]:[],p=arguments.length>11?arguments[11]:void 0;return e(e=>({searchHistory:[...e.searchHistory,{input:t,header:o,title:s,footer:r,aiReply:n,displayType:a,isTravelQuery:l,canGenerateItinerary:null===i,missingDetails:i,travelDetails:d,travelItems:c,quickFacts:u,travelCosts:p}]}))},updateLastSearchEntry:t=>e(e=>{if(0===e.searchHistory.length)return e;let n=[...e.searchHistory];return n[n.length-1]={...n[n.length-1],...t},{searchHistory:n}}),clearLastEntry:()=>e(e=>({searchHistory:e.searchHistory.slice(0,-1)})),clearSearchHistory:()=>e({searchHistory:[]})}),{name:"chat-history-store"})),Z=e=>{let{history:t}=e,[n,i]=(0,o.useState)(""),s=(0,o.useMemo)(()=>b(t,n),[t,n]);return{searchQuery:n,setSearchQuery:i,filteredHistory:s,hasResults:s.length>0}};var V=n(65251),Q=n(91498);let X=e=>{let{data:t,isLoading:n,error:i,refetch:o}=(0,V.I)({queryKey:["conversationHistory",e],queryFn:async()=>
1{if(!e)throw Error("User ID is required");return Q.v3.fetchConversationHistory({user_id:e})},enabled:!!e,gcTime:0,staleTime:0,retry:1});return{conversationHistory:t||null,isLoading:n,error:i?i instanceof Error?i.message:"Failed to fetch conversation history":null,refetch:o}};var $=n(23412),ee=n(895),et=n(87628),en=n(42255);let ei=e=>{let{searchQuery:t,onSearchChange:n,filteredHistory:o,isLoading:s=!1,onNewChat:l,onLogoClick:d,onEntryClick:c,onShare:u,onDelete:p}=e;return(0,i.jsx)(ee.NP,{defaultMode:"light",children:(0,i.jsxs)("div",{style:{minHeight:"100vh",backgroundColor:r.t0.primary,display:"flex",width:"100%",maxWidth:"100vw",overflowX:"hidden",boxSizing:"border-box"},children:[(0,i.jsx)(et.B,{onNewChat:l,onLogoClick:d}),(0,i.jsx)("div",{className:"md:hidden",children:(0,i.jsx)(en.n,{onNewChat:l,onLogoClick:d})}),(0,i.jsx)("main",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",justifyContent:"flex-start",alignItems:"center",width:"100%",maxWidth:"100%",boxSizing:"border-box",position:"relative"},className:"md:ml-[111px] pt-[56px] md:pt-[64px]",children:(0,i.jsxs)("div",{style:{width:"100%",maxWidth:"761px",display:"flex",flexDirection:"column",gap:r.YK[6],alignItems:"center",paddingTop:r.YK[6],paddingBottom:r.YK[6],paddingLeft:r.YK[4],paddingRight:r.YK[4]},className:"md:px-[320px] md:gap-[32px] md:py-4",children:[(0,i.jsx)(a,{}),(0,i.jsx)(m,{value:t,onChange:n}),(0,i.jsx)(P,{entries:o,searchQuery:t,isLoading:s,onEntryClick:c,onShare:u,onDelete:p})]})})]})})};var eo=n(56858),es=n(67540);let er=e=>{let{open:t,onOpenChange:n,title:o,description:s,confirmLabel:a="Confirm",cancelLabel:l="Cancel",onConfirm:d,onCancel:c,showCloseButton:u=!0,confirmVariant:p="default"}=e,h={padding:"".concat(r.YK[2]," ").concat(r.YK[4]),borderRadius:"6px",border:"none",background:"destructive"===p?"#DC2626":"#000",color:"#fff",fontFamily:r.Wx,fontSize:r.Il.size.base,fontWeight:r.Il.weight.regular,cursor:"pointer",transition:"opacity 0.2s"};return(0,i.jsx)(es.lG,{open:t,onOpenChange:n,children:(0,i.jsxs)(es.Cf,{showCloseButton:u,children:[(0,i.jsxs)(es.c7,{children:[(0,i.jsx)(es.L3,{style:{fontFamily:r.Wx,fontSize:r.Il.size.lg,fontWeight:r.Il.weight.semibold,color:r.AH.text},children:o}),(0,i.jsx)(es.rr,{style:{fontFamily:r.Wx,fontSize:r.Il.size.base,color:r.AH.secondary,marginTop:r.YK[2]},children:s})]}),(0,i.jsxs)(es.Es,{style:{display:"flex",gap:r.YK[3],marginTop:r.YK[4],justifyContent:"flex-end"},children:[(0,i.jsx)("button",{onClick:()=>{c?c():n(!1)},style:{padding:"".concat(r.YK[2]," ").concat(r.YK[4]),borderRadius:"6px",border:"1px solid #E7E5E4",background:"transparent",color:r.AH.text,fontFamily:r.Wx,fontSize:r.Il.size.base,fontWeight:r.Il.weight.regular,cursor:"pointer",transition:"background-color 0.2s"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#F5F5F4"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:l}),(0,i.jsx)("button",{onClick:()=>{d()},style:h,onMouseEnter:e=>{e.currentTarget.style.opacity="0.8"},onMouseLeave:e=>{e.currentTarget.style.opacity="1"},children:a})]})]})})};var ea=n(55910);let el=()=>{let e=(0,O.useRouter)(),{searchHistory:t}=B(),[n,s]=(0,o.useState)(null),[r,a]=(0,o.useState)(!1),[l,d]=(0,o.useState)(null),{openSharePopup:c,shareUrl:u,popupOpen:p,setPopupOpen:h,shareTitle:m,shareDescription:y}=(0,ea.R)({title:"Share Chat",description:"Copy the link below to share this conversation with others."});(0,o.useEffect)(()=>{try{let e=(0,$.cT)();s(e)}catch(e){console.error("â [HistoryContainer] Failed to generate user ID:",e)}},[]);let{conversationHistory:x,isLoading:f,error:v}=X(n),b=(0,U.jE)(),j=(0,G.n)({mutationFn:async e=>{let{userId:t,conversationId:n}=e;return(0,Q.ly)(t,n)},onSuccess:()=>{b.invalidateQueries({queryKey:["conversationHistory",n]})},onError:e=>{console.error("â [HistoryContainer] Delete error:",e)}});(0,o.useEffect)(()=>{if(x){var e;console.log("\uD83D\uDCCB [HistoryContainer] Conversation history from API:",x),console.log("\uD83D\uDCCB [HistoryContainer] Conversations count:",(null===(e=x.conversations)||void 0===e?void 0:e.length)||0),console.log("\uD83D\uDCCB [HistoryContainer] Conversations data:",x.conversations)}v&&console.error("â [HistoryContainer] API Error:",v),f&&console.log("â³ [HistoryContainer] Loading conversation history...")},[x,v,f]);let w=(0,o.useMemo)(()=>
1{if(!(null==x?void 0:x.conversations))return console.log("â ï¸ [HistoryContainer] No conversations in history:",x),[];console.log("\uD83D\uDD04 [HistoryContainer] Converting conversations to search entries:",x.conversations.length,"items");let e=x.conversations.map(e=>{let t=new Date(e.last_update_time),n=(0,g.GP)(t,"yyyy-MM-dd"),i=(0,g.GP)(t,"MMM d, yyyy"),o={footer:n,input:e.title||"Conversation ".concat(e.id.substring(0,8),"..."),title:e.title||"Conversation ".concat(e.id.substring(0,8),"..."),aiReply:e.description||i,displayType:"text",isTravelQuery:!1,canGenerateItinerary:!1,missingDetails:null,travelDetails:null,travelItems:[],quickFacts:[],conversationId:e.id,last_update_time:e.last_update_time,lastUpdateTime:e.last_update_time};return console.log("â [HistoryContainer] Converted entry:",{id:e.id,title:o.title,conversationId:o.conversationId}),o});return console.log("â [HistoryContainer] Converted entries count:",e.length),e},[x]),{searchQuery:C,setSearchQuery:N,filteredHistory:I}=Z({history:(0,o.useMemo)(()=>{console.log("\uD83D\uDD04 [HistoryContainer] Merging history:",{apiEntriesCount:w.length,localEntriesCount:t.length,totalCount:w.length+t.length});let e=[...w,...t].sort((e,t)=>{let n=(null==e?void 0:e.last_update_time)||(null==e?void 0:e.timestamp)||0;return((null==t?void 0:t.last_update_time)||(null==t?void 0:t.timestamp)||0)-n});return console.log("â [HistoryContainer] Sorted merged history:",{totalCount:e.length,sortedTimestamps:e.map(e=>{let t=(null==e?void 0:e.last_update_time)||(null==e?void 0:e.timestamp)||0;return{title:e.title,timestamp:t?new Date(t).toISOString():"no-timestamp"}})}),e},[w,t])});(0,o.useEffect)(()=>{console.log("\uD83D\uDD0D [HistoryContainer] Filtered history:",{totalCount:I.length,searchQuery:C,entries:I.map(e=>({id:null==e?void 0:e.conversationId,title:e.title}))})},[I,C]);let H=async e=>{let t=I[e],n=null==t?void 0:t.conversationId,i=window.location.origin,o=n?"".concat(i,"/chat?conversationId=").concat(n):"".concat(i,"/chat");await c(o)},k=async()=>{if(!l||!n){console.error("â [HistoryContainer] Cannot delete: missing conversation data"),a(!1);return}try{await j.mutateAsync({userId:n,conversationId:l.conversationId}),a(!1),d(null)}catch(e){console.error("â [HistoryContainer] Failed to delete conversation:",e)}};return(0,o.useEffect)(()=>{var e;console.log("\uD83C\uDFAF [HistoryContainer] Props to HistoryPresenter:",{filteredHistoryCount:I.length,isLoading:f,searchQuery:C,hasEntries:I.length>0,firstEntry:I[0]?{title:I[0].title,conversationId:null===(e=I[0])||void 0===e?void 0:e.conversationId}:null})},[I,f,C]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ei,{searchQuery:C,onSearchChange:N,filteredHistory:I,isLoading:f,onNewChat:()=>{e.push("/chat?new=1")},onLogoClick:()=>{e.push("/chat?view=full-landing")},onEntryClick:t=>{let n=I[t],i=null==n?void 0:n.conversationId;i?e.push({pathname:"/chat",query:{conversationId:i}}):e.push({pathname:"/chat",query:{historyId:t}})},onShare:H,onDelete:e=>{let t=I[e],i=null==t?void 0:t.conversationId;if(!i||!n){console.error("â [HistoryContainer] Cannot delete: missing conversationId or userId");return}d({index:e,conversationId:i}),a(!0)}}),(0,i.jsx)(eo.K,{open:p,onOpenChange:h,shareUrl:u,title:m,description:y}),(0,i.jsx)(er,{open:r,onOpenChange:a,title:"Delete Conversation",description:"Are you sure you want to delete this conversation? This action cannot be undone.",confirmLabel:"Delete",cancelLabel:"Cancel",confirmVariant:"destructive",onConfirm:k,onCancel:()=>{a(!1),d(null)}})]})};function ed(){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.Ay,{title:s.l1,description:s.jA,path:"/history",disableTitleSuffix:!0}),(0,i.jsx)(el,{})]})}}},e=>{var t=t=>e(e.s=t);e.O(0,[9965,4909,4335,2717,5251,7012,4089,2657,1037,8903,636,6593,8792],()=>t(5425)),_N_E=e.O()}]); 2//# sourceMappingURL=history-ebdeb82214762f08.js.map
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.