1import{u as H,r as x,j as e,L as g,B as V,a3 as D,y as j,m as X,T as q,ab as L,s as T,l as J,h as W}from"./index-CFwEnLEY.js";import{L as f}from"./Layout-oLPtcFLj.js";import{C as l,a as i,b as h,c as p}from"./card-CteQ74-H.js";import{S as M}from"./skeleton-BKvDqBLK.js";import{C as Q}from"./CountdownTimer-CiQaad4F.js";import{S as Z,e as ee}from"./SEOHead-uWUFPZHW.js";import{o as se,a as ae,b as re,c as te,d as le}from"./oracle-epsilon-6tPE_rRf.js";import{C as ie,F as ne}from"./formatDistanceToNow-DzOxBwAv.js";import{T as ce}from"./target-pXm4F1Zq.js";import{C as A}from"./chart-column-DEG8jlY4.js";import{R as v,p as O,X as R,Y as E,T as b,l as $,B as de}from"./generateCategoricalChart-B_TP4ono.js";import{a as oe,L as me}from"./LineChart-SkswtP0t.js";import{P as xe,a as he,B as pe}from"./PieChart-B8gI1FNu.js";import{C as ue}from"./circle-x-Cvt5MVCy.js";import"./sparkles-Dl2NHoO3.js";import"./gift-dmx2PjYI.js";import"./format-UFh5ULii.js";import"./shield-CwgYv8UO.js";const N={"a1111111-1111-1111-1111-111111111111":se,"a2222222-2222-2222-2222-222222222222":ae,"a3333333-3333-3333-3333-333333333333":re,"a4444444-4444-4444-4444-444444444444":te,"a5555555-5555-5555-5555-555555555555":le},P={primary:"hsl(var(--primary))",success:"hsl(var(--success))",danger:"hsl(var(--danger))",muted:"hsl(var(--muted))"};function Oe(){var z;const{id:c}=H(),[a,B]=x.useState(null),[t,F]=x.useState([]),[I,y]=x.useState(!0);x.useEffect(()=>{async function s(){if(!c)return;const{data:r,error:o}=await T.from("oracles").select("*").eq("id",c).single();if(o){console.error("Fel vid hämtning av orakel:",o),y(!1);return}B(r);const{data:m,error:n}=await T.from("markets").select("*").eq("oracle_id",c).order("created_at",{ascending:!1});n?console.error("Fel vid hämtning av marknader:",n):F(J(m||[],W.getState().language)),y(!1)}s()},[c]);const k=s=>({Music:"bg-pink-500/20 text-pink-300 border-pink-500/30",Musik:"bg-pink-500/20 text-pink-300 border-pink-500/30","E-sport":"bg-cyan-500/20 text-cyan-300 border-cyan-500/30",Gaming:"bg-cyan-500/20 text-cyan-300 border-cyan-500/30",Culture:"bg-yellow-500/20 text-yellow-300 border-yellow-500/30",Science:"bg-emerald-500/20 text-emerald-300 border-emerald-500/30",Weather:"bg-sky-500/20 text-sky-300 border-sky-500/30",Politik:"bg-purple-500/20 text-purple-300 border-purple-500/30",Politics:"bg-purple-500/20 text-purple-300 border-purple-500/30",Finance:"bg-emerald-500/20 text-emerald-300 border-emerald-500/30",Sports:"bg-orange-500/20 text-orange-300 border-orange-500/30",Entertainment:"bg-yellow-500/20 text-yellow-300 border-yellow-500/30"})[s]||"bg-muted text-muted-foreground",K=t.reduce((s,r)=>s+Number(r.volume),0),d=t.filter(s=>s.status==="resolved"),C=t.filter(s=>s.status==="open"),U=d.filter(s=>s.resolved_outcome==="yes").length,Y=d.length>0?Math.round(U/d.length*100):0,w=t.slice().reverse().map((s,r)=>({name:`M${r+1}`,volume:Number(s.volume),price:Math.round(Number(s.yes_price)*100)})),G=t.reduce((s,r)=>(s[r.category]=(s[r.category]||0)+1,s),{}),u=Object.entries(G).map(([s,r])=>({name:s,value:r})),S=["#8b5cf6","#ec4899","#06b6d4","#10b981","#f59e0b"],_=[{name:"Ãppna",value:C.length,fill:P.primary},{name:"Lösta",value:d.length,fill:P.success}];return I?e.jsx(f,{children:e.jsxs("div",{className:"container mx-auto px-4 py-12",children:[e.jsx(M,{className:"h-64 rounded-xl mb-8"}),e.jsx("div",{className:"grid gap-6 md:grid-cols-3",children:[1,2,3].map(s=>e.jsx(M,{className:"h-40 rounded-xl"},s))})]})}):a?e.jsxs(f,{children:[e.jsx(Z,{title:a.display_name,description:`${a.display_name} är ett ${a.specialty} Orakel pÃ¥ LYD Markets. ${((z=a.bio)==null?void 0:z.slice(0,100))||"Se deras spÃ¥domsstatistik och marknadshistorik."}`,structuredData:ee({name:a.display_name,description:a.bio||void 0,image:N[a.id],url:`/oracle/${a.id}`})}),e.jsxs("div",{className:"container mx-auto px-4 py-8",children:[e.jsxs(g,{to:"/oracles",className:"inline-flex items-center gap-2 text-muted-foreground hover:text-foreground mb-6 transition-colors",children:[e.jsx(D,{size:16}),"Tillbaka till Orakler"]}),e.jsx("div",{className:"glass-card rounded-2xl p-8 mb-8",children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-6 items-start md:items-center",children:[e.jsx("div",{className:"w-24 h-24 rounded-full overflow-hidden bg-gradient-to-br from-primary to-accent flex items-center justify-center shrink-0",children:N[a.id]?e.jsx("img",{src:N[a.id],alt:a.display_name,className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-2xl font-bold text-primary-foreground",children:a.display_name.charAt(0).toUpperCase()})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:a.display_name}),e.jsx(j,{variant:"outline",className:k(a.specialty),children:a.specialty})]}),e.jsx("p",{className:"text-muted-foreground mb-4 max-w-2xl",children:a.bio}),e.jsx("div",{className:"flex items-center gap-4 text-sm",children:e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ie,{size:14}),"Medlem sedan ",new Date(a.created_at).toLocaleDateString()]})})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex items-center justify-center gap-1 text-primary mb-1",children:e.jsx(X,{size:20})}),e.jsx("div",{className:"font-display text-2xl font-bold",children:a.reputation_score}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Rykte"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex items-center justify-center gap-1 text-success mb-1",children:e.jsx(ce,{size:20})}),e.jsxs("div",{className:"font-display text-2xl font-bold",children:[a.accuracy_rate,"%"]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Träffsäkerhet"})]})]})]})}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-4 mb-8",children:[e.jsx(l,{className:"glass-card",children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 rounded-xl bg-primary/20",children:e.jsx(A,{className:"text-primary",size:24})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:t.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Totalt antal marknader"})]})]})})}),e.jsx(l,{className:"glass-card",children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 rounded-xl bg-success/20",children:e.jsx(q,{className:"text-success",size:24})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:["Ŧ",K.toLocaleStr
1ing()]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total volym"})]})]})})}),e.jsx(l,{className:"glass-card",children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 rounded-xl bg-accent/20",children:e.jsx(L,{className:"text-accent",size:24})}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-2xl font-bold",children:[Y,"%"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Vinstfrekvens"})]})]})})}),e.jsx(l,{className:"glass-card",children:e.jsx(i,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-3 rounded-xl bg-warning/20",children:e.jsx(ne,{className:"text-warning",size:24})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:C.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Aktiva marknader"})]})]})})})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2 mb-8",children:[e.jsxs(l,{className:"glass-card",children:[e.jsx(h,{children:e.jsx(p,{className:"text-lg",children:"Volymutveckling"})}),e.jsx(i,{children:w.length>0?e.jsx(v,{width:"100%",height:200,children:e.jsxs(oe,{data:w,children:[e.jsx(O,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(R,{dataKey:"name",stroke:"hsl(var(--muted-foreground))",fontSize:12}),e.jsx(E,{stroke:"hsl(var(--muted-foreground))",fontSize:12}),e.jsx(b,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(me,{type:"monotone",dataKey:"volume",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"}})]})}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-muted-foreground",children:"Ingen data tillgänglig"})})]}),e.jsxs(l,{className:"glass-card",children:[e.jsx(h,{children:e.jsx(p,{className:"text-lg",children:"Marknadskategorier"})}),e.jsx(i,{children:u.length>0?e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(v,{width:"100%",height:200,children:e.jsxs(xe,{children:[e.jsx(he,{data:u,cx:"50%",cy:"50%",innerRadius:50,outerRadius:80,paddingAngle:5,dataKey:"value",label:({name:s,value:r})=>`${s}: ${r}`,children:u.map((s,r)=>e.jsx($,{fill:S[r%S.length]},`cell-${r}`))}),e.jsx(b,{})]})})}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-muted-foreground",children:"Ingen data tillgänglig"})})]})]}),e.jsxs(l,{className:"glass-card mb-8",children:[e.jsx(h,{children:e.jsx(p,{className:"text-lg",children:"Ãversikt över marknadsstatus"})}),e.jsx(i,{children:e.jsx(v,{width:"100%",height:150,children:e.jsxs(pe,{data:_,layout:"vertical",children:[e.jsx(O,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(R,{type:"number",stroke:"hsl(var(--muted-foreground))",fontSize:12}),e.jsx(E,{type:"category",dataKey:"name",stroke:"hsl(var(--muted-foreground))",fontSize:12,width:80}),e.jsx(b,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),e.jsx(de,{dataKey:"value",radius:[0,4,4,0],children:_.map((s,r)=>e.jsx($,{fill:s.fill},`cell-${r}`))})]})})})]}),e.jsxs(l,{className:"glass-card",children:[e.jsx(h,{children:e.jsxs(p,{className:"text-lg flex items-center gap-2",children:[e.jsx(A,{size:20}),"Alla marknader av ",a.display_name]})}),e.jsx(i,{children:e.jsxs("div",{className:"space-y-4",children:[t.map(s=>{var m,n;const r=new Date(s.resolution_date),o=s.status==="open"&&r.getTime()-Date.now()<3*24*60*60*1e3;return e.jsx(g,{to:`/market/${s.id}`,className:`block p-4 rounded-xl bg-secondary/30 hover:bg-secondary/50 transition-all ${o?"ring-1 ring-warning/50":""}`,children:e.jsx("div",{className:"flex items-start justify-between gap-4",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium mb-2 line-clamp-2",children:s.title}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(j,{variant:"outline",className:k(s.category),children:s.category}),e.jsxs("span",{className:"text-sm text-success",children:[Math.round(Number(s.yes_price)*100),"% Ja"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Ŧ",Number(s.volume).toLocaleStr
1ing()," vol"]}),s.status==="open"&&e.jsx(Q,{targetDate:r,compact:!0}),s.status==="resolved"&&e.jsxs(j,{variant:"outline",className:s.resolved_outcome==="yes"?"bg-success/20 text-success border-success/30":"bg-danger/20 text-danger border-danger/30",children:[s.resolved_outcome==="yes"?e.jsx(L,{size:12,className:"mr-1"}):e.jsx(ue,{size:12,className:"mr-1"}),((m=s.resolved_outcome)==null?void 0:m.toUpperCase())==="YES"?"JA":(n=s.resolved_outcome)==null?void 0:n.toUpperCase()]})]})]})})},s.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Inga marknader har skapats än"})]})})]})]})]}):e.jsx(f,{children:e.jsxs("div",{className:"container mx-auto px-4 py-12 text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Oraklet hittades inte"}),e.jsx(g,{to:"/oracles",children:e.jsxs(V,{children:[e.jsx(D,{className:"mr-2",size:16}),"Tillbaka till Orakler"]})})]})})}export{Oe 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.