const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rolldown-runtime-hePW80VL.js","assets/lucide-icons-6JcOMNkr.js","assets/jsx-runtime-NZYk81nU.js","assets/useTheme-C5QTa_U0.js","assets/useAppContext-DVsgK-HT.js","assets/useEncryptedSettings-Xhb6VgJS.js","assets/useAuthor-K0SVHIbr.js","assets/esm-0y5H0J9W.js","assets/useMutation-B3AB1JC6.js","assets/useCurrentUser-CgUH2vq7.js","assets/useToast-BZaXaeWY.js","assets/fetchFreshEvent-CXox1SyJ.js","assets/useIsMobile-8UO1VB7D.js","assets/colorUtils-KIRxbuSj.js","assets/EmojiPackDialog-NQcdaVLC.js","assets/dist-CitWBVEa.js","assets/useNostrPublish-D4pB8G4O.js","assets/utils-CFLjoQCu.js","assets/button-DwJ7jtrK.js","assets/dist--t6UMBpz.js","assets/dist-U-Iv1vyA.js","assets/dist-6F83Gh1K.js","assets/input-Dkzlj0L8.js","assets/dialog-Bh2SYyZW.js","assets/dist-QjkaCeV2.js","assets/dist-D7pvA9fR.js","assets/dist-BUUm7xJW.js","assets/dist-B243A_v0.js","assets/dist-TclcpL79.js","assets/es2015-CQgmJOvf.js","assets/CustomEmoji-DxjyZluk.js","assets/useImageProxy-C0ThLkT_.js","assets/customEmoji-kpim4Htm.js","assets/useUploadFile-fBcRCPnG.js","assets/appBlossom-CsMDSd4h.js","assets/label-DbuWtQm3.js","assets/dist-E3kMcwQP.js","assets/scroll-area-B3M47T-8.js","assets/dist-CxcvWxxD.js","assets/dist-CCP8JwMC.js","assets/dist-B8UZnK_Y.js","assets/dist-C2J943E6.js","assets/textarea-FOlFw9be.js","assets/ArticleContent-BPp4GtXB.js","assets/appUrls-CRSwgtcj.js","assets/EmbeddedNote-DrUd4Foc.js","assets/TranslateButton-DiWnIeAQ.js","assets/useTranslation-DClBQ1v-.js","assets/preload-helper-Czpn1I53.js","assets/CampaignCard-i2mQdn0N.js","assets/chunk-62JRHF6Z-ByakpFgU.js","assets/avatar-8iFLkhAN.js","assets/skeleton-C53mCyi9.js","assets/genUserName-DLQrbfFW.js","assets/sanitizeUrl-Bd1A9ELz.js","assets/lib-7uQUP1a1.js","assets/lib-BWxi2zkG.js","assets/popover-CdTvSJAh.js","assets/dist-CQNJl2wh.js","assets/dist-pkeM7iu9.js","assets/useBtcPrice-s5UGsaE4.js","assets/useEventTranslation-JqEZgW2T.js","assets/appRelays-Duq5P3DM.js","assets/Trans-BCdErB0a.js","assets/i18next-pPed_4FM.js","assets/dropdown-menu-BbdDfqao.js","assets/collapsible-DeI_R02F.js","assets/communityUtils-CML5SRHR.js","assets/dist-ByRx2HZA.js","assets/dist-UrnQoaTI.js","assets/countryIdentifiers-DkqoLpd_.js","assets/countries-DOXck9T3.js","assets/useVerifierStatement-SKZOT1GH.js","assets/agoraNoteTags-D6RY6yl8.js","assets/card-D83yFPTL.js","assets/badge-ABjrmSMr.js","assets/campaignCategories-BcBEkSPQ.js","assets/formatCampaignAmount-BEWIejQ7.js","assets/useFollowActions-CAUj_2Cc.js","assets/storageKey-Hu6452Ya.js","assets/useEventInteractions-COCeUaO7.js","assets/utils-1bOINbOx.js","assets/sha256-BgZ4MAII.js","assets/browser-Cpc4qo6y.js","assets/downloadFile-BTSWd5cT.js","assets/dist-C2I8JNdt.js","assets/haptics-DWDOjcyW.js","assets/timeAgo-BXjjbyXp.js","assets/useActions-Dp20S8bZ.js","assets/CountryFlag-D9w0wcAf.js","assets/defaultActionCovers-CtOtrsxB.js","assets/EmbeddedNote-CCnCjowl.css","assets/CustomNipCard-BszL5Eg6.js","assets/PullRequestCard-CmJ_WAtX.js"])))=>i.map(i=>d[i]); import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$n as t,$t as n,Bn as r,Br as i,Cr as a,Ct as o,D as s,Dt as c,E as l,En as u,Et as d,Fr as f,Ft as p,G as m,Gn as h,Gr as g,H as _,Ht as v,I as y,In as b,Ir as x,It as S,Jt as C,Kr as w,Kt as T,L as E,Lr as D,Mr as O,Mt as k,N as A,Nr as ee,Nt as te,On as ne,Or as re,Pn as ie,Pt as ae,Qn as oe,R as se,Sn as ce,St as le,T as ue,Un as j,Ur as M,Ut as N,V as de,Vn as fe,Vt as pe,Wn as me,X as he,Xr as P,Y as ge,Z as _e,Zn as ve,Zr as ye,Zt as be,_ as xe,_r as Se,_t as Ce,ar as F,at as we,b as I,bt as Te,cn as Ee,di as De,dr as Oe,dt as ke,ei as Ae,er as je,f as Me,g as Ne,gr as Pe,gt as Fe,h as Ie,i as Le,ir as Re,it as ze,j as Be,jt as Ve,k as He,kn as Ue,kt as We,lt as Ge,nn as Ke,nr as qe,nt as Je,o as Ye,on as Xe,or as Ze,ot as Qe,q as $e,qr as et,qt as tt,rr as nt,si as rt,sn as it,sr as at,st as ot,ti as L,tn as st,tr as ct,un as lt,v as ut,vn as dt,vr as ft,wt as pt,x as mt,xr as ht,yn as gt,yt as _t,z as vt,zr as yt,zt as bt}from"./lucide-icons-6JcOMNkr.js";import{W as xt,a as R,ct as St,ft as Ct,ht as wt,n as z,pt as Tt,s as B,t as Et,tt as Dt,wt as Ot,x as V}from"./useAuthor-K0SVHIbr.js";import{n as kt,r as At}from"./TranslateButton-DiWnIeAQ.js";import{t as jt}from"./jsx-runtime-NZYk81nU.js";import{t as Mt}from"./preload-helper-Czpn1I53.js";import{a as Nt,f as Pt,m as Ft,p as It,u as H}from"./esm-0y5H0J9W.js";import{t as Lt}from"./useMutation-B3AB1JC6.js";import{a as Rt,c as zt,g as Bt,h as Vt,l as Ht,m as Ut,s as Wt}from"./CampaignCard-i2mQdn0N.js";import{t as Gt}from"./useLocalStorage-B6ue6X7-.js";import{t as Kt}from"./useAppContext-DVsgK-HT.js";import{a as qt,c as Jt,d as Yt,f as Xt,g as Zt,h as Qt,i as $t,m as en,n as tn,p as nn,r as rn,t as U,u as an,v as on}from"./useCurrentUser-CgUH2vq7.js";import{n as sn,t as W}from"./useToast-BZaXaeWY.js";import{t as cn}from"./fetchFreshEvent-CXox1SyJ.js";import{t as ln}from"./useNostrPublish-D4pB8G4O.js";import{t as un}from"./nostrId-hlO3XEuY.js";import{r as dn}from"./useMuteList-AuK7yw18.js";import{i as fn,r as pn,t as mn}from"./appUrls-CRSwgtcj.js";import{a as hn,n as gn}from"./appRelays-Duq5P3DM.js";import{i as _n,r as vn,s as yn,t as bn}from"./nostrEvents-CCXNIbkt.js";import{i as xn,n as Sn,t as Cn}from"./tooltip-1urWnwwM.js";import{T as wn,_ as Tn,g as En,t as G}from"./utils-CFLjoQCu.js";import{a as Dn,n as On,o as kn,r as An,t as jn}from"./useEventInteractions-COCeUaO7.js";import{r as Mn,t as Nn}from"./useWallet-CGlbjv_C.js";import{l as Pn,n as K}from"./chunk-62JRHF6Z-ByakpFgU.js";import{t as Fn}from"./useTranslation-DClBQ1v-.js";import{t as q}from"./button-DwJ7jtrK.js";import{t as In}from"./input-Dkzlj0L8.js";import{n as Ln}from"./dist-QjkaCeV2.js";import{a as Rn,c as zn,l as Bn,n as Vn,o as Hn,r as Un,s as Wn,t as Gn}from"./dialog-Bh2SYyZW.js";import{t as Kn}from"./qrcode-COnCKZdj.js";import{t as qn}from"./useIsMobile-8UO1VB7D.js";import{t as Jn}from"./useImageProxy-C0ThLkT_.js";import{i as Yn,n as Xn,r as Zn,t as Qn}from"./avatar-8iFLkhAN.js";import{t as J}from"./skeleton-C53mCyi9.js";import{t as $n}from"./useFeedSettings-BBOZbM3C.js";import{t as er}from"./genUserName-DLQrbfFW.js";import{a as tr,n as nr,o as rr,r as ir,t as ar}from"./sheet-BY7IUyy8.js";import{i as or,r as sr}from"./customEmoji-kpim4Htm.js";import{$ as cr,A as lr,B as ur,C as dr,D as fr,E as pr,G as mr,H as hr,I as gr,J as _r,K as vr,L as yr,N as br,O as xr,P as Sr,Q as Cr,R as wr,S as Tr,T as Er,U as Dr,V as Or,W as kr,X as Ar,Y as jr,Z as Mr,_ as Nr,a as Pr,b as Fr,c as Ir,d as Lr,et as Rr,f as zr,g as Br,h as Vr,i as Hr,it as Ur,j as Wr,k as Gr,l as Kr,m as qr,n as Jr,nt as Yr,o as Xr,p as Zr,q as Qr,r as $r,s as ei,t as ti,tt as ni,u as ri,w as ii,x as ai,y as oi,z as si}from"./EmbeddedNote-DrUd4Foc.js";import{i as ci,n as li,r as ui,t as di}from"./CustomEmoji-DxjyZluk.js";import{t as Y}from"./sanitizeUrl-Bd1A9ELz.js";import{t as fi}from"./ProfileCard-CLgNOMYZ.js";import{a as pi,b as mi,c as hi,d as gi,m as _i,o as vi,p as yi,s as bi,u as xi}from"./communityUtils-CML5SRHR.js";import{t as Si}from"./useUploadFile-fBcRCPnG.js";import{n as Ci,r as wi,t as Ti}from"./lib-7uQUP1a1.js";import{t as Ei}from"./label-DbuWtQm3.js";import{a as Di,i as Oi,r as ki,t as Ai}from"./popover-CdTvSJAh.js";import{t as ji}from"./separator-CCPnlDZv.js";import{n as Mi,t as Ni}from"./agoraNoteTags-D6RY6yl8.js";import{n as Pi}from"./downloadFile-BTSWd5cT.js";import{t as Fi}from"./scroll-area-B3M47T-8.js";import{n as Ii,r as Li,t as Ri}from"./haptics-DWDOjcyW.js";import{t as zi}from"./timeAgo-BXjjbyXp.js";import{t as Bi}from"./useActions-Dp20S8bZ.js";import{t as Vi}from"./useBtcPrice-s5UGsaE4.js";import{a as Hi,i as Ui,o as Wi}from"./countries-DOXck9T3.js";import{n as Gi,r as Ki,t as qi}from"./CountryFlag-D9w0wcAf.js";import{A as Ji,N as Yi,T as Xi,_ as Zi,b as Qi,c as $i,d as ea,k as ta,l as na,t as ra,u as ia}from"./useEventTranslation-JqEZgW2T.js";import{t as X}from"./badge-ABjrmSMr.js";import{t as aa}from"./textarea-FOlFw9be.js";import{r as oa,t as sa}from"./formatCampaignAmount-BEWIejQ7.js";import{n as ca,r as la,t as ua}from"./useInsertText-CHKvCW0R.js";import{r as da,t as fa}from"./EmojiPicker-CvYLenpU.js";import{n as pa,r as ma,t as ha}from"./useShareOrigin-BF96RqOS.js";import{t as ga}from"./contentWarning-DcKHjdNG.js";import{a as _a,i as va,n as ya,o as ba,s as xa,t as Sa}from"./bitcoinFeeSpeed-B65cB0kZ.js";import{a as Ca,c as wa,i as Ta,n as Ea,o as Da,r as Oa,s as ka,t as Aa}from"./alert-dialog-GUtjwCor.js";import{n as ja,t as Ma}from"./radio-group-B40RS2I7.js";import{a as Na,c as Pa,f as Fa,i as Ia,l as La,o as Ra,p as za,s as Ba,t as Va,u as Ha}from"./campaignEmbed-Le5cURTV.js";import{n as Ua,t as Wa}from"./admins-7SV8oI_M.js";import{t as Ga}from"./useOrganizers-CqkWQWLZ.js";import{i as Ka,t as qa}from"./zapHelpers-CY_iVNCt.js";import{t as Ja}from"./HelpTip-CaxXULj6.js";import{i as Ya,n as Xa,r as Za,t as Qa}from"./tabs-CWGKXyj_.js";import{n as $a,t as eo}from"./alert-BT6B1GYM.js";var Z=jt(),Q=e(De(),1),to=(0,Q.createContext)(void 0);function no(){let e=(0,Q.useContext)(to);if(!e)throw Error(`useAudioPlayer must be used within AudioPlayerProvider`);return e}var ro=`AIzaSyAyimkuYQYF_FXVALexPuGQctUWRURdCYQ`,io=`https://tenor.googleapis.com/v2`,ao=30;function oo(e){let t=e.media_formats.gif??e.media_formats.mediumgif,n=e.media_formats.tinygif??e.media_formats.nanogif;return{id:e.id,title:e.content_description||e.title,url:t?.url??n?.url??``,previewUrl:n?.url??t?.url??``,width:n?.dims[0]??t?.dims[0]??220,height:n?.dims[1]??t?.dims[1]??160}}async function so(e,t){let n=new URLSearchParams({key:ro,q:e,limit:String(ao),media_filter:`gif,tinygif`,contentfilter:`medium`,client_key:`ditto_nostr`});t&&n.set(`pos`,t);let r=await fetch(`${io}/search?${n}`);if(!r.ok)throw Error(`Tenor search failed: ${r.status}`);let i=await r.json();return{results:i.results.map(oo).filter(e=>e.url),next:i.next}}async function co(e){let t=new URLSearchParams({key:ro,limit:String(ao),media_filter:`gif,tinygif`,contentfilter:`medium`,client_key:`ditto_nostr`});e&&t.set(`pos`,e);let n=await fetch(`${io}/featured?${t}`);if(!n.ok)throw Error(`Tenor featured failed: ${n.status}`);let r=await n.json();return{results:r.results.map(oo).filter(e=>e.url),next:r.next}}function lo(){let[e,t]=(0,Q.useState)(``),[n,r]=(0,Q.useState)(``),i=(0,Q.useRef)(void 0),a=(0,Q.useCallback)(e=>{t(e),clearTimeout(i.current),i.current=setTimeout(()=>{r(e.trim())},300)},[]),o=(0,Q.useCallback)(()=>{t(``),r(``),clearTimeout(i.current)},[]),s=n.length>0,c=B({queryKey:[`tenor`,`trending`],queryFn:()=>co(),staleTime:3e5,enabled:!s}),l=B({queryKey:[`tenor`,`search`,n],queryFn:()=>so(n),staleTime:12e4,enabled:s}),u=s?l:c;return{query:e,setQuery:a,clearQuery:o,results:u.data?.results??[],isLoading:u.isLoading,isError:u.isError,isSearching:s}}function uo({gif:e,onClick:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),o=(0,Q.useRef)(null),s=e.width&&e.height?e.width/e.height:1,c=Math.round(150/s);return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>t(e),className:G(`relative w-full rounded-lg overflow-hidden cursor-pointer`,`transition-all duration-200 hover:ring-2 hover:ring-primary/60 hover:scale-[1.02]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`group`),style:{height:c},title:e.title,children:[!n&&!i&&(0,Z.jsx)(J,{className:`absolute inset-0 rounded-lg`}),i&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-muted rounded-lg`,children:(0,Z.jsx)(u,{className:`size-5 text-muted-foreground`})}),(0,Z.jsx)(`img`,{ref:o,src:e.previewUrl,alt:e.title,loading:`lazy`,className:G(`w-full h-full object-cover rounded-lg transition-opacity duration-200`,n?`opacity-100`:`opacity-0`),onLoad:()=>r(!0),onError:()=>a(!0)}),(0,Z.jsx)(`div`,{className:G(`absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/60 to-transparent`,`px-2 py-1.5 opacity-0 group-hover:opacity-100 transition-opacity duration-150`),children:(0,Z.jsx)(`span`,{className:`text-[10px] text-white line-clamp-1 font-medium`,children:e.title})})]})}function fo({results:e,onSelect:t}){let n=[[],[]],r=[0,0];for(let t of e){let e=t.width&&t.height?t.width/t.height:1,i=Math.round(150/e),a=r[0]<=r[1]?0:1;n[a].push(t),r[a]+=i+8}return(0,Z.jsx)(`div`,{className:`flex gap-2 px-2 pb-2`,children:n.map((e,n)=>(0,Z.jsx)(`div`,{className:`flex-1 flex flex-col gap-2`,children:e.map(e=>(0,Z.jsx)(uo,{gif:e,onClick:t},e.id))},n))})}function po({onSelect:e}){let{query:t,setQuery:n,clearQuery:r,results:i,isLoading:a,isError:o,isSearching:s}=lo(),c=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let e=setTimeout(()=>{c.current?.focus()},100);return()=>clearTimeout(e)},[]);let l=(0,Q.useCallback)(t=>{e(t)},[e]);return(0,Z.jsxs)(`div`,{className:`flex flex-col w-full h-[280px] bg-popover rounded-lg overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`px-3 pt-3 pb-2`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(ke,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none`}),(0,Z.jsx)(In,{ref:c,value:t,onChange:e=>n(e.target.value),placeholder:`Search GIFs...`,className:`pl-8 pr-20 h-9 text-base md:text-sm bg-muted/50 border-0 rounded-lg`}),t?(0,Z.jsx)(`button`,{type:`button`,onClick:r,className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:(0,Z.jsx)(Ye,{className:`size-3.5`})}):(0,Z.jsx)(`span`,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground/50 pointer-events-none select-none`,children:`Powered by Tenor`})]})}),(0,Z.jsx)(`div`,{className:`px-3 pb-1.5`,children:(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground uppercase tracking-wider`,children:s?`Results`:`Trending`})}),(0,Z.jsx)(Fi,{className:`flex-1`,children:a?(0,Z.jsx)(`div`,{className:`px-2 pb-2`,children:(0,Z.jsx)(`div`,{className:`flex gap-2`,children:[0,1].map(e=>(0,Z.jsx)(`div`,{className:`flex-1 flex flex-col gap-2`,children:Array.from({length:4}).map((e,t)=>(0,Z.jsx)(J,{className:`w-full rounded-lg`,style:{height:80+Math.random()*60}},t))},e))})}):o?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 text-muted-foreground`,children:[(0,Z.jsx)(u,{className:`size-8 mb-2`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:`Failed to load GIFs`}),(0,Z.jsx)(`p`,{className:`text-xs mt-1`,children:`Please try again`})]}):i.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 text-muted-foreground`,children:[(0,Z.jsx)(`p`,{className:`text-sm`,children:`No GIFs found`}),(0,Z.jsx)(`p`,{className:`text-xs mt-1`,children:`Try a different search term`})]}):(0,Z.jsx)(fo,{results:i,onSelect:l})})]})}var mo=`direction.boxSizing.width.height.overflowX.overflowY.borderTopWidth.borderRightWidth.borderBottomWidth.borderLeftWidth.borderStyle.paddingTop.paddingRight.paddingBottom.paddingLeft.fontStyle.fontVariant.fontWeight.fontStretch.fontSize.fontSizeAdjust.lineHeight.fontFamily.textAlign.textTransform.textIndent.textDecoration.letterSpacing.wordSpacing.tabSize.MozTabSize.whiteSpace.wordWrap.wordBreak`.split(`.`);function ho(e,t){let n=document.createElement(`div`);n.id=`emoji-mirror`;let r=window.getComputedStyle(e);for(let e of mo)n.style[e]=r.getPropertyValue(e.replace(/([A-Z])/g,`-$1`).toLowerCase());n.style.position=`absolute`,n.style.visibility=`hidden`,n.style.whiteSpace=`pre-wrap`,n.style.wordWrap=`break-word`,n.style.overflow=`hidden`,document.body.appendChild(n),n.textContent=e.value.substring(0,t);let i=document.createElement(`span`);i.textContent=`​`,n.appendChild(i);let a=n.getBoundingClientRect(),o=i.getBoundingClientRect(),s={top:o.top-a.top-e.scrollTop,left:o.left-a.left-e.scrollLeft};return document.body.removeChild(n),s}var go=8;function _o(){let e=da.emojis,t=da.aliases,n=[];for(let[r,i]of Object.entries(e)){let e=i.skins?.[0]?.native;if(!e)continue;let a=[];for(let[e,n]of Object.entries(t))n===r&&a.push(e);n.push({id:r,name:i.name,native:e,keywords:[...i.keywords||[],...a]})}return n}var vo=null;function yo(){return vo||=_o(),vo}function bo(e,t){if(!e)return[];let n=e.toLowerCase(),r=[];for(let e of t){let t=e.shortcode.toLowerCase();t===n?r.push({id:`custom:${e.shortcode}`,name:e.shortcode,customUrl:e.url,score:-1}):t.startsWith(n)?r.push({id:`custom:${e.shortcode}`,name:e.shortcode,customUrl:e.url,score:0}):t.includes(n)&&r.push({id:`custom:${e.shortcode}`,name:e.shortcode,customUrl:e.url,score:1})}let i=yo();for(let e of i)e.id===n?r.push({id:e.id,name:e.name,native:e.native,score:2}):e.id.startsWith(n)?r.push({id:e.id,name:e.name,native:e.native,score:3}):e.id.includes(n)?r.push({id:e.id,name:e.name,native:e.native,score:4}):e.name.toLowerCase().startsWith(n)?r.push({id:e.id,name:e.name,native:e.native,score:5}):e.name.toLowerCase().includes(n)?r.push({id:e.id,name:e.name,native:e.native,score:6}):e.keywords?.some(e=>e.startsWith(n)||e.includes(n))&&r.push({id:e.id,name:e.name,native:e.native,score:7});return r.sort((e,t)=>e.score-t.score),r.slice(0,go)}function xo({textareaRef:e,content:t,onInsertEmoji:n,onCustomEmojiInsert:r}){let{emojis:i}=si(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(-1),[l,u]=(0,Q.useState)(0),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),h=(0,Q.useRef)(null),g=(0,Q.useRef)(null),_=(0,Q.useCallback)(()=>f(!1),[]),{computePosition:v,renderPortal:y}=la({textareaRef:e,isOpen:d,onClose:_,dropdownHeight:280}),b=(0,Q.useMemo)(()=>bo(a,i),[a,i]),x=(0,Q.useCallback)((t,n)=>{let r=e.current;if(!r)return;let i=n??r.selectionStart,a=t??r.value,s=-1;for(let e=i-1;e>=0;e--){let t=a[e];if(t===` `||t===` `||t===` `)break;if(t===`:`&&e32){f(!1),o(``),c(-1);return}if(l.includes(`:`)){f(!1),o(``),c(-1);return}o(l),c(s),f(!0),u(0);let d=ho(r,s);m(v(d))},[e,v]);(0,Q.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{x(t.value,t.selectionStart)},r=()=>x(),i=e=>{[`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key)&&x()};return t.addEventListener(`input`,n),t.addEventListener(`click`,r),t.addEventListener(`keyup`,i),()=>{t.removeEventListener(`input`,n),t.removeEventListener(`click`,r),t.removeEventListener(`keyup`,i)}},[e,x,t]),(0,Q.useEffect)(()=>{let n=e.current;n&&x(t,n.selectionStart)},[t,x,e]),(0,Q.useEffect)(()=>{if(!d||b.length===0)return;let t=e.current;if(!t)return;let n=e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),u(e=>ee>0?e-1:b.length-1);break;case`Enter`:case`Tab`:b.length>0&&(e.preventDefault(),S(b[l]));break;case`Escape`:e.preventDefault(),f(!1)}};return t.addEventListener(`keydown`,n),()=>t.removeEventListener(`keydown`,n)},[d,b,l,e]),(0,Q.useEffect)(()=>{l>=0&&g.current&&g.current.querySelectorAll(`[data-emoji-item]`)[l]?.scrollIntoView({block:`nearest`})},[l]);let S=(0,Q.useCallback)(t=>{let l=e.current?.selectionStart??s+a.length+1;if(t.customUrl){let e=t.name;n({start:s,end:l,replacement:`:${e}: `});let a=i.find(t=>t.shortcode===e);a&&r&&r(a)}else t.native&&n({start:s,end:l,replacement:t.native});f(!1),o(``),c(-1)},[s,a,e,n,r,i]);return!d||!p||b.length===0?null:y((0,Z.jsx)(`div`,{ref:h,"data-autocomplete-dropdown":!0,className:`fixed z-[300] w-[280px] rounded-xl border border-border bg-popover shadow-lg overflow-hidden animate-in fade-in-0 zoom-in-95 slide-in-from-top-2 duration-150 pointer-events-auto`,style:{top:p.top,left:p.left},children:(0,Z.jsx)(`div`,{ref:g,className:`max-h-[280px] overflow-y-auto py-1`,children:b.map((e,t)=>(0,Z.jsxs)(`button`,{"data-emoji-item":!0,className:G(`w-full flex items-center gap-3 px-3 py-1.5 text-left text-popover-foreground transition-colors cursor-pointer`,t===l?`bg-secondary/60`:`hover:bg-secondary/60`),onClick:()=>S(e),onMouseDown:e=>e.preventDefault(),children:[e.customUrl?(0,Z.jsx)(di,{name:e.name,url:e.customUrl,className:`size-5 object-contain shrink-0`}):(0,Z.jsx)(`span`,{className:`text-xl leading-none shrink-0 font-emoji`,children:e.native}),(0,Z.jsxs)(`span`,{className:`text-sm truncate`,children:[`:`,e.id.replace(`custom:`,``),`:`]})]},e.id))})}),document.body)}function So({customEmojis:e,onSelect:t,height:n=350,autoFocus:r=!0}){let[i,a]=(0,Q.useState)(``),o=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{if(r){let e=setTimeout(()=>o.current?.focus(),100);return()=>clearTimeout(e)}},[r]);let s=(0,Q.useMemo)(()=>{if(!i.trim())return e;let t=i.toLowerCase();return e.filter(e=>e.shortcode.toLowerCase().includes(t))},[e,i]);return e.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground gap-2`,style:{height:n},children:[(0,Z.jsx)(_,{className:`size-8`}),(0,Z.jsx)(`p`,{className:`text-sm`,children:`No sticker packs yet`}),(0,Z.jsx)(`p`,{className:`text-xs`,children:`Add emoji packs to your profile to use stickers`})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col`,style:{height:n},children:[(0,Z.jsx)(`div`,{className:`px-3 pt-3 pb-2 shrink-0`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(ke,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none`}),(0,Z.jsx)(In,{ref:o,value:i,onChange:e=>a(e.target.value),placeholder:`Search stickers...`,className:`pl-8 pr-8 h-9 text-base md:text-sm bg-muted/50 border-0 rounded-lg`}),i&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(``),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:(0,Z.jsx)(Ye,{className:`size-3.5`})})]})}),(0,Z.jsx)(Fi,{className:`flex-1 min-h-0`,children:s.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-muted-foreground`,children:[(0,Z.jsx)(`p`,{className:`text-sm`,children:`No stickers found`}),(0,Z.jsx)(`p`,{className:`text-xs mt-1`,children:`Try a different search term`})]}):(0,Z.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5 p-2`,children:s.map(e=>(0,Z.jsx)(`button`,{type:`button`,title:e.shortcode,onClick:()=>t(e),className:`aspect-square rounded-lg overflow-hidden hover:bg-muted transition-colors p-1 group`,children:(0,Z.jsx)(di,{name:e.shortcode,url:e.url,className:`w-full h-full object-contain group-hover:scale-110 transition-transform duration-150`})},e.shortcode))})})]})}function Co(){let{mutateAsync:e}=ln(),t=V();return Lt({mutationFn:async({root:t,reply:n,content:r,tags:i})=>{let a=Eo(n),o=[];return o.push(...To(`root`,t,a)),n?o.push(...To(`reply`,n,a)):o.push(...To(`reply`,t,a)),i&&o.push(...i),await e({kind:1111,content:r,tags:Mi(o)})},onSuccess:(e,{root:n})=>{let r=n instanceof URL?n.toString():typeof n==`string`?n:n.id,i=wo(n);if(t.invalidateQueries({queryKey:[`nostr`,`comments`,r]}),t.invalidateQueries({queryKey:[`agora-feed`]}),t.invalidateQueries({queryKey:[`mixed-feed`]}),Do(n)){let e=n.tags.find(([e])=>e===`A`)?.[1];e&&t.invalidateQueries({queryKey:[`organization-activity`,e]}),e&&t.invalidateQueries({predicate:t=>{let[n,r]=t.queryKey;return n===`community-activity-feed`&&typeof r==`string`&&r.split(`,`).includes(e)}});let r=n.tags.find(([e])=>e===`d`)?.[1]??``,i=`${n.kind}:${n.pubkey}:${r}`;t.invalidateQueries({queryKey:[`event-comments`,i]})}i&&(t.setQueriesData({queryKey:[`agora-feed-paginated`,i]},t=>{if(!t||t.pages.length===0||t.pages.some(t=>t.events.some(t=>t.id===e.id)))return t;let[n,...r]=t.pages;return{...t,pages:[{...n,events:[e,...n.events],totalFetched:n.totalFetched+1},...r]}}),t.invalidateQueries({queryKey:[`agora-feed-paginated`,i]}),t.invalidateQueries({queryKey:[`agora-feed-new-posts`,i]}),setTimeout(()=>{t.invalidateQueries({queryKey:[`agora-feed-paginated`,i]}),t.invalidateQueries({queryKey:[`agora-feed-new-posts`,i]})},3e3))}})}function wo(e){if(e instanceof URL&&e.protocol===`iso3166:`)return e.pathname.toUpperCase();if(typeof e==`string`&&e.toLowerCase().startsWith(`iso3166:`))return e.slice(8).toUpperCase()}function To(e,t,n){let r=[],{aHints:i,eHints:a,pHints:o}=n;if(typeof t==`string`)r.push([`I`,t]);else if(t instanceof URL)r.push([`I`,t.toString()]);else if(Dt.replaceable(t.kind)||Dt.addressable(t.kind)){let e=t.tags.find(([e])=>e===`d`)?.[1]??``,n=`${t.kind}:${t.pubkey}:${Dt.addressable(t.kind)?e:``}`;r.push([`A`,n,...i.get(n)??[]])}else r.push([`E`,t.id,...a.get(t.id)??[]]);if(typeof t==`string`)r.push([`K`,`#`]);else if(t instanceof URL)switch(t.protocol){case`http:`:case`https:`:r.push([`K`,`web`]);break;default:r.push([`K`,t.protocol.replace(/:$/,``)])}else r.push([`K`,t.kind.toString()]),r.push([`P`,t.pubkey,...o.get(t.pubkey)??[]]);return e===`reply`?r.map(([e,...t])=>[e.toLowerCase(),...t]):r}function Eo(e){let t=new Map,n=new Map,r=new Map;if(!Do(e))return{pHints:t,eHints:n,aHints:r};for(let[i,a,...o]of e.tags){let e=i?.toLowerCase();if(e===`p`)try{let e=new URL(o[0]);t.set(a,[e.href])}catch{}else if(e===`a`)try{let e=new URL(o[0]);r.set(a,[e.href])}catch{}else if(e===`e`){let e=/^[0-9a-f]{64}$/.test(o[1])?o[1]:void 0;try{let t=new URL(o[0]);n.set(a,[t.href,...e?[e]:[]])}catch{e&&n.set(a,[``,e])}}}return{pHints:t,eHints:n,aHints:r}}function Do(e){return!!e&&typeof e!=`string`&&!(e instanceof URL)}function Oo(e,t,n){if(typeof t==`string`){e.invalidateQueries({queryKey:[`nip85-event-stats`,t,n]}),e.invalidateQueries({queryKey:[`nip85-event-stats`,t]});return}let r=t;if(e.invalidateQueries({queryKey:[`nip85-event-stats`,r.id,n]}),e.invalidateQueries({queryKey:[`nip85-event-stats`,r.id]}),r.kind>=3e4&&r.kind<4e4||r.kind>=1e4&&r.kind<2e4){let t=r.tags.find(([e])=>e===`d`)?.[1]??``,i=`${r.kind}:${r.pubkey}:${t}`;e.invalidateQueries({queryKey:[`nip85-addr-stats`,i,n]}),e.invalidateQueries({queryKey:[`nip85-addr-stats`,i]})}}var ko=60,Ao=100,jo=100;function Mo(){if(typeof MediaRecorder>`u`)return`audio/webm`;for(let e of[`audio/mp4`,`audio/mp4;codecs=aac`,`audio/aac`,`audio/webm;codecs=opus`,`audio/webm`,`audio/ogg;codecs=opus`])if(MediaRecorder.isTypeSupported(e))return e;return`audio/webm`}function No(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(0),[i,a]=(0,Q.useState)([]),o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useRef)(null),u=(0,Q.useRef)([]),d=(0,Q.useRef)([]),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(0),h=(0,Q.useRef)(null),g=typeof navigator<`u`&&!!navigator.mediaDevices&&!!navigator.mediaDevices.getUserMedia&&typeof MediaRecorder<`u`;(0,Q.useEffect)(()=>()=>{_()},[]);let _=(0,Q.useCallback)(()=>{f.current&&=(clearInterval(f.current),null),p.current&&=(clearInterval(p.current),null),l.current&&=(l.current.getTracks().forEach(e=>e.stop()),null),s.current&&=(s.current.close().catch(()=>{}),null),c.current=null,o.current=null,u.current=[]},[]);return{isSupported:g,isRecording:e,recordingDuration:n,liveWaveform:i,startRecording:(0,Q.useCallback)(async()=>{if(e||!g)return;let n=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=n;let i=new AudioContext;s.current=i;let v=i.createMediaStreamSource(n),y=i.createAnalyser();y.fftSize=256,v.connect(y),c.current=y;let b=Mo(),x=new MediaRecorder(n,{mimeType:b});o.current=x,u.current=[],d.current=[],x.ondataavailable=e=>{e.data.size>0&&u.current.push(e.data)},x.onstop=()=>{let e=new Blob(u.current,{type:b}),n=(Date.now()-m.current)/1e3,i=d.current,o=Po(i,Ao),s={blob:e,mimeType:b,duration:n,waveform:o};h.current&&=(h.current(s),null),_(),t(!1),r(0),a([])},x.start(250),m.current=Date.now(),t(!0),r(0),a([]),f.current=setInterval(()=>{let e=(Date.now()-m.current)/1e3;r(e),e>=ko&&o.current?.state===`recording`&&o.current.stop()},100),p.current=setInterval(()=>{if(!c.current)return;let e=new Uint8Array(c.current.frequencyBinCount);c.current.getByteTimeDomainData(e);let t=0;for(let n=0;n[...e,r])},jo)},[e,g,_]),stopRecording:(0,Q.useCallback)(async()=>{let e=o.current;return!e||e.state!==`recording`?null:new Promise(t=>{h.current=t,e.stop()})},[]),cancelRecording:(0,Q.useCallback)(()=>{let e=o.current;e&&e.state===`recording`?(e.onstop=()=>{_(),t(!1),r(0),a([])},e.stop()):(_(),t(!1),r(0),a([])),h.current&&=(h.current(null),null)},[_])}}function Po(e,t){if(e.length===0)return[];if(e.length<=t)return e;let n=[],r=e.length/t;for(let i=0;io&&(o=e[n]);n.push(o)}return n}var Fo=(0,Q.lazy)(()=>Mt(()=>import(`./EmojiPicker-CvYLenpU.js`).then(e=>e.n).then(e=>({default:e.EmojiPicker})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),Io=5e3;function Lo(){return Math.random().toString(36).slice(2,8)}async function Ro(e){if(!e.type.startsWith(`image/`))return{};try{let t=URL.createObjectURL(e);try{let e=await new Promise((e,n)=>{let r=new Image;r.onload=()=>e(r),r.onerror=n,r.src=t}),n=e.naturalWidth,r=e.naturalHeight;if(!n||!r)return{};let i=`${n}x${r}`,a=64/n,o=Math.max(1,Math.round(r*a)),s=document.createElement(`canvas`);s.width=64,s.height=o;let c=s.getContext(`2d`);if(!c)return{dim:i};c.drawImage(e,0,0,64,o);let{data:l}=c.getImageData(0,0,64,o);return{dim:i,blurhash:Vt(l,64,o,4,3)}}finally{URL.revokeObjectURL(t)}}catch{return{}}}function zo(e){return e instanceof URL||typeof e==`string`}function Bo({count:e,max:t}){let n=2*Math.PI*10,r=n*(1-Math.min(e/t,1)),i=e>t,a=e>t*.9;return(0,Z.jsx)(`div`,{className:`relative flex items-center justify-center size-7`,children:(0,Z.jsxs)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 28 28`,className:`-rotate-90`,children:[(0,Z.jsx)(`circle`,{cx:`14`,cy:`14`,r:10,fill:`none`,strokeWidth:`2.5`,className:`stroke-secondary`}),(0,Z.jsx)(`circle`,{cx:`14`,cy:`14`,r:10,fill:`none`,strokeWidth:`2.5`,strokeDasharray:n,strokeDashoffset:r,strokeLinecap:`round`,className:G(`transition-all duration-150`,i?`stroke-destructive`:a?`stroke-amber-500`:`stroke-primary`)})]})})}function Vo({onSuccess:e,onPublished:t,placeholder:n,compact:r=!1,replyTo:i,quotedEvent:a,forceExpanded:s=!1,hideAvatar:c=!1,hideBorder:l=!1,className:u,previewMode:d,onHasPreviewableContentChange:f,initialContent:p=``,initialMode:h=`post`,customPublish:g,hidePoll:v=!1,submitLabel:y,defaultTags:b,defaultExpanded:S=!1}){let{t:C}=Fn(),w=n??C(`compose.placeholderDefault`),T=y??C(`compose.submitDefault`),{user:E,metadata:D,isLoading:O}=U(),k=kt(E?.pubkey??``,D),{mutateAsync:A,isPending:ne,isPending:re}=ln(),{mutateAsync:ie,isPending:ae}=Co(),{mutateAsync:oe,isPending:se}=Si(),{feedSettings:ce}=$n(),le=ce.showCustomEmojis!==!1,{emojis:ue}=si(),j=(0,Q.useMemo)(()=>le?ue:[],[le,ue]),M=V(),{toast:N}=sn(),{config:de}=Kt(),fe=de.imageQuality,pe=de.nip85StatsPubkey,me=qn(),he=(0,Q.useMemo)(()=>i instanceof URL?`compose-draft:url:${i.href}`:typeof i==`string`?`compose-draft:ext:${i}`:i?`compose-draft:reply:${i.id}`:a?`compose-draft:quote:${a.id}`:`compose-draft:new`,[i,a]),[P,_e]=(0,Q.useState)(()=>{if(p)return p;try{return localStorage.getItem(he)??``}catch{return``}}),[ve,ye]=(0,Q.useState)(S),[be,xe]=(0,Q.useState)(!1),[Se,Ce]=(0,Q.useState)(``),[F,we]=(0,Q.useState)(!1),[I,Te]=(0,Q.useState)(`emoji`),[Ee,De]=(0,Q.useState)(!1),[Oe,ke]=(0,Q.useState)(!1),[Ae,je]=(0,Q.useState)(h),[Me,Ne]=(0,Q.useState)([{id:Lo(),label:``},{id:Lo(),label:``}]),[Pe,Fe]=(0,Q.useState)(`singlechoice`),[Ie,Le]=(0,Q.useState)(7),[Re,ze]=(0,Q.useState)(new Set),[Ve,He]=(0,Q.useState)(new Map),Ue=(0,Q.useRef)(null),We=(0,Q.useRef)(null),[Ge,Ke]=(0,Q.useState)(),{insertAtCursor:qe,insertEmoji:Je}=ua(Ue,P,_e),Ze=(0,Q.useRef)(null),Qe=No(),[$e,et]=(0,Q.useState)(!1),nt=(0,Q.useCallback)(()=>{_e(``),xe(!1),Ce(``),ye(S),we(!1),De(!1),ke(!1),je(h),Ne([{id:Lo(),label:``},{id:Lo(),label:``}]),Fe(`singlechoice`),Le(7),ze(new Set),He(new Map),Ke(void 0);try{localStorage.removeItem(he)}catch{}},[h,he,S]),rt=d===void 0?Oe:d;(0,Q.useEffect)(()=>{(a||P)&&ye(!0)},[a]),(0,Q.useEffect)(()=>{if(rt)return;let e=Ue.current;if(!e)return;e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`;let t=We.current;t&&Ke(t.offsetHeight)},[P,rt,ve,s,r]),(0,Q.useEffect)(()=>{if(p)return;let e=setTimeout(()=>{try{P.trim()?localStorage.setItem(he,P):localStorage.removeItem(he)}catch{}},300);return()=>clearTimeout(e)},[P,he,p]);let it=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(me){if(F)Ue.current?.blur(),it.current=!0;else if(it.current){it.current=!1;let e=setTimeout(()=>Ue.current?.focus(),150);return()=>clearTimeout(e)}}},[F,me]);let at=P.length,ot=Io-at,L=(0,Q.useCallback)(()=>{ve||ye(!0)},[ve]),st=(0,Q.useCallback)(()=>{if(!be)return[];let e=[[`content-warning`,Se||``],[`L`,`content-warning`]];return Se&&e.push([`l`,Se,`content-warning`]),e},[be,Se]),ct=(0,Q.useRef)(S);(0,Q.useEffect)(()=>{ve&&!ct.current&&Ue.current?.focus(),ct.current=ve},[ve]);let lt=(0,Q.useMemo)(()=>{let e=[],t=P.matchAll(/nostr:(nevent1|note1|naddr1)[023456789acdefghjklmnpqrstuvwxyz]+/g);for(let n of t){let t=n[0].slice(6);try{let r=H.decode(t);r.type===`nevent`?e.push({type:`nevent`,value:n[0],index:n.index,eventId:r.data.id}):r.type===`note`?e.push({type:`note`,value:n[0],index:n.index,eventId:r.data}):r.type===`naddr`&&e.push({type:`naddr`,value:n[0],index:n.index,addr:{kind:r.data.kind,pubkey:r.data.pubkey,identifier:r.data.identifier}})}catch{}}let n=P.matchAll(/\b(nevent1|note1|naddr1)[023456789acdefghjklmnpqrstuvwxyz]+\b/g);for(let t of n){let n=t[0],r=t.index-6;if(!P.substring(Math.max(0,r),t.index).endsWith(`nostr:`))try{let r=H.decode(n);r.type===`nevent`?e.push({type:`nevent`,value:t[0],index:t.index,eventId:r.data.id}):r.type===`note`?e.push({type:`note`,value:t[0],index:t.index,eventId:r.data}):r.type===`naddr`&&e.push({type:`naddr`,value:t[0],index:t.index,addr:{kind:r.data.kind,pubkey:r.data.pubkey,identifier:r.data.identifier}})}catch{}}let r=P.matchAll(/https?:\/\/[^\s]+/g);for(let t of r){let n=t[0];Hr.test(n)||e.push({type:`link`,value:n,index:t.index})}return e.sort((e,t)=>e.index-t.index)},[P]),ut=(0,Q.useMemo)(()=>lt.filter(e=>!Re.has(e.value)),[lt,Re]),dt=(0,Q.useMemo)(()=>P?Xr(P):[],[P]),ft=(0,Q.useMemo)(()=>P?Pr(P):[],[P]),pt=(0,Q.useMemo)(()=>P?/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp|svg|avif)(\?[^\s]*)?/i.test(P):!1,[P]),mt=(0,Q.useMemo)(()=>/nostr:(npub1|nprofile1)[023456789acdefghjklmnpqrstuvwxyz]+/.test(P),[P]),ht=(0,Q.useMemo)(()=>{if(j.length===0||!P)return!1;let e=new Set(j.map(e=>e.shortcode)),t=P.matchAll(/:([a-zA-Z0-9_-]+):/g);for(let n of t)if(e.has(n[1]))return!0;return!1},[P,j]),gt=(0,Q.useMemo)(()=>ut.length>0||pt||dt.length>0||ft.length>0||mt||ht,[ut,pt,dt,ft,mt,ht]);(0,Q.useEffect)(()=>{f&&f(gt)},[gt,f]);let _t=(0,Q.useMemo)(()=>{if(!a)return null;if(a.kind>=3e4&&a.kind<4e4){let e=a.tags.find(([e])=>e===`d`)?.[1]??``;return H.naddrEncode({kind:a.kind,pubkey:a.pubkey,identifier:e,relays:[gn]})}return H.neventEncode({id:a.id,author:a.pubkey,relays:[gn]})},[a]),vt=_t?`nostr:${_t}`:null,yt=a&&vt&&!Re.has(vt),bt=(0,Q.useMemo)(()=>{if(!E||!P)return null;let e=fn(P),t=Ur(e).map(e=>[`t`,e]);if(j.length>0){let n=new Map(j.map(e=>[e.shortcode,e.url])),r=/:([a-zA-Z0-9_-]+):/g,i=new Set,a;for(;(a=r.exec(e))!==null;){let e=a[1];n.has(e)&&!i.has(e)&&(i.add(e),t.push([`emoji`,e,n.get(e)]))}}let n=e.matchAll(new RegExp($r.source,`gi`)),r=new Set;for(let e of n){let n=e[0];if(r.has(n))continue;r.add(n);let i=e[1].toLowerCase(),a=Ve.get(n);if(a){let e=a.map(e=>`${e[0]} ${e[1]}`);t.push([`imeta`,...e])}else{let e=ei(i);t.push([`imeta`,`url ${n}`,`m ${e}`])}}return{id:`preview`,pubkey:E.pubkey,content:e.trim(),created_at:Math.floor(Date.now()/1e3),kind:1,tags:t,sig:``}},[E,P,j,Ve]),xt=(0,Q.useCallback)(e=>{Je(e),L()},[Je,L]),R=qe,St=qe,Ct=(0,Q.useCallback)(async e=>{try{let t=e.type.startsWith(`image/`),n,r;if(t&&fe===`compressed`){let t=await mi(e);n=t.file,r=t.dimensions}else n=e;let i=await oe(n),[[,a]]=i;if(t){r&&i.push([`dim`,r]);let{blurhash:e}=await Ro(n);e&&i.push([`blurhash`,e])}He(e=>new Map(e).set(a,i)),_e(e=>e?e+` `+a:a),L()}catch{N({title:C(`compose.submit.uploadFailed`),description:C(`compose.submit.uploadFailedBody`),variant:`destructive`})}},[oe,L,N,fe,C]),wt=(0,Q.useCallback)(async e=>{let t=e.clipboardData?.items;if(t)for(let n=0;n{try{await Qe.startRecording(),L()}catch{N({title:C(`compose.voice.micDeniedTitle`),description:C(`compose.voice.micDeniedBody`),variant:`destructive`})}},[Qe,L,N,C]),Tt=(0,Q.useCallback)(async()=>{if(E){et(!0);try{let n=await Qe.stopRecording();if(!n)return;let r={"audio/mp4":`.m4a`,"audio/mp4;codecs=aac":`.m4a`,"audio/aac":`.aac`,"audio/webm;codecs=opus":`.webm`,"audio/webm":`.webm`,"audio/ogg;codecs=opus":`.ogg`}[n.mimeType]??`.webm`,a=`voice-message-${Date.now()}${r}`,o=new File([n.blob],a,{type:n.mimeType}),[[,s]]=await oe(o),c=[`imeta`,`url ${s}`,`m ${n.mimeType}`,`waveform ${n.waveform.join(` `)}`,`duration ${Math.round(n.duration)}`],l=st();if(g){let e=await A({kind:g.kind,content:s,tags:[...g.tags,c,...l]});t?.(e)}else{let e=i&&(zo(i)||i.kind!==1),t=i&&!zo(i)&&i.kind===1;if(e){let e=[c,...l];if(i instanceof URL){let t=i.protocol===`http:`||i.protocol===`https:`?`web`:i.protocol.replace(/:$/,``);e.push([`I`,i.toString()]),e.push([`K`,t]),e.push([`i`,i.toString()]),e.push([`k`,t])}else typeof i==`string`?(e.push([`I`,i]),e.push([`K`,`#`]),e.push([`i`,i]),e.push([`k`,`#`])):(e.push([`E`,i.id]),e.push([`K`,i.kind.toString()]),e.push([`P`,i.pubkey]),e.push([`e`,i.id]),e.push([`k`,i.kind.toString()]),e.push([`p`,i.pubkey]));await A({kind:1244,content:s,tags:e})}else if(t&&!zo(i)){let e=[c,...l],t=i.tags.find(([e,,,t])=>e===`e`&&t===`root`);t?(e.push([`e`,t[1],t[2]||`wss://relay.ditto.pub/`,`root`,...t[4]?[t[4]]:[]]),e.push([`e`,i.id,gn,`reply`,i.pubkey])):e.push([`e`,i.id,gn,`root`,i.pubkey]),e.push([`p`,i.pubkey]),await A({kind:1222,content:s,tags:e})}else await A({kind:1222,content:s,tags:[c,...l]})}M.invalidateQueries({queryKey:[`feed`]}),M.invalidateQueries({queryKey:[`agora-feed`]}),M.invalidateQueries({queryKey:[`mixed-feed`]}),i&&(zo(i)?M.invalidateQueries({queryKey:[`nostr`,`comments`]}):(M.invalidateQueries({queryKey:[`replies`,i.id]}),i.kind!==1&&M.invalidateQueries({queryKey:[`nostr`,`comments`]}),Oo(M,i,pe))),Li(),N({title:C(`compose.voice.sentTitle`),description:C(`compose.voice.sentBody`)}),e?.()}catch{N({title:C(`common.error`),description:C(`compose.voice.sendFailed`),variant:`destructive`})}finally{et(!1)}}},[E,Qe,oe,st,g,A,t,i,M,N,e,pe,C]),B=async()=>{if(!(!P.trim()||!E||at>Io))try{let n=fn(P),r=Ur(n).map(e=>[`t`,e]),o=n.matchAll(/nostr:(npub1[023456789acdefghjklmnpqrstuvwxyz]+)/g),s=new Set;for(let e of o)try{let t=H.decode(e[1]);t.type===`npub`&&s.add(t.data)}catch{}s.delete(E.pubkey);for(let e of s)r.push([`p`,e]);let c=i&&(zo(i)||i.kind!==1);if(i&&!c&&!zo(i)){let e=i.tags.find(([e,,,t])=>e===`e`&&t===`root`);e?(r.push([`e`,e[1],e[2]||`wss://relay.ditto.pub/`,`root`,...e[4]?[e[4]]:[]]),r.push([`e`,i.id,gn,`reply`,i.pubkey])):r.push([`e`,i.id,gn,`root`,i.pubkey]);let t=new Set;t.add(i.pubkey);for(let e of i.tags)e[0]===`p`&&e[1]&&t.add(e[1]);E.pubkey&&t.delete(E.pubkey);for(let e of s)t.delete(e);for(let e of t)r.push([`p`,e])}let l=n.trim();if(yt&&a&&_t){if(a.kind>=3e4&&a.kind<4e4){let e=a.tags.find(([e])=>e===`d`)?.[1]??``;r.push([`q`,`${a.kind}:${a.pubkey}:${e}`,gn])}else r.push([`q`,a.id,gn,a.pubkey]);let e=`nostr:${_t}`;l.includes(e)||(l=l+` `+e)}if(r.push(...st()),j.length>0){let e=new Map(j.map(e=>[e.shortcode,e.url])),t=/:([a-zA-Z0-9_-]+):/g,n=new Set,i;for(;(i=t.exec(l))!==null;){let t=i[1];e.has(t)&&!n.has(t)&&(n.add(t),r.push([`emoji`,t,e.get(t)]))}}let u=l.matchAll(new RegExp($r.source,`gi`)),d=new Set;for(let e of u){let t=e[0];if(d.has(t))continue;d.add(t);let n=e[1].toLowerCase(),i=Ve.get(t);if(i){let e=i.map(e=>`${e[0]} ${e[1]}`);r.push([`imeta`,...e])}else{let e=ei(n);r.push([`imeta`,`url ${t}`,`m ${e}`])}}if(g){let e=await A({kind:g.kind,content:l,tags:[...g.tags,...r],created_at:Math.floor(Date.now()/1e3)});t?.(e)}else if(c){let e,t;if(i instanceof URL)e=i;else if(typeof i==`string`)e=i;else if(i.kind===1111){t=i;let n=i.tags.find(([e])=>e===`K`)?.[1],r=i.tags.find(([e])=>e===`P`)?.[1],a=i.tags.find(([e])=>e===`A`)?.[1],o=i.tags.find(([e])=>e===`E`)?.[1],s=i.tags.find(([e])=>e===`I`)?.[1];if(s){if(n===`#`)e=s;else try{e=new URL(s)}catch{e=s}}else{let t=n?parseInt(n,10):0,i=r??``;if(a){let n=a.split(`:`),r=n.length>=3?n.slice(2).join(`:`):``;e={id:o??``,kind:t,pubkey:i,content:``,created_at:0,sig:``,tags:[[`d`,r]]}}else e={id:o??``,kind:t,pubkey:i,content:``,created_at:0,sig:``,tags:[]}}}else e=i;await ie({root:e,reply:t,content:l,tags:r})}else await A({kind:1,content:l,tags:[...b??Ni,...r],created_at:Math.floor(Date.now()/1e3)});if(nt(),i&&!zo(i)&&M.setQueryData([`nip85-event-stats`,i.id,pe],e=>e&&{...e,commentCount:e.commentCount+1}),M.invalidateQueries({queryKey:[`feed`]}),M.invalidateQueries({queryKey:[`agora-feed`]}),M.invalidateQueries({queryKey:[`mixed-feed`]}),i){if(zo(i))M.invalidateQueries({queryKey:[`nostr`,`comments`]});else if(M.invalidateQueries({queryKey:[`replies`,i.id]}),i.kind!==1){let e=i.tags.find(([e])=>e===`d`)?.[1]??``,t=`${i.kind}:${i.pubkey}:${e}`;M.invalidateQueries({queryKey:[`event-comments`,t]})}}a&&(Oo(M,a,pe),M.invalidateQueries({queryKey:[`event-interactions`,a.id]})),Li(),g?.suppressSuccessToast||N({title:g?.successTitle??C(`compose.submit.posted`),description:g?.successDescription??C(i?`compose.submit.replyPublished`:a?`compose.submit.quotePublished`:`compose.submit.notePublished`)}),e?.()}catch{N({title:C(`common.error`),description:C(`compose.submit.publishFailed`),variant:`destructive`})}},Et=async()=>{let t=Me.filter(e=>e.label.trim()),n=P.trim();if(!n||t.length<2||!E||re)return;let r=[];for(let e of t)r.push([`option`,e.id,e.label.trim()]);r.push([`polltype`,Pe]),Ie>0&&r.push([`endsAt`,String(Math.floor(Date.now()/1e3)+Ie*86400)]);let a=n.matchAll(new RegExp($r.source,`gi`)),o=new Set;for(let e of a){let t=e[0];if(o.has(t))continue;o.add(t);let n=Ve.get(t);if(n)r.push([`imeta`,...n.map(e=>`${e[0]} ${e[1]}`)]);else{let n=e[1].toLowerCase();r.push([`imeta`,`url ${t}`,`m ${ei(n)}`])}}if(r.push([`alt`,`Poll: ${n}`]),i instanceof URL&&i.protocol===`iso3166:`){let e=i.toString();r.push([`I`,e]),r.push([`K`,`iso3166`]),r.push([`i`,e]),r.push([`k`,`iso3166`])}try{if(await A({kind:1068,content:n,tags:r}),nt(),M.invalidateQueries({queryKey:[`feed`]}),M.invalidateQueries({queryKey:[`agora-feed`]}),M.invalidateQueries({queryKey:[`mixed-feed`]}),i instanceof URL&&i.protocol===`iso3166:`){let e=i.pathname.toUpperCase();M.invalidateQueries({queryKey:[`agora-feed-paginated`,e]}),M.invalidateQueries({queryKey:[`agora-feed-new-posts`,e]})}Li(),N({title:C(`compose.poll.published`)}),e?.()}catch{N({title:C(`common.error`),description:C(`compose.poll.publishFailed`),variant:`destructive`})}},Dt=Me.filter(e=>e.label.trim()).length,Ot=P.trim().length>0&&Dt>=2,At=s||ve||P.length>0||!r;return!E&&r?null:(0,Z.jsxs)(`div`,{className:G(`relative px-4 pt-3 bg-background/85 flex flex-col`,s?`flex-1 min-h-0 rounded-2xl`:``,F?`pb-0`:`pb-3`,!s&&!l&&`border-b border-border`,u),children:[(0,Z.jsxs)(`div`,{className:G(`flex gap-3`,s&&`flex-1 min-h-0`),children:[!c&&E&&(O?(0,Z.jsx)(J,{className:`size-12 shrink-0 mt-0.5 rounded-full`}):(0,Z.jsx)(K,{to:k,className:`shrink-0`,children:(0,Z.jsxs)(Qn,{className:`size-12 shrink-0 mt-0.5`,children:[(0,Z.jsx)(Zn,{src:D?.picture,alt:D?.name}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary text-sm`,children:(D?.name||D?.display_name||er(E?.pubkey))[0]?.toUpperCase()??`?`})]})})),(0,Z.jsx)(`div`,{className:G(`flex-1 min-w-0`,s&&`flex flex-col min-h-0`),children:(0,Z.jsxs)(`div`,{className:G(s&&`flex-1 min-h-0 overflow-y-auto`),children:[(0,Z.jsxs)(`div`,{ref:We,className:`relative`,style:rt&&Ge?{minHeight:Ge}:void 0,children:[rt?bt&&(0,Z.jsx)(`div`,{className:`pt-2.5 pb-2 overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`text-lg leading-normal opacity-85 [&_img]:max-w-full [&_img]:h-auto`,children:(0,Z.jsx)(Jr,{event:bt,className:`text-foreground`})})}):(0,Z.jsx)(`textarea`,{ref:Ue,dir:`auto`,value:P,onChange:e=>_e(e.target.value),onPointerDown:L,onFocus:L,onPaste:wt,placeholder:Ae===`poll`?C(`compose.placeholderPoll`):w,className:G(`w-full bg-transparent text-foreground placeholder:text-muted-foreground resize-none outline-none text-lg leading-normal pt-2.5 pb-2 opacity-85 break-words overflow-hidden transition-[min-height] duration-200 ease-in-out`,At?`min-h-[100px]`:`min-h-[44px]`),rows:1,disabled:!E,autoFocus:s,onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&B()}}),!rt&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ca,{textareaRef:Ue,content:P,onInsertMention:R}),(0,Z.jsx)(xo,{textareaRef:Ue,content:P,onInsertEmoji:St})]})]}),Ae===`poll`&&(0,Z.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[h!==`poll`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>je(`post`),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsx)(ee,{className:`size-3.5 rtl:rotate-180`}),C(`compose.poll.backToPost`)]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[Me.map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{type:`text`,value:e.label,onChange:t=>Ne(n=>n.map(n=>n.id===e.id?{...n,label:t.target.value}:n)),placeholder:C(`compose.poll.optionLabel`,{number:t+1}),maxLength:100,className:`flex-1 bg-secondary/40 rounded-lg px-3 py-1.5 text-sm outline-none focus:ring-1 focus:ring-primary/40 placeholder:text-muted-foreground`}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{Me.length>2&&Ne(t=>t.filter(t=>t.id!==e.id))},disabled:Me.length<=2,className:`p-1 rounded-full text-muted-foreground hover:text-destructive transition-colors disabled:opacity-20`,children:(0,Z.jsx)(Ye,{className:`size-3.5`})})]},e.id)),Me.length<8&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Ne(e=>[...e,{id:Lo(),label:``}]),className:`flex items-center gap-1.5 text-xs text-primary hover:text-primary/80 transition-colors pt-0.5`,children:[(0,Z.jsx)(o,{className:`size-3`}),C(`compose.poll.addOption`)]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-0.5`,children:[[`singlechoice`,`multiplechoice`].map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Fe(e),className:G(`text-xs px-2.5 py-1 rounded-full border transition-colors`,Pe===e?`border-primary bg-primary/10 text-primary font-medium`:`border-border text-muted-foreground hover:text-foreground hover:border-foreground/30`),children:C(e===`singlechoice`?`compose.poll.singleChoice`:`compose.poll.multipleChoice`)},e)),(0,Z.jsx)(`div`,{className:`w-px bg-border self-stretch mx-0.5`}),[1,3,7,0].map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Le(e),className:G(`text-xs px-2.5 py-1 rounded-full border transition-colors`,Ie===e?`border-primary bg-primary/10 text-primary font-medium`:`border-border text-muted-foreground hover:text-foreground hover:border-foreground/30`),children:e===0?(0,Z.jsx)(`span`,{style:{fontSize:`15px`,lineHeight:1,position:`relative`,top:`-1px`},children:`∞`}):`${e}d`},e))]})]}),be&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)(Be,{className:`size-4 text-amber-500 shrink-0`}),(0,Z.jsx)(In,{value:Se,onChange:e=>Ce(e.target.value),placeholder:C(`compose.placeholderCwReason`),className:`h-8 text-base md:text-sm bg-secondary/50 border-0 rounded-lg`}),(0,Z.jsx)(`button`,{onClick:()=>{xe(!1),Ce(``)},className:`p-1 rounded-full text-muted-foreground hover:text-foreground transition-colors shrink-0`,children:(0,Z.jsx)(Ye,{className:`size-4`})})]}),yt&&a&&vt&&(0,Z.jsx)(`div`,{className:`mt-4 mb-3 overflow-hidden`,children:a.kind>=3e4&&a.kind<4e4?(0,Z.jsx)(Er,{addr:{kind:a.kind,pubkey:a.pubkey,identifier:a.tags.find(([e])=>e===`d`)?.[1]??``}}):(0,Z.jsx)(ti,{eventId:a.id,authorHint:a.pubkey})})]})})]}),At&&Ae===`post`&&ot<=100&&(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-1.5`,children:[(0,Z.jsx)(Bo,{count:at,max:Io}),(0,Z.jsx)(`span`,{className:G(`text-xs tabular-nums`,ot<0?`text-destructive font-semibold`:`text-amber-500`),children:ot})]}),At&&(Qe.isRecording||$e?(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 mt-3 rounded-xl bg-destructive/5 border border-destructive/20 px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`size-2.5 rounded-full bg-destructive animate-pulse shrink-0`}),(0,Z.jsx)(`span`,{className:`text-sm font-medium tabular-nums text-destructive`,children:zr(Qe.recordingDuration)})]}),(0,Z.jsx)(`div`,{className:`flex-1 flex items-center gap-[2px] h-6 overflow-hidden`,children:Qe.liveWaveform.slice(-60).map((e,t)=>{let n=3+e/100*21;return(0,Z.jsx)(`div`,{className:`w-[3px] shrink-0 rounded-full bg-destructive/60`,style:{height:`${n}px`}},t)})}),(0,Z.jsxs)(Cn,{children:[(0,Z.jsx)(xn,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,onClick:Qe.cancelRecording,disabled:$e,className:`p-2 rounded-full text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-40`,children:(0,Z.jsx)(Ye,{className:`size-[18px]`})})}),(0,Z.jsx)(Sn,{children:C(`compose.voice.cancel`)})]}),(0,Z.jsxs)(q,{onClick:Tt,disabled:$e||Qe.recordingDuration<.5,className:`rounded-full px-4 font-bold`,size:`sm`,children:[$e?(0,Z.jsx)(Xe,{className:`size-4 animate-spin mr-1.5`}):(0,Z.jsx)(m,{className:`size-3.5 mr-1.5`,fill:`currentColor`}),C($e?`compose.voice.sending`:`compose.voice.send`)]})]}):(0,Z.jsxs)(`div`,{className:G(`flex items-center justify-between mt-3`,s&&`shrink-0`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsxs)(Cn,{children:[(0,Z.jsx)(xn,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>Ze.current?.click(),disabled:se||!E,className:`p-2 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors disabled:opacity-40`,children:se?(0,Z.jsx)(Xe,{className:`size-[18px] animate-spin`}):(0,Z.jsx)(te,{className:`size-[18px]`})})}),(0,Z.jsx)(Sn,{children:C(`compose.toolbar.attachFile`)})]}),(0,Z.jsx)(`input`,{ref:Ze,type:`file`,accept:`image/*,video/*,audio/*`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&Array.from(t).forEach(e=>Ct(e)),e.target.value=``}}),(0,Z.jsxs)(Cn,{children:[(0,Z.jsx)(xn,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>we(e=>!e),className:G(`p-2 rounded-full transition-colors`,F?`text-primary bg-primary/10`:`text-muted-foreground hover:text-primary hover:bg-primary/10`),children:(0,Z.jsx)(ge,{className:`size-[18px]`})})}),!F&&(0,Z.jsx)(Sn,{children:C(`compose.toolbar.emojiGif`)})]}),(0,Z.jsxs)(Ai,{open:Ee,onOpenChange:De,children:[(0,Z.jsxs)(Cn,{children:[(0,Z.jsx)(xn,{asChild:!0,children:(0,Z.jsx)(Oi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,disabled:!E,className:G(`p-2 rounded-full transition-colors disabled:opacity-40`,Ee||Ae===`poll`||be?`text-primary bg-primary/10`:`text-muted-foreground hover:text-primary hover:bg-primary/10`),children:(0,Z.jsx)(o,{className:`size-[18px]`,strokeWidth:2.5})})})}),!Ee&&(0,Z.jsx)(Sn,{children:C(`compose.toolbar.more`)})]}),(0,Z.jsx)(ki,{side:`top`,align:`start`,sideOffset:6,className:`w-48 p-1.5 rounded-xl border-border shadow-lg`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[Qe.isSupported&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{z(),De(!1)},disabled:!E,className:`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-sm transition-colors text-muted-foreground hover:text-foreground hover:bg-secondary/60 disabled:opacity-40`,children:[(0,Z.jsx)(tt,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:C(`compose.voice.voiceMessage`)})]}),!v&&(!i||i instanceof URL)&&!g&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{je(e=>e===`poll`?`post`:`poll`),De(!1),L()},className:G(`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-sm transition-colors`,Ae===`poll`?`text-primary bg-primary/10`:`text-muted-foreground hover:text-foreground hover:bg-secondary/60`),children:[(0,Z.jsx)(x,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:C(`compose.toolbar.poll`)})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>{xe(e=>!e),De(!1),L()},className:G(`flex items-center gap-2.5 w-full px-3 py-2 rounded-lg text-sm transition-colors`,be?`text-amber-500 bg-amber-500/10`:`text-muted-foreground hover:text-foreground hover:bg-secondary/60`),children:[(0,Z.jsx)(Be,{className:`size-4`}),(0,Z.jsx)(`span`,{className:`font-medium`,children:C(`compose.toolbar.spoiler`)})]})]})})]})]}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[P.trim().length>0&&d===void 0&&(0,Z.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>ke(e=>!e),"aria-pressed":rt,className:G(`rounded-full px-3 font-medium`,rt?`bg-primary/15 text-primary hover:bg-primary/20 hover:text-primary`:`text-muted-foreground`),children:C(`compose.preview.previewMode`)}),Ae===`poll`?(0,Z.jsx)(q,{onClick:Et,disabled:!Ot||re||!E,className:`rounded-full px-5 font-bold text-white`,size:`sm`,children:C(re?`compose.poll.publishing`:`compose.poll.publish`)}):(0,Z.jsx)(q,{onClick:B,disabled:!P.trim()||ne||ae||!E||at>Io,className:`rounded-full px-5 font-bold text-white`,size:`sm`,children:ne||ae?C(`compose.submit.posting`):T})]})]})),F&&(0,Z.jsxs)(`div`,{className:G(`-mx-4 shrink-0 overflow-hidden animate-in fade-in-0 duration-150`,s&&`rounded-b-2xl`),children:[(0,Z.jsxs)(`div`,{className:`flex gap-1 px-3 pt-2`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Te(`emoji`),className:G(`flex items-center justify-center gap-1.5 px-4 py-1.5 rounded-full text-sm font-medium transition-colors`,I===`emoji`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:[(0,Z.jsx)(ge,{className:`size-3.5`}),C(`compose.toolbar.emoji`)]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Te(`gif`),className:G(`flex items-center justify-center gap-1.5 px-4 py-1.5 rounded-full text-sm font-medium transition-colors`,I===`gif`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:[(0,Z.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 18 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":`true`,children:[(0,Z.jsx)(`rect`,{x:`1`,y:`1`,width:`16`,height:`16`,rx:`3`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`}),(0,Z.jsx)(`text`,{x:`9`,y:`9`,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`7`,fontWeight:`700`,fontFamily:`system-ui,sans-serif`,fill:`currentColor`,letterSpacing:`0.5`,children:`GIF`})]}),`GIF`]}),j.length>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Te(`stickers`),className:G(`flex items-center justify-center gap-1.5 px-4 py-1.5 rounded-full text-sm font-medium transition-colors`,I===`stickers`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:[(0,Z.jsx)(_,{className:`size-3.5`}),C(`compose.toolbar.stickers`)]})]}),I===`emoji`?(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`w-full h-[280px] flex items-center justify-center`,children:(0,Z.jsx)(Xe,{className:`size-6 animate-spin text-muted-foreground`})}),children:(0,Z.jsx)(Fo,{customEmojis:j,onSelect:e=>{e.type===`native`?xt(e.emoji):xt(`:${e.shortcode}:`)}})}):I===`stickers`?(0,Z.jsx)(So,{customEmojis:j,height:280,autoFocus:!me,onSelect:e=>{_e(t=>t?t+` `+e.url:e.url),we(!1),L()}}):(0,Z.jsx)(po,{onSelect:e=>{_e(t=>t?t+` `+e.url:e.url),we(!1),L()}})]})]})}function Ho(e,t){return e.find(([e])=>e===t)?.[1]}function Uo(e){for(let t of e){if(t[0]!==`imeta`)continue;let e={};for(let n=1;ne===`a`||e===`e`).map(([,e])=>e),isAlbum:e.tags.filter(([e])=>e===`t`).map(([,e])=>e?.toLowerCase()).includes(`album`),released:Ho(e.tags,`released`),label:Ho(e.tags,`label`)}}function Ko(e){let t=Ho(e.tags,`d`)??``;return`/`+H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}function qo(e,t){return{id:e.id,title:t.title,artist:t.artist,url:t.url,artwork:t.artwork,duration:t.duration,path:Ko(e)}}function Jo(e,t){return e.find(([e])=>e===t)?.[1]}function Yo(e){for(let t of e){if(t[0]!==`imeta`)continue;let e={};for(let n=1;ne===`audio`),i=r?.[1]??n.url??Jo(e.tags,`url`)??Jo(e.tags,`media`);if(!i)return null;let a=r?.[2],o=n.duration??Jo(e.tags,`duration`),s=o?parseFloat(o):void 0,c=Jo(e.tags,`pubdate`)??Jo(e.tags,`published_at`),l;if(c){let t=parseInt(c,10);if(isFinite(t)&&String(t)===c)l=t;else{let t=new Date(c);l=isFinite(t.getTime())?Math.floor(t.getTime()/1e3):e.created_at}}else l=e.created_at;return{title:t,audioUrl:i,audioMime:a??n.mime??Jo(e.tags,`m`),pubdate:l&&isFinite(l)?l:void 0,description:Jo(e.tags,`description`)||e.content||``,artwork:Jo(e.tags,`image`)??n.thumbnail??Jo(e.tags,`thumb`),duration:s&&isFinite(s)?s:void 0}}function Zo(e){let t=Jo(e.tags,`title`)??Jo(e.tags,`subject`)??`Trailer`,n=Yo(e.tags).url??Jo(e.tags,`url`)??Jo(e.tags,`media`);return n?{title:t,url:n,pubdate:e.created_at,type:Jo(e.tags,`type`),season:Jo(e.tags,`season`)}:null}function Qo(e,t){return e.find(([e])=>e===t)?.[1]}function $o(e){let t=Qo(e.tags,`d`)??``;return`/`+H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}function es(e,t){return{id:e.id,title:t.title,artist:``,url:t.audioUrl,artwork:t.artwork,duration:t.duration,path:$o(e)}}function ts(e,t){return{id:e.id,title:t.title,artist:``,url:t.url,path:$o(e)}}function ns({isPlaying:e,isActive:t,onClick:n,size:r=`lg`}){let i=r===`lg`?`size-12`:`size-10`,a=r===`lg`?`size-5`:`size-4`;return(0,Z.jsx)(`button`,{onClick:n,className:G(`shrink-0 rounded-full flex items-center justify-center transition-colors`,i,t&&e?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`),"aria-label":t&&e?`Pause`:`Play`,children:t&&e?(0,Z.jsx)(Ve,{className:a,fill:`currentColor`}):(0,Z.jsx)(pt,{className:G(a,`ml-0.5`),fill:`currentColor`})})}function rs({event:e}){let t=no(),n=(0,Q.useMemo)(()=>Wo(e),[e]),r=z(e.pubkey),i=Jn();if(!n)return null;let a=t.currentTrack?.id===e.id,o=n.duration?zr(n.duration):void 0,s=i=>{if(i.stopPropagation(),a&&t.isPlaying)t.pause();else if(a)t.resume();else{let i=qo(e,n);i.artwork??=r.data?.metadata?.picture,t.playTrack(i)}};return(0,Z.jsxs)(`div`,{className:G(`mt-3 rounded-2xl border overflow-hidden`,a?`border-primary bg-primary/5`:`border-border`),children:[n.artwork?(0,Z.jsxs)(`div`,{className:`relative aspect-square max-h-[280px] w-full overflow-hidden cursor-pointer`,onClick:s,children:[(0,Z.jsx)(`img`,{src:i(n.artwork,600),alt:n.title,className:`w-full h-full object-cover`,loading:`lazy`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 hover:bg-black/10 transition-colors`,children:(0,Z.jsx)(ns,{isPlaying:t.isPlaying,isActive:a,onClick:s,size:`lg`})})]}):(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[140px] cursor-pointer`,onClick:s,children:[(0,Z.jsx)(bt,{className:`size-10 text-primary`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Z.jsx)(ns,{isPlaying:t.isPlaying,isActive:a,onClick:s,size:`lg`})})]}),(0,Z.jsxs)(`div`,{className:`p-3.5 space-y-1.5 cursor-pointer`,children:[(0,Z.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug truncate`,children:n.title}),n.artist&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:n.artist}),o&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ht,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:o})]})]})]})}function is({event:e}){let t=(0,Q.useMemo)(()=>Go(e),[e]),n=Jn();if(!t)return null;let r=t.trackRefs.length;return(0,Z.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-border overflow-hidden cursor-pointer`,children:[t.artwork?(0,Z.jsx)(`div`,{className:`aspect-video max-h-[200px] w-full overflow-hidden`,children:(0,Z.jsx)(`img`,{src:n(t.artwork,600),alt:t.title,className:`w-full h-full object-cover`,loading:`lazy`})}):(0,Z.jsx)(`div`,{className:`flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[100px]`,children:(0,Z.jsx)(lt,{className:`size-10 text-primary`})}),(0,Z.jsxs)(`div`,{className:`p-3.5 space-y-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug truncate`,children:t.title}),t.description&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:t.description}),r>0&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(lt,{className:`size-3 shrink-0`}),(0,Z.jsxs)(`span`,{children:[r,` track`,r===1?``:`s`]})]})]})]})}function as({event:e}){let t=no(),n=(0,Q.useMemo)(()=>Xo(e),[e]),r=z(e.pubkey),i=Jn(),a=lr(r.data?.metadata,e.pubkey);if(!n)return null;let o=t.currentTrack?.id===e.id,s=n.duration?zr(n.duration):void 0,c=i=>{if(i.stopPropagation(),o&&t.isPlaying)t.pause();else if(o)t.resume();else{let i=es(e,n);i.artist=a,i.artwork??=r.data?.metadata?.picture,t.playTrack(i)}};return(0,Z.jsxs)(`div`,{className:G(`mt-3 rounded-2xl border overflow-hidden`,o?`border-primary bg-primary/5`:`border-border`),children:[n.artwork?(0,Z.jsxs)(`div`,{className:`relative aspect-square max-h-[280px] w-full overflow-hidden cursor-pointer`,onClick:c,children:[(0,Z.jsx)(`img`,{src:i(n.artwork,600),alt:n.title,className:`w-full h-full object-cover`,loading:`lazy`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 hover:bg-black/10 transition-colors`,children:(0,Z.jsx)(ns,{isPlaying:t.isPlaying,isActive:o,onClick:c,size:`lg`})})]}):(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[140px] cursor-pointer`,onClick:c,children:[(0,Z.jsx)(le,{className:`size-10 text-primary`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Z.jsx)(ns,{isPlaying:t.isPlaying,isActive:o,onClick:c,size:`lg`})})]}),(0,Z.jsxs)(`div`,{className:`p-3.5 space-y-1.5 cursor-pointer`,children:[(0,Z.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug line-clamp-2`,children:n.title}),n.description&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:n.description}),s&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ht,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:s})]})]})]})}function os({event:e}){let t=no(),n=(0,Q.useMemo)(()=>Zo(e),[e]),r=z(e.pubkey),i=lr(r.data?.metadata,e.pubkey);if(!n)return null;let a=t.currentTrack?.id===e.id,o=o=>{if(o.stopPropagation(),a&&t.isPlaying)t.pause();else if(a)t.resume();else{let a=ts(e,n);a.artist=i,a.artwork??=r.data?.metadata?.picture,t.playTrack(a)}};return(0,Z.jsxs)(`div`,{className:G(`mt-3 rounded-2xl border overflow-hidden`,a?`border-primary bg-primary/5`:`border-border`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent h-[100px] relative cursor-pointer`,onClick:o,children:[(0,Z.jsx)(le,{className:`size-8 text-primary`}),(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Z.jsx)(ns,{isPlaying:t.isPlaying,isActive:a,onClick:o,size:`lg`})})]}),(0,Z.jsxs)(`div`,{className:`p-3.5 space-y-1 cursor-pointer`,children:[(0,Z.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug truncate`,children:n.title}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Trailer`})]})]})}function ss({image:e,fallbackIcon:t,title:n,description:r,meta:i}){return(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-gradient-to-br from-primary/15 via-primary/5 to-secondary`,children:e?(0,Z.jsx)(Ht,{src:e,width:600,gated:!0,alt:``,loading:`lazy`,className:`aspect-[16/7] w-full object-cover`}):(0,Z.jsx)(`div`,{className:`flex aspect-[16/7] items-center justify-center text-primary/45`,children:t})}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`h3`,{className:`text-base font-bold leading-tight tracking-tight line-clamp-2`,children:n}),r?.trim()?(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground line-clamp-3`,children:r}):null,i]})]})}function cs({event:e}){let{t}=Fn(),n=Yi(e),{data:r}=Vi(),i=(0,Q.useRef)(null),a=Rt(i),{data:o}=Wt(n??void 0,{enabled:a}),s=z(e.pubkey),c=s.data?.metadata?.nip05,{data:l}=At(c,e.pubkey),{data:u}=Bt();if(!n)return null;let d=s.data?.metadata,f=Y(n.banner)??Y(d?.banner)??Y(d?.picture),p=Ji(n,{nip05:c,nip05Verified:l===!0,directoryName:u?.get(e.pubkey),appHost:mn}),m=ta(n),h=!n.wallets.onchain,g=!!n.wallets.sp,_=n.goalUsd&&n.goalUsd>0?oa(n.goalUsd):void 0,v=o?.totalSats??0,y=v>0;return(0,Z.jsx)(K,{ref:i,to:p,onClick:e=>e.stopPropagation(),className:`block rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:(0,Z.jsx)(ss,{image:f,fallbackIcon:(0,Z.jsx)(b,{className:`size-12`}),title:n.title,description:n.story,meta:(0,Z.jsxs)(`div`,{className:`space-y-1 pt-1`,children:[h?(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ze,{className:`size-3.5 shrink-0`}),_?t(`campaignsDetail.target`,{amount:_}):t(`campaignsDetail.privateCampaign`)]}):(0,Z.jsxs)(Z.Fragment,{children:[y?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(Ut,{className:`text-lg text-primary`,children:sa(v,r)}),(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-muted-foreground`,children:t(g?`campaignsDetail.raisedPublicly`:`campaignsDetail.raised`)})]}):(0,Z.jsx)(`div`,{className:`text-sm font-bold leading-tight text-primary`,children:t(`campaignsDetail.beFirstDonor`)}),_&&(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(y?`campaignsDetail.ofGoal`:`campaignsDetail.goalAmount`,{amount:_})})]}),m&&(0,Z.jsx)(`div`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:m})]})})})}function ls({event:e}){let{t}=Fn(),r=Bi(e),{data:a}=Vi();if(!r)return null;let o=H.naddrEncode({kind:36639,pubkey:r.pubkey,identifier:r.id}),s=r.countryCode?Hi(r.countryCode):void 0,c=r.deadline?pa(r.deadline):void 0;return(0,Z.jsx)(K,{to:`/${o}`,onClick:e=>e.stopPropagation(),className:`block rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:(0,Z.jsx)(ss,{image:r.image,fallbackIcon:(0,Z.jsx)(n,{className:`size-12`}),title:r.title,description:r.description,meta:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 pt-1 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`font-semibold uppercase tracking-wide text-primary`,children:t(`pledges.card.pledged`)}),(0,Z.jsx)(`span`,{className:`text-sm font-bold text-foreground`,children:ma(r.bounty,a)})]}),s&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(st,{className:`size-3.5`}),s]}),c&&(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center gap-1.5`,c.isPast&&`text-destructive`),children:[(0,Z.jsx)(i,{className:`size-3.5`}),c.label]})]})})})}function us({event:e}){let{t}=Fn(),n=_i(e);if(!n)return null;let r=H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:n.dTag}),i=n.countryCode?Hi(n.countryCode):void 0;return(0,Z.jsx)(K,{to:`/${r}`,onClick:e=>e.stopPropagation(),className:`block rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:(0,Z.jsx)(ss,{image:n.image,fallbackIcon:(0,Z.jsx)(I,{className:`size-12`}),title:n.name,description:n.description,meta:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 pt-1 text-xs text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(I,{className:`size-3.5`}),t(`groups.create.moderatorsCount`,{count:n.moderatorPubkeys.length})]}),i&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(st,{className:`size-3.5`}),i]})]})})})}function ds(){let{user:e}=U(),{nostr:t}=R(),n=V(),{mutateAsync:r}=ln();return Lt({mutationFn:async({aTag:n,awardEventId:i})=>{if(!e)throw Error(`User is not logged in`);let a=await _r(t,e.pubkey),o=a?.tags??[[`d`,`profile_badges`]];if(o.some(([e,t],r)=>e===`a`&&t===n&&o[r+1]?.[0]===`e`&&o[r+1]?.[1]===i))return;let s=[...o.filter(([e,t])=>e!==`d`||t!==`profile_badges`),[`a`,n],[`e`,i]];await r({kind:Qr,content:``,tags:s,prev:a??void 0})},onSuccess:()=>{n.invalidateQueries({queryKey:[`profile-badges`,e?.pubkey]})}})}function fs({awardEvent:e,prominent:t}){let{user:n}=U(),{refs:r}=kr(n?.pubkey),{mutate:i,isPending:a,isSuccess:o}=ds(),s=e.tags.find(([e,t])=>e===`a`&&t?.startsWith(`30009:`))?.[1],c=r.some(e=>e.aTag===s)||o;return!s||!n?null:c?(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center gap-1 text-muted-foreground`,t?`text-sm`:`text-xs`),children:[(0,Z.jsx)(f,{className:t?`size-4`:`size-3`}),`Accepted`]}):t?(0,Z.jsx)(q,{className:`rounded-full px-6 h-10 text-sm font-semibold gap-2 shadow-md hover:scale-105 active:scale-95 transition-all`,onClick:t=>{t.stopPropagation(),i({aTag:s,awardEventId:e.id})},disabled:a,style:{filter:`drop-shadow(0 2px 8px hsl(var(--primary) / 0.25))`},children:a?(0,Z.jsx)(Xe,{className:`size-4 animate-spin`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{className:`size-4`}),`Accept Badge`]})}):(0,Z.jsx)(q,{size:`sm`,variant:`outline`,className:`h-7 px-2.5 text-xs font-medium gap-1 transition-colors hover:bg-primary hover:text-primary-foreground`,onClick:t=>{t.stopPropagation(),i({aTag:s,awardEventId:e.id})},disabled:a,children:a?(0,Z.jsx)(Xe,{className:`size-3 animate-spin`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(L,{className:`size-3`}),`Accept`]})})}function ps({event:e}){let t=(0,Q.useMemo)(()=>Dr(e),[e]);if(!t)return null;let n=t.image??t.thumbs.find(e=>e.dimensions===`512x512`)?.url??t.thumbs[0]?.url;return(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsxs)(`div`,{className:`relative isolate flex flex-col items-center py-10 overflow-hidden rounded-2xl`,children:[(0,Z.jsx)(`div`,{className:`absolute -z-10 pointer-events-none`,"aria-hidden":`true`,style:{width:360,height:360,top:`50%`,left:`50%`,transform:`translate(-50%, -55%)`},children:(0,Z.jsx)(`div`,{className:`w-full h-full animate-badge-spotlight`,style:{background:`repeating-conic-gradient( hsl(var(--primary) / 0.08) 0deg 6deg, transparent 6deg 18deg )`,maskImage:`radial-gradient(circle, black 15%, transparent 70%)`,WebkitMaskImage:`radial-gradient(circle, black 15%, transparent 70%)`}})}),(0,Z.jsx)(hs,{heroImage:n,badgeName:t.name}),(0,Z.jsxs)(`div`,{className:`relative z-[1] mt-4 text-center px-6 max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`text-[15px] font-semibold leading-snug`,children:t.name}),t.description&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t.description})]})]})})}var ms=48;function hs({heroImage:e,badgeName:t}){let n=Or(25,1.08),r=(0,Q.useRef)(null),i=Jn(),[a,o]=(0,Q.useState)(!1),s=e&&i(e,256),c=s!==e,l=a||!c?e:s,u=l?{maskImage:`url(${l})`,WebkitMaskImage:`url(${l})`,maskSize:`cover`,WebkitMaskSize:`cover`,maskRepeat:`no-repeat`,WebkitMaskRepeat:`no-repeat`,maskPosition:`center`,WebkitMaskPosition:`center`}:void 0,d=(0,Q.useCallback)(e=>{if(e.pointerType===`touch`)return;n.onPointerMove(e);let t=n.ref.current,i=r.current;if(!t||!i)return;let a=t.getBoundingClientRect(),o=(e.clientX-a.left-ms)/(a.width-96)*100,s=(e.clientY-a.top-ms)/(a.height-96)*100;i.style.background=`radial-gradient(circle at ${o}% ${s}%, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.08) 35%, transparent 65%)`,i.style.opacity=`1`},[n]),f=(0,Q.useCallback)(e=>{if(e.pointerType===`touch`)return;n.onPointerLeave(e);let t=r.current;t&&(t.style.opacity=`0`)},[n]),p={...n.style,touchAction:`auto`,transformStyle:`preserve-3d`,padding:ms,margin:-48};return(0,Z.jsxs)(`div`,{ref:n.ref,style:p,onPointerMove:d,onPointerLeave:f,className:`relative z-[1] select-none`,children:[l?(0,Z.jsx)(`img`,{src:l,alt:t,className:`size-28 rounded-2xl object-cover drop-shadow-lg`,loading:`lazy`,decoding:`async`,onError:()=>{c&&!a&&o(!0)}}):(0,Z.jsx)(`div`,{className:`size-28 rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-transparent flex items-center justify-center`,children:(0,Z.jsx)(L,{className:`size-12 text-primary`})}),l&&u&&(0,Z.jsx)(`div`,{ref:r,className:`absolute pointer-events-none`,style:{inset:ms,opacity:0,transition:`opacity 0.4s ease-out`,mixBlendMode:`overlay`,...u},"aria-hidden":`true`})]})}function gs({event:e}){let{user:t}=U(),n=(0,Q.useMemo)(()=>jr(e),[e]),r=(0,Q.useMemo)(()=>Mr(e),[e]),i=r&&r.pubkey===e.pubkey?r:void 0,a=(0,Q.useMemo)(()=>i?[i]:[],[i]),{badgeMap:o}=hr(a),s=i?`${vr}:${i.pubkey}:${i.identifier}`:void 0,c=(s?o.get(s):void 0)?.event,l=(0,Q.useMemo)(()=>i?H.naddrEncode({kind:vr,pubkey:i.pubkey,identifier:i.identifier}):void 0,[i]),u=t?Ar(e,t.pubkey):!1,d=n[0],f=Math.max(n.length-1,0);return(0,Z.jsxs)(`div`,{className:`mt-1 space-y-2`,children:[d&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:`to`}),(0,Z.jsx)(_s,{pubkey:d}),f>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`and `,f,` `,f===1?`other`:`others`]})]}),c?l?(0,Z.jsx)(K,{to:`/${l}`,className:`block`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(ps,{event:c})}):(0,Z.jsx)(ps,{event:c}):(0,Z.jsx)(vs,{name:i?Cr(i.identifier):void 0,href:l?`/${l}`:void 0}),u&&(0,Z.jsx)(`div`,{className:`flex justify-center pt-1`,children:(0,Z.jsx)(fs,{awardEvent:e,prominent:!0})})]})}function _s({pubkey:e}){let t=z(e),n=t.data?.metadata,r=n?.name??n?.display_name??er(e),i=kt(e,n);return t.isLoading?(0,Z.jsx)(J,{className:`h-3.5 w-24 inline-block`}):(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsx)(K,{to:i,className:`font-semibold text-foreground hover:underline truncate max-w-[14rem]`,onClick:e=>e.stopPropagation(),children:t.data?.event?(0,Z.jsx)(li,{tags:t.data.event.tags,children:r}):r})})}function vs({name:e,href:t}){let n=(0,Z.jsxs)(`div`,{className:`mt-3 rounded-2xl border border-dashed border-border py-10 px-6 flex flex-col items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`size-20 rounded-2xl bg-gradient-to-br from-primary/10 via-primary/5 to-transparent flex items-center justify-center`,children:(0,Z.jsx)(L,{className:`size-8 text-primary`})}),e?(0,Z.jsx)(`p`,{className:`text-sm font-semibold text-center`,children:e}):(0,Z.jsx)(J,{className:`h-4 w-32`})]});return t?(0,Z.jsx)(K,{to:t,className:`block`,onClick:e=>e.stopPropagation(),children:n}):n}var ys={sm:`size-6 text-[10px]`,md:`size-8 text-xs`},bs={sm:`-space-x-1.5`,md:`-space-x-2`};function xs({pubkey:e,size:t=`sm`}){let{data:n}=z(e),r=n?.metadata,i=r?.display_name||r?.name||er(e),a=i.charAt(0).toUpperCase();return(0,Z.jsxs)(Cn,{children:[(0,Z.jsx)(xn,{asChild:!0,children:(0,Z.jsxs)(Qn,{className:G(ys[t],`ring-2 ring-background`),children:[(0,Z.jsx)(Zn,{src:r?.picture}),(0,Z.jsx)(Xn,{className:`bg-muted text-muted-foreground`,children:a})]})}),(0,Z.jsx)(Sn,{side:`bottom`,className:`text-xs`,children:i})]})}function Ss({pubkeys:e,maxVisible:t=5,size:n=`sm`,className:r}){let i=e.slice(0,t),a=e.length-t;return(0,Z.jsxs)(`div`,{className:G(`flex items-center`,bs[n],r),children:[i.map(e=>(0,Z.jsx)(xs,{pubkey:e,size:n},e)),a>0&&(0,Z.jsxs)(`span`,{className:`pl-2.5 text-xs text-muted-foreground`,children:[`+`,a]})]})}function Cs(e,t){return e.find(([e])=>e===t)?.[1]}function ws(e,t){return e.filter(([e])=>e===t)}function Ts(e){let t=e.trim();if(!t.startsWith(`{`))return e;try{let e=JSON.parse(t);if(typeof e.description==`string`&&e.description)return e.description;if(typeof e.name==`string`&&e.name)return e.name;if(typeof e.address==`string`&&e.address)return e.address}catch{}return e}var Es=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,year:`numeric`}),Ds=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`}),Os=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`});function ks(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function As(e){let t=Cs(e.tags,`start`);if(!t)return``;if(e.kind===31922){let n=new Date(`${t}T00:00:00Z`);if(isNaN(n.getTime()))return t;let r=Cs(e.tags,`end`);if(r){let e=new Date(`${r}T00:00:00Z`);if(!isNaN(e.getTime())&&e>n){let t=new Date(e.getTime()-864e5);if(t>n)return`${Es.format(n).replace(/, \d{4}$/,``)} - ${Es.format(t)}`}}return Es.format(n)}if(e.kind===31923){let n=parseInt(t,10);if(isNaN(n))return t;let r=new Date(n*1e3),i=Cs(e.tags,`end`);if(i){let e=parseInt(i,10);if(!isNaN(e)&&e>n){let t=new Date(e*1e3);return ks(r,t)?`${Ds.format(r)} - ${Os.format(t)}`:`${Ds.format(r)} - ${Ds.format(t)}`}}return Ds.format(r)}return t}function js(e){let t=Cs(e.tags,`start`);if(!t)return 0;if(e.kind===31922){let n=Cs(e.tags,`end`),r=new Date(`${n||t}T00:00:00Z`);return isNaN(r.getTime())?0:Math.floor(r.getTime()/1e3)+(n?0:86400)}let n=Cs(e.tags,`end`)||t,r=parseInt(n,10);return isNaN(r)?0:r}function Ms({event:e,compact:t,className:n}){let r=(0,Q.useMemo)(()=>Cs(e.tags,`title`),[e.tags]),i=(0,Q.useMemo)(()=>Y(Cs(e.tags,`image`)),[e.tags]),a=(0,Q.useMemo)(()=>Cs(e.tags,`location`),[e.tags]),o=(0,Q.useMemo)(()=>a?Ts(a):void 0,[a]),s=(0,Q.useMemo)(()=>As(e),[e]),c=(0,Q.useMemo)(()=>ws(e.tags,`t`).map(([,e])=>e).filter(Boolean),[e.tags]),l=(0,Q.useMemo)(()=>ws(e.tags,`p`),[e.tags]),u=(0,Q.useMemo)(()=>Cs(e.tags,`summary`),[e.tags]),d=(0,Q.useMemo)(()=>js(e)0,p=(0,Q.useMemo)(()=>l.map(([,e])=>e).filter(Boolean),[l]);return t?(0,Z.jsxs)(`div`,{className:G(`mt-3 space-y-3`,n),children:[i&&(0,Z.jsxs)(`div`,{className:`relative -mx-4 aspect-[21/9] overflow-hidden`,children:[(0,Z.jsx)(Ht,{src:i,width:600,gated:!0,alt:r??`Calendar event`,className:`w-full h-full object-cover`,loading:`lazy`}),p.length>0&&(0,Z.jsx)(`div`,{className:`absolute bottom-2 left-3`,children:(0,Z.jsx)(Ss,{pubkeys:p,maxVisible:4,size:`md`})})]}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(yt,{className:`size-4 text-primary shrink-0`}),(0,Z.jsx)(`h3`,{className:`font-semibold text-[15px] leading-tight line-clamp-2`,children:r??`Untitled event`})]}),d?(0,Z.jsx)(X,{variant:`secondary`,className:`shrink-0`,children:`Ended`}):s?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground shrink-0 max-w-[45%]`,children:[(0,Z.jsx)(ht,{className:`size-3`}),(0,Z.jsx)(`span`,{className:`truncate`,children:s})]}):null]}),s&&d&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ht,{className:`size-3`}),(0,Z.jsx)(`span`,{children:s})]}),(u||f)&&(0,Z.jsx)(`div`,{className:`text-sm text-muted-foreground leading-relaxed line-clamp-2`,children:u&&!f?(0,Z.jsx)(`p`,{children:u}):(0,Z.jsx)(Jr,{event:e,className:`text-sm`,hideEmbedImages:!0})}),(o||p.length>0)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-lg bg-muted/50 px-3 py-2`,children:[o?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(st,{className:`h-4 w-4 shrink-0 text-red-500`}),(0,Z.jsx)(`span`,{className:`text-sm truncate flex-1`,children:o})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(I,{className:`h-4 w-4 shrink-0 text-primary`}),(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground flex-1`,children:`Participants`})]}),p.length>0&&(0,Z.jsx)(Ss,{pubkeys:p,maxVisible:4,size:`sm`})]}),c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:c.slice(0,4).map(e=>(0,Z.jsx)(X,{variant:`secondary`,className:`text-[11px] px-2 py-0.5`,children:e},e))})]}):(0,Z.jsxs)(`div`,{className:G(`mt-2 rounded-xl border border-border overflow-hidden`,n),children:[i?(0,Z.jsx)(`div`,{className:`aspect-video rounded-lg overflow-hidden`,children:(0,Z.jsx)(Ht,{src:i,width:600,gated:!0,alt:r??`Calendar event`,className:`h-full w-full object-cover`,loading:`lazy`})}):(0,Z.jsx)(`div`,{className:`flex items-center justify-center bg-gradient-to-br from-primary/10 via-primary/5 to-transparent py-8`,children:(0,Z.jsx)(yt,{className:`h-10 w-10 text-primary`})}),(0,Z.jsxs)(`div`,{className:`space-y-2 p-3`,children:[r&&(0,Z.jsx)(`h3`,{className:`text-[15px] font-semibold leading-snug`,children:r}),s&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ht,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:s})]}),o&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(st,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:o})]}),l.length>0&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`h-3.5 w-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[l.length,` `,l.length===1?`participant`:`participants`]})]}),u&&!f&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u}),f&&(0,Z.jsx)(Jr,{event:e,className:`text-sm`,hideEmbedImages:!!i}),c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:c.map(e=>(0,Z.jsx)(X,{variant:`secondary`,className:`text-[11px] px-2 py-0`,children:e},e))})]})]})}function Ns(e){return e.filter(([e])=>e===`c`).map(([,e])=>e).filter(e=>/^#[0-9A-Fa-f]{6}$/.test(e))}function Ps(e,t){return e.find(([e])=>e===t)?.[1]}function Fs(e){return e<=3?{cols:e,rows:1}:e===4?{cols:2,rows:2}:{cols:3,rows:2}}function Is(e){let t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,r=parseInt(e.slice(5,7),16)/255,i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return .2126*i(t)+.7152*i(n)+.0722*i(r)}function Ls({colors:e}){return(0,Z.jsx)(`div`,{className:`flex flex-col w-full rounded-2xl overflow-hidden`,style:{height:180},children:e.map((e,t)=>(0,Z.jsx)(`div`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function Rs({colors:e}){return(0,Z.jsx)(`div`,{className:`flex w-full rounded-2xl overflow-hidden`,style:{height:180},children:e.map((e,t)=>(0,Z.jsx)(`div`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function zs({colors:e}){let{cols:t}=Fs(e.length);return(0,Z.jsx)(`div`,{className:`grid w-full rounded-2xl overflow-hidden`,style:{height:180,gridTemplateColumns:`repeat(${t}, 1fr)`},children:e.map((e,t)=>(0,Z.jsx)(`div`,{style:{backgroundColor:e}},t))})}function Bs(e,t){let n=360/t,r=.5,i=e*n-90-r,a=n+r*2,o=1.5,s=[`50% 50%`];for(let e=0;e<=12;e++){let t=(i+a*e/12)*Math.PI/180,n=50+50*o*Math.cos(t),r=50+50*o*Math.sin(t);s.push(`${n}% ${r}%`)}return`polygon(${s.join(`, `)})`}function Vs({colors:e}){return(0,Z.jsxs)(`div`,{className:`relative w-full rounded-2xl overflow-hidden`,style:{height:180},children:[(0,Z.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundColor:e[0]}}),e.map((t,n)=>(0,Z.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundColor:t,clipPath:Bs(n,e.length)}},n))]})}function Hs({colors:e}){let t=e.length,n=t*Math.max(2,4-t),r=180/n,i=Math.ceil(600/r),a=[];for(let r=0;r(0,Z.jsx)(`div`,{style:{backgroundColor:e}},t))})})}function Us({colors:e}){let t=580/e.length;return(0,Z.jsx)(`div`,{className:`w-full rounded-2xl overflow-hidden`,style:{height:180},children:(0,Z.jsx)(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 400 180`,preserveAspectRatio:`none`,xmlns:`http://www.w3.org/2000/svg`,shapeRendering:`geometricPrecision`,children:e.map((e,n)=>{let r=n*t,i=(n+1)*t,a=n*t-180,o=(n+1)*t-180,s=[`${r},0`,`${i},0`,`${o},180`,`${a},180`].join(` `);return(0,Z.jsx)(`polygon`,{points:s,fill:e},n)})})})}var Ws={horizontal:Ls,vertical:Rs,grid:zs,star:Vs,checkerboard:Hs,diagonalStripes:Us};function Gs({event:e}){let t=(0,Q.useMemo)(()=>Ns(e.tags),[e.tags]),n=Ps(e.tags,`layout`)??`horizontal`,r=Ps(e.tags,`name`),i=e.content.trim(),a=i.length>0&&[...i].length<=2&&/\p{Emoji}/u.test(i)?i:void 0,o=Ws[n]??Ls,s=(0,Q.useMemo)(()=>t.length===0?.5:t.reduce((e,t)=>e+Is(t),0)/t.length,[t])>.5?`text-black/80`:`text-white/90`;return t.length===0?null:(0,Z.jsxs)(`div`,{className:`mt-2`,children:[r&&(0,Z.jsx)(`p`,{className:`text-[15px] font-medium mb-2`,children:r}),(0,Z.jsxs)(`div`,{className:`relative isolate`,children:[(0,Z.jsx)(o,{colors:t}),a&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:(0,Z.jsx)(`span`,{className:G(`text-4xl drop-shadow-lg select-none`,s),children:a})})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-2`,children:t.map((e,t)=>(0,Z.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e)},className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] font-mono text-muted-foreground hover:bg-secondary/60 transition-colors`,title:`Copy ${e}`,children:[(0,Z.jsx)(`span`,{className:`size-2.5 rounded-sm shrink-0 border border-border/40`,style:{backgroundColor:e}}),e]},t))})]})}function Ks(e){let t=(0,Q.useMemo)(()=>e.kind===1018?e.tags.find(([e])=>e===`e`):void 0,[e]),n=t?.[1],r=t?.[2]||void 0,i=t?.[4]||(e.kind===1018?e.tags.find(([e])=>e===`p`)?.[1]:void 0)||void 0,{data:a}=fr(n,r?[r]:void 0,i);return(0,Q.useMemo)(()=>{let t=e.kind===1018?e.tags.filter(([e])=>e===`response`).map(([,e])=>e):[];if(t.length===0)return``;if(!a)return t.join(`, `);let n=new Map;for(let e of a.tags)e[0]===`option`&&n.set(e[1],e[2]);return t.map(e=>n.get(e)??e).join(`, `)},[e,a])}Tt({title:wt(),authors:St(Tt({name:wt()})).optional(),number_of_pages:Ct().optional(),publish_date:wt().optional(),publishers:St(Tt({name:wt()})).optional(),subjects:St(Tt({name:wt()})).optional(),cover:Tt({small:wt().optional(),medium:wt().optional(),large:wt().optional()}).optional(),excerpts:St(Tt({text:wt()})).optional()});async function qs(e,t){try{let n=await fetch(`https://openlibrary.org/isbn/${e}.json`,{signal:t,headers:{Accept:`application/json`}});if(!n.ok)return null;let r=await n.json(),i;if(r.authors&&Array.isArray(r.authors)){let e=r.authors;e.some(e=>e.key&&!e.name)&&(i=await Promise.all(e.map(async e=>{if(e.name)return{name:e.name};if(e.key)try{let n=await fetch(`https://openlibrary.org${e.key}.json`,{signal:t});if(n.ok)return{name:(await n.json()).name??`Unknown Author`}}catch{}return{name:`Unknown Author`}})))}let a;if(r.covers&&Array.isArray(r.covers)&&r.covers.length>0){let e=r.covers[0];a={small:`https://covers.openlibrary.org/b/id/${e}-S.jpg`,medium:`https://covers.openlibrary.org/b/id/${e}-M.jpg`,large:`https://covers.openlibrary.org/b/id/${e}-L.jpg`}}return{title:r.title??`Unknown Title`,authors:i??r.authors,number_of_pages:r.number_of_pages,publish_date:r.publish_date,publishers:r.publishers,subjects:r.subjects?.slice(0,5),cover:a??r.cover,excerpts:r.excerpts}}catch{return null}}function Js(e){return B({queryKey:[`book-info`,e],queryFn:({signal:t})=>qs(e,t),enabled:!!e,staleTime:864e5,gcTime:6048e5,retry:1})}function Ys(e,t=`normal`){return e.setId&&e.artId?`https://api.scryfall.com/cards/${encodeURIComponent(e.setId.toLowerCase())}/${encodeURIComponent(e.artId)}?format=image&version=${t}`:`https://api.scryfall.com/cards/named?exact=${encodeURIComponent(e.name??``)}&format=image&version=${t}`}function Xs(e){switch(e.kind){case`multiverse`:return`https://api.scryfall.com/cards/multiverse/${encodeURIComponent(e.multiverseId)}`;case`set`:{let t=`https://api.scryfall.com/cards/${encodeURIComponent(e.set.toLowerCase())}/${encodeURIComponent(e.number)}`;return e.lang&&e.lang.toLowerCase()!==`en`&&e.lang.toLowerCase()!==`en-us`?`${t}/${encodeURIComponent(e.lang.toLowerCase())}`:t}}}async function Zs(e,t){let n=Xs(e),r=await fetch(n,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)return null;let i=await r.json();return!i||i.id==null?null:i}function Qs(e,t=`large`){return e.image_uris?.[t]??e.card_faces?.[0]?.image_uris?.[t]}function $s(e){return B({queryKey:[`scryfall-card`,e],queryFn:({signal:t})=>Zs(e,t),enabled:!!e,staleTime:864e5,gcTime:6048e5,retry:1})}var ec=(0,Q.createContext)(null);function tc(){return(0,Q.useContext)(ec)}var nc=`flex items-center gap-x-1 text-sm text-muted-foreground mt-2 mb-1 min-w-0 overflow-hidden`;function rc(e){let t=e.tags.find(([e])=>e===`A`),n=e.tags.find(([e])=>e===`E`),r=e.tags.find(([e])=>e===`I`)?.[1],i=e.tags.find(([e])=>e===`K`)?.[1],a=e.tags.find(([e])=>e===`P`)?.[1];if(t){let e=t[1],n=t[2]||void 0,r=e.split(`:`);return{type:`addr`,addr:{kind:parseInt(r[0],10),pubkey:r[1]??``,identifier:r.slice(2).join(`:`)},rootKind:i,relayHint:n}}if(n)return{type:`event`,eventId:n[1],rootKind:i,relayHint:n[2]||void 0,authorHint:n[3]||a||void 0};if(r)return{type:`external`,identifier:r,rootKind:i}}var ic={0:`a profile`,1:`a post`,3:`a follow list`,4:`an encrypted message`,6:`a repost`,7:`a reaction`,8:`a badge award`,16:`a repost`,20:`a photo`,21:`a video`,22:`a short video`,62:`a request to vanish`,1063:`a file`,1018:`a vote`,1068:`a poll`,1111:`a comment`,1222:`a voice message`,8211:`a letter`,1617:`a patch`,1618:`a pull request`,2473:`a bird detection`,12473:`a Birdex`,3367:`a color moment`,7516:`a found log`,15128:`an nsite`,10008:`profile badges`,30008:`profile badges`,30009:`a badge`,30023:`an article`,30030:`an emoji pack`,30054:`a podcast episode`,30055:`a podcast trailer`,3063:`a Zapstore asset`,30063:`a Zapstore release`,30311:`a stream`,30315:`a status`,30617:`a repository`,30817:`a custom NIP`,31922:`a calendar event`,31923:`a calendar event`,31990:`an app`,32267:`a Zapstore app`,34139:`a playlist`,34236:`a divine`,34550:`a group`,9041:`a goal`,33863:`a campaign`,35128:`an nsite`,36639:`a pledge`,36787:`a track`,37381:`a Magic deck`,37516:`a treasure`,3e4:`a follow set`,30621:`a constellation`,39089:`a follow pack`,9735:`a zap`,9802:`a highlight`},ac={0:I,1:C,4:Ke,6:wn,8:L,16:wn,20:D,21:oe,22:oe,1063:je,1018:Ie,1068:x,1222:tt,1617:je,8211:Ke,1618:fe,15128:Fe,35128:Fe,36639:n,10008:L,30008:L,30009:L,30023:w,30030:he,30054:le,30055:le,3063:S,30063:S,30311:_t,30617:me,31990:S,32267:S,34236:a,36787:bt,34139:bt,37381:Tn,37516:En,7516:En,3:s,3e4:I,39089:k,3367:p,9041:y,33863:b,9735:Le,9802:ne,2473:ye,12473:ye,30621:$e};function oc(e){return ic[e]??`an unsupported event`}function sc(e){if(!e)return`a post`;let t=parseInt(e,10);return isNaN(t)?e===`web`||e===`https`||e===`http`?`a link`:e===`#`?`a hashtag`:e:oc(t)}var cc={30009:`badge`,30030:`emoji pack`,3e4:`follow set`,39089:`follow pack`,37381:`deck`,37516:`treasure`,30621:`constellation`,34550:`group`,33863:`campaign`,30054:`episode`,30055:`trailer`,34139:`playlist`},lc={32267:`on Zapstore`,30063:`Zapstore release`,3063:`Zapstore asset`};function uc(e){let t=ac[e.kind];if(e.kind===15128||e.kind===35128){let n=e.tags.find(([e])=>e===`title`)?.[1],r=e.tags.find(([e])=>e===`d`)?.[1],i=n||r;return{text:i?`${i} nsite`:`an nsite`,icon:t}}if(e.kind===31990){try{let n=JSON.parse(e.content)?.name||e.tags.find(([e])=>e===`name`)?.[1];if(n)return{text:`${n} app`,icon:t}}catch{}return{text:`an app`,icon:t}}let n=e.tags.find(([e])=>e===`title`)?.[1],r=e.tags.find(([e])=>e===`name`)?.[1],i=e.tags.find(([e])=>e===`d`)?.[1],a=e.tags.find(([e])=>e===`alt`)?.[1]?.trim(),o=n||r||i,s=lc[e.kind];if(s&&o)return{text:`${o} ${s}`,icon:t};let c=cc[e.kind];return c&&o?{text:`${o} ${c}`,icon:t}:ic[e.kind]&&o?{text:o,icon:t}:a?{text:a,icon:t}:{text:oc(e.kind),icon:t}}function dc(e){if(e.kind>=3e4&&e.kind<4e4){let t=e.tags.find(([e])=>e===`d`)?.[1];if(t)return`/${H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}`}return`/${H.neventEncode({id:e.id,author:e.pubkey})}`}function fc({prefix:e,className:t,loading:n,children:r}){return(0,Z.jsxs)(`div`,{className:t||nc,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e}),n?(0,Z.jsx)(J,{className:`h-3.5 w-24 inline-block`}):r]})}function pc({display:e,link:t,hoverContent:n}){let r=e.icon;return(0,Z.jsxs)(gr,{openDelay:300,closeDelay:150,children:[(0,Z.jsx)(wr,{asChild:!0,children:(0,Z.jsxs)(K,{to:t,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[r&&(0,Z.jsx)(r,{className:`size-3.5 shrink-0`}),e.text]})}),(0,Z.jsx)(yr,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:n})]})}function mc({event:e,className:t,prefix:n=`Commenting on`}){let r=e.tags.find(([e])=>e===`k`)?.[1],i=e.tags.findLast(([e])=>e===`p`)?.[1];if(r===`1111`&&i)return(0,Z.jsx)(hc,{pubkey:i,eventId:e.tags.findLast(([e])=>e===`e`)?.[1],className:t});let a=rc(e);if(!a)return null;switch(a.type){case`addr`:return(0,Z.jsx)(gc,{root:a,className:t,prefix:n});case`event`:return(0,Z.jsx)(xc,{root:a,className:t,prefix:n});case`external`:return(0,Z.jsx)(wc,{root:a,className:t,prefix:n});default:return null}}function hc({pubkey:e,eventId:t,className:n}){let r=z(e),i=r.data?.metadata,a=i?.name??i?.display_name??er(e),o=(0,Q.useMemo)(()=>H.npubEncode(e),[e]),s=(0,Q.useMemo)(()=>{if(t)try{return`/${H.neventEncode({id:t,author:e})}`}catch{return}},[t,e]);return(0,Z.jsx)(fc,{prefix:`Replying to`,className:n,loading:r.isLoading,children:(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsxs)(K,{to:s??`/${o}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,a]})})})}function gc({root:e,className:t,prefix:n}){return e.addr?.kind===0?(0,Z.jsx)(vc,{pubkey:e.addr.pubkey,className:t,prefix:n}):e.addr?.kind===10008||e.addr?.kind===30008?(0,Z.jsx)(yc,{root:e,className:t,prefix:n}):e.addr?.kind===3?(0,Z.jsx)(_c,{pubkey:e.addr.pubkey,className:t,prefix:n}):(0,Z.jsx)(bc,{root:e,className:t,prefix:n})}function _c({pubkey:e,className:t,prefix:n}){let r=z(e),i=r.data?.metadata,a=i?.name??i?.display_name??er(e),o=(0,Q.useMemo)(()=>H.npubEncode(e),[e]),c=(0,Q.useMemo)(()=>`/${H.naddrEncode({kind:3,pubkey:e,identifier:``})}`,[e]);return(0,Z.jsxs)(fc,{prefix:n,className:t,loading:r.isLoading,children:[(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsxs)(K,{to:`/${o}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,a,`'s`]})}),(0,Z.jsxs)(K,{to:c,className:`inline-flex items-center gap-1 text-primary hover:underline shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(s,{className:`size-3.5 shrink-0`}),`follow list`]})]})}function vc({pubkey:e,className:t,prefix:n}){let r=z(e),i=r.data?.metadata,a=i?.name??i?.display_name??er(e),o=(0,Q.useMemo)(()=>H.npubEncode(e),[e]);return(0,Z.jsx)(fc,{prefix:n,className:t,loading:r.isLoading,children:(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsxs)(K,{to:`/${o}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,a]})})})}function yc({root:e,className:t,prefix:n}){let r=e.addr?.pubkey??``,i=z(r),a=i.data?.metadata,o=a?.name??a?.display_name??er(r),s=(0,Q.useMemo)(()=>H.npubEncode(r),[r]),c=(0,Q.useMemo)(()=>{if(e.addr)try{return`/${H.naddrEncode({kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier})}`}catch{return}},[e.addr]),l=e.addr?(0,Z.jsx)(Er,{addr:{kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier},className:`border-0 rounded-none`}):void 0;return(0,Z.jsxs)(fc,{prefix:n,className:t,loading:i.isLoading,children:[c&&l?(0,Z.jsx)(pc,{display:{text:`profile badges`,icon:L},link:c,hoverContent:l}):(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,Z.jsx)(L,{className:`size-3.5 shrink-0`}),`profile badges`]}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`by`}),(0,Z.jsx)(br,{pubkey:r,asChild:!0,children:(0,Z.jsxs)(K,{to:`/${s}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[`@`,o]})})]})}function bc({root:e,className:t,prefix:n}){let{data:r,isLoading:i}=pr(e.addr,e.relayHint?[e.relayHint]:void 0),a=(e.rootKind===`34550`||e.addr?.kind===34550)&&n===`Commenting on`?`Posted in`:n,o=r?uc(r):{text:sc(e.rootKind)},s=r?dc(r):void 0,c=e.addr?(0,Z.jsx)(Er,{addr:{kind:e.addr.kind,pubkey:e.addr.pubkey,identifier:e.addr.identifier},className:`border-0 rounded-none`}):void 0;return(0,Z.jsx)(fc,{prefix:a,className:t,loading:i,children:s&&c?(0,Z.jsx)(pc,{display:o,link:s,hoverContent:c}):s?(0,Z.jsxs)(K,{to:s,className:`inline-flex items-center gap-1 text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:[o.icon&&(0,Z.jsx)(o.icon,{className:`size-3.5 shrink-0`}),o.text]}):(0,Z.jsx)(`span`,{className:`truncate`,children:o.text})})}function xc({root:e,className:t,prefix:n}){let{data:r,isLoading:i}=fr(e.eventId,e.relayHint?[e.relayHint]:void 0,e.authorHint);if(r?.kind===7)return(0,Z.jsx)(Sc,{event:r,className:t,prefix:n});if(r?.kind===1018)return(0,Z.jsx)(Cc,{event:r,className:t,prefix:n});let a=r?uc(r):{text:sc(e.rootKind)},o=r?dc(r):void 0,s=e.eventId?(0,Z.jsx)(ti,{eventId:e.eventId,relays:e.relayHint?[e.relayHint]:void 0,authorHint:e.authorHint,className:`border-0 rounded-none`,disableHoverCards:!0}):void 0;return(0,Z.jsx)(fc,{prefix:n,className:t,loading:i,children:o&&s?(0,Z.jsx)(pc,{display:a,link:o,hoverContent:s}):(0,Z.jsx)(`span`,{className:`truncate`,children:a.text})})}function Sc({event:e,className:t,prefix:n}){let r=z(e.pubkey),i=r.data?.metadata,a=lr(i,e.pubkey),o=dc(e),s=`/${H.npubEncode(e.pubkey)}`;return(0,Z.jsxs)(fc,{prefix:n,className:t,children:[(0,Z.jsx)(K,{to:o,className:`text-primary hover:underline shrink-0 cursor-pointer`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(ui,{content:e.content,tags:e.tags,className:`inline-block h-[1.2em] w-[1.2em] align-text-bottom object-contain`})}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`by`}),r.isLoading?(0,Z.jsx)(J,{className:`h-3.5 w-16 inline-block`}):(0,Z.jsx)(br,{pubkey:e.pubkey,asChild:!0,children:(0,Z.jsxs)(K,{to:s,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[`@`,a]})})]})}function Cc({event:e,className:t,prefix:n}){let r=z(e.pubkey),i=r.data?.metadata,a=lr(i,e.pubkey),o=dc(e),s=`/${H.npubEncode(e.pubkey)}`,c=Ks(e);return(0,Z.jsxs)(fc,{prefix:n,className:t,children:[r.isLoading?(0,Z.jsx)(J,{className:`h-3.5 w-16 inline-block`}):(0,Z.jsx)(br,{pubkey:e.pubkey,asChild:!0,children:(0,Z.jsxs)(K,{to:s,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[`@`,a]})}),(0,Z.jsxs)(K,{to:o,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(Ie,{className:`size-3.5 shrink-0`}),c?`vote for ${c}`:`vote`]})]})}function wc({root:e,className:t,prefix:n}){let r=e.identifier??``;if(r.startsWith(`isbn:`))return(0,Z.jsx)(Ac,{identifier:r,className:t,prefix:n});if(r.startsWith(`http://`)||r.startsWith(`https://`)){let e=Nr(r);return e?(0,Z.jsx)(jc,{card:e,url:r,className:t,prefix:n}):(0,Z.jsx)(Tc,{url:r,className:t,prefix:n})}if(r.startsWith(`iso3166:`))return(0,Z.jsx)(kc,{identifier:r,className:t,prefix:n});let i=`/i/${encodeURIComponent(r)}`;return(0,Z.jsx)(fc,{prefix:n,className:t,children:(0,Z.jsx)(K,{to:i,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:r})})}function Tc({url:e,className:t,prefix:n}){let{data:r,isLoading:i}=Tr(e),a=`/i/${encodeURIComponent(e)}`,o;try{o=new URL(e).hostname.replace(/^www\./,``)}catch{o=e}let s=r?.title;return(0,Z.jsxs)(fc,{prefix:n,className:t,loading:i,children:[(0,Z.jsx)(cr,{url:e,size:14,className:`shrink-0`}),(0,Z.jsxs)(gr,{openDelay:300,closeDelay:150,children:[(0,Z.jsx)(wr,{asChild:!0,children:(0,Z.jsx)(K,{to:a,className:`text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:s||o})}),(0,Z.jsx)(yr,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(ai,{url:e,className:`border-0 rounded-none`,navigateToComments:!0})})]})]})}function Ec({identifier:e,className:t}){let n=e.slice(8),r=Ui(n),i=`/i/${encodeURIComponent(e)}`,a=r?.flag??`🌍`,o=Ki(n),s=r?.subdivisionName??r?.name??n,c=!o&&r?.subdivisionName&&r.name?r.name:null,l=r?.subdivisionName&&!o?`Region`:`Country`,u=r?`Flag of ${s}`:n;return(0,Z.jsxs)(gr,{openDelay:300,closeDelay:150,children:[(0,Z.jsx)(wr,{asChild:!0,children:(0,Z.jsx)(K,{to:i,onClick:e=>e.stopPropagation(),"aria-label":`Posted from ${r?.name??n}`,className:G(`group/flag inline-flex items-center justify-center shrink-0`,`text-xl leading-none`,`transition-transform duration-200`,`motion-safe:hover:scale-110 motion-safe:active:scale-95`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-full`,t),children:(0,Z.jsx)(qi,{code:n,emoji:a,label:u})})}),(0,Z.jsx)(yr,{side:`bottom`,align:`end`,sideOffset:6,className:`w-64 p-0 rounded-2xl shadow-lg overflow-hidden`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,Z.jsx)(qi,{code:n,emoji:a,label:u,className:`text-2xl shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(st,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:l})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:s}),c&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:c})]})]})})]})}function Dc(e){let t=tc();if(e.kind!==1111||e.tags.find(([e])=>e===`k`)?.[1]===`1111`)return null;let n=e.tags.find(([e])=>e===`I`)?.[1];if(!n||!n.startsWith(`iso3166:`))return null;let r=n.slice(8);return t&&t.countryCode===r.toUpperCase()?null:{iTag:n,code:r}}function Oc({event:e,className:t}){let n=Dc(e);return n?(0,Z.jsx)(Ec,{identifier:n.iTag,className:t}):null}function kc(e){return null}function Ac({identifier:e,className:t,prefix:n}){let r=e.slice(5),{data:i,isLoading:a}=Js(r),o=`/i/${encodeURIComponent(e)}`,s=i?.title??e,c=i?.cover?.medium||i?.cover?.large,l=i?.authors?.map(e=>e.name).join(`, `);return(0,Z.jsx)(fc,{prefix:n,className:t,loading:a,children:(0,Z.jsxs)(gr,{openDelay:300,closeDelay:150,children:[(0,Z.jsx)(wr,{asChild:!0,children:(0,Z.jsxs)(K,{to:o,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(w,{className:`size-3.5 shrink-0`}),s]})}),(0,Z.jsx)(yr,{side:`bottom`,align:`start`,sideOffset:4,className:`w-72 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[c?(0,Z.jsx)(`img`,{src:c,alt:i?.title||`Book cover`,className:`w-9 h-12 rounded object-cover shrink-0`,loading:`lazy`}):(0,Z.jsx)(`div`,{className:`w-9 h-12 rounded bg-secondary flex items-center justify-center shrink-0`,children:(0,Z.jsx)(w,{className:`size-4 text-muted-foreground`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(w,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:`Book`})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:i?.title||`ISBN ${r}`}),l&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[`by `,l]})]})]})})]})})}function jc({card:e,url:t,className:n,prefix:r}){let{data:i,isLoading:a}=$s((0,Q.useMemo)(()=>e.kind===`multiverse`?{kind:`multiverse`,multiverseId:e.multiverseId}:{kind:`set`,set:e.set,number:e.number,lang:e.lang},[e])),o=`/i/${encodeURIComponent(t)}`,s=i?.name??`Magic card`,c=i?Qs(i,`small`):void 0;return(0,Z.jsx)(fc,{prefix:r,className:n,loading:a,children:(0,Z.jsxs)(gr,{openDelay:300,closeDelay:150,children:[(0,Z.jsx)(wr,{asChild:!0,children:(0,Z.jsxs)(K,{to:o,className:`inline-flex items-center gap-1 text-primary hover:underline truncate cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(Tn,{className:`size-3.5 shrink-0`}),s]})}),(0,Z.jsx)(yr,{side:`bottom`,align:`start`,sideOffset:4,className:`w-72 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[c?(0,Z.jsx)(`img`,{src:c,alt:i?.name??`Magic card`,className:`w-9 h-12 rounded object-cover shrink-0`,loading:`lazy`}):(0,Z.jsx)(`div`,{className:`w-9 h-12 rounded bg-secondary flex items-center justify-center shrink-0`,children:(0,Z.jsx)(Tn,{className:`size-4 text-muted-foreground`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Tn,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:`Magic Card`})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:i?.name??`Unknown card`}),i?.set_name&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:i.set_name})]})]})})]})})}var Mc=(0,Q.createContext)(null);function Nc(){return(0,Q.useContext)(Mc)}var Pc={nudity:`nudity`,spam:`spam`,profanity:`hateful speech`,illegal:`illegal content`,malware:`malware`,impersonation:`impersonation`,other:`group guidelines`};function Fc({event:e,children:t,className:n}){let r=Nc(),i=r?gi(e,r.moderation):[],[a,o]=(0,Q.useState)(!1);if(i.length===0||a)return(0,Z.jsx)(Z.Fragment,{children:t});let s=[...new Set(i.map(e=>e.reportType))].map(e=>Pc[e]??e).join(`, `),c=new Set(i.map(e=>e.reporterPubkey)).size;return(0,Z.jsx)(`div`,{className:G(`border-b border-border`,n),children:(0,Z.jsx)(`div`,{className:`px-4 py-6`,children:(0,Z.jsxs)(`div`,{className:`max-w-sm mx-auto flex flex-col items-center text-center gap-2.5`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-center size-9 rounded-full bg-amber-500/10`,children:(0,Z.jsx)(Be,{className:`size-4.5 text-amber-500`})}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Reported Content`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:c===1?`Reported by a group moderator for ${s}.`:`Reported by ${c} group moderators for ${s}.`})]}),(0,Z.jsxs)(q,{variant:`outline`,size:`sm`,className:`gap-1.5 mt-0.5 rounded-full px-5`,onClick:()=>o(!0),children:[(0,Z.jsx)(nt,{className:`size-3.5`}),`Show Anyway`]})]})})})}function Ic({event:e,children:t,className:n}){let{config:r}=Kt(),[i,a]=(0,Q.useState)(!1),o=ga(e);if(o===void 0)return(0,Z.jsx)(Z.Fragment,{children:t});let s=r.contentWarningPolicy;return s===`show`?(0,Z.jsx)(Z.Fragment,{children:t}):s===`hide`?null:i?(0,Z.jsx)(Z.Fragment,{children:t}):(0,Z.jsxs)(`div`,{className:G(`relative mt-2 rounded-xl overflow-hidden`,n),children:[(0,Z.jsxs)(`div`,{className:`bg-muted/40 blur-lg select-none`,"aria-hidden":!0,children:[(0,Z.jsxs)(`div`,{className:`px-4 pt-4 pb-2 space-y-2.5`,children:[(0,Z.jsx)(`div`,{className:`h-3.5 w-full rounded bg-muted/60`}),(0,Z.jsx)(`div`,{className:`h-3.5 w-4/5 rounded bg-muted/60`}),(0,Z.jsx)(`div`,{className:`h-3.5 w-3/5 rounded bg-muted/60`})]}),(0,Z.jsx)(`div`,{className:`mx-4 mb-4 mt-1 h-32 rounded-lg bg-muted/60`})]}),(0,Z.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2.5 px-4 text-center`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-background/80 shadow-sm backdrop-blur-sm`,children:(0,Z.jsx)(Qe,{className:`size-5 text-muted-foreground`})}),(0,Z.jsxs)(`div`,{className:`space-y-1 max-w-xs`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Content Warning`}),o?(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:[`“`,o,`”`]}):(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:`The author flagged this post as sensitive.`})]}),(0,Z.jsxs)(q,{variant:`outline`,size:`sm`,className:`gap-1.5 mt-0.5 rounded-full px-5 bg-background/80 backdrop-blur-sm`,onClick:e=>{e.stopPropagation(),a(!0)},children:[(0,Z.jsx)(nt,{className:`size-3.5`}),`Show Content`]})]})]})}var Lc=(0,Q.lazy)(()=>Mt(()=>import(`./EmojiPackDialog-NQcdaVLC.js`).then(e=>({default:e.EmojiPackDialog})),__vite__mapDeps([14,0,1,15,2,6,7,9,10,11,16,8,4,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42]))),Rc=24;function zc(e){if(e.kind!==30030)return null;let t=e.tags.find(([e])=>e===`d`)?.[1];if(!t)return null;let n=e.tags.find(([e])=>e===`name`)?.[1]||t,r=e.tags.find(([e])=>e===`picture`)?.[1],i=e.tags.find(([e])=>e===`about`)?.[1],a=[];for(let t of e.tags)t[0]===`emoji`&&t[1]&&t[2]&&a.push({shortcode:t[1],url:t[2]});return{identifier:t,name:n,picture:r,about:i,emojis:a}}function Bc({event:e}){let t=(0,Q.useMemo)(()=>zc(e),[e]),{user:n}=U(),{nostr:r}=R(),{mutateAsync:i}=ln(),a=V(),{toast:s}=sn(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!1),h=n?.pubkey===e.pubkey,g=B({queryKey:[`emoji-list`,n?.pubkey],queryFn:async()=>n?(await r.query([{kinds:[10030],authors:[n.pubkey],limit:1}]))[0]??null:null,enabled:!!n,staleTime:6e4}),_=`30030:${e.pubkey}:${t?.identifier??``}`,v=(0,Q.useMemo)(()=>g.data?g.data.tags.some(([e,t])=>e===`a`&&t===_):!1,[g.data,_]),y=(0,Q.useCallback)(async()=>{if(!(!n||!t)){l(!0);try{let e=g.data?.tags.filter(([e])=>e===`emoji`||e===`a`)??[],n;n=v?e.filter(([e,t])=>e!==`a`||t!==_):[...e,[`a`,_]],await i({kind:10030,content:``,tags:n}),a.invalidateQueries({queryKey:[`emoji-list`]}),a.invalidateQueries({queryKey:[`custom-emojis`]}),s({title:v?`Pack removed`:`Pack added`,description:v?`"${t.name}" removed from your emoji collection.`:`"${t.name}" added to your emoji collection!`})}catch(e){console.error(`Failed to update emoji list:`,e),s({title:`Failed`,description:`Could not update your emoji collection.`,variant:`destructive`})}finally{l(!1)}}},[n,t,g.data,v,_,i,a,s]);if(!t)return null;let b=p?t.emojis:t.emojis.slice(0,Rc),x=p?0:t.emojis.length-Rc;return(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t.picture&&(0,Z.jsx)(`img`,{src:t.picture,alt:t.name,className:`size-12 rounded-lg object-cover shrink-0 border border-border`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-[15px] truncate`,children:t.name}),t.about&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2 mt-0.5`,children:t.about})]})]}),b.length>0&&(0,Z.jsx)(`div`,{className:`rounded-xl border border-border bg-secondary/30 p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[b.map(e=>(0,Z.jsx)(`div`,{className:`group relative`,title:`:${e.shortcode}:`,children:(0,Z.jsx)(di,{name:e.shortcode,url:e.url,className:`size-8 object-contain rounded transition-transform group-hover:scale-125`})},e.shortcode)),x>0&&(0,Z.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),m(!0)},className:`flex items-center justify-center size-8 rounded bg-muted text-muted-foreground text-xs font-medium hover:bg-accent hover:text-accent-foreground transition-colors cursor-pointer`,children:[`+`,x]})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[n&&(0,Z.jsxs)(q,{variant:v?`secondary`:`default`,size:`sm`,className:G(`h-8 text-xs gap-1.5`,v&&`text-muted-foreground`),disabled:c,onClick:y,children:[c?(0,Z.jsx)(Xe,{className:`size-3.5 animate-spin`}):v?(0,Z.jsx)(f,{className:`size-3.5`}):(0,Z.jsx)(o,{className:`size-3.5`}),v?`Added`:`Add to Collection`]}),h&&(0,Z.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-8 text-xs gap-1.5`,onClick:()=>d(!0),children:[(0,Z.jsx)(We,{className:`size-3.5`}),`Edit`]})]}),u&&(0,Z.jsx)(Q.Suspense,{fallback:null,children:(0,Z.jsx)(Lc,{open:u,onOpenChange:d,editEvent:e})})]})}function Vc(e,t){return e.find(([e])=>e===t)?.[1]}function Hc(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Uc({title:e,text:t}){return!e&&!t?null:(0,Z.jsxs)(`div`,{className:`mt-2.5 rounded-xl bg-secondary/50 px-3.5 py-2.5`,children:[e&&(0,Z.jsx)(`p`,{className:`text-base font-semibold text-foreground break-words`,children:e}),t&&(0,Z.jsx)(`p`,{className:G(`text-sm leading-relaxed text-muted-foreground break-words`,e&&`mt-1`),children:t})]})}function Wc({event:e,url:t,mime:n,description:r}){let i=z(e.pubkey).data?.metadata,a=lr(i,e.pubkey)??er(e.pubkey);return(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(ri,{src:t,mime:n,avatarUrl:i?.picture,avatarFallback:a[0]?.toUpperCase()??`?`}),r&&(0,Z.jsx)(Uc,{text:r})]})}function Gc({event:e,compact:n}){let r=Y(Vc(e.tags,`url`)),i=Vc(e.tags,`m`)??``,a=Vc(e.tags,`alt`),o=Vc(e.tags,`dim`),s=Vc(e.tags,`blurhash`),c=Vc(e.tags,`thumb`)??Vc(e.tags,`image`),l=Vc(e.tags,`size`);if(!r)return null;let u=e.content||void 0,d=a??void 0,f=r.split(`/`).pop()??`file`,p=l?Hc(Number(l)):void 0;if(i.startsWith(`image/`))return(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(Ir,{images:[r],imetaMap:o||s?new Map([[r,{dim:o,blurhash:s}]]):void 0}),u&&!n&&(0,Z.jsx)(Uc,{text:u})]});if(i.startsWith(`video/`))return(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(Lr,{src:r,poster:c,dim:o,blurhash:s,title:d}),u&&!n&&(0,Z.jsx)(Uc,{text:u})]});if(i.startsWith(`audio/`))return(0,Z.jsx)(Wc,{event:e,url:r,mime:i,description:u});let m=d??f,h=i?i.split(`/`).pop()?.toUpperCase():void 0;return(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3.5 p-4`,children:[(0,Z.jsx)(`div`,{className:`flex items-center justify-center size-12 rounded-xl bg-muted shrink-0`,children:(0,Z.jsx)(t,{className:`size-6 text-muted-foreground`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-semibold truncate`,children:m}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[h,p].filter(Boolean).join(` · `)||`File`})]}),(0,Z.jsx)(q,{variant:`outline`,size:`sm`,className:`shrink-0 rounded-full gap-1.5`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:r,download:!0,children:[(0,Z.jsx)(Oe,{className:`size-3.5`}),`Download`]})})]})}),u&&(0,Z.jsx)(Uc,{text:u})]})}function Kc(e){let{nostr:t}=R(),n=V(),r=[...new Set(e)].sort(),i=r.join(`,`);return B({queryKey:[`authors`,i],queryFn:async({signal:e})=>{if(r.length===0)return new Map;let i=new Map;for(let e of r)i.set(e,{pubkey:e});let a=await t.query([{kinds:[0],authors:r,limit:r.length}],{signal:e});for(let e of a){let t=Et(e);i.set(e.pubkey,{pubkey:e.pubkey,...t}),n.setQueryData([`author`,e.pubkey],t),Ot(e,t.metadata)}return i},staleTime:3e5,gcTime:6e5,enabled:r.length>0,placeholderData:e=>e})}var qc={sm:`size-6`,md:`size-7`,lg:`size-9`,comment:`size-10`},Jc={sm:`-space-x-1.5`,md:`-space-x-2`,lg:`-space-x-3`,comment:`-space-x-3`},Yc={sm:`text-[10px]`,md:`text-[10px]`,lg:`text-xs`,comment:`text-xs`};function Xc({pubkeys:e,maxVisible:t=6,size:n=`md`,forceCircle:r=!1,showOverflowCount:i=!0,className:a}){let o=(0,Q.useMemo)(()=>e.slice(0,t),[e,t]),{data:s}=Kc(o);if(e.length===0)return null;let c=e.length-o.length;return(0,Z.jsxs)(`div`,{className:G(`flex items-center gap-2`,a),children:[(0,Z.jsx)(`div`,{className:G(`flex`,Jc[n]),children:o.map(e=>{let t=s?.get(e),i=t?.metadata?.name||t?.metadata?.display_name||er(e),a=r?void 0:Yn(t?.metadata);return(0,Z.jsxs)(Cn,{children:[(0,Z.jsx)(xn,{asChild:!0,children:(0,Z.jsx)(K,{to:`/${H.npubEncode(e)}`,"aria-label":i,onClick:e=>e.stopPropagation(),className:G(`rounded-full relative transition-transform duration-150 ease-out`,`hover:z-10 motion-safe:hover:scale-110 focus-visible:z-10 motion-safe:focus-visible:scale-110`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`),children:(0,Z.jsxs)(Qn,{shape:a,className:G(qc[n],`ring-2 ring-background`),children:[(0,Z.jsx)(Zn,{src:t?.metadata?.picture,alt:i}),(0,Z.jsx)(Xn,{className:G(`bg-primary/20 text-primary`,Yc[n]),children:i[0]?.toUpperCase()})]})})}),(0,Z.jsx)(Sn,{side:`bottom`,className:`text-xs`,children:i})]},e)})}),i&&c>0&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`+`,c,` more`]})]})}function Zc(e){return e===3?`follow-list`:e===3e4?`follow-set`:e===39089?`follow-pack`:null}function Qc(e,t){let n=t=>e.tags.find(([e])=>e===t)?.[1],r=e.tags.filter(([e])=>e===`p`).map(([,e])=>e),i=Zc(e.kind)??`follow-pack`;if(e.kind===3){let e=t?.authorDisplayName||t?.authorMetadata?.name||t?.authorMetadata?.display_name;return{title:e?`${e}'s follows`:`Follow list`,description:``,image:void 0,pubkeys:r,variant:i}}return{title:n(`title`)||n(`name`)||`Untitled`,description:n(`description`)||n(`summary`)||``,image:n(`image`)||n(`thumb`)||n(`banner`),pubkeys:r,variant:i}}function $c(e,t){return e.kind===3?t.slice().reverse():t}function el(e){let{title:t,description:n,image:r,pubkeys:i}=Qc(e);return{title:t===`Untitled`?`Untitled Pack`:t,description:n,image:r,pubkeys:i}}function tl({event:e}){let t=e.kind===3,n=z(t?e.pubkey:``),r=t?n.data?.metadata:void 0,{title:i,description:a,image:o,pubkeys:c,variant:l}=(0,Q.useMemo)(()=>Qc(e,{authorMetadata:r,authorDisplayName:r?.name||r?.display_name}),[e,r]),u=(0,Q.useMemo)(()=>$c(e,c),[e,c]),d=(0,Q.useMemo)(()=>Y(o),[o]);return(0,Z.jsxs)(`div`,{className:`mt-2`,children:[i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)(l===`follow-list`?s:l===`follow-set`?I:k,{className:`size-4 text-primary shrink-0`}),(0,Z.jsx)(`span`,{className:`text-[15px] font-semibold leading-snug`,children:i})]}),a&&(0,Z.jsx)(`p`,{className:`text-[15px] leading-relaxed text-foreground/90 line-clamp-3 mb-3`,children:a}),d&&(0,Z.jsx)(`div`,{className:`rounded-2xl overflow-hidden mb-3`,children:(0,Z.jsx)(`img`,{src:d,alt:i,className:`w-full max-h-[200px] object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`}})}),(0,Z.jsx)(Xc,{pubkeys:u,maxVisible:8,size:`md`})]})}function nl(e,t){return e.find(([e])=>e===t)?.[1]}function rl(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function il(e){let t=nl(e,`a`);if(!t)return;let n=t.split(`:`);if(n.length<3)return;let[r,i,...a]=n,o=Number(r);if(!(!o||!i))return{kind:o,pubkey:i,identifier:a.join(`:`)}}function al({event:e}){let t=e.content,n=rl(e.tags,`image`).filter(e=>e.trim()!==``),r=!!nl(e.tags,`verification`),i=(0,Q.useMemo)(()=>il(e.tags),[e.tags]),{data:a,isLoading:o}=pr(i),s=a?.tags.find(([e])=>e===`name`)?.[1],c=(0,Q.useMemo)(()=>{if(i)return`/${H.naddrEncode({kind:i.kind,pubkey:i.pubkey,identifier:i.identifier})}`},[i]);return(0,Z.jsxs)(`div`,{className:`mt-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-2`,children:[o?(0,Z.jsx)(J,{className:`h-5 w-32`}):s&&c?(0,Z.jsxs)(K,{to:c,className:`flex items-center gap-1.5 text-sm font-medium text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(En,{className:`size-3.5`}),s]}):i?(0,Z.jsx)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:i.identifier}):null,r&&(0,Z.jsxs)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium text-green-600 dark:text-green-400`,children:[(0,Z.jsx)(ze,{className:`size-3`}),`Verified`]})]}),t&&(0,Z.jsx)(`p`,{className:`text-[15px] leading-relaxed text-foreground/90 line-clamp-4`,children:t}),n.length>0&&(0,Z.jsx)(`div`,{className:`mt-3 rounded-2xl overflow-hidden`,children:(0,Z.jsx)(`img`,{src:n[0],alt:`Found log`,className:`w-full max-h-[300px] object-cover`,loading:`lazy`})})]})}function ol(e,t){return e.find(([e])=>e===t)?.[1]}function sl(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function cl({value:e,max:t=5}){return(0,Z.jsx)(`div`,{className:`flex gap-0.5`,children:Array.from({length:t}).map((t,n)=>(0,Z.jsx)(`div`,{className:G(`size-2 rounded-full`,n{let t=e<=`Z`?65:97;return String.fromCharCode((e.charCodeAt(0)-t+13)%26+t)})}var ul={micro:`Micro`,small:`Small`,regular:`Regular`,large:`Large`,other:`Other`},dl={traditional:`Traditional`,multi:`Multi-cache`,mystery:`Mystery`};function fl({event:e}){let t=ol(e.tags,`name`),n=Number(ol(e.tags,`D`)??1),r=Number(ol(e.tags,`T`)??1),i=ol(e.tags,`S`)??`other`,a=ol(e.tags,`t`)??`traditional`,o=sl(e.tags,`g`).reduce((e,t)=>e===void 0||t.length>e.length?t:e,void 0)?.slice(0,5),s=ol(e.tags,`hint`),c=sl(e.tags,`image`).filter(e=>e.trim()!==``),l=e.content,[u,d]=(0,Q.useState)(!1),f=(0,Q.useMemo)(()=>s?ll(s):``,[s]);return(0,Z.jsxs)(`div`,{className:`mt-2`,children:[t&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,Z.jsx)(En,{className:`size-4 text-primary mt-0.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`text-[15px] font-semibold leading-snug`,children:t})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[(0,Z.jsx)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:dl[a]??a}),(0,Z.jsxs)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:[(0,Z.jsx)(S,{className:`size-3`}),ul[i]??i]}),o&&(0,Z.jsx)(K,{to:`/g/${o}`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium hover:bg-secondary/80 transition-colors`,children:[(0,Z.jsx)(st,{className:`size-3`}),o]})})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-4 mb-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(M,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`D`}),(0,Z.jsx)(cl,{value:n}),(0,Z.jsx)(`span`,{className:`text-xs font-medium tabular-nums`,children:n})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(pe,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:`T`}),(0,Z.jsx)(cl,{value:r}),(0,Z.jsx)(`span`,{className:`text-xs font-medium tabular-nums`,children:r})]})]}),l&&(0,Z.jsx)(`p`,{className:`text-[15px] leading-relaxed text-foreground/90 line-clamp-4`,children:l}),c.length>0&&(0,Z.jsx)(Ir,{images:c}),s&&(0,Z.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),d(!u)},className:`flex items-center gap-1.5 mt-3 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[u?(0,Z.jsx)(Re,{className:`size-3.5`}):(0,Z.jsx)(nt,{className:`size-3.5`}),u?f:`Show hint`]})]})}var pl=class e{pubkey;identifier;relay;constructor(e){this.pubkey=e.pubkey,this.identifier=e.identifier,this.relay=e.relay}static fromEvent(t){let n=t.tags.find(([e])=>e===`d`)?.[1]??``,r=t.tags.find(([e])=>e===`relays`)?.[1];return new e({pubkey:t.pubkey,identifier:n,relay:r})}static fromNaddr(t){let n=H.decode(t);if(n.type!==`naddr`)throw Error(`Invalid naddr: must be an addressable event pointer`);let r=n.data;return new e({pubkey:r.pubkey,identifier:r.identifier,relay:r.relays?.[0]})}toString(){let e=H.npubEncode(this.pubkey);if(this.relay)try{return`nostr://${e}/${new URL(this.relay).hostname}/${this.identifier}`}catch{}return`nostr://${e}/${this.identifier}`}toNaddr(){let e={kind:30617,pubkey:this.pubkey,identifier:this.identifier};return this.relay&&(e.relays=[this.relay]),H.naddrEncode(e)}toJSON(){return{pubkey:this.pubkey,identifier:this.identifier,relay:this.relay}}};function ml(e){try{return`${new URL(e).origin}/favicon.ico`}catch{return}}function hl({event:e}){let t=e.tags.find(([e])=>e===`name`)?.[1],n=e.tags.find(([e])=>e===`description`)?.[1],i=e.tags.filter(([e])=>e===`web`).map(([,e])=>Y(e)).filter(e=>!!e),a=e.tags.some(([e,t])=>e===`t`&&t===`personal-fork`),o=e.tags.some(([e,t])=>e===`t`&&t===`shakespeare`),s=e.tags.find(([e])=>e===`d`)?.[1]??``,c=pl.fromEvent(e).toString(),l=o&&!!i[0],u=l?ml(i[0]):void 0,d=t||s,[p,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),_=e=>{navigator.clipboard.writeText(e),g(!0),setTimeout(()=>g(!1),2e3)},v=`https://shakespeare.diy/clone?url=${encodeURIComponent(c)}`;return(0,Z.jsx)(`div`,{className:`mt-2 rounded-2xl border border-border overflow-hidden`,children:(0,Z.jsxs)(`div`,{className:`px-3.5 py-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[l&&u&&!p?(0,Z.jsx)(`img`,{src:u,alt:``,className:`size-5 rounded object-cover shrink-0`,loading:`lazy`,onError:()=>m(!0)}):(0,Z.jsx)(et,{className:`size-4 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`font-semibold text-sm truncate leading-snug`,children:d}),a&&(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full border border-border px-2 py-0 text-[11px] text-muted-foreground leading-relaxed`,children:`Fork`})]}),n&&(0,Z.jsx)(`p`,{className:`text-[13px] text-muted-foreground line-clamp-2 leading-relaxed`,children:n}),(0,Z.jsxs)(`div`,{className:`group/nostr flex items-center gap-2 rounded-lg bg-muted/50 px-2.5 py-1.5`,children:[(0,Z.jsx)(`code`,{className:`flex-1 text-[11px] font-mono text-muted-foreground truncate select-all`,children:c}),(0,Z.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-5 w-5 p-0 shrink-0 opacity-50 group-hover/nostr:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),_(c)},children:[h?(0,Z.jsx)(f,{className:`size-3`}):(0,Z.jsx)(Pe,{className:`size-3`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:h?`Copied`:`Copy`})]})]}),(o||l||i[0])&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-0.5`,children:[o&&(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-full bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90`,onClick:e=>{e.stopPropagation(),Pi(v)},children:[(0,Z.jsx)(Me,{className:`size-3`}),`Edit with Shakespeare`]}),l?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-full border border-border px-3 py-1.5 text-xs font-medium transition-colors hover:bg-secondary/60`,onClick:e=>{e.stopPropagation(),Pi(i[0])},children:[(0,Z.jsx)(F,{className:`size-3`}),`Open App`]}):i[0]?(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-full border border-border px-3 py-1.5 text-xs font-medium transition-colors hover:bg-secondary/60`,onClick:e=>{e.stopPropagation(),Pi(i[0])},children:[(0,Z.jsx)(r,{className:`size-3`}),`Browse Repository`]}):null]})]})})}var gl=9041;function _l(e){if(e)try{let t=new URL(e);return t.protocol!==`wss:`&&t.protocol!==`ws:`?void 0:t.toString()}catch{return}}function vl(e){return e.kind===gl&&e.tags.some(([e])=>e===`zap`)}function yl(e){if(e.kind!==gl)return null;let t=e.content.trim();if(!t)return null;let n=e.tags.find(([e])=>e===`amount`)?.[1];if(!n)return null;let r=parseInt(n,10);if(isNaN(r)||r<=0)return null;let i=e.tags.find(([e])=>e===`relays`),a=i?[...new Set(i.slice(1).map(_l).filter(e=>!!e))]:[],o=e.tags.find(([e])=>e===`closed_at`)?.[1],s=o?parseInt(o,10):void 0,c=e.tags.find(([e])=>e===`image`)?.[1],l=Y(c),u=e.tags.find(([e])=>e===`summary`)?.[1]||void 0,d=e.tags.find(([e,t])=>e===`a`&&t?.startsWith(`34550:`))?.[1];return{title:t,amountMsat:r,amountSats:Math.floor(r/1e3),relays:a,closedAt:s&&!isNaN(s)?s:void 0,image:l||void 0,summary:u,communityATag:d,beneficiary:e.pubkey,hasZapSplits:vl(e)}}function bl(e){return e.closedAt?Math.floor(Date.now()/1e3)>e.closedAt:!1}function xl(e){return e.toLocaleString()}function Sl(e){let t=_n(e);if(!(!t||t.kind!==34550))return t}var Cl=class{maxRemembered;verified=new Set;constructor(e=1e4){this.maxRemembered=e}verify=e=>this.verified.has(e.id)?Nt(e)===e.id:It(e)?(this.remember(e.id),!0):!1;remember(e){if(this.verified.add(e),this.verified.size>this.maxRemembered){let e=this.verified.values().next().value;e!==void 0&&this.verified.delete(e)}}},wl=21600;function Tl(e){if(e.length===0)return Math.floor(Date.now()/1e3);if(e.length===1)return e[0].created_at;let t=e.map(e=>e.created_at).sort((e,t)=>t-e);for(let e=0;e=wl)return t[e];return t[t.length-1]}var El=new Set([6,16]);function Dl(e){return El.has(e)}function Ol(e){return e===1?6:16}var kl=new Set([`mute`,`pin`,`bookmark`,`communities`]);function Al(e){if(e.kind!==3e4)return!1;let t=e.tags.find(([e])=>e===`d`)?.[1]??``;if(kl.has(t))return!0;let n=e.tags.some(([e])=>e===`p`),r=e.tags.some(([e])=>e===`title`||e===`name`);return!n&&!r}function jl(e){if(Al(e)||e.kind===37381&&e.tags.some(([e,t])=>e===`t`&&t===`unlisted`)||e.kind===37516&&e.tags.some(([e,t])=>e===`t`&&t===`hidden`)||e.kind===30030&&!e.tags.some(([e,t,n])=>e===`emoji`&&t&&n))return!0;if(e.kind===2473){let t=/^https:\/\/www\.wikidata\.org\/entity\/Q\d+$/;if(!e.tags.some(([e,n])=>e===`i`&&typeof n==`string`&&t.test(n)))return!0}if(e.kind===12473){let t=/^https:\/\/www\.wikidata\.org\/entity\/Q\d+$/;if(!e.tags.some(([e,n])=>e===`i`&&typeof n==`string`&&t.test(n)))return!0}if(e.kind===30621&&!e.tags.some(([e,t,n])=>e===`edge`&&/^\d+$/.test(t??``)&&/^\d+$/.test(n??``)))return!0;if(e.kind===9802){let t=e.content.trim().length>0,n=e.tags.some(([e])=>e===`a`||e===`e`||e===`r`);if(!t&&!n)return!0}return!1}var Ml=new Cl;function Nl(e){if(typeof e!=`object`||!e)return!1;let t=e;return un(t.id)&&un(t.pubkey)&&typeof t.sig==`string`&&/^[0-9a-f]{128}$/.test(t.sig)&&typeof t.kind==`number`&&Number.isInteger(t.kind)&&typeof t.content==`string`&&typeof t.created_at==`number`&&Number.isInteger(t.created_at)&&Array.isArray(t.tags)&&t.tags.every(e=>Array.isArray(e)&&e.every(e=>typeof e==`string`))}function Pl(e){if(!e.content||e.content.trim()===``)return;let t;try{t=JSON.parse(e.content)}catch{return}if(Nl(t)&&Ml.verify(t))return t}var Fl=500,Il=20;function Ll(e,t){let{nostr:n}=R(),r=e?.id,i=t.relays.join(`,`),a=B({queryKey:[`goal-progress`,r,i,t.closedAt??null],queryFn:async e=>{if(!r)return{receipts:[],isPartial:!1};let i=AbortSignal.any([e.signal,AbortSignal.timeout(8e3)]),a=t.relays.length>0?n.group(t.relays):n,o=[],s=new Set,c=t.closedAt,l=!1;for(let e=0;e!t.closedAt||e.created_at<=t.closedAt);for(let e of u)s.has(e.id)||(s.add(e.id),o.push({msats:jn(e),sender:An(e),createdAt:e.created_at}));if(n.length{let e=a.data?.receipts??[],n=0,r=new Set,i=0;for(let a of e)t.closedAt&&a.createdAt>t.closedAt||a.msats<=0||(n+=a.msats,a.sender&&r.add(a.sender),i++);let o=t.amountMsat,s=Math.floor(o/1e3),c=Math.floor(n/1e3);return{currentMsat:n,currentSats:c,targetMsat:o,targetSats:s,percentage:o>0?Math.min(100,Math.round(n/o*100)):0,contributors:Array.from(r),zapCount:i,isPartial:a.data?.isPartial??!1}},[a.data,t.amountMsat,t.closedAt]),isLoading:a.isLoading}}function Rl(e){let[t,n]=(0,Q.useState)(()=>Math.floor(Date.now()/1e3));return(0,Q.useEffect)(()=>{let t=setInterval(()=>n(Math.floor(Date.now()/1e3)),e);return()=>clearInterval(t)},[e]),t}function zl(e,t){let n=Rl(6e4),r=bl(t),{currentSats:i,percentage:a,isLoading:o,isPartial:s}=Ll(e,t),c=a>=100,l=z(t.beneficiary).data?.metadata,u=l?.display_name||l?.name||er(t.beneficiary),d=kt(t.beneficiary,l),f=l?.lud16||l?.lud06||void 0,p=(0,Q.useMemo)(()=>{if(!t.closedAt)return null;let e=t.closedAt-n;if(e<=0)return`Ended`;let r=Math.floor(e/86400),i=Math.floor(e%86400/3600);if(r>0)return`${r}d ${i}h left`;let a=Math.floor(e%3600/60);return i>0?`${i}h ${a}m left`:`${a}m left`},[t.closedAt,n]),m=(0,Q.useMemo)(()=>t.communityATag?Sl(t.communityATag):void 0,[t.communityATag]),{data:h}=pr(m);return{expired:r,funded:c,currentSats:i,percentage:a,progressLoading:o,progressIsPartial:s,metadata:l,displayName:u,profileUrl:d,lightningAddress:f,deadlineLabel:p,communityName:h?.tags.find(([e])=>e===`name`)?.[1]||h?.tags.find(([e])=>e===`d`)?.[1],communityUrl:(0,Q.useMemo)(()=>{if(m)try{return`/${H.naddrEncode({kind:m.kind,pubkey:m.pubkey,identifier:m.identifier})}`}catch{return}},[m]),image:t.image}}function Bl({event:e}){let t=(0,Q.useMemo)(()=>yl(e),[e]);return t?(0,Z.jsx)(Vl,{event:e,goal:t}):null}function Vl({event:e,goal:t}){let n=zl(e,t),[r,i]=(0,Q.useState)(!1);return(0,Z.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[n.image&&!r&&(0,Z.jsx)(`div`,{className:`-mx-4 aspect-[21/9] overflow-hidden`,children:(0,Z.jsx)(`img`,{src:n.image,alt:t.title,className:`w-full h-full object-cover`,onError:()=>i(!0)})}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(y,{className:`size-4 text-primary shrink-0`}),(0,Z.jsx)(`h3`,{className:`font-semibold text-[15px] leading-tight`,children:t.title})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n.communityUrl&&n.communityName&&(0,Z.jsxs)(K,{to:n.communityUrl,className:`flex items-center gap-1 text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(I,{className:`size-3`}),n.communityName]}),n.funded?(0,Z.jsx)(X,{className:`bg-emerald-500/15 text-emerald-600 dark:text-emerald-400 border-emerald-500/20`,children:`Funded`}):n.expired?(0,Z.jsx)(X,{variant:`secondary`,children:`Ended`}):n.deadlineLabel?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(ht,{className:`size-3`}),n.deadlineLabel]}):null]})]}),t.summary&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed line-clamp-2`,children:t.summary}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(xa,{value:n.percentage,className:G(`h-2.5`,n.funded&&`[&>div]:bg-emerald-500`)}),(0,Z.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:n.progressLoading?(0,Z.jsx)(J,{className:`h-3.5 w-16 inline-block`}):n.progressIsPartial?(0,Z.jsxs)(Cn,{children:[(0,Z.jsx)(xn,{asChild:!0,children:(0,Z.jsxs)(`span`,{className:`cursor-help underline decoration-dotted underline-offset-2`,children:[`~`,xl(n.currentSats),` sats`]})}),(0,Z.jsx)(Sn,{side:`top`,className:`max-w-[240px] text-xs`,children:`Showing at least this amount. More zap receipts exist than we could tally in a single fetch, so the real total is higher.`})]}):(0,Z.jsxs)(Z.Fragment,{children:[xl(n.currentSats),` sats`]})}),(0,Z.jsxs)(`span`,{children:[`of `,xl(t.amountSats),` sats (`,n.percentage,`%)`]})]})]}),t.hasZapSplits?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5 rounded-lg bg-muted/50 px-3 py-2 text-muted-foreground`,children:[(0,Z.jsx)(ce,{className:`size-4 mt-0.5 shrink-0`}),(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed`,children:`This goal uses split recipients. Split zap support is not available in this app yet.`})]}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,Z.jsx)(K,{to:n.profileUrl,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(Qn,{className:`size-8 ring-2 ring-background`,children:[(0,Z.jsx)(Zn,{src:n.metadata?.picture}),(0,Z.jsx)(Xn,{className:`bg-muted text-muted-foreground text-xs`,children:n.displayName.charAt(0).toUpperCase()})]})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Receiving zaps`}),(0,Z.jsx)(K,{to:n.profileUrl,className:`text-sm font-medium truncate block hover:underline`,onClick:e=>e.stopPropagation(),children:n.displayName}),n.lightningAddress&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,title:n.lightningAddress,children:[(0,Z.jsx)(Le,{className:`size-3 inline-block mr-0.5 -mt-0.5`}),n.lightningAddress]})]})]})]})}var Hl=50;function Ul(e){let t=0n;for(let n=0;ne===`d`)?.[1];return e.kind===35128&&t?`${Ul(e.pubkey)}${t}`:H.npubEncode(e.pubkey)}function Gl({event:e}){let t=e.tags.find(([e])=>e===`title`)?.[1],n=e.tags.find(([e])=>e===`description`)?.[1],i=e.tags.find(([e])=>e===`d`)?.[1],a=Y(e.tags.find(([e])=>e===`source`)?.[1]),o=e.tags.filter(([e])=>e===`path`),s=e.tags.filter(([e])=>e===`server`),l=e.kind===35128&&!!i,u=Wl(e),f=`https://${u}.nsite.lol`,p=t||(l?i:`Root Site`),{addToSidebar:m,removeFromSidebar:h,orderedItems:g}=$n(),_=l?`nsite://${u}`:void 0,v=_?g.includes(_):!1,{data:y,isLoading:b}=Tr(f),x=y?.thumbnail_url,S=y?.title,C=(0,Q.useCallback)(()=>{_&&(v?(h(_),W({title:`Removed from sidebar`})):(m(_),W({title:`Added to sidebar`})))},[_,v,m,h]);return b?(0,Z.jsx)(Kl,{}):(0,Z.jsxs)(`div`,{className:G(`group mt-2 rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors`),onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,className:`block`,onClick:e=>e.stopPropagation(),children:[x&&(0,Z.jsx)(`div`,{className:`w-full overflow-hidden bg-muted`,children:(0,Z.jsx)(`img`,{src:x,alt:``,className:`w-full h-[180px] object-cover transition-transform duration-300 group-hover:scale-[1.02]`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`}})}),(0,Z.jsxs)(`div`,{className:`px-3.5 pt-2.5 pb-1.5 space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(cr,{url:f,size:16,className:`shrink-0`}),(0,Z.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2`,children:S||p})]}),(n||y?.author_name)&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:n||y?.author_name}),(o.length>0||s.length>0)&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 pt-0.5 text-[11px] text-muted-foreground`,children:[o.length>0&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(je,{className:`size-3`}),o.length,` `,o.length===1?`file`:`files`]}),s.length>0&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(Ge,{className:`size-3`}),s.length,` `,s.length===1?`server`:`servers`]})]})]})]}),(0,Z.jsxs)(`div`,{className:`px-3.5 pb-2.5 flex items-center gap-2`,children:[a?(0,Z.jsx)(q,{asChild:!0,size:`sm`,variant:`secondary`,className:`h-7 text-xs`,children:(0,Z.jsxs)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(r,{className:`size-3 mr-1`}),`Source`]})}):(0,Z.jsx)(q,{asChild:!0,size:`sm`,variant:`secondary`,className:`h-7 text-xs`,children:(0,Z.jsxs)(`a`,{href:f,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(F,{className:`size-3 mr-1`}),`Visit`]})}),_&&(0,Z.jsxs)(q,{size:`sm`,variant:`ghost`,className:`h-7 text-xs ml-auto text-muted-foreground`,onClick:e=>{e.stopPropagation(),C()},children:[v?(0,Z.jsx)(c,{className:`size-3 mr-1`}):(0,Z.jsx)(d,{className:`size-3 mr-1`}),v?`Unpin`:`Pin`]})]})]})}function Kl(){return(0,Z.jsxs)(`div`,{className:`mt-2 rounded-2xl border border-border overflow-hidden`,children:[(0,Z.jsx)(J,{className:`w-full h-[180px] rounded-none`}),(0,Z.jsxs)(`div`,{className:`px-3.5 py-2.5 space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-3 w-28`}),(0,Z.jsx)(J,{className:`h-4 w-3/4`}),(0,Z.jsx)(J,{className:`h-3 w-full`}),(0,Z.jsx)(J,{className:`h-3 w-32`})]})]})}function ql({src:e,poster:t,className:n,title:r,artist:i}){let a=(0,Q.useRef)(null),o=(0,Q.useRef)(null),s=(0,Q.useRef)(null),{config:c}=Kt(),l=!c.lowBandwidthMode,[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!0),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),{showControls:b,revealControls:x,scheduleHide:S,isMuted:C,volume:w,toggleMute:E,handleVolumeChange:D}=Zr({mediaRef:a,containerRef:o,isPlaying:u});(0,Q.useEffect)(()=>{let t=a.current;if(!t||!e)return;if(t.canPlayType(`application/vnd.apple.mpegurl`)){t.src=e,t.play().catch(()=>{y(!0)});return}let n=!1;return Mt(async()=>{let{default:e}=await import(`./hls-xRULx_jC.js`);return{default:e}},[]).then(({default:r})=>{if(n)return;if(!r.isSupported()){_(!0);return}let i=new r({enableWorker:!0,lowLatencyMode:!0,backBufferLength:30});s.current=i,i.loadSource(e),i.attachMedia(t),i.on(r.Events.MANIFEST_PARSED,()=>{t.play().catch(()=>{y(!0)})}),i.on(r.Events.ERROR,(e,t)=>{if(t.fatal)switch(t.type){case r.ErrorTypes.NETWORK_ERROR:i.startLoad();break;case r.ErrorTypes.MEDIA_ERROR:i.recoverMediaError();break;default:_(!0),i.destroy()}})}).catch(()=>{n||_(!0)}),()=>{n=!0,s.current&&=(s.current.destroy(),null)}},[e]),(0,Q.useEffect)(()=>{let e=()=>{p(!!document.fullscreenElement)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),(0,Q.useEffect)(()=>{if(!(`mediaSession`in navigator))return;let e=a.current;if(!e)return;let n=t?[{src:t,sizes:`512x512`,type:`image/jpeg`}]:[];return navigator.mediaSession.metadata=new MediaMetadata({title:r||`Live Stream`,artist:i||``,artwork:n}),navigator.mediaSession.setActionHandler(`play`,()=>e.play().catch(()=>{})),navigator.mediaSession.setActionHandler(`pause`,()=>e.pause()),navigator.mediaSession.setActionHandler(`seekto`,null),navigator.mediaSession.setActionHandler(`previoustrack`,null),navigator.mediaSession.setActionHandler(`nexttrack`,null),()=>{`mediaSession`in navigator&&(navigator.mediaSession.metadata=null,navigator.mediaSession.setActionHandler(`play`,null),navigator.mediaSession.setActionHandler(`pause`,null))}},[r,i,t]),(0,Q.useEffect)(()=>{`mediaSession`in navigator&&(navigator.mediaSession.playbackState=u?`playing`:`paused`)},[u]);let O=(0,Q.useCallback)(e=>{e.stopPropagation();let t=a.current;t&&(t.paused?t.play().catch(()=>{}):t.pause())},[]),k=(0,Q.useCallback)(e=>{if(e.stopPropagation(),v){let e=a.current;if(!e)return;e.play().then(()=>{y(!1),h(!1)}).catch(()=>{});return}if(!b){x();return}O(e),x()},[v,b,O,x]),A=(0,Q.useCallback)(e=>{e.stopPropagation();let t=o.current;t&&(document.fullscreenElement?document.exitFullscreen():t.requestFullscreen())},[]);return g?(0,Z.jsx)(`div`,{className:G(`relative lg:rounded-2xl overflow-hidden bg-black aspect-video flex items-center justify-center`,n),children:(0,Z.jsxs)(`div`,{className:`text-center space-y-2 px-4`,children:[(0,Z.jsx)(`p`,{className:`text-white/80 text-sm font-medium`,children:`Stream unavailable`}),(0,Z.jsx)(`p`,{className:`text-white/50 text-xs`,children:`The live stream could not be loaded. It may have ended or the URL is unreachable.`})]})}):(0,Z.jsxs)(`div`,{ref:o,className:G(`relative lg:rounded-2xl overflow-hidden bg-black group aspect-video`,n),onMouseMove:x,onMouseLeave:()=>{u&&S()},onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`video`,{ref:a,poster:t,className:`w-full h-full object-contain cursor-pointer`,playsInline:!0,autoPlay:l,muted:!0,"webkit-playsinline":`true`,onClick:k,onPlay:()=>d(!0),onPause:()=>d(!1),onWaiting:()=>h(!0),onPlaying:()=>h(!1),onCanPlay:()=>h(!1)}),v&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/40 cursor-pointer`,onClick:k,children:(0,Z.jsx)(`div`,{className:`size-16 rounded-full bg-black/60 flex items-center justify-center backdrop-blur-sm transition-transform hover:scale-110`,children:(0,Z.jsx)(pt,{className:`size-8 text-white ml-1`,fill:`white`})})}),m&&!v&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:(0,Z.jsx)(`div`,{className:`size-12 border-[3px] border-white/20 border-t-white rounded-full animate-spin`})}),(0,Z.jsx)(`div`,{className:G(`absolute bottom-0 left-0 right-0 transition-opacity duration-200`,`bg-gradient-to-t from-black/80 via-black/40 to-transparent pt-10 pb-3 px-4`,b&&!v?`opacity-100`:`opacity-0 pointer-events-none`),children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`button`,{onClick:O,className:`text-white hover:text-white/80 transition-colors p-1`,"aria-label":u?`Pause`:`Play`,children:u?(0,Z.jsx)(Ve,{className:`size-5`,fill:`white`}):(0,Z.jsx)(pt,{className:`size-5 ml-0.5`,fill:`white`})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 bg-red-600 text-white text-xs font-bold px-2 py-0.5 rounded`,children:[(0,Z.jsx)(`div`,{className:`size-1.5 bg-white rounded-full animate-pulse`}),`LIVE`]}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 group/vol`,children:[(0,Z.jsx)(`button`,{onClick:E,className:`text-white hover:text-white/80 transition-colors shrink-0`,"aria-label":C?`Unmute`:`Mute`,children:C||w===0?(0,Z.jsx)(Ne,{className:`size-5`}):w<.5?(0,Z.jsx)(ut,{className:`size-5`}):(0,Z.jsx)(xe,{className:`size-5`})}),(0,Z.jsx)(`input`,{type:`range`,min:0,max:1,step:.02,value:C?0:w,onChange:D,onClick:e=>e.stopPropagation(),"aria-label":`Volume`,className:G(`w-0 opacity-0 group-hover/vol:w-16 group-hover/vol:opacity-100 group-focus-within/vol:w-16 group-focus-within/vol:opacity-100`,`transition-all duration-200 cursor-pointer accent-white h-1`)})]}),(0,Z.jsx)(`button`,{onClick:A,className:`text-white hover:text-white/80 transition-colors p-1`,"aria-label":f?`Exit fullscreen`:`Fullscreen`,children:f?(0,Z.jsx)(T,{className:`size-[18px]`}):(0,Z.jsx)(Ze,{className:`size-[18px]`})})]})})]})}function Jl(e,t){return e.find(([e])=>e===t)?.[1]}function Yl(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function Xl(e){if(e.length<3)return null;let[,t,n,r,i,a,o]=e,s=parseInt(n,10);return!t||isNaN(s)||s<1?null:{name:t,quantity:s,setId:r??``,artId:i??``,lang:a??``,foil:o===`foil`||o===`true`}}var Zl={standard:`Standard`,modern:`Modern`,commander:`Commander`,legacy:`Legacy`,vintage:`Vintage`,pioneer:`Pioneer`,pauper:`Pauper`,cedh:`cEDH`,limited:`Limited`,draft:`Draft`,sealed:`Sealed`,brawl:`Brawl`,historic:`Historic`,explorer:`Explorer`,alchemy:`Alchemy`,timeless:`Timeless`},Ql={aggro:`Aggro`,midrange:`Midrange`,control:`Control`,combo:`Combo`,tempo:`Tempo`,ramp:`Ramp`,tribal:`Tribal`,burn:`Burn`,mill:`Mill`,stax:`Stax`,tokens:`Tokens`,reanimator:`Reanimator`,voltron:`Voltron`,aristocrats:`Aristocrats`};function $l({card:e,onClick:t}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1 text-[13px] hover:bg-secondary/30 transition-colors cursor-pointer`,onClick:t,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsxs)(`span`,{className:`text-muted-foreground tabular-nums text-xs w-5 text-right shrink-0`,children:[e.quantity,`x`]}),(0,Z.jsx)(`span`,{className:G(`truncate`,e.foil&&`bg-gradient-to-r from-foreground via-primary to-foreground bg-clip-text text-transparent`),children:e.name}),e.foil&&(0,Z.jsx)($e,{className:`size-3 text-primary shrink-0`})]}),e.setId&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider shrink-0 ml-2`,children:e.setId})]})}function eu({card:e,onClick:t}){let[n,r]=(0,Q.useState)(!1);return n?(0,Z.jsxs)(`div`,{className:`relative aspect-[5/7] rounded-lg bg-secondary/60 border border-border flex items-center justify-center p-1 cursor-pointer`,onClick:t,children:[(0,Z.jsx)(`span`,{className:`text-[9px] text-center text-muted-foreground leading-tight line-clamp-3`,children:e.name}),e.quantity>1&&(0,Z.jsx)(tu,{quantity:e.quantity})]}):(0,Z.jsxs)(`div`,{className:`relative aspect-[5/7] rounded-lg overflow-hidden group cursor-pointer`,onClick:t,children:[(0,Z.jsx)(`img`,{src:Ys(e,`normal`),alt:e.name,className:`w-full h-full object-cover transition-transform group-hover:scale-105`,loading:`lazy`,onError:()=>r(!0)}),e.foil&&(0,Z.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-transparent via-white/10 to-transparent pointer-events-none`}),e.quantity>1&&(0,Z.jsx)(tu,{quantity:e.quantity})]})}function tu({quantity:e}){return(0,Z.jsxs)(`span`,{className:`absolute top-1 right-1 bg-black/70 text-white text-[10px] font-bold px-1.5 py-0.5 rounded-full leading-none backdrop-blur-sm`,children:[`x`,e]})}function nu({card:e,index:t,total:n}){return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[n>1&&(0,Z.jsxs)(`span`,{className:`text-white/80 text-sm font-medium tabular-nums`,children:[t+1,` / `,n]}),(0,Z.jsx)(`span`,{className:`text-white text-sm font-medium truncate max-w-[200px]`,children:e.name}),e.foil&&(0,Z.jsx)($e,{className:`size-3.5 text-amber-400 shrink-0`})]})}function ru({event:e}){let t=Jl(e.tags,`title`),n=Jl(e.tags,`banner`),r=Yl(e.tags,`C`),i=Jl(e.tags,`S`),a=Yl(e.tags,`t`),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(null),u=(0,Q.useMemo)(()=>e.tags.filter(([e])=>e===`c`).map(Xl).filter(e=>e!==null),[e.tags]),d=(0,Q.useMemo)(()=>e.tags.filter(([e])=>e===`b`).map(Xl).filter(e=>e!==null),[e.tags]),f=(0,Q.useMemo)(()=>[...u,...d],[u,d]),m=(0,Q.useMemo)(()=>a.filter(e=>e in Zl),[a]),h=(0,Q.useMemo)(()=>a.filter(e=>e in Ql),[a]),g=(0,Q.useMemo)(()=>a.filter(e=>!(e in Zl)&&!(e in Ql)),[a]),_=(0,Q.useMemo)(()=>u.reduce((e,t)=>e+t.quantity,0),[u]),v=(0,Q.useMemo)(()=>d.reduce((e,t)=>e+t.quantity,0),[d]),y=(0,Q.useCallback)(e=>{l(e)},[]),b=(0,Q.useCallback)(()=>{l(null)},[]),x=(0,Q.useCallback)(()=>{l(e=>e===null?null:(e+1)%f.length)},[f.length]),S=(0,Q.useCallback)(()=>{l(e=>e===null?null:(e-1+f.length)%f.length)},[f.length]);return(0,Z.jsxs)(`div`,{className:`mt-2`,children:[n&&(0,Z.jsx)(`div`,{className:`rounded-2xl overflow-hidden mb-3`,children:(0,Z.jsx)(`img`,{src:n,alt:t??`Magic deck`,className:`w-full max-h-[200px] object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`}})}),t&&(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 mb-2`,children:[(0,Z.jsx)(Tn,{className:`size-4 text-primary mt-0.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`text-[15px] font-semibold leading-snug`,children:t})]}),r.length>0&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)(Je,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Commander`,r.length>1?`s`:``,`:`]}),(0,Z.jsx)(`span`,{className:`text-xs font-medium`,children:r.join(` & `)})]}),i&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Z.jsx)($e,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Companion:`}),(0,Z.jsx)(`span`,{className:`text-xs font-medium`,children:i})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-2`,children:[m.map(e=>(0,Z.jsx)(K,{to:`/t/${encodeURIComponent(e)}`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium hover:bg-secondary/80 transition-colors`,children:[(0,Z.jsx)(se,{className:`size-3`}),Zl[e]??e]})},e)),h.map(e=>(0,Z.jsx)(K,{to:`/t/${encodeURIComponent(e)}`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(X,{variant:`outline`,className:`text-[11px] font-medium hover:bg-secondary/80 transition-colors`,children:Ql[e]??e})},e)),g.map(e=>(0,Z.jsx)(K,{to:`/t/${encodeURIComponent(e)}`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(X,{variant:`outline`,className:`text-[11px] font-medium hover:bg-secondary/80 transition-colors`,children:e})},e)),(0,Z.jsxs)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:[(0,Z.jsx)(Tn,{className:`size-3`}),_,` cards`]}),v>0&&(0,Z.jsxs)(X,{variant:`secondary`,className:`text-[11px] gap-1 font-medium`,children:[v,` sideboard`]})]}),u.length>0&&(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 bg-secondary/30 border-b border-border/50`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium text-muted-foreground`,children:o?`Visual Spoiler`:`Decklist`}),(0,Z.jsxs)(`button`,{onClick:()=>s(!o),className:`flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors`,children:[o?(0,Z.jsx)(it,{className:`size-3.5`}):(0,Z.jsx)(p,{className:`size-3.5`}),o?`List`:`Visual`]})]}),o?(0,Z.jsxs)(`div`,{className:`max-h-[400px] overflow-y-auto p-2`,children:[(0,Z.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:u.map((e,t)=>(0,Z.jsx)(eu,{card:e,onClick:()=>y(t)},`${e.name}-${t}`))}),d.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`px-1 py-2 mt-1`,children:(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Sideboard`})}),(0,Z.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:d.map((e,t)=>(0,Z.jsx)(eu,{card:e,onClick:()=>y(u.length+t)},`sb-${e.name}-${t}`))})]})]}):(0,Z.jsxs)(`div`,{className:`max-h-[240px] overflow-y-auto`,children:[u.map((e,t)=>(0,Z.jsx)($l,{card:e,onClick:()=>y(t)},`${e.name}-${t}`)),d.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`px-3 py-1.5 bg-secondary/40 border-y border-border/50`,children:(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Sideboard`})}),d.map((e,t)=>(0,Z.jsx)($l,{card:e,onClick:()=>y(u.length+t)},`sb-${e.name}-${t}`))]})]})]}),c!==null&&f.length>0&&(0,Z.jsx)(Kr,{images:f.map(e=>Ys(e,`large`)),currentIndex:c,onClose:b,onNext:x,onPrev:S,showDownload:!1,maxDotIndicators:20,topBarLeft:(0,Z.jsx)(nu,{card:f[c],index:c,total:f.length})})]})}function iu({eventId:e,targetPubkey:t,communityATag:n,open:r,onOpenChange:i}){let a=V(),{mutateAsync:o,isPending:s}=ln(),[c,l]=(0,Q.useState)(``);return(0,Z.jsx)(Gn,{open:r,onOpenChange:i,children:(0,Z.jsxs)(Vn,{className:`max-w-md rounded-2xl flex flex-col overflow-hidden`,children:[(0,Z.jsx)(zn,{children:`Remove from group`}),(0,Z.jsx)(Un,{className:`text-sm text-muted-foreground`,children:`This will hide the post from canonical group views.`}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(Ei,{htmlFor:`ban-reason`,className:`text-sm font-medium`,children:[`Reason `,(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Z.jsx)(aa,{id:`ban-reason`,value:c,onChange:e=>l(e.target.value),placeholder:`Reason for this action...`,className:`resize-none`,rows:2})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 justify-end pt-2`,children:[(0,Z.jsx)(q,{variant:`ghost`,onClick:()=>i(!1),disabled:s,children:`Cancel`}),(0,Z.jsx)(q,{onClick:async()=>{try{let r=[[`e`,e,`other`],[`p`,t,`other`],[`A`,n],[`L`,pi],[`l`,`ban`,pi]];await o({kind:hi,content:c.trim(),tags:r}),await Promise.all([a.invalidateQueries({queryKey:[`community-members`,n]}),a.invalidateQueries({predicate:e=>{let[t,r]=e.queryKey;return t===`community-activity-feed`&&typeof r==`string`&&r.split(`,`).includes(n)}}),a.invalidateQueries({queryKey:[`organization-activity`,n]})]),W({title:`Post removed from group`}),l(``),i(!1)}catch{W({title:`Failed to remove post from group`,variant:`destructive`})}},disabled:s,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:s?`Submitting...`:`Remove`})]})]})})}var au=[{value:`spam`,label:`Spam`,description:`Unsolicited or repetitive content`},{value:`nudity`,label:`Nudity or sexual content`,description:`Depictions of nudity or pornography`},{value:`impersonation`,label:`Impersonation`,description:`Pretending to be someone else`},{value:`profanity`,label:`Hateful speech`,description:`Profanity, hateful or abusive speech`},{value:`illegal`,label:`Illegal content`,description:`Content that may be illegal in some jurisdictions`},{value:`malware`,label:`Malware`,description:`Virus, trojan horse, spyware, or ransomware`},{value:`other`,label:`Other`,description:`Something else not listed above`}];function ou({event:e,pubkey:t,open:n,onOpenChange:r}){let{user:i}=U(),{mutateAsync:a,isPending:o}=ln(),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),d=!!t,f=e?.pubkey??t,p=s!==``&&!o;return(0,Z.jsx)(Gn,{open:n,onOpenChange:r,children:(0,Z.jsxs)(Vn,{className:`max-w-md max-h-[85dvh] rounded-2xl flex flex-col overflow-hidden`,children:[(0,Z.jsx)(zn,{children:d?`Report user`:`Report post`}),(0,Z.jsxs)(Un,{className:`text-sm text-muted-foreground`,children:[`Select a reason for reporting this `,d?`user`:`post`,`.`]}),(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0 -mx-6 px-6`,children:[(0,Z.jsx)(Ma,{value:s,onValueChange:e=>c(e),className:`mt-2 space-y-1`,children:au.map(e=>(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg px-3 py-2.5 cursor-pointer transition-colors hover:bg-secondary/60`,children:[(0,Z.jsx)(ja,{value:e.value,className:`mt-0.5 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:e.label}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e.description})]})]},e.value))}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 pb-1`,children:[(0,Z.jsxs)(Ei,{htmlFor:`report-details`,className:`text-sm font-medium`,children:[`Additional details `,s!==`other`&&(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Z.jsx)(aa,{id:`report-details`,value:l,onChange:e=>u(e.target.value),placeholder:`Provide additional context...`,className:`resize-none`,rows:2})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 justify-end pt-2 shrink-0`,children:[(0,Z.jsx)(q,{variant:`ghost`,onClick:()=>r(!1),disabled:o,children:`Cancel`}),(0,Z.jsx)(q,{onClick:async()=>{if(!(!s||!i||!f))try{let t=[[`p`,f,s]];e&&t.unshift([`e`,e.id,s]),await a({kind:1984,content:l.trim(),tags:t}),W({title:`Report submitted`}),c(``),u(``),r(!1)}catch{W({title:`Failed to submit report`,variant:`destructive`})}},disabled:!p,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:o?`Submitting...`:`Submit Report`})]})]})})}function su({event:e,communityATag:t,open:n,onOpenChange:r}){let{user:i}=U(),a=V(),{mutateAsync:o,isPending:s}=ln(),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),f=c!==``&&!s;return(0,Z.jsx)(Gn,{open:n,onOpenChange:r,children:(0,Z.jsxs)(Vn,{className:`max-w-md max-h-[85dvh] rounded-2xl flex flex-col overflow-hidden`,children:[(0,Z.jsx)(zn,{children:`Report post`}),(0,Z.jsx)(Un,{className:`text-sm text-muted-foreground`,children:`Select a reason for reporting this post to the organization.`}),(0,Z.jsxs)(`div`,{className:`flex-1 overflow-y-auto min-h-0 -mx-6 px-6`,children:[(0,Z.jsx)(Ma,{value:c,onValueChange:e=>l(e),className:`mt-2 space-y-1`,children:vi.map(e=>{let t=bi[e];return(0,Z.jsxs)(`label`,{className:`flex items-start gap-3 rounded-lg px-3 py-2.5 cursor-pointer transition-colors hover:bg-secondary/60`,children:[(0,Z.jsx)(ja,{value:e,className:`mt-0.5 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium`,children:t.label}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t.description})]})]},e)})}),(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2 pb-1`,children:[(0,Z.jsxs)(Ei,{htmlFor:`community-report-details`,className:`text-sm font-medium`,children:[`Additional details`,` `,c!==`other`&&(0,Z.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Z.jsx)(aa,{id:`community-report-details`,value:u,onChange:e=>d(e.target.value),placeholder:`Provide additional context...`,className:`resize-none`,rows:2})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-2 justify-end pt-2 shrink-0`,children:[(0,Z.jsx)(q,{variant:`ghost`,onClick:()=>r(!1),disabled:s,children:`Cancel`}),(0,Z.jsx)(q,{onClick:async()=>{if(!(!c||!i))try{await o({kind:hi,content:u.trim(),tags:[[`e`,e.id,c],[`p`,e.pubkey,c],[`A`,t]]}),await Promise.all([a.invalidateQueries({queryKey:[`community-members`,t]}),a.invalidateQueries({predicate:e=>{let[n,r]=e.queryKey;return n===`community-activity-feed`&&typeof r==`string`&&r.split(`,`).includes(t)}})]),W({title:`Report submitted`}),l(``),d(``),r(!1)}catch{W({title:`Failed to submit report`,variant:`destructive`})}},disabled:!f,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:s?`Submitting...`:`Submit Report`})]})]})})}function cu(e){return{id:e.tags.find(e=>e[0]===`d`)?.[1]??``,title:e.tags.find(e=>e[0]===`title`)?.[1]||e.tags.find(e=>e[0]===`name`)?.[1]||`Untitled Pack`,pubkeys:e.tags.filter(e=>e[0]===`p`&&e[1]).map(e=>e[1]),event:e}}function lu(){let{nostr:e}=R(),{user:t}=U();return B({queryKey:[`own-follow-packs`,t?.pubkey],queryFn:async({signal:n})=>{if(!t)return[];let r=await e.query([{kinds:[39089],authors:[t.pubkey],limit:100}],{signal:AbortSignal.any([n,AbortSignal.timeout(8e3)])}),i=new Map;for(let e of r){let t=e.tags.find(e=>e[0]===`d`)?.[1]??``,n=i.get(t);(!n||e.created_at>n.created_at)&&i.set(t,e)}return Array.from(i.values()).map(cu)},enabled:!!t,staleTime:3e4})}var uu=new Set([`mute`,`pin`,`bookmark`,`communities`]);function du(e){return e.includes(`?iv=`)}async function fu(e,t,n){if(!e)return null;try{let r=null;if(du(e)){if(t.nip04)r=await t.nip04.decrypt(n,e);else return console.warn(`List uses NIP-04 encryption but signer does not support nip04`),null}else if(t.nip44)r=await t.nip44.decrypt(n,e);else return console.warn(`List uses NIP-44 encryption but signer does not support nip44`),null;if(!r)return null;let i=JSON.parse(r);return Array.isArray(i)?i:null}catch(e){return console.error(`Failed to decrypt list content:`,e),null}}function pu(e){let t=t=>e.tags.find(([e])=>e===t)?.[1],n=t(`d`)??``;return{id:n,title:t(`title`)||t(`name`)||n,description:t(`description`)||t(`summary`)||void 0,image:t(`image`)||t(`thumb`)||void 0,pubkeys:e.tags.filter(([e])=>e===`p`).map(([,e])=>e),privatePubkeys:[],event:e}}async function mu(e,t,n){let r=pu(e);if(!e.content)return r;let i=await fu(e.content,t,n);if(!i)return r;let a=i.filter(([e])=>e===`p`).map(([,e])=>e).filter(Boolean);if(a.length===0)return r;let o=new Set(r.pubkeys),s=[...r.pubkeys];for(let e of a)o.has(e)||s.push(e);return{...r,pubkeys:s,privatePubkeys:a}}async function hu(e,t,n){if(e.length===0)return``;if(!t.nip44)return console.warn(`Cannot re-encrypt private list items: signer does not support NIP-44`),``;let r=e.map(e=>[`p`,e]),i=JSON.stringify(r);return t.nip44.encrypt(n,i)}function gu(){let{nostr:e}=R(),{user:t}=U(),n=V(),{mutateAsync:r}=ln(),i=B({queryKey:[`user-lists`,t?.pubkey],queryFn:async({signal:n})=>{if(!t)return[];let r=AbortSignal.any([n,AbortSignal.timeout(8e3)]),[i,a]=await Promise.all([e.query([{kinds:[3e4],authors:[t.pubkey],limit:100}],{signal:r}),e.query([{kinds:[5],authors:[t.pubkey],"#k":[`30000`],limit:200}],{signal:r})]),o=new Set;for(let e of a)for(let[t,n]of e.tags)t===`a`&&n?.startsWith(`30000:`)&&o.add(n);let s=i.filter(e=>{let n=e.tags.find(([e])=>e===`d`)?.[1]??``;if(uu.has(n))return!1;let r=`30000:${t.pubkey}:${n}`;if(o.has(r))return!1;let i=e.tags.some(([e])=>e===`p`),a=e.tags.some(([e])=>e===`title`||e===`name`),s=!!e.content;return!(!i&&!a&&!s)});return await Promise.all(s.map(e=>mu(e,t.signer,t.pubkey)))},enabled:!!t,staleTime:6e4}),a=i.data??[],o=Lt({mutationFn:async({title:e,description:n,pubkeys:i=[]})=>{if(!t)throw Error(`Must be logged in`);let a=crypto.randomUUID(),o=[[`d`,a],[`title`,e.trim()],...n?.trim()?[[`description`,n.trim()]]:[],...i.map(e=>[`p`,e]),[`alt`,`Follow set: ${e.trim()}`]];return await r({kind:3e4,content:``,tags:o}),{id:a,title:e.trim(),pubkeys:i}},onSuccess:()=>{n.invalidateQueries({queryKey:[`user-lists`,t?.pubkey]})}}),s=Lt({mutationFn:async({listId:n,pubkey:i})=>{if(!t)throw Error(`Must be logged in`);let a=await cn(e,{kinds:[3e4],authors:[t.pubkey],"#d":[n]});if(!a)throw Error(`List not found`);let o=await mu(a,t.signer,t.pubkey);if(o.pubkeys.includes(i))return;let s=[...a.tags,[`p`,i]],c=await hu(o.privatePubkeys,t.signer,t.pubkey);await r({kind:3e4,content:c,tags:s,prev:a})},onSuccess:()=>{n.invalidateQueries({queryKey:[`user-lists`,t?.pubkey]})}}),c=Lt({mutationFn:async({listId:n,pubkey:i})=>{if(!t)throw Error(`Must be logged in`);let a=await cn(e,{kinds:[3e4],authors:[t.pubkey],"#d":[n]});if(!a)throw Error(`List not found`);let o=await mu(a,t.signer,t.pubkey),s=a.tags.filter(([e,t])=>e!==`p`||t!==i),c=await hu(o.privatePubkeys.filter(e=>e!==i),t.signer,t.pubkey);await r({kind:3e4,content:c,tags:s,prev:a})},onSuccess:()=>{n.invalidateQueries({queryKey:[`user-lists`,t?.pubkey]})}}),l=Lt({mutationFn:async({listId:n,title:i})=>{if(!t)throw Error(`Must be logged in`);let a=await cn(e,{kinds:[3e4],authors:[t.pubkey],"#d":[n]});if(!a)throw Error(`List not found`);let o=await mu(a,t.signer,t.pubkey),s=a.tags.map(([e,...t])=>e===`title`?[`title`,i.trim(),...t]:[e,...t]);s.find(([e])=>e===`title`)||s.push([`title`,i.trim()]);let c=await hu(o.privatePubkeys,t.signer,t.pubkey);await r({kind:3e4,content:c,tags:s,prev:a})},onSuccess:()=>{n.invalidateQueries({queryKey:[`user-lists`,t?.pubkey]})}}),u=Lt({mutationFn:async({listId:e})=>{if(!t)throw Error(`Must be logged in`);let n=a.find(t=>t.id===e);if(!n)throw Error(`List not found`);await r({kind:3e4,content:``,tags:[[`d`,e]]});let i=`30000:${t.pubkey}:${e}`;return await r({kind:5,content:`Deleted list`,tags:[[`e`,n.event.id],[`a`,i],[`k`,`30000`]]}),{listId:e}},onSuccess:({listId:e})=>{n.setQueryData([`user-lists`,t?.pubkey],t=>t?t.filter(t=>t.id!==e):[])}});function d(e,t){return a.find(t=>t.id===e)?.pubkeys.includes(t)??!1}return{lists:a,isLoading:i.isLoading,createList:o,addToList:s,removeFromList:c,renameList:l,deleteList:u,isInList:d}}function _u(e){let{lists:t}=gu(),{data:n=[]}=lu();return(0,Q.useMemo)(()=>{if(e.length===0)return``;let r=t.find(t=>t.pubkeys.length===e.length&&e.every(e=>t.pubkeys.includes(e)));if(r)return`set:${r.id}`;let i=n.find(t=>t.pubkeys.length===e.length&&e.every(e=>t.pubkeys.includes(e)));return i?`pack:${i.id}`:``},[e,t,n])}function vu({pubkey:e,displayName:t,open:n,onOpenChange:r}){let{user:i}=U(),{lists:a,isLoading:s,addToList:c,createList:l,isInList:u}=gu(),{data:d=[],isLoading:f}=lu(),{mutateAsync:p}=ln(),m=V(),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(new Set),C=e=>{e||S(new Set),r(e)},w=()=>C(!1),T=s||f,E=async t=>{if(!_){v(t);try{await c.mutateAsync({listId:t,pubkey:e}),W({title:`Added to list`})}catch{W({title:`Failed to add to list`,variant:`destructive`})}finally{v(null)}}},D=async t=>{if(!_){v(t.id);try{let n=[...t.event.tags,[`p`,e]];await p({kind:39089,content:t.event.content??``,tags:n}),S(e=>new Set(e).add(t.id)),m.invalidateQueries({queryKey:[`own-follow-packs`,i?.pubkey]}),W({title:`Added to "${t.title}"`})}catch{W({title:`Failed to add to pack`,variant:`destructive`})}finally{v(null)}}},O=async()=>{if(!(!h.trim()||y)){b(!0);try{let t=await l.mutateAsync({title:h.trim(),pubkeys:[e]});W({title:`Created "${t.title}" and added`}),g(``)}catch{W({title:`Failed to create list`,variant:`destructive`})}finally{b(!1)}}},A=a.length>0||d.length>0;return i?(0,Z.jsx)(Gn,{open:n,onOpenChange:C,children:(0,Z.jsxs)(Vn,{className:`max-w-sm max-h-[80dvh] p-0 gap-0 rounded-2xl overflow-hidden [&>button]:hidden flex flex-col`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 shrink-0`,children:[(0,Z.jsx)(Rn,{className:`p-0 space-y-0`,children:(0,Z.jsx)(zn,{className:`text-base font-bold`,children:t?`Add ${t} to list`:`Add to list`})}),(0,Z.jsx)(q,{variant:`ghost`,size:`icon`,className:`rounded-full size-8 shrink-0`,onClick:w,children:(0,Z.jsx)(Ye,{className:`size-4`})})]}),(0,Z.jsx)(`div`,{className:`overflow-y-auto flex-1`,children:T?(0,Z.jsx)(`div`,{className:`py-2 space-y-1`,children:Array.from({length:3}).map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5 flex-1`,children:[(0,Z.jsx)(J,{className:`size-4 rounded`}),(0,Z.jsx)(J,{className:`h-4 w-32`})]}),(0,Z.jsx)(J,{className:`h-7 w-14 rounded-md`})]},t))}):A?(0,Z.jsxs)(`div`,{className:`py-1`,children:[a.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[d.length>0&&(0,Z.jsx)(`p`,{className:`px-4 pt-1 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Lists`}),a.map(t=>{let n=u(t.id,e),r=_===t.id;return(0,Z.jsx)(yu,{icon:(0,Z.jsx)(it,{className:`size-3.5 text-muted-foreground shrink-0`}),label:t.title,count:t.pubkeys.length,inList:n,isPending:r,disabled:!!_,onAdd:()=>E(t.id)},t.id)})]}),d.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[a.length>0&&(0,Z.jsx)(ji,{className:`my-1`}),(0,Z.jsx)(`p`,{className:`px-4 pt-1 pb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Follow Packs`}),d.map(t=>{let n=t.pubkeys.includes(e)||x.has(t.id),r=_===t.id;return(0,Z.jsx)(yu,{icon:(0,Z.jsx)(k,{className:`size-3.5 text-muted-foreground shrink-0`}),label:t.title,count:t.pubkeys.length,inList:n,isPending:r,disabled:!!_,onAdd:()=>D(t)},t.id)})]})]}):(0,Z.jsxs)(`div`,{className:`py-8 px-4 text-center text-sm text-muted-foreground`,children:[(0,Z.jsx)(it,{className:`size-8 mx-auto mb-2 text-muted-foreground`}),`No lists or packs yet. Create one below.`]})}),(0,Z.jsx)(ji,{}),(0,Z.jsxs)(`div`,{className:`p-3 space-y-2 shrink-0`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium uppercase tracking-wide px-1`,children:`New list`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(In,{placeholder:`List name…`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},className:`flex-1 h-8 text-base md:text-sm`,disabled:y}),(0,Z.jsxs)(q,{size:`sm`,onClick:O,disabled:!h.trim()||y,className:`h-8 gap-1`,children:[y?(0,Z.jsx)(Xe,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(o,{className:`size-3.5`}),`Create`]})]})]})]})}):null}function yu({icon:e,label:t,count:n,inList:r,isPending:i,disabled:a,onAdd:s}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 hover:bg-secondary/40 transition-colors`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0 flex-1`,children:[e,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium truncate`,children:t}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,Z.jsx)(I,{className:`size-3 shrink-0`}),n,` `,n===1?`person`:`people`]})]})]}),(0,Z.jsx)(q,{size:`sm`,variant:r?`secondary`:`default`,className:`h-7 px-2.5 text-xs shrink-0 gap-1.5`,disabled:a||r,onClick:s,children:i?(0,Z.jsx)(Xe,{className:`size-3 animate-spin`}):r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{className:`size-3`}),` Added`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{className:`size-3`}),` Add`]})})]})}var bu={auto:N,light:vt,dark:v},xu={auto:`settings.appearance.system`,light:`settings.appearance.light`,dark:`settings.appearance.dark`};function Su({naddr:e,open:t,onOpenChange:n}){let{t:r}=Fn(),[i,a]=(0,Q.useState)(Pa),[o,s]=(0,Q.useState)(Ba),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),p=(0,Q.useRef)(null),[m,h]=(0,Q.useState)(null),g=window.location.origin,_=r(`embedCampaign.iframeTitle`),v=r(`embedCampaign.snippetLabel`),y=(0,Q.useMemo)(()=>Ha({naddr:e,variant:i,theme:o,origin:g}),[e,i,o,g]),b=(0,Q.useMemo)(()=>La({naddr:e,variant:i,theme:o,origin:g,title:_}),[e,i,o,g,_]),{width:x,height:S}=Ia[i],C=(0,Q.useRef)({variant:i,theme:o});C.current={variant:i,theme:o};let w=(0,Q.useCallback)(()=>{p.current?.contentWindow?.postMessage({type:Va,...C.current},g)},[g]);return(0,Q.useEffect)(()=>{h(t?Ha({naddr:e,...C.current,origin:g}):null)},[t,e,g]),(0,Q.useEffect)(()=>{t&&w()},[t,i,o,w]),(0,Q.useEffect)(()=>{l(null)},[i,o]),(0,Q.useEffect)(()=>{if(!t)return;let e=e=>{if(e.origin===g){if(za(e.data)){w();return}Fa(e.data)&&l(Math.min(Math.max(e.data.height,160),2400))}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t,g,w]),(0,Z.jsx)(ar,{open:t,onOpenChange:n,children:(0,Z.jsxs)(nr,{side:`bottom`,className:`flex h-[92dvh] flex-col gap-0 rounded-t-2xl p-0`,children:[(0,Z.jsxs)(tr,{className:`shrink-0 px-5 py-4 pr-14 text-left`,children:[(0,Z.jsx)(rr,{className:`text-base font-semibold`,children:r(`embedCampaign.dialogTitle`)}),(0,Z.jsx)(ir,{children:r(`embedCampaign.dialogDescription`)})]}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 space-y-5 px-5 pb-5 pt-5 lg:w-[340px] lg:border-r`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Ei,{children:r(`embedCampaign.variantLabel`)}),(0,Z.jsx)(_a,{type:`single`,value:i,onValueChange:e=>e&&a(e),className:`grid grid-cols-3 gap-2`,children:Ra.map(e=>(0,Z.jsx)(ba,{value:e,className:`rounded-lg border text-sm data-[state=on]:border-primary data-[state=on]:bg-primary/10`,children:r(`embedCampaign.variant.${e}`)},e))})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Ei,{children:r(`embedCampaign.themeLabel`)}),(0,Z.jsx)(_a,{type:`single`,value:o,onValueChange:e=>e&&s(e),className:`grid grid-cols-3 gap-2`,children:Na.map(e=>{let t=bu[e];return(0,Z.jsxs)(ba,{value:e,className:`gap-1.5 rounded-lg border data-[state=on]:border-primary data-[state=on]:bg-primary/10`,children:[(0,Z.jsx)(t,{className:`size-4 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate text-sm`,children:r(xu[e])})]},e)})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(Ei,{children:v}),(0,Z.jsxs)(`a`,{href:y,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-sm text-xs font-medium text-muted-foreground hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-safe:transition-colors`,children:[r(`embedCampaign.openStandalone`),(0,Z.jsx)(F,{className:`size-3.5`})]})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(b),d(!0),setTimeout(()=>d(!1),2e3),W({title:r(`noteMoreMenu.toast.embedCopied`)})}catch{W({title:r(`campaignsDetail.copyFailed`),description:r(`campaignsDetail.copyFailedBody`),variant:`destructive`})}},"aria-label":r(`campaignsDetail.copyLabelAction`,{label:v}),className:`flex w-full items-start gap-2 rounded-lg border bg-muted/40 p-3 text-left hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary motion-safe:transition-colors`,children:[(0,Z.jsx)(`code`,{className:`line-clamp-3 min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs leading-relaxed text-muted-foreground`,children:b}),u?(0,Z.jsx)(f,{className:`size-4 shrink-0 text-green-500`}):(0,Z.jsx)(Pe,{className:`size-4 shrink-0 text-muted-foreground`})]})]})]}),(0,Z.jsx)(`div`,{className:`flex justify-center lg:flex-1`,children:(0,Z.jsx)(`iframe`,{ref:p,src:m??void 0,title:_,allow:`clipboard-write`,className:`w-full self-start border-0 motion-safe:transition-[height] motion-safe:duration-200`,style:{maxWidth:x,height:c??S}})})]})]})})}function Cu(){let{nostr:e}=R(),{user:t}=U(),n=V(),{mutateAsync:r}=ln(),i=B({queryKey:[`bookmarks`,t?.pubkey],queryFn:async()=>t?(await e.query([{kinds:[10003],authors:[t.pubkey],limit:1}]))[0]??null:null,enabled:!!t}),a=(i.data?.tags??[]).filter(([e])=>e===`e`).map(([,e])=>e),o=B({queryKey:[`bookmarked-events`,a],queryFn:async()=>{if(a.length===0)return[];let t=await e.query([{ids:a,limit:a.length}]),n=[...a].reverse();return t.sort((e,t)=>n.indexOf(e.id)-n.indexOf(t.id))},enabled:a.length>0});function s(e){return a.includes(e)}let c=Lt({mutationFn:async n=>{if(!t)throw Error(`User is not logged in`);let i=await cn(e,{kinds:[10003],authors:[t.pubkey]}),a=i?.tags??[],o=a.some(([e,t])=>e===`e`&&t===n),s;s=o?a.filter(([e,t])=>e!==`e`||t!==n):[...a,[`e`,n]],await r({kind:10003,content:i?.content??``,tags:s,created_at:Math.floor(Date.now()/1e3),prev:i??void 0})},onSuccess:()=>{n.invalidateQueries({queryKey:[`bookmarks`,t?.pubkey]}),n.invalidateQueries({queryKey:[`bookmarked-events`]})}});return{bookmarkList:i.data,bookmarkedIds:a,events:o.data??[],isLoading:i.isLoading,isLoadingEvents:o.isLoading,isBookmarked:s,toggleBookmark:c}}function wu(e){let{nostr:t}=R(),{user:n}=U(),r=V(),{mutateAsync:i}=ln(),a=B({queryKey:[`pinned-notes`,e],queryFn:async({signal:n})=>e?(await t.query([{kinds:[10001],authors:[e],limit:1}],{signal:AbortSignal.any([n,AbortSignal.timeout(5e3)])}))[0]??null:null,enabled:!!e,staleTime:3e5}),o=(a.data?.tags??[]).filter(([e])=>e===`e`).map(([,e])=>e);function s(e){return o.includes(e)}let c=Lt({mutationFn:async e=>{if(!n)throw Error(`User is not logged in`);let r=await cn(t,{kinds:[10001],authors:[n.pubkey]}),a=r?.tags??[],o=a.some(([t,n])=>t===`e`&&n===e),s;s=o?a.filter(([t,n])=>t!==`e`||n!==e):[...a,[`e`,e]],await i({kind:10001,content:r?.content??``,tags:s,created_at:Math.floor(Date.now()/1e3),prev:r??void 0})},onSuccess:()=>{r.invalidateQueries({queryKey:[`pinned-notes`,n?.pubkey]}),r.invalidateQueries({queryKey:[`profile-pinned-events`]})}});return{pinnedList:a.data,pinnedIds:o,isLoading:a.isLoading,isPinned:s,togglePin:c}}function Tu(e){return e>=3e4&&e<4e4}var Eu=new Set(`feed.agora-feed.agora-feed-paginated.agora-feed-new-posts.mixed-feed.nostr-layer.profile-feed.profile-likes-infinite.profile-media.profile-pinned-events.replies.nostr.event-comments.wall-comments.pinned-event-comments.pinned-event-comments-list.notifications.notifications-unread.campaign.campaigns.campaigns-all.campaigns-all-scores.agora-action.agora-actions.community-actions.community-activity-feed.organization-activity.organization-home-activity-feed.trending.trending-posts.sorted-posts.infinite-sorted-posts.infinite-hot-feed.ditto-curated-feed.world-feed.following-feed.following-country-feed.following-hashtag-feed.my-feed.tab-feed.relay-feed.domain-feed.event.addr-event`.split(`.`));function Du(){let{user:e}=U(),t=V(),{mutateAsync:n}=ln();return Lt({mutationFn:async({eventId:t,eventKind:r,eventPubkey:i,eventDTag:a})=>{if(!e)throw Error(`User is not logged in`);let o=[[`e`,t],[`k`,String(r)]];return Tu(r)&&i&&a!==void 0&&o.push([`a`,`${r}:${i}:${a}`]),await n({kind:5,content:``,tags:o}),t},onSuccess:()=>{t.invalidateQueries({predicate:e=>{let t=e.queryKey[0];return typeof t==`string`&&Eu.has(t)}})}})}var Ou=`agora-pinned-`,ku=`pathos-pinned-`;function Au(e){return`${Ou}${e.toUpperCase()}`}function ju(e){return`${ku}${e.toUpperCase()}`}function Mu(e){return e.length===0?null:e.reduce((e,t)=>t.created_at>e.created_at?t:e)}function Nu(e){if(!e)return[];try{let t=JSON.parse(e.content);if(Array.isArray(t.pinnedEvents))return t.pinnedEvents.filter(e=>typeof e==`string`)}catch(e){console.warn(`Failed to parse pinned posts event:`,e)}return[]}function Pu(e){let{nostr:t}=R(),n=V(),{mutateAsync:r}=ln(),{getOrganizersByCountry:i,isLoading:a}=Ga(),o=e?i(e).map(e=>e.pubkey):[],s=[...Wa,...o],{data:c,isLoading:l}=B({queryKey:[`pinned-posts`,e,o.join(`,`)],queryFn:async n=>{if(!e||s.length===0)return{eventIds:[],sourceEvent:null};let r=AbortSignal.any([n.signal,AbortSignal.timeout(5e3)]),i=Mu(await t.query([{kinds:[30078],authors:s,"#d":[Au(e),ju(e)],limit:50}],{signal:r}));return{eventIds:Nu(i),sourceEvent:i}},enabled:!!e&&!a&&s.length>0,staleTime:3e4}),u=c?.eventIds??[],{data:d=[],isLoading:f}=B({queryKey:[`pinned-posts-events`,e,u],queryFn:async e=>{if(u.length===0)return[];let n=AbortSignal.any([e.signal,AbortSignal.timeout(5e3)]);return(await t.query([{ids:u,limit:u.length}],{signal:n})).sort((e,t)=>t.created_at-e.created_at)},enabled:u.length>0,staleTime:3e4});async function p(e,n){let i=e.toUpperCase(),a=Mu(await t.query([{kinds:[30078],authors:s,"#d":[Au(i),ju(i)],limit:50}],{signal:AbortSignal.timeout(1e4)})),o=n(Nu(a));return r({kind:30078,content:JSON.stringify({pinnedEvents:o}),tags:[[`d`,Au(i)],[`alt`,`Pinned posts for ${i} feed`]],prev:a??void 0})}let m=Lt({mutationFn:async({eventId:e,countryCode:t})=>{await p(t,t=>[...new Set([...t,e])])},onSuccess:(e,t)=>{n.invalidateQueries({queryKey:[`pinned-posts`,t.countryCode]})}}),h=Lt({mutationFn:async({eventId:e,countryCode:t})=>{await p(t,t=>t.filter(t=>t!==e))},onSuccess:(e,t)=>{n.invalidateQueries({queryKey:[`pinned-posts`,t.countryCode]})}});return{pinnedPosts:d,pinnedEventIds:u,isLoading:l||f||a,pinPost:m,unpinPost:h,isPinned:e=>u.includes(e)}}function Fu({icon:e,label:t,onClick:n,destructive:r}){return(0,Z.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:G(`flex items-center gap-4 w-full px-5 py-3 text-[15px] transition-colors hover:bg-secondary/60`,r?`text-destructive`:`text-muted-foreground`),children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:e}),(0,Z.jsx)(`span`,{children:t})]})}function Iu(e){if(e.kind>=3e4&&e.kind<4e4){let t=e.tags.find(([e])=>e===`d`)?.[1];if(t)return H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}return H.neventEncode({id:e.id,author:e.pubkey})}function Lu({text:e,label:t}){let{t:n}=Fn(),[r,i]=(0,Q.useState)(!1);return(0,Z.jsx)(q,{variant:`ghost`,size:`icon`,onClick:()=>{navigator.clipboard.writeText(e),i(!0),W({title:n(`noteMoreMenu.toast.copied`,{label:t})}),setTimeout(()=>i(!1),2e3)},className:`size-6 shrink-0 text-muted-foreground hover:text-foreground`,children:r?(0,Z.jsx)(f,{className:`size-3.5 text-green-500`}):(0,Z.jsx)(Pe,{className:`size-3.5`})})}function Ru({event:e,nip19Id:t,open:n,onOpenChange:r}){let{t:i}=Fn(),{nostr:a}=R(),[o,s]=(0,Q.useState)(!1),c=JSON.stringify(e,null,2);return(0,Z.jsx)(Gn,{open:n,onOpenChange:r,children:(0,Z.jsxs)(Vn,{className:`max-w-2xl max-h-[85dvh] flex flex-col gap-0 p-0 rounded-2xl overflow-hidden`,children:[(0,Z.jsx)(Rn,{className:`px-5 pt-5 pb-3 shrink-0`,children:(0,Z.jsx)(zn,{className:`text-base font-semibold`,children:i(`noteMoreMenu.jsonDialog.title`)})}),(0,Z.jsxs)(`div`,{className:`px-5 pb-3 shrink-0`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:i(`noteMoreMenu.jsonDialog.eventId`)}),(0,Z.jsxs)(`div`,{className:`relative flex items-center bg-muted rounded-lg px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`font-mono text-xs break-all text-foreground/80 flex-1 pr-2 select-all`,children:t}),(0,Z.jsx)(Lu,{text:t,label:i(`noteMoreMenu.jsonDialog.eventIdLabel`)})]})]}),(0,Z.jsxs)(`div`,{className:`px-5 pb-5 flex flex-col flex-1 min-h-0`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:i(`noteMoreMenu.jsonDialog.rawJson`)}),(0,Z.jsxs)(`div`,{className:`relative flex-1 min-h-0 overflow-auto rounded-lg bg-muted border border-border`,children:[(0,Z.jsx)(`div`,{className:`sticky top-2 right-2 float-right mr-2`,children:(0,Z.jsx)(Lu,{text:c,label:i(`noteMoreMenu.jsonDialog.eventJsonLabel`)})}),(0,Z.jsx)(`pre`,{className:`p-4 text-xs font-mono text-foreground/80 whitespace-pre leading-relaxed`,children:c})]})]}),(0,Z.jsx)(`div`,{className:`px-5 pb-5 shrink-0`,children:(0,Z.jsxs)(q,{variant:`outline`,className:`w-full gap-2`,onClick:async()=>{s(!0);try{await a.event(e,{signal:AbortSignal.timeout(5e3)}),W({title:i(`noteMoreMenu.toast.eventBroadcast`)})}catch{W({title:i(`noteMoreMenu.toast.broadcastFailed`),variant:`destructive`})}finally{s(!1)}},disabled:o,children:[(0,Z.jsx)(_t,{className:`size-4`}),i(o?`noteMoreMenu.jsonDialog.broadcasting`:`noteMoreMenu.jsonDialog.broadcast`)]})})]})})}function zu({event:e,open:t,onOpenChange:n}){let{t:r}=Fn(),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),{user:b}=U(),x=Nc(),S=(0,Q.useMemo)(()=>{if(!x||!b)return;let t=yi(b.pubkey,x.rankMap,x.moderation);if(t)return{communityATag:x.communityATag,canBan:xi(t,x.rankMap.get(e.pubkey))}},[x,b,e.pubkey]),{mutate:C,isPending:w}=Du(),T=Iu(e),E=e.kind===Xi,D=e.tags.find(([e])=>e===`d`)?.[1]??``,O=E?`${Xi}:${e.pubkey}:${D}`:``,k=e.tags.find(([e])=>e===`title`)?.[1]??``,{verify:A}=Zi(),ee=async()=>{try{await A.mutateAsync({coord:O}),W({title:r(`campaignVerification.verified`),description:k}),p(!1)}catch(e){W({title:r(`campaignVerification.actionFailed`),description:e instanceof Error?e.message:void 0,variant:`destructive`})}},te=()=>{let t=e.tags.find(([e])=>e===`d`)?.[1];C({eventId:e.id,eventKind:e.kind,eventPubkey:e.pubkey,eventDTag:t},{onSuccess:()=>{y(!1),W({title:r(`noteMoreMenu.toast.postDeleted`)})},onError:()=>{W({title:r(`noteMoreMenu.toast.deleteFailed`),variant:`destructive`})}})};return(0,Z.jsxs)(Z.Fragment,{children:[t&&(0,Z.jsx)(Bu,{event:e,open:t,onOpenChange:n,communityContext:S,onReport:()=>{n(!1),setTimeout(()=>a(!0),150)},onBanContent:()=>{n(!1),setTimeout(()=>s(!0),150)},onAddToList:()=>{n(!1),setTimeout(()=>l(!0),150)},onAddToCampaignList:()=>{n(!1),setTimeout(()=>d(!0),150)},onRequestVerify:()=>{n(!1),setTimeout(()=>p(!0),150)},onViewEventJson:()=>{n(!1),setTimeout(()=>h(!0),150)},onEmbedWidget:()=>{n(!1),setTimeout(()=>_(!0),150)},onDelete:()=>{n(!1),setTimeout(()=>y(!0),150)}}),S?(0,Z.jsx)(su,{event:e,communityATag:S.communityATag,open:i,onOpenChange:a}):(0,Z.jsx)(ou,{event:e,open:i,onOpenChange:a}),S?.canBan&&(0,Z.jsx)(iu,{eventId:e.id,targetPubkey:e.pubkey,communityATag:S.communityATag,open:o,onOpenChange:s}),(0,Z.jsx)(vu,{pubkey:e.pubkey,open:c,onOpenChange:l}),E&&(0,Z.jsx)(ia,{open:u,onOpenChange:d,campaignCoord:O,campaignTitle:k}),E&&(0,Z.jsx)(na,{open:f,onOpenChange:p,campaignTitle:k,isPending:A.isPending,onConfirm:ee}),(0,Z.jsx)(Ru,{event:e,nip19Id:T,open:m,onOpenChange:h}),E&&(0,Z.jsx)(Su,{naddr:T,open:g,onOpenChange:_}),(0,Z.jsx)(Aa,{open:v,onOpenChange:y,children:(0,Z.jsxs)(Ta,{onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(ka,{children:[(0,Z.jsx)(wa,{children:r(`noteMoreMenu.deleteDialog.title`)}),(0,Z.jsx)(Ca,{children:r(`noteMoreMenu.deleteDialog.description`)})]}),(0,Z.jsxs)(Da,{children:[(0,Z.jsx)(Oa,{disabled:w,children:r(`noteMoreMenu.deleteDialog.cancel`)}),(0,Z.jsx)(Ea,{onClick:e=>{e.preventDefault(),te()},disabled:w,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:r(w?`noteMoreMenu.deleteDialog.deleting`:`noteMoreMenu.deleteDialog.delete`)})]})]})})]})}function Bu({event:e,open:t,onOpenChange:n,communityContext:r,onReport:i,onBanContent:a,onAddToList:o,onAddToCampaignList:s,onRequestVerify:c,onViewEventJson:l,onEmbedWidget:u,onDelete:f}){let{t:p}=Fn(),m=Pn(),{user:h}=U(),{isBookmarked:_,toggleBookmark:v}=Cu(),y=_(e.id),{isPinned:b,togglePin:x}=wu(h?.pubkey),S=b(e.id),C=h?.pubkey===e.pubkey,w=e.kind===Xi,T=ea(),E=w&&T.isMod,D=tc()?.countryCode,O=!!h&&Ua(h.pubkey),{isOrganizer:k}=Ga(),ee=!!h&&!!D&&k(h.pubkey,D),te=O||ee,{isPinned:ne,pinPost:re,unpinPost:ie}=Pu(te?D:void 0),oe=!!D&&ne(e.id),se=z(e.pubkey).data?.metadata?.name||er(e.pubkey),{addMute:ce,removeMute:le,isMuted:ue}=dn(),j=ue(`pubkey`,e.pubkey),{addToSidebar:M,removeFromSidebar:N,orderedItems:fe}=$n(),pe=Iu(e),me=`nostr:${pe}`,he=fe.includes(me),P=()=>n(!1);return(0,Z.jsx)(Gn,{open:t,onOpenChange:n,children:(0,Z.jsxs)(Vn,{className:`max-w-md max-h-[85dvh] p-0 gap-0 rounded-2xl overflow-y-auto [&>button]:hidden`,children:[(0,Z.jsx)(zn,{className:`sr-only`,children:p(`noteMoreMenu.title`)}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(de,{className:`size-5`}),label:p(`noteMoreMenu.viewPost`),onClick:()=>{m(`/${pe}`),P()}}),w&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(ft,{className:`size-5`}),label:p(`noteMoreMenu.embedWidget`),onClick:u}),(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(qe,{className:`size-5`}),label:p(`noteMoreMenu.viewEventJson`),onClick:l}),!w&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(g,{className:G(`size-5`,y&&`fill-current`)}),label:p(y?`noteMoreMenu.removeBookmark`:`noteMoreMenu.bookmark`),onClick:()=>{Ri(),v.mutate(e.id),P()}}),h&&!w&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(Ee,{className:`size-5`}),label:p(`noteMoreMenu.addToList`),onClick:()=>{o()}}),!w&&(0,Z.jsx)(Fu,{icon:he?(0,Z.jsx)(A,{className:`size-5`}):(0,Z.jsx)(ae,{className:`size-5`}),label:p(he?`noteMoreMenu.removeFromSidebar`:`noteMoreMenu.addToSidebar`),onClick:()=>{he?(N(me),W({title:p(`noteMoreMenu.toast.removedFromSidebar`)})):(M(me),W({title:p(`noteMoreMenu.toast.addedToSidebar`)})),P()}}),C&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(d,{className:G(`size-5`,S&&`fill-current`)}),label:p(S?`noteMoreMenu.unpinProfile`:`noteMoreMenu.pinProfile`),onClick:()=>{Ri(),x.mutate(e.id,{onSuccess:()=>{W({title:p(S?`noteMoreMenu.toast.unpinned`:`noteMoreMenu.toast.pinned`)})},onError:()=>{W({title:p(`noteMoreMenu.toast.pinFailed`),variant:`destructive`})}}),P()}}),te&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(d,{className:G(`size-5`,oe&&`fill-current`)}),label:p(oe?`noteMoreMenu.unpinCountry`:`noteMoreMenu.pinCountry`),onClick:()=>{D&&(Ri(),(oe?ie:re).mutate({eventId:e.id,countryCode:D},{onSuccess:()=>{W({title:p(oe?`noteMoreMenu.toast.countryUnpinned`:`noteMoreMenu.toast.countryPinned`)})},onError:()=>{W({title:p(oe?`noteMoreMenu.toast.countryUnpinFailed`:`noteMoreMenu.toast.countryPinFailed`),variant:`destructive`})}}),P())}}),!C&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(Ne,{className:`size-5`}),label:p(j?`noteMoreMenu.unmute`:`noteMoreMenu.mute`,{name:se}),onClick:()=>{let t={type:`pubkey`,value:e.pubkey};(j?le:ce).mutate(t,{onSuccess:()=>{W({title:p(j?`noteMoreMenu.toast.unmuted`:`noteMoreMenu.toast.muted`,{name:se})})},onError:()=>{W({title:p(j?`noteMoreMenu.toast.unmuteFailed`:`noteMoreMenu.toast.muteFailed`),variant:`destructive`})}}),P()}}),!C&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(ve,{className:`size-5`}),label:r?p(`noteMoreMenu.reportToGroup`):p(`noteMoreMenu.report`,{name:se}),onClick:i,destructive:!0}),!C&&r?.canBan&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(we,{className:`size-5`}),label:p(`noteMoreMenu.removeFromGroup`),onClick:a,destructive:!0}),C&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(A,{className:`size-5`}),label:p(`noteMoreMenu.delete`),onClick:f,destructive:!0})]}),w&&h&&(0,Z.jsx)(Vu,{coord:`33863:${e.pubkey}:${e.tags.find(([e])=>e===`d`)?.[1]??``}`,entityTitle:e.tags.find(([e])=>e===`title`)?.[1]??``,canManageCampaignLists:E,onAddToCampaignList:s,onRequestVerify:c,onClose:P}),(0,Z.jsx)(ji,{}),(0,Z.jsx)(`div`,{className:`py-1`,children:(0,Z.jsx)(q,{variant:`ghost`,className:`w-full h-auto py-3 text-[15px] font-medium text-muted-foreground hover:bg-secondary/60 rounded-none`,onClick:P,children:p(`noteMoreMenu.close`)})})]})})}function Vu({coord:e,entityTitle:t,canManageCampaignLists:n,onAddToCampaignList:r,onRequestVerify:i,onClose:a}){let{t:o}=Fn(),{user:s}=U(),{data:c,canVerify:l,unverify:u}=Zi(),{data:d,moderate:f}=$i(),p=n,m=!!s&&Qi(s.pubkey,e),h=l&&!m;if(!h&&!p)return null;let g=s?(c.byCoord.get(e)??[]).find(e=>e.pubkey===s.pubkey):void 0,_=d.hiddenCoords.has(e),v=async()=>{if(g){try{await u.mutateAsync({verification:g}),W({title:o(`campaignVerification.unverified`),description:t})}catch(e){W({title:o(`campaignVerification.actionFailed`),description:e instanceof Error?e.message:void 0,variant:`destructive`})}a()}},y=async()=>{try{await f.mutateAsync({coord:e,action:_?`unhidden`:`hidden`}),W({title:o(_?`moderation.menu.toastUnhidden`:`moderation.menu.toastHidden`),description:t})}catch(e){W({title:o(`moderation.menu.failedAction`,{action:_?`unhidden`:`hidden`}),description:e instanceof Error?e.message:void 0,variant:`destructive`})}a()};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ji,{}),(0,Z.jsxs)(`div`,{className:`py-1`,children:[(0,Z.jsx)(`p`,{className:`px-5 pt-2 pb-1 text-xs font-medium text-muted-foreground`,children:o(`moderation.menu.label`)}),h&&(g?(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(Ae,{className:`size-5`}),label:o(`campaignVerification.removeVerification`),onClick:v}):(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(Ae,{className:`size-5`}),label:o(`campaignVerification.verifyCampaign`),onClick:i})),p&&(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(Ee,{className:`size-5`}),label:o(`campaigns.lists.membershipTitle`),onClick:r}),p&&(_?(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(nt,{className:`size-5`}),label:o(`moderation.menu.unhide`),onClick:y}):(0,Z.jsx)(Fu,{icon:(0,Z.jsx)(Re,{className:`size-5`}),label:o(`moderation.menu.hide`),onClick:y,destructive:!0}))]})]})}function Hu(e){let t=e.split(` `),n=``,r=``,i=``,a=t[0]?.trim()??``;n=a.startsWith(`Subject:`)?a.replace(/^Subject:\s*(\[PATCH[^\]]*\])?\s*/,``):a;let o=-1;for(let e=0;e0){let e=[];for(let n=1;ne===`t`&&t===`root`),o=e.tags.some(([e,t])=>e===`t`&&t===`root-revision`),s=e.tags.some(([e,t])=>e===`t`&&t===`shakespeare`),c=(e.tags.find(([e])=>e===`a`)?.[1])?.split(`:`)[2]??``,l=e.tags.find(([e])=>e===`commit`)?.[1],u=e.tags.find(([e])=>e===`parent-commit`)?.[1],d=e.tags.find(([e])=>e===`committer`),f=e.tags.filter(([e])=>e===`t`).map(([,e])=>e).filter(e=>e!==`root`&&e!==`root-revision`&&e!==`shakespeare`);return(0,Z.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:(0,Z.jsxs)(`div`,{className:`px-3.5 py-3 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,Z.jsx)(je,{className:`size-4 text-orange-500 dark:text-orange-400 shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-sm leading-snug line-clamp-2`,children:n||`Patch`}),a&&(0,Z.jsx)(X,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-medium border-orange-500/30 text-orange-600 dark:text-orange-400`,children:`root`}),o&&(0,Z.jsx)(X,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-medium border-orange-500/30 text-orange-600 dark:text-orange-400`,children:`revision`})]}),c&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 font-mono`,children:c})]})]}),f.length>0&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[f.slice(0,t?6:f.length).map(e=>(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`#`,e]},e)),t&&f.length>6&&(0,Z.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/50`,children:[`+`,f.length-6,` more`]})]}),s&&(0,Z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-full bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90`,onClick:e=>{e.stopPropagation(),Pi(`https://shakespeare.diy`)},children:[(0,Z.jsx)(Me,{className:`size-3`}),`Edit with Shakespeare`]})]})}),!t&&(l||u||d)&&(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden divide-y divide-border`,children:[l&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2 text-sm`,children:[(0,Z.jsx)(h,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Commit`}),(0,Z.jsx)(`code`,{className:`ml-auto text-xs font-mono text-muted-foreground`,children:l.slice(0,12)})]}),u&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2 text-sm`,children:[(0,Z.jsx)(h,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Parent`}),(0,Z.jsx)(`code`,{className:`ml-auto text-xs font-mono text-muted-foreground`,children:u.slice(0,12)})]}),d&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2 text-sm`,children:[(0,Z.jsx)(mt,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Committer`}),(0,Z.jsx)(`span`,{className:`ml-auto text-xs`,children:d[1]}),d[2]&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`<`,d[2],`>`]})]})]}),!t&&r&&(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden px-3.5 py-3`,children:(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed whitespace-pre-wrap break-words text-muted-foreground`,children:r})}),!t&&i&&(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsx)(`pre`,{className:`px-3.5 py-3 text-xs font-mono leading-relaxed`,children:i.split(` `).map((e,t)=>{let n=`text-muted-foreground`;return e.startsWith(`+`)&&!e.startsWith(`+++`)?n=`text-green-700 dark:text-green-400 bg-green-500/5`:e.startsWith(`-`)&&!e.startsWith(`---`)?n=`text-red-700 dark:text-red-400 bg-red-500/5`:e.startsWith(`@@`)?n=`text-blue-700 dark:text-blue-400 bg-blue-500/5`:e.startsWith(`diff --git`)&&(n=`text-foreground font-semibold mt-2 first:mt-0`),(0,Z.jsx)(`div`,{className:n,children:e},t)})})})})]})}function Wu({nip05:e,pubkey:t,className:n}){let{data:r,isPending:i}=At(e,t);return i?(0,Z.jsx)(J,{className:G(`h-3 w-24 inline-block`,n)}):r?(0,Z.jsxs)(`span`,{className:n,children:[`@`,Rr(e)]}):null}function Gu({nip05:e,pubkey:t,className:n,iconSize:r=16,showCheck:i=!1}){let{data:a,isPending:o}=At(e,t);if(o)return(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center gap-1`,n),children:[(0,Z.jsx)(J,{className:`h-3 w-24`}),(0,Z.jsx)(J,{className:`rounded-full`,style:{width:r,height:r}})]});if(!a)return null;let s=ni(e),c=Yr(e),l=c===`_`;return(0,Z.jsxs)(`span`,{className:G(`inline-flex items-center min-w-0`,n),children:[i&&(0,Z.jsx)(re,{className:`size-3.5 text-primary shrink-0 mr-1 mt-[0.2rem]`}),l?(0,Z.jsxs)(K,{to:`/feed/${s}`,className:`truncate min-w-0 hover:underline`,onClick:e=>e.stopPropagation(),title:`View ${s} feed`,children:[`@`,s]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`truncate min-w-0`,children:[`@`,c,`@`]}),s&&(0,Z.jsx)(K,{to:`/feed/${s}`,className:`shrink-0 hover:underline`,onClick:e=>e.stopPropagation(),title:`View ${s} feed`,children:s})]}),s&&(0,Z.jsx)(K,{to:`/feed/${s}`,className:`inline-flex items-center shrink-0 ml-1 hover:opacity-80 transition-opacity`,onClick:e=>e.stopPropagation(),title:`View ${s} feed`,children:(0,Z.jsx)(cr,{url:`https://${s}`,size:r,className:`shrink-0`})})]})}function Ku(e,t){return e.find(([e])=>e===t)?.[1]}function qu(e){return e.filter(([e])=>e===`option`).map(([,e,t])=>({id:e,label:t}))}function Ju(e){let t=new Map;for(let n of e){let e=t.get(n.pubkey);(!e||n.created_at>e.created_at)&&t.set(n.pubkey,n)}return Array.from(t.values())}function Yu(e,t){let n=new Map;for(let r of e){let e=r.tags.filter(([e])=>e===`response`);if(t===`singlechoice`){let t=e[0]?.[1];t&&n.set(t,(n.get(t)??0)+1)}else{let t=new Set;for(let[,r]of e)r&&!t.has(r)&&(t.add(r),n.set(r,(n.get(r)??0)+1))}}return n}function Xu(e,t,n){return e.filter(e=>{let r=e.tags.filter(([e])=>e===`response`);return n===`singlechoice`?r[0]?.[1]===t:r.some(([,e])=>e===t)})}function Zu({votes:e,totalVotes:t,authorsMap:n,onClick:r,className:i}){return(0,Z.jsxs)(`button`,{onClick:r,className:G(`flex items-center gap-1.5 group`,i),children:[(0,Z.jsx)(`div`,{className:`flex -space-x-1.5`,children:e.slice(0,6).map(e=>{let t=n?.get(e.pubkey)?.metadata,r=t?.name||er(e.pubkey);return(0,Z.jsxs)(Qn,{className:`size-5 ring-1 ring-background`,children:[(0,Z.jsx)(Zn,{src:t?.picture,alt:r}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary text-[8px]`,children:r[0]?.toUpperCase()})]},e.pubkey)})}),(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground group-hover:text-foreground transition-colors`,children:[t,` `,t===1?`vote`:`votes`]})]})}function Qu({event:e}){let{nostr:t}=R(),{user:n}=U(),r=V(),{mutate:i}=ln(),a=(0,Q.useMemo)(()=>qu(e.tags),[e.tags]),o=Ku(e.tags,`polltype`)??`singlechoice`,s=Ku(e.tags,`endsAt`),c=s?Number(s){let r={kinds:[1018],"#e":[e.id],limit:200};return s&&(r.until=Number(s)),Ju(await t.query([r],{signal:AbortSignal.any([n,AbortSignal.timeout(5e3)])}))},staleTime:3e4}),m=(0,Q.useMemo)(()=>Yu(p??[],o),[p,o]),h=(0,Q.useMemo)(()=>{let e=0;for(let t of m.values())e+=t;return e},[m]),g=(0,Q.useMemo)(()=>{if(!(!n||!p))return p.find(e=>e.pubkey===n.pubkey)},[n,p]),_=!!g,v=_||c,[y,b]=(0,Q.useState)(null),S=t=>{t.stopPropagation(),!(!y||!n||_||c)&&i({kind:1018,content:``,tags:[[`e`,e.id],[`response`,y]]},{onSuccess:()=>{r.invalidateQueries({queryKey:[`poll-votes`,e.id]})}})},{data:C}=Kc((0,Q.useMemo)(()=>p?p.map(e=>e.pubkey):[],[p])),w=e=>{f(e),u(!0)};return(0,Z.jsxs)(`div`,{className:`mt-2`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`div`,{className:`text-[15px] leading-relaxed font-medium break-words`,children:(0,Z.jsx)(Jr,{event:e})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground bg-secondary/60 px-2 py-0.5 rounded-full`,children:[(0,Z.jsx)(x,{className:`size-3`}),o===`multiplechoice`?`Multiple choice`:`Single choice`]}),c&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground bg-secondary/60 px-2 py-0.5 rounded-full`,children:[(0,Z.jsx)(ht,{className:`size-3`}),`Ended`]}),v&&h>0&&(0,Z.jsx)(Zu,{votes:p??[],totalVotes:h,authorsMap:C,onClick:()=>w(null),className:`ml-auto`})]}),(0,Z.jsx)(`div`,{className:`mt-3 space-y-2`,children:a.map(e=>{let t=m.get(e.id)??0,n=h>0?Math.round(t/h*100):0,r=g?.tags.some(([t,n])=>t===`response`&&n===e.id),i=y===e.id;return v?(0,Z.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border`,children:[(0,Z.jsx)(`div`,{className:G(`absolute inset-0 transition-all duration-500`,r?`bg-primary/15`:`bg-secondary/40`),style:{width:`${n}%`}}),(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-between px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[r&&(0,Z.jsx)(re,{className:`size-4 text-primary shrink-0`}),(0,Z.jsx)(`span`,{className:G(`text-sm break-words`,r&&`font-semibold`),children:e.label})]}),(0,Z.jsxs)(`span`,{className:`text-sm font-medium tabular-nums text-muted-foreground shrink-0 ml-3`,children:[n,`%`]})]})]},e.id):(0,Z.jsx)(`button`,{onClick:()=>b(e.id),className:G(`w-full text-left rounded-lg border px-3 py-2.5 text-sm transition-colors`,i?`border-primary bg-primary/10 font-semibold`:`border-border hover:bg-secondary/40`),children:e.label},e.id)})}),!v&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[h>0?(0,Z.jsx)(Zu,{votes:p??[],totalVotes:h,authorsMap:C,onClick:()=>w(null)}):(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`0 votes`}),n&&(0,Z.jsx)(`button`,{onClick:S,disabled:!y,className:G(`text-sm font-semibold px-4 py-1.5 rounded-full transition-colors`,y?`bg-primary text-primary-foreground hover:bg-primary/90`:`bg-secondary text-muted-foreground cursor-not-allowed`),children:`Vote`})]}),(0,Z.jsx)($u,{open:l,onOpenChange:u,allVotes:p??[],options:a,pollType:o,initialOptionId:d,authorsMap:C})]})}function $u({open:e,onOpenChange:t,allVotes:n,options:r,pollType:i,initialOptionId:a,authorsMap:o}){let[s,c]=(0,Q.useState)(a??null);(0,Q.useMemo)(()=>{e&&c(a??null)},[e,a]);let l=(0,Q.useMemo)(()=>{let e=new Map;for(let t of r)e.set(t.id,t.label);return e},[r]),u=(0,Q.useMemo)(()=>s===null?n:Xu(n,s,i),[n,s,i]),d=(0,Q.useMemo)(()=>Yu(n,i),[n,i]);return(0,Z.jsx)(Gn,{open:e,onOpenChange:t,children:(0,Z.jsxs)(Vn,{className:`max-w-[460px] rounded-2xl p-0 gap-0 border-border overflow-hidden [&>button]:hidden`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12`,children:[(0,Z.jsx)(zn,{className:`text-base font-semibold`,children:`Voters`}),(0,Z.jsx)(`button`,{onClick:()=>t(!1),className:`p-1.5 -mr-1.5 rounded-full text-muted-foreground hover:text-foreground hover:bg-secondary/60 transition-colors`,children:(0,Z.jsx)(Ye,{className:`size-5`})})]}),(0,Z.jsx)(Fi,{className:G(`px-4`,r.length>2&&`max-h-[120px]`),children:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`button`,{onClick:()=>c(null),className:G(`relative w-full overflow-hidden rounded-lg border transition-colors text-left`,s===null?`border-primary`:`border-border hover:border-muted-foreground/40`),children:[(0,Z.jsx)(`div`,{className:G(`absolute inset-0 transition-all duration-500`,s===null?`bg-primary/15`:`bg-secondary/40`),style:{width:`100%`}}),(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-between px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:G(`text-sm`,s===null&&`font-semibold`),children:`All`}),(0,Z.jsx)(`span`,{className:`text-sm font-medium tabular-nums text-muted-foreground shrink-0 ml-3`,children:n.length})]})]}),r.map(e=>{let t=d.get(e.id)??0,r=n.length>0?Math.round(t/n.length*100):0,i=s===e.id;return(0,Z.jsxs)(`button`,{onClick:()=>c(e.id),className:G(`relative w-full overflow-hidden rounded-lg border transition-colors text-left`,i?`border-primary`:`border-border hover:border-muted-foreground/40`),children:[(0,Z.jsx)(`div`,{className:G(`absolute inset-0 transition-all duration-500`,i?`bg-primary/15`:`bg-secondary/40`),style:{width:`${r}%`}}),(0,Z.jsxs)(`div`,{className:`relative flex items-center justify-between px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:G(`text-sm break-words min-w-0`,i&&`font-semibold`),children:e.label}),(0,Z.jsx)(`span`,{className:`text-sm font-medium tabular-nums text-muted-foreground shrink-0 ml-3`,children:t})]})]},e.id)})]})}),r.length>2&&(0,Z.jsx)(`div`,{className:`mx-4 h-1 bg-primary rounded-full`}),(0,Z.jsx)(Fi,{className:`max-h-[60vh]`,children:u.length===0?(0,Z.jsx)(`div`,{className:`py-12 text-center text-muted-foreground text-sm`,children:`No votes yet`}):(0,Z.jsx)(`div`,{className:`divide-y divide-border`,children:u.map(e=>(0,Z.jsx)(ed,{vote:e,optionLabelMap:l,pollType:i,authorsMap:o},e.id))})})]})})}function ed({vote:e,optionLabelMap:t,pollType:n,authorsMap:r}){let i=z(r?.has(e.pubkey)?void 0:e.pubkey),a=r?.get(e.pubkey)??i.data,o=a?.metadata,s=o?.name||er(e.pubkey),c=(0,Q.useMemo)(()=>H.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),l=(0,Q.useMemo)(()=>{let r=e.tags.filter(([e])=>e===`response`);if(n===`singlechoice`){let e=r[0]?.[1],n=e?t.get(e):void 0;return n?[n]:[]}let i=[],a=new Set;for(let[,e]of r)if(e&&!a.has(e)){a.add(e);let n=t.get(e);n&&i.push(n)}return i},[e.tags,n,t]);return(0,Z.jsxs)(K,{to:`/${c}`,onClick:()=>{document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`}))},className:`flex items-center gap-3 px-4 py-3 hover:bg-secondary/30 transition-colors`,children:[(0,Z.jsxs)(Qn,{className:`size-10 shrink-0`,children:[(0,Z.jsx)(Zn,{src:o?.picture,alt:s}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary text-sm`,children:s[0].toUpperCase()})]}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`font-bold text-sm truncate`,children:a?.event?(0,Z.jsx)(li,{tags:a.event.tags,children:s}):s}),o?.nip05&&(0,Z.jsx)(Wu,{nip05:o.nip05,pubkey:e.pubkey,className:`text-xs text-muted-foreground truncate`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l.length>0&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l.join(`, `)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:zi(e.created_at)})]})]}),(0,Z.jsx)(O,{className:`size-4 text-muted-foreground shrink-0`})]})}var td=12;function nd({event:e}){let{nostr:t}=R(),n=(0,Q.useMemo)(()=>mr(e),[e]),r=B({queryKey:[`badge-definitions`,n.map(e=>e.aTag).join(`,`)],queryFn:async()=>{if(n.length===0)return[];let e=n.map(e=>({kinds:[30009],authors:[e.pubkey],"#d":[e.identifier],limit:1}));return await t.query(e)},enabled:n.length>0,staleTime:3e5}),i=(0,Q.useMemo)(()=>{let e=new Map;if(!r.data)return e;for(let t of r.data){let n=Dr(t);if(!n)continue;let r=`30009:${t.pubkey}:${n.identifier}`;e.set(r,n)}return e},[r.data]),[a,o]=(0,Q.useState)(!1);if(n.length===0)return null;let s=n.length>td,c=s?11:td,l=Math.max(0,n.length-c),u=a?n:n.slice(0,c);return(0,Z.jsx)(`div`,{className:`mt-3 space-y-3`,children:r.isLoading?(0,Z.jsxs)(`div`,{className:`grid grid-cols-4 sm:grid-cols-6 gap-3`,children:[n.slice(0,c).map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,Z.jsx)(J,{className:`size-12 rounded-lg`}),(0,Z.jsx)(J,{className:`h-2.5 w-12`})]},`${e.aTag}-${t}`)),s&&(0,Z.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-1.5`,children:(0,Z.jsx)(J,{className:`size-12 rounded-lg`})})]}):u.length>0?(0,Z.jsxs)(`div`,{className:`grid grid-cols-4 sm:grid-cols-6 gap-3`,children:[u.map((e,t)=>{let n=i.get(e.aTag),r=`/${H.naddrEncode({kind:30009,pubkey:e.pubkey,identifier:e.identifier})}`;return(0,Z.jsxs)(K,{to:r,className:`flex flex-col items-center gap-1.5 group`,title:n?.description||n?.name||e.identifier,onClick:e=>e.stopPropagation(),children:[n?(0,Z.jsx)(ur,{badge:n,size:48}):(0,Z.jsx)(`div`,{className:`size-12 rounded-lg border border-border bg-background flex items-center justify-center`,children:(0,Z.jsx)(L,{className:`size-6 text-muted-foreground`})}),(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground text-center leading-tight line-clamp-2 max-w-[4.5rem] group-hover:text-foreground transition-colors`,children:n?.name||e.identifier})]},`${e.aTag}-${t}`)}),l>0&&!a&&(0,Z.jsx)(`button`,{className:`flex flex-col items-center justify-center gap-1.5`,onClick:e=>{e.stopPropagation(),o(!0)},children:(0,Z.jsxs)(`div`,{className:`size-12 rounded-lg bg-muted hover:bg-muted/80 flex items-center justify-center text-muted-foreground text-xs font-medium transition-colors`,children:[`+`,l]})})]}):n.length>0?(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border bg-secondary/30 p-4 text-center text-sm text-muted-foreground`,children:[n.length,` badge`,n.length===1?``:`s`,` referenced but definitions could not be loaded.`]}):null})}var rd=[`❤️`,`👍`,`👎`,`😂`,`😮`,`😢`];function id(){let{user:e}=U(),[t,n]=Gt(e?`emoji-usage-${e.pubkey}`:`emoji-usage`,{});return{trackEmojiUsage:(0,Q.useCallback)(e=>{n(t=>({...t,[e]:(t[e]||0)+1}))},[n]),getTopEmojis:(0,Q.useCallback)((e=6)=>{let n=Object.entries(t).sort(([,e],[,t])=>t-e).map(([e])=>e).slice(0,e),r=e-n.length;if(r>0){let e=new Set(n),t=rd.filter(t=>!e.has(t)).slice(0,r);return[...n,...t]}return n},[t])}}function ad({eventId:e,eventPubkey:t,eventKind:n,onClose:r,onExpandChange:i,onReact:a,className:o}){let{user:s}=U(),{mutate:c}=ln(),l=V(),{config:u}=Kt(),d=u.nip85StatsPubkey,f=(0,Q.useMemo)(()=>[`nip85-event-stats`,e,d],[e,d]),{trackEmojiUsage:p,getTopEmojis:m}=id(),{feedSettings:h}=$n(),{emojis:g}=si(),_=h.showCustomEmojis!==!1,v=(0,Q.useMemo)(()=>_?g:[],[_,g]),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),C=(0,Q.useMemo)(()=>{let e=new Map;for(let t of v)e.set(t.shortcode,t.url);return e},[v]),w=(0,Q.useMemo)(()=>m(8).filter(e=>{if(!sr(e))return!0;let t=e.slice(1,-1);return C.has(t)}).slice(0,6),[m,C]),T=(0,Q.useCallback)((i,o)=>{if(!s)return;if(Ri(),r?.(),S(i),p(i),a){a(i,o);return}let u=i===`+`||i===``?`👍`:i,m=o?{content:u,url:o[2],name:o[1]}:{content:u},h=l.getQueryData(f);h&&l.setQueryData(f,{...h,reactionCount:h.reactionCount+1}),l.setQueryData([`user-reaction`,e],m);let g=[[`e`,e],[`p`,t],[`k`,String(n)]];o&&g.push(o),c({kind:7,content:i,created_at:Math.floor(Date.now()/1e3),tags:g},{onSuccess:()=>{setTimeout(()=>{Oo(l,e,d),l.invalidateQueries({queryKey:[`event-interactions`,e]})},3e3)},onError:()=>{S(null),h&&l.setQueryData(f,h),l.removeQueries({queryKey:[`user-reaction`,e]})}})},[s,e,t,n,a,c,l,p,r,d,f]),E=(0,Q.useCallback)(e=>{if(sr(e)){let t=e.slice(1,-1),n=C.get(t);if(n){T(e,[`emoji`,t,n]);return}}T(e)},[T,C]),D=(0,Q.useCallback)(e=>{e.type===`native`?T(e.emoji):T(`:${e.shortcode}:`,[`emoji`,e.shortcode,e.url])},[T]);return s?y?(0,Z.jsx)(`div`,{className:G(`rounded-xl shadow-xl overflow-hidden bg-popover border border-border`,o),onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(fa,{customEmojis:v,onSelect:D})}):(0,Z.jsxs)(`div`,{className:G(`inline-flex items-center gap-1 p-1.5 rounded-full bg-popover border border-border shadow-lg`,o),onClick:e=>e.stopPropagation(),children:[w.map(e=>{let t=sr(e),n=t?e.slice(1,-1):void 0,r=n?C.get(n):void 0;return(0,Z.jsx)(`button`,{onClick:()=>E(e),className:G(`flex items-center justify-center size-9 rounded-full text-xl transition-all focus:outline-none hover:bg-secondary hover:scale-110 active:scale-95`,x===e&&`bg-secondary scale-110`),title:`React with ${t?n:e}`,children:r?(0,Z.jsx)(di,{name:n??e,url:r,className:`size-6 object-contain`}):e},e)}),(0,Z.jsx)(`button`,{onClick:()=>{b(!0),i?.(!0)},className:`flex items-center justify-center size-9 rounded-full text-muted-foreground transition-all focus:outline-none hover:bg-secondary hover:text-foreground hover:scale-110 active:scale-95`,title:`More reactions`,children:(0,Z.jsx)(at,{className:`size-5`})})]}):null}function od(e){let{nostr:t}=R(),{user:n}=U(),r=V().getQueryData([`user-reaction`,e??``]),i=r!==void 0,{data:a}=B({queryKey:[`user-reaction`,e??``],queryFn:async({signal:r})=>{if(!e||!n)return null;let i=await t.query([{kinds:[7],authors:[n.pubkey],"#e":[e],limit:1}],{signal:r});return i.length===0||i[0].content.trim()===`-`?null:or(i[0])??null},enabled:!!e&&!!n&&!i,staleTime:3e5,gcTime:6e5});return i?r:a}function sd({eventId:e,eventPubkey:t,eventKind:n,reactionCount:r=0,className:i,filledHeart:a=!1,variant:o=`pill`}){let{t:s}=Fn(),{user:c}=U(),{nostr:l}=R(),{mutate:u}=ln(),d=V(),{config:f}=Kt(),p=f.nip85StatsPubkey,m=(0,Q.useMemo)(()=>[`nip85-event-stats`,e,p],[e,p]),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(null),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(!1),b=od(e),x=!!b,S=(0,Q.useCallback)(async t=>{if(t.stopPropagation(),!c)return;let n=await l.query([{kinds:[7],authors:[c.pubkey],"#e":[e],limit:1}]);if(n.length===0)return;let r=n[0].id,i=d.getQueryData([`user-reaction`,e]),a=d.getQueryData(m);d.setQueryData([`user-reaction`,e],null),a&&d.setQueryData(m,{...a,reactionCount:Math.max(0,a.reactionCount-1)}),u({kind:5,content:``,tags:[[`e`,r],[`k`,`7`]]},{onSuccess:()=>{setTimeout(()=>{Oo(d,e,p),d.invalidateQueries({queryKey:[`event-interactions`,e]}),d.invalidateQueries({queryKey:[`user-reaction`,e]})},3e3)},onError:()=>{d.setQueryData([`user-reaction`,e],i),a&&d.setQueryData(m,a)}})},[c,l,e,u,d,p,m]),C=(0,Q.useCallback)(()=>{c&&(x||v.current||(_.current&&=(clearTimeout(_.current),null),g(!0)))},[c,x]),w=(0,Q.useCallback)(()=>{y.current||(_.current=setTimeout(()=>{g(!1)},150))},[]);return(0,Z.jsxs)(Ai,{open:h,onOpenChange:e=>{e&&v.current||(e||(y.current=!1),g(e))},children:[(0,Z.jsx)(Oi,{asChild:!0,children:(0,Z.jsxs)(`button`,{className:G(`transition-colors focus:outline-none`,o===`chip`?`inline-flex items-center gap-2 h-9 px-3 rounded-full text-sm font-medium text-muted-foreground hover:text-pink-500 hover:bg-pink-500/10`:`flex items-center gap-1.5 p-2 rounded-full text-muted-foreground hover:text-pink-500 hover:bg-pink-500/10`,i,x&&`text-pink-500`),title:s(`feed.actions.react`),onClick:e=>{if(e.stopPropagation(),c){if(x){Ri(),S(e);return}v.current||g(e=>!e)}},onDoubleClick:r=>{if(r.stopPropagation(),!c||x)return;Ri(),g(!1);let i=d.getQueryData(m);d.setQueryData([`user-reaction`,e],{content:`❤️`}),i&&d.setQueryData(m,{...i,reactionCount:i.reactionCount+1}),u({kind:7,content:`❤️`,tags:[[`e`,e],[`p`,t],[`k`,String(n)]]},{onSuccess:()=>{setTimeout(()=>{Oo(d,e,p),d.invalidateQueries({queryKey:[`event-interactions`,e]}),d.invalidateQueries({queryKey:[`user-reaction`,e]})},3e3)},onError:()=>{d.setQueryData([`user-reaction`,e],null),i&&d.setQueryData(m,i)}})},onMouseEnter:C,onMouseLeave:w,children:[a?(0,Z.jsx)(Ue,{className:`size-6`,fill:x?`currentColor`:`none`}):x&&b?(0,Z.jsx)(ci,{emoji:b,className:G(`object-contain leading-none translate-y-px`,o===`chip`?`h-[18px] w-[18px]`:`h-5 w-5`)}):(0,Z.jsx)(Ue,{className:o===`chip`?`size-[18px]`:`size-5`}),r>0?(0,Z.jsx)(`span`,{className:G(`tabular-nums`,o===`chip`?``:`text-sm`,x&&`text-pink-500`),children:ii(r)}):null]})}),(0,Z.jsx)(ki,{className:`w-auto p-0 border-0 bg-transparent shadow-none`,side:`top`,align:`start`,onClick:e=>e.stopPropagation(),onOpenAutoFocus:e=>e.preventDefault(),onMouseEnter:C,onMouseLeave:w,children:(0,Z.jsx)(ad,{eventId:e,eventPubkey:t,eventKind:n,onExpandChange:e=>{y.current=e},onClose:()=>{y.current=!1,v.current=!0,g(!1),setTimeout(()=>{v.current=!1},300)}})})]})}function cd(e){let{nostr:t}=R(),{user:n}=U(),r=V(),i=e?.value??``,a=r.getQueryData([`external-user-reaction`,i]),{data:o}=B({queryKey:[`external-user-reaction`,i],queryFn:async({signal:e})=>{if(!i||!n)return null;let r=await t.query([{kinds:[17],authors:[n.pubkey],"#i":[i],limit:1}],{signal:e});if(r.length===0)return null;let a=r[0].content.trim();return a===`-`?null:{emoji:a||`+`,tags:r[0].tags}},enabled:!!i&&!!n&&a===void 0,staleTime:3e5,gcTime:6e5});return a===void 0?o:a}function ld(e){let{nostr:t}=R(),n=e?.value??``,{data:r}=B({queryKey:[`external-reaction-count`,n],queryFn:async({signal:e})=>n?(await t.query([{kinds:[17],"#i":[n],limit:500}],{signal:e})).filter(e=>e.content.trim()!==`-`).length:0,enabled:!!n,staleTime:12e4,gcTime:6e5});return r??0}function ud(e){switch(e.type){case`url`:return`web`;case`isbn`:return`isbn`;case`iso3166`:return`iso3166`;default:return`web`}}function dd({content:e,iconSize:t=`size-5`,count:n,className:r,variant:i=`pill`}){let{user:a}=U(),{mutate:o}=ln(),s=V(),{toast:c}=sn(),l=e.value,u=cd(e),d=ld(e),f=!!u,p=u?.emoji,m=u?.tags,[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(null),v=(0,Q.useRef)(!1),y=(0,Q.useRef)(!1),b=(0,Q.useCallback)(()=>{a&&(v.current||(_.current&&=(clearTimeout(_.current),null),g(!0)))},[a]),x=(0,Q.useCallback)(()=>{y.current||(_.current=setTimeout(()=>g(!1),150))},[]),S=(0,Q.useCallback)((t,n)=>{if(!a)return;Ri();let r=[[`k`,ud(e)],[`i`,l]];n&&r.push(n),s.setQueryData([`external-user-reaction`,l],{emoji:t||`+`,tags:r}),s.setQueryData([`external-reaction-count`,l],e=>(e??0)+1),o({kind:17,content:t,created_at:Math.floor(Date.now()/1e3),tags:r},{onSuccess:()=>{setTimeout(()=>{s.invalidateQueries({queryKey:[`external-user-reaction`,l]}),s.invalidateQueries({queryKey:[`external-reaction-count`,l]})},3e3)},onError:()=>{c({title:`Failed to react`,variant:`destructive`}),s.setQueryData([`external-user-reaction`,l],null),s.setQueryData([`external-reaction-count`,l],e=>Math.max(0,(e??1)-1))}})},[a,e,l,o,s,c]);return(0,Z.jsxs)(Ai,{open:h,onOpenChange:e=>{e&&v.current||(e||(y.current=!1),g(e))},children:[(0,Z.jsx)(Oi,{asChild:!0,children:(0,Z.jsxs)(`button`,{className:G(`transition-colors`,i===`chip`?`inline-flex items-center gap-2 h-9 px-3 rounded-full text-sm font-medium`:`flex items-center gap-1.5 p-2 rounded-full`,f?`text-pink-500`:`text-muted-foreground hover:text-pink-500 hover:bg-pink-500/10`,r),title:`React`,onClick:e=>{e.stopPropagation(),a&&(v.current||g(e=>!e))},onMouseEnter:b,onMouseLeave:x,children:[f&&p?(0,Z.jsx)(`span`,{className:G(t,`flex items-center justify-center text-base leading-none`),children:(0,Z.jsx)(ui,{content:p,tags:m,className:t})}):(0,Z.jsx)(Ue,{className:t}),(n??d)>0?(0,Z.jsx)(`span`,{className:G(`tabular-nums`,i===`chip`?``:`text-sm`),children:ii(n??d)}):i===`chip`?(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:`React`}):null]})}),(0,Z.jsx)(ki,{className:`w-auto p-0 border-0 bg-transparent shadow-none`,side:`top`,align:`start`,onClick:e=>e.stopPropagation(),onOpenAutoFocus:e=>e.preventDefault(),onMouseEnter:b,onMouseLeave:x,children:(0,Z.jsx)(ad,{eventId:l,eventPubkey:``,eventKind:17,onExpandChange:e=>{y.current=e},onClose:()=>{y.current=!1,v.current=!0,g(!1),setTimeout(()=>{v.current=!1},300)},onReact:S})})]})}var fd=Q.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(`svg`,{ref:n,xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,...t,children:(0,Z.jsx)(`path`,{d:`M12.09 13.119c-.936 1.932-2.217 4.548-2.853 5.728-.616 1.074-1.127.931-1.532.029-1.406-3.321-4.293-9.144-5.651-12.409-.251-.601-.441-.987-.619-1.139-.181-.15-.554-.24-1.122-.271C.103 5.033 0 4.982 0 4.898v-.455l.052-.045c.924-.005 5.401 0 5.401 0l.051.045v.434c0 .119-.075.176-.225.176l-.564.031c-.485.029-.727.164-.727.436 0 .135.053.33.166.601 1.082 2.646 4.818 10.521 4.818 10.521l.136.046 2.411-4.81-.482-1.067-1.658-3.264s-.318-.654-.428-.872c-.728-1.443-.712-1.518-1.447-1.617-.207-.023-.313-.05-.313-.149v-.468l.06-.045h4.292l.113.037v.451c0 .105-.076.15-.227.15l-.308.047c-.792.061-.661.381-.136 1.422l1.582 3.252 1.758-3.504c.293-.64.233-.801.111-.947-.07-.084-.305-.22-.812-.24l-.201-.021c-.052 0-.098-.015-.145-.051-.045-.031-.067-.076-.067-.129v-.427l.061-.045c1.247-.008 4.043 0 4.043 0l.059.045v.436c0 .121-.059.178-.193.178-.646.03-.782.095-1.023.439-.12.186-.375.589-.646 1.039l-2.301 4.273-.065.135 2.792 5.712.17.048 4.396-10.438c.154-.422.129-.722-.064-.895-.197-.172-.346-.273-.857-.295l-.42-.016c-.061 0-.105-.014-.152-.045-.043-.029-.072-.075-.072-.119v-.436l.059-.045h4.961l.041.045v.437c0 .119-.074.18-.209.18-.648.03-1.127.18-1.443.421-.314.255-.557.616-.736 1.067 0 0-4.043 9.258-5.426 12.339-.525 1.007-1.053.917-1.503-.031-.571-1.171-1.773-3.786-2.646-5.71l.053-.036z`})}));fd.displayName=`WikipediaIcon`;var pd=Q.forwardRef(({className:e,...t},n)=>(0,Z.jsx)(`svg`,{ref:n,xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,className:e,...t,children:(0,Z.jsx)(`path`,{d:`M5.202 2.857C7.954 4.922 10.913 9.11 12 11.358c1.087-2.247 4.046-6.436 6.798-8.501C20.783 1.366 24 .213 24 3.883c0 .732-.42 6.156-.667 7.037-.856 3.061-3.978 3.842-6.755 3.37 4.854.826 6.089 3.562 3.422 6.299-5.065 5.196-7.28-1.304-7.847-2.97-.104-.305-.152-.448-.153-.327 0-.121-.05.022-.153.327-.568 1.666-2.782 8.166-7.847 2.97-2.667-2.737-1.432-5.473 3.422-6.3-2.777.473-5.899-.308-6.755-3.369C.42 10.04 0 4.615 0 3.883c0-3.67 3.217-2.517 5.202-1.026`})}));pd.displayName=`BlueskyIcon`;function md(e){if(e.startsWith(`isbn:`))return{type:`isbn`,value:e};if(e.startsWith(`iso3166:`))return{type:`iso3166`,value:e,code:e.slice(8)};let t=e.match(/^bitcoin:tx:([0-9a-f]{64})$/i);if(t)return{type:`bitcoin-tx`,value:e,txid:t[1].toLowerCase()};let n=e.match(/^bitcoin:address:(.+)$/);return n?{type:`bitcoin-address`,value:e,address:n[1]}:e.startsWith(`http://`)||e.startsWith(`https://`)?{type:`url`,value:e}:{type:`unknown`,value:e}}function hd(e){let t=e.replace(/\D/g,``);return t.length===13?`${t.slice(0,3)}-${t.slice(3,4)}-${t.slice(4,9)}-${t.slice(9,12)}-${t.slice(12)}`:t.length===10?`${t.slice(0,1)}-${t.slice(1,5)}-${t.slice(5,9)}-${t.slice(9)}`:e}function gd(e){try{let{pathname:t}=new URL(e),n=t.split(`/`).filter(Boolean);for(let e=n.length-1;e>=0;e--){let t=decodeURIComponent(n[e]);if(!(t.length<4)&&!(/^[A-Za-z0-9_-]{6,14}$/.test(t)&&!/[- ]/.test(t))&&/[-_]/.test(t))return t.replace(/[-_]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim()}}catch{}return null}function _d(e){switch(e.type){case`url`:{let t=gd(e.value);if(t)return t;let n=Vr(e.value);if(n)return n;try{return new URL(e.value).hostname.replace(/^www\./,``)}catch{return`Web Page`}}case`isbn`:return`Books`;case`iso3166`:{let t=Ui(e.code);return t?.subdivisionName??t?.name??`Country`}case`bitcoin-tx`:return`Bitcoin Transaction`;case`bitcoin-address`:return`Bitcoin Address`;default:return`External Content`}}function vd(e,t){switch(e.type){case`url`:try{return`${new URL(e.value).hostname.replace(/^www\./,``)} | ${t}`}catch{return`Web Page | ${t}`}case`isbn`:return`Book (ISBN ${e.value.replace(`isbn:`,``)}) | ${t}`;case`iso3166`:{let n=Ui(e.code),r=n?.subdivisionName??n?.name;return r?`${r} | ${t}`:`Country | ${t}`}case`bitcoin-tx`:return`Bitcoin TX ${`${e.txid.slice(0,8)}...${e.txid.slice(-8)}`} | ${t}`;case`bitcoin-address`:return`Bitcoin Address ${`${e.address.slice(0,8)}...${e.address.slice(-6)}`} | ${t}`;default:return`External Content | ${t}`}}async function yd(e,t){if(navigator.share)try{return await navigator.share({url:e,title:t}),`shared`}catch(e){if(e instanceof Error&&e.name===`AbortError`)return`cancelled`}return await navigator.clipboard.writeText(e),`copied`}async function bd(e,t){try{let n=encodeURIComponent(e.replace(/ /g,`_`)),r=await fetch(`https://en.wikipedia.org/api/rest_v1/page/summary/${n}`,{signal:t,headers:{Accept:`application/json`}});if(!r.ok)return null;let i=await r.json();return i.type===`disambiguation`||i.type===`no-extract`?null:{title:i.title??e,extract:i.extract??``,extractHtml:i.extract_html??``,description:i.description,thumbnail:i.thumbnail?{source:i.thumbnail.source,width:i.thumbnail.width,height:i.thumbnail.height}:void 0,originalImage:i.originalimage?{source:i.originalimage.source,width:i.originalimage.width,height:i.originalimage.height}:void 0,articleUrl:i.content_urls?.desktop?.page??`https://en.wikipedia.org/wiki/${n}`}}catch{return null}}function xd(e){return B({queryKey:[`wikipedia-summary`,e],queryFn:({signal:t})=>bd(e,t),enabled:!!e,staleTime:864e5,gcTime:6048e5,retry:1})}var Sd=`https://query.wikidata.org/sparql`;function Cd(e){return` SELECT ?country ?countryLabel ?demonymLabel ?capitalLabel ?governmentLabel ?headOfStateLabel ?headOfGovernmentLabel ?population ?area ?inception (GROUP_CONCAT(DISTINCT ?languageEntry; SEPARATOR="|") AS ?languages) (GROUP_CONCAT(DISTINCT ?currencyLabel; SEPARATOR="|") AS ?currencies) (GROUP_CONCAT(DISTINCT ?timeZoneLabel; SEPARATOR="|") AS ?timeZones) (GROUP_CONCAT(DISTINCT CONCAT(LANG(?officialName), ":", STR(?officialName)); SEPARATOR="|") AS ?officialNames) (SAMPLE(?coatOfArms) AS ?coatOfArms) (SAMPLE(?anthem) AS ?anthem) (SAMPLE(?anthemLabel) AS ?anthemTitle) WHERE { ?country wdt:P297 "${e.toUpperCase().replace(/[^A-Z]/g,``)}" . OPTIONAL { ?country wdt:P1813 ?demonym . FILTER(LANG(?demonym) = "en") } OPTIONAL { ?country wdt:P1448 ?officialName . } OPTIONAL { ?country wdt:P36 ?capital . } OPTIONAL { ?country wdt:P122 ?government . } OPTIONAL { ?country wdt:P35 ?headOfState . } OPTIONAL { ?country wdt:P6 ?headOfGovernment . } OPTIONAL { ?country wdt:P1082 ?population . } OPTIONAL { ?country wdt:P2046 ?area . } OPTIONAL { ?country wdt:P571 ?inception . } OPTIONAL { ?country wdt:P37 ?language . ?language rdfs:label ?languageLabel . FILTER(LANG(?languageLabel) = "en") # Wikidata lists sign languages as official languages of many # countries (e.g. Venezuelan Sign Language for VE) alongside the # spoken language(s). For a destination-flavour header the user # is asking "what do they speak?" — signed languages are # accessibility metadata, not a postcard answer. Filter them out. FILTER NOT EXISTS { ?language wdt:P31/wdt:P279* wd:Q34228 } BIND(?languageLabel AS ?languageEntry) } OPTIONAL { ?country wdt:P38 ?currency . ?currency rdfs:label ?currencyLabel . FILTER(LANG(?currencyLabel) = "en") } OPTIONAL { ?country wdt:P421 ?timeZone . ?timeZone rdfs:label ?timeZoneLabel . FILTER(LANG(?timeZoneLabel) = "en") } OPTIONAL { ?country wdt:P94 ?coatOfArms . } OPTIONAL { ?country wdt:P85 ?anthemRef . ?anthemRef wdt:P51 ?anthem . ?anthemRef rdfs:label ?anthemLabel . FILTER(LANG(?anthemLabel) = "en") } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } GROUP BY ?country ?countryLabel ?demonymLabel ?capitalLabel ?governmentLabel ?headOfStateLabel ?headOfGovernmentLabel ?population ?area ?inception LIMIT 1`}function wd(e){let t=Td(e);return t?`https://commons.wikimedia.org/wiki/Special:FilePath/${encodeURIComponent(t)}`:null}function Td(e){if(!e)return null;let t=e.replace(/^https?:\/\/commons\.wikimedia\.org\/wiki\/Special:FilePath\//i,``);if(!t)return null;try{return decodeURIComponent(t)}catch{return t}}function Ed(e){return e?e.split(`|`).map(e=>e.trim()).filter(Boolean):[]}function Dd(e){if(!e)return null;let t=e.match(/^(-?\d{1,4})(?:-(\d{2}))?(?:-(\d{2}))?/);if(!t)return null;let[,n,r,i]=t;return r===`01`&&i===`01`||!r?n:i?`${n}-${r}-${i}`:`${n}-${r}`}async function Od(e,t){try{let n=new URL(Sd);n.searchParams.set(`query`,Cd(e)),n.searchParams.set(`format`,`json`);let r=await fetch(n.toString(),{signal:t,headers:{Accept:`application/sparql-results+json`}});if(!r.ok)return null;let i=(await r.json()).results?.bindings?.[0];if(!i||!i.country)return null;let a=e=>i[e]?.value,o=e=>{let t=a(e);if(!t)return null;let n=Number(t);return Number.isFinite(n)?n:null},s=Ed(a(`officialNames`)).map(e=>{let t=e.indexOf(`:`);if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1);return!n||!r?null:{lang:n,name:r}}).filter(e=>e!==null),c=i.country.value.split(`/`).pop()??``;return{id:c,officialNames:s,demonym:a(`demonymLabel`)??null,capital:a(`capitalLabel`)??null,government:a(`governmentLabel`)??null,headOfState:a(`headOfStateLabel`)??null,headOfGovernment:a(`headOfGovernmentLabel`)??null,population:o(`population`),area:o(`area`),inception:Dd(a(`inception`)),languages:Ed(a(`languages`)),currencies:Ed(a(`currencies`)),coatOfArmsUrl:wd(a(`coatOfArms`)),anthemFilename:Td(a(`anthem`)),anthemTitle:a(`anthemTitle`)??null,timeZones:Ed(a(`timeZones`)),wikidataUrl:`https://www.wikidata.org/wiki/${c}`}}catch{return null}}function kd(e){let t=!!e&&/^[A-Za-z]{2}$/.test(e);return B({queryKey:[`country-facts`,e?.toUpperCase()??null],queryFn:({signal:t})=>Od(e,t),enabled:t,staleTime:864e5,gcTime:6048e5,retry:1})}var Ad=`https://commons.wikimedia.org/w/api.php`;async function jd(e,t){let n=new URL(Ad);n.searchParams.set(`action`,`query`),n.searchParams.set(`titles`,`File:${e}`),n.searchParams.set(`prop`,`videoinfo`),n.searchParams.set(`viprop`,`derivatives|url`),n.searchParams.set(`format`,`json`),n.searchParams.set(`origin`,`*`);let r=await fetch(n.toString(),{signal:t,headers:{Accept:`application/json`}});if(!r.ok)return[];let i=(await r.json()).query?.pages??{},a=Object.values(i)[0]?.videoinfo?.[0];if(!a)return[];let o=(a.derivatives??[]).filter(e=>!!e.src&&!!e.type).map(e=>({src:e.src.replace(/[?&](?:utm_[^=]+|fastcgi)=[^&]*/g,``).replace(/[?&]$/,``),type:e.type}));if(o.length>0)return o;if(a.url){let t=e.split(`.`).pop()?.toLowerCase(),n=t===`mp3`?`audio/mpeg`:t===`oga`||t===`ogg`?`audio/ogg; codecs="vorbis"`:t===`opus`?`audio/ogg; codecs="opus"`:t===`flac`?`audio/flac`:t===`wav`?`audio/wav`:`audio/*`;return[{src:a.url.replace(/[?&](?:utm_[^=]+)=[^&]*/g,``).replace(/[?&]$/,``),type:n}]}return[]}function Md(e){return B({queryKey:[`commons-audio`,e??null],queryFn:({signal:t})=>jd(e,t),enabled:!!e,staleTime:864e5,gcTime:6048e5,retry:1})}function Nd({url:e}){let t=(0,Q.useMemo)(()=>oi(e),[e]),n=(0,Q.useMemo)(()=>Br(e),[e]);return t?(0,Z.jsx)(Rd,{title:t,url:e}):n?(0,Z.jsx)(Id,{author:n.author,rkey:n.rkey,url:e}):(0,Z.jsx)(qr,{url:e,showActions:!1})}function Pd(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Fd(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return`${r}h`;let i=Math.floor(r/24);return i<30?`${i}d`:`${Math.floor(i/30)}mo`}function Id({author:e,rkey:t,url:n}){let{data:r,isLoading:i,isError:a}=dr(e,t),{toast:o}=sn(),s=`/i/${encodeURIComponent(`https://bsky.app/profile/${r?.handle??e}`)}`,c=ha(),l=(0,Q.useMemo)(()=>md(n),[n]),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=(0,Q.useCallback)(e=>{e.stopPropagation(),p(!0)},[]),h=(0,Q.useCallback)(e=>{e.stopPropagation(),d(!0)},[]),g=(0,Q.useCallback)(async e=>{e.stopPropagation(),await yd(`${c}/i/${encodeURIComponent(n)}`)===`copied`&&o({title:`Link copied`})},[c,n,o]);return i?(0,Z.jsx)(`div`,{className:`py-3`,children:(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsx)(J,{className:`size-11 rounded-full shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(J,{className:`h-4 w-28`}),(0,Z.jsx)(J,{className:`h-3.5 w-20`})]}),(0,Z.jsx)(J,{className:`h-4 w-full`}),(0,Z.jsx)(J,{className:`h-4 w-4/5`}),(0,Z.jsxs)(`div`,{className:`flex gap-6 pt-1`,children:[(0,Z.jsx)(J,{className:`h-4 w-10`}),(0,Z.jsx)(J,{className:`h-4 w-10`}),(0,Z.jsx)(J,{className:`h-4 w-10`})]})]})]})}):a||!r?(0,Z.jsx)(qr,{url:n,showActions:!1}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`article`,{className:`py-1`,children:[(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsx)(K,{to:s,className:`shrink-0`,children:r.avatar?(0,Z.jsx)(`img`,{src:r.avatar,alt:``,className:`size-11 rounded-full object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-11 rounded-full bg-gradient-to-br from-sky-400 to-blue-500 flex items-center justify-center text-white text-sm font-bold`,children:(r.displayName??r.handle).charAt(0).toUpperCase()})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(K,{to:s,className:`font-semibold text-[15px] truncate leading-tight hover:underline`,children:r.displayName??r.handle}),(0,Z.jsxs)(K,{to:s,className:`text-muted-foreground text-sm truncate leading-tight hover:underline`,children:[`@`,r.handle]}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-sm shrink-0`,children:`·`}),(0,Z.jsx)(`span`,{className:`text-muted-foreground text-sm shrink-0`,children:Fd(r.createdAt)})]}),r.text&&(0,Z.jsx)(`p`,{className:`mt-1 text-[15px] leading-relaxed whitespace-pre-wrap break-words`,children:r.text}),r.images&&r.images.length>0&&(0,Z.jsx)(`div`,{className:G(`mt-3 rounded-xl overflow-hidden border border-border`,r.images.length===1&&`grid grid-cols-1`,r.images.length===2&&`grid grid-cols-2 gap-0.5`,r.images.length===3&&`grid grid-cols-2 gap-0.5`,r.images.length>=4&&`grid grid-cols-2 gap-0.5`),children:r.images.slice(0,4).map((e,t)=>(0,Z.jsx)(`div`,{className:G(`relative overflow-hidden bg-secondary`,r.images.length===1?`aspect-video`:`aspect-square`,r.images.length===3&&t===0&&`row-span-2 aspect-auto`),children:(0,Z.jsx)(`img`,{src:e.thumb,alt:e.alt||``,loading:`lazy`,className:`absolute inset-0 w-full h-full object-cover`,onError:e=>{e.currentTarget.style.display=`none`}})},t))}),r.external&&r.external.thumb&&(0,Z.jsxs)(`div`,{className:`mt-3 rounded-xl border border-border overflow-hidden bg-secondary/30`,children:[(0,Z.jsx)(`div`,{className:`aspect-[2/1] overflow-hidden bg-secondary`,children:(0,Z.jsx)(`img`,{src:r.external.thumb,alt:``,loading:`lazy`,className:`w-full h-full object-cover`,onError:e=>{e.currentTarget.style.display=`none`}})}),r.external.title&&(0,Z.jsx)(`div`,{className:`px-3 py-2.5`,children:(0,Z.jsx)(`p`,{className:`text-sm font-semibold leading-tight line-clamp-2`,children:r.external.title})})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 sm:gap-2 mt-3`,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:m,className:`inline-flex items-center gap-2 h-9 px-3 rounded-full text-sm font-medium text-muted-foreground hover:text-sky-500 hover:bg-sky-500/10 transition-colors`,title:`Comment`,children:[(0,Z.jsx)(be,{className:`size-[18px]`}),r.replyCount>0?(0,Z.jsx)(`span`,{className:`tabular-nums`,children:Pd(r.replyCount)}):(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:`Comment`})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-2 h-9 px-3 rounded-full text-sm font-medium text-muted-foreground hover:text-green-500 hover:bg-green-500/10 transition-colors`,title:`Share to feed`,children:[(0,Z.jsx)(Ce,{className:`size-[18px]`}),r.repostCount>0?(0,Z.jsx)(`span`,{className:`tabular-nums`,children:Pd(r.repostCount)}):(0,Z.jsx)(`span`,{className:`hidden sm:inline`,children:`Repost`})]}),(0,Z.jsx)(dd,{content:l,count:r.likeCount,variant:`chip`}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,onClick:g,className:`inline-flex items-center justify-center h-9 w-9 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:`Share link`,children:(0,Z.jsx)(ot,{className:`size-[18px]`})})]})]})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(pd,{className:`size-3.5 text-sky-500`}),(0,Z.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:`hover:text-foreground transition-colors hover:underline`,children:`View on Bluesky`}),(0,Z.jsx)(F,{className:`size-3`})]})]}),f&&(0,Z.jsx)(Qd,{open:f,onOpenChange:p,event:new URL(n)}),u&&(0,Z.jsx)(Qd,{open:u,onOpenChange:d,initialContent:n,title:`Share to feed`})]})}var Ld=160;function Rd({title:e,url:t}){let{data:n,isLoading:r}=xd(e),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(()=>{let e=i.current;e&&o(e.scrollHeight>Ld)},[]);if((0,Q.useEffect)(()=>(l(),window.addEventListener(`resize`,l),()=>window.removeEventListener(`resize`,l)),[l]),r)return(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,Z.jsx)(J,{className:`w-full aspect-[16/9]`}),(0,Z.jsxs)(`div`,{className:`p-5 space-y-3`,children:[(0,Z.jsx)(J,{className:`h-3 w-24`}),(0,Z.jsx)(J,{className:`h-7 w-3/4`}),(0,Z.jsx)(J,{className:`h-4 w-1/2`}),(0,Z.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,Z.jsx)(J,{className:`h-4 w-full`}),(0,Z.jsx)(J,{className:`h-4 w-full`}),(0,Z.jsx)(J,{className:`h-4 w-3/4`})]})]})]});if(!n)return(0,Z.jsx)(qr,{url:t,showActions:!1});let u=n.originalImage?.source??n.thumbnail?.source;return(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[u&&(0,Z.jsx)(`div`,{className:`relative w-full overflow-hidden bg-gradient-to-br from-blue-500/10 to-indigo-500/10`,children:(0,Z.jsx)(`img`,{src:u,alt:n.title,className:`w-full max-h-[320px] object-cover`,loading:`eager`,onError:e=>{e.currentTarget.parentElement.style.display=`none`}})}),(0,Z.jsxs)(`div`,{className:`p-5 sm:p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground mb-2`,children:[(0,Z.jsx)(fd,{className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{children:`Wikipedia`})]}),(0,Z.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold leading-snug mb-1`,children:n.title}),n.description&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground capitalize mb-4`,children:n.description}),n.extract&&(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`p`,{ref:i,style:!s&&a?{maxHeight:Ld,overflow:`hidden`}:void 0,className:`text-sm leading-relaxed text-muted-foreground`,children:n.extract}),!s&&a&&(0,Z.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-12 bg-gradient-to-t from-background to-transparent pointer-events-none`})]}),a&&(0,Z.jsx)(`button`,{className:`text-sm text-primary hover:underline`,onClick:()=>c(e=>!e),children:s?`Show less`:`Read more`})]})]}),(0,Z.jsx)(`div`,{className:`border-t border-border px-5 py-2.5`,children:(0,Z.jsxs)(`a`,{href:n.articleUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsx)(fd,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Read on Wikipedia`}),(0,Z.jsx)(F,{className:`size-3`})]})})]})}function zd({isbn:e}){let t=e.replace(`isbn:`,``),{data:n,isLoading:i}=Js(t),a=hd(t);if(i)return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border overflow-hidden p-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-5`,children:[(0,Z.jsx)(J,{className:`w-[120px] h-[180px] rounded-lg shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[(0,Z.jsx)(J,{className:`h-3 w-24`}),(0,Z.jsx)(J,{className:`h-6 w-3/4`}),(0,Z.jsx)(J,{className:`h-4 w-1/2`}),(0,Z.jsx)(J,{className:`h-4 w-1/3`}),(0,Z.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,Z.jsx)(J,{className:`h-6 w-16 rounded-full`}),(0,Z.jsx)(J,{className:`h-6 w-20 rounded-full`})]})]})]})});let o=n?.cover?.large||n?.cover?.medium,s=n?.authors?.map(e=>e.name).join(`, `),c=n?.publishers?.map(e=>e.name).join(`, `);return(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`p-5`,children:(0,Z.jsxs)(`div`,{className:`flex gap-5`,children:[o?(0,Z.jsx)(`div`,{className:`shrink-0`,children:(0,Z.jsx)(`img`,{src:o,alt:n?.title||`Book cover`,className:`w-[120px] sm:w-[140px] rounded-lg shadow-md object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}})}):(0,Z.jsx)(`div`,{className:`shrink-0 w-[120px] sm:w-[140px] h-[180px] sm:h-[210px] rounded-lg bg-secondary flex items-center justify-center`,children:(0,Z.jsx)(w,{className:`size-10 text-muted-foreground`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(w,{className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{children:[`ISBN `,a]})]}),(0,Z.jsx)(`h2`,{className:`text-xl font-bold leading-snug line-clamp-3`,children:n?.title||`Unknown Book`}),s&&(0,Z.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`by `,s]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground pt-1`,children:[n?.publish_date&&(0,Z.jsx)(`span`,{children:n.publish_date}),c&&(0,Z.jsx)(`span`,{children:c}),n?.number_of_pages&&(0,Z.jsxs)(`span`,{children:[n.number_of_pages,` pages`]})]}),n?.subjects&&n.subjects.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-2`,children:n.subjects.map(e=>(0,Z.jsx)(`span`,{className:`text-xs px-2.5 py-0.5 rounded-full bg-secondary text-muted-foreground`,children:e.name},e.name))})]})]})}),(0,Z.jsx)(`div`,{className:`border-t border-border px-5 py-2.5`,children:(0,Z.jsxs)(`a`,{href:`https://openlibrary.org/isbn/${t}`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsx)(r,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`View on OpenLibrary`}),(0,Z.jsx)(F,{className:`size-3`})]})})]})}var Bd=100;function Vd({extract:e,articleUrl:t}){let n=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useCallback)(()=>{let e=n.current;e&&a(e.scrollHeight>Bd)},[]);return(0,Q.useEffect)(()=>(c(),window.addEventListener(`resize`,c),()=>window.removeEventListener(`resize`,c)),[c]),(0,Z.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`p`,{ref:n,style:!o&&i?{maxHeight:Bd,overflow:`hidden`}:void 0,className:`text-sm leading-relaxed text-muted-foreground`,children:e}),!o&&i&&(0,Z.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-12 bg-gradient-to-t from-background to-transparent pointer-events-none`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[i&&(0,Z.jsx)(`button`,{className:`text-sm text-primary hover:underline`,onClick:()=>s(e=>!e),children:o?`Show less`:`Read more`}),(0,Z.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[(0,Z.jsx)(r,{className:`size-3.5`}),(0,Z.jsx)(`span`,{children:`Wikipedia`}),(0,Z.jsx)(F,{className:`size-3`})]})]})]})}function Hd({code:e,facts:t}){let n=[];if(t&&(t.population!==null&&n.push({key:`population`,icon:(0,Z.jsx)(I,{className:`size-3 shrink-0`}),label:`Population`,value:ii(t.population)}),t.languages.length>0&&n.push({key:`languages`,icon:(0,Z.jsx)(dt,{className:`size-3 shrink-0`}),label:t.languages.length>1?`Languages`:`Language`,value:t.languages.slice(0,2).join(`, `)}),t.currencies.length>0&&n.push({key:`currency`,icon:(0,Z.jsx)(Se,{className:`size-3 shrink-0`}),label:t.currencies.length>1?`Currencies`:`Currency`,value:t.currencies[0]})),n.length===0)return null;let r=t?.capital??null;return(0,Z.jsxs)(`div`,{className:`px-4 py-2 flex flex-wrap items-center justify-between gap-x-4 gap-y-1.5 text-sm`,children:[!!r&&(0,Z.jsx)(`div`,{className:`flex flex-wrap items-baseline gap-x-3 gap-y-1 min-w-0`,children:r&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground/80 text-xs`,children:[(0,Z.jsx)(gt,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:r})]})}),(0,Z.jsx)(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground/80 min-w-0`,children:n.map(e=>(0,Z.jsxs)(`li`,{className:`flex items-center gap-1 min-w-0`,title:`${e.label}: ${e.value}`,children:[e.icon,(0,Z.jsx)(`span`,{className:`truncate max-w-[14ch] sm:max-w-[18ch]`,children:e.value})]},e.key))})]})}function Ud({filename:e,title:t}){let n=(0,Q.useRef)(null),[r,i]=(0,Q.useState)(!1),{data:a,isLoading:o}=Md(e),{toast:s}=sn(),c=(0,Q.useMemo)(()=>a?[...a].sort((e,t)=>{let n=e=>/^audio\/mpeg\b/i.test(e);return Number(n(t.type))-Number(n(e.type))}):[],[a]),l=c.length>0,u=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=n.current;!t||!l||(t.paused?t.play().catch(e=>{let t=e instanceof Error?e.message:`Playback failed`;s({title:`Could not play anthem`,description:t,variant:`destructive`}),i(!1)}):t.pause())},[l,s]),d=!l&&!o?`Anthem unavailable`:r?`Pause anthem${t?`: ${t}`:``}`:`Play anthem${t?`: ${t}`:``}`;return o?(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`inline-flex size-8 rounded-full shrink-0 bg-black/20 border border-white/20 backdrop-blur-sm [text-shadow:none]`}):l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:u,"aria-label":d,title:d,className:G(`inline-flex items-center justify-center size-8 rounded-full shrink-0`,`bg-black/30 text-white backdrop-blur-sm border border-white/30`,`hover:bg-black/50 hover:border-white/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80`,`transition-colors [text-shadow:none]`),children:r?(0,Z.jsx)(Ve,{className:`size-3.5`}):(0,Z.jsx)(pt,{className:`size-3.5 translate-x-[1px]`})}),(0,Z.jsx)(`audio`,{ref:n,preload:`none`,onPlay:()=>i(!0),onPause:()=>i(!1),onEnded:()=>i(!1),onError:()=>{i(!1),s({title:`Could not load anthem`,variant:`destructive`})},className:`sr-only`,children:c.map(e=>(0,Z.jsx)(`source`,{src:e.src,type:e.type},e.src))})]}):null}function Wd({code:e}){let t=Ui(e),{data:n,isLoading:r}=xd(Wi(e)),{data:i}=kd(t?.subdivision?null:e),{user:a}=U(),{isFollowingCountry:o,toggleCountryFollow:c,isPending:u}=Ka(),{toast:d}=sn(),f=t?o(e):!1,[p,m]=(0,Q.useState)(!1),h=(0,Q.useCallback)(async n=>{if(n.preventDefault(),n.stopPropagation(),!(!a||!t||u))try{await c(e),d({title:f?`Country unfollowed`:`Country followed`})}catch{d({title:`Failed to update country follow`,variant:`destructive`})}},[a,t,u,c,e,d,f]);if(!t)return(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border p-5 text-center mx-4`,children:[(0,Z.jsx)(st,{className:`size-8 mx-auto mb-2 text-muted-foreground`}),(0,Z.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Unknown country code: `,e]})]});let g=Gi(e)??n?.originalImage?.source??n?.thumbnail?.source??null,_=!t.subdivision&&!!i?.coatOfArmsUrl&&!p;return(0,Z.jsxs)(`section`,{className:`relative isolate overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full aspect-[2/1] sm:aspect-[21/9]`,children:[(0,Z.jsxs)(`div`,{"aria-hidden":!0,className:`absolute inset-0 -z-10`,children:[g?(0,Z.jsx)(`img`,{src:g,alt:``,className:`absolute inset-0 w-full h-full object-cover`,loading:`eager`}):(0,Z.jsx)(`div`,{className:G(`absolute inset-0`,`bg-gradient-to-br from-amber-400/30 via-rose-400/20 to-primary/10`)}),(0,Z.jsx)(`div`,{className:G(`absolute inset-0`,`bg-[linear-gradient(to_bottom,rgba(254,202,87,0.18)_0%,rgba(255,107,107,0.12)_30%,rgba(0,0,0,0.65)_70%,hsl(var(--card))_100%)]`)})]}),(0,Z.jsx)(K,{to:`/`,"aria-label":`Back`,className:G(`sidebar:hidden absolute top-3 left-3 z-10 inline-flex items-center justify-center size-9 rounded-full`,`bg-black/30 text-white backdrop-blur-sm border border-white/30`,`hover:bg-black/50 hover:border-white/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/80`,`transition-colors shadow-md`),children:(0,Z.jsx)(rt,{className:`size-5`})}),a&&(0,Z.jsx)(`div`,{className:`absolute top-3 right-3 z-10`,children:(0,Z.jsx)(Sr,{size:`sm`,isFollowing:f,isPending:u,onClick:h,icon:(0,Z.jsx)(ue,{className:`size-4`}),followingIcon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s,{className:`size-4 group-hover:hidden group-focus-visible:hidden`}),(0,Z.jsx)(l,{className:`size-4 hidden group-hover:inline group-focus-visible:inline`})]}),hoverToUnfollow:!0,className:G(`shadow-md`,!f&&`bg-white text-black hover:bg-white/90`,f&&`bg-black/30 backdrop-blur-sm border-white/40 text-white hover:bg-destructive/30 hover:text-white hover:border-destructive/60`)})}),(0,Z.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 px-5 pb-4 pt-10 [text-shadow:0_1px_4px_rgba(0,0,0,0.7),0_2px_8px_rgba(0,0,0,0.4)]`,children:(0,Z.jsxs)(`div`,{className:`flex items-end gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-end gap-2 [text-shadow:none] shrink-0`,children:[t.subdivision&&n?.thumbnail&&!Ki(e)?(0,Z.jsx)(`img`,{src:n.thumbnail.source,alt:t.subdivisionName??t.subdivision,className:`size-14 sm:size-16 rounded-md object-cover shadow-lg border border-white/20`}):(0,Z.jsx)(qi,{code:e,emoji:t.flag,label:`Flag of ${t.subdivisionName??t.name}`,className:`text-5xl sm:text-6xl drop-shadow-[0_2px_8px_rgba(0,0,0,0.6)]`}),_&&(0,Z.jsx)(`img`,{src:i.coatOfArmsUrl,alt:`Coat of arms of ${t.name}`,className:`h-10 sm:h-14 w-auto object-contain drop-shadow-[0_2px_8px_rgba(0,0,0,0.6)] -mb-1`,loading:`lazy`,onError:()=>m(!0)})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 pb-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-2xl sm:text-4xl font-bold leading-tight text-white truncate`,children:t.subdivisionName??t.name}),i?.anthemFilename&&(0,Z.jsx)(Ud,{filename:i.anthemFilename,title:i.anthemTitle})]}),t.subdivision&&!Ki(e)?(0,Z.jsxs)(`p`,{className:`text-sm text-white/85 mt-0.5 truncate`,children:[t.name,t.subdivisionName?``:` · ${t.subdivision}`]}):i?.officialNames?.[0]&&i.officialNames[0].name!==t.name?(0,Z.jsx)(`p`,{className:`text-sm text-white/85 mt-0.5 truncate italic`,lang:i.officialNames[0].lang||void 0,children:i.officialNames[0].name}):n?.description?(0,Z.jsx)(`p`,{className:`text-sm text-white/85 mt-0.5 truncate capitalize`,children:n.description}):null]})]})})]}),(0,Z.jsxs)(`div`,{className:`divide-y divide-border/40`,children:[(0,Z.jsx)(Hd,{code:e,facts:i??void 0}),r?(0,Z.jsxs)(`div`,{className:`px-4 pb-1 space-y-2`,children:[(0,Z.jsx)(J,{className:`h-4 w-full`}),(0,Z.jsx)(J,{className:`h-4 w-full`}),(0,Z.jsx)(J,{className:`h-4 w-3/4`})]}):n?.extract?(0,Z.jsx)(`div`,{className:`px-4 pb-1`,children:(0,Z.jsx)(Vd,{extract:n.extract,articleUrl:n.articleUrl})}):null]})]})}function Gd({identifier:e}){let t=(0,Q.useMemo)(()=>md(e),[e]),n=`/i/${encodeURIComponent(e)}`;switch(t.type){case`url`:return(0,Z.jsx)(Kd,{url:t.value,link:n});case`isbn`:return(0,Z.jsx)(qd,{isbn:t.value,link:n});case`iso3166`:return(0,Z.jsx)(Jd,{code:t.code,link:n});default:return(0,Z.jsx)(K,{to:n,className:`block px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(r,{className:`size-5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground truncate`,children:e})]})})}}function Kd({url:e,link:t}){let n=(0,Q.useMemo)(()=>Fr(e),[e]),{data:r,isLoading:i}=Tr(e),a=(0,Q.useMemo)(()=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}},[e]),o=r?.title,s=r?.thumbnail_url,c=r?.provider_name||a;if(i)return(0,Z.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(J,{className:`size-12 rounded-lg shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-3 w-24`}),(0,Z.jsx)(J,{className:`h-4 w-3/4`})]})]})});let l=n?`https://img.youtube.com/vi/${n}/mqdefault.jpg`:s;return(0,Z.jsxs)(K,{to:t,className:`flex items-center gap-3 px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors`,children:[l?(0,Z.jsx)(`img`,{src:l,alt:``,className:`size-12 rounded-lg object-cover shrink-0`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-12 rounded-lg bg-secondary flex items-center justify-center shrink-0`,children:(0,Z.jsx)(cr,{url:e,size:20})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(cr,{url:e,size:12,className:`shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:c})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:o||e})]}),(0,Z.jsx)(F,{className:`size-4 text-muted-foreground shrink-0`})]})}function qd({isbn:e,link:t}){let n=e.replace(`isbn:`,``),{data:r,isLoading:i}=Js(n);if(i)return(0,Z.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(J,{className:`w-9 h-12 rounded shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-3 w-16`}),(0,Z.jsx)(J,{className:`h-4 w-3/4`})]})]})});let a=r?.cover?.medium||r?.cover?.large,o=r?.authors?.map(e=>e.name).join(`, `);return(0,Z.jsxs)(K,{to:t,className:`flex items-center gap-3 px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors`,children:[a?(0,Z.jsx)(`img`,{src:a,alt:r?.title||`Book cover`,className:`w-9 h-12 rounded object-cover shrink-0`,loading:`lazy`}):(0,Z.jsx)(`div`,{className:`w-9 h-12 rounded bg-secondary flex items-center justify-center shrink-0`,children:(0,Z.jsx)(w,{className:`size-4 text-muted-foreground`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(w,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:`Book`})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:r?.title||`ISBN ${n}`}),o&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[`by `,o]})]}),(0,Z.jsx)(F,{className:`size-4 text-muted-foreground shrink-0`})]})}function Jd({code:e,link:t}){let n=Ui(e),r=Ki(e)?n?.subdivisionName??n?.name??e:n?.name??e;return(0,Z.jsxs)(K,{to:t,className:`flex items-center gap-3 px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors`,children:[(0,Z.jsx)(qi,{code:e,emoji:n?.flag??`🌍`,label:`Flag of ${r}`,className:`text-2xl shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(st,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:`Country`})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:r})]}),(0,Z.jsx)(F,{className:`size-4 text-muted-foreground shrink-0`})]})}function Yd({addr:e}){let{data:t,isLoading:n}=pr(e),r=t?.tags.find(([e])=>e===`name`)?.[1]||t?.tags.find(([e])=>e===`d`)?.[1]||`Group`,i=t?.tags.find(([e])=>e===`image`)?.[1],a=t?.tags.find(([e])=>e===`description`)?.[1],o=t?.tags.filter(([e,,,t])=>e===`p`&&t===`moderator`).length??0,s=(0,Q.useMemo)(()=>`/${H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:e.identifier})}`,[e]);return n?(0,Z.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(J,{className:`size-12 rounded-lg shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-3 w-16`}),(0,Z.jsx)(J,{className:`h-4 w-32`})]})]})}):(0,Z.jsxs)(K,{to:s,className:`flex items-center gap-3 px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors`,children:[i?(0,Z.jsx)(`img`,{src:i,alt:r,className:`size-12 rounded-lg object-cover shrink-0`,loading:`lazy`}):(0,Z.jsx)(`div`,{className:`size-12 rounded-lg bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(I,{className:`size-5 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:`Group`}),o>0&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`· `,o,` mod`,o===1?``:`s`]})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:r}),a&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:a})]})]})}function Xd({pubkey:e}){let t=z(e),n=t.data?.metadata,r=n?.name??er(e),i=kt(e,n);return t.isLoading?(0,Z.jsx)(`div`,{className:`px-4 py-3 border-b border-border`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(J,{className:`size-12 rounded-full shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-3 w-16`}),(0,Z.jsx)(J,{className:`h-4 w-32`})]})]})}):(0,Z.jsxs)(K,{to:i,className:`flex items-center gap-3 px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors`,children:[(0,Z.jsxs)(Qn,{className:`size-12 shrink-0`,children:[(0,Z.jsx)(Zn,{src:n?.picture,alt:r}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary`,children:(0,Z.jsx)(mt,{className:`size-5`})})]}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(mt,{className:`size-3 shrink-0`}),(0,Z.jsx)(`span`,{children:`Profile`})]}),(0,Z.jsx)(`p`,{className:`text-sm font-medium truncate mt-0.5`,children:r}),n?.nip05&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:n.nip05})]})]})}function Zd({event:e,className:t,disableHoverCards:n}){if(e.kind===0)return(0,Z.jsx)(`div`,{className:G(`rounded-xl border border-border bg-secondary/30 overflow-hidden`,t),children:(0,Z.jsx)(Xd,{pubkey:e.pubkey})});if(e.kind>=3e4&&e.kind<4e4){let r=e.tags.find(([e])=>e===`d`)?.[1]??``;return(0,Z.jsx)(Er,{addr:{kind:e.kind,pubkey:e.pubkey,identifier:r},className:t,disableHoverCards:n})}return(0,Z.jsx)(ti,{eventId:e.id,authorHint:e.pubkey,className:t,disableHoverCards:n})}function Qd({event:e,quotedEvent:t,open:n,onOpenChange:r,onSuccess:i,initialContent:a,initialMode:o,title:s,placeholder:c}){let{t:l}=Fn(),u=e instanceof URL,d=typeof e==`string`,f=u||d,p=!!e,m=!!t,[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(void 0),x=!f&&e instanceof Object&&`kind`in e&&e.kind===0,S=s??l(o===`poll`?`replyModal.title.newPoll`:f?`replyModal.title.newComment`:x?`replyModal.title.commentOnProfile`:p?`replyModal.title.replyToPost`:m?`replyModal.title.quotePost`:`replyModal.title.newPost`),C=c??l(f?`replyModal.placeholder.writeComment`:p?`compose.placeholderDefault`:m?`replyModal.placeholder.addComment`:`replyModal.placeholder.whatsHappening`),w=(0,Q.useCallback)(e=>{b(e??void 0)},[]),T=(0,Q.useCallback)(e=>{e.preventDefault()},[]);return(0,Z.jsx)(Gn,{open:n,onOpenChange:r,children:(0,Z.jsx)(Vn,{ref:w,className:`max-w-[520px] max-h-[95dvh] sm:max-h-[85dvh] rounded-2xl p-0 gap-0 border-border overflow-hidden [&>button]:hidden !flex !flex-col`,onOpenAutoFocus:e=>{e.preventDefault();let t=e.currentTarget.querySelector(`textarea`);t&&t.focus()},onInteractOutside:T,children:(0,Z.jsxs)(Di,{value:y,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12 shrink-0`,children:[(0,Z.jsx)(zn,{className:`text-base font-semibold`,children:S}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_&&(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-0.5 p-1 bg-muted/50 rounded-lg`,children:[(0,Z.jsx)(`button`,{onClick:()=>g(!1),className:G(`px-3.5 py-1.5 text-xs font-medium rounded-md transition-all`,h?`text-muted-foreground hover:text-foreground`:`bg-background text-foreground shadow-sm`),children:l(`compose.preview.edit`)}),(0,Z.jsx)(`button`,{onClick:()=>g(!0),className:G(`px-3.5 py-1.5 text-xs font-medium rounded-md transition-all`,h?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:l(`compose.preview.previewMode`)})]}),(0,Z.jsx)(`button`,{onClick:()=>r(!1),className:`p-1.5 -mr-1.5 rounded-full text-muted-foreground hover:text-foreground hover:bg-secondary/60 transition-colors`,children:(0,Z.jsx)(Ye,{className:`size-5`})})]})]}),e&&!m&&(0,Z.jsx)(`div`,{className:`overflow-y-auto max-h-[20dvh] shrink-0`,children:u?(0,Z.jsx)(`div`,{className:`mx-4 mb-2`,children:(0,Z.jsx)(qr,{url:e.href,showActions:!1,hideImage:!0})}):d?null:(0,Z.jsx)(Zd,{event:e,className:`mx-4 mb-2`,disableHoverCards:!0})}),u&&/bsky\.(app|social)/.test(e.href)&&(0,Z.jsxs)(`div`,{className:`mx-4 mb-2 rounded-lg border border-amber-500/30 bg-amber-500/5 px-3 py-2 flex items-start gap-2 shrink-0`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-relaxed shrink-0`,"aria-hidden":!0,children:`⚠️`}),(0,Z.jsx)(`p`,{className:`text-xs text-amber-700 dark:text-amber-400 leading-relaxed`,children:l(`replyModal.blueskyDisclaimer`)})]}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 flex flex-col overflow-hidden`,children:(0,Z.jsx)(Vo,{replyTo:m?void 0:e??void 0,quotedEvent:t??void 0,onSuccess:()=>{r(!1),i?.()},placeholder:C,forceExpanded:!0,hideAvatar:!0,previewMode:h,onHasPreviewableContentChange:v,initialContent:a,initialMode:o})})]})})})}function $d({pubkeys:e,parentEventId:t,parentRelayHint:n,parentAuthorHint:r,className:i}){let{t:a}=Fn(),o=e.filter(Boolean),s=o.slice(0,2),c=t?(0,Z.jsxs)(gr,{openDelay:300,closeDelay:150,children:[(0,Z.jsx)(wr,{asChild:!0,children:(0,Z.jsx)(`span`,{className:`shrink-0 cursor-pointer hover:underline`,children:a(`feed.replyContext.replyingTo`)})}),(0,Z.jsx)(yr,{side:`bottom`,align:`start`,sideOffset:4,className:`w-80 p-0 rounded-2xl shadow-lg`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(ti,{eventId:t,relays:n?[n]:void 0,authorHint:r,className:`border-0 rounded-none`,disableHoverCards:!0})})]}):(0,Z.jsx)(`span`,{className:`shrink-0`,children:a(`feed.replyContext.replyingTo`)});return(0,Z.jsxs)(`div`,{className:i||`flex items-center flex-wrap gap-x-1 text-sm text-muted-foreground mt-2 mb-1 min-w-0 overflow-hidden`,children:[c,s.map((e,t)=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 min-w-0`,children:[(0,Z.jsx)(ef,{pubkey:e}),t2&&(0,Z.jsx)(`span`,{className:`text-muted-foreground shrink-0`,children:a(`feed.replyContext.andOthers`,{count:o.length-2})})]})}function ef({pubkey:e}){let t=z(e),n=t.data?.metadata?.name||t.data?.metadata?.display_name||er(e),r=kt(e,t.data?.metadata);return t.isLoading?(0,Z.jsx)(J,{className:`h-3.5 w-20 inline-block`}):(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsxs)(K,{to:r,className:`text-primary hover:underline truncate max-w-[200px] inline-block align-bottom`,onClick:e=>e.stopPropagation(),children:[`@`,n]})})}function tf(e){let{nostr:t}=R(),{user:n}=U(),r=V().getQueryData([`user-repost`,e??``]),{data:i}=B({queryKey:[`user-repost`,e??``],queryFn:async({signal:r})=>{if(!e||!n)return null;let i=await t.query([{kinds:[6,16],authors:[n.pubkey],"#e":[e],limit:1}],{signal:r});return i.length===0?null:i[0].id},enabled:!!e&&!!n&&!r,staleTime:3e5,gcTime:6e5});return r||i}function nf(e){if(e.kind>=3e4&&e.kind<4e4){let t=e.tags.find(([e])=>e===`d`)?.[1];if(t)return H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}return e.kind>=1e4&&e.kind<2e4||rf(e.kind)?H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:``}):H.neventEncode({id:e.id,author:e.pubkey})}function rf(e){return e===0||e===3||e===41}function af({event:e,children:t}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(void 0),[l,u]=(0,Q.useState)(!0),{user:d}=U(),{mutate:f}=ln(),{mutate:p}=Du(),m=tf(e.id),h=V(),{toast:g}=sn(),{config:_}=Kt(),v=_.nip85StatsPubkey,y=[`nip85-event-stats`,e.id,v],b=!!m,x=()=>{if(!d){g({title:`Please log in to repost`,variant:`destructive`});return}Ri();let t=h.getQueryData(y);t&&h.setQueryData(y,{...t,repostCount:t.repostCount+1}),h.setQueryData([`user-repost`,e.id],`optimistic`);let n=Ol(e.kind),r=[[`e`,e.id,gn],[`p`,e.pubkey]];if(n===16&&(r.push([`k`,String(e.kind)]),e.kind>=3e4&&e.kind<4e4)){let t=e.tags.find(([e])=>e===`d`)?.[1]??``;r.push([`a`,`${e.kind}:${e.pubkey}:${t}`,gn])}f({kind:n,content:``,created_at:Math.floor(Date.now()/1e3),tags:r},{onSuccess:()=>{g({title:`Reposted!`}),i(!1),setTimeout(()=>{Oo(h,e,v),h.invalidateQueries({queryKey:[`event-interactions`,e.id]}),h.invalidateQueries({queryKey:[`user-repost`,e.id]})},3e3)},onError:()=>{g({title:`Failed to repost`,variant:`destructive`}),t&&h.setQueryData(y,t),h.setQueryData([`user-repost`,e.id],null)}})},S=()=>{if(!d||!m)return;Ri();let t=h.getQueryData(y);t&&h.setQueryData(y,{...t,repostCount:Math.max(0,t.repostCount-1)});let n=h.getQueryData([`user-repost`,e.id]);h.setQueryData([`user-repost`,e.id],null),p({eventId:m,eventKind:Ol(e.kind)},{onSuccess:()=>{g({title:`Repost removed`}),i(!1),setTimeout(()=>{Oo(h,e,v),h.invalidateQueries({queryKey:[`event-interactions`,e.id]}),h.invalidateQueries({queryKey:[`user-repost`,e.id]})},3e3)},onError:()=>{g({title:`Failed to remove repost`,variant:`destructive`}),t&&h.setQueryData(y,t),h.setQueryData([`user-repost`,e.id],n)}})},C=()=>{c(void 0),u(!0),i(!1),o(!0)},w=()=>{c(`\n\n${pn(nf(e))}`),u(!1),i(!1),o(!0)},T=(0,Z.jsxs)(`div`,{className:`w-full`,children:[b?(0,Z.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`flex items-center gap-3 w-full px-4 py-3 text-[15px] text-accent hover:bg-secondary/60 transition-colors`,children:[(0,Z.jsx)(He,{className:`size-5`}),(0,Z.jsx)(`span`,{children:`Undo repost`})]}):(0,Z.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),x()},className:`flex items-center gap-3 w-full px-4 py-3 text-[15px] text-foreground hover:bg-secondary/60 transition-colors`,children:[(0,Z.jsx)(wn,{className:`size-5`}),(0,Z.jsx)(`span`,{children:`Repost`})]}),(0,Z.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),C()},className:`flex items-center gap-3 w-full px-4 py-3 text-[15px] text-foreground hover:bg-secondary/60 transition-colors`,children:[(0,Z.jsx)(Te,{className:`size-5`}),(0,Z.jsx)(`span`,{children:`Quote`})]}),(0,Z.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w()},className:`flex items-center gap-3 w-full px-4 py-3 text-[15px] text-foreground hover:bg-secondary/60 transition-colors`,children:[(0,Z.jsx)(n,{className:`size-5`}),(0,Z.jsx)(`span`,{children:`Boost`})]})]}),E=typeof t==`function`?t(b):t;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Ai,{open:r,onOpenChange:i,children:[(0,Z.jsx)(Oi,{asChild:!0,onClick:e=>e.stopPropagation(),children:E}),(0,Z.jsx)(ki,{className:`w-48 p-0 rounded-xl overflow-hidden`,align:`start`,side:`top`,onClick:e=>e.stopPropagation(),children:T})]}),(0,Z.jsx)(Qd,{quotedEvent:l?e:void 0,open:a,onOpenChange:o,initialContent:s})]})}function of(e,t){return e.find(([e])=>e===t)?.[1]}function sf(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function cf(e){return{"android-arm64-v8a":`Android`,"android-armeabi-v7a":`Android`,"android-x86":`Android`,"android-x86_64":`Android`,"darwin-arm64":`macOS`,"darwin-x86_64":`macOS`,"linux-aarch64":`Linux`,"linux-x86_64":`Linux`,"linux-armv7l":`Linux`,"linux-riscv64":`Linux`,"windows-aarch64":`Windows`,"windows-x86_64":`Windows`,"ios-arm64":`iOS`,web:`Web`}[e]||e}function lf(e){return[...new Set(e.map(cf))]}function uf(e,t){let{nostr:n}=R();return B({queryKey:[`zapstore-release`,e,t],queryFn:async({signal:r})=>{if(!e||!t)return null;try{let i=AbortSignal.any([r,AbortSignal.timeout(5e3)]),a=await n.query([{kinds:[30063],authors:[t],"#i":[e],limit:5}],{signal:i});return a.length===0?null:a.find(e=>{let t=of(e.tags,`c`);return!t||t===`main`})||a[0]}catch{return null}},enabled:!!e&&!!t,staleTime:3e5})}function df({images:e,initialIndex:t,open:n,onOpenChange:r}){let[i,a]=(0,Q.useState)(t);(0,Q.useEffect)(()=>{n&&a(t)},[n,t]);let o=(0,Q.useCallback)(()=>a(t=>t>0?t-1:e.length-1),[e.length]),s=(0,Q.useCallback)(()=>a(t=>t{if(!n)return;let e=e=>{e.key===`ArrowLeft`?o():e.key===`ArrowRight`&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,o,s]),(0,Z.jsx)(Gn,{open:n,onOpenChange:r,children:(0,Z.jsxs)(Wn,{children:[(0,Z.jsx)(Hn,{className:`bg-black/80`}),(0,Z.jsxs)(Ln,{className:`fixed inset-0 z-[250] flex items-center justify-center focus:outline-none`,onClick:()=>r(!1),"aria-label":`Screenshot viewer`,children:[(0,Z.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r(!1)},className:`absolute top-4 right-4 z-10 rounded-full bg-black/50 p-2 text-white/80 hover:text-white transition-colors hover:bg-black/70`,"aria-label":`Close`,children:(0,Z.jsx)(Ye,{className:`size-5`})}),e.length>1&&(0,Z.jsx)(`button`,{onClick:e=>{e.stopPropagation(),o()},className:`absolute left-4 z-10 rounded-full bg-black/50 p-2 text-white/80 hover:text-white transition-colors hover:bg-black/70`,"aria-label":`Previous screenshot`,children:(0,Z.jsx)(ee,{className:`size-6`})}),(0,Z.jsx)(`img`,{src:e[i],alt:`Screenshot ${i+1} of ${e.length}`,className:`max-h-[90vh] max-w-[90vw] rounded-lg object-contain shadow-2xl select-none`,onClick:e=>e.stopPropagation(),draggable:!1}),e.length>1&&(0,Z.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s()},className:`absolute right-4 z-10 rounded-full bg-black/50 p-2 text-white/80 hover:text-white transition-colors hover:bg-black/70`,"aria-label":`Next screenshot`,children:(0,Z.jsx)(O,{className:`size-6`})}),e.length>1&&(0,Z.jsx)(`div`,{className:`absolute bottom-6 flex gap-1.5`,onClick:e=>e.stopPropagation(),children:e.map((e,t)=>(0,Z.jsx)(`button`,{onClick:()=>a(t),className:`size-2 rounded-full transition-colors ${t===i?`bg-white`:`bg-white/40 hover:bg-white/60`}`,"aria-label":`Go to screenshot ${t+1}`},t))})]})]})})}function ff({images:e,maxHeight:t,maxCount:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(0),s=n?e.slice(0,n):e;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`flex gap-2.5 overflow-x-auto pb-1.5 -mx-1 px-1 scrollbar-none`,children:s.map((e,n)=>(0,Z.jsx)(`button`,{type:`button`,className:`shrink-0 cursor-pointer rounded-xl overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-primary transition-transform hover:scale-[1.02] active:scale-[0.98]`,onClick:e=>{e.stopPropagation(),o(n),i(!0)},"aria-label":`View screenshot ${n+1}`,children:(0,Z.jsx)(`img`,{src:e,alt:``,className:`${t} rounded-xl object-cover shadow-sm`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`}})},e))}),(0,Z.jsx)(df,{images:e,initialIndex:a,open:r,onOpenChange:i})]})}function pf({event:e,compact:t}){let n=of(e.tags,`name`)||of(e.tags,`d`)||`Unknown App`,i=of(e.tags,`summary`),a=of(e.tags,`icon`),o=sf(e.tags,`image`),s=sf(e.tags,`f`),c=(0,Q.useMemo)(()=>lf(s),[s]),l=sf(e.tags,`t`),u=Y(of(e.tags,`url`)),d=Y(of(e.tags,`repository`)),f=of(e.tags,`license`),p=of(e.tags,`d`),{data:m}=uf(p,e.pubkey),h=m?of(m.tags,`version`):void 0,g=e.content;return t?(0,Z.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[a?(0,Z.jsx)(`img`,{src:a,alt:n,className:`size-12 rounded-xl object-cover shrink-0 shadow-sm`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-12 rounded-xl bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(S,{className:`size-6 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-[15px] leading-snug`,children:n}),i&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2 mt-0.5`,children:i})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[c.map(e=>(0,Z.jsx)(X,{variant:`secondary`,className:`text-xs px-2 py-0`,children:e},e)),h&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,h]}),f&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Je,{className:`size-3`}),f]})]}),o.length>0&&(0,Z.jsx)(ff,{images:o,maxHeight:`h-36`,maxCount:3}),l.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:l.slice(0,6).map(e=>(0,Z.jsxs)(K,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))})]}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[a?(0,Z.jsx)(`img`,{src:a,alt:n,className:`size-16 rounded-2xl object-cover shrink-0 shadow-md`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-16 rounded-2xl bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(S,{className:`size-8 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-xl font-bold leading-snug`,children:n}),i&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:i}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mt-2`,children:[c.map(e=>(0,Z.jsx)(X,{variant:`secondary`,className:`text-xs px-2 py-0`,children:e},e)),h&&(0,Z.jsxs)(X,{variant:`outline`,className:`text-xs px-2 py-0`,children:[`v`,h]}),f&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(Je,{className:`size-3`}),f]})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u&&(0,Z.jsx)(q,{size:`sm`,variant:`outline`,className:`gap-1.5`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(r,{className:`size-3.5`}),`Website`]})}),d&&(0,Z.jsx)(q,{size:`sm`,variant:`outline`,className:`gap-1.5`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:d,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(j,{className:`size-3.5`}),`Source`]})}),p&&(0,Z.jsx)(q,{size:`sm`,variant:`outline`,className:`gap-1.5`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:`https://zapstore.dev/apps/${encodeURIComponent(p)}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(F,{className:`size-3.5`}),`Zapstore`]})})]}),g&&(0,Z.jsx)(`p`,{className:`text-[15px] leading-relaxed whitespace-pre-wrap break-words`,children:g}),o.length>0&&(0,Z.jsx)(ff,{images:o,maxHeight:`h-52`}),m&&m.content&&(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border p-3 space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Z.jsx)(S,{className:`size-4 text-primary`}),(0,Z.jsxs)(`span`,{children:[`Release `,h]})]}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground whitespace-pre-wrap break-words line-clamp-6`,children:m.content})]}),l.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>(0,Z.jsxs)(K,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))})]})}var mf={...Ci,tagNames:[`h1`,`h2`,`h3`,`ul`,`ol`,`li`,`p`,`strong`,`em`,`code`,`br`],attributes:{}};function $(e,t){return e.find(([e])=>e===t)?.[1]}function hf(e,t){return e.filter(([e])=>e===t)}function gf(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function _f(e){return{"application/vnd.android.package-archive":`Android APK`,"application/vnd.apple.ipa":`iOS IPA`,"application/x-apple-diskimage":`macOS DMG`,"application/vnd.apple.installer+xml":`macOS PKG`,"application/x-msi":`Windows MSI`,"application/vnd.appimage":`Linux AppImage`,"application/vnd.flatpak":`Linux Flatpak`,"application/x-executable":`Linux Binary`,"application/x-mach-binary":`macOS Binary`,"application/vnd.microsoft.portable-executable":`Windows EXE`,"application/vsix":`VS Code Extension`,"application/x-chrome-extension":`Chrome Extension`,"application/x-xpinstall":`Firefox Extension`,"application/wasm":`WebAssembly`,"application/webbundle":`Web Bundle`,"application/vnd.oci.image.manifest.v1+json":`OCI Image`}[e]??e}function vf({mime:e,className:t}){return e.includes(`android`)||e.includes(`apple.ipa`)?(0,Z.jsx)(_e,{className:t}):e.includes(`apple`)||e.includes(`mach`)||e.includes(`msi`)||e.includes(`portable-executable`)||e.includes(`appimage`)||e.includes(`flatpak`)||e.includes(`executable`)?(0,Z.jsx)(N,{className:t}):e.includes(`wasm`)||e.includes(`webbundle`)||e.includes(`chrome`)||e.includes(`xpinstall`)||e.includes(`vsix`)?(0,Z.jsx)(r,{className:t}):(0,Z.jsx)(S,{className:t})}function yf(e){if(!e)return;let t=parseInt(e,10);return isNaN(t)?e:t>=1e6?`${(t/1e6).toFixed(1)} MB`:t>=1e3?`${(t/1e3).toFixed(0)} KB`:`${t} B`}function bf(e){return{"android-arm64-v8a":`ARM64`,"android-armeabi-v7a":`ARMv7`,"android-x86":`x86`,"android-x86_64":`x64`,"darwin-arm64":`Apple Silicon`,"darwin-x86_64":`Intel`,"linux-aarch64":`ARM64`,"linux-x86_64":`x64`,"linux-armv7l":`ARMv7`,"linux-riscv64":`RISC-V`,"windows-aarch64":`ARM64`,"windows-x86_64":`x64`,"ios-arm64":`ARM64`,wasm32:`WASM32`,wasm64:`WASM64`,"wasi-wasm32":`WASI`,"wasi-wasm64":`WASI64`}[e]??e}function xf({channel:e}){let t={main:`bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400`,beta:`bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400`,nightly:`bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-400`,dev:`bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-400`}[e]??`bg-muted text-muted-foreground`;return(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${t}`,children:e})}function Sf(e){let{nostr:t}=R();return B({queryKey:[`zapstore-assets`,...e.sort()],queryFn:async({signal:n})=>{if(e.length===0)return[];try{let r=AbortSignal.any([n,AbortSignal.timeout(8e3)]),i=await t.relay(hn).query([{kinds:[3063],ids:e}],{signal:r});if(i.length>0)return i;let a=AbortSignal.any([n,AbortSignal.timeout(5e3)]);return await t.query([{kinds:[3063],ids:e}],{signal:a})}catch{return[]}},enabled:e.length>0,staleTime:6e5})}function Cf(e,t){let{nostr:n}=R();return B({queryKey:[`zapstore-app-for-release`,e,t],queryFn:async({signal:r})=>{if(!e)return null;try{let i=AbortSignal.any([r,AbortSignal.timeout(5e3)]),a=await n.relay(hn).query([{kinds:[32267],authors:[t],"#d":[e],limit:1}],{signal:i});if(a.length>0)return a[0];let o=AbortSignal.any([r,AbortSignal.timeout(5e3)]),s=await n.query([{kinds:[32267],authors:[t],"#d":[e],limit:1}],{signal:o});return s.length>0?s[0]:null}catch{return null}},enabled:!!e,staleTime:3e5})}function wf({event:e}){let t=$(e.tags,`m`)??``,n=Y($(e.tags,`url`)),r=$(e.tags,`version`),i=yf($(e.tags,`size`)),a=gf(e.tags,`f`),o=$(e.tags,`variant`),s=$(e.tags,`commit`),c=$(e.tags,`x`),l=_f(t),u=a.map(bf),d=async()=>{n&&await Pi(n)};return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 py-2.5 px-3 rounded-lg hover:bg-muted/50 transition-colors group`,children:[(0,Z.jsx)(`div`,{className:`size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(vf,{mime:t,className:`size-4 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium truncate`,children:l}),o&&(0,Z.jsx)(X,{variant:`outline`,className:`text-xs px-1.5 py-0`,children:o}),u.length>0&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.join(`, `)})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 flex-wrap`,children:[r&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,Z.jsx)(E,{className:`size-3`}),r]}),i&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i}),s&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,Z.jsx)(h,{className:`size-3`}),(0,Z.jsx)(`code`,{className:`font-mono`,children:s.slice(0,7)})]}),c&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,Z.jsx)(ie,{className:`size-3`}),(0,Z.jsx)(`code`,{className:`font-mono`,children:c.slice(0,8)})]})]})]}),n&&(0,Z.jsxs)(q,{size:`sm`,variant:`ghost`,className:`gap-1.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),d()},children:[(0,Z.jsx)(Oe,{className:`size-3.5`}),`Download`]})]})}function Tf({event:e,compact:t}){let n=$(e.tags,`version`),r=$(e.tags,`c`)??`main`,i=$(e.tags,`i`),a=(0,Q.useMemo)(()=>hf(e.tags,`e`),[e.tags]),o=(0,Q.useMemo)(()=>a.map(([,e])=>e).filter(Boolean),[a]),{data:s=[],isLoading:c}=Sf(o),{data:l}=Cf(i,e.pubkey),u=l&&($(l.tags,`name`)||$(l.tags,`d`))||i,d=l?$(l.tags,`icon`):void 0,f=l?$(l.tags,`d`):i,p=l?H.naddrEncode({kind:32267,pubkey:l.pubkey,identifier:$(l.tags,`d`)??``}):void 0,m=e.content;return t?(0,Z.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d?(0,Z.jsx)(`img`,{src:d,alt:u??``,className:`size-10 rounded-xl object-cover shrink-0 shadow-sm`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-10 rounded-xl bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(S,{className:`size-5 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[u&&(p?(0,Z.jsx)(K,{to:`/${p}`,className:`font-semibold text-[15px] leading-snug hover:underline`,onClick:e=>e.stopPropagation(),children:u}):(0,Z.jsx)(`span`,{className:`font-semibold text-[15px] leading-snug`,children:u})),n&&(0,Z.jsxs)(X,{variant:`outline`,className:`text-xs px-2 py-0`,children:[`v`,n]}),(0,Z.jsx)(xf,{channel:r})]}),o.length>0&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[o.length,` `,o.length===1?`asset`:`assets`,` available`]})]})]}),m&&(0,Z.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed text-muted-foreground line-clamp-4 [&_h1]:text-sm [&_h1]:font-semibold [&_h2]:text-sm [&_h2]:font-semibold [&_h3]:text-sm [&_h3]:font-semibold [&_ul]:pl-4 [&_ul]:list-disc [&_ol]:pl-4 [&_ol]:list-decimal [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-xs [&_code]:font-mono [&_p]:my-0 [&_li]:my-0 [&_h1]:my-0 [&_h2]:my-0 [&_h3]:my-0`,children:(0,Z.jsx)(wi,{rehypePlugins:[[Ti,mf]],children:m})})]}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[d?(0,Z.jsx)(`img`,{src:d,alt:u??``,className:`size-14 rounded-2xl object-cover shrink-0 shadow-md`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-14 rounded-2xl bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(S,{className:`size-7 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[u&&(p?(0,Z.jsx)(K,{to:`/${p}`,className:`text-lg font-bold leading-snug hover:underline`,onClick:e=>e.stopPropagation(),children:u}):(0,Z.jsx)(`h2`,{className:`text-lg font-bold leading-snug`,children:u})),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mt-1.5`,children:[n&&(0,Z.jsxs)(X,{variant:`secondary`,className:`text-xs px-2 py-0`,children:[`v`,n]}),(0,Z.jsx)(xf,{channel:r})]})]})]}),f&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(q,{size:`sm`,variant:`outline`,className:`gap-1.5`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:`https://zapstore.dev/apps/${encodeURIComponent(f)}`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(F,{className:`size-3.5`}),`View on Zapstore`]})}),p&&(0,Z.jsx)(q,{size:`sm`,variant:`ghost`,className:`gap-1.5`,asChild:!0,children:(0,Z.jsxs)(K,{to:`/${p}`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(S,{className:`size-3.5`}),`App details`]})})]}),m&&(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border bg-muted/30 p-4 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:`Release Notes`}),(0,Z.jsx)(`div`,{className:`prose prose-sm dark:prose-invert max-w-none text-sm leading-relaxed [&_h1]:text-base [&_h1]:font-semibold [&_h1]:mt-3 [&_h1]:mb-1 [&_h2]:text-sm [&_h2]:font-semibold [&_h2]:mt-3 [&_h2]:mb-1 [&_h3]:text-sm [&_h3]:font-semibold [&_h3]:mt-2 [&_h3]:mb-1 [&_ul]:my-1 [&_ul]:pl-4 [&_ul]:list-disc [&_ol]:my-1 [&_ol]:pl-4 [&_ol]:list-decimal [&_li]:my-0.5 [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-xs [&_code]:font-mono [&_p]:my-1 first:[&>*]:mt-0`,children:(0,Z.jsx)(wi,{rehypePlugins:[[Ti,mf]],children:m})})]}),o.length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground px-1`,children:`Downloads`}),(0,Z.jsx)(`div`,{className:`rounded-xl border border-border overflow-hidden divide-y divide-border`,children:c?Array.from({length:Math.min(o.length,3)}).map((e,t)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,Z.jsx)(J,{className:`size-8 rounded-lg shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-3.5 w-32`}),(0,Z.jsx)(J,{className:`h-3 w-24`})]})]},t)):s.length>0?s.map(e=>(0,Z.jsx)(wf,{event:e},e.id)):o.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`size-8 rounded-lg bg-muted flex items-center justify-center shrink-0`,children:(0,Z.jsx)(S,{className:`size-4 text-muted-foreground`})}),(0,Z.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground font-mono truncate`,children:[e.slice(0,16),`…`]})})]},e))})]})]})}function Ef(){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Z.jsx)(J,{className:`size-14 rounded-2xl shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Z.jsx)(J,{className:`h-5 w-28`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(J,{className:`h-5 w-12 rounded-full`}),(0,Z.jsx)(J,{className:`h-5 w-10 rounded-full`})]})]})]}),(0,Z.jsx)(J,{className:`h-8 w-36 rounded-md`}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-4 w-full`}),(0,Z.jsx)(J,{className:`h-4 w-4/5`}),(0,Z.jsx)(J,{className:`h-4 w-3/5`})]}),(0,Z.jsx)(`div`,{className:`rounded-xl border border-border overflow-hidden divide-y divide-border`,children:[1,2].map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,Z.jsx)(J,{className:`size-8 rounded-lg shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-3.5 w-32`}),(0,Z.jsx)(J,{className:`h-3 w-20`})]})]},e))})]})}function Df({event:e,compact:t}){let n=$(e.tags,`m`)??``,r=Y($(e.tags,`url`)),i=$(e.tags,`version`),a=yf($(e.tags,`size`)),o=$(e.tags,`i`),s=gf(e.tags,`f`),c=$(e.tags,`variant`),l=$(e.tags,`commit`),u=$(e.tags,`x`),d=gf(e.tags,`supported_nip`),f=$(e.tags,`min_platform_version`),p=_f(n),m=s.map(bf),g=async()=>{r&&await Pi(r)};return t?(0,Z.jsx)(`div`,{className:`space-y-2`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(`div`,{className:`size-10 rounded-xl bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(vf,{mime:n,className:`size-5 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-[15px] leading-snug`,children:p}),c&&(0,Z.jsx)(X,{variant:`outline`,className:`text-xs px-1.5 py-0`,children:c}),i&&(0,Z.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,i]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 text-xs text-muted-foreground flex-wrap`,children:[o&&(0,Z.jsx)(`span`,{children:o}),m.length>0&&(0,Z.jsx)(`span`,{children:m.join(`, `)}),a&&(0,Z.jsx)(`span`,{children:a})]})]})]})}):(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Z.jsx)(`div`,{className:`size-14 rounded-2xl bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Z.jsx)(vf,{mime:n,className:`size-7 text-primary`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-xl font-bold leading-snug`,children:p}),o&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:o}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mt-2`,children:[i&&(0,Z.jsxs)(X,{variant:`secondary`,className:`text-xs px-2 py-0`,children:[`v`,i]}),c&&(0,Z.jsx)(X,{variant:`outline`,className:`text-xs px-2 py-0`,children:c}),m.length>0&&m.map(e=>(0,Z.jsx)(X,{variant:`outline`,className:`text-xs px-2 py-0`,children:e},e))]})]})]}),r&&(0,Z.jsxs)(q,{size:`sm`,className:`gap-1.5`,onClick:e=>{e.stopPropagation(),g()},children:[(0,Z.jsx)(Oe,{className:`size-3.5`}),`Download`]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border divide-y divide-border`,children:[a&&(0,Z.jsx)(Of,{label:`File Size`,value:a}),n&&(0,Z.jsx)(Of,{label:`MIME Type`,value:(0,Z.jsx)(`code`,{className:`text-xs font-mono`,children:n})}),u&&(0,Z.jsx)(Of,{label:`SHA-256`,value:(0,Z.jsx)(`code`,{className:`text-xs font-mono break-all`,children:u})}),l&&(0,Z.jsx)(Of,{label:`Commit`,value:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(h,{className:`size-3 shrink-0`}),(0,Z.jsx)(`code`,{className:`text-xs font-mono`,children:l})]})}),f&&(0,Z.jsx)(Of,{label:`Min Platform Version`,value:f}),d.length>0&&(0,Z.jsx)(Of,{label:`Supported NIPs`,value:(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:d.map(e=>(0,Z.jsxs)(X,{variant:`secondary`,className:`text-xs px-1.5 py-0`,children:[`NIP-`,e]},e))})})]}),gf(e.tags,`apk_certificate_hash`).length>0&&(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`APK Certificate`}),gf(e.tags,`apk_certificate_hash`).map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(Je,{className:`size-3.5 text-green-600 shrink-0`}),(0,Z.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground break-all`,children:e})]},e))]})]})}function Of({label:e,value:t}){return(0,Z.jsxs)(`div`,{className:`flex items-start gap-4 px-3 py-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground w-36 shrink-0 pt-0.5`,children:e}),(0,Z.jsx)(`span`,{className:`text-sm flex-1 min-w-0`,children:t})]})}function kf(){return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Z.jsx)(J,{className:`size-14 rounded-2xl shrink-0`}),(0,Z.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Z.jsx)(J,{className:`h-6 w-40`}),(0,Z.jsx)(J,{className:`h-4 w-32`}),(0,Z.jsx)(`div`,{className:`flex gap-2`,children:(0,Z.jsx)(J,{className:`h-5 w-14 rounded-full`})})]})]}),(0,Z.jsx)(J,{className:`h-8 w-28 rounded-md`}),(0,Z.jsx)(`div`,{className:`rounded-xl border border-border divide-y divide-border`,children:[1,2,3].map(e=>(0,Z.jsxs)(`div`,{className:`flex items-start gap-4 px-3 py-2`,children:[(0,Z.jsx)(J,{className:`h-3 w-28 mt-0.5 shrink-0`}),(0,Z.jsx)(J,{className:`h-3 w-48 flex-1`})]},e))})]})}function Af(e,t){return e.find(([e])=>e===t)?.[1]}function jf(e,t){return e.filter(([e])=>e===t).map(([,e])=>e)}function Mf(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}function Nf(e,t){let n=e.filter(([e])=>e===`web`);for(let e of n){let t=e[1];if(t)return t.replace(//g,``).replace(/\/+$/,``)}return t.website}function Pf(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function Ff(e){for(let t of e){if(t[0]!==`a`)continue;let e=t[1]?.split(`:`);if(!e||e[0]!==`30617`||e.length<3)continue;let n=e[1],r=new pl({pubkey:n,identifier:e.slice(2).join(`:`)}).toString();return`https://shakespeare.diy/clone?url=${encodeURIComponent(r)}`}}function If(e){for(let t of e){if(t[0]!==`a`)continue;let e=t[1]?.split(`:`);if(!e||e[0]!==`35128`||e.length<3)continue;let n=e[1],r=e.slice(2).join(`:`);if(!(!n||!r))return{pubkey:n,identifier:r}}}function Lf(e){return`https://${Ul(e.pubkey)}${e.identifier}.nsite.lol`}function Rf({event:e,compact:t}){let n=(0,Q.useMemo)(()=>Mf(e.content),[e.content]),r=n.name||Af(e.tags,`name`)||Af(e.tags,`d`)||`Unknown App`,i=n.about,a=Y(n.picture),o=Y(n.banner),s=Y(Nf(e.tags,n)),c=jf(e.tags,`t`),l=(0,Q.useMemo)(()=>Ff(e.tags),[e.tags]),u=(0,Q.useMemo)(()=>{let t=If(e.tags);return t?Lf(t):void 0},[e.tags]);return t?(0,Z.jsx)(`div`,{className:`mt-2`,children:(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border overflow-hidden transition-all duration-300 hover:shadow-md hover:border-primary/20`,children:[o&&(0,Z.jsx)(`div`,{className:`relative aspect-[2/1] bg-gradient-to-br from-muted/50 to-muted overflow-hidden`,children:(0,Z.jsx)(`img`,{src:o,alt:``,className:`size-full object-cover transition-transform duration-300 group-hover:scale-105`,loading:`lazy`})}),(0,Z.jsxs)(`div`,{className:`relative px-3.5 pb-3.5 space-y-2`,children:[(0,Z.jsx)(`div`,{className:o?`-mt-7`:`pt-3.5`,children:a?(0,Z.jsx)(`img`,{src:a,alt:r,className:`size-14 rounded-xl object-cover shrink-0 border-3 border-background bg-background shadow-sm`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-14 rounded-xl bg-primary/10 flex items-center justify-center shrink-0 border-3 border-background shadow-sm`,children:(0,Z.jsx)(S,{className:`size-6 text-primary`})})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-[15px] leading-snug truncate`,children:r}),s&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground mt-0.5`,children:[(0,Z.jsx)(cr,{url:s,size:12}),(0,Z.jsx)(`span`,{className:`truncate`,children:Pf(s)})]})]}),i&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:i}),c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:c.slice(0,4).map(e=>(0,Z.jsxs)(K,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u&&(0,Z.jsx)(q,{asChild:!0,size:`sm`,className:`h-7 text-xs`,children:(0,Z.jsxs)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[`Open Site`,(0,Z.jsx)(F,{className:`size-3 ml-1.5`})]})}),s&&(0,Z.jsx)(q,{asChild:!0,size:`sm`,variant:u?`secondary`:`default`,className:`h-7 text-xs`,children:(0,Z.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[`Open App`,(0,Z.jsx)(F,{className:`size-3 ml-1.5`})]})}),l&&(0,Z.jsx)(q,{asChild:!0,variant:`secondary`,size:`sm`,className:`h-7 text-xs`,children:(0,Z.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[`Fork`,(0,Z.jsx)(j,{className:`size-3 ml-1`})]})})]})]})]})}):(0,Z.jsx)(`div`,{className:`mt-3`,children:(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border overflow-hidden`,children:[o&&(0,Z.jsx)(`div`,{className:`relative aspect-[2/1] bg-gradient-to-br from-muted/50 to-muted overflow-hidden`,children:(0,Z.jsx)(`img`,{src:o,alt:``,className:`size-full object-cover`,loading:`lazy`})}),(0,Z.jsxs)(`div`,{className:`relative px-4 pb-4 space-y-3`,children:[(0,Z.jsx)(`div`,{className:G(`flex items-end justify-between`,o?`-mt-10`:`pt-4`),children:a?(0,Z.jsx)(`img`,{src:a,alt:r,className:`size-20 rounded-2xl object-cover shrink-0 border-4 border-background bg-background shadow-sm`,loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,Z.jsx)(`div`,{className:`size-20 rounded-2xl bg-primary/10 flex items-center justify-center shrink-0 border-4 border-background shadow-sm`,children:(0,Z.jsx)(S,{className:`size-8 text-primary`})})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-xl font-semibold leading-snug truncate`,children:r}),s&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground mt-0.5`,children:[(0,Z.jsx)(cr,{url:s,size:14}),(0,Z.jsx)(`span`,{className:`truncate`,children:Pf(s)})]})]}),i&&(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed`,children:i}),c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>(0,Z.jsxs)(K,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[u&&(0,Z.jsx)(q,{asChild:!0,size:`sm`,children:(0,Z.jsxs)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[`Open Site`,(0,Z.jsx)(F,{className:`size-3.5 ml-1.5`})]})}),s&&(0,Z.jsx)(q,{asChild:!0,size:`sm`,variant:u?`secondary`:`default`,children:(0,Z.jsxs)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[`Open App`,(0,Z.jsx)(F,{className:`size-3 ml-1.5`})]})}),l&&(0,Z.jsx)(q,{asChild:!0,variant:`secondary`,size:`sm`,children:(0,Z.jsxs)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:[`Fork`,(0,Z.jsx)(j,{className:`size-3.5 ml-1.5`})]})})]})]})]})})}function zf(e){for(let t of e){if(t[0]!==`imeta`)continue;let e,n;for(let r=1;r!isNaN(e)):o===`duration`&&(n=parseFloat(s),isNaN(n)&&(n=void 0))}if(e||n)return{waveform:e,duration:n}}return{}}function Bf({event:e,className:t}){let n=e.content.trim(),{waveform:r,duration:i}=(0,Q.useMemo)(()=>zf(e.tags),[e.tags]),a=z(e.pubkey).data?.metadata,o=a?.name??a?.display_name??er(e.pubkey),s=a?.picture;return!r||r.length===0?(0,Z.jsx)(ri,{src:n,avatarUrl:s,avatarFallback:o[0]?.toUpperCase()??`?`,className:t}):(0,Z.jsx)(Vf,{src:n,waveform:r,imetaDuration:i,className:t})}function Vf({src:e,waveform:t,imetaDuration:n,className:r}){let i=(0,Q.useRef)(null),a=(0,Q.useRef)(null),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(0),[u,d]=(0,Q.useState)(n??0),f=u>0?c/u:0,p=(0,Q.useMemo)(()=>{let e=Math.max(...t,1);return t.map(t=>t/e)},[t]);(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=()=>s(!0),n=()=>s(!1),r=()=>s(!1),a=()=>l(e.currentTime),o=()=>{e.duration&&isFinite(e.duration)&&d(e.duration)};return e.addEventListener(`play`,t),e.addEventListener(`pause`,n),e.addEventListener(`ended`,r),e.addEventListener(`timeupdate`,a),e.addEventListener(`durationchange`,o),e.addEventListener(`loadedmetadata`,o),()=>{e.removeEventListener(`play`,t),e.removeEventListener(`pause`,n),e.removeEventListener(`ended`,r),e.removeEventListener(`timeupdate`,a),e.removeEventListener(`durationchange`,o),e.removeEventListener(`loadedmetadata`,o)}},[]),(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=new IntersectionObserver(([t])=>{!t.isIntersecting&&!e.paused&&e.pause()},{threshold:.1});return a.current&&t.observe(a.current),()=>t.disconnect()},[]);let m=(0,Q.useCallback)(e=>{e.stopPropagation();let t=i.current;t&&(t.paused?t.play():t.pause())},[]),h=(0,Q.useCallback)(e=>{e.stopPropagation();let t=i.current,n=a.current;if(!t||!n||!u)return;let r=n.getBoundingClientRect();t.currentTime=Math.max(0,Math.min(1,(e.clientX-r.left)/r.width))*u},[u]);return(0,Z.jsxs)(`div`,{className:G(`mt-3 rounded-2xl border border-border bg-muted/30 p-3 flex items-center gap-3`,r),onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`audio`,{ref:i,preload:`metadata`,className:`hidden`,children:(0,Z.jsx)(`source`,{src:e})}),(0,Z.jsx)(`button`,{onClick:m,className:G(`shrink-0 size-10 rounded-full flex items-center justify-center transition-colors`,o?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary hover:bg-primary/25`),"aria-label":o?`Pause`:`Play`,children:o?(0,Z.jsx)(Ve,{className:`size-4`,fill:`currentColor`}):(0,Z.jsx)(pt,{className:`size-4 ml-0.5`,fill:`currentColor`})}),(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[(0,Z.jsx)(`div`,{ref:a,className:`flex items-end gap-[2px] h-8 cursor-pointer`,onClick:h,children:p.map((e,t)=>{let n=t/p.length0?zr(u):`--:--`})]})]})]})}var Hf=new Set;function Uf(e){Hf.add(e),window.dispatchEvent(new CustomEvent(`bitcoin-signer-unsupported`,{detail:e}))}function Wf(){let{user:e}=U(),{logins:t}=xt(),n=t[0]?.type,[r,i]=(0,Q.useState)(()=>{if(n!==`extension`)return`unknown`;let e=globalThis.nostr;return e&&typeof e.signPsbt==`function`?`supported`:e?`unsupported`:`unknown`});(0,Q.useEffect)(()=>{if(n!==`extension`)return;let e=!1,t=()=>{let e=globalThis.nostr;return e?(i(typeof e.signPsbt==`function`?`supported`:`unsupported`),!0):!1};if(t())return;let r=setInterval(()=>{e||t()&&clearInterval(r)},250),a=setTimeout(()=>clearInterval(r),3e3);return()=>{e=!0,clearInterval(r),clearTimeout(a)}},[n]);let[a,o]=(0,Q.useState)(()=>e?Hf.has(e.pubkey):!1);(0,Q.useEffect)(()=>{if(!e){o(!1),Hf.clear();return}o(Hf.has(e.pubkey))},[e?.pubkey]),(0,Q.useEffect)(()=>{if(n!==`bunker`||!e)return;let t=t=>{t.detail===e.pubkey&&o(!0)},r=t=>{let n=t.detail;(n===`*`||n===e.pubkey)&&o(!1)};return window.addEventListener(`bitcoin-signer-unsupported`,t),window.addEventListener(`bitcoin-signer-cleared`,r),()=>{window.removeEventListener(`bitcoin-signer-unsupported`,t),window.removeEventListener(`bitcoin-signer-cleared`,r)}},[n,e]);let s=(0,Q.useMemo)(()=>{if(!e)return`unsupported`;switch(n){case`nsec`:return`supported`;case`extension`:return r;case`bunker`:return a?`unsupported`:`unknown`;default:return tn(e.signer)?`unknown`:`unsupported`}},[e,n,r,a]),c=(0,Q.useMemo)(()=>!e||s===`unsupported`?null:tn(e.signer)?e.signer:null,[e,s]);return{capability:s,canSignPsbt:s!==`unsupported`&&c!==null,signPsbt:c?e=>c.signPsbt(e):null}}function Gf(e){if(!e)return!1;let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`does not support`)||t.includes(`doesn't support`)||t.includes(`signpsbt`)||t.includes(`sign_psbt`)}function Kf(e,t){switch(t){case`fastest`:return e.fastestFee;case`halfHour`:return e.halfHourFee;case`hour`:return e.hourFee;case`economy`:return e.economyFee}}function qf(e,t){let{user:n}=U(),{canSignPsbt:r,signPsbt:i}=Wf(),{mutateAsync:a}=ln(),{toast:o}=sn(),{config:s}=Kt(),{esploraApis:c}=s,l=V(),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(`idle`),m=Lt({mutationFn:async({amountSats:t,comment:o=``,feeSpeed:s=`halfHour`})=>{if(!n)throw Error(`You must be logged in to zap.`);if(n.pubkey===e.pubkey)throw Error(`You can't zap yourself.`);if(!r||!i)throw Error(`Your login doesn't support sending Bitcoin. Log in with your secret key to send Bitcoin zaps.`);if(!Number.isFinite(t)||t<=0)throw Error(`Invalid amount.`);d(!0),p(`building`);let l=Zt(n.pubkey),u=Zt(e.pubkey);if(!l||!u)throw Error(`Failed to derive Bitcoin address.`);let[f,m]=await Promise.all([an(l,c),en(c)]);if(f.length===0)throw Error(`Your Bitcoin wallet has no spendable funds.`);let h=Kf(m,s),g=f.reduce((e,t)=>e+t.value,0),_=qt(f.length,2,h);if(t+_>g)throw Error(`Insufficient funds. Need ~${(t+_).toLocaleString()} sats, have ${g.toLocaleString()}.`);let{psbtHex:v,fee:y}=$t(n.pubkey,u,t,f,h);p(`signing`);let b=await i(v),x=Yt(b);p(`broadcasting`);let S=await rn(x,c);p(`publishing`);let C=e.kind>=3e4&&e.kind<4e4,w=[[`i`,`bitcoin:tx:${S}`],[`p`,e.pubkey],[`amount`,String(t)]];if(C){let t=e.tags.find(([e])=>e===`d`)?.[1]??``;w.push([`a`,`${e.kind}:${e.pubkey}:${t}`])}return w.push([`e`,e.id]),w.push([`alt`,`Bitcoin zap: ${t.toLocaleString()} sats`]),{txid:S,amountSats:t,fee:y,event:await a({kind:8333,content:o,tags:Mi(w)})}},onSuccess:n=>{Li(),l.setQueryData([`user-zap`,e.id],!0),l.invalidateQueries({queryKey:[`onchain-zaps`]}),l.invalidateQueries({queryKey:[`event-interactions`]}),l.invalidateQueries({queryKey:[`bitcoin-utxos`]}),l.invalidateQueries({queryKey:[`bitcoin-balance`]}),l.invalidateQueries({queryKey:[`bitcoin-txs`]}),t?t(n):o({title:`Bitcoin zap sent!`,description:`Broadcast txid ${n.txid.slice(0,12)}… (fee ${n.fee.toLocaleString()} sats)`})},onError:e=>{if(Gf(e)&&n){Uf(n.pubkey);return}o({title:`Bitcoin zap failed`,description:e.message,variant:`destructive`})},onSettled:()=>{d(!1),p(`idle`)}});return{zap:m.mutate,zapAsync:m.mutateAsync,isZapping:u,progress:f,canZap:!!n&&n.pubkey!==e.pubkey&&r,canSignPsbt:r}}var Jf=[1,5,10,25,100],Yf={fastest:`~10 min`,halfHour:`~30 min`,hour:`~1 hour`,economy:`~1 day`};function Xf({target:e,onSuccess:t,onClose:n}){let{user:r}=U(),{capability:i}=Wf(),{logins:a}=xt(),{config:o}=Kt(),{esploraApis:s}=o,c=a[0]?.type,[l,u]=(0,Q.useState)(5),[d,f]=(0,Q.useState)(`halfHour`),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),_=(0,Q.useRef)(!1),v=r?Zt(r.pubkey):``,y=(0,Q.useMemo)(()=>Zt(e.pubkey),[e.pubkey]),b=y?`${y.slice(0,10)}…${y.slice(-8)}`:``,{data:x}=B({queryKey:[`btc-price`,s],queryFn:({signal:e})=>Jt(s,e),staleTime:3e4}),{data:S}=B({queryKey:[`bitcoin-utxos`,s,v],queryFn:({signal:e})=>an(v,s,e),enabled:!!v&&i!==`unsupported`,staleTime:3e4}),{data:C}=B({queryKey:[`bitcoin-fee-rates`,s],queryFn:({signal:e})=>en(s,e),enabled:i!==`unsupported`,staleTime:3e4}),w=(0,Q.useMemo)(()=>S?.reduce((e,t)=>e+t.value,0)??0,[S]),T=(0,Q.useMemo)(()=>C?Sa(C,d):0,[C,d]),E=(0,Q.useMemo)(()=>{if(!x)return 0;let e=typeof l==`string`?parseFloat(l):l;if(!Number.isFinite(e)||e<=0)return 0;let t=e/x;return Math.round(t*1e8)},[l,x]),D=(0,Q.useMemo)(()=>{if(!S?.length||!E||!Number.isFinite(T)||T<1)return 0;let e=qt(S.length,2,T),t=w-E-e>546?2:1;return qt(S.length,t,T)},[S,T,E,w]),O=E+D,k=w>0&&O>w,A=k||E>0&&w===0;(0,Q.useEffect)(()=>{if(_.current||!S?.length||!C||E<=0)return;let e=ya(C),t=E*.4,n=e[e.length-1];for(let r of e){let e=Sa(C,r);if(!Number.isFinite(e)||e<1)continue;let i=qt(S.length,2,e),a=w-E-i>546?2:1;if(qt(S.length,a,e)<=t){n=r;break}}f(e=>e===n?e:n)},[E,C,S,w]);let ee=(0,Q.useCallback)(e=>{_.current=!0,f(e),g(!1)},[]),te=Qt(O,x),[ne,re]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{re(!1)},[E,T,x]);let{zapAsync:ie,isZapping:ae,progress:oe}=qf(e,e=>{t?.({txid:e.txid,amountSats:e.amountSats})}),se=(0,Q.useCallback)(async()=>{if(m(``),!r){m(`You must be logged in.`);return}if(r.pubkey===e.pubkey){m(`You can't zap yourself.`);return}if(!x){m(`Waiting for BTC price…`);return}if(E<=0){m(`Enter an amount.`);return}if(!S?.length){m(`You don't have any Bitcoin yet. Receive some first.`);return}if(k){m(`Not enough Bitcoin for this amount + network fee.`);return}if(te&&!ne){re(!0);return}try{await ie({amountSats:E,comment:``,feeSpeed:d})}catch(e){let t=e instanceof Error?e.message:`Zap failed`;/does not support|doesn't support|signpsbt|sign_psbt/i.test(t)||m(t)}},[r,e.pubkey,x,E,S,k,ie,d,te,ne]),ce=typeof l==`string`?parseFloat(l):l,le=Number.isFinite(ce)&&ce>0,ue=x?on(O,x):``,j=(0,Q.useMemo)(()=>ya(C),[C]);return r&&i===`unsupported`?(0,Z.jsx)(Qf,{recipientAddress:y,truncatedRecipient:b,amountSats:E,btcPrice:x,usdAmount:l,setUsdAmount:u,loginType:c,onClose:n}):(0,Z.jsxs)(`div`,{className:`grid gap-4 px-4 py-4 w-full overflow-hidden`,children:[(0,Z.jsx)(va,{usdAmount:l,onUsdAmountChange:u,presets:Jf,insufficient:k,onAmountChangeStart:()=>m(``)}),p&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:p}),(0,Z.jsx)(q,{onClick:se,disabled:!x||E<=0||ae||k,variant:(k||te)&&!ae?`destructive`:`default`,className:`w-full`,children:ae?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Xe,{className:`size-4 mr-1.5 animate-spin`}),Zf(oe)]}):k?(0,Z.jsx)(Z.Fragment,{children:`Not enough Bitcoin`}):te&&ne?(0,Z.jsxs)(Z.Fragment,{children:[`Tap again to send `,ue]}):(0,Z.jsxs)(Z.Fragment,{children:[`Send `,ue||(le?`$${ce}`:``)]})}),E>0&&(0,Z.jsxs)(`div`,{className:`flex items-center justify-center gap-3 -mt-1 text-xs`,children:[(0,Z.jsxs)(Ai,{open:h,onOpenChange:g,children:[(0,Z.jsx)(Oi,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors`,children:(0,Z.jsxs)(`span`,{children:[`Fee`,` `,D>0&&x?`≈ ${on(D,x)}`:T?`${T} sat/vB`:`loading`,(0,Z.jsxs)(`span`,{className:`opacity-60`,children:[` · `,Yf[d]]})]})})}),(0,Z.jsx)(ki,{align:`center`,sideOffset:6,className:`w-56 p-1`,children:(0,Z.jsx)(`div`,{className:`flex flex-col`,children:j.map(e=>{let t=C?Sa(C,e):0;return(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>ee(e),className:`flex items-center justify-between px-2 py-1.5 rounded-sm text-xs text-left hover:bg-muted transition-colors ${e===d?`bg-muted font-medium`:``}`,children:[(0,Z.jsx)(`span`,{children:Yf[e]}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[t,` sat/vB`]})]},e)})})})]}),A&&!k&&x&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Balance: `,on(w,x)]})]})]})}function Zf(e){switch(e){case`building`:return`Building…`;case`signing`:return`Signing…`;case`broadcasting`:return`Broadcasting…`;case`publishing`:return`Publishing…`;default:return`Processing…`}}function Qf({recipientAddress:e,truncatedRecipient:t,amountSats:n,btcPrice:r,usdAmount:i,setUsdAmount:a,loginType:o,onClose:s}){let{toast:c}=sn(),[l,u]=(0,Q.useState)(null),d=(0,Q.useMemo)(()=>e?n<=0?`bitcoin:${e}`:`bitcoin:${e}?amount=${(n/1e8).toFixed(8)}`:``,[e,n]),p=o===`extension`?`Your browser extension can't sign Bitcoin transactions.`:o===`bunker`?`Your remote signer can't sign Bitcoin transactions.`:`Your signer can't sign Bitcoin transactions.`,m=(0,Q.useCallback)(async(e,t,n)=>{try{await navigator.clipboard.writeText(e),u(t),c({title:`Copied`,description:`${n} copied to clipboard`}),setTimeout(()=>u(null),2e3)}catch{c({title:`Copy failed`,description:`Please copy manually.`,variant:`destructive`})}},[c]),h=typeof i==`string`?parseFloat(i):i,g=n>0;return(0,Z.jsxs)(`div`,{className:`grid gap-3 px-4 py-4 w-full overflow-hidden`,children:[(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[p,` You can still zap by scanning this QR from any Bitcoin wallet.`]}),(0,Z.jsx)(_a,{type:`single`,value:Jf.includes(Number(i))?String(i):``,onValueChange:e=>{e&&a(Number(e))},className:`grid grid-cols-5 gap-1 w-full`,children:Jf.map(e=>(0,Z.jsxs)(ba,{value:String(e),className:`h-8 min-w-0 text-xs font-semibold px-1`,children:[`$`,e]},e))}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`h-px flex-1 bg-muted`}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`OR`}),(0,Z.jsx)(`div`,{className:`h-px flex-1 bg-muted`})]}),(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground`,children:`$`}),(0,Z.jsx)(In,{type:`number`,inputMode:`decimal`,min:0,step:`0.01`,placeholder:`Custom amount (USD)`,value:i,onChange:e=>a(e.target.value),className:`pl-6`})]}),(0,Z.jsx)(`div`,{className:`flex justify-center`,children:g&&d?(0,Z.jsx)(`div`,{className:`bg-white p-3 rounded-xl`,"aria-label":`Bitcoin payment QR code`,children:(0,Z.jsx)(Kn,{value:d,size:220,level:`M`,className:`block`})}):(0,Z.jsx)(`div`,{className:`size-[220px] rounded-xl border border-dashed flex items-center justify-center text-xs text-muted-foreground text-center px-4`,children:r?`Choose an amount above to generate a payment QR.`:`Loading BTC price…`})}),g&&r&&(0,Z.jsxs)(`div`,{className:`text-center text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:h>0?`$${h}`:``}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,nn(n),` sats`]})]}),e&&(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-muted-foreground`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(P,{className:`size-3.5 text-orange-500 shrink-0`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`To:`}),(0,Z.jsx)(`span`,{className:`font-mono truncate`,title:e,children:t})]})}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,Z.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(e,`address`,`Address`),disabled:!e,className:`text-xs`,children:[l===`address`?(0,Z.jsx)(f,{className:`size-3.5 mr-1.5`}):(0,Z.jsx)(Pe,{className:`size-3.5 mr-1.5`}),`Copy address`]}),(0,Z.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(d,`uri`,`Payment link`),disabled:!g||!d,className:`text-xs`,children:[l===`uri`?(0,Z.jsx)(f,{className:`size-3.5 mr-1.5`}):(0,Z.jsx)(Pe,{className:`size-3.5 mr-1.5`}),`Copy link`]})]}),(0,Z.jsxs)(eo,{children:[(0,Z.jsx)(Be,{className:`size-4`}),(0,Z.jsx)($a,{className:`text-xs`,children:`Because we can't see your transaction, this zap won't show up as yours on Nostr. The recipient will still get the Bitcoin.`})]}),s&&(0,Z.jsx)(q,{type:`button`,variant:`secondary`,onClick:s,className:`w-full`,children:`Done`})]})}function $f({recipientPubkey:e,amountSats:t,btcPrice:n,txid:r,onClose:i}){let{data:a}=z(e),o=a?.metadata,s=o?.name||o?.display_name||er(e),c=Yn(o),l=(0,Q.useMemo)(()=>n?on(t,n):``,[t,n]),u=(0,Q.useMemo)(()=>Array.from({length:8},(e,t)=>{let n=t/8*Math.PI*2;return{id:t,x:Math.cos(n)*58,y:Math.sin(n)*58,delay:.15+t%4*.05,hue:t%2==0?`bg-amber-400`:`bg-orange-500`}}),[]);return(0,Z.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`relative grid gap-5 px-6 py-8 w-full overflow-hidden text-center motion-safe:animate-success-fade-up`,children:[(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 -z-10 bg-[radial-gradient(circle_at_50%_35%,hsl(var(--primary)/0.18),transparent_65%)]`}),(0,Z.jsxs)(`div`,{className:`relative mx-auto flex size-28 items-center justify-center`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0 rounded-full bg-gradient-to-br from-amber-400/40 to-orange-500/30 motion-safe:animate-success-halo`}),(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0 rounded-full bg-gradient-to-br from-amber-400 to-orange-500 shadow-lg shadow-orange-500/30 motion-safe:animate-success-pop`}),(0,Z.jsx)(f,{className:`relative size-14 text-white drop-shadow-sm motion-safe:animate-success-pop`,strokeWidth:3,"aria-hidden":!0}),(0,Z.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 motion-reduce:hidden`,children:u.map(e=>(0,Z.jsx)(`span`,{className:`absolute left-1/2 top-1/2 size-1.5 rounded-full ${e.hue} motion-safe:animate-success-spark`,style:{"--spark-x":`${e.x}px`,"--spark-y":`${e.y}px`,animationDelay:`${e.delay}s`}},e.id))})]}),(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:`Bitcoin sent`}),(0,Z.jsx)(`div`,{className:`text-4xl font-bold tabular-nums bg-gradient-to-br from-amber-500 to-orange-600 bg-clip-text text-transparent`,children:l||`${t.toLocaleString()} sats`})]}),(0,Z.jsxs)(`div`,{className:`mx-auto flex items-center gap-3 rounded-full border border-border/70 bg-muted/40 pl-2 pr-4 py-2 max-w-full`,children:[(0,Z.jsxs)(Qn,{shape:c,className:`size-8 shrink-0`,children:[(0,Z.jsx)(Zn,{src:o?.picture,alt:s}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary text-xs`,children:s[0]?.toUpperCase()})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-tight`,children:`To`}),(0,Z.jsx)(`div`,{className:`text-sm font-medium truncate max-w-[220px]`,children:s})]})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[r&&(0,Z.jsx)(q,{type:`button`,variant:`outline`,asChild:!0,className:`w-full`,children:(0,Z.jsxs)(K,{to:`/i/bitcoin:tx:${r}`,onClick:i,children:[(0,Z.jsx)(F,{className:`size-4 mr-2`}),`View transaction`]})}),(0,Z.jsx)(q,{type:`button`,onClick:i,className:`w-full`,children:`Done`})]})]})}function ep({lud06:e,lud16:t}){let n;if(e?.trim()){let{words:t}=Ft.decode(e.trim().toLowerCase(),!1);n=new TextDecoder().decode(Ft.fromWords(t))}else if(t?.trim()){let[e,r]=t.trim().split(`@`);if(!e||!r)return null;n=new URL(`/.well-known/lnurlp/${encodeURIComponent(e)}`,`https://${r}`).toString()}else return null;let r=new URL(n);if(r.protocol!==`https:`)throw Error(`Lightning address must use HTTPS`);return r.toString()}function tp(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.floor(e):null}async function np(e,t){let n=ep(e);if(!n)throw Error(`No lightning address configured`);let r=await fetch(n,{signal:t});if(!r.ok)throw Error(`Lightning service returned HTTP ${r.status}`);let i=await r.json();if(typeof i.reason==`string`&&!i.callback)throw Error(i.reason);if(i.tag!==`payRequest`)throw Error(`Lightning address does not support payments`);if(typeof i.callback!=`string`)throw Error(`Lightning service returned no payment callback`);let a=new URL(i.callback);if(a.protocol!==`https:`)throw Error(`Lightning service requested an insecure payment callback`);let o=tp(i.minSendable),s=tp(i.maxSendable);if(o===null||s===null||o>s)throw Error(`Lightning service returned invalid payment limits`);return{callback:a.toString(),minSendable:o,maxSendable:s,metadata:typeof i.metadata==`string`?i.metadata:``,allowsNostr:i.allowsNostr===!0,nostrPubkey:typeof i.nostrPubkey==`string`?i.nostrPubkey:void 0}}function rp(e,t,n,r){let{toast:i}=sn(),{user:a}=U(),{config:o}=Kt(),s=V(),c=z(e?.pubkey),{sendPayment:l,getActiveConnection:u}=Mn(),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>()=>{f(!1),m(null)},[]),{zap:async(n,d)=>{if(!(n<=0)){if(f(!0),m(null),!a){i({title:`Login required`,description:`You must be logged in to send a zap.`,variant:`destructive`}),f(!1);return}if(!e){i({title:`Event not found`,description:`Could not find the event to zap.`,variant:`destructive`}),f(!1);return}try{if(!c.data||!c.data?.metadata||!c.data?.event){i({title:`Author not found`,description:`Could not find the author of this item.`,variant:`destructive`}),f(!1);return}let{lud06:p,lud16:h}=c.data.metadata;if(!p&&!h){i({title:`Lightning address not found`,description:`The author does not have a lightning address configured.`,variant:`destructive`}),f(!1);return}let g;try{g=await np({lud06:p,lud16:h})}catch(e){i({title:`Zap endpoint not found`,description:e instanceof Error?e.message:`Could not find a zap endpoint for the author.`,variant:`destructive`}),f(!1);return}if(!g.allowsNostr||!g.nostrPubkey){i({title:`Zaps not supported`,description:`This author's lightning address does not support zaps.`,variant:`destructive`}),f(!1);return}let _=e.kind>=3e4&&e.kind<4e4?e:e.id,v=n*1e3;if(vg.maxSendable){i({title:`Amount out of range`,description:`This lightning address accepts between ${Math.ceil(g.minSendable/1e3)} and ${Math.floor(g.maxSendable/1e3)} sats.`,variant:`destructive`}),f(!1);return}let y=Pt.makeZapRequest({profile:e.pubkey,event:_,amount:v,relays:o.relayMetadata.relays.map(e=>e.url),comment:d});if(!a.signer)throw Error(`No signer available`);let b=await a.signer.signEvent(y),x=JSON.stringify(b);try{let n=new URL(g.callback);n.searchParams.set(`amount`,String(v)),n.searchParams.set(`nostr`,x);let a=await fetch(n.toString()),o=await a.text(),c={};try{c=o?JSON.parse(o):{}}catch(e){console.warn(`Failed to parse zap callback response as JSON`,e)}if(!a.ok){let e=o.trim()||`Unknown error`;throw Error(`HTTP ${a.status}: ${c.reason||e}`)}let d=c.pr;if(!d||typeof d!=`string`)throw Error(`Lightning service did not return a valid invoice`);let p=Dn(d,v);if(!kn(p,[x,g.metadata]))throw Error(`Lightning service returned an invoice for a different request. Payment cancelled.`);let h=Math.round(p.amountMsat/1e3),_=u();if(_&&_.connectionString&&_.isConnected)try{await l(_,d,v),f(!1),m(null),Li(),s.setQueryData([`user-zap`,e.id],!0),s.invalidateQueries({queryKey:[`zaps`]}),r?r({amountSats:h}):i({title:`Zap successful!`,description:`You sent ${h} sats via NWC to the author.`});return}catch(e){console.error(`NWC payment failed, falling back:`,e);let t=e instanceof Error?e.message:`Unknown NWC error`;i({title:`NWC payment failed`,description:`${t}. Falling back to other payment methods...`,variant:`destructive`})}if(t)try{let n=t;if(t.enable&&typeof t.enable==`function`){let e=await t.enable();e&&(n=e)}await n.sendPayment(d),f(!1),m(null),Li(),s.setQueryData([`user-zap`,e.id],!0),s.invalidateQueries({queryKey:[`zaps`]}),r?r({amountSats:h}):i({title:`Zap successful!`,description:`You sent ${h} sats to the author.`})}catch(e){console.error(`WebLN payment failed, falling back:`,e);let t=e instanceof Error?e.message:`Unknown WebLN error`;i({title:`WebLN payment failed`,description:`${t}. Falling back to other payment methods...`,variant:`destructive`}),m(d),f(!1)}else m(d),f(!1)}catch(e){console.error(`Zap error:`,e),i({title:`Zap failed`,description:e.message,variant:`destructive`}),f(!1)}}catch(e){console.error(`Zap error:`,e),i({title:`Zap failed`,description:e.message,variant:`destructive`}),f(!1)}}},isZapping:d,invoice:p,setInvoice:m,resetInvoice:(0,Q.useCallback)(()=>{m(null)},[])}}function ip(e){return e?!!(e.lud16||e.lud06):!1}var ap=[.1,.5,1,2,5];function op(e){return e<1?`$${e.toFixed(2)}`:`$${e}`}var sp=(0,Q.forwardRef)(({invoice:e,usdAmount:t,amountSats:n,btcPrice:r,isZapping:i,copied:a,webln:o,insufficient:s,isLarge:c,confirmArmed:l,error:u,handleZap:d,handleCopy:p,openInWallet:m,setUsdAmount:h,setError:g,editingAmount:_,setEditingAmount:v,amountInputRef:y,commitAmountEdit:b,payWithWebLN:x},S)=>{let C=typeof t==`string`?parseFloat(t):t,w=Number.isFinite(C)&&C>0,T=r&&n>0?on(n,r):``,E=w?C<1?`$${C.toFixed(2)}`:`$${C}`:``,D=T||E;return e?(0,Z.jsxs)(`div`,{ref:S,className:`grid gap-3 px-4 py-4 w-full overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col items-center pt-1`,children:(0,Z.jsx)(`div`,{className:`text-3xl font-semibold tabular-nums`,children:D})}),(0,Z.jsx)(`div`,{className:`flex justify-center`,children:(0,Z.jsx)(`div`,{className:`bg-white p-3 rounded-xl`,"aria-label":`Lightning invoice QR code`,children:(0,Z.jsx)(Kn,{value:e.toUpperCase(),size:220,level:`M`,className:`block`})})}),(0,Z.jsxs)(`div`,{className:`flex gap-2 min-w-0`,children:[(0,Z.jsx)(In,{id:`invoice`,value:e,readOnly:!0,"aria-label":`Lightning invoice`,className:`font-mono text-xs min-w-0 flex-1 overflow-hidden text-ellipsis`,onClick:e=>e.currentTarget.select()}),(0,Z.jsx)(q,{type:`button`,variant:`outline`,size:`icon`,onClick:p,className:`shrink-0`,"aria-label":`Copy invoice`,children:a?(0,Z.jsx)(f,{className:`h-4 w-4 text-green-600`}):(0,Z.jsx)(Pe,{className:`h-4 w-4`})})]}),(0,Z.jsxs)(`div`,{className:`grid gap-2`,children:[o&&(0,Z.jsx)(q,{type:`button`,onClick:x,disabled:i,className:`w-full`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Xe,{className:`size-4 mr-1.5 animate-spin`}),`Processing…`]}):`Pay with WebLN`}),(0,Z.jsxs)(q,{type:`button`,variant:o?`outline`:`default`,onClick:m,className:`w-full`,children:[(0,Z.jsx)(F,{className:`h-4 w-4 mr-2`}),`Open in Lightning Wallet`]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground text-center`,children:`Scan the QR or copy the invoice to pay with any Lightning wallet.`})]}):(0,Z.jsxs)(`div`,{ref:S,className:`grid gap-3 px-4 py-4 w-full overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col items-center pt-2`,children:_?(0,Z.jsxs)(`div`,{className:`flex items-baseline justify-center`,children:[(0,Z.jsx)(`span`,{className:`text-4xl font-semibold ${s?`text-destructive`:`text-muted-foreground`}`,children:`$`}),(0,Z.jsx)(`input`,{ref:y,type:`number`,inputMode:`decimal`,min:0,step:`0.01`,value:t,onChange:e=>{h(e.target.value),g(``)},onBlur:b,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())},"aria-label":`Amount in USD`,className:`bg-transparent border-0 outline-none text-4xl font-semibold text-center [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none ${s?`text-destructive`:``}`,style:{width:`${Math.max(2,String(t).length+1)}ch`}})]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>v(!0),"aria-label":`Edit amount`,className:`flex items-baseline justify-center rounded-md px-2 -mx-2 hover:bg-muted/50 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors`,children:[(0,Z.jsx)(`span`,{className:`text-4xl font-semibold ${s?`text-destructive`:`text-muted-foreground`}`,children:`$`}),(0,Z.jsx)(`span`,{className:`text-4xl font-semibold tabular-nums ${s?`text-destructive`:``}`,children:w?C<1?C.toFixed(2):C:0})]})}),(0,Z.jsx)(_a,{type:`single`,value:ap.includes(Number(t))?String(t):``,onValueChange:e=>{e&&(h(Number(e)),g(``),v(!1))},className:`grid grid-cols-5 gap-1 w-full`,children:ap.map(e=>(0,Z.jsx)(ba,{value:String(e),className:`h-8 min-w-0 text-xs font-semibold px-1`,children:op(e)},e))}),u&&(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:u}),(0,Z.jsx)(q,{type:`button`,onClick:d,disabled:!r||n<=0||i,variant:c&&!i?`destructive`:`default`,className:`w-full`,children:i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Xe,{className:`size-4 mr-1.5 animate-spin`}),`Creating invoice…`]}):c&&l?(0,Z.jsxs)(Z.Fragment,{children:[`Tap again to send `,D]}):(0,Z.jsxs)(Z.Fragment,{children:[`Send `,D]})})]})});sp.displayName=`LightningZapContent`;function cp({target:e,children:t,className:n}){let[r,i]=(0,Q.useState)(!1),{user:a}=U(),{data:o}=z(e.pubkey),{toast:s}=sn(),{webln:c,activeNWC:l}=Nn(),{config:u}=Kt(),{esploraApis:d}=u,[f,p]=(0,Q.useState)(null),{zap:m,isZapping:h,invoice:g,setInvoice:_}=rp(e,c,l,(0,Q.useCallback)(({amountSats:e})=>{p({kind:`lightning`,amountSats:e})},[])),[v,y]=(0,Q.useState)(.5),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(!1),O=(0,Q.useRef)(null),{data:k}=B({queryKey:[`btc-price`,d],queryFn:({signal:e})=>Jt(d,e),staleTime:3e4}),A=(0,Q.useMemo)(()=>{if(!k)return 0;let e=typeof v==`string`?parseFloat(v):v;if(!Number.isFinite(e)||e<=0)return 0;let t=e/k;return Math.round(t*1e8)},[v,k]),ee=Qt(A,k),{capability:te}=Wf(),ne=ip(o?.metadata),re=te===`unsupported`,[ie,ae]=(0,Q.useState)(re&&ne?`lightning`:`onchain`);(0,Q.useEffect)(()=>{D(!1)},[A]),(0,Q.useEffect)(()=>{S&&(O.current?.focus(),O.current?.select())},[S]);let oe=(0,Q.useCallback)(()=>{C(!1),typeof v==`string`&&v.trim()===``&&y(0)},[v]),se=async()=>{g&&(await navigator.clipboard.writeText(g),x(!0),s({title:`Invoice copied`,description:`Lightning invoice copied to clipboard`}),setTimeout(()=>x(!1),2e3))},ce=()=>{g&&Pi(`lightning:${g}`)};(0,Q.useEffect)(()=>{r?(y(.5),_(null),x(!1),C(!1),T(``),D(!1),p(null),ae(re&&ne?`lightning`:`onchain`)):(y(.5),_(null),x(!1),C(!1),T(``),D(!1),p(null))},[r,_]);let le={invoice:g,usdAmount:v,amountSats:A,btcPrice:k,isZapping:h,copied:b,webln:c,insufficient:!1,isLarge:ee,confirmArmed:E,error:w,handleZap:()=>{if(T(``),!k){T(`Waiting for BTC price…`);return}if(A<=0){T(`Enter an amount.`);return}if(ee&&!E){D(!0);return}Ii(),m(A,``)},handleCopy:se,openInWallet:ce,setUsdAmount:y,setError:T,editingAmount:S,setEditingAmount:C,amountInputRef:O,commitAmountEdit:oe,payWithWebLN:()=>{A>0&&m(A,``)}};return a?a.pubkey===e.pubkey?(0,Z.jsx)(`div`,{className:`cursor-pointer ${n||``}`,onClick:e=>{e.stopPropagation(),s({title:`Self-zaps are not supported`,description:`You cannot zap your own post.`})},children:t}):(0,Z.jsxs)(Gn,{open:r,onOpenChange:i,children:[(0,Z.jsx)(Bn,{asChild:!0,children:(0,Z.jsx)(`div`,{className:`cursor-pointer ${n||``}`,onClick:e=>e.stopPropagation(),children:t})}),(0,Z.jsxs)(Vn,{className:`max-w-[425px] rounded-2xl p-0 gap-0 border-border overflow-hidden max-h-[95vh] [&>button]:hidden`,"data-testid":`zap-modal`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-4 h-12`,children:[(0,Z.jsxs)(zn,{className:`text-base font-semibold flex items-center gap-1.5`,children:[f?`Success`:g?`Lightning Payment`:`Send Bitcoin`,` `,!f&&(0,Z.jsx)(Ja,{faqId:g||ie===`lightning`?`send-bitcoin-lightning`:`send-bitcoin-onchain`})]}),(0,Z.jsx)(`button`,{onClick:()=>i(!1),className:`p-1.5 -mr-1.5 rounded-full text-muted-foreground hover:text-foreground hover:bg-secondary/60 transition-colors`,children:(0,Z.jsx)(Ye,{className:`size-5`})})]}),(0,Z.jsx)(`div`,{className:`overflow-y-auto`,children:f?(0,Z.jsx)($f,{recipientPubkey:e.pubkey,amountSats:f.amountSats,btcPrice:k,txid:f.kind===`onchain`?f.txid:void 0,onClose:()=>i(!1)}):ne?(0,Z.jsxs)(Qa,{value:ie,onValueChange:e=>ae(e),className:`w-full`,children:[(0,Z.jsx)(`div`,{className:`px-4 pt-2`,children:(0,Z.jsxs)(Za,{className:`grid w-full grid-cols-2 h-9`,children:[(0,Z.jsxs)(Ya,{value:`onchain`,className:`gap-1.5 text-xs`,children:[(0,Z.jsx)(P,{className:`size-3.5`}),` Bitcoin`]}),(0,Z.jsxs)(Ya,{value:`lightning`,className:`gap-1.5 text-xs`,children:[(0,Z.jsx)(Le,{className:`size-3.5`}),` Lightning`]})]})}),(0,Z.jsx)(Xa,{value:`onchain`,className:`mt-0`,children:(0,Z.jsx)(Xf,{target:e,onSuccess:({txid:e,amountSats:t})=>p({kind:`onchain`,amountSats:t,txid:e}),onClose:()=>i(!1)})}),(0,Z.jsx)(Xa,{value:`lightning`,className:`mt-0`,children:(0,Z.jsx)(sp,{...le})})]}):(0,Z.jsx)(Xf,{target:e,onSuccess:({txid:e,amountSats:t})=>p({kind:`onchain`,amountSats:t,txid:e}),onClose:()=>i(!1)})})]})]}):(0,Z.jsx)(Z.Fragment,{children:t})}function lp(e){let t=Pn();return{onClick:()=>t(e),onAuxClick:t=>{t.button===1&&(t.preventDefault(),window.open(e,`_blank`))}}}function up(e){let{nostr:t}=R(),{config:n}=Kt(),r=n.nip85StatsPubkey;return B({queryKey:[`nip85-event-stats`,e,r],queryFn:async({signal:n})=>{if(!e||!r)return null;try{let i=await t.query([{kinds:[30383],authors:[r],"#d":[e],limit:1}],{signal:n});if(i.length===0)return null;let a=i[0],o=e=>{let t=a.tags.find(([t])=>t===e);return t?.[1]?parseInt(t[1],10):0};return{commentCount:o(`comment_cnt`),repostCount:o(`repost_cnt`),reactionCount:o(`reaction_cnt`),zapCount:o(`zap_cnt`),zapAmount:o(`zap_amount`)}}catch{return null}},enabled:!!e&&!!r,staleTime:3e4,retry:!1})}function dp(e){let{nostr:t}=R(),{config:n}=Kt(),r=n.nip85StatsPubkey;return B({queryKey:[`nip85-user-stats`,e,r],queryFn:async({signal:n})=>{if(!e||!r)return null;let i=AbortSignal.timeout(2e3),a=AbortSignal.any([n,i]);try{let n=await t.query([{kinds:[30382],authors:[r],"#d":[e],limit:1}],{signal:a});if(n.length===0)return null;let i=n[0],o=e=>{let t=i.tags.find(([t])=>t===e);return t?.[1]?parseInt(t[1],10):0};return{followers:o(`followers`),postCount:o(`post_cnt`)}}catch{return null}},enabled:!!e&&!!r,staleTime:6e4,retry:!1})}function fp(e){let{nostr:t}=R(),{config:n}=Kt(),r=n.nip85StatsPubkey;return B({queryKey:[`nip85-addr-stats`,e,r],queryFn:async({signal:n})=>{if(!e||!r)return null;let i=AbortSignal.timeout(2e3),a=AbortSignal.any([n,i]);try{let n=await t.query([{kinds:[30384],authors:[r],"#d":[e],limit:1}],{signal:a});if(n.length===0)return null;let i=n[0],o=e=>{let t=i.tags.find(([t])=>t===e);return t?.[1]?parseInt(t[1],10):0};return{commentCount:o(`comment_cnt`),repostCount:o(`repost_cnt`),reactionCount:o(`reaction_cnt`),zapCount:o(`zap_cnt`),zapAmount:o(`zap_amount`)}}catch{return null}},enabled:!!e&&!!r,staleTime:3e4,retry:!1})}var pp={replies:0,reposts:0,quotes:0,reactions:0,zapAmount:0,zapCount:0,reactionEmojis:[]};function mp(e){return e>=3e4&&e<4e4}function hp(e){if(!mp(e.kind))return;let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return`${e.kind}:${e.pubkey}:${t}`}function gp(e,t){let n=t?hp(t):void 0,r=up(n?void 0:e),i=fp(n),a=n?i:r;return{data:(0,Q.useMemo)(()=>a.data?{replies:a.data.commentCount,reposts:a.data.repostCount,quotes:0,reactions:a.data.reactionCount,zapAmount:a.data.zapAmount,zapCount:a.data.zapCount,reactionEmojis:[]}:pp,[a.data]),isLoading:a.isLoading}}var _p=/https?:\/\/\S+\.(?:jpg|jpeg|png|gif|webp|svg|bmp|tiff|avif|jxl)(?:\?\S*)?/i;function vp(e){let t=e.content.trim(),n=t.match(new RegExp(_p.source,`gi`));return!n||n.length!==1?!1:t.replace(_p,``).trim().length<=100}function yp(e,{created:t,updated:n,fallback:r}){if(!e)return r;let i=e.tags.find(([e])=>e===`published_at`)?.[1];return i?i===String(e.created_at)?t:n:r}var bp=86400;function xp(e){let t=e.tags.find(([e])=>e===`status`)?.[1]??`ended`;return t===`live`&&Math.floor(Date.now()/1e3)-e.created_at>bp?`ended`:t}var Sp=(0,Q.lazy)(()=>Mt(()=>import(`./ArticleContent-BPp4GtXB.js`).then(e=>e.n).then(e=>({default:e.ArticleContent})),__vite__mapDeps([43,0,1,2,44,17,7,45,15,6,46,4,47,18,19,20,21,48,49,9,10,50,31,51,52,53,54,55,56,57,25,26,27,58,59,28,29,60,61,8,11,16,62,63,64,22,23,24,65,40,66,67,38,68,36,41,69,33,34,70,71,35,72,73,74,75,42,76,77,78,79,80,81,82,32,83,30,84,85,86,87,88,89,90,13,91]))),Cp=(0,Q.lazy)(()=>Mt(()=>import(`./CustomNipCard-BszL5Eg6.js`).then(e=>({default:e.CustomNipCard})),__vite__mapDeps([92,1,0,2,55,56,84,48,85]))),wp=(0,Q.lazy)(()=>Mt(()=>import(`./PullRequestCard-CmJ_WAtX.js`).then(e=>({default:e.PullRequestCard})),__vite__mapDeps([93,0,1,2,18,17,7,19,20,21,55,56,84,48,85,75])));function Tp({event:e}){let t={};try{t=JSON.parse(e.content)}catch{}return(0,Z.jsx)(`div`,{className:`mt-2`,onClick:e=>e.stopPropagation(),children:(0,Z.jsx)(fi,{pubkey:e.pubkey,metadata:t,showNip05:!1})})}function Ep({icon:e,actorRow:t,children:n,threaded:r,threadedLast:i,threadedLineClassName:a,className:o,onClick:s,onAuxClick:c}){let l=r||i;return(0,Z.jsx)(`article`,{className:G(`px-4 hover:bg-secondary/30 transition-colors cursor-pointer overflow-hidden`,l?G(`pt-3`,r?`pb-0`:`pb-3 border-b border-border`):`py-3 border-b border-border`,o),onClick:s,onAuxClick:c,children:(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center`,children:[e,r&&(0,Z.jsx)(`div`,{className:G(`w-0.5 flex-1 mt-2 rounded-full`,a||`bg-foreground/20`)})]}),(0,Z.jsxs)(`div`,{className:G(`flex-1 min-w-0`,l?`min-h-10 flex flex-col justify-center`:``,r&&`pb-3`),children:[t,n]})]})})}function Dp({pubkey:e,profileUrl:t,picture:n,displayName:r,authorEvent:i,isLoading:a,label:o,extra:s,timestampLabel:c}){return a?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(J,{className:`size-6 rounded-full shrink-0`}),(0,Z.jsx)(J,{className:`h-3.5 w-20`})]}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsx)(K,{to:t,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(Qn,{className:`size-6`,children:[(0,Z.jsx)(Zn,{src:n,alt:r}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary text-[8px]`,children:r[0]?.toUpperCase()})]})})}),(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsx)(K,{to:t,className:`font-semibold text-sm hover:underline truncate`,onClick:e=>e.stopPropagation(),children:i?(0,Z.jsx)(li,{tags:i.tags,children:r}):r})}),(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground shrink-0`,children:o}),s,(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,children:c})]})}function Op(e,t){return e.find(([e])=>e===t)?.[1]}function kp(e){let t=e.find(([e])=>e===`imeta`);if(!t)return{};let n={};for(let e=1;e=3e4&&e.kind<4e4){let t=Op(e.tags,`d`);if(t)return H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})}return e.kind>=1e4&&e.kind<2e4?H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:``}):H.neventEncode({id:e.id,author:e.pubkey})}var jp=new Set([`mute`,`pin`,`bookmark`,`communities`]);function Mp(e){if(e.kind!==3e4)return!1;let t=e.tags.find(([e])=>e===`d`)?.[1]??``;if(jp.has(t))return!0;let n=e.tags.some(([e])=>e===`p`),r=e.tags.some(([e])=>e===`title`||e===`name`);return!n&&!r}function Np(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Pp(e){if(e.kind!==9735)return[];let t=e.tags.find(([e])=>e===`description`)?.[1];if(!t)return[];try{let e=JSON.parse(t);if(!e||typeof e!=`object`||!(`tags`in e))return[];let n=e.tags;return Array.isArray(n)?n.filter(Np):[]}catch{return[]}}function Fp(e,t,n){return e.tags.find(([e])=>e===n)??t.find(([e])=>e===n)}function Ip(e,t,n,r){let i=[],a=Fp(e,t,`a`),o=Fp(e,t,`e`),s=Fp(e,t,`p`),c=Fp(e,t,`K`)??Fp(e,t,`k`);if(a?.[1]){i.push([`A`,a[1],a[2]??``]);let e=c?.[1]??a[1].split(`:`)[0];e&&i.push([`K`,e])}else o?.[1]?(i.push([`E`,o[1],o[2]??``,o[3]??s?.[1]??``]),c?.[1]&&i.push([`K`,c[1]]),s?.[1]&&i.push([`P`,s[1]])):s?.[1]&&i.push([`A`,`0:${s[1]}:`],[`K`,`0`]);return{...e,pubkey:n,kind:1111,content:r,tags:i}}var Lp=(0,Q.memo)(function e({event:t,className:n,repostedBy:r,compact:i,threaded:a,threadedLineClassName:o,threadedLast:s,highlight:c,hideKindHeader:l,commentContextPrefix:u,hideCommentContext:d,authorBadge:f,actionEvent:p,donationAmountSats:m,donationTransaction:h,donationTxid:g}){let{t:_}=Fn(),v=p??t,{config:y}=Kt(),{user:x}=U(),S=ha(),C=z(t.pubkey),w=z(p?.pubkey),T=(0,Q.useMemo)(()=>t.kind===9735?An(t):t.kind===8333?t.pubkey:``,[t]),E=(0,Q.useMemo)(()=>Pp(t),[t]),D=Ks(t),O=C.data?.metadata,k=p?w.data?.metadata:O,A=lr(O,t.pubkey),ee=kt(t.pubkey,O),te=(0,Q.useMemo)(()=>Ap(v),[v]),{data:ne}=gp(v.id,v),{data:re}=Vi(),[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{console.debug(`[nostr note render]`,{relay:yn(t.id)??`unknown`,kind:t.kind,id:t.id,actionRelay:p?yn(p.id)??`unknown`:void 0,actionKind:p?.kind,actionId:p?.id,path:window.location.pathname})},[t.id,t.kind,p]);let ce=x&&ip(k)&&!vl(v),{onClick:le,onAuxClick:ue}=lp(`/${te}`),j=e=>{let t=e.target;t.closest(`[role="dialog"]`)||t.closest(`[data-radix-dialog-overlay]`)||t.closest(`[data-radix-dialog-content]`)||t.closest(`[data-vaul-drawer]`)||t.closest(`[data-vaul-drawer-overlay]`)||t.closest(`[data-testid="zap-modal"]`)||t.closest(`button`)||t.closest(`a`)||le()},M=e=>{let t=e.target;t.closest(`[role="dialog"]`)||t.closest(`[data-radix-dialog-overlay]`)||t.closest(`[data-radix-dialog-content]`)||t.closest(`[data-vaul-drawer]`)||t.closest(`[data-vaul-drawer-overlay]`)||t.closest(`[data-testid="zap-modal"]`)||t.closest(`button`)||t.closest(`a`)||ue(e)},N=t.kind===34236,de=t.kind===1068,fe=t.kind===37516,pe=t.kind===7516,me=t.kind===3367,he=t.kind===3||t.kind===39089||t.kind===3e4,P=t.kind===30023,ge=t.kind===37381,_e=t.kind===30311,ve=t.kind===1063,ye=t.kind===1222||t.kind===1244,xe=t.kind===31922||t.kind===31923,Se=t.kind===30030,Ce=t.kind===30009,we=t.kind===10008||t.kind===30008,I=t.kind===8,Ee=Ce||we||I,De=t.kind===34550,Oe=t.kind===9041,ke=t.kind===36639,Ae=t.kind===33863,je=t.kind===7,Me=t.kind===1018,Ne=t.kind===6||t.kind===16,Pe=t.kind===20,Fe=t.kind===21,Ie=t.kind===22,Re=Fe||Ie,ze=t.kind===36787,Be=t.kind===34139,Ve=t.kind===30054,He=t.kind===30055,Ue=ze||Be||Ve||He,We=t.kind===30617,Ge=t.kind===1617,Ke=t.kind===1618,qe=t.kind===30817,Je=t.kind===15128||t.kind===35128,Ye=t.kind===32267,Xe=t.kind===30063,Ze=t.kind===3063,Qe=t.kind===31990,$e=t.kind===4,et=t.kind===8211,tt=t.kind===62,nt=t.kind===9735||t.kind===8333,rt=t.kind===0,it=!N&&!de&&!fe&&!pe&&!me&&!he&&!P&&!ge&&!_e&&!ve&&!ye&&!xe&&!Se&&!Ee&&!De&&!Oe&&!ke&&!Ae&&!je&&!Me&&!Ne&&!Pe&&!Re&&!Ue&&!(We||Ge||Ke||qe||Je)&&!Ye&&!Xe&&!Ze&&!Qe&&!$e&&!et&&!tt&&!nt&&!rt,L=t.kind===1111,st=it&&!L&&vn(t),{translatedEvent:ct,translateAction:lt}=ra(t,{includePlainContent:it,iconOnly:!0,buttonClassName:`h-9 w-9 p-0`}),ut=(0,Q.useMemo)(()=>{if(!it||!st)return[];let e=t.tags.filter(([e,,,t])=>e===`p`&&t!==`mention`);if(e.length>0)return[...new Set(e.map(([,e])=>e).filter(Boolean))];let n=t.tags.filter(([e])=>e===`p`);if(n.length>0)return[...new Set(n.map(([,e])=>e).filter(Boolean))];let r=t.tags.filter(([e,,,t])=>e===`e`&&t!==`mention`),i=r.find(([,,,e])=>e===`reply`),a=r.find(([,,,e])=>e===`root`);return[i?.[4]||a?.[4]||t.pubkey]},[t.tags,it,st,t.pubkey]),dt=(0,Q.useMemo)(()=>{if(st)return bn(t)},[t,st]),ft=dt?.id,pt=(0,Q.useMemo)(()=>N?kp(t.tags):void 0,[t.tags,N]),mt=N?Op(t.tags,`title`):void 0,ht=N?t.tags.filter(([e])=>e===`t`).map(([,e])=>e):[];if(Mp(t)||ga(t)!==void 0&&y.contentWarningPolicy===`hide`||ge&&t.tags.some(([e,t])=>e===`t`&&t===`unlisted`)||fe&&t.tags.some(([e,t])=>e===`t`&&t===`hidden`))return null;let gt=(0,Z.jsxs)(Fc,{event:t,children:[L&&!d&&m===void 0&&(0,Z.jsx)(mc,{event:t,prefix:u}),st&&(0,Z.jsx)($d,{pubkeys:ut,parentEventId:ft,parentRelayHint:dt?.relayHint,parentAuthorHint:dt?.authorHint}),m!==void 0&&m>0?(0,Z.jsxs)(`div`,{className:G(`group/donation mb-0 py-1`,L&&!d?`mt-2`:`mt-3`),children:[L&&!d?(0,Z.jsx)(mc,{event:t,prefix:u,className:`flex items-center gap-x-1 text-sm text-muted-foreground mt-0 mb-1 min-w-0 overflow-hidden`}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5 text-2xl leading-none text-emerald-600 dark:text-emerald-400`,children:[(0,Z.jsx)(b,{className:`size-6 shrink-0 motion-safe:transition-transform motion-safe:group-hover/donation:-rotate-6 motion-safe:group-hover/donation:scale-110`,"aria-hidden":!0}),(0,Z.jsx)(`span`,{className:`latin-display font-display font-normal tracking-wide leading-none uppercase inline-block`,style:{WebkitTextStroke:`0.022em currentColor`,transform:`skewX(-6deg) scaleX(1.1)`,transformOrigin:`0 100%`},children:_(`campaignsDetail.ledger.donated`)})]}),(0,Z.jsx)(`div`,{className:`shrink-0 flex items-center gap-3`,children:(0,Z.jsxs)(`div`,{className:`latin-display text-right font-display font-normal tracking-wide leading-none tabular-nums text-2xl inline-block text-emerald-600 dark:text-emerald-400`,style:{WebkitTextStroke:`0.022em currentColor`,transform:`skewX(-6deg) scaleX(1.1)`,transformOrigin:`100% 100%`},children:[`+`,re?on(m,re):`${Xt(m)} ${_(`campaignsDetail.ledger.btcUnit`)}`]})})]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between gap-4 text-xs text-muted-foreground`,children:[g?(0,Z.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1.5 text-left hover:text-foreground motion-safe:transition-colors`,onClick:e=>{e.stopPropagation(),Pi(`https://mempool.space/tx/${g}`)},title:_(`campaignsDetail.ledger.openOnMempool`),children:[(0,Z.jsxs)(`span`,{className:`truncate font-mono`,children:[g.slice(0,8),`…`,g.slice(-6)]}),h?.confirmed&&h.blockHeight?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:_(`campaignsDetail.ledger.block`,{height:h.blockHeight})})]}):h?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:_(`campaignsDetail.ledger.unconfirmed`)})]}):null,(0,Z.jsx)(F,{className:`size-3 shrink-0`,"aria-hidden":!0})]}):(0,Z.jsx)(`span`,{}),re?(0,Z.jsxs)(`div`,{className:`shrink-0 text-right tabular-nums leading-none`,children:[`+`,Xt(m),` `,_(`campaignsDetail.ledger.btcUnit`)]}):null]})]}):null,(0,Z.jsx)(Ic,{event:t,children:m===void 0?Pe?(0,Z.jsx)(Vp,{event:t}):Re?(0,Z.jsx)(Wp,{event:t}):N?(0,Z.jsxs)(Z.Fragment,{children:[mt&&(0,Z.jsx)(`p`,{className:`text-[15px] mt-2 leading-relaxed break-words overflow-hidden`,children:mt}),(0,Z.jsx)(Gp,{imeta:pt,hashtags:ht})]}):de?(0,Z.jsx)(Qu,{event:t}):fe?(0,Z.jsx)(fl,{event:t}):pe?(0,Z.jsx)(al,{event:t}):me?(0,Z.jsx)(Gs,{event:t}):he?(0,Z.jsx)(tl,{event:t}):P?(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(J,{className:`h-24 w-full rounded-lg`}),children:(0,Z.jsx)(Sp,{event:t,preview:!0,className:`mt-2`})}):ge?(0,Z.jsx)(ru,{event:t}):_e?(0,Z.jsx)(qp,{event:t}):ve?(0,Z.jsx)(Gc,{event:t,compact:!0}):Se?(0,Z.jsx)(Bc,{event:t}):Ce?(0,Z.jsx)(ps,{event:t}):we?(0,Z.jsx)(nd,{event:t}):I?(0,Z.jsx)(gs,{event:t}):De?(0,Z.jsx)(us,{event:ct}):Oe?(0,Z.jsx)(Bl,{event:t}):ke?(0,Z.jsx)(ls,{event:ct}):Ae?(0,Z.jsx)(cs,{event:ct}):ye?(0,Z.jsx)(Bf,{event:t}):xe?(0,Z.jsx)(Ms,{event:t,compact:!0}):ze?(0,Z.jsx)(rs,{event:t}):Be?(0,Z.jsx)(is,{event:t}):Ve?(0,Z.jsx)(as,{event:t}):He?(0,Z.jsx)(os,{event:t}):We?(0,Z.jsx)(hl,{event:t}):Ge?(0,Z.jsx)(Uu,{event:t}):Ke?(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(J,{className:`h-24 w-full rounded-lg`}),children:(0,Z.jsx)(wp,{event:t})}):qe?(0,Z.jsx)(Q.Suspense,{fallback:(0,Z.jsx)(J,{className:`h-24 w-full rounded-lg`}),children:(0,Z.jsx)(Cp,{event:t})}):Je?(0,Z.jsx)(Gl,{event:t}):Ye?(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-border overflow-hidden transition-all duration-300 hover:shadow-md hover:border-primary/20`,children:(0,Z.jsx)(`div`,{className:`px-3.5 pb-3.5 pt-3`,children:(0,Z.jsx)(pf,{event:t,compact:!0})})}):Xe?(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-border overflow-hidden transition-all duration-300 hover:shadow-md hover:border-primary/20`,children:(0,Z.jsx)(`div`,{className:`px-3.5 pb-3.5 pt-3`,children:(0,Z.jsx)(Tf,{event:t,compact:!0})})}):Ze?(0,Z.jsx)(`div`,{className:`mt-2 rounded-xl border border-border overflow-hidden transition-all duration-300 hover:shadow-md hover:border-primary/20`,children:(0,Z.jsx)(`div`,{className:`px-3.5 pb-3.5 pt-3`,children:(0,Z.jsx)(Df,{event:t,compact:!0})})}):Qe?(0,Z.jsx)(Rf,{event:t,compact:!0}):$e?(0,Z.jsx)(Gr,{event:t,compact:!0}):et?(0,Z.jsx)(xr,{event:t,compact:!0}):rt?(0,Z.jsx)(Tp,{event:t}):(0,Z.jsx)(zp,{event:ct}):ct.content.trim()?(0,Z.jsxs)(`div`,{className:`relative mt-2 mb-0 pl-7 text-lg font-medium leading-relaxed text-foreground sm:text-xl`,children:[(0,Z.jsx)(Te,{className:`absolute left-0 top-0.5 size-5 text-primary/40`,"aria-hidden":!0}),(0,Z.jsx)(zp,{event:ct,className:`mt-0`,contentClassName:`text-lg font-medium leading-relaxed sm:text-xl`})]}):null})]}),_t=C.isLoading?(0,Z.jsxs)(`div`,{className:`min-w-0 min-h-[42px] flex flex-col justify-center space-y-1.5`,children:[(0,Z.jsx)(J,{className:`h-4 w-28`}),(0,Z.jsx)(J,{className:`h-3 w-36`})]}):(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 min-h-[42px] flex flex-col justify-center`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(br,{pubkey:t.pubkey,asChild:!0,children:(0,Z.jsx)(K,{to:ee,className:`font-bold text-[15px] hover:underline truncate`,onClick:e=>e.stopPropagation(),children:C.data?.event?(0,Z.jsx)(li,{tags:C.data.event.tags,children:A}):A})}),O?.bot&&(0,Z.jsx)(`span`,{className:`text-xs text-primary shrink-0`,title:_(`noteCard.botAccount`),children:`🤖`}),f]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 text-sm text-muted-foreground min-w-0 pr-2`,children:(0,Z.jsx)(`span`,{className:`shrink-0 hover:underline whitespace-nowrap`,children:zi(t.created_at)})})]}),vt=C.isLoading?(0,Z.jsx)(J,{className:G(a||s?`size-10`:`size-11`,`rounded-full shrink-0`)}):(0,Z.jsx)(br,{pubkey:t.pubkey,asChild:!0,children:(0,Z.jsx)(K,{to:ee,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(Qn,{className:a||s?`size-10`:`size-11`,children:[(0,Z.jsx)(Zn,{src:O?.picture,alt:A}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary text-sm`,children:A[0]?.toUpperCase()})]})})}),yt=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 sm:gap-2 mt-3`,children:[(0,Z.jsxs)(`button`,{className:`inline-flex items-center gap-2 h-9 px-3 rounded-full text-sm font-medium text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:_(`feed.actions.reply`),onClick:e=>{e.stopPropagation(),se(!0)},children:[(0,Z.jsx)(be,{className:`size-[18px]`}),ne?.replies?(0,Z.jsx)(`span`,{className:`tabular-nums`,children:ii(ne.replies)}):null]}),(0,Z.jsx)(af,{event:v,children:e=>(0,Z.jsxs)(`button`,{className:G(`inline-flex items-center gap-2 h-9 px-3 rounded-full text-sm font-medium transition-colors`,e?`text-accent hover:text-accent/80 hover:bg-accent/10`:`text-muted-foreground hover:text-accent hover:bg-accent/10`),title:_(e?`feed.actions.undoRepost`:`feed.actions.repost`),children:[(0,Z.jsx)(wn,{className:`size-[18px]`}),ne?.reposts||ne?.quotes?(0,Z.jsx)(`span`,{className:`tabular-nums`,children:ii((ne?.reposts??0)+(ne?.quotes??0))}):null]})}),(0,Z.jsx)(sd,{eventId:v.id,eventPubkey:v.pubkey,eventKind:v.kind,reactionCount:ne?.reactions,variant:`chip`}),ce&&(0,Z.jsx)(cp,{target:v,children:(0,Z.jsxs)(`button`,{className:`inline-flex items-center gap-2 h-9 px-3 rounded-full text-sm font-medium text-muted-foreground hover:text-amber-500 hover:bg-amber-500/10 transition-colors`,title:_(`feed.actions.zap`),children:[(0,Z.jsx)(Le,{className:`size-[18px]`}),ne?.zapAmount?(0,Z.jsx)(`span`,{className:`tabular-nums`,children:ii(ne.zapAmount)}):null]})}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{className:`inline-flex items-center justify-center h-9 w-9 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:_(`feed.actions.share`),onClick:async e=>{e.stopPropagation(),Ri(),await yd(`${S}/${te}`)===`copied`&&W({title:_(`feed.actions.linkCopied`)})},children:(0,Z.jsx)(ot,{className:`size-[18px]`})})]}),bt=i?null:(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[lt,(0,Z.jsx)(`button`,{className:`inline-flex items-center justify-center h-9 w-9 rounded-full text-muted-foreground hover:text-primary hover:bg-primary/10 transition-colors`,title:_(`feed.actions.more`),onClick:e=>{e.stopPropagation(),ae(!0)},children:(0,Z.jsx)(at,{className:`size-[18px]`})})]});if(tt)return a||s?(0,Z.jsxs)(`article`,{className:G(`relative px-4 pt-3 hover:bg-secondary/30 transition-colors cursor-pointer overflow-hidden`,a?`pb-0`:`pb-3 border-b border-border`,n),onClick:j,onAuxClick:M,children:[bt&&(0,Z.jsx)(`div`,{className:`absolute right-3 top-2 z-10`,children:bt}),(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center`,children:[vt,a&&(0,Z.jsx)(`div`,{className:G(`w-0.5 flex-1 mt-2 rounded-full`,o||`bg-foreground/20`)})]}),(0,Z.jsxs)(`div`,{className:G(`flex-1 min-w-0`,a&&`pb-3`),children:[(0,Z.jsx)(Wr,{event:t,timestamp:zi(t.created_at)}),!i&&(0,Z.jsxs)(Z.Fragment,{children:[yt,(0,Z.jsx)(zu,{event:v,open:ie,onOpenChange:ae}),(0,Z.jsx)(Qd,{event:v,open:oe,onOpenChange:se})]})]})]})]}):(0,Z.jsxs)(`article`,{className:G(`relative px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors cursor-pointer overflow-hidden`,n),onClick:j,onAuxClick:M,children:[bt&&(0,Z.jsx)(`div`,{className:`absolute right-3 top-2 z-10`,children:bt}),(0,Z.jsx)(Wr,{event:t}),!i&&(0,Z.jsxs)(Z.Fragment,{children:[yt,(0,Z.jsx)(zu,{event:v,open:ie,onOpenChange:ae}),(0,Z.jsx)(Qd,{event:v,open:oe,onOpenChange:se})]})]});if(je)return(0,Z.jsx)(Ep,{icon:(0,Z.jsx)(`div`,{className:G(`flex items-center justify-center rounded-full bg-pink-500/10 shrink-0 text-lg leading-none`,a||s?`size-10`:`size-11`),children:(0,Z.jsx)(ui,{content:t.content,tags:t.tags,className:`h-5 w-5 object-contain`})}),actorRow:(0,Z.jsx)(Dp,{pubkey:t.pubkey,profileUrl:ee,picture:O?.picture,displayName:A,authorEvent:C.data?.event,isLoading:C.isLoading,label:_(`noteCard.reacted`),timestampLabel:zi(t.created_at)}),threaded:a,threadedLast:s,threadedLineClassName:o,className:n,onClick:j,onAuxClick:M});if(Ne)return(0,Z.jsx)(Ep,{icon:(0,Z.jsx)(`div`,{className:G(`flex items-center justify-center rounded-full bg-accent/10 shrink-0`,a||s?`size-10`:`size-11`),children:(0,Z.jsx)(wn,{className:`size-5 text-accent`})}),actorRow:(0,Z.jsx)(Dp,{pubkey:t.pubkey,profileUrl:ee,picture:O?.picture,displayName:A,authorEvent:C.data?.event,isLoading:C.isLoading,label:_(`noteCard.reposted`),timestampLabel:zi(t.created_at)}),threaded:a,threadedLast:s,threadedLineClassName:o,className:n,onClick:j,onAuxClick:M});if(nt){let r=qa(t),l=(t.kind===8333?t.content:On(t)).trim(),u=re?on(r,re):void 0,f=_(`noteCard.zap.sat`,{count:r,formattedCount:ii(r)}),p=u??f,m=t.kind===8333?_(`noteCard.zap.donatedTo`):r>0?_(`noteCard.zap.donatedAmountTo`,{amount:p}):_(`noteCard.zap.donatedTo`),g=Ip(t,E,T||t.pubkey,l);return(0,Z.jsx)(e,{event:g,actionEvent:t,className:n,compact:i,threaded:a,threadedLineClassName:o,threadedLast:s,highlight:c,hideKindHeader:!0,commentContextPrefix:m,hideCommentContext:d,donationAmountSats:t.kind===8333?r:void 0,donationTransaction:h,donationTxid:t.kind===8333?zt(t)??void 0:void 0})}if(Me){let e=a||s?`size-10`:`size-11`;return(0,Z.jsx)(Ep,{icon:(0,Z.jsx)(br,{pubkey:t.pubkey,asChild:!0,children:(0,Z.jsx)(K,{to:ee,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Z.jsxs)(Qn,{className:e,children:[(0,Z.jsx)(Zn,{src:O?.picture,alt:A}),(0,Z.jsx)(Xn,{className:`bg-primary/20 text-primary text-sm`,children:A[0]?.toUpperCase()})]})})}),actorRow:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(br,{pubkey:t.pubkey,asChild:!0,children:(0,Z.jsx)(K,{to:ee,className:`font-semibold text-sm hover:underline truncate`,onClick:e=>e.stopPropagation(),children:C.data?.event?(0,Z.jsx)(li,{tags:C.data.event.tags,children:A}):A})}),(0,Z.jsx)(`span`,{className:`text-sm text-muted-foreground shrink-0`,children:_(`noteCard.voted`)}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto shrink-0`,children:zi(t.created_at)})]}),threaded:a,threadedLast:s,threadedLineClassName:o,className:n,onClick:j,onAuxClick:M,children:D&&(0,Z.jsx)(`p`,{className:`text-sm font-semibold mt-0.5 truncate`,children:D})})}if(a||s){let e=!r&&!l&&Yp[t.kind]?(()=>{let e=Yp[t.kind],n=t.kind===30311&&xp(t)===`live`;return(0,Z.jsx)(Xp,{pubkey:t.pubkey,icon:e.icon,iconClassName:t.kind===30311?n?`text-primary`:`text-muted-foreground`:e.iconClassName,action:typeof e.action==`function`?e.action(t):e.action,noun:e.noun,nounRoute:e.nounRoute})})():null;return(0,Z.jsx)(`article`,{className:G(`relative px-4 pt-3 hover:bg-secondary/30 transition-colors cursor-pointer overflow-hidden`,a?`pb-0`:`pb-3 border-b border-border`,n),onClick:j,onAuxClick:M,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[e&&(0,Z.jsx)(`div`,{children:e}),(0,Z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col items-center`,children:[vt,a&&(0,Z.jsx)(`div`,{className:G(`w-0.5 flex-1 mt-2 rounded-full`,o||`bg-foreground/20`)})]}),(0,Z.jsxs)(`div`,{className:G(`flex-1 min-w-0`,a&&`pb-3`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:_t}),(0,Z.jsx)(Oc,{event:t,className:`shrink-0 [text-shadow:none]`}),bt]}),gt,yt,(0,Z.jsx)(zu,{event:v,open:ie,onOpenChange:ae}),(0,Z.jsx)(Qd,{event:v,open:oe,onOpenChange:se})]})]})]})})}return(0,Z.jsx)(`article`,{className:G(`relative px-4 py-3 border-b border-border hover:bg-secondary/30 transition-colors cursor-pointer overflow-hidden`,c&&`animate-highlight-fade`,n),onClick:j,onAuxClick:M,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsxs)(`div`,{children:[r?(0,Z.jsx)(Xp,{pubkey:r,icon:wn,iconClassName:`text-accent`,action:`noteCard.reposted`}):!l&&Yp[t.kind]&&(()=>{let e=Yp[t.kind],n=t.kind===30311&&xp(t)===`live`;return(0,Z.jsx)(Xp,{pubkey:t.pubkey,icon:e.icon,iconClassName:t.kind===30311?n?`text-primary`:`text-muted-foreground`:e.iconClassName,action:typeof e.action==`function`?e.action(t):e.action,noun:e.noun,nounRoute:e.nounRoute})})(),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[vt,_t,(0,Z.jsx)(Oc,{event:t,className:`shrink-0 [text-shadow:none]`}),bt]})]}),gt,!i&&(0,Z.jsxs)(Z.Fragment,{children:[yt,(0,Z.jsx)(zu,{event:v,open:ie,onOpenChange:ae}),(0,Z.jsx)(Qd,{event:v,open:oe,onOpenChange:se})]})]})})}),Rp=400;function zp({event:e,className:t,contentClassName:n}){let{t:r}=Fn(),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=vp(e),u=(0,Q.useCallback)(()=>{let e=i.current;e&&o(!l&&e.scrollHeight>Rp)},[l]);return(0,Q.useEffect)(()=>(u(),window.addEventListener(`resize`,u),()=>window.removeEventListener(`resize`,u)),[u]),(0,Q.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.querySelectorAll(`img`);if(t.length!==0)return t.forEach(e=>e.addEventListener(`load`,u,{once:!0})),()=>t.forEach(e=>e.removeEventListener(`load`,u))},[u]),(0,Z.jsxs)(`div`,{className:G(`mt-2 break-words overflow-hidden`,t),children:[(0,Z.jsxs)(`div`,{ref:i,style:!s&&a?{maxHeight:Rp,overflow:`hidden`}:void 0,className:`relative`,children:[(0,Z.jsx)(Jr,{event:e,className:G(`text-[15px] leading-relaxed`,n)}),!s&&a&&(0,Z.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-background to-transparent pointer-events-none`})]}),a&&(0,Z.jsx)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2`,children:(0,Z.jsx)(`button`,{className:`text-sm text-primary hover:underline`,onClick:e=>{e.stopPropagation(),c(e=>!e)},children:r(s?`noteCard.showLess`:`noteCard.readMore`)})})]})}function Bp(e){let t=[];for(let n of e){if(n[0]!==`imeta`)continue;let e={};for(let t=1;tBp(e.tags),[e.tags]),n=Op(e.tags,`title`),r=e.content,i=e.tags.filter(([e])=>e===`t`).map(([,e])=>e),a=(0,Q.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.url,{blurhash:n.blurhash});return e},[t]);return t.length===0?null:(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[n&&(0,Z.jsx)(`p`,{className:`font-semibold text-[15px]`,children:n}),(0,Z.jsx)(Ir,{images:t.map(e=>e.url),maxVisible:4,maxGridHeight:`480px`,imetaMap:a}),r&&(0,Z.jsx)(`p`,{className:`text-[15px] leading-relaxed text-muted-foreground`,children:r}),i.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.slice(0,5).map(e=>(0,Z.jsxs)(K,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))})]})}function Hp(e){for(let t of e){if(t[0]!==`imeta`)continue;let e={};for(let n=1;ne===`url`)?.[1],thumbnail:e.find(([e])=>e===`thumb`)?.[1]??e.find(([e])=>e===`image`)?.[1]}}function Up(e){let t=parseFloat(e??``);if(isNaN(t)||t<=0)return;let n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=Math.floor(t%60),a=String(r).padStart(2,`0`),o=String(i).padStart(2,`0`);return n>0?`${n}:${a}:${o}`:`${a}:${o}`}function Wp({event:e}){let{url:t,thumbnail:n,duration:r}=(0,Q.useMemo)(()=>Hp(e.tags),[e.tags]),i=Op(e.tags,`title`),a=e.content,o=e.kind===22,s=Up(r),c=e.tags.filter(([e])=>e===`t`).map(([,e])=>e);return t?(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[i&&(0,Z.jsx)(`p`,{className:`font-semibold text-[15px]`,children:i}),(0,Z.jsxs)(`div`,{className:G(`relative rounded-xl overflow-hidden bg-muted`,o?`max-w-[280px]`:``),children:[(0,Z.jsx)(Lr,{src:t,poster:n,title:i??void 0}),s&&(0,Z.jsx)(`div`,{className:`absolute bottom-2 right-2 bg-black/80 text-white text-[10px] px-1.5 py-0.5 rounded font-medium pointer-events-none`,children:s}),o&&(0,Z.jsx)(`div`,{className:`absolute top-2 left-2 pointer-events-none`,children:(0,Z.jsx)(`span`,{className:`text-[10px] bg-black/60 text-white px-1.5 py-0.5 rounded`,children:`Short`})})]}),a&&(0,Z.jsx)(`p`,{className:`text-[15px] leading-relaxed text-muted-foreground`,children:a}),c.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:c.slice(0,5).map(e=>(0,Z.jsxs)(K,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))})]}):null}function Gp({imeta:e,hashtags:t}){let n=(0,Q.useRef)(null),r=(0,Q.useRef)(null),[i,a]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let e=n.current,t=r.current;if(!e||!t)return;let i=new IntersectionObserver(([t])=>{!t.isIntersecting&&!e.paused&&e.pause()},{threshold:.25});return i.observe(t),()=>i.disconnect()},[]),(0,Z.jsxs)(Z.Fragment,{children:[e?.url&&(0,Z.jsxs)(`div`,{ref:r,className:`relative mt-3 rounded-2xl overflow-hidden cursor-pointer`,onClick:e=>{e.stopPropagation();let t=n.current;t&&(t.paused?(t.play(),a(!0)):(t.pause(),a(!1)))},children:[(0,Z.jsx)(`video`,{ref:n,src:e.url,poster:e.thumbnail,className:`w-full max-h-[70vh] object-cover`,loop:!0,playsInline:!0,preload:`none`,onPlay:()=>a(!0),onPause:()=>a(!1)}),!i&&(0,Z.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/20`,children:(0,Z.jsx)(`div`,{className:`size-14 rounded-full bg-black/60 flex items-center justify-center backdrop-blur-sm`,children:(0,Z.jsx)(pt,{className:`size-7 text-white ml-1`,fill:`white`})})})]}),t.length>0&&(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-2`,children:t.slice(0,5).map(e=>(0,Z.jsxs)(K,{to:`/t/${encodeURIComponent(e)}`,className:`text-xs text-primary hover:underline`,onClick:e=>e.stopPropagation(),children:[`#`,e]},e))})]})}function Kp(e){switch(e){case`live`:return{labelKey:`noteCard.stream.live`,className:`bg-red-600 hover:bg-red-600 text-white border-red-600`};case`ended`:return{labelKey:`noteCard.stream.ended`,className:`bg-muted text-muted-foreground border-border`};case`planned`:return{labelKey:`noteCard.stream.planned`,className:`bg-blue-600/90 hover:bg-blue-600/90 text-white border-blue-600`};default:return{labelKey:`noteCard.stream.unknown`,className:`bg-muted text-muted-foreground border-border`}}}function qp({event:e}){let{t}=Fn(),n=Op(e.tags,`title`)||t(`noteCard.stream.untitled`),r=Op(e.tags,`summary`),i=Op(e.tags,`image`),a=Op(e.tags,`streaming`),o=xp(e),s=Op(e.tags,`current_participants`),c=Kp(o),l=o===`live`&&!!a,{onClick:u}=lp(`/${(0,Q.useMemo)(()=>{let t=Op(e.tags,`d`)||``;return H.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e])}`);return(0,Z.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Z.jsx)(`div`,{className:`rounded-xl overflow-hidden border border-border`,children:l?(0,Z.jsxs)(`div`,{className:`relative`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(ql,{src:a,poster:i,title:n}),(0,Z.jsxs)(`div`,{className:`absolute top-2 left-2 z-10 flex items-center gap-2 pointer-events-none`,children:[(0,Z.jsxs)(X,{variant:`outline`,className:G(`text-[10px]`,c.className),children:[(0,Z.jsx)(`div`,{className:`size-1.5 bg-white rounded-full animate-pulse mr-1`}),t(c.labelKey)]}),s&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 bg-black/60 text-white text-xs px-2 py-0.5 rounded`,children:[(0,Z.jsx)(I,{className:`size-3`}),s]})]})]}):i?(0,Z.jsxs)(`div`,{className:`relative w-full aspect-video overflow-hidden bg-muted`,children:[(0,Z.jsx)(`img`,{src:i,alt:``,className:`w-full h-full object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`}}),(0,Z.jsx)(`div`,{className:`absolute top-2 left-2`,children:(0,Z.jsx)(X,{variant:`outline`,className:G(`text-[10px]`,c.className),children:t(c.labelKey)})}),s&&(0,Z.jsxs)(`div`,{className:`absolute bottom-2 right-2 flex items-center gap-1 bg-black/60 text-white text-xs px-2 py-0.5 rounded`,children:[(0,Z.jsx)(I,{className:`size-3`}),s]})]}):(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 bg-muted/40`,children:[(0,Z.jsx)(_t,{className:`size-4 text-primary shrink-0`}),(0,Z.jsxs)(X,{variant:`outline`,className:G(`text-[10px]`,c.className),children:[o===`live`&&(0,Z.jsx)(`div`,{className:`size-1.5 bg-white rounded-full animate-pulse mr-1`}),t(c.labelKey)]}),s&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(I,{className:`size-3`}),s]})]})}),(0,Z.jsxs)(`button`,{type:`button`,className:`flex items-start gap-2 text-left w-full group`,onClick:e=>{e.stopPropagation(),u()},children:[(0,Z.jsx)(_t,{className:`size-4 text-primary shrink-0 mt-0.5`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`font-semibold text-sm leading-snug line-clamp-2 group-hover:underline`,children:n}),r&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2 mt-0.5`,children:r})]})]})]})}function Jp(e,t){return yp(e,t)}var Yp={20:{icon:D,action:`noteCard.kindHeader.photo.action`,noun:`noteCard.kindHeader.photo.noun`,nounRoute:`/photos`},4:{icon:Ke,action:`noteCard.kindHeader.encryptedMessage.action`,noun:`noteCard.kindHeader.encryptedMessage.noun`},8211:{icon:Ke,action:`noteCard.kindHeader.letter.action`,noun:`noteCard.kindHeader.letter.noun`,nounRoute:`/letters`},37516:{icon:En,action:e=>Jp(e,{created:`noteCard.kindHeader.treasureHidCreated`,updated:`noteCard.kindHeader.treasureHidUpdated`,fallback:`noteCard.kindHeader.treasureHidCreated`}),noun:`noteCard.kindHeader.treasureNoun`,nounRoute:`/treasures`},7516:{icon:En,action:`noteCard.kindHeader.treasureFound`,noun:`noteCard.kindHeader.treasureNoun`,nounRoute:`/treasures`},37381:{icon:Tn,action:e=>Jp(e,{created:`noteCard.kindHeader.deckCreated`,updated:`noteCard.kindHeader.deckUpdated`,fallback:`noteCard.kindHeader.deckFallback`}),noun:`noteCard.kindHeader.deckNoun`,nounRoute:`/decks`},30030:{icon:he,action:e=>Jp(e,{created:`noteCard.kindHeader.emojiPackCreated`,updated:`noteCard.kindHeader.emojiPackUpdated`,fallback:`noteCard.kindHeader.emojiPackFallback`}),noun:`noteCard.kindHeader.emojiPackNoun`,nounRoute:`/emojis`},34550:{icon:I,action:e=>Jp(e,{created:`noteCard.kindHeader.groupCreated`,updated:`noteCard.kindHeader.groupUpdated`,fallback:`noteCard.kindHeader.groupFallback`}),noun:`noteCard.kindHeader.groupNoun`,nounRoute:`/groups`},33863:{icon:b,action:e=>Jp(e,{created:`noteCard.kindHeader.campaignLaunched`,updated:`noteCard.kindHeader.campaignUpdated`,fallback:`noteCard.kindHeader.campaignFallback`}),noun:`noteCard.kindHeader.campaignNoun`,nounRoute:`/campaigns`},8:{icon:L,action:`noteCard.kindHeader.badgeAwarded`,noun:`noteCard.kindHeader.badgeNoun`,nounRoute:`/badges`},30009:{icon:L,action:e=>Jp(e,{created:`noteCard.kindHeader.badgeCreated`,updated:`noteCard.kindHeader.badgeDefUpdated`,fallback:`noteCard.kindHeader.badgeCreated`}),noun:`noteCard.kindHeader.badgeNoun`,nounRoute:`/badges`},10008:{icon:L,action:e=>Jp(e,{created:`noteCard.kindHeader.badgesCreatedTheir`,updated:`noteCard.kindHeader.badgesUpdatedTheir`,fallback:`noteCard.kindHeader.badgesUpdatedTheir`}),noun:`noteCard.kindHeader.badgesNoun`,nounRoute:`/badges`},30008:{icon:L,action:e=>Jp(e,{created:`noteCard.kindHeader.badgesCreatedTheir`,updated:`noteCard.kindHeader.badgesUpdatedTheir`,fallback:`noteCard.kindHeader.badgesUpdatedTheir`}),noun:`noteCard.kindHeader.badgesNoun`,nounRoute:`/badges`},30311:{icon:_t,iconClassName:void 0,action:e=>xp(e)===`live`?`noteCard.kindHeader.streamingLive`:`noteCard.kindHeader.streamed`},32267:{icon:S,action:e=>Jp(e,{created:`noteCard.kindHeader.zapstoreAppPublished`,updated:`noteCard.kindHeader.zapstoreAppUpdated`,fallback:`noteCard.kindHeader.zapstoreAppPublished`})},30063:{icon:S,action:e=>Jp(e,{created:`noteCard.kindHeader.zapstoreReleasePublished`,updated:`noteCard.kindHeader.zapstoreReleaseUpdated`,fallback:`noteCard.kindHeader.zapstoreReleasePublished`})},3063:{icon:S,action:`noteCard.kindHeader.zapstoreAssetPublished`},31990:{icon:S,action:e=>Jp(e,{created:`noteCard.kindHeader.appPublished`,updated:`noteCard.kindHeader.appUpdated`,fallback:`noteCard.kindHeader.appPublished`})},30617:{icon:me,action:e=>Jp(e,{created:`noteCard.kindHeader.repoCreated`,updated:`noteCard.kindHeader.repoUpdated`,fallback:`noteCard.kindHeader.repoFallback`}),noun:`noteCard.kindHeader.repoNoun`,nounRoute:`/development`},1617:{icon:je,action:`noteCard.kindHeader.patchSubmitted`,noun:`noteCard.kindHeader.patchNoun`,nounRoute:`/development`},1618:{icon:fe,action:`noteCard.kindHeader.prOpened`,noun:`noteCard.kindHeader.prNoun`,nounRoute:`/development`},30817:{icon:ct,action:e=>Jp(e,{created:`noteCard.kindHeader.nipProposed`,updated:`noteCard.kindHeader.nipUpdated`,fallback:`noteCard.kindHeader.nipProposed`}),noun:`noteCard.kindHeader.nipNoun`,nounRoute:`/development`},15128:{icon:Fe,action:e=>Jp(e,{created:`noteCard.kindHeader.nsiteDeployed`,updated:`noteCard.kindHeader.nsiteRedeployed`,fallback:`noteCard.kindHeader.nsiteDeployed`}),noun:`noteCard.kindHeader.nsiteNoun`,nounRoute:`/development`},35128:{icon:Fe,action:e=>Jp(e,{created:`noteCard.kindHeader.nsiteDeployed`,updated:`noteCard.kindHeader.nsiteRedeployed`,fallback:`noteCard.kindHeader.nsiteDeployed`}),noun:`noteCard.kindHeader.nsiteNoun`,nounRoute:`/development`},9735:{icon:Le,action:`noteCard.kindHeader.zapped`},36639:{icon:n,action:e=>Jp(e,{created:`noteCard.kindHeader.pledgeCreated`,updated:`noteCard.kindHeader.pledgeUpdated`,fallback:`noteCard.kindHeader.pledgeCreated`}),noun:`noteCard.kindHeader.pledgeNoun`,nounRoute:`/pledges`},39089:{icon:k,action:e=>Jp(e,{created:`noteCard.kindHeader.followPackCreated`,updated:`noteCard.kindHeader.followPackUpdated`,fallback:`noteCard.kindHeader.followPackFallback`}),noun:`noteCard.kindHeader.followPackNoun`,nounRoute:`/packs`},3e4:{icon:k,action:e=>Jp(e,{created:`noteCard.kindHeader.followSetCreated`,updated:`noteCard.kindHeader.followSetUpdated`,fallback:`noteCard.kindHeader.followSetFallback`}),noun:`noteCard.kindHeader.followSetNoun`,nounRoute:`/packs`}};function Xp({pubkey:e,icon:t,iconClassName:n,action:r,noun:i,nounRoute:a}){let{t:o}=Fn(),s=z(e),c=s.data?.metadata?.name||er(e),l=kt(e,s.data?.metadata),u=o(r),d=i?o(i):void 0;return(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground mb-3 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`w-11 shrink-0 flex justify-end`,children:(0,Z.jsx)(t,{className:G(`size-4 translate-y-px`,n??`text-primary`)})}),(0,Z.jsxs)(`div`,{className:`flex items-center min-w-0`,children:[s.isLoading?(0,Z.jsx)(J,{className:`h-3 w-20 inline-block`}):(0,Z.jsx)(br,{pubkey:e,asChild:!0,children:(0,Z.jsx)(K,{to:l,className:`font-medium hover:underline mr-1 truncate`,onClick:e=>e.stopPropagation(),children:s.data?.event?(0,Z.jsx)(li,{tags:s.data.event.tags,children:c}):c})}),(0,Z.jsxs)(`span`,{className:G(`shrink-0`,s.isLoading&&`ml-1`),children:[u,d&&a&&(0,Z.jsxs)(Z.Fragment,{children:[` `,(0,Z.jsx)(K,{to:a,className:`hover:underline`,onClick:e=>e.stopPropagation(),children:d})]}),d&&!a&&(0,Z.jsxs)(Z.Fragment,{children:[` `,d]})]})]})]})}export{Ol as $,yd as A,qo as At,zu as B,zd as C,ds as Ct,Xd as D,ts as Dt,Gd as E,Zo as Et,sd as F,lu as G,Du as H,Qu as I,ql as J,ou as K,Gu as L,md as M,Oo as Mt,vd as N,to as Nt,Nd as O,Go as Ot,dd as P,no as Pt,Tl as Q,Wu as R,Qd as S,fs as St,Wd as T,Xo as Tt,_u as U,Pu as V,gu as W,Bl as X,Gl as Y,Rl as Z,Tf as _,Ks as _t,yp as a,fl as at,af as b,gs as bt,cp as c,Xc as ct,Uf as d,Bc as dt,Dl as et,Wf as f,Ic as ft,kf as g,$s as gt,Df as h,ec as ht,xp as i,hl as it,_d as j,Vo as jt,xd as k,Wo as kt,ip as l,Kc as lt,Rf as m,mc as mt,Xp as n,jl as nt,gp as o,al as ot,Bf as p,Mc as pt,ru as q,Lp as r,vl as rt,dp as s,el as st,Ep as t,Pl as tt,Gf as u,Gc as ut,Ef as v,Gs as vt,Yd as w,es as wt,nf as x,ps as xt,pf as y,Ss as yt,Uu as z};