(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4821],{34821:function(e,a,s){"use strict";s.r(a),s.d(a,{SearchChatPage:function(){return u}});var t=s(57437),n=s(2265),i=s(68454),r=s(6031),l=s.n(r),c=s(59208),m=s(35499),d=s(38669),h=s(56073),o=s(13894),k=s(75591),_=s(44922);function u(){let e=(0,c.s0)(),a=(0,_.aK)(),s=a.sessions,r=a.selectSession,[u,f]=(0,n.useState)([]),x=(0,n.useRef)(""),g=(0,n.useRef)(null),j=(0,n.useCallback)(e=>{let a=e.toLowerCase(),t=[];return s.forEach((e,s)=>{let n=[];e.messages.forEach(e=>{let s=e.content;if(!s.toLowerCase||""===s)return;let t=s.toLowerCase(),i=t.indexOf(a);for(;-1!==i;){let e=Math.max(0,i-35),r=Math.min(s.length,i+a.length+35);n.push(s.substring(e,r)),i=t.indexOf(a,i+a.length)}}),n.length>0&&t.push({id:s,name:e.topic,content:n.join("... ")})}),t.sort((e,a)=>a.content.length-e.content.length),t},[]);return(0,n.useEffect)(()=>{let e=setInterval(()=>{if(g.current){let e=g.current.value;e!==x.current&&(e.length>0&&f(j(e)),x.current=e)}},1e3);return()=>clearInterval(e)},[j]),(0,t.jsx)(i.S,{children:(0,t.jsxs)("div",{className:l()["mask-page"],children:[(0,t.jsxs)("div",{className:"window-header",children:[(0,t.jsxs)("div",{className:"window-header-title",children:[(0,t.jsx)("div",{className:"window-header-main-title",children:o.ZP.SearchChat.Page.Title}),(0,t.jsx)("div",{className:"window-header-submai-title",children:o.ZP.SearchChat.Page.SubTitle(u.length)})]}),(0,t.jsx)("div",{className:"window-actions",children:(0,t.jsx)("div",{className:"window-action-button",children:(0,t.jsx)(m.h,{icon:(0,t.jsx)(d.Z,{}),bordered:!0,onClick:()=>e(-1)})})})]}),(0,t.jsxs)("div",{className:l()["mask-page-body"],children:[(0,t.jsx)("div",{className:l()["mask-filter"],children:(0,t.jsx)("input",{type:"text",className:l()["search-bar"],placeholder:o.ZP.SearchChat.Page.Search,autoFocus:!0,ref:g,onKeyDown:e=>{if("Enter"===e.key){e.preventDefault();let a=e.currentTarget.value;a.length>0&&f(j(a))}}})}),(0,t.jsx)("div",{children:u.map(a=>(0,t.jsxs)("div",{className:l()["mask-item"],onClick:()=>{e(k.y$.Chat),r(a.id)},style:{cursor:"pointer"},children:[(0,t.jsx)("div",{className:l()["mask-header"],children:(0,t.jsxs)("div",{className:l()["mask-title"],children:[(0,t.jsx)("div",{className:l()["mask-name"],children:a.name}),a.content.slice(0,70)]})}),(0,t.jsx)("div",{className:l()["mask-actions"],children:(0,t.jsx)(m.h,{icon:(0,t.jsx)(h.Z,{}),text:o.ZP.SearchChat.Item.View})})]},a.id))})]})]})})}},6031:function(e){e.exports={"mask-page":"mask_mask-page__ou14k","mask-page-body":"mask_mask-page-body__kBXsJ","mask-filter":"mask_mask-filter__OdpU3","slide-in":"mask_slide-in__unpXH","search-bar":"mask_search-bar__7_Msn","mask-filter-lang":"mask_mask-filter-lang__mRxyv","mask-create":"mask_mask-create__BjAzk","mask-item":"mask_mask-item__dinia","mask-header":"mask_mask-header__RXJXI","mask-icon":"mask_mask-icon__wO1ER","mask-title":"mask_mask-title__IDEbR","mask-name":"mask_mask-name__77Rjh","mask-info":"mask_mask-info__2gtiu","mask-actions":"mask_mask-actions__rsWn_","slide-in-from-top":"mask_slide-in-from-top__DOEYB"}}}]);