1import{b as S,r as f,j as e,L as v}from"./vendor-react-BPv6TnFg.js";import{d as I,c as _,X as j,s as k}from"./index-CjMpuxY_.js";import{U as P}from"./UserList-CVjVoViH.js";import{L as C}from"./LikeButton-BSsw5P_M.js";import{C as E}from"./CommentsSection-DrZwEWpP.js";import{T as A}from"./trending-up-E0ZxCj4S.js";import{U as y}from"./user-DBCLKGPG.js";import{S as L}from"./search-Dx_Vf7QJ.js";import"./heart-Dgl_4QBx.js";import"./ReportModal-_tjB7Ptr.js";import"./triangle-alert-DciQAs-Z.js";import"./send-D6bX1xJB.js";import"./trash-2-DG4kpofm.js";import"./flag-Qm7xmD0J.js";import"./reply-D_f_RyDV.js";const ee=()=>{const{user:r}=I(),{theme:g}=_(),u=S(),[n,d]=f.useState(""),[l,o]=f.useState("posts"),[s,t]=f.useState([]),[a,c]=f.useState([]),[x,i]=f.useState(!1),[m,p]=f.useState(!1),[b,h]=f.useState(null),[N,w]=f.useState(null),T=()=>{u("/profile")};return e.jsxs("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-surface-elevated rounded-xl shadow-2xl w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Entdecken"}),e.jsx("button",{onClick:T,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",title:"SchlieÃen",children:e.jsx(j,{className:"w-6 h-6 text-gray-600 dark:text-gray-400"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsxs("div",{className:"flex space-x-1 bg-[#050814] dark:bg-[#050814] p-1 rounded-lg mb-6 border border-[#1f2933]/80",children:[e.jsxs("button",{onClick:()=>o("posts"),className:"flex-1 flex items-center justify-center space-x-2 py-2 px-4 rounded-md text-sm font-medium transition-colors ".concat(l==="posts"?"bg-gradient-to-r from-[#C9A96E] via-[#C9A96E] to-[#C9A96E] text-[#0A0A0A] shadow-md":"text-gray-300 dark:text-gray-400 hover:text-white"),children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),e.jsx("span",{children:"Posts"})]}),e.jsxs("button",{onClick:()=>o("ideas"),className:"flex-1 flex items-center justify-center space-x-2 py-2 px-4 rounded-md text-sm font-medium transition-colors ".concat(l==="ideas"?"bg-gradient-to-r from-[#C9A96E] via-[#C9A96E] to-[#C9A96E] text-[#0A0A0A] shadow-md":"text-gray-300 dark:text-gray-400 hover:text-white"),children:[e.jsx(A,{className:"w-4 h-4"}),e.jsx("span",{children:"Trading Ideen"})]}),e.jsxs("button",{onClick:()=>o("users"),className:"flex-1 flex items-center justify-center space-x-2 py-2 px-4 rounded-md text-sm font-medium transition-colors ".concat(l==="users"?"bg-gradient-to-r from-[#C9A96E] via-[#C9A96E] to-[#C9A96E] text-[#0A0A0A] shadow-md":"text-gray-300 dark:text-gray-400 hover:text-white"),children:[e.jsx(y,{className:"w-4 h-4"}),e.jsx("span",{children:"Benutzer"})]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx(L,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",value:n,onChange:$=>d($.target.value),placeholder:l==="users"?"Nach Name oder @handle suchen...":l==="ideas"?"Nach Symbolen, Begriffen oder Beschreibungen suchen...":"Nach Post-Inhalten suchen...",className:"w-full pl-10 pr-10 py-3 border border-gray-700 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-[#C9A96E] focus:border-transparent bg-[#0A0A0A] dark:bg-[#0A0A0A] text-white"}),n&&e.jsx("button",{onClick:()=>d(""),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(j,{className:"w-5 h-5"})})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:l==="users"?"Finde andere Trader und folge ihnen, um ihre Ideen zu sehen":l==="ideas"?'Suche nac
1h Trading Ideen mit Begriffen wie "BTC", "XRP", "long", "short" etc.':"Entdecke Posts von anderen Tradern in der Community"})]}),l==="users"?e.jsx(P,{searchQuery:n}):l==="ideas"?e.jsx(D,{searchQuery:n,loading:x,tradingIdeas:s,setTradingIdeas:t,setLoading:i,setModalIdea:h}):e.jsx(M,{searchQuery:n,loading:m,userPosts:a,setUserPosts:c,setLoading:p,setModalPost:w,theme:g})]})]}),b&&e.jsx(U,{idea:b,onClose:()=>h(null),theme:g}),N&&e.jsx(B,{post:N,onClose:()=>w(null),theme:g})]})},D=({searchQuery:r,loading:g,tradingIdeas:u,setTradingIdeas:n,setLoading:d,setModalIdea:l})=>{const{theme:o}=_();f.useEffect(()=>{s()},[r]);const s=async()=>{d(!0);try{let t=k.from("user_trading_ideas").select("\n id, user_id, tradingview_url, title, description, symbol, created_at,\n profiles:user_id (username, handle, profile_picture_url)\n ");r&&r.trim()&&(t=t.or("title.ilike.%".concat(r,"%,description.ilike.%").concat(r,"%,symbol.ilike.%").concat(r,"%")));const{data:a,error:c}=await t.order("created_at",{ascending:!1}).limit(50);if(c)console.error("Error fetching trading ideas:",c);else{const x=(a==null?void 0:a.map(i=>({...i,profiles:Array.isArray(i.profiles)?i.profiles[0]:i.profiles})))||[];n(x)}}catch(t){console.error("Error fetching trading ideas:",t)}finally{d(!1)}};return g?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 animate-pulse",children:[...Array(6)].map((t,a)=>e.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 h-64 rounded-lg"},a))}):u.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(A,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:r?"Keine Trading Ideen gefunden":"Noch keine Trading Ideen verfügbar"}),r&&e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-2",children:'Versuche andere Suchbegriffe wie "BTC", "ETH", "long", "short"'})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:u.map(t=>{var a,c,x;return e.jsx("div",{className:"group bg-gradient-to-r from-[#C9A96E]/60 via-[#C9A96E]/70 to-[#C9A96E]/80 p-[2px] rounded-lg shadow-lg dark:shadow-none cursor-pointer",onClick:()=>l(t),children:e.jsxs("div",{className:"".concat(o==="dark"?"bg-dark":"bg-white"," rounded-lg overflow-hidden h-[300px] flex flex-col"),children:[e.jsxs("div",{className:"relative h-40 flex-shrink-0",children:[e.jsx("div",{className:"absolute top-2 left-2 z-10",children:e.jsx("span",{className:"text-xs bg-black bg-opacity-70 text-white px-2 py-1 rounded",children:"Open Chart"})}),e.jsx("div",{className:"cursor-pointer hover:opacity-95 transition-opacity h-full w-full",onClick:i=>{i.stopPropagation(),window.open(t.tradingview_url,"_blank")},children:e.jsx("img",{src:t.tradingview_url,alt:"".concat(t.symbol||"Trading"," chart"),className:"w-full h-full object-cover",onError:i=>{const m=i.target;m.src="https://placehold.co/600x400?text=TradingView+Chart"}})})]}),e.jsxs("div",{className:"p-3 flex-grow flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-semibold text-sm ".concat(o==="dark"?"text-white":"text-gray-900"),children:t.title||t.symbol||"Trading Idee"}),e.jsx("span",{className:"text-xs bg-[#C9A96E]/10 dark:bg-[#C9A96E]/15 text-[#C9A96E] dark:text-[#C9A96E] px-2 py-1 rounded",children:new Date(t.created_at).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})})]}),t.description&&e.jsxs("p",{className:"text-xs ".concat(o==="dark"?"text-gray-400":"text-gray-600"," mb-2 line-clamp-2"),children:[t.description.substring(0,100),"..."]}),e.jsxs("div",{className:"flex items-center space-x-2 mt-auto",children:[e.jsx("div",{className:"w-6 h-6 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center overflow-hidden",children:(a=t.profiles)!=null&&a.profile_picture_url?e.jsx("img",{src:t.profiles.profile_picture_url,alt:t.profiles.username||t.profiles.handle,className:"w-full h-full object-cover"}):e.jsx(y,{className:"w-3 h-3 text-gray-400"})}),e.jsxs(v,{to:"/profile/".concat((c=t.profiles)==null?void 0:c.handle),onClick:i=>i.stopPropagation(),className:"text-xs ".concat(o==="dark"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900"," transition-colors"),children:["@",((x=t.profiles)==null?void 0:x.handle)||"user"]})]})]})]})},t.id)})})},U=({idea:r,onClose:g,theme:u})=>{var n,d,l;return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-surface-elevated rounded-lg w-full max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center overflow-hidden",children:(n=r.profiles)!=null&&n.profile_picture_url?e.jsx("img",{src:r.profiles.profile_picture_url,alt:r.profiles.username||r.profiles.handle,className:"w-full h-full object-cover"}):e.jsx(y,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r.title||r.symbol||"Trading Idee"}),e.jsxs(v,{to:"/profile/".concat((d=r.profiles)==null?void 0:d.handle),className:"text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors",children:["@",((l=r.profiles)==null?void 0:l.handle)||"user"]})]})]}),e.jsx("button",{onClick:g,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(j,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"cursor-pointer hover:opacity-95 transition-opacity",onClick:()=>window.open(r.tradingview_url,"_blank"),children:e.jsx("img",{src:r.tradingview_url,alt:"".concat(r.symbol||"Trading"," chart"),className:"w-full h-64 object-cover",onError:o=>{const s=o.target;s.src="https://placehold.co/600x400?text=TradingView+Chart"}})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("span",{className:"text-xs bg-[#C9A96E]/10 dark:bg-[#C9A96E]/15 text-[#C9A96E] dark:text-[#C9A96E] px-2 py-1 rounded",children:new Date(r.created_at).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})}),r.description&&e.jsx("div",{className:"mb-6",children:e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:r.description})}),e.jsx("button",{onClick:()=>window.open(r.tradingview_url,"_blank"),className:"text-sm text-[#C9A96E] hover:text-white transition-colors mb-3",children:"TradingView-Chart öffnen â"}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-3 space-y-3",children:[e.jsx(C,{contentType:"trading_idea",contentId:r.id}),e.jsx(E,{contentType:"trading_idea",contentId:r.id,defaultExpanded:!0})]})]})]})]})})},M=({searchQuery:r,loading:g,userPosts:u,setUserPosts:n,setLoading:d,setModalPost:l,theme:o})=>(f.useEffect(()=>{(async()=>{d(!0);try{let t=k.from("user_posts").select("*").or("is_deleted.is.null,is_deleted.eq.false");r&&r.trim()&&(t=t.or("content.ilike.%".concat(r,"%,link_title.ilike.%").concat(r,"%,link_description.ilike.%").concat(r,"%")));const{data:a,error:c}=await t.order("created_at",{ascending:!1}).limit(50);if(c){console.error("Error fetching posts:",c);return}if(!a||a.length===0){n([]);return}const x=[...new Set(a.map(h=>
1h.user_id))],{data:i,error:m}=await k.from("profiles").select("id, username, handle, profile_picture_url").in("id",x),p=new Map;i&&i.forEach(h=>{p.set(h.id,h)});const b=a.map(h=>({...h,profiles:p.get(h.user_id)||null}));n(b)}catch(t){console.error("Error fetching user posts:",t)}finally{d(!1)}})()},[r,d,n]),g?e.jsx("div",{className:"space-y-4 animate-pulse",children:[...Array(4)].map((s,t)=>e.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 h-32 rounded-lg"},t))}):u.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("svg",{className:"w-16 h-16 text-gray-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:r?"Keine Posts gefunden":"Noch keine Posts verfügbar"}),r&&e.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-2",children:"Versuche andere Suchbegriffe"})]}):e.jsx("div",{className:"space-y-4",children:u.map(s=>{var t,a,c,x,i;return e.jsx("div",{className:"group bg-gradient-to-r from-[#C9A96E]/60 via-[#C9A96E]/70 to-[#C9A96E]/80 p-[2px] rounded-lg shadow-lg dark:shadow-none cursor-pointer",onClick:()=>l(s),children:e.jsxs("div",{className:"".concat(o==="dark"?"bg-surface-elevated":"bg-white"," rounded-lg p-4"),children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center overflow-hidden",children:(t=s.profiles)!=null&&t.profile_picture_url?e.jsx("img",{src:s.profiles.profile_picture_url,alt:s.profiles.username||s.profiles.handle,className:"w-full h-full object-cover"}):e.jsx(y,{className:"w-5 h-5 text-gray-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(v,{to:"/profile/".concat((a=s.profiles)==null?void 0:a.handle),onClick:m=>m.stopPropagation(),className:"font-semibold text-sm ".concat(o==="dark"?"text-white hover:text-gray-300":"text-gray-900 hover:text-gray-700"," transition-colors"),children:((c=s.profiles)==null?void 0:c.username)||((x=s.profiles)==null?void 0:x.handle)||"User"}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["@",((i=s.profiles)==null?void 0:i.handle)||"user"," ⢠",new Date(s.created_at).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})]})]})]}),e.jsx("p",{className:"text-sm ".concat(o==="dark"?"text-gray-300":"text-gray-700"," mb-3"),children:s.content.length>280?s.content.substring(0,280)+"...":s.content}),s.image_urls&&s.image_urls.length>0&&e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"relative rounded-lg overflow-hidden max-w-md w-full",children:e.jsxs("div",{className:"aspect-[16/9]",children:[e.jsx("img",{src:s.image_urls[0],alt:"Post image",className:"w-full h-full object-cover",onError:m=>{const p=m.target;p.style.display="none"}}),s.image_urls.length>1&&e.jsxs("div",{className:"absolute bottom-2 right-2 bg-black bg-opacity-60 text-white text-xs px-2 py-1 rounded",children:["+",s.image_urls.length-1," mehr"]})]})})}),s.link_url&&e.jsx("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-3 mb-3",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[s.link_image_url&&e.jsx("img",{src:s.link_image_url,alt:"Link preview",className:"w-16 h-16 rounded object-cover flex-shrink-0",onError:m=>{const p=m.target;p.style.display="none"}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:s.link_title||"Link"}),s.link_description&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 line-clamp-2",children:s.link_description})]})]})})]})},s.id)})})),B=({post:r,onClose:g,theme:u})=>{var n,d,l,o,s;return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-surface-elevated rounded-lg w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"w-10 h-10 bg-gray-200 dark:bg-gray-700 rounded-full flex items-center justify-center overflow-hidden",children:(n=r.profiles)!=null&&n.profile_picture_url?e.jsx("img",{src:r.profiles.profile_picture_url,alt:r.profiles.username||r.profiles.handle,className:"w-full h-full object-cover"}):e.jsx(y,{className:"w-5 h-5 text-gray-400"})}),e.jsxs("div",{children:[e.jsx(v,{to:"/profile/".concat((d=r.profiles)==null?void 0:d.handle),className:"font-semibold text-gray-900 dark:text-white hover:text-gray-700 dark:hover:text-gray-300 transition-colors",children:((l=r.profiles)==null?void 0:l.username)||((o=r.profiles)==null?void 0:o.handle)||"User"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["@",((s=r.profiles)==null?void 0:s.handle)||"user"," ⢠",new Date(r.created_at).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]}),e.jsx("button",{onClick:g,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(j,{className:"w-5 h-5 text-gray-600 dark:text-gray-400"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap mb-4",children:r.content}),r.image_urls&&r.image_urls.length>0&&e.jsx("div",{className:"grid grid-cols-1 gap-3 mb-4",children:r.image_urls.map((t,a)=>e.jsx("img",{src:t,alt:"Post image ".concat(a+1),className:"w-full rounded-lg",onError:c=>{const x=c.target;x.style.display="none"}},a))}),r.link_url&&e.jsxs("a",{href:r.link_url,target:"_blank",rel:"noopener noreferrer",className:"block border border-gray-200 dark:border-gray-700 rounded-lg p-4 hover:bg-gray-50 dark:hover:bg-surface-elevated transition-colors mb-4",onClick:t=>t.stopPropagation(),children:[r.link_image_url&&e.jsx("img",{src:r.link_image_url,alt:"Link preview",className:"w-full h-48 object-cover rounded-lg mb-3",onError:t=>{const a=t.target;a.style.display="none"}}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white mb-1",children:r.link_title||"Link"}),r.link_description&&e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 line-clamp-2",children:r.link_description}),e.jsx("p",{className:"text-xs text-[#C9A96E] dark:text-[#C9A96E] mt-2",children:new URL(r.link_url).hostname})]}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4 space-y-3",children:[e.jsx(C,{contentType:"user_post",contentId:r.id}),e.jsx(E,{contentType:"user_post",contentId:r.id,defaultExpanded:!0})]})]})]})})};export{ee as default};
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.