import{a as V,K as j,c as r,e as s,L as y,M as g,t as c,F as p,N as h,i as b,g as B,O as D,r as u,k as L,P as T,b as l,n as k}from"./index-BD9qoze1.js";import{useNostr as U}from"./useNostr-BqBiQvAw.js";const F={class:"min-h-screen bg-[#0a0a0a] text-white"},P={class:"sticky top-0 z-10 glass border-b border-white/5"},R={class:"max-w-3xl mx-auto px-4 py-3 flex items-center gap-3"},z={class:"flex-1 min-w-0"},E={class:"text-sm font-semibold text-white/90 truncate"},H={class:"text-xs text-white/40"},G={key:0,class:"flex items-center justify-center h-64"},K={key:1,class:"max-w-3xl mx-auto px-4 py-12 text-center"},O={class:"text-white/40 text-sm"},Y={key:2,class:"max-w-3xl mx-auto px-4 py-6 space-y-4"},q={class:"flex items-center gap-2 mb-2"},J=["textContent"],Z=V({__name:"ConversationViewerPage",setup(Q){const C=D(),{connect:N,fetchNote:A}=U(),v=u(!0),i=u(null),f=u("Shared Conversation"),x=u(null),d=u(null),w=u([]),I=L(()=>d.value?new Date(d.value*1e3).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"");function M(n){const t=[],o=n.split(`
`);let e="",a=[];for(const m of o){const _=m.match(/^##?\s*(?:Human|User|You)/),S=m.match(/^##?\s*(?:Assistant|AI|Claude)/);_||S?(e&&a.length>0&&t.push({role:e,content:a.join(`
`).trim()}),e=_?"user":"assistant",a=[]):a.push(m)}return e&&a.length>0&&t.push({role:e,content:a.join(`
`).trim()}),t.length===0&&n.trim()&&t.push({role:"assistant",content:n.trim()}),t}return j(async()=>{try{const n=C.params.nostrAddr;if(!n){i.value="No Nostr address provided.";return}await N();let t=null;try{const e=atob(n).split(":");e.length>=2&&(t={dTag:e[0],pubkey:e[1]})}catch{}if(t){const o=await A(t.dTag);if(o){const e=o.tags.find(a=>a[0]==="title");e&&(f.value=e[1]),x.value=o.authorName??null,d.value=o.created_at,w.value=M(o.content)}else i.value="Conversation not found on relays."}else i.value="Invalid Nostr address format."}catch(n){i.value=n instanceof Error?n.message:"Failed to load conversation."}finally{v.value=!1}}),(n,t)=>{const o=T("router-link");return l(),r("div",F,[s("header",P,[s("div",R,[y(o,{to:"/",class:"text-white/40 hover:text-white/70 transition-colors"},{default:g(()=>[...t[0]||(t[0]=[s("svg",{class:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[s("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})],-1)])]),_:1}),s("div",z,[s("h1",E,c(f.value),1),s("p",H,[x.value?(l(),r(p,{key:0},[h("by "+c(x.value),1)],64)):b("",!0),d.value?(l(),r(p,{key:1},[h(" · "+c(I.value),1)],64)):b("",!0)])]),t[1]||(t[1]=s("span",{class:"text-xs px-2 py-1 rounded-full bg-white/5 text-white/40"},"Read-only",-1))])]),v.value?(l(),r("div",G,[...t[2]||(t[2]=[s("div",{class:"w-6 h-6 rounded-full border-2 border-accent/30 border-t-accent animate-spin"},null,-1)])])):i.value?(l(),r("div",K,[s("p",O,c(i.value),1),y(o,{to:"/",class:"mt-4 inline-block text-accent text-sm hover:underline"},{default:g(()=>[...t[3]||(t[3]=[h(" Go to AIUI ",-1)])]),_:1})])):(l(),r("main",Y,[(l(!0),r(p,null,B(w.value,(e,a)=>(l(),r("div",{key:a,class:k(["rounded-xl p-4",e.role==="user"?"bg-white/[0.03] border border-white/5 ml-8":"mr-8"])},[s("div",q,[s("span",{class:k(["text-xs font-bold uppercase tracking-wider",e.role==="user"?"text-accent/70":"text-white/30"])},c(e.role==="user"?"Human":"Assistant"),3)]),s("div",{class:"text-sm text-white/80 leading-relaxed whitespace-pre-wrap break-words",textContent:c(e.content)},null,8,J)],2))),128))])),t[4]||(t[4]=s("footer",{class:"max-w-3xl mx-auto px-4 py-8 text-center"},[s("p",{class:"text-xs text-white/20"}," Shared via AIUI · Powered by Nostr ")],-1))])}}});export{Z as default};
