1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6670],{10239:(e,t,a)=>{"use strict";a.d(t,{A:()=>r});let r=(0,a(17963).A)("trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]])},37900:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>V});var r=a(37876),s=a(4913),l=a(14232),n=a(68106),i=a(89099),c=a(26573),o=a(78625),d=a(42298),h=a(26381),u=a(97052),x=a(72416),g=a(74605),m=a(86935),p=a(59435),b=a(28249),f=a(10239),y=a(8894),w=a(76928),v=a(65734);let j=e=>{let{isOpen:t,onClose:a,onConfirm:s,characterCount:l}=e;return(0,r.jsxs)("div",{className:"fixed inset-0 z-50 ".concat(t?"block":"hidden"),onClick:a,children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 backdrop-blur-sm"}),(0,r.jsx)("div",{className:"flex justify-center items-center min-h-screen",onClick:e=>e.stopPropagation(),children:(0,r.jsx)(v.lG,{open:t,children:(0,r.jsxs)("div",{className:"relative z-50 bg-gray-800 shadow-lg mx-auto p-6 rounded-lg max-w-sm",children:[(0,r.jsx)("button",{onClick:a,className:"top-2 right-2 absolute text-gray-400 hover:text-white transition","aria-label":"Close",children:(0,r.jsx)(b.A,{size:18})}),(0,r.jsx)("h2",{className:"mb-2 font-semibold text-lg text-white",children:"Are you sure?"}),(0,r.jsxs)("p",{className:"mb-4 text-gray-400 text-sm",children:["This permanently deletes every chat you have with ",l," character",l>1?"s":"",", including saved ones. This cannot be undone!"]}),(0,r.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,r.jsx)(d.$,{onClick:a,className:"bg-gray-600 hover:bg-gray-500 shadow-lg px-4 py-2 rounded-full text-white",children:"Cancel"}),(0,r.jsx)(d.$,{onClick:s,className:"bg-red-600 hover:bg-red-500 shadow-lg px-4 py-2 rounded-full text-white",children:"Confirm"})]})]})})})]})};var C=a(48396),N=a(42595),k=a(77328),A=a.n(k),S=a(5309),I=a(67514),_=a(38745),R=a(93536),E=a(65070),P=a(27025);function T(e){let{name:t,chatCount:a,onConfirm:s,className:l}=e,n=a>1?{title:"Delete your chats with ".concat(t,"?"),description:"This deletes all ".concat(a," of your chats with ").concat(t,", including saved ones. It cannot be undone."),confirm:"Delete chats"}:{title:"Delete your chat with ".concat(t,"?"),description:"This deletes your chat with ".concat(t," and its messages. It cannot be undone."),confirm:"Delete chat"};return(0,r.jsx)(E.m,{onConfirm:s,onCancel:()=>{},show:!0,title:n.title,description:n.description,confirmText:n.confirm,confirmClassName:"bg-red-600 text-white hover:bg-red-500",cancelText:"Cancel",children:(0,r.jsx)("button",{type:"button","aria-label":"".concat(n.confirm," with ").concat(t),className:(0,P.cn)("group top-1 right-1 z-40 absolute flex justify-center items-center w-11 h-11 focus-visible:outline-none",l),children:(0,r.jsx)("span",{className:"flex justify-center items-center bg-black/55 group-hover:bg-red-600 backdrop-blur-sm border border-white/20 group-hover:border-transparent rounded-full group-focus-visible:ring-2 group-focus-visible:ring-ring w-9 h-9 text-white transition-all group-active:scale-90",children:(0,r.jsx)(R.A,{className:"w-4 h-4","aria-hidden":"true"})})})})}let V=function(){var e,t;let a=(0,i.useRouter)(),v=(null==(e=a.query)?void 0:e.category)||"Recent",k=(0,l.useContext)(c.F),R=null==k?void 0:k.user,E=parseInt((null==(t=a.query)?void 0:t.page)||"1"),{search:P,setSearch:V,debouncedSearch:z}=(0,_.A)(),[q,F]=(0,l.useState)(25),[D,L]=(0,l.useState)(!1),M=(0,l.useRef)(!1),{toast:B}=(0,o.dj)(),[O,U]=(0,l.useState)(!1),[$,G]=(0,l.useState)([]),[X,H]=(0,l.useState)(!1),[J,W]=(0,l.useState)([]),{characters:K,data:Q,isLoading:Y,fetchNextPage:Z,fetchPreviousPage:ee,hasNextPage:et,hasPreviousPage:ea,isFetchingNextPage:er,isFetchingPreviousPage:es,refetch:el}=(0,S.IT)({page:E,limit:q,search:z,sortBy:v},a.isReady&&!!R),en=K.filter(e=>!J.includes(e.id));(0,l.useEffect)(()=>{if(!(null==Q?void 0:Q.pages)||0===Q.pages.length)return;let e=Math.max(...Q.pages.map(e=>e.currentPage));e!==parseInt(a.query.page||"1")&&a.isReady&&a.replace({pathname:a.pathname,query:{...a.query,page:e}},void 0,{scroll:!1,shallow:!0})},[null==Q?void 0:Q.pages,a.isReady]),(0,l.useEffect)(()=>
1{document.title="Recent Chats | Crushchat",L(!0)},[]),(0,l.useEffect)(()=>{er||es||(M.current=!1)},[er,es]);let ei=(0,l.useCallback)(()=>{M.current||et&&!er&&(M.current=!0,Z())},[et,er,Z]),ec=(0,l.useCallback)(()=>{M.current||ea&&!es&&(M.current=!0,ee())},[ea,es,ee]),eo=()=>{U(!O),G([]),X&&H(!1)},ed=e=>{G(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},eh=async()=>{H(!1);try{await Promise.all($.map(e=>(window.localStorage.removeItem("messages-"+e),s.pB.delete("/chat/delete?characterId=".concat(e))))),U(!1),G([]),el(),B({title:"Success",description:"Selected chats have been deleted."})}catch(e){B({title:"Error",description:"Failed to delete chats."})}},eu=async(e,t,a)=>{W(t=>[...t,e]);try{window.localStorage.removeItem("messages-"+e),await s.pB.delete("/chat/delete?characterId=".concat(e)),await el(),B({title:a>1?"Chats deleted":"Chat deleted",description:"".concat(t," was removed from your recent chats.")})}catch(t){W(t=>t.filter(t=>t!==e)),B({title:"Error",description:"Failed to delete chats."})}},ex=e=>{var t;return O?null:(0,r.jsx)(T,{name:e.name,chatCount:null!=(t=e.userChatCount)?t:1,onConfirm:()=>{var t;return eu(e.id,e.name,null!=(t=e.userChatCount)?t:1)}})};function eg(e,t){e&&a.push({pathname:a.pathname,query:(0,_.R)({...a.query,category:t})})}return(0,r.jsxs)(u.A,{children:[(0,r.jsxs)(A(),{children:[(0,r.jsx)("title",{children:"Recent Chats | Crushchat"}),(0,r.jsx)("meta",{name:"description",content:"All your recent chats in one place. Chat with your favorite characters and create new ones. CrushChat is the place to go for Uncensored AI Chats, Image generation and Character Creation."}),(0,r.jsx)("meta",{name:"robots",content:"index, follow"}),(0,r.jsx)("meta",{property:"og:title",content:"Recent Chats | Crushchat"}),(0,r.jsx)("meta",{property:"og:description",content:"All your recent chats in one place. Chat with your favorite characters and create new ones. CrushChat is the place to go for Uncensored AI Chats, Image generation and Character Creation."})]}),(0,r.jsxs)(n.A,{className:"lg:px-8 py-4 w-full transition-all duration-300",children:[(0,r.jsx)(h.R,{}),R&&(0,r.jsxs)("div",{className:"flex items-center gap-4 py-4 flex-wrap-reverse xl:flex-wrap flex-row-reverse xl:flex-row",children:[(0,r.jsx)(C.Ay,{toggles:[(0,r.jsx)(C.Gt,{category:v,pressChange:eg},"Recent"),(0,r.jsx)(C.JO,{category:v,pressChange:eg},"New"),(0,r.jsx)(C.iW,{category:v,pressChange:eg},"Top"),(0,r.jsx)(C.q_,{category:v,pressChange:eg},"Updated")]}),(0,r.jsxs)("div",{className:"relative mx-auto w-full max-w-xl min-w-52 md:min-w-96",children:[(0,r.jsx)(p.A,{className:"top-1/2 left-3 absolute w-4 h-4 text-gray-500 -translate-y-1/2 pointer-events-none","aria-hidden":"true"}),(0,r.jsx)(I.p,{type:"text",id:"recent-search",name:"recentSearch",variant:"glass",placeholder:"Search your recent chats","aria-label":"Search your recent chats",value:P,onChange:e=>V(e.target.value),className:"pr-11 pl-9 w-full h-11"}),P.length>0&&(0,r.jsx)("button",{type:"button","aria-label":"Clear search",onClick:()=>V(""),className:"top-1/2 right-1 absolute flex justify-center items-center hover:bg-white/10 rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-500 focus-visible:ring-offset-2 focus-visible:ring-offset-background w-9 h-9 text-gray-400 hover:text-white -translate-y-1/2 active:scale-90 transition-all",children:(0,r.jsx)(b.A,{className:"w-4 h-4","aria-hidden":"true"})})]}),(0,r.jsx)(d.$,{onClick:eo,className:"flex items-center gap-2 bg-gray-700 hover:bg-gray-600 ml-auto px-3 sm:px-4 py-2 sm:py-2 rounded-md text-sm text-white sm:text-base transition-all",children:O?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.A,{size:16}),"Cancel"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f.A,{size:16}),"Clear Chats"]})}),O&&R&&(0,r.jsx)(d.$,{onClick:()=>{$.length===en.length?G([]):G(en.map(e=>e.id))},className:"bg-gray-500 hover:bg-gray-400 px-3 sm:px-4 py-2 sm:py-2 rounded-md text-sm text-white sm:text-base transition-all",children:$.length===en.length?"Deselect All":"Select All"})]}),O&&$.length>0&&(0,r.jsxs)("div",{className:"right-5 bottom-20 sm:bottom-24 md:bottom-28 fixed flex items-center space-x-4 border-gray-700 bg-gray-950 shadow-xl p-3 border rounded-lg",style:{zIndex:100},children:[(0,r.jsx)("button",{onClick:eo,className:"flex justify-center items-center bg-gray-600 hover:bg-gray-500 shadow-lg p-3 rounded-full text-white","aria-label":"Cancel Selection",children:(0,r.jsx)(b.A,{size:20})}),(0,r.jsxs)("button",{onClick:()=>{H(!0)},className:"relative flex justify-center items-center bg-red-600 hover:bg-red-500 shadow-lg p-3 rounded-full text-white","aria-label":"Delete Selected",children:[(0,r.jsx)(f.A,{size:20}),(0,r.jsx)("span",{className:"-top-2 -right-2 absolute bg-gray-900 px-2 py-0.5 border border-red-500 rounded-full font-semibold text-white text-xs",children:$.length})]})]}),(0,r.jsx)(j,{isOpen:X,onClose:()=>H(!1),onConfirm:eh,characterCount:$.length}),D&&Y&&(null==en?void 0:en.length)===0&&(0,r.jsx)("span",{children:"Loading..."}),!Y&&!R&&(0,r.jsx)("div",{className:"flex flex-col items-center justify-center h-full w-full text-center py-10",children:(0,r.jsx)("h1",{className:"text-2xl font-bold text-gray-200 mb-4",children:"Please login to view your recent chats."})}),ea&&(0,r.jsx)("div",{className:"flex justify-center mb-4",children:(0,r.jsx)("button",{onClick:ec,disabled:es,className:"px-4 py-2 bg-pink-600 hover:bg-pink-700 text-white rounded-lg disabled:opacity-50 disabled:cursor-not-allowed",children:es?"Loading...":"Load Previous"})}),(0,r.jsxs)(g.Ay,{className:(null==k?void 0:k.cardView)==="Portrait View"?g.kk:void 0,children:[en.map(e=>(0,r.jsxs)("div",{className:"relative w-full",children:[((null==k?void 0:k.cardView)==="Portrait View"||(null==k?void 0:k.cardView)==="Expanded View")&&ex(e),(null==k?void 0:k.cardView)==="Expanded View"?(0,r.jsx)(x.fB,{character:e,globalContext:k,toast:B,isLast:e.id===en[en.length-1].id,newPage:ei,loading:er,clearChatsMode:O,handleCharacterSelect:ed,isSelected:$.includes(e.id),reserveTopRight:!0}):(0,r.jsxs)(r.Fragment,{children:[O&&(0,r.jsx)("div",{className:"top-2 right-2 absolute cursor-pointer z-40",onClick:()=>ed(e.id),children:$.includes(e.id)?(0,r.jsx)(y.A,{className:"w-6 h-6 text-white"}):(0,r.jsx)(w.A,{className:"w-6 h-6 text-white"})}),(null==k?void 0:k.cardView)==="Portrait View"?(0,r.jsx)(m.A,{character:e,globalContext:k,user:{name:e.user.name||"",id:e.user.id,tier:e.user.tier},toast:B}):(0,r.jsx)(N.o_,{character:e,globalContext:k,handleFavorite:()=>{},handleUpvote:()=>{},artAction:ex(e),user:{name:e.user.name||"",id:e.user.id,tier:e.user.tier},toast:B})]})]},e.id)),en.length>0&&et&&!er&&(0,r.jsx)(x.CT,{newPage:ei,loading:er},"load-more")]})]})]})}},86479:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/characters/recent",function(){return a(37900)}])}},e=>{e.O(0,[2652,4881,2416,2595,6935,4602,636,6593,8792],()=>e(e.s=86479)),_N_E=e.O()}]);
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.