1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4595],{35194:function(e,t,n){"use strict";n.d(t,{EI:function(){return s},iA:function(){return l},kY:function(){return r}});var i=n(16287);n(47409);let s=()=>(0,i.G0)("/client/products/category/tree"),r=()=>i.ZP.get("/api/global/customizations?keys=material&language=en").then(e=>e.data),l=()=>i.ZP.get("api/global/state_abbreviations").then(e=>e.data)},14595:function(e,t,n){"use strict";n.d(t,{PortalAgent:function(){return to}});var i,s,r,l,a=n(27573),o=n(44087),c=n(10124),d=n(7653);let u=[/\/checkout\//,/\/export\//,/\/rate-card/];var m=n(38260),x=n(40164),g=n(72646),f=n(75259),h=n(67754),p=n(98582),v=n(61027),y=n(50966),j=n(87278);function b(e){let{icon:t,title:n,onClick:i,className:s="",requireLogin:r=!1,isLogin:l=!1}=e,o=Array.isArray(n)?n.join(" "):n,c=(0,a.jsxs)("div",{className:"relative flex w-full shrink-0 cursor-pointer flex-row items-center justify-center gap-3 rounded-2xl bg-white px-5 hover:border-[#E0E0E0] hover:bg-[#EDEDED] ".concat(s),onClick:r&&!l?void 0:i,children:[(0,a.jsx)("div",{className:"pointer-events-none absolute inset-0 rounded-2xl border border-[#e0e0e0] shadow-[0px_2px_4px_0px_rgba(0,0,0,0.05)]"}),(0,a.jsxs)("div",{className:"flex min-h-px min-w-px grow basis-0 flex-row items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex shrink-0 flex-row items-center gap-2",children:[t,(0,a.jsx)("div",{className:"shrink-0 text-center text-sm font-normal text-[#0d0d2b]",children:(0,a.jsx)("p",{className:"whitespace-pre leading-[1.4]",children:o})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[r&&!l&&(0,a.jsx)("span",{className:"py-1 text-xs font-medium text-[#0B0B0BA8]",children:"Log in"}),(0,a.jsx)(j.LZ,{size:16})]})]})]});return r&&!l?(0,a.jsx)(f.LoginModalTrigger,{onLoginSuccess:()=>null==i?void 0:i(),className:"w-full",children:c}):c}function w(e){let{icon:t,title:n,onClick:i,className:s="",requireLogin:r=!1,isLogin:l=!1}=e,o=Array.isArray(n)?n:[n],c=(0,a.jsxs)("div",{className:"relative flex min-h-0 min-w-0 grow cursor-pointer flex-row items-center justify-between gap-3 rounded-2xl border border-[#E0E0E0] bg-white px-5 py-3 text-[#0B0B0B] hover:bg-[#EDEDED] ".concat(s),onClick:r&&!l?void 0:i,style:{boxShadow:"box-shadow: 0px 2px 4px 0px #0000000D"},children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-1 flex-row items-center gap-2",children:[(0,a.jsx)("div",{className:"shrink-0",children:t}),(0,a.jsx)("div",{className:"min-w-0 shrink-0 text-base font-medium leading-5 text-[#0b0b0b]",children:o.map((e,t)=>(0,a.jsx)("p",{className:0===t?"mb-0":"",children:e},t))})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[r&&!l&&(0,a.jsx)("span",{className:"text-sm text-[#0B0B0BA8]",children:"Log in"}),(0,a.jsx)(j.LZ,{size:20})]})]});return r&&!l?(0,a.jsx)(f.LoginModalTrigger,{onLoginSuccess:()=>null==i?void 0:i(),className:"min-w-0 grow basis-0",children:c}):c}function k(e){var t;let{isExpanded:n,onPromptClick:i,className:s,itemsPerRow:r}=e,{ua:l}=(0,y.useAgentInfo)(),o=(0,v.xu)(),c=!!(null==o?void 0:null===(t=o.user_info)||void 0===t?void 0:t.email),d=r||(n?E:C).length,u=n?E:C,m=()=>1===d?"flex flex-col gap-2":"grid gap-3 w-full",x=()=>1===d?"":({1:"grid-cols-1",2:"grid-cols-1 sm:grid-cols-2",3:"grid-cols-1 sm:grid-cols-2 md:grid-cols-3",4:"grid-cols-1 sm:grid-cols-2 md:grid-cols-4",5:"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5",6:"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-6"})[Math.min((null==l?void 0:l.isMobile)?Math.min(d,2):d,6)]||"grid-cols-1 sm:grid-cols-2 md:grid-cols-4";return n?(0,a.jsx)("div",{className:"".concat(m()," ").concat(x()," w-full shrink-0 ").concat(s),children:u.map(e=>(0,a.jsx)(w,{icon:e.icon(),title:e.title,onClick:()=>i(e.message,e.scene),requireLogin:e.requireLogin,isLogin:c},e.id))}):(0,a.jsx)("div",{className:"".concat(m()," ").concat(x()," w-full shrink-0 ").concat(s),children:u.map(e=>(0,a.jsx)(b,{icon:e.icon(20),title:e.title,onClick:()=>i(e.message,e.scene),className:"!h-[44px]",requireLogin:e.requireLogin,isLogin:c},e.id))})}let N=[{id:"create-branded-merch",message:"Create branded merch",scene:"source_product",requireLogin:!1},{id:"make-fully-custom-product",message:"Make a fully custom product",scene:"fully_custom_product",requireLogin:!1},{id:"track-order-or-shipment",message:"Track order or shipment",scene:"track_order",requireLogin:!0},{id:"faq",message:"Ask a general question",scene:"faq",requireLogin:!1}],A={"create-branded-merch":{defaultIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;return(0,a.jsx)(j.pg,{size:e})},expandedIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;return(0,a.jsx)(j.pg,{size:e})},defaultTitle:"Create branded merch",expandedTitle:["Create branded merch"]},"make-fully-custom-product":{defaultIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;return(0,a.jsx)(j.cY,{size:e})},expandedIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;return(0,a.jsx)(j.cY,{size:e})},defaultTitle:"Make a fully custom product",expandedTitle:["Make a fully custom product"]},"track-order-or-shipment":{defaultIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;return(0,a.jsx)(j.mT,{size:e})},expandedIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;return(0,a.jsx)(j.mT,{size:e})},defaultTitle:"Track order or shipment",expandedTitle:["Track order or shipment"]},faq:{defaultIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:20;return(0,a.jsx)(j.q$,{size:e})},expandedIcon:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;return(0,a.jsx)(j.q$,{size:e})},defaultTitle:"Ask a general question",expandedTitle:["Ask a general question"]}},C=N.map(e=>({...e,icon:A[e.id].defaultIcon,title:A[e.id].defaultTitle})),E=N.map(e=>({...e,icon:A[e.id].expandedIcon,title:A[e.id].expandedTitle})),T={source_product:"Mock up merch with my branding",fully_custom_product:(null===(i=N.find(e=>"fully_custom_product"===e.scene))||void 0===i?void 0:i.message)||"",faq:(null===(s=N.find(e=>"faq"===e.scene))||void 0===s?void 0:s.message)||"",track_order:(null===(r=N.find(e=>"track_order"===e.scene))||void 0===r?void 0:r.message)||"",update_account:(null===(l=N.find(e=>"update_account"===e.scene))||void 0===l?void 0:l.message)||""};var I=n(16727),S=n(46575),_=n(44665),M=n(54070);function B(){let{chats:e,isLoading:t,isLoadingMore:n,hasNextPage:i,error:s,deleteChat:r,refresh:l,setLoadingElement:a,isValidating:o}=function(){var e;let{anonymous_info:t,user_info:n}=(0,v.xu)(),{isOpen:i}=(0,I.E)(),s=(0,d.useMemo)(()=>(null==n?void 0:n.email)?"user-".concat(n.email):(null==t?void 0:t.odin_id)&&
1(null==t?void 0:t.bruce)?"anonymous-".concat(t.odin_id,"-").concat(t.bruce):"no-auth",[null==n?void 0:n.email,null==t?void 0:t.odin_id,null==t?void 0:t.bruce]),{data:r,size:l,setSize:a,isLoading:o,error:c,isValidating:u,mutate:m}=(0,_.ZP)((e,t)=>{if(0===e)return"chat-list-first-".concat(s);if(!t||!t.data||0===t.data.length)return null;let n=t.data[t.data.length-1],i=(null==n?void 0:n.cursor)||"";return i?"chat-list-".concat(i,"-").concat(s):null},e=>{if(e.startsWith("chat-list-first-"))return(0,p.Ag)({size:20});let t=e.split("-").slice(2,-1).join("-")||"";return(0,p.Ag)({cursor:t,size:20})},{revalidateOnFocus:!0,revalidateOnReconnect:!1,refreshInterval:i?5e3:0}),x=(0,d.useMemo)(()=>r?r.flatMap(e=>e.data):[],[r]),g=r&&(null===(e=r[r.length-1])||void 0===e?void 0:e.data.length)===20,f=u&&l>1,h=(0,d.useCallback)(()=>{!u&&g&&a(e=>e+1)},[a,u,g]),y=(0,M.e5)({threshold:.1},h);return{chats:x,isLoading:o,isLoadingMore:f,hasNextPage:g,error:c,deleteChat:(0,d.useCallback)(async e=>{try{return await (0,p.GO)(e),await (0,S.JG)(e=>"string"==typeof e&&e.startsWith("chat-list"),void 0,{revalidate:!0}),Promise.resolve()}catch(e){return Promise.reject(e)}},[]),refresh:m,setLoadingElement:y,isValidating:u}}();return{chats:e,isLoading:t,isLoadingMore:n,hasNextPage:i,totalCount:e.length,error:s,deleteChat:r,refresh:l,setLoadingElement:a,isValidating:o,isEmpty:0===e.length}}var D=n(39518),F=n(74769),L=n(80733),z=n(82296),O=n(74847),R=n(39747),P=n(93148),W=n(46161),H=n.n(W),q=n(5480),Z=n.n(q),J=n(11054),V=n.n(J),G=n(36067),Y=n.n(G);function U(e){let t=H()(e),n=H()();return t.isToday()?"Today, ".concat(t.format("hh:mm a")):t.isYesterday()?"Yesterday, ".concat(t.format("hh:mm a")):t.year()===n.year()?t.format("MMM DD, hh:mm a"):t.format("MMM DD YYYY, hh:mm a")}H().extend(V()),H().extend(Y()),H().extend(Z());var Q=n(64072),X=n(54034);function K(e){let{isOpen:t,onClose:n,onConfirm:i,isLoading:s=!1}=e;return(0,a.jsxs)(X.u,{open:t,onClose:n,className:"w-[436px] rounded-[20px]",children:[(0,a.jsx)(X.u.Header,{children:(0,a.jsx)("h3",{className:"ui-text-lg ui-font-medium ui-text-gray-900",children:"Are you sure you want to delete this conversation?"})}),(0,a.jsx)(X.u.Content,{children:(0,a.jsx)("p",{className:"ui-text-sm ui-text-gray-500",children:"This will permanently delete this chat and all its contents."})}),(0,a.jsxs)(X.u.Footer,{className:"ui-gap-3",children:[(0,a.jsx)(Q.z,{variant:"secondary",onClick:n,disabled:s,children:"Cancel"}),(0,a.jsx)(Q.z,{variant:"danger",onClick:i,disabled:s,children:s?"Deleting...":"Yes, delete"})]})]})}function $(e){var t;let{chat:n,onDelete:i}=e,[s,r]=(0,d.useState)(!1),[l,o]=(0,d.useState)(!1),[c,u]=(0,d.useState)(!1),[m,x]=(0,d.useState)(!1),{switchToChat:g,setCurrentChatId:f,setMenuOpen:h,currentChatId:p}=(0,I.E)(),{refresh:v}=B(),y=()=>{r(!0),u(!1)},j=async()=>{try{o(!0),await i(n.id),r(!1),v()}catch(e){}finally{o(!1)}},b=(0,a.jsx)("div",{className:"w-[186px] p-4 text-left",children:(0,a.jsx)("div",{className:"w-full cursor-pointer justify-start text-base font-normal text-[#0D0D2B]",onClick:e=>{e.stopPropagation(),y()},children:"Delete"})}),w=n.unread_count>0,k=p===n.id,N=m||c||k,A=!m&&w;return(0,a.jsxs)("div",{className:"h-14 px-[6px] py-1",onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[(0,a.jsxs)("div",{className:(0,L.cn)("flex h-full w-full cursor-pointer items-center gap-1 rounded-lg px-3 text-left font-normal transition-colors hover:bg-gray-200/50",{"bg-gray-200/50 font-medium":k}),onClick:()=>{f(n.id),g(),h(!1)},children:[(0,a.jsxs)(P.kC,{flexDirection:"column",className:"min-w-0 flex-1",children:[(0,a.jsx)(R.S,{messageInfo:n.title||"New Chat",contentClassName:"z-[9999999]",onClick:e=>{e.stopPropagation()},useModalInMobile:!1,children:(0,a.jsx)("p",{className:"font-inter truncate text-sm not-italic leading-[140%] tracking-normal text-[#0b0b0b]",children:n.title||"New Chat"})}),(0,a.jsx)("p",{className:"font-inter truncate text-xs not-italic leading-[140%] tracking-normal text-[#0B0B0BA8]",children:U(null===(t=n.last_message)||void 0===t?void 0:t.created_at)})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center",children:[A&&!c&&(0,a.jsx)("div",{className:"h-2 w-2 rounded-full bg-[#C12E5A]"}),N&&!A&&(0,a.jsx)(O.e,{menuContent:b,onOpenChange:u,open:c,menuContentClassName:"z-[9999999] p-1 rounded-[20px]",children:(0,a.jsx)("div",{className:(0,L.cn)("flex h-6 w-6 cursor-pointer items-center justify-center rounded-sm transition-colors",{"bg-gray-200":c,"hover:bg-gray-100":!c}),onClick:e=>{e.stopPropagation()},children:(0,a.jsx)("span",{className:"text-[#0F172A] hover:text-gray-700 ",children:"â¯"})})})]})]}),(0,a.jsx)(K,{isOpen:s,onClose:()=>{r(!1)},onConfirm:j,isLoading:l})]})}function ee(){let{chats:e,isLoading:t,error:n,deleteChat:i,setLoadingElement:s,hasNextPage:r,isLoadingMore:l}=B();return t?(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,a.jsx)("div",{className:"px-5 pb-3 pt-5",children:(0,a.jsx)("h3",{className:"text-sm font-normal text-[#0B0B0BA8]",children:"Chat history"})}),(0,a.jsx)(et,{})]}):n?(0,a.jsxs)("div",{className:"flex flex-1 flex-col overflow-y-auto",children:[(0,a.jsx)("div",{className:"px-5 pb-3 pt-5",children:(0,a.jsx)("h3",{className:"text-sm font-normal text-[#0B0B0BA8]",children:"Chat history"})}),(0,a.jsx)("div",{className:"flex-1 px-5 text-center",children:(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsx)("p",{className:"text-sm text-[#0B0B0B80]",children:"Chat history couldn't be loaded. Please refresh or try again."})})})]}):0===e.length?(0,a.jsxs)("div",{className:"flex flex-1 flex-col overflow-y-auto",children:[(0,a.jsx)("div",{className:"px-5 pb-3 pt-5",children:(0,a.jsx)("h3",{className:"text-sm font-normal text-[#0B0B0BA8]",children:"Chat history"})}),(0,a.jsx)("div",{className:"flex-1 px-5 text-center",children:(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsx)("p",{className:"text-sm text-[#0B0B0B80]",children:"No chat history yet."})})})]}):(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,a.jsx)("div",{className:"px-5 pb-3 pt-5",children:(0,a.jsx)("h3",{className:"text-sm font-normal text-[#0B0B0BA8]",children:"Chat history"})}),(0,a.jsxs)("div",{className:"space-y-0",children:[e.map(e=>(0,a.jsx)($,{chat:e,onDelete:i},e.id)),r&&(0,a.jsx)("div",{ref:s,className:"flex items-center justify-center py-4",children:l?(0,a.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border border-gray-300 border-t-gray-600"}):(0,a.jsx)("div",{className:"h-4"})})]})]})}function et(){let e=e=>{let{width:t="w-full",height:n="h-4",rounded:i="rounded",className:s=""}=e;return(0,a.jsx)("div",{className:"relative overflow-hidden bg-gray-200 ".concat(t," ").concat(n," ").concat(i," ").concat(s),children:(0,a.jsx)("div",{className:"skeleton-animation absolute inset-0"})})};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("style",{children:"\n .skeleton-animation {\n background: linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0) 0%,\n rgba(255, 255, 255, 0.3) 50%,\n #E7E7E7\n );\n animation: skeleton-loading 1.5s infinite;\n }\n\n @keyframes skeleton-loading {\n 0% {\n transform: translateX(-100%);\n }\n 100% {\n transform: translateX(100%);\n }\n }\n "}),(0,a.jsx)("div",{className:"flex flex-col items-center justify-center px-5",children:Array.from({length:4},(e,t)=>t).map(t=>(0,a.jsx)(e,{height:"h-[10px]",className:"my-[17px] w-full"},t))})]})}var en=n(2684);function ei(e){let{onClose:t,showCloseButton:n=!0}=e;return(0,a.jsxs)("div",{className:"flex items-center justify-between p-5",children:[(0,a.jsx)(j.N_,{}),n&&(0,a.jsx)("button",{className:"flex h-5 w-5 items-center justify-center text-gray-600 transition-colors hover:text-gray-900","aria-label":"Close menu",onClick:t,children:(0,a.jsx)(en.s5_,{className:"h-full w-full"})})]})}function es(e){let{onClick:t}=e;return(0,a.jsxs)("button",{className:"flex w-full items-center gap-3 px-5 py-3 text-left transition-colors hover:bg-gray-200/50",onClick:t,children:[(0,a.jsx)(j.pO,{}),(0,a.jsx)("span",{className:"text-sm font-normal text-[#0b0b0b]",children:"New chat"})]})}function er(e){var t;let{className:n,onClose:i,showCloseButton:s=!0}=e,{chats:r}=B(),l=(0,v.xu)(),o=!!(null==l?void 0:null===(t=l.user_info)||void 0===t?void 0:t.email),{setCurrentChatId:c,setShouldShowLoginTip:d,shouldShowLoginTip:u,triggerLoginTipShake:m,switchToList:x,nextGreetingTitle:g}=(0,I.E)(),f=async()=>
1{if(!o&&r.length>0){u?m():d(!0),x();return}x(),g(),c(null)};return(0,a.jsxs)("div",{className:(0,L.cn)("flex h-full w-[286px] flex-col rounded-bl-[12px] rounded-tl-[12px] bg-[#f6f6f6]",n),children:[(0,a.jsx)(ei,{onClose:i,showCloseButton:s}),(0,a.jsx)(es,{onClick:f}),(0,a.jsx)(z.i,{className:"mt-2 bg-[#ededed]"}),(0,a.jsx)(ee,{})]})}var el=n(23009),ea=n(71517),eo=n(96379),ec=n(83807),ed=n(78949),eu="/_next/static/media/nory-grey-bg.84a23380.svg";let em={colors:{text:{primary:"#0d0d2b",default:"#0b0b0b",secondary:"#0b0b0ba8",tertiary:"#0b0b0b80",inverse:"#ffffff",brand:"#343482",emphasized:"#0E2337"},background:{primary:"#ffffff",light:"#f6f6f6",grey:"#f8f8f8",brand:{default:"#343482",muted:"#423ea2"},info:{muted:"#E1EAFB"},gradient:{teal:"linear-gradient(180deg, #FFF -43.05%, #EAF8F5 100%)",blue:"linear-gradient(180deg, #FFF -49.97%, #E1EAFB 100%)",purple:"linear-gradient(180deg, #FFF -41.89%, #F4E8FF 100%)",green:"linear-gradient(180deg, #FFF -65.99%, #EBFBE5 100%)",cobalt:"linear-gradient(180deg, #FFF -70.34%, #EAEAFA 100%)",yellow:"linear-gradient(180deg, #FFF -109.57%, #FFF7EA 100%)"}},border:{primary:"#e0e0e0",secondary:"#ededed",subtle:"#cfcfd6"},icon:{primary:"#0b0b0b",secondary:"#0b0b0ba8",brand:"#423ea2",inverse:"#ffffff"},grey:{800:"#0f172a",700:"#1e293b"},indigo:{400:"#262099"}},typography:{fontFamily:"Inter",heading:{fontSize:"16px",fontWeight:600,lineHeight:"normal"},body:{fontSize:"14px",fontWeight:400,lineHeight:1.6},bodyLarge:{fontSize:"14px",fontWeight:400,lineHeight:1.8},caption:{fontSize:"12px",fontWeight:400,lineHeight:1.4},captionMedium:{fontSize:"12px",fontWeight:500,lineHeight:1.4},button:{fontSize:"16px",fontWeight:500,lineHeight:1.4}},spacing:{containerPadding:"20px",messagePadding:"12px",messageGap:"8px",headerPadding:"20px"},layout:{containerMaxWidth:"800px",messageMaxWidth:"65%",agentMessageMaxWidth:"90%"},borderRadius:{container:"20px",message:"16px",messageSmall:"4px",input:"200",button:"32px"}};var ex=n(46861),eg=n(86866),ef=n(86772),eh=n(70832),ep=n(38363),ev=n.n(ep);let ey={typingSpeed:15,startDelay:0,pauseAfterTyping:0,cursor:"â",cursorBlinkSpeed:500,randomizeSpeed:0,respectReducedMotion:!0};var ej=n(1670),eb=n(76988),ew=n(73e3);function ek(e,t,n,i){let s=n;for(let n of t){if(n.end<=s)continue;if("tag"===n.kind){if(!n.complete)return Math.max(s,n.start);s=n.end;continue}"markdown"===n.kind&&(s=Math.max(s,n.innerStart));let t="markdown"===n.kind?n.innerEnd:n.end;for(;s<t&&i>0;){var r;s+=(null!==(r=e.codePointAt(s))&&void 0!==r?r:0)>65535?2:1,i--}if(s<t)break;s=n.end}return s}let eN=new Map([["invoice-group",em.colors.background.gradient.cobalt],["order-group",em.colors.background.gradient.green],["shipment-group",em.colors.background.gradient.green],["project-group",em.colors.background.gradient.blue],["project-confirm",em.colors.background.gradient.blue],["product-confirm",em.colors.background.gradient.blue],["project-summary",em.colors.background.gradient.blue],["product-summary",em.colors.background.gradient.blue],["spu-group-blue",em.colors.background.gradient.blue],["spu-group-purple",em.colors.background.gradient.purple],["update-account",em.colors.background.gradient.yellow],["brand-selector",em.colors.background.gradient.teal],["website-selector",em.colors.background.light],["tip-button",em.colors.background.primary],["tip",em.colors.background.info.muted],["tip-upload",em.colors.background.primary],["rating",em.colors.background.light],["thinking",em.colors.background.light]]),eA=new Map([["invoice-group","900px"],["order-group","640px"],["shipment-group","640px"],["project-group","720px"],["project-confirm","720px"],["product-confirm","720px"],["project-summary","720px"],["product-summary","720px"],["markdown","650px"],["rich-text","650px"],["text","650px"],["tip","600px"],["tip-button","600px"]]),eC=new Map([["invoice-group","100%"],["order-group","100%"],["shipment-group","100%"],["project-group","100%"],["project-confirm","100%"],["product-confirm","100%"],["project-summary","100%"],["product-summary","100%"]]),eE=(e,t)=>{var n;return"spu-group"===e.node_type?eN.get("spu-group-purple"):null!==(n=eN.get(e.node_type))&&void 0!==n?n:t?em.colors.background.light:em.colors.background.primary},eT=(e,t,n,i,s)=>{let r=(0,eg.S)(i),l=eA.get(e.node_type),a=eC.get(e.node_type),o="tip-button"===e.n
1ode_type||"tip-upload"===e.node_type,c={border:"1px solid ".concat(n.colors.border.primary),borderRadius:"12px",padding:"0px",overflow:"hidden"},d="tip"===e.node_type,u={padding:"12px 16px",color:n.colors.text.emphasized},m=["text","markdown","rich-text"].includes(e.node_type)&&!t?s?"4px 0 0 0":"0px":"12px 16px";return{flexDirection:"column",display:r?"block":"flex",background:eE(e,t),color:n.colors.text.default,fontFamily:n.typography.fontFamily,fontSize:n.typography.body.fontSize,fontWeight:n.typography.body.fontWeight,lineHeight:n.typography.bodyLarge.lineHeight,maxWidth:l,width:a||"fit-content",borderRadius:t?"12px 0 12px 12px":"0 16px 16px 16px",wordBreak:"break-word",padding:m,...d?u:{},...o?c:{}}},eI=(0,d.memo)(function(e){let{message:t,isUser:n,isMe:i,designTokens:s,onSendMessage:r,onLoginSuccess:l,isThinking:o,chat_id:c,showAvatar:u=!0}=e,{ua:m}=(0,y.useAgentInfo)(),{isExpanded:x}=(0,I.E)(),{nodes:g,isTyping:f,showCursor:h}=function(e,t,n){let[i,s]=(0,d.useState)(null),r=(0,d.useRef)(!1),l=(0,d.useRef)(null),[a,o]=(0,d.useState)(null);(0,d.useEffect)(()=>{if(!t)return;if(!ey.respectReducedMotion){s(!1);return}let e=window.matchMedia("(prefers-reduced-motion: reduce)"),n=()=>s(e.matches);return n(),e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[t]);let c=(0,d.useMemo)(()=>t?function(e){let t=[],n=0,i=0,s=e=>{e>n&&t.push({kind:"text",start:n,end:e})};for(;i<e.length;){if("`"===e[i]||"~~~"===e.slice(i,i+3)){let t=e[i],n=i;for(;e[n]===t;)n++;let s=e.slice(i,n),r=e.indexOf(s,n);i=r<0?e.length:r+s.length;continue}if("<"!==e[i]){i++;continue}let l=/^<([a-zA-Z][\w-]*)/.exec(e.slice(i)),a=null==l?void 0:l[1].toLowerCase(),o=i+((null==l?void 0:l[0].length)||0);if(!a||!(0,ej.o)(a)){if(/^<[a-zA-Z]*$/.test(e.slice(i)))return s(i),t.push({kind:"tag",start:i,end:e.length,complete:!1}),t;i++;continue}if(o<e.length&&!/[\s/>]/.test(e[o])){i++;continue}s(i);let c=(0,ew.N)(e,i),d=c>=0&&/\/\s*>$/.test(e.slice(i,c)),u=c>=0&&!d?(0,ew.V)(e,c,a):null,m=d||!!u,x=d?c:(null==u?void 0:u.end)||e.length;if("markdown"===a&&c>=0){var r;t.push({kind:"markdown",name:a,start:i,end:x,complete:m,innerStart:c,innerEnd:null!==(r=null==u?void 0:u.start)&&void 0!==r?r:e.length})}else t.push({kind:"tag",name:a,start:i,end:x,complete:m});i=x,n=x}return s(e.length),t}(e):[],[e,t]),[u,m]=(0,d.useState)({source:e,position:0}),x=i?e.length:u.position;if(!i&&u.source!==e){let t=0;for(;t<Math.min(u.source.length,e.length)&&u.source[t]===e[t];)t++;x=Math.min(x,t)}let g=(0,d.useRef)({content:e,parts:c,position:x});g.current={content:e,parts:c,position:x};let f=t&&!1===i&&ek(e,c,x,1)!==x;return(0,d.useEffect)(()=>{t&&i&&(r.current=!0,m({source:e,position:e.length}))},[e,t,i]),(0,d.useEffect)(()=>{if(!f){null!==l.current&&clearTimeout(l.current),l.current=null;return}if(null!==l.current)return;let e=()=>ey.typingSpeed+(ey.randomizeSpeed>0?(2*Math.random()-1)*ey.randomizeSpeed:0),t=()=>{l.current=null;let{content:n,parts:i,position:s}=g.current,a=ek(n,i,s,function(e,t,n){let i=0;for(let r of t){if(r.end<=n)continue;if("tag"===r.kind){if(!r.complete)break;continue}let t="markdown"===r.kind?r.innerStart:r.start,l="markdown"===r.kind?r.innerEnd:r.end,a=Math.max(n,t);for(;a<l;){var s;if(a+=(null!==(s=e.codePointAt(a))&&void 0!==s?s:0)>65535?2:1,++i>240)return 8}}return i>120?4:i>60?2:1}(n,i,s));ek(n,i,a,1)!==a&&(l.current=setTimeout(t,e())),a!==s&&(r.current=!0,g.current.position=a,m({source:n,position:a}))},n=r.current?e():ey.startDelay;0===n?t():l.current=setTimeout(t,n)}),(0,d.useEffect)(()=>()=>{null!==l.current&&clearTimeout(l.current),l.current=null},[]),(0,d.useEffect)(()=>{if(!t||n||f||!1!==i){o(null);return}if(!e||ey.pauseAfterTyping<=0)return;let s=setTimeout(()=>o(e),ey.pauseAfterTyping);return()=>clearTimeout(s)},[e,t,n,f,i]),{nodes:(0,d.useMemo)(()=>t?function(e,t,n){let i=[];for(let s of t){if(s.start>n)break;if("tag"===s.kind){if(!s.name)continue;let t=s.complete?e.slice(s.start,s.end):"<".concat(s.name," />"),n=(0,ej.p)(t,"markdown");i.push(...n.map(e=>({...e,pending:!s.complete})))}else{let t="markdown"===s.kind?s.innerStart:s.start,r=Math.min(n,"markdown"===s.kind?s.innerEnd:s.end),l=e.slice(t,Math.max(t,r));"markdown"!==s.kind||s.complete||(l=l.replace(/<\/?(?:m(?:a(?:r(?:k(?:d(?
1:o(?:w(?:n)?)?)?)?)?)?)?)?$/i,"")),l.trim()&&i.push({node_type:"markdown",innerHtml:String((0,eb.e)(l))})}}return i}(e,c,x):void 0,[e,t,c,x]),isTyping:f,showCursor:t&&!!e&&!1===i&&(n||f||ey.pauseAfterTyping>0&&a!==e)}}(t.content,!n&&void 0!==t.isStreaming,!!t.isStreaming),p=t.stream_id||t.id,v=(0,d.useMemo)(()=>{var e,n;return(0,eo.fK)({message:t.content,defaultTextType:(null==t?void 0:null===(e=t.user)||void 0===e?void 0:e.type)==="ai"?"markdown":"text",isAutoAddTip:(null==t?void 0:null===(n=t.user)||void 0===n?void 0:n.type)==="ai",parsedNodes:g})},[t.content,t.user.type,g]),j=h?null==g?void 0:g.at(-1):void 0,b={"--typewriter-blink-speed":"".concat(ey.cursorBlinkSpeed,"ms"),"--typewriter-cursor":JSON.stringify(ey.cursor)},w=h&&(0,a.jsx)("span",{className:ev().cursor,style:b,"aria-hidden":"true",children:ey.cursor}),k=(0,d.useMemo)(()=>(null==m?void 0:m.isMobile)||!x?"mobile":"pc",[null==m?void 0:m.isMobile,x]),N=(0,d.useMemo)(()=>v.map(e=>eT(e[0],i,s,t.content,u)),[v,i,s,t.content,u]),A=(0,d.useMemo)(()=>(0,L.cn)("flex flex-wrap items-start gap-2 whitespace-pre-wrap break-words",i?"justify-end":"justify-start"),[i]);return(0,a.jsxs)(ef.x1,{isThinking:o||t.isStreaming||f,onSendMessage:r,onLoginSuccess:l,messageId:t.id,interacts:t.interacts,chatId:c,children:[v.map((e,t)=>(0,a.jsxs)("div",{className:(0,L.cn)(A),style:{...N[t],...b},children:[e.map((e,s)=>(0,a.jsx)(eh.l,{node:e,mode:k,isUser:n,isMe:i,showTypingCursor:e===j},"".concat(p,"-").concat(t,"-").concat(s))),(null==j?void 0:j.node_type)!=="markdown"&&e.includes(j)&&w]},"".concat(p,"-").concat(t))),!j&&w]})}),eS={ai:(0,a.jsx)(ed.TinyImage,{src:eu,alt:"Agent Avatar",className:"h-8 w-8",width:32,height:32})},e_={ai:"Nory"},eM="Anonymous";function eB(e){var t,n,i,s,r,l,o,c,d,u;let{message:m,onSendMessage:x,showAvatar:g=!0,showName:f=!0,onLoginSuccess:h,isThinking:p,defaultName:y,chat_id:j}=e,b=(null==m?void 0:null===(t=m.user)||void 0===t?void 0:t.type)==="client"||(null==m?void 0:null===(n=m.user)||void 0===n?void 0:n.type)==="anonymous",w=null==m?void 0:m.is_me,k=!b||(null==m?void 0:null===(i=m.user)||void 0===i?void 0:i.type)==="client",{userName:N,userInfo:A}=(0,v.Xl)(),C=null==A?void 0:A.first_name,E=null==A?void 0:A.last_name;return w?(0,a.jsxs)("div",{className:(0,L.cn)("flex items-start justify-end gap-x-2 gap-y-2 px-5 pb-5"),"data-message-id":m.id,children:[(0,a.jsxs)("div",{className:"flex flex-col items-end gap-1",style:{maxWidth:em.layout.messageMaxWidth},children:[f&&(0,a.jsx)("span",{className:"text-black-primary-0/66 self-end text-right font-['Inter'] text-xs font-normal leading-[1.4]",children:N||eM}),(0,a.jsx)(eI,{message:m,isUser:b,isMe:w,designTokens:em,onSendMessage:x,isThinking:p}),m.status&&(0,a.jsxs)("span",{className:"self-end text-right font-['Inter'] text-xs font-normal leading-[1.8] text-[rgba(11,11,11,0.66)]",children:["sending"===m.status&&"Uploading...","sent"===m.status&&"Sent","failed"===m.status&&(0,a.jsxs)("div",{className:"flex items-center gap-1 text-[#972245]",children:[(0,a.jsx)(ec.$O,{className:"h-4 w-4"}),"Message failed to send.",(0,a.jsx)(P.Qj,{className:"text-[#972245]",onClick:()=>{null==x||x({content:m.content,attachments:[],isStrict:!0,id:m.id})},children:"Retry"})]})]})]}),g?(0,a.jsx)(ex.Y,{id:null==m?void 0:null===(u=m.user)||void 0===u?void 0:u.id,name:C||eM,lastName:E||"",size:32,isMe:null==m?void 0:m.is_me}):(0,a.jsx)("div",{className:"h-8 w-8 flex-shrink-0"})]}):(0,a.jsxs)("div",{className:"flex items-start justify-start gap-x-2 gap-y-2 px-5 pb-5","data-message-id":m.id,children:[k&&(g?eS[null==m?void 0:null===(s=m.user)||void 0===s?void 0:s.type]||(0,a.jsx)(ex.Y,{id:null==m?void 0:null===(r=m.user)||void 0===r?void 0:r.id,name:(null==m?void 0:null===(l=m.user)||void 0===l?void 0:l.name)||y||eM,lastName:null==m?void 0:null===(o=m.user)||void 0===o?void 0:o.last_name,size:32,isMe:null==m?void 0:m.is_me}):(0,a.jsx)("div",{className:"h-8 w-8 flex-shrink-0"})),(0,a.jsxs)("div",{className:"flex w-full flex-col items-start gap-2",style:{maxWidth:em.layout.agentMessageMaxWidth},children:[f&&(0,a.jsx)("span",{className:"font-['Inter'] text-xs font-normal leading-[1.4] text-[rgba(11,11,11,0.66)]",children:e_[null==m?void 0:null===(c=m.user)||void 0===c?void 0:c.type]||(null==m?void 0:null===(d=m.user)||void 0===d?void 0:d.name)||"Agent"}),(0,a.jsx)(eI,{message:m,isUser:b,isMe:w,isThinking:p,designTokens:em,onSendMessage:x,onLoginSuccess:h,chat_id:j,showAvatar:g})]})]})}function eD(e){let{time:t}=e;return(0,a.jsx)("div",{className:"flex justify-center py-3",children:(0,a.jsx)("div",{className:"text-center",style:{color:"#0B0B0B",fontFamily:"Inter",fontSize:"12px",fontWeight:400,lineHeight:"normal"},children:(0,a.jsx)("span",{style:{fontFamily:"Inter, -apple-system, Roboto, Helvetica, sans-serif",fontWeight:400,fontSize:"12px",color:"rgba(11,11,11,0.66)"},children:t})})})}function eF(e){let{messages:t,loading:n=!1,hasMore:i=!1,onLoadMore:s,onSendMessage:r,shouldScrollToBottom:l=!1,chatId:o,isThinking:c=!1,isStreaming:u=!1,thinkingList:m=[],className:x}=e,g=(0,d.useRef)(null),f=(0,d.useRef)(null),[h,p]=(0,d.useState)(!0),[y,j]=(0,d.useState)(!1),b=(0,d.useRef)(0),w=(0,d.useRef)(0),{postCommitRead:k}=eL(),{trigger:N}=(0,ea.TR)(),[A,C]=(0,d.useState)(null),{access:E}=(0,v.xu)(),T=(0,d.useMemo)(()=>{var e,n,i;let s=t.find(e=>{var t;return(null===(t=e.user)||void 0===t?void 0:t.type)==="ai"}),r={id:"thinking",created_at:new Date().toISOString(),content:'<Thinking messages="'.concat(encodeURIComponent(JSON.stringify(m)),'" />'),attachments:[],is_me:!1,user:{id:(null==s?void 0:null===(e=s.user)||void 0===e?void 0:e.id)||"ai",name:(null==s?void 0:null===(n=s.user)||void 0===n?void 0:n.name)||"Nory",avatar:(null==s?void 0:null===(i=s.user)||void 0===i?void 0:i.avatar)||"",type:"ai",is_me:!1},cursor:""},l=[...t];return c&&(null==l?void 0:l.length)>0&&l.push(r),l.filter(e=>!(0,eo.Fj)(e.content))},[t,c,m]);(0,d.useEffect)(()=>
1{if(!h||!t.some(e=>void 0!==e.isStreaming))return;let e=g.current,n=f.current;if(!e||!n)return;let i=new ResizeObserver(()=>{e.scrollTop=e.scrollHeight});return i.observe(n),()=>i.disconnect()},[h,t]),(0,d.useEffect)(()=>{var e;let t=g.current;if(!t)return;let n=null==T?void 0:null===(e=T[(null==T?void 0:T.length)-1])||void 0===e?void 0:e.cursor,i=()=>{n&&k({chatId:o,cursor:n})};if(l){let e=setTimeout(()=>{let e=t.querySelectorAll("[data-message-id]"),n=e.item(e.length-1),s=n?t.scrollTop+n.getBoundingClientRect().top-t.getBoundingClientRect().top:t.scrollHeight;console.log("top>>>",t.scrollTop,n.getBoundingClientRect().top,t.getBoundingClientRect().top,t.scrollHeight),t.scrollTop=s-5,i()},0);return()=>clearTimeout(e)}if(h){let e=setTimeout(()=>{t.scrollTop=t.scrollHeight,p(!0),i()},0);return()=>clearTimeout(e)}},[T,h,l,o,k]);let I=(0,d.useCallback)(()=>{let e=g.current;if(!e)return;let{scrollTop:t,scrollHeight:n,clientHeight:r}=e;p(n-t-r<10),t<100&&i&&!y&&s&&(b.current=e.scrollHeight,w.current=e.scrollTop,j(!0),s())},[i,y,s]);(0,d.useEffect)(()=>{let e=g.current;if(!n&&y&&e){let t=e.scrollHeight-b.current;e.scrollTop=w.current+t,j(!1)}else n||j(!1)},[n,y]);let S=(0,d.useCallback)(e=>{let{messageId:t,chatId:n}=e;C(null),N({chat_id:n,message_id:t,type:"login_success"})},[N]);return(0,d.useEffect)(()=>{A&&E&&S({messageId:A,chatId:o})},[A,E,o,S]),(0,a.jsx)("div",{className:(0,L.cn)("relative min-h-0 flex-1",x),children:(0,a.jsxs)("div",{ref:g,className:"custom-scrollbar h-full touch-pan-y overflow-y-auto overscroll-contain px-0",onScroll:I,style:{WebkitOverflowScrolling:"touch"},children:[n&&(0,a.jsx)("div",{className:"flex justify-center py-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[(0,a.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600"}),"Loading more messages..."]})}),(0,a.jsx)("div",{className:"pt-3",ref:f,children:(()=>{let e=[];for(let t=0;t<T.length;t++){let n=T[t],i=t>0?T[t-1]:null,s=0===t||i&&new Date(n.created_at).getTime()-new Date(i.created_at).getTime()>3e5;if(s){let i="time-".concat(t),s=U(n.created_at);e.push((0,a.jsx)(eD,{time:s},i))}e.push((0,a.jsx)(eB,{message:n,onSendMessage:r,onLoginSuccess:()=>{C(n.id)},isThinking:c||u,chat_id:o,...(()=>{var e,r,l,a;return{showAvatar:!(i&&(null===(e=i.user)||void 0===e?void 0:e.id)===(null===(r=n.user)||void 0===r?void 0:r.id)&&
1(null===(l=i.user)||void 0===l?void 0:l.type)===(null===(a=n.user)||void 0===a?void 0:a.type))||s||0===t,showName:!1}})()},n.stream_id||n.id))}return e})()}),0===T.length&&!n&&(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center text-gray-500",children:[(0,a.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-gray-100",children:(0,a.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),(0,a.jsx)("p",{className:"text-sm",children:"Start a conversation"})]})})]})})}let eL=()=>{let e=(0,d.useRef)({});return{postCommitRead:(0,d.useCallback)(t=>{let{chatId:n,cursor:i}=t;if(!n||!i)return;let s="".concat(n,"-").concat(i);e.current[s]||(e.current[s]=!0,(0,p.my)({chat_id:n,cursor:i}))},[])}};function ez(e){var t;let{onClose:n,isExpanded:i,toggleExpanded:s,onMenuButtonClick:r,onClickHumanButton:l,talkToHumanButtonDisabled:o}=e,c=(0,v.xu)(),d=!!(null==c?void 0:null===(t=c.user_info)||void 0===t?void 0:t.email);return(0,a.jsx)("div",{className:"px-5 pb-5 pt-5",style:{borderBottom:"1px solid ".concat(em.colors.border.secondary)},children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[d&&(0,a.jsx)(eP,{onClick:r}),(0,a.jsx)(eR,{isExpanded:i,onClickHumanButton:l,humanButtonDisabled:o})]}),(0,a.jsx)(eO,{onClose:n,toggleExpanded:s,isExpanded:i,talkToHumanButtonDisabled:o,handleTalkToHumanButtonClick:l})]})})}function eO(e){let{onClose:t,toggleExpanded:n,isExpanded:i,talkToHumanButtonDisabled:s,handleTalkToHumanButtonClick:r}=e,{ua:l}=(0,y.useAgentInfo)(),o=(0,a.jsx)(R.S,{customTip:"Talk to the Wayo team",contentClassName:"py-3 px-4 border-[#EDEDED] shadow-none bg-white rounded-xl text-[#0B0B0BA8]",children:(0,a.jsx)(eW,{isDisabled:s,onClick:r,startIcon:(0,a.jsx)("span",{className:"text-[#0B0B0BA8]",children:(0,a.jsx)(j.tB,{className:"opacity-66"})}),children:i&&(0,a.jsx)("span",{className:"max-md:hidden",children:"Talk to the Wayo team"})})}),c=null;return c=l.isMobile?(0,a.jsx)("div",{className:"rounded-ful flex flex-shrink-0 items-center",children:(0,a.jsx)("button",{onClick:t,className:"flex items-center justify-center rounded-full transition-colors hover:bg-slate-100 active:bg-slate-200",children:(0,a.jsx)("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center",children:(0,a.jsx)(j.Tw,{})})})}):(0,a.jsxs)("div",{className:"rounded-ful flex flex-shrink-0 items-center gap-x-3",children:[(0,a.jsx)("button",{onClick:n,className:"flex items-center justify-center rounded-md p-1 transition-colors hover:bg-[#EDEDED] active:bg-slate-200",children:(0,a.jsx)("div",{className:"flex h-6 w-6 flex-shrink-0 items-center justify-center",children:i?(0,a.jsx)(j.jM,{}):(0,a.jsx)(j.vc,{})})}),(0,a.jsx)("button",{onClick:t,className:"flex items-center justify-center rounded-md p-1 transition-colors hover:bg-[#EDEDED] active:bg-slate-200",children:(0,a.jsx)(j.Tw,{})})]}),(0,a.jsxs)("div",{className:(0,L.cn)("flex items-center max-md:gap-x-2",i?"gap-x-5":"gap-x-3"),children:[i&&o,c]})}function eR(e){let{isExpanded:t,onClickHumanButton:n,humanButtonDisabled:i}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"h-[46px] w-[46px]",children:(0,a.jsx)("img",{alt:"",className:"block h-full w-full max-w-none",src:eu})}),(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h1",{className:"whitespace-nowrap font-['Inter'] text-base font-semibold leading-normal text-[#0d0d2b]",children:"Nory the AI Agent"}),!t&&(0,a.jsx)(eW,{isDisabled:i,onClick:n,className:"gap-x-0.5 border-none p-0 text-[#423EA2] hover:bg-transparent hover:underline",startIcon:(0,a.jsx)(j.tB,{}),children:(0,a.jsx)("span",{children:"Talk to the Wayo team"})})]})]})}function eP(e){let{onClick:t}=e;return(0,a.jsx)("button",{onClick:t,className:"flex h-6 w-6 items-center justify-center",children:(0,a.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,a.jsx)("path",{d:"M4 6H20M4 12H20M4 18H20",stroke:"#0F172A",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function eW(e){let{onClick:t,isDisabled:n,children:i,className:s,startIcon:r}=e;return(0,a.jsxs)("button",{className:(0,L.cn)("font-Inter text-black-primary-0 flex items-center justify-center gap-1 gap-x-1 whitespace-nowrap rounded-lg border border-[#
1E0E0E0] bg-white px-3 py-2 text-center text-sm font-medium leading-[140%] hover:border-[#EDEDED] hover:bg-[#EDEDED]",n?"opacity-50":"",s),onClick:t,disabled:n,children:[r,i]})}n(86545);var eH=n(2154),eq=n(49784);function eZ(){var e;let{chatId:t,setFirstThinking:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[i,s]=(0,d.useState)([]),[r,l]=(0,d.useState)(!1),[a,o]=(0,d.useState)(!0),[c,u]=(0,d.useState)(!1),{trigger:m}=(0,eH.$3)(),{trigger:x}=(0,eH.vz)(),{userName:g}=(0,v.Xl)(),{disconnect:f,messages:h,streamMessages:p,thinkingList:y,deleteMessageIds:j,isThinking:b}=(0,eH.Bl)(t||null,void 0,2),w=p.some(e=>e.content);(0,d.useEffect)(()=>{w&&(null==n||n(!1))},[t,w,n]),(0,d.useEffect)(()=>{t||f()},[f,t]);let k=(0,d.useRef)(new Set),N=(0,d.useRef)(new Set),[A,C]=(0,d.useState)(!1);(0,d.useEffect)(()=>{(j||[]).length>0&&s(e=>eJ(e.filter(e=>!j.some(t=>t.message_id===e.id))))},[j,s]),(0,d.useEffect)(()=>{var e;if(A)return;let t=[...i,...h],r=t[t.length-1];if((null==r?void 0:null===(e=r.user)||void 0===e?void 0:e.type)==="ai"&&(null==n||n(!1)),h&&h.length>0){let e=h.filter(e=>{let t="".concat(e.id);return!k.current.has(t)&&(k.current.add(t),!0)});if(e.length>0){let t=e.filter(e=>!N.current.has(e.id)&&!i.some(t=>t.id===e.id)).map(e=>({...e,id:"".concat(e.id),content:(null==e?void 0:e.content)||""})),n=e.filter(e=>{var t,n;return(null===(t=e.user)||void 0===t?void 0:t.type)==="client"||(null===(n=e.user)||void 0===n?void 0:n.type)==="anonymous"});n.length>0&&s(e=>eJ(e.map(e=>{let t=n.find(t=>t.id===e.id);return t&&t.created_at!==e.created_at?{...e,created_at:t.created_at}:e}))),t.length>0&&(s(e=>eJ([...e,...t])),u(!0))}}},[h,i,A,n]);let E=null===(e=i[0])||void 0===e?void 0:e.cursor,T=(0,d.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!t||r||!a)return;l(!0);let n=await x({chat_id:t,cursor:E}),i=((null==n?void 0:n.data)||[]).reverse();if(s(e=>eJ([...i.filter(t=>!e.some(e=>e.id===t.id)),...e])),o(i.length>=20),0===i.length&&(!(null==n?void 0:n.data)||0===n.data.length)&&e<3){setTimeout(()=>{T(e+1)},500);return}l(!1)},[r,a,x,E,t]),I=(0,d.useCallback)(async e=>{let{content:n,attachments:i,chatId:r,isStrict:l=!0,id:a}=e,o={id:a||"user-".concat(Date.now()),content:(0,eo.wv)(n,i,l),is_me:!0,user:{id:"user-1",name:g,avatar:"",type:"client",is_me:!0},cursor:"",created_at:new Date().toISOString(),attachments:i,status:"sending"};s(e=>{let t=null==e?void 0:e.find(e=>(null==e?void 0:e.id)===a),n=null==e?void 0:e.findLast(e=>{var t;return(null==e?void 0:null===(t=e.user)||void 0===t?void 0:t.type)==="ai"});return t&&a?e.map(e=>e.id===t.id?{...e,status:"sending",created_at:eG(o.created_at,eV(null==n?void 0:n.created_at))}:e):eJ([...e,{...o,created_at:eG(o.created_at,eV(null==n?void 0:n.created_at))}])}),u(!0),C(!0);try{var c;let e=await m({chat_id:r||t,content:o.content,attachments:null==i?void 0:i.map(e=>e.id)});if(e.code)throw eq.ZP.error(e.message),Error(e.message);return N.current.add(null===(c=e.data)||void 0===c?void 0:c.message_id),s(t=>t.map(t=>{var n;return t.id===o.id?{...t,status:"sent",id:null===(n=e.data)||void 0===n?void 0:n.message_id}:t})),C(!1),!0}catch(e){return C(!1),s(e=>e.map(e=>e.id===o.id?{...e,status:"failed"}:e)),!1}},[t,m,g]),S=(0,d.useCallback)(()=>{s([]),o(!0)},[]);return(0,d.useEffect)(()=>{S()},[t,S]),(0,d.useEffect)(()=>{t&&0===i.length&&T()},[t,i.length,T]),(0,d.useEffect)(()=>{if(c){let e=setTimeout(()=>{u(!1)},100);return()=>clearTimeout(e)}},[c,i]),{messages:(0,d.useMemo)(()=>{let e=new Set(p.map(e=>e.id));return eJ([...i.filter(t=>!e.has(t.id)),...p])},[i,p]),isStreaming:p.some(e=>e.isStreaming),loading:r,isThinking:b,thinkingList:y,hasMore:a,sendMessage:I,loadMoreMessages:T,clearMessages:S,shouldScrollToBottom:c}}function eJ(e){return e.every((t,n)=>{if(n+1<e.length){var i;return new Date(null==t?void 0:t.created_at).getTime()-new Date(null===(i=e[n+1])||void 0===i?void 0:i.created_at).getTime()<0}return!0})?e:e.sort((e,t)=>new Date(null==e?void 0:e.created_at).getTime()-new Date(null==t?void 0:t.created_at).getTime())}function eV(e){return e?new Date(e).getTime()+500:new Date().toISOString()}function eG(e,t){return e&&t?e?t?new Date(Math.max(new Date(e).getTime(),new Date(t).getTime())).toISOString():new Date(e).toISOString():new Date(t).toISOString():new Date().toISOString()}function eY(){let{currentChatId:e,toggleExpanded:t,isExpanded:n,setOpen:i,setFirstThinking:s,isFirstThinking:r,isMenuOpen:l,setMenuOpen:o}=(0,I.E)(),{messages:c,loading:u,hasMore:m,sendMessage:x,loadMoreMessages:g,shouldScrollToBottom:f,isThinking:h,isStreaming:p,thinkingList:v}=eZ({chatId:e,setFirstThinking:s}),{ua:j}=(0,y.useAgentInfo)(),b=(0,d.useMemo)(()=>(null==j?void 0:j.isMobile)||!n?"mobile":"pc",[null==j?void 0:j.isMobile,n]);(0,d.useEffect)(()=>{(0,D.W)("Chat SSE Connect Init Props",{currentChatId:e})},[e]);let w=async t=>{if(e)try{s(!1),x({...t,chatId:e})}catch(e){}};return(0,a.jsxs)("div",{className:"relative flex h-full w-full flex-1 flex-col",children:[(0,a.jsx)("div",{className:"z-60 absolute left-0 top-0 h-full",children:(0,a.jsx)(F.u,{show:l,enter:"transition-transform duration-300 ease-out",enterFrom:"-translate-x-full",enterTo:"translate-x-0",leave:"transition-transform duration-200 ease-in",leaveFrom:"translate-x-0",leaveTo:"-translate-x-full",className:"h-full",children:(0,a.jsx)(er,{onClose:()=>o(!1),showCloseButton:!0,className:"border-r border-r-[#E0E0E0]"})})}),(0,a.jsx)(ez,{onClose:()=>{i(!1)},isExpanded:n,toggleExpanded:t,onMenuButtonClick:()=>{o(!0)},onClickHumanButton:()=>{w({content:"Talk to the Wayo team"})},talkToHumanButtonDisabled:u||h||r||p}),(0,a.jsx)(eF,{className:(0,L.cn)("pc"===b?"px-[60px]":"px-0"),messages:c,loading:u,hasMore:m,chatId:e,onLoadMore:g,shouldScrollToBottom:f,onSendMessage:x,isThinking:h||r,isStreaming:p,thinkingList:v}),(0,a.jsx)(el.ZP,{onSendMessage:w,className:(0,L.cn)("mb-5","pc"===b?"mx-[80px]":"mx-5"),disabled:h||r||p})]})}var eU=n(65621),eQ=n(67573),eX=n(65880);function eK(e){let{width:t,height:n,size:i,className:s,variant:r="main",shape:l}=e,o=t||i,c=n||i,d=(0,L.cn)("min-w-4",s);return"whale"===l?(0,a.jsxs)("svg",{width:"43",height:"31",viewBox:"0 0 43 31",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.5555 0C4.27814 0 0 4.27814 0 9.5
1555V21.0221C0 26.2995 4.27815 30.5776 9.55551 30.5776H25.7999C26.0125 30.5776 26.2235 30.5707 26.4326 30.557C26.6793 30.5706 26.9459 30.5776 27.2332 30.5776C35.8991 30.5776 39.4421 24.2123 40.1321 21.0259C40.1325 21.0258 40.1328 21.0258 40.1332 21.0258C40.1297 20.9824 40.126 20.9355 40.1216 20.8853C41.2461 20.5628 42.3036 19.7325 42.7226 18.9023C43.2584 17.8405 42.8814 16.5625 42.7226 16.2479C42.2463 16.4052 41.5407 16.67 40.3594 17.8405C40.0059 18.1908 39.7582 18.5603 39.5846 18.9231C39.4007 18.5817 39.1525 18.2396 38.8153 17.923C37.6584 16.8363 37.002 16.622 36.5607 16.4988C36.4428 16.825 36.2053 18.131 36.7724 19.1551C37.2024 19.9316 38.173 20.6651 39.178 20.9296C39.1779 20.962 39.1779 20.9929 39.1779 21.0221L35.3554 21.0221V9.5555C35.3554 4.27815 31.0772 0 25.7999 0H9.5555ZM39.5406 21.0038C39.4678 21.0124 39.3951 21.0186 39.3226 21.0221L39.6955 21.0221C39.644 21.0174 39.5924 21.0113 39.5406 21.0038Z",fill:"white"}),(0,a.jsx)("circle",{cx:"10.0334",cy:"23.411",r:"1.43333",fill:"#1E293B"})]}):(0,a.jsx)(eX.default,{alt:"wayo",width:o,height:c,className:d,objectFit:"cover",src:"white"===r?eU.Z:eQ.Z})}var e$=n(49556),e0=n(87659);let e1=e=>{let{greetingTitleIndex:t,firstName:n}=e;return e6(t,n).greetingTitle},e2=e=>{let{greetingTitleIndex:t,firstName:n}=e;return e6(t,n).greetingDescription},e5="[First name]",e4=[{greetingTitle:"How can I help you today?",greetingDescription:"Tell me what you want to create and Iâll help you bring it to life."},{greetingTitle:"Building something new?",greetingDescription:"Let me know what youâre making and Iâll handle the rest."},{greetingTitle:"Letâs make something extraordinary",greetingDescription:"From ready-to-customize catalog products to fully custom builds, Iâve got you covered."},{greetingTitle:"Letâs make something cool",greetingDescription:"Branded merch or fully custom products â itâs your call."},{greetingTitle:"Not sure where to start?",greetingDescription:"I can help with merch design, product ideas, custom sourcing, or questions about Wayo."}],e3=[...e4,{greetingTitle:"Welcome back, ".concat(e5,"!"),greetingDescription:"Pick up where you left off, or starting making something new."},{greetingTitle:"Good to see you again, ".concat(e5,"?"),greetingDescription:"What would you like to make or customize today?"},{greetingTitle:"Whatâs the plan today, ".concat(e5,"?"),greetingDescription:"I can help you design merch, explore product ideas, or go fully custom."},{greetingTitle:"Ready to make something, ".concat(e5,"?"),greetingDescription:"Tell me what you have in mind, and Iâll guide you through the details."},{greetingTitle:"Planning a product or merch idea, ".concat(e5,"?"),greetingDescription:"I can help you explore ready-to-customize options or source something 100% unique."}],e6=(e,t)=>{if(t){let n=e3[e%e3.length];return{greetingTitle:n.greetingTitle.replace(e5,t),greetingDescription:n.greetingDescription.replace(e5,t)}}return e4[e%e4.length]};function e8(){var e,t,n;let{isExpanded:i,switchToChat:s,setCurrentChatId:r,setFirstThinking:l,setShouldShowLoginTip:o,shouldShowLoginTip:c,triggerLoginTipShake:d,greetingTitleIndex:u}=(0,I.E)(),{ua:m}=(0,y.useAgentInfo)(),{refresh:x,chats:g}=B(),f=(0,v.xu)(),h=!!(null==f?void 0:null===(e=f.user_info)||void 0===e?void 0:e.email),j=(0,a.jsx)(e2,{greetingTitleIndex:u,firstName:null==f?void 0:null===(t=f.user_info)||void 0===t?void 0:t.first_name}),b=(0,a.jsx)(e1,{greetingTitleIndex:u,firstName:null==f?void 0:null===(n=f.user_info)||void 0===n?void 0:n.first_name}),w=async(e,t)=>{if(!h&&g.length>0){c?d():o(!0);return}l(!1);try{let e=await (0,p.P4)({scene:t});(0,D.W)("Prompt Card Create Chat",{apiProps:JSON.stringify({scene:t}),apiResult:JSON.stringify(e)});let n=e.data.id;r(n),l(!0),s(),x()}catch(e){(0,D.W)("Prompt Card Create Chat Error",{apiRes:JSON.stringify(e),apiProps:JSON.stringify({})})}};return(null==m?void 0:m.isMobile)?(0,a.jsxs)(P.kC,{className:"flex-1",flexDirection:"column",justifyContent:"spaceBetween",children:[(0,a.jsxs)("div",{className:"flex w-full flex-shrink flex-col gap-y-5",children:[(0,a.jsx)("div",{className:"h-3 flex-shrink"}),(0,a.jsx)(e7,{}),(0,a.jsx)(eK,{size:32}),(0,a.jsxs)("div",{className:"flex w-full flex-col gap-y-1.5",children:[(0,a.jsx)("div",{className:"shrink-0 text-2xl font-semibold ",children:(0,a.jsx)("p",{className:"leading-7",children:b})}),(0,a.jsx)("div",{className:"min-w-full shrink-0 text-sm font-normal leading-5 text-[rgba(11,11,11,0.66)]",children:(0,a.jsx)("p",{className:"mb-0",children:j})})]})]}),(0,a.jsxs)(P.kC,{flexDirection:"column",justifyContent:"center",className:"gap-y-3",children:[(0,a.jsx)(k,{isExpanded:!1,onPromptClick:w,itemsPerRow:1}),!h&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-x-1 text-[10px] leading-[18px] text-[#0B0B0BA8]",children:[(0,a.jsx)("span",{className:"whitespace-nowrap",children:"By messaging Nory, you agree to our"}),(0,a.jsx)(e0.default,{target:"_blank",className:"whitespace-nowrap text-[#343482] underline",href:"https://thewayo.com/agreements/service",children:"Terms of service"}),(0,a.jsx)("span",{className:"whitespace-nowrap",children:"and"}),(0,a.jsx)(e0.default,{target:"_blank",className:"whitespace-nowrap text-[#343482] underline",href:"https://thewayo.com/agreements/privacy",children:"Privacy Policy"}),(0,a.jsx)("span",{children:"."})]})]})]}):i?(0,a.jsxs)("div",{className:"flex min-h-full w-full max-w-[754px] flex-col justify-between gap-y-10 p-0",children:[(0,a.jsxs)("div",{className:"flex w-full shrink-0 flex-col gap-y-2",children:[(0,a.jsx)(e7,{}),(0,a.jsxs)("div",{className:"flex w-full shrink-0 flex-col gap-y-2",children:[(0,a.jsx)("div",{className:"min-w-full shrink-0 text-[32px] font-semibold leading-[37px]",children:(0,a.jsx)("p",{children:b})}),(0,a.jsx)("div",{className:"m-1 mx-0 shrink-0 text-sm font-normal leading-5 text-[rgba(11,11,11,0.66)]",children:(0,a.jsx)("p",{className:"mb-0 w-[684px]",children:j})})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-y-10",children:[(0,a.jsx)(k,{isExpanded:!0,onPromptClick:w,itemsPerRow:1,
1className:"gap-4"}),!h&&(0,a.jsx)("div",{className:"flex flex-col gap-y-5",children:(0,a.jsxs)(P.kC,{alignItems:"center",justifyContent:"center",className:"text-xs text-[#0B0B0BA8]",children:[(0,a.jsx)("span",{children:"By messaging Nory, you agree to our\xa0"}),(0,a.jsx)(e0.default,{target:"_blank",className:"text-[#343482] underline",href:"https://thewayo.com/agreements/service",children:"Terms of service"}),(0,a.jsx)("span",{children:"\xa0and\xa0"}),(0,a.jsx)(e0.default,{target:"_blank",className:"text-[#343482] underline",href:"https://thewayo.com/agreements/privacy",children:"Privacy Policy"}),"."]})})]})]}):(0,a.jsxs)(P.kC,{className:"w-full flex-1 pt-7",flexDirection:"column",justifyContent:"spaceBetween",children:[(0,a.jsxs)("div",{className:"flex w-full flex-col gap-y-5",children:[(0,a.jsx)(e7,{}),(0,a.jsx)(eK,{size:32}),(0,a.jsxs)("div",{className:"flex w-full flex-col gap-y-1.5",children:[(0,a.jsx)("div",{className:"text-2xl font-semibold ",children:(0,a.jsx)("p",{className:"leading-7",children:b})}),(0,a.jsx)("div",{className:"min-w-full text-sm font-normal leading-5 text-[rgba(11,11,11,0.66)]",children:(0,a.jsx)("p",{className:"mb-0",children:j})})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-y-3",children:[(0,a.jsx)(k,{isExpanded:!1,onPromptClick:w,itemsPerRow:1}),(0,a.jsx)(P.kC,{flexDirection:"column",justifyContent:"center",className:"flex-shrink gap-y-1",children:!h&&(0,a.jsxs)(P.kC,{alignItems:"center",justifyContent:"center",className:"text-[10px] leading-[18px] text-[#0B0B0BA8]",children:[(0,a.jsx)("span",{children:"By messaging Nory, you agree to our\xa0"}),(0,a.jsx)(e0.default,{target:"_blank",className:"text-[#343482] underline",href:"https://thewayo.com/agreements/service",children:"Terms of service"}),(0,a.jsx)("span",{children:"\xa0and\xa0"}),(0,a.jsx)(e0.default,{target:"_blank",className:"text-[#343482] underline",href:"https://thewayo.com/agreements/privacy",children:"Privacy Policy"}),"."]})})]})]})}function e7(e){let{className:t}=e,{access:n}=(0,v.xu)(),{shouldShowLoginTip:i,setShouldShowLoginTip:s,loginTipShakeTrigger:r}=(0,I.E)(),[l,o]=(0,d.useState)(!1),c=(0,d.useRef)(0),u=(0,d.useRef)(!0);return((0,d.useEffect)(()=>{u.current&&(c.current=r,u.current=!1)},[]),(0,d.useEffect)(()=>{if(r>c.current&&i){o(!0);let e=setTimeout(()=>{o(!1)},500);return c.current=r,()=>clearTimeout(e)}},[r,i]),n||!i)?null:(0,a.jsxs)(e$.I,{theme:"info",needClosed:!1,onOpenChange:e=>{e||s(!1)},className:(0,L.cn)(t,l&&"animate-shake"),children:[(0,a.jsx)(f.LoginModalTrigger,{className:"inline-block cursor-pointer underline",children:"Sign in"}),"\xa0",(0,a.jsx)(a.Fragment,{children:"to start a new chat with Nory. You can try it once as a guest."})]})}var e9=n(14571),te=n(58602),tt=n(67732);function tn(e){let{children:t}=e,{isExpanded:n,setExpanded:i}=(0,I.E)(),{ua:s}=(0,y.useAgentInfo)(),{width:r}=(0,M.dz)(),l=!(null==s?void 0:s.isMobile)&&r<1024;return((0,d.useEffect)(()=>{l&&n&&i(!1)},[l,n,i]),null==s?void 0:s.isMobile)?(0,a.jsx)(ts,{children:t}):l?(0,a.jsx)(tl,{hideExpandButton:!0,children:t}):n?(0,a.jsx)(tr,{children:t}):(0,a.jsx)(tl,{hideExpandButton:!1,children:t})}function ti(e){let{children:t}=e,{isOpen:n,setOpen:i}=(0,I.E)(),{ua:s}=(0,y.useAgentInfo)();return(null==s?void 0:s.isMobile)?(0,a.jsx)(F.u.Root,{show:n,as:d.Fragment,children:(0,a.jsx)(te.V,{as:"div",onClose:()=>{i(!1)},className:"relative z-[51]",children:(0,a.jsx)("div",{className:"fixed inset-0 flex h-[100dvh] w-screen flex-col overflow-hidden bg-black/80 will-change-transform",children:(0,a.jsx)(F.u.Child,{as:d.Fragment,enter:"ease-out duration-500",enterFrom:"opacity-0",enterTo:"opacity-100",children:(0,a.jsx)(te.V.Panel,{className:"w-screen bg-white text-black",children:(0,a.jsx)("div",{className:"flex h-[100dvh] flex-col",children:(0,a.jsx)("div",{className:"relative flex flex-1 overflow-auto",children:t})})})})})})}):null}function ts(e){let{children:t}=e,{setOpen:n,viewMode:i,isMenuOpen:s,setMenuOpen:r}=(0,I.E)(),{chats:l}=B(),o=l.length>0;return(0,a.jsxs)(ti,{children:[(0,a.jsxs)("div",{className:"flex w-full flex-1 flex-col bg-[#fff] ".concat("chat"===i?"":"px-5 py-6"),style:"list"===i?{backgroundImage:"url(/images/agent-mobile-bg.svg)",backgroundSize:"cover"}:void 0,onClick:e=>{s&&e.currentTarget.contains(e.target)&&r(!1)},children:["list"===i&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[o?(0,a.jsx)("button",{onClick:()=>r(!0),className:"flex h-6 w-6 items-center justify-center",children:(0,a.jsx)(j.Oq,{})}):(0,a.jsx)("div",{}),(0,a.jsx)("button",{onClick:()=>n(!1),className:"flex h-6 w-6 items-center justify-center",children:(0,a.jsx)(j.Tw,{})})]}),t]}),"list"===i&&(0,a.jsx)("div",{className:"absolute left-0 top-0 h-full",children:(0,a.jsx)(F.u,{show:s,enter:"transition-transform duration-300 ease-out",enterFrom:"-translate-x-full",enterTo:"translate-x-0",leave:"transition-transform duration-200 ease-in",leaveFrom:"translate-x-0",leaveTo:"-translate-x-full",className:"h-full",children:(0,a.jsx)(er,{onClose:()=>r(!1),showCloseButton:!1})})})]})}function tr(e){let{children:t}=e,{isOpen:n,setOpen:i,toggleExpanded:s,viewMode:r,isMenuOpen:l,setMenuOpen:o}
1=(0,I.E)(),{showFlow:c}=(0,e9.V)();return(0,a.jsx)(P.u_,{open:n,onClose:c?()=>{}:()=>i(!1),containerClassName:"w-[1400px]",className:"!m-0 rounded-[20px] !p-0",unmount:!1,enableExternalClose:!0,children:(0,a.jsxs)("div",{"data-nory-panel":"",className:"flex h-[min(929px,100vh-80px)] justify-between rounded-[20px] bg-[#fff]",onClick:e=>{l&&e.currentTarget.contains(e.target)&&o(!1)},children:["list"===r&&(0,a.jsx)(er,{onClose:()=>o(!1),showCloseButton:!1,className:"flex-none"}),(0,a.jsxs)("div",{className:"flex max-h-full w-full flex-col ".concat("chat"===r?"":"p-10 pb-20"),style:"list"===r?{backgroundImage:"url(/images/agent-pc-bg.svg)",backgroundSize:"cover",backgroundPosition:"-1px 0"}:void 0,children:["list"===r&&(0,a.jsx)("div",{className:"mb-[75px] flex items-start justify-end",children:(0,a.jsxs)("div",{className:"flex items-center gap-x-4",children:[(0,a.jsx)("button",{onClick:s,className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-[#EDEDED]",children:(0,a.jsx)(j.oN,{})}),(0,a.jsx)("button",{onClick:()=>i(!1),className:"flex h-10 w-10 items-center justify-center rounded-lg hover:bg-[#EDEDED]",children:(0,a.jsx)(j.vE,{})})]})}),(0,a.jsx)("div",{className:"flex max-h-full w-full flex-1 justify-center",children:t})]})]})})}function tl(e){let{children:t,hideExpandButton:n=!1}=e,{isOpen:i,setOpen:s,toggleExpanded:r,viewMode:l,isMenuOpen:o,setMenuOpen:c}=(0,I.E)(),{chats:u}=B(),m=u.length>0,{collapsedPanelPosition:x}=(0,tt.p1)(),g=e=>void 0!==e?"".concat(e,"px"):void 0;return(0,d.useEffect)(()=>{let e=e=>{"Escape"===e.key&&i&&s(!1)};return i&&document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[i,s]),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(F.u,{show:i,enter:"transition-all duration-300 ease-out",enterFrom:"opacity-0 translate-y-4 scale-95",enterTo:"opacity-100 translate-y-0 scale-100",leave:"transition-all duration-200 ease-in",leaveFrom:"opacity-100 translate-y-0 scale-100",leaveTo:"opacity-0 translate-y-4 scale-95",style:{position:"fixed",zIndex:50,bottom:g(x.bottom),right:g(x.right),left:g(x.left),top:g(x.top)},children:(0,a.jsxs)("div",{"data-nory-panel":"",className:"relative h-[min(738px,100vh-60px)] w-[420px] overflow-hidden rounded-xl bg-[#fff] shadow-lg",onClick:e=>{o&&e.currentTarget.contains(e.target)&&c(!1)},children:[(0,a.jsxs)("div",{className:"flex h-full flex-col justify-between ".concat("chat"===l?"h-full":"px-5 py-6"),style:"list"===l?{backgroundImage:"url(/images/agent-mobile-bg.svg)",backgroundSize:"cover"}:void 0,children:["list"===l&&(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[m?(0,a.jsx)("button",{className:"flex h-6 w-6 items-center justify-center rounded-md hover:bg-[#EDEDED]",onClick:()=>c(!0),children:(0,a.jsx)(j.Oq,{})}):(0,a.jsx)("div",{}),(0,a.jsxs)("div",{className:"flex items-center gap-x-4",children:[!n&&(0,a.jsx)("button",{className:"flex h-6 w-6 items-center justify-center rounded-md hover:bg-[#EDEDED]",onClick:r,children:(0,a.jsx)(j.PS,{})}),(0,a.jsx)("button",{className:"flex h-6 w-6 items-center justify-center rounded-md hover:bg-[#EDEDED]",onClick:()=>s(!1),children:(0,a.jsx)(j.Tw,{})})]})]}),(0,a.jsx)("div",{className:"flex min-h-0 w-full flex-1 justify-center",children:t})]}),"list"===l&&(0,a.jsx)("div",{className:"absolute left-0 top-0 h-full",children:(0,a.jsx)(F.u,{show:o,enter:"transition-transform duration-300 ease-out",enterFrom:"-translate-x-full",enterTo:"translate-x-0",leave:"transition-transform duration-200 ease-in",leaveFrom:"translate-x-0",leaveTo:"-translate-x-full",className:"h-full",children:(0,a.jsx)(er,{onClose:()=>c(!1)})})})]})})})}function ta(){let e=(0,I.E)(e=>e.viewMode),t=(0,I.E)(e=>e.dispatchAgentEvent),n=(0,I.E)(e=>e.isLoginModalOpen),i=(0,I.E)(e=>e.postLoginOpenChatId),s=(0,I.E)(e=>e.closeLoginModal),r=(0,h.useSearchParams)(),l=r.get("agent"),o=r.get("chat_id"),c=r.get("chat_view");(0,d.useEffect)(()=>{if("auto"===l){t({type:"OpenAgent"});return}o&&t({type:"OpenChatById",chatId:o,chatView:"expanded"===c?"expanded":"widget"})},[l,o,c,t]);let{sendMessage:u}=eZ({chatId:null});return!function(e){var t;let{sendMessage:n}=e,{clearPendingAgentEvent:i,setOpen:s,setExpanded:r,setMenuOpen:l,setCurrentChatId:a,switchToChat:o,switchToList:c,setFirstThinking:u,openLoginModal:m,pendingAgentEvent:x}=(0,I.E)(),{chats:g,refresh:f,isEmpty:h,isLoading:y}=B(),j=(0,v.xu)(),b=!!(null==j?void 0:null===(t=j.user_info)||void 0===t?void 0:t.email),w=(0,d.useRef)(!1),k=(0,d.useCallback)(e=>{var t;return(null===(t=I.E.getState().pendingAgentEvent)||void 0===t?void 0:t.eventId)!==e},[]),N=(0,d.useCallback)(e=>{s(!0),l(!1),"expanded"===e.chatView?r(!0):"widget"===e.chatView&&r(!1)},[r,l,s]),A=(0,d.useCallback)(async e=>{if(console.log("[AGENT_FLOW] event:start",{eventId:e.eventId,type:e.type,scene:e.scene,chatId:e.chatId}),"OpenChatById"===e.type&&!b){m(e.chatId);return}if(N(e),"OpenChatById"===e.type){e.chatId&&(a(e.chatId),o());return}if("OpenAgent"===e.type){if(!b&&!h){a(g[0].id),o();return}if(h){u(!1);let t=await (0,p.P4)({scene:"source_product"});if(k(e.eventId))return;a(t.data.id),u(!0),o(),f()}else c();return}if("OpenWithMessage"===e.type){var t,i;let s=null===(t=e.message)||void 0===t?void 0:t.trim();if(!s)return;u(!1);let r=b?void 0:null===(i=g[0])||void 0===i?void 0:i.id;if(!r){let t=await (0,p.P4)();if(k(e.eventId))return;r=t.data.id}let l=await n({content:s,chatId:r});if(k(e.eventId))return;a(r),u(l),o(),f();return}if("OpenWithScene"===e.type){let t=function(e){let{event:t,isLogin:n,chats:i}=e;return"OpenWithScene"===t.type&&t.scene?!n&&i.length>0?{type:"SendToFirstAnonymousChat",chatId:i[0].id,scene:t.scene}:{type:"CreateChatFromScene",scene:t.scene}:null}({event:e,isLogin:b,chats:g});if(!t)return;if("SendToFirstAnonymousChat"===t.type){if(a(t.chatId),o(),k(e.eventId))return;let i=T[t.scene];if(!i){console.log("[AGENT_FLOW] event:empty-prompt",{eventId:e.eventId,scene:t.scene,policy:t.type});return}await n({content:"<Ghost>".concat(i,"</Ghost>"),chatId:t.chatId,isStrict:!1});return}if("CreateChatFromScene"===t.type){u(!1);let n=await (0,p.P4)({scene:t.scene});if(k(e.eventId))return;a(n.data.id),u(!0),o(),f()}return}},[h,g,b,k,N,f,n,a,u,m,o,c]);(0,d.useEffect)(()=>{x&&!w.current&&("OpenWithMessage"!==x.type||b||!y)&&(async()=>{w.current=!0;let e=I.E.getState().pendingAgentEvent;for(;e;){let n=Date.now(),s=!0;try{await A(e)}catch(t){s=!1,console.log("[AGENT_FLOW] event:error",{eventId:e.eventId,type:e.type,error:t})}finally{var t;(null===(t=I.E.getState().pendingAgentEvent)||void 0===t?void 0:t.eventId)===e.eventId&&i(e.eventId),console.log("[AGENT_FLOW] event:done",{eventId:e.eventId,type:e.type,result:s?"success":"failed",latencyMs:Date.now()-n})}e=I.E.getState().pendingAgentEvent}w.current=!1})()},[i,y,b,x,A])}({sendMessage:u}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tn,{children:"chat"===e?(0,a.jsx)(eY,{}):(0,a.jsx)(e8,{})}),(0,a.jsx)(f.LoginModal,{visible:n,needCloseIcon:!0,toggleModal:s,onLoginSuccess:()=>{i&&t({type:"OpenChatById",chatId:i,chatView:"expanded"===c?"expanded":"widget"}),s()}})]})}function to(){return!function(){let e=(0,c.jD)();return(0,d.useMemo)(()=>!e||!u.some(t=>t.test(e)),[e])}()?null:(0,a.jsx)(tc,{})}function tc(){let{data:e}=(0,m.R7)(),{data:t}=(0,x.l)();
1return(0,a.jsx)(tt.AP,{children:(0,a.jsxs)(o.CategoryProvider,{data:(null==e?void 0:e.data)||[],collectionData:t||{data:[],key:"",id:""},children:[(0,a.jsx)(g.e,{}),(0,a.jsx)(ta,{})]})})}},14571:function(e,t,n){"use strict";n.d(t,{QuestionnaireProvider:function(){return l},V:function(){return a}});var i=n(27573),s=n(7653);let r=(0,s.createContext)(void 0);function l(e){let{children:t}=e,[n,l]=(0,s.useState)(!1),[a,o]=(0,s.useState)(!1);return(0,i.jsx)(r.Provider,{value:{showFlow:n,setShowFlow:l,isQuestionnaireOpen:n,isQuestionnaireResolved:a,setIsQuestionnaireResolved:o},children:t})}function a(){let e=(0,s.useContext)(r);if(!e)throw Error("useQuestionnaireContext must be used within a QuestionnaireProvider");return e}},38260:function(e,t,n){"use strict";n.d(t,{R7:function(){return r},xu:function(){return l}});var i=n(35194),s=n(46575);function r(){return(0,s.ZP)("GLOBAL_CATEGORY_TRY",i.EI)}function l(){return(0,s.ZP)("GLOBAL_MATERIAL_TRY",i.kY)}},40164:function(e,t,n){"use strict";n.d(t,{l:function(){return a}});var i=n(47409),s=n(16287);let r=e=>{let t="/client/operations/homepage_config/get?".concat((0,i.FJ)(e));return(0,s.G0)(t).then(e=>e.data)};var l=n(46575);function a(){return(0,l.ZP)("SWR_GET_OPERATION_PORTAL_COLLECTIONS",()=>r({key:"portal_collections"}))}},86545:function(){},65621:function(e,t){"use strict";t.Z={src:"/_next/static/media/wayo-icon-white.d77dab6e.png",height:501,width:500,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAP1BMVEVMaXE25MMm4r3///////////////////////8k5r////////////8k4b3///////868c0z4b/8/f004b////+Nhb8+AAAAFHRSTlMAD4Um0uE+AysyEWaRI1avzritxKsnf8IAAAAJcEhZcwAACxMAAAsTAQCanBgAAAA+SURBVHicFctJEsAgCADBQUXAmJiF/7815a0vDYCIAOOd5XsCVl5R7qDmAVFOfKPPgTXtXdXAW2arO5u7wQ8+XAGzNTrofQAAAABJRU5ErkJggg==",blurWidth:8,blurHeight:8}},67573:function(e,t){"use strict";t.Z={src:"/_next/static/media/wayo-icon.13f26758.png",height:500,width:500,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAMAAADz0U65AAAAOVBMVEVMaXEmIJsz68QlHZk16MUlHJonIJwjHpQlHJcmIJwy4L8sIZAiIpQz8MEy9sQz48Iz7sI28c0oIqJ9Omq2AAAAEnRSTlMAxxiYJqwmCGj3xhc8Nn6Ce83ANRxGAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAOklEQVR4nCWJWw7AIAjAKoKAe7h5/8MuZP1pkwK4qAKj9XtOhZanrFcZO+B65I8wrxWxDTgsszuFlz4yPgFcYbSomQAAAABJRU5ErkJggg==",blurWidth:8,blurHeight:8}}}]);
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.