import{c as A,r as l,j as e}from"./index-x-IbNx01.js";import{A as H,m as r,X as v,L as R}from"./AppContent-OZvJ19iO.js";import{S as w}from"./search-CiMed_5s.js";import{A as g}from"./arrow-right-BIb2kQ4e.js";import{F as k}from"./file-text-DT8Zjg4-.js";import{B as $}from"./book-open-DNKNWzUh.js";/**
 * @license lucide-react v0.487.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const E=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],L=A("panels-top-left",E);/**
 * @license lucide-react v0.487.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const D=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],q=A("wrench",D);function K({isOpen:i,onClose:n,onNavigate:S}){const[c,m]=l.useState(""),[a,o]=l.useState({blogPosts:[],sexualHealthArticles:[],pages:[]}),[b,j]=l.useState(!1),[y,x]=l.useState(!1),h=l.useRef(null),u=l.useRef(null);l.useEffect(()=>{i&&h.current&&setTimeout(()=>h.current?.focus(),100)},[i]),l.useEffect(()=>{i||(m(""),o({blogPosts:[],sexualHealthArticles:[],pages:[]}),x(!1))},[i]);const C=l.useCallback(async t=>{if(t.trim().length<2){o({blogPosts:[],sexualHealthArticles:[],pages:[]}),x(!1);return}j(!0),x(!0);try{const s=await fetch(`/api/content/search/public?q=${encodeURIComponent(t)}`);if(s.ok){const _=await s.json();o(_.data)}}catch(s){console.error("Search error:",s)}finally{j(!1)}},[]),T=t=>{const s=t.target.value;m(s),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{C(s)},300)},p=t=>{let s="";t.type==="blog"?s=`blog/${t.slug}`:t.type==="sexual-health"?s=`sexual-health/${t.slug}`:s=t.slug,S(s),n()},P=t=>{t.key==="Escape"&&n()},d=a.blogPosts.length+a.sexualHealthArticles.length+a.pages.length,f=t=>{switch(t){case"blog":return e.jsx(k,{className:"w-4 h-4 text-[#A80000]"});case"sexual-health":return e.jsx($,{className:"w-4 h-4 text-pink-500"});case"page":return e.jsx(L,{className:"w-4 h-4 text-white/60"});default:return e.jsx(k,{className:"w-4 h-4 text-white/60"})}},N=t=>{switch(t){case"blog":return"The Naked Truth";case"sexual-health":return"Sexual Health";case"page":return"Page";default:return"Content"}};return e.jsx(H,{children:i&&e.jsxs(e.Fragment,{children:[e.jsx(r.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:n,className:"fixed inset-0 bg-black/80 backdrop-blur-xl z-[9999]"}),e.jsxs(r.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{type:"spring",damping:25,stiffness:300},className:"fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-[94%] sm:w-[90%] md:w-[85%] lg:w-[80%] max-w-6xl max-h-[85vh] bg-[#0D0D0D] border border-white/20 rounded-3xl z-[10000] flex flex-col shadow-[0_0_80px_rgba(160,0,8,0.4)] overflow-hidden",onKeyDown:P,children:[e.jsxs("div",{className:"flex-shrink-0 backdrop-blur-xl bg-gradient-to-r from-[#A00008]/30 to-pink-600/30 border-b border-white/20 p-5 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-white text-xl md:text-2xl font-medium",children:"Search"}),e.jsx("p",{className:"text-white/60 text-xs md:text-sm",children:"Find articles, pages, and more"})]}),e.jsx("button",{onClick:n,className:"w-9 h-9 md:w-10 md:h-10 rounded-full backdrop-blur-xl bg-white/10 border border-white/20 flex items-center justify-center hover:bg-white/20 transition-all",children:e.jsx(v,{className:"w-4 h-4 md:w-5 md:h-5 text-white"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(w,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-white/50"}),e.jsx("input",{ref:h,type:"text",value:c,onChange:T,placeholder:"Search articles, pages...",className:"w-full bg-white/5 border border-white/10 rounded-xl py-3 pl-12 pr-12 text-white placeholder:text-white/40 focus:outline-none focus:border-white/30 focus:bg-white/10 transition-all text-base",autoComplete:"off"}),b?e.jsx(R,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-[#A80000] animate-spin"}):c&&e.jsx("button",{onClick:()=>{m(""),o({blogPosts:[],sexualHealthArticles:[],pages:[]}),x(!1),h.current?.focus()},className:"absolute right-4 top-1/2 -translate-y-1/2 p-1 hover:bg-white/10 rounded-full transition-colors",children:e.jsx(v,{className:"w-4 h-4 text-white/50 hover:text-white transition-colors"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{scrollbarWidth:"thin",scrollbarColor:"rgba(255,255,255,0.1) transparent"},children:[!y&&!c&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[200px] text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx(w,{className:"w-8 h-8 text-white/30"})}),e.jsx("p",{className:"text-white/70 text-lg font-medium mb-2",children:"Start searching"}),e.jsx("p",{className:"text-white/40 text-sm max-w-[200px]",children:"Type to find articles and pages"})]}),y&&!b&&d===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center min-h-[200px] text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-white/5 flex items-center justify-center mb-4",children:e.jsx(w,{className:"w-8 h-8 text-white/30"})}),e.jsx("p",{className:"text-white/70 text-lg font-medium mb-2",children:"No results found"}),e.jsxs("p",{className:"text-white/40 text-sm max-w-[250px]",children:['Try different keywords for "',c,'"']})]}),a.pages.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-xs font-medium text-white/50 uppercase tracking-wider mb-3",children:"Pages"}),e.jsx("div",{className:"space-y-2",children:a.pages.map((t,s)=>e.jsxs(r.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:s*.05},onClick:()=>p(t),className:"w-full flex items-center gap-3 p-4 backdrop-blur-xl bg-white/5 border border-white/10 rounded-2xl hover:bg-white/10 transition-all group text-left",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center flex-shrink-0 group-hover:bg-white/15 transition-colors",children:f(t.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-medium truncate",children:t.title}),t.description&&e.jsx("p",{className:"text-white/50 text-sm truncate",children:t.description})]}),e.jsx(g,{className:"w-4 h-4 text-white/20 group-hover:text-[#A80000] transition-colors flex-shrink-0"})]},`page-${s}`))})]}),a.blogPosts.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-xs font-medium text-white/50 uppercase tracking-wider mb-3",children:"The Naked Truth Blog"}),e.jsx("div",{className:"space-y-3",children:a.blogPosts.map((t,s)=>e.jsxs(r.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:s*.05},onClick:()=>p(t),className:"w-full flex items-center gap-4 p-3 backdrop-blur-xl bg-white/5 border border-white/10 rounded-2xl hover:bg-white/10 transition-all group text-left",children:[t.featured_image?e.jsx("div",{className:"w-24 aspect-video rounded-lg overflow-hidden flex-shrink-0 ring-1 ring-white/10",children:e.jsx("img",{src:t.featured_image,alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-24 aspect-video rounded-lg bg-[#A80000]/20 flex items-center justify-center flex-shrink-0",children:f(t.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-medium truncate",children:t.title}),t.excerpt&&e.jsx("p",{className:"text-white/50 text-sm line-clamp-1",children:t.excerpt}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("span",{className:"text-[#A80000] text-xs font-medium",children:N(t.type)}),t.category&&e.jsxs("span",{className:"text-white/40 text-xs",children:["• ",t.category]})]})]}),e.jsx(g,{className:"w-4 h-4 text-white/20 group-hover:text-[#A80000] transition-colors flex-shrink-0"})]},`blog-${t.id}`))})]}),a.sexualHealthArticles.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-xs font-medium text-white/50 uppercase tracking-wider mb-3",children:"Sexual Health Articles"}),e.jsx("div",{className:"space-y-3",children:a.sexualHealthArticles.map((t,s)=>e.jsxs(r.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:s*.05},onClick:()=>p(t),className:"w-full flex items-center gap-4 p-3 backdrop-blur-xl bg-white/5 border border-white/10 rounded-2xl hover:bg-white/10 transition-all group text-left",children:[t.featured_image?e.jsx("div",{className:"w-24 aspect-video rounded-lg overflow-hidden flex-shrink-0 ring-1 ring-white/10",children:e.jsx("img",{src:t.featured_image,alt:"",className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-24 aspect-video rounded-lg bg-pink-500/20 flex items-center justify-center flex-shrink-0",children:f(t.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-white font-medium truncate",children:t.title}),t.excerpt&&e.jsx("p",{className:"text-white/50 text-sm line-clamp-1",children:t.excerpt}),e.jsx("span",{className:"text-pink-500 text-xs font-medium",children:N(t.type)})]}),e.jsx(g,{className:"w-4 h-4 text-white/20 group-hover:text-pink-500 transition-colors flex-shrink-0"})]},`health-${t.id}`))})]})]}),e.jsxs("div",{className:"backdrop-blur-xl bg-gradient-to-r from-[#A00008]/10 to-pink-600/10 border-t border-white/10 px-6 py-4 flex items-center justify-between text-xs text-white/40",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("kbd",{className:"px-2 py-1 rounded bg-white/10 text-white/50 text-[10px]",children:"ESC"}),e.jsx("span",{children:"to close"})]}),d>0&&e.jsxs("span",{className:"text-white/50",children:[d," result",d!==1?"s":""," found"]})]})]})]})})}export{K as S,q as W};