// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later // @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlobbiStateCard-BzIlF1sW.js","assets/rolldown-runtime-QTnfLwEv.js","assets/lucide-icons-BdRF0moN.js","assets/jsx-runtime-By8HlURe.js","assets/utils-BFSTDHdM.js","assets/blobbi-CLChx8JU.js","assets/sha256-Cx9u8cje.js","assets/index-CYEZWNq6.js","assets/react-dom-YCZzGcHh.js","assets/useNip05Resolve-B9x4kFtR.js","assets/useQuery-rCAlChE8.js","assets/nostrId-DuqQCAdJ.js","assets/dist-DQ82bf9M.js","assets/esm-CRVqHnq2.js","assets/ErrorBoundary-DAm6b_mx.js","assets/preload-helper-CZgWQFsJ.js","assets/useMutation-CgsR0O-3.js","assets/useInfiniteQuery-BFtb_-3K.js","assets/useLocalStorage-DLDvi0Ge.js","assets/useAppContext-Ughdk2-Z.js","assets/useTheme-B8n3R7ig.js","assets/useEncryptedSettings-DPGHcvzd.js","assets/fetchFreshEvent-Kkz3MzZN.js","assets/useCurrentUser-C6OJJlWo.js","assets/dist-DQ_zK-Nr.js","assets/fontLoader-C8ZADbrS.js","assets/sanitizeUrl-Bk5f35GN.js","assets/useNostrPublish-CrMjnYm4.js","assets/react-intl-eZirkCBg.js","assets/useLanguage-yd3vEXqu.js","assets/credentialManager-Dv_8gYNN.js","assets/downloadFile-kpATXaJi.js","assets/encryptedFile-DKFYUsvG.js","assets/NewPostsPill-BQIcBVZE.js","assets/LayoutContext-CjQBLGO-.js","assets/dist-DEYuuXMO.js","assets/button-Cs26nq0r.js","assets/dist-CrweAx5r.js","assets/dist-BI-be9Ir.js","assets/useFollowActions-cve70R08.js","assets/appRelays-Clm5NPIe.js","assets/letterTypes-BLLFWtiN.js","assets/appBlossom-CsMDSd4h.js","assets/useBlossomFallback-DY_46Uqi.js","assets/avatar--oX_CTF4.js","assets/chunk-62JRHF6Z-yJW_vgm4.js","assets/CustomEmoji-DRcU63lJ.js","assets/customEmoji-kpim4Htm.js","assets/profileUrl-DpJiPx2H.js","assets/useProfileUrl-DoFhqUUR.js","assets/ExternalFavicon-BWUhHW7H.js","assets/useUserStatus-Bgu4AAxG.js","assets/haptics-Cp_uF-bV.js","assets/input-CM5Fnyvy.js","assets/dropdown-menu-ug3FLSAW.js","assets/dist-Bz2abD7M.js","assets/dist-BMrfXngQ.js","assets/dist-CxepVuy2.js","assets/dist-D9YQw-T8.js","assets/dist-wmZSqlsD.js","assets/dist-DTSySAaw.js","assets/dist-BeEGgqo9.js","assets/dist-B2RAV5d5.js","assets/dist-BsC49GML.js","assets/Combination-C1QBaE03.js","assets/usePortalContainer-mvErHojv.js","assets/popover-Dw5E1auH.js","assets/skeleton-CVls4GW9.js","assets/ProfileCard-Baz_I7BX.js","assets/BioContent-BjUPDB1O.js","assets/hashtag-DjDKS0mr.js","assets/FallbackImage-Dlnc8809.js","assets/parseAddr-BmO3JZWT.js","assets/collapsible-C12_mOsk.js","assets/dist-B6j_mgMi.js","assets/dist-CxcvWxxD.js","assets/dist-CpRh64jj.js","assets/dist-CX38Lmo0.js","assets/useAuthors-DHw1W6Un.js","assets/storageKey-Hu6452Ya.js","assets/useMuteList-uFe-Ok2F.js","assets/useLoginActions-CynKtWLl.js","assets/LoginFlow-Bd1W7T2S.js","assets/dist-DW2GM_Ig.js","assets/dialog-C3CFmras.js","assets/qrcode-DVi38FWW.js","assets/browser-B_X_RtOd.js","assets/useIsMobile-B6g4lnSy.js","assets/useShareOrigin-04gGNDPW.js","assets/alert-CY7M1xVR.js","assets/useUploadFile-BpPXwoE0.js","assets/safeNip19-CtQLwPmS.js","assets/useEventInteractions-Buyvdv_T.js","assets/nsiteSubdomain-DmdGxq_K.js","assets/ComposeDialogContent-YxhSZA-Y.js","assets/cards-DDSmTmb2.js","assets/WikipediaIcon-Dvm9f9D4.js","assets/BlueskyIcon-BZ9o1lYL.js","assets/tooltip-Ba63GpbC.js","assets/esplora-CScU9uce.js","assets/musicHelpers-B271Bg0t.js","assets/imeta-83Lqxs5-.js","assets/textarea-B93xm6Zg.js","assets/EmbeddedPost-Bb-ngBHS.js","assets/dist-D7z3WTXi.js","assets/useLinkPreview-CqNF97jn.js","assets/bitcoinMoney-CQsGrYK3.js","assets/countries-Du6BjHuX.js","assets/extraKinds-BydAXtVV.js","assets/sidebarItems-BFr7FKBa.js","assets/formatNumber-D1ols1S-.js","assets/formatTime-CT4ZmnVr.js","assets/useCustomEmojis-BRL1hilD.js","assets/useSearchProfiles-uU0NOVhy.js","assets/useFeedSettings-DkFDaYIY.js","assets/birthday-DHyHAOFk.js","assets/resizeImage-LOlp-rx5.js","assets/DecryptedImage-DLbW5kmn.js","assets/wikimedia-CCPyM-j2.js","assets/getDisplayName-B6lnEGRj.js","assets/optimisticEvent-1jcgWuWv.js","assets/useInView-DAJQSIvc.js","assets/NoteCard-COwLfrJJ.js","assets/timeAgo-BXjjbyXp.js","assets/packUtils-BzqQUARG.js","assets/relayList-BL1oPXvf.js","assets/memorycard-BpAZd6ha.js","assets/EmbeddedPublicationCard-DiFfM9Jf.js","assets/campaign-DRgHWLio.js","assets/quiz-kCjrdDeU.js","assets/badge-eEdLlpTp.js","assets/TarotReadingSection-DRLtYoI5.js","assets/card-CthSADjg.js","assets/TarotReadingSection-DBSfhNtE.css","assets/NoteMoreMenu-FwlS01AC.js","assets/label-BBIj2Nkw.js","assets/radio-group-DRkm3Stx.js","assets/dist-BEZkw2Ia.js","assets/dist-DjUhKbpW.js","assets/alert-dialog-n1eT_Aa8.js","assets/separator-CWY6Ovdb.js","assets/scroll-area-D2CmkWvj.js","assets/dist-C2J943E6.js","assets/useUserLists-zSWA8dQn.js","assets/useInteractionReaction-03diUK1e.js","assets/colorMomentUtils-VGseiWMP.js","assets/contentWarning-CNDzjeMP.js","assets/ContentWarningGuard-BQGV-Ggw.js","assets/useRelayInfo-CT_UT7Yl.js","assets/GitSiteLinks-CnSU1vGl.js","assets/TarotStars-D-jATuHd.js","assets/useOpenPost-DKpHsp1A.js","assets/switch-B6lxwP1L.js","assets/useRepostStatus-KJZve8_M.js","assets/useBitcoinSigner-CheBjN_q.js","assets/checkbox-CM1MZiSJ.js","assets/RepostMenu-CULlcQsd.js","assets/lib-D6JeXc-v.js","assets/lib-DhF-PQbN.js","assets/useTrending-DsL3v2RN.js","assets/vineGlobalMute-Du-DhONT.js","assets/SubHeaderBar-BYwNp4Nc.js","assets/useFeed-DtXzJkqY.js","assets/useMutedAuthorFilter-CTggZCaG.js","assets/usePageRefresh-BuJEOs2u.js","assets/index-poUxjvrc.css","assets/blobbi-shop-items-gin9pdH4.js","assets/BlobbiStageVisual-Cyhy_5-y.js","assets/purify.es-DCh266OY.js","assets/BlobbiStageVisual-ZqmrGSeZ.css","assets/useBlobbiInteractions-BR0C9tjk.js","assets/FloatingSocialHearts-ChoPyJfb.js","assets/bitcoin-DQZnWjqL.js","assets/silentPaymentsCore-DNoThJua.js"])))=>i.map(i=>d[i]); import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{An as t,Cr as n,Di as r,E as i,Fn as a,Fr as o,Gr as s,Hn as c,Ht as l,It as u,J as d,Jn as f,Mn as p,Mt as m,Ni as h,Ot as g,Qr as _,S as v,Si as y,Sr as b,Ut as x,V as S,Wn as C,Wr as w,Xr as T,Zt as E,_ as D,_i as O,_n as ee,_r as k,_t as A,a as j,ar as te,b as M,br as N,ci as ne,dr as re,dt as ie,ei as ae,en as oe,et as se,fn as ce,ft as le,gr as ue,hi as de,hr as fe,ir as pe,jr as me,jt as he,k as ge,li as _e,ln as ve,mn as ye,oi as be,on as xe,pt as Se,qi as Ce,qn as we,qr as Te,r as Ee,si as De,sn as Oe,ti as ke,ui as Ae,ur as je,ut as Me,v as Ne,w as Pe,y as Fe}from"./lucide-icons-BdRF0moN.js";import{t as Ie}from"./react-dom-YCZzGcHh.js";import{t as Le}from"./jsx-runtime-By8HlURe.js";import{t as Re}from"./ErrorBoundary-DAm6b_mx.js";import{t as ze}from"./preload-helper-CZgWQFsJ.js";import{f as Be,l as Ve,t as He,v as Ue}from"./dist-DQ82bf9M.js";import{_ as We,b as Ge,g as Ke,h as qe,i as Je,m as Ye,p as Xe,s as Ze,u as P,v as Qe}from"./esm-CRVqHnq2.js";import{a as $e,i as et,o as tt,t as nt}from"./sha256-Cx9u8cje.js";import{L as rt,N as it,a as at,c as ot,f as st,g as ct,h as lt,i as ut,l as dt,o as ft,p as pt,r as mt,s as ht,t as F,u as gt,y as _t}from"./useQuery-rCAlChE8.js";import{t as vt}from"./useMutation-CgsR0O-3.js";import{t as I}from"./useAppContext-Ughdk2-Z.js";import{L as yt,M as bt,R as xt,T as St,j as Ct,t as wt,w as Tt}from"./useTheme-B8n3R7ig.js";import{n as Et,r as L,t as Dt}from"./sanitizeUrl-Bk5f35GN.js";import{o as Ot,r as kt}from"./react-intl-eZirkCBg.js";import{t as At}from"./dist-DQ_zK-Nr.js";import{n as jt,s as Mt}from"./encryptedFile-DKFYUsvG.js";import{a as Nt,i as Pt,n as Ft}from"./downloadFile-kpATXaJi.js";import{t as It}from"./fetchFreshEvent-Kkz3MzZN.js";import{i as Lt,l as R,o as Rt,p as zt,s as Bt,t as Vt}from"./useCurrentUser-C6OJJlWo.js";import{t as z}from"./utils-BFSTDHdM.js";import{t as B}from"./button-Cs26nq0r.js";import{t as Ht}from"./useNostrPublish-CrMjnYm4.js";import{t as V}from"./nostrId-DuqQCAdJ.js";import{n as Ut}from"./useFollowActions-cve70R08.js";import{a as Wt,i as Gt}from"./letterTypes-BLLFWtiN.js";import{n as Kt}from"./appBlossom-CsMDSd4h.js";import{t as qt}from"./useBlossomFallback-DY_46Uqi.js";import{n as H,o as U,r as W,t as G}from"./avatar--oX_CTF4.js";import{c as K,n as q}from"./chunk-62JRHF6Z-yJW_vgm4.js";import{t as Jt}from"./customEmoji-kpim4Htm.js";import{t as Yt}from"./hashtag-DjDKS0mr.js";import{n as Xt,t as Zt}from"./CustomEmoji-DRcU63lJ.js";import{t as J}from"./useProfileUrl-DoFhqUUR.js";import{_ as Qt,a as $t,b as en,c as tn,g as nn,i as rn,n as an,r as Y,s as on,v as sn,y as cn}from"./BioContent-BjUPDB1O.js";import{t as ln}from"./FallbackImage-Dlnc8809.js";import{n as un,t as dn}from"./ExternalFavicon-BWUhHW7H.js";import{n as fn}from"./haptics-Cp_uF-bV.js";import{t as pn}from"./parseAddr-BmO3JZWT.js";import{n as mn,r as hn,t as gn}from"./collapsible-C12_mOsk.js";import{t as X}from"./skeleton-CVls4GW9.js";import{t as _n}from"./useAuthors-DHw1W6Un.js";import{t as vn}from"./storageKey-Hu6452Ya.js";import{n as yn,r as bn}from"./safeNip19-CtQLwPmS.js";import{a as xn,c as Sn,f as Cn,n as wn,p as Tn,r as En,s as Dn,t as On,u as kn}from"./useEventInteractions-Buyvdv_T.js";import{c as An}from"./nsiteSubdomain-DmdGxq_K.js";import{i as jn,n as Mn,t as Nn}from"./tooltip-Ba63GpbC.js";import{a as Pn,c as Fn,n as In,t as Ln}from"./dialog-C3CFmras.js";import{t as Rn}from"./timeAgo-BXjjbyXp.js";import{t as zn}from"./getDisplayName-B6lnEGRj.js";import{r as Bn,t as Vn}from"./letterUtils-ByLgglzi.js";import{r as Hn}from"./optimisticEvent-1jcgWuWv.js";import{i as Un,n as Wn,r as Gn,t as Kn}from"./useLinkPreview-CqNF97jn.js";import{n as qn,r as Jn,t as Yn}from"./packUtils-BzqQUARG.js";import{n as Xn,r as Zn}from"./relayList-BL1oPXvf.js";import{_ as Qn,h as $n,l as er,m as tr,o as nr,r as rr,s as ir}from"./memorycard-BpAZd6ha.js";import{r as ar,t as or}from"./EmbeddedArticleCard-DTHHB3Yi.js";import{t as sr}from"./articleHelpers-Dhr_Z8YP.js";import{o as cr,t as lr}from"./EmbeddedPublicationCard-DiFfM9Jf.js";import{g as ur,n as dr,u as fr}from"./bitcoinMoney-CQsGrYK3.js";import{t as pr}from"./countries-Du6BjHuX.js";import{o as mr}from"./campaign-DRgHWLio.js";import{c as hr,u as gr}from"./quiz-kCjrdDeU.js";import{c as _r,o as vr,u as yr}from"./extraKinds-BydAXtVV.js";import{t as br}from"./badge-eEdLlpTp.js";import{f as xr,l as Sr}from"./cards-DDSmTmb2.js";import{t as Cr}from"./TarotReadingSection-DRLtYoI5.js";import{t as wr}from"./formatNumber-D1ols1S-.js";import{t as Tr}from"./browser-B_X_RtOd.js";import{i as Er,n as Dr,o as Or,r as kr}from"./imeta-83Lqxs5-.js";import{t as Ar}from"./formatTime-CT4ZmnVr.js";import{t as jr}from"./browser-C1AyMpfR.js";import{s as Mr}from"./LayoutContext-CjQBLGO-.js";import{t as Nr}from"./useInView-DAJQSIvc.js";import{t as Pr}from"./useCustomEmojis-BRL1hilD.js";function Fr(e,t){return e.filter(e=>!t.includes(e))}function Ir(e,t,n){let r=e.slice(0);return r[t]=n,r}var Lr=class extends rt{#e;#t;#n;#r;#i;#a;#o;#s;#c=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,_t.batch(()=>{let e=this.#i,t=this.#d(this.#n);this.#c=t,t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=n.some((t,n)=>t!==e[n]);e.length===n.length&&!i||(this.#i=n,this.#t=r,this.hasListeners()&&(Fr(e,n).forEach(e=>{e.destroy()}),Fr(n,e).forEach(e=>{e.subscribe(t=>{this.#f(e,t)})}),this.#p()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#d(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions));return[r,e=>this.#u(e??r,t),()=>this.#l(r,n)]}#l(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#u(e,t){return t?((!this.#a||this.#t!==this.#s||t!==this.#o)&&(this.#o=t,this.#s=this.#t,this.#a=it(this.#a,t(e))),this.#a):e}#d(e){let t=new Map(this.#i.map(e=>[e.options.queryHash,e])),n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash);i?n.push({defaultedQueryOptions:r,observer:i}):n.push({defaultedQueryOptions:r,observer:new ct(this.#e,r)})}),n}#f(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Ir(this.#t,n,t),this.#p())}#p(){if(this.hasListeners()){let e=this.#a,t=this.#l(this.#t,this.#c);e!==this.#u(t,this.#r?.combine)&&_t.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},Z=e(Ce(),1);function Rr({queries:e,...t},n){let r=lt(n),i=pt(),a=st(),o=Z.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{mt(e),ht(e,a)}),dt(a);let[s]=Z.useState(()=>new Lr(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;Z.useSyncExternalStore(Z.useCallback(e=>d?s.subscribe(_t.batchCalls(e)):gt,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),Z.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>at(o[t],e))?c.flatMap((e,t)=>{let n=o[t];if(n){let t=new ct(r,n);if(at(n,e))return ut(n,t,a);ft(e,i)&&ut(n,t,a)}return[]}):[];if(f.length>0)throw Promise.all(f);let p=c.find((e,t)=>{let n=o[t];return n&&ot({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(p?.error)throw p.error;return l(u())}var zr={id:`data-highlight-id`,pubkey:`data-highlight-pubkey`,kind:`data-highlight-kind`,addr:`data-highlight-addr`};function Br(e){if(!e||!V(e.id)||!V(e.pubkey))return{};let t={[zr.id]:e.id,[zr.pubkey]:e.pubkey,[zr.kind]:String(e.kind)};if(Be.replaceable(e.kind)||Be.addressable(e.kind)){let n=e.tags.find(([e])=>e===`d`)?.[1]??``;t[zr.addr]=`${e.kind}:${e.pubkey}:${Be.addressable(e.kind)?n:``}`}return t}function Vr(e){if(!e)return;let t=e.getAttribute(zr.id),n=e.getAttribute(zr.pubkey),r=e.getAttribute(zr.kind);if(!t||!n||!r||!V(t)||!V(n))return;let i=Number(r);if(Number.isInteger(i))return{id:t,pubkey:n,kind:i,addr:e.getAttribute(zr.addr)??void 0}}function Hr(e){let t=e instanceof Element?e:e?.parentElement??null;for(;t;){let e=Vr(t);if(e)return e;t=t.parentElement}}function Ur(e,t){let n=[];return e.addr?n.push([`a`,e.addr]):n.push([`e`,e.id]),n.push([`p`,e.pubkey,``,`author`]),t&&n.push([`context`,t]),n.push([`alt`,`Highlight`]),n}var Q=Le();function Wr({compact:e=!1,className:t}){return(0,Q.jsx)(`div`,{className:z(`rounded-2xl border border-dashed border-border`,e?`mt-1`:`mt-2`,t),children:(0,Q.jsxs)(`div`,{className:z(`flex flex-col items-center justify-center gap-2 text-center text-muted-foreground`,e?`px-3 py-3 text-xs`:`px-3.5 py-4 text-sm`),children:[(0,Q.jsx)(te,{className:z(e?`size-4`:`size-5`),"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:`This post could not be displayed`})]})})}function $({pubkey:e,createdAt:t,navigateTo:n,className:r,disableHoverCards:i,children:a}){let o=K(),s=R(e),c=s.data?.metadata,l=U(c),u=c?.name||c?.display_name||`Anonymous`,d=J(e,c);return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,r),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),o(`/${n}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),o(`/${n}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[s.isLoading?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{className:`size-5 rounded-full shrink-0`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gr,{pubkey:e,disabled:i,children:(0,Q.jsx)(q,{to:d,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:l,className:`size-5`,children:[(0,Q.jsx)(W,{src:c?.picture,alt:u}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[10px]`,children:u[0]?.toUpperCase()})]})})}),(0,Q.jsx)(Gr,{pubkey:e,disabled:i,children:(0,Q.jsx)(q,{to:d,className:`text-sm font-semibold truncate hover:underline min-w-0`,onClick:e=>e.stopPropagation(),children:s.data?.event?(0,Q.jsx)(Xt,{tags:s.data.event.tags,children:u}):u})})]}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,Rn(t)]})]}),a]})})}function Gr({pubkey:e,disabled:t,children:n}){return t?(0,Q.jsx)(Q.Fragment,{children:n}):(0,Q.jsx)(Y,{pubkey:e,asChild:!0,children:n})}function Kr(e){switch(e){case 1617:return{icon:fe,label:`Patch`,iconClassName:`text-orange-500 dark:text-orange-400`};case 1618:return{icon:we,label:`Pull request`,iconClassName:`text-emerald-600 dark:text-emerald-400`};case 1619:return{icon:f,label:`Pull request update`,iconClassName:`text-emerald-600 dark:text-emerald-400`};case 1621:return{icon:_,label:`Issue`,iconClassName:`text-green-600 dark:text-green-400`};case 1630:return{icon:_,label:Tn(e),iconClassName:`text-green-600 dark:text-green-400`};case 1631:return{icon:ke,label:Tn(e),iconClassName:`text-purple-600 dark:text-purple-400`};case 1632:return{icon:T,label:Tn(e),iconClassName:`text-red-600 dark:text-red-400`};default:return{icon:ae,label:Tn(e),iconClassName:`text-muted-foreground`}}}function qr({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),{icon:i,label:a,iconClassName:o}=Kr(e.kind),s=kn(e)?.identifier,c=e.kind>=1630&&e.kind<=1633,l=e.kind===1619||c?e.content.split(` `)[0]?.trim():Cn(e);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:r,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(i,{className:`size-3 ${o}`}),a]}),l&&(0,Q.jsx)(`p`,{className:`mt-1 text-sm font-medium leading-snug line-clamp-2 break-words`,children:l}),s&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground font-mono truncate`,children:s})]})}function Jr({event:e,className:t,timestamp:n}){let r=(0,Z.useMemo)(()=>P.npubEncode(e.pubkey),[e.pubkey]),i=e.tags.some(([e,t])=>e===`relay`&&t===`ALL_RELAYS`),a=e.content||void 0;return(0,Q.jsxs)(`div`,{className:z(`rounded-xl border-2 border-red-500/30 overflow-hidden`,t),children:[(0,Q.jsx)(`div`,{className:`vanish-stripes h-1.5`}),(0,Q.jsxs)(`div`,{className:`px-3 py-2.5 bg-red-500/[0.04] dark:bg-red-500/[0.06] space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Q.jsx)(`div`,{className:`size-8 rounded-full bg-red-500/10 border border-red-500/30 flex items-center justify-center`,children:(0,Q.jsx)(`span`,{className:`text-sm font-black vanish-glitch-text text-red-500 dark:text-red-400`,"data-text":`///`,children:`///`})}),(0,Q.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 size-3.5 rounded-full bg-red-600 flex items-center justify-center`,children:(0,Q.jsx)(`span`,{className:`text-[7px] font-black text-white leading-none`,children:`!`})})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-bold text-red-500 dark:text-red-400 leading-tight`,children:i?`Global Request to Vanish`:`Request to Vanish`}),(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground font-mono truncate mt-0.5`,children:r})]}),n&&(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground shrink-0`,children:n})]}),a&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic line-clamp-2 pl-[42px]`,children:[`“`,a,`”`]})]}),(0,Q.jsx)(`div`,{className:`vanish-stripes h-1.5`})]})}function Yr({event:e,compact:t}){if(t)return(0,Q.jsx)(Jr,{event:e,className:`mt-2`});let n=P.npubEncode(e.pubkey),r=e.tags.filter(([e])=>e===`relay`),i=r.some(([,e])=>e===`ALL_RELAYS`),a=r.map(([,e])=>e).filter(e=>e!==`ALL_RELAYS`),o=e.content||void 0,s=new Date(e.created_at*1e3).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0});return(0,Q.jsxs)(`div`,{className:`mt-4 space-y-0`,children:[(0,Q.jsx)(`div`,{className:`vanish-stripes h-3 rounded-t-xl`}),(0,Q.jsxs)(`div`,{className:`relative border-x-2 border-red-500/30 bg-gradient-to-b from-red-500/[0.06] to-red-500/[0.02] dark:from-red-500/[0.08] dark:to-red-500/[0.03] px-5 py-6 overflow-hidden isolate`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03] dark:opacity-[0.05] -z-10 pointer-events-none`,style:{backgroundImage:`repeating-linear-gradient(45deg, currentColor 0, currentColor 1px, transparent 0, transparent 50%)`,backgroundSize:`12px 12px`}}),(0,Q.jsx)(`div`,{className:`flex justify-center mb-5`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-red-500/20 vanish-ring-pulse`}),(0,Q.jsx)(`div`,{className:`absolute -inset-2 rounded-full border border-red-500/10 vanish-ring-pulse-delayed`}),(0,Q.jsx)(`div`,{className:`relative size-16 rounded-full bg-red-500/10 border-2 border-red-500/40 flex items-center justify-center shadow-lg shadow-red-500/10`,children:(0,Q.jsx)(`span`,{className:`text-2xl font-black vanish-glitch-text text-red-500 dark:text-red-400`,"data-text":`///`,children:`///`})}),(0,Q.jsx)(`div`,{className:`absolute -bottom-1 -right-1 size-6 rounded-full bg-red-600 border-2 border-background flex items-center justify-center shadow-md`,children:(0,Q.jsx)(`span`,{className:`text-xs font-black text-white leading-none`,children:`!`})})]})}),(0,Q.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-black tracking-tight text-red-500 dark:text-red-400 uppercase`,children:i?`Global Request to Vanish`:`Request to Vanish`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed max-w-sm mx-auto`,children:i?`This identity has requested permanent erasure from all Nostr relays.`:`This identity has requested permanent erasure from ${a.length} relay${a.length===1?``:`s`}.`})]}),(0,Q.jsxs)(`div`,{className:`mt-5 rounded-lg border border-red-500/20 bg-red-500/[0.04] dark:bg-red-500/[0.06] p-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground uppercase tracking-wider font-bold`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-full bg-red-500 vanish-blink`}),(0,Q.jsx)(`span`,{children:`Identity`})]}),(0,Q.jsx)(`p`,{className:`font-mono text-xs text-foreground/80 break-all leading-relaxed select-all`,children:n})]}),o&&(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg border border-border/50 bg-background/50 p-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground uppercase tracking-wider font-bold mb-2`,children:`Final words`}),(0,Q.jsxs)(`blockquote`,{className:`text-sm text-foreground/80 italic leading-relaxed pl-3 border-l-2 border-red-500/40`,children:[`“`,o,`”`]})]}),!i&&a.length>0&&(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg border border-border/50 bg-background/50 p-4`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground uppercase tracking-wider font-bold mb-2`,children:`Target relays`}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:a.map(e=>(0,Q.jsx)(`p`,{className:`font-mono text-xs text-foreground/70`,children:e},e))})]}),(0,Q.jsx)(`p`,{className:`text-center text-xs text-muted-foreground mt-5`,children:s})]}),(0,Q.jsx)(`div`,{className:`vanish-stripes h-3 rounded-b-xl`})]})}function Xr({pubkey:e}){let t=R(e),n=t.data?.metadata,r=U(n),i=zn(n,e),a=J(e,n);return t.isLoading?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(X,{className:`size-10 rounded-full`}),(0,Q.jsx)(X,{className:`h-3 w-14`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(Y,{pubkey:e,asChild:!0,children:(0,Q.jsx)(q,{to:a,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:r,className:`size-10 ring-2 ring-background shadow-md`,children:[(0,Q.jsx)(W,{src:n?.picture,alt:i}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-xs font-semibold`,children:i[0]?.toUpperCase()})]})})}),(0,Q.jsx)(Y,{pubkey:e,asChild:!0,children:(0,Q.jsx)(q,{to:a,onClick:e=>e.stopPropagation(),className:`text-xs font-medium text-foreground/80 hover:text-foreground truncate max-w-[80px] transition-colors`,children:i})})]})}function Zr({event:e,compact:t,className:n}){let r=e.tags.find(([e])=>e===`p`)?.[1],i=zn(R(e.pubkey).data?.metadata,e.pubkey);return r?(0,Q.jsx)(`div`,{className:z(`mt-2`,n),children:(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-border px-5 py-4`,children:[(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground text-center mb-3`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:i}),` sent a direct message`]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,Q.jsx)(Xr,{pubkey:e.pubkey}),(0,Q.jsxs)(`div`,{className:`flex-1 flex items-center justify-center min-w-0 max-w-[180px] relative`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-x-0 top-1/2 -translate-y-1/2 h-px border-t-2 border-dashed border-foreground/15`}),(0,Q.jsx)(`div`,{className:`relative z-10 flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`size-9 rounded-full bg-background border-2 border-foreground/10 flex items-center justify-center shadow-sm`,children:(0,Q.jsx)(ce,{className:`size-4 text-muted-foreground`})})})]}),(0,Q.jsx)(Xr,{pubkey:r})]})]})}):(0,Q.jsx)(`div`,{className:z(`mt-2 px-4 py-3`,n),children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Encrypted message (no recipient found)`})})}function Qr({event:e,className:t}){let n=K(),r=R(e.pubkey),i=r.data?.metadata,a=U(i),o=i?.name||i?.display_name||`Anonymous`,s=e.tags.find(([e])=>e===`p`)?.[1],c=R(s??``),l=s?zn(c.data?.metadata,s):void 0,u=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),d=J(e.pubkey,i);return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),n(`/${u}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),n(`/${u}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2 space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[r.isLoading?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{className:`size-5 rounded-full shrink-0`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{pubkey:e.pubkey,asChild:!0,children:(0,Q.jsx)(q,{to:d,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:a,className:`size-5`,children:[(0,Q.jsx)(W,{src:i?.picture,alt:o}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[10px]`,children:o[0]?.toUpperCase()})]})})}),(0,Q.jsx)(Y,{pubkey:e.pubkey,asChild:!0,children:(0,Q.jsx)(q,{to:d,className:`text-sm font-semibold truncate hover:underline`,onClick:e=>e.stopPropagation(),children:o})})]}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,Rn(e.created_at)]})]}),(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,Q.jsx)(ce,{className:`size-3.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Sent a direct message`,l?(0,Q.jsxs)(Q.Fragment,{children:[` to `,(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:l})]}):``]})]})]})})}var $r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,ei=Array.from({length:64},(e,t)=>String.fromCodePoint(110960+t)),ti=new Map($r.split(``).map((e,t)=>[e,ei[t]]));function ni(e,t=36){let n=e.replace(/[\s=]/g,``),r=[],i=Math.max(1,Math.floor(n.length/t));for(let e=0;ee.stopPropagation(),className:`font-semibold truncate hover:underline transition-colors`,style:{fontFamily:`'Caveat', 'Pacifico', cursive`,fontSize:s},children:a})})]})}function ii({pubkey:e}){let t=R(e).data?.metadata,n=zn(t,e),r=U(t);return(0,Q.jsx)(Y,{pubkey:e,asChild:!0,children:(0,Q.jsx)(q,{to:J(e,t),onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:r,className:`size-12 ring-2 ring-amber-900/30 shadow-lg`,children:[(0,Q.jsx)(W,{src:t?.picture,alt:n}),(0,Q.jsx)(H,{className:`bg-amber-900/20 text-amber-900 text-sm font-bold`,children:n[0]?.toUpperCase()})]})})})}function ai({event:e,compact:t,className:n}){let[r,i]=(0,Z.useState)(`back`),a=e.tags.find(([e])=>e===`p`)?.[1],o=e.pubkey,s=(0,Z.useMemo)(()=>ni(e.content,t?20:36),[e.content,t]),c=en(18,1.03,800),l=(0,Z.useCallback)(()=>{if(t){i(e=>e===`back`?`front`:`back`);return}i(e=>e===`back`?`front`:e===`front`?`open`:`back`)},[t]);if(!a)return(0,Q.jsx)(`div`,{className:z(`mt-2 px-4 py-3`,n),children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Encrypted letter (no recipient found)`})});let u=r===`front`||r===`open`,d=r===`open`;return(0,Q.jsx)(`div`,{className:z(`mt-3`,n),children:(0,Q.jsx)(`div`,{className:z(`mx-auto`,t?`max-w-sm px-2`:`max-w-md px-4`),children:(0,Q.jsx)(`div`,{ref:c.ref,style:{...c.style,touchAction:`pan-y`},onPointerDown:c.onPointerDown,onPointerMove:c.onPointerMove,onPointerUp:c.onPointerUp,onPointerLeave:c.onPointerLeave,children:(0,Q.jsx)(`div`,{className:`cursor-pointer select-none`,style:{perspective:`1200px`},onClick:l,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l())},"aria-label":r===`back`?`Envelope back — click to flip to the front`:r===`front`?`Sealed envelope — click to open the flap`:`Encrypted letter — click to close`,children:(0,Q.jsxs)(`div`,{className:`relative w-full transition-transform duration-700 ease-in-out`,style:{transformStyle:`preserve-3d`,transform:u?`rotateY(180deg)`:`rotateY(0deg)`,aspectRatio:t?`16 / 9`:`4 / 3`},children:[(0,Q.jsxs)(`div`,{className:`absolute inset-0 rounded-2xl overflow-hidden shadow-lg`,style:{backfaceVisibility:`hidden`},children:[(0,Q.jsx)(`div`,{className:`absolute inset-0`,style:{background:`linear-gradient(145deg, #F5E6D3 0%, #E8D5BF 40%, #D4C4AA 100%)`}}),(0,Q.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)'/%3E%3C/svg%3E")`}}),(0,Q.jsx)(`div`,{className:`absolute top-3 left-4`,style:{color:`#5C4A3A`},children:(0,Q.jsx)(ri,{pubkey:o,size:`sm`})}),(0,Q.jsx)(`div`,{className:`absolute left-1/2 -translate-x-1/2`,style:{top:`50%`,transform:`translate(-50%, -50%)`,color:`#5C4A3A`},children:(0,Q.jsx)(ri,{pubkey:a,size:`lg`})}),(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-2xl pointer-events-none`,style:{boxShadow:`inset 0 2px 4px rgba(255,255,255,0.3), inset 0 -2px 8px rgba(0,0,0,0.08)`}})]}),(0,Q.jsxs)(`div`,{className:`absolute inset-0 rounded-2xl overflow-hidden shadow-lg`,style:{backfaceVisibility:`hidden`,transform:`rotateY(180deg)`},children:[(0,Q.jsx)(`div`,{className:`absolute inset-0`,style:{background:`linear-gradient(145deg, #EDD9C3 0%, #E0CCAF 50%, #D0BC9C 100%)`}}),(0,Q.jsx)(`div`,{className:`absolute inset-0 opacity-[0.03]`,style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)'/%3E%3C/svg%3E")`}}),(0,Q.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none`,viewBox:`0 0 400 300`,preserveAspectRatio:`none`,style:{zIndex:1},children:[(0,Q.jsx)(`path`,{d:`M0,300 L200,160`,stroke:`#C4A882`,strokeWidth:`1`,fill:`none`,opacity:`0.25`}),(0,Q.jsx)(`path`,{d:`M400,300 L200,160`,stroke:`#C4A882`,strokeWidth:`1`,fill:`none`,opacity:`0.25`})]}),(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 right-0 transition-transform duration-500 ease-in-out`,style:{zIndex:2,transformOrigin:`top center`,transform:d?`rotateX(180deg)`:`rotateX(0deg)`},children:(0,Q.jsxs)(`svg`,{viewBox:`0 0 400 200`,className:`w-full`,preserveAspectRatio:`none`,children:[(0,Q.jsx)(`defs`,{children:(0,Q.jsxs)(`linearGradient`,{id:`flap-front`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,Q.jsx)(`stop`,{offset:`0%`,stopColor:`#EDD9C3`}),(0,Q.jsx)(`stop`,{offset:`100%`,stopColor:`#E0CCAF`})]})}),(0,Q.jsx)(`path`,{d:`M0,0 L200,180 L400,0 L400,0 L0,0 Z`,fill:`url(#flap-front)`}),(0,Q.jsx)(`path`,{d:`M0,0 L200,180 L400,0`,fill:`none`,stroke:`#B5A48A`,strokeWidth:`1`,opacity:`0.4`})]})}),(0,Q.jsx)(`div`,{className:`absolute left-1/2 transition-opacity duration-300`,style:{zIndex:3,top:`50%`,transform:`translate(-50%, -50%)`,opacity:+!d},children:(0,Q.jsx)(`div`,{className:`rounded-full flex items-center justify-center`,style:{width:t?48:64,height:t?48:64,background:`radial-gradient(ellipse at 35% 30%, #d4524d 0%, #a52422 50%, #7a1a19 100%)`,boxShadow:`0 4px 12px rgba(122, 26, 25, 0.4), inset 0 2px 4px rgba(255,255,255,0.15), inset 0 -2px 4px rgba(0,0,0,0.2)`},children:(0,Q.jsx)(ii,{pubkey:o})})}),(0,Q.jsx)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center transition-all duration-500`,style:{zIndex:d?4:0,opacity:+!!d,transform:d?`translateY(-8px)`:`translateY(20px)`},children:(0,Q.jsxs)(`div`,{className:`rounded-lg mx-4 p-5 max-h-[85%] flex flex-col`,style:{background:`linear-gradient(180deg, #FDFAF5 0%, #F8F0E5 100%)`,boxShadow:`0 2px 12px rgba(0,0,0,0.1)`,width:`calc(100% - 2rem)`},children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto relative`,children:[(0,Q.jsx)(`p`,{className:`text-center select-none`,style:{fontFamily:`'Noto Sans Nushu', serif`,fontSize:t?`1rem`:`1.25rem`,color:`#3A2E26`,lineHeight:2.2,letterSpacing:`0.25em`},"aria-label":`Encrypted content rendered as Nushu script`,children:s}),(0,Q.jsx)(`div`,{className:`sticky bottom-0 left-0 right-0 h-8 pointer-events-none`,style:{background:`linear-gradient(transparent, #F8F0E5)`}})]}),(0,Q.jsx)(`div`,{className:`mx-auto mt-2 shrink-0`,style:{width:`40%`,height:1,background:`linear-gradient(90deg, transparent, #C4A882, transparent)`}}),(0,Q.jsxs)(`p`,{className:`flex items-center justify-center gap-1.5 mt-2 text-xs shrink-0`,style:{color:`#8B7355`},children:[(0,Q.jsx)(ye,{className:`size-3`}),`This message is encrypted`]})]})}),(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-2xl pointer-events-none`,style:{boxShadow:`inset 0 2px 4px rgba(255,255,255,0.2), inset 0 -2px 8px rgba(0,0,0,0.06)`}})]})]})})})})})}function oi({event:e,className:t}){let n=K(),r=R(e.pubkey),i=r.data?.metadata,a=U(i),o=i?.name||i?.display_name||`Anonymous`,s=e.tags.find(([e])=>e===`p`)?.[1],c=R(s??``),l=s?zn(c.data?.metadata,s):void 0,u=J(e.pubkey,i),d=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]);return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),n(`/${d}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),n(`/${d}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:r.isLoading?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{className:`size-5 rounded-full shrink-0`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{pubkey:e.pubkey,asChild:!0,children:(0,Q.jsx)(q,{to:u,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:a,className:`size-5`,children:[(0,Q.jsx)(W,{src:i?.picture,alt:o}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[10px]`,children:o[0]?.toUpperCase()})]})})}),(0,Q.jsx)(Y,{pubkey:e.pubkey,asChild:!0,children:(0,Q.jsx)(q,{to:u,className:`text-sm font-semibold truncate hover:underline`,onClick:e=>e.stopPropagation(),children:o})})]})}),(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,Q.jsx)(ce,{className:`size-3.5 shrink-0`}),(0,Q.jsxs)(`span`,{children:[`Sent a letter`,l?(0,Q.jsxs)(Q.Fragment,{children:[` to `,(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:l})]}):``]})]})]})})}var si=15683,ci=`Love list: the people this user truly loves`;function li(e){if(!e)return[];let t=new Set,n=[];for(let[r,i]of e.tags)r===`p`&&i&&V(i)&&!t.has(i)&&(t.add(i),n.push(i));return n}function ui(e){return vn(e,`loveListCache`)}function di(e,t){try{let n=localStorage.getItem(e);if(!n)return;let r=JSON.parse(n);return r.pubkey!==t||!Array.isArray(r.pubkeys)?void 0:r.pubkeys.filter(e=>typeof e==`string`&&V(e))}catch{return}}function fi(e,t,n){try{localStorage.setItem(ui(e),JSON.stringify({pubkey:t,pubkeys:n}))}catch{}}function pi(){let{nostr:e}=He(),{user:t}=Vt(),{config:n}=I(),r=lt(),{mutateAsync:i}=Ht(),{store:a}=zt(),o=ui(n.appId),s=t?.pubkey,c=(0,Z.useMemo)(()=>s?di(o,s):void 0,[o,s]),l=(0,Z.useMemo)(()=>c?{event:null,pubkeys:c}:void 0,[c]),u=F({queryKey:[`love-list`,t?.pubkey??``],queryFn:async()=>{if(!t)return{event:null,pubkeys:[]};try{let r=await It(e,{kinds:[si],authors:[t.pubkey]},{store:a}),i=li(r);return fi(n.appId,t.pubkey,i),{event:r??null,pubkeys:i}}catch{return{event:null,pubkeys:c??[]}}},enabled:!!t,staleTime:300*1e3,placeholderData:l}),d=u.data?.pubkeys;function f(e){return d?.includes(e)??!1}async function p(r,o){if(!t)throw Error(`User is not logged in`);let s=await It(e,{kinds:[si],authors:[t.pubkey]},{store:a}),c=s?.tags??[],l=c.filter(([e])=>e===`p`),u=c.filter(([e])=>e!==`p`&&e!==`alt`),d;d=o===`add`?l.some(([,e])=>e===r)?l:[...l,[`p`,r]]:l.filter(([,e])=>e!==r);let f=await i({kind:si,content:s?.content??``,tags:[...u,[`alt`,ci],...d],created_at:Math.floor(Date.now()/1e3),prev:s??void 0});return a.event(f),fi(n.appId,t.pubkey,li(f)),f}let m=[`love-list`,t?.pubkey??``],h=e=>{r.setQueryData(m,{event:e,pubkeys:li(e)}),r.invalidateQueries({queryKey:[`feed`]})};function g(e,t){let n=r.getQueryData(m),i=n?.pubkeys??[],a=t===`add`?i.includes(e)?i:[...i,e]:i.filter(t=>t!==e);return r.setQueryData(m,{event:n?.event??null,pubkeys:a}),n}let _=vt({mutationFn:e=>p(e,`add`),onMutate:e=>({snapshot:g(e,`add`)}),onError:(e,t,n)=>{Hn(r,m,n?.snapshot)},onSuccess:h}),v=vt({mutationFn:e=>p(e,`remove`),onMutate:e=>({snapshot:g(e,`remove`)}),onError:(e,t,n)=>{Hn(r,m,n?.snapshot)},onSuccess:h});return{loveList:u.data?.event??null,lovedPubkeys:d,isLoading:u.isLoading,isLoved:f,addLove:_,removeLove:v}}var mi=Gt[0].family,hi=8,gi=4,_i=`url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)'/%3E%3C/svg%3E")`,vi=`#f283b4`,yi=`#d9518f`,bi=`#a52e68`,xi=`#b03a72`,Si=` radial-gradient(ellipse at 35% 30%, rgba(255,255,255,0.22) 0%, transparent 50%), radial-gradient(ellipse at 65% 70%, rgba(0,0,0,0.14) 0%, transparent 50%), radial-gradient(circle at 50% 50%, ${vi} 0%, ${yi} 55%, ${bi} 100%) `,Ci=`M42 3 C50 2, 58 7, 64 13 C69 18, 76 24, 78 33 C80 41, 82 48, 77 56 C73 62, 66 70, 56 73 C48 76, 40 78, 32 74 C24 71, 14 66, 9 58 C5 50, 2 42, 4 34 C6 26, 12 18, 19 12 C26 6, 34 4, 42 3 Z`,wi=Wt.find(e=>e.id===`hearts`),Ti=28,Ei=`#F0699F`,Di=[{style:{top:`-0.75rem`,right:`-0.75rem`},size:`size-20`,rotate:`rotate-12`,opacity:.12},{style:{top:`18%`,left:`-1rem`},size:`size-14`,rotate:`-rotate-[18deg]`,opacity:.09},{style:{top:`36%`,right:`8%`},size:`size-9`,rotate:`rotate-[24deg]`,opacity:.1},{style:{top:`6%`,left:`34%`},size:`size-7`,rotate:`-rotate-6`,opacity:.09},{style:{top:`12%`,right:`28%`},size:`size-6`,rotate:`rotate-[16deg]`,opacity:.08},{style:{top:`52%`,left:`6%`},size:`size-8`,rotate:`rotate-[8deg]`,opacity:.09},{style:{top:`48%`,left:`58%`},size:`size-6`,rotate:`-rotate-[22deg]`,opacity:.08},{style:{bottom:`26%`,right:`-0.75rem`},size:`size-16`,rotate:`-rotate-[14deg]`,opacity:.1},{style:{bottom:`8%`,left:`14%`},size:`size-10`,rotate:`-rotate-12`,opacity:.11},{style:{bottom:`-1rem`,right:`32%`},size:`size-16`,rotate:`rotate-[20deg]`,opacity:.08},{style:{top:`72%`,left:`44%`},size:`size-7`,rotate:`rotate-[30deg]`,opacity:.08},{style:{bottom:`14%`,right:`12%`},size:`size-7`,rotate:`rotate-6`,opacity:.09}],Oi=[{left:`18%`,size:`size-5`,opacity:.5,sway:16,duration:7,delay:0},{left:`46%`,size:`size-4`,opacity:.4,sway:-14,duration:8.5,delay:2.4},{left:`68%`,size:`size-6`,opacity:.45,sway:20,duration:6.5,delay:4.2},{left:`84%`,size:`size-4`,opacity:.35,sway:-12,duration:9,delay:1.2}];function ki({pubkey:e,compact:t}){let n=R(e),r=n.data?.metadata,i=zn(r,e),o=U(r),s=J(e,r);return(0,Q.jsxs)(`li`,{className:z(`relative flex items-center gap-3 min-w-0`,t?`py-2`:`py-2.5`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`absolute bottom-0 left-0 right-0 h-[3px] rounded-full pointer-events-none`,style:{background:`rgba(196, 134, 134, 0.3)`}}),(0,Q.jsx)(a,{"aria-hidden":!0,className:z(`shrink-0`,t?`size-4`:`size-[18px]`),style:{color:`#C0392B`,fill:`#E74C3C`}}),n.isLoading?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{className:z(`rounded-full shrink-0`,t?`size-7`:`size-8`)}),(0,Q.jsx)(X,{className:`h-5 w-28`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{pubkey:e,asChild:!0,children:(0,Q.jsx)(q,{to:s,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:o,className:z(t?`size-7`:`size-8`,`ring-1 ring-[#C48686]/40`),children:[(0,Q.jsx)(W,{src:r?.picture,alt:i}),(0,Q.jsx)(H,{className:`bg-[#E74C3C]/15 text-[#A93226] text-xs font-bold`,children:i[0]?.toUpperCase()})]})})}),(0,Q.jsx)(Y,{pubkey:e,asChild:!0,children:(0,Q.jsx)(q,{to:s,onClick:e=>e.stopPropagation(),className:`truncate hover:underline decoration-[#C0392B]/50`,style:{fontFamily:mi,fontSize:t?`1.5rem`:`1.7rem`,lineHeight:1.2,color:`#6B3A3A`},children:i})})]})]})}function Ai({event:e,compact:t,className:n}){let r=(0,Z.useMemo)(()=>li(e),[e]),i=(0,Z.useId)();Vn(mi);let o=t?gi:hi,s=r.slice(0,o),c=r.length-s.length;return r.length===0?(0,Q.jsx)(`div`,{className:z(`mt-2 px-4 py-3`,n),children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`An empty love list — hearts yet to be written.`})}):(0,Q.jsx)(`div`,{className:z(`mt-3`,n),children:(0,Q.jsx)(`div`,{className:`w-full rounded-[2rem] shadow-md motion-safe:transition-shadow motion-safe:duration-300 hover:shadow-lg`,style:{padding:Ti},children:(0,Q.jsxs)(`div`,{className:`relative isolate`,children:[wi?.emojis&&(0,Q.jsx)(Bn,{tint:Ei,thickness:Ti,emojis:wi.emojis,defaultBg:Ei,scatter:!0,keepDefaultBg:!0}),(0,Q.jsxs)(`div`,{className:`relative rounded-2xl overflow-hidden`,style:{background:`linear-gradient(165deg, #FFF8F0 0%, #FDEFE6 55%, #F9E3DC 100%)`},children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 opacity-[0.04] pointer-events-none`,style:{backgroundImage:_i}}),(0,Q.jsx)(`div`,{className:`absolute inset-3 rounded-xl pointer-events-none`,style:{border:`2.5px dashed rgba(192, 57, 43, 0.4)`}}),Di.map((e,t)=>(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`absolute pointer-events-none motion-safe:animate-heart-drift`,style:{...e.style,animationDelay:`${t%4*.5}s`,animationDuration:`${4+t%3}s`},children:(0,Q.jsx)(a,{className:z(`block`,e.size,e.rotate),style:{color:`#E74C3C`,fill:`#E74C3C`,opacity:e.opacity}})},t)),Oi.map((e,t)=>(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`absolute pointer-events-none motion-safe:animate-heart-float`,style:{left:e.left,animationDelay:`${e.delay}s`,"--float-sway":`${e.sway}px`,"--float-opacity":e.opacity,"--float-duration":`${e.duration}s`},children:(0,Q.jsx)(a,{className:z(`block`,e.size),style:{color:`#E74C3C`,fill:`#E74C3C`}})},`float-${t}`)),(0,Q.jsx)(`div`,{className:`absolute inset-0 rounded-2xl pointer-events-none`,style:{boxShadow:`inset 0 2px 4px rgba(255,255,255,0.6), inset 0 -2px 8px rgba(122, 26, 25, 0.06)`}}),(0,Q.jsxs)(`div`,{className:z(`relative`,t?`p-7`:`px-8 sm:px-10 py-8`),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 mb-5`,children:[(0,Q.jsxs)(`span`,{className:z(`relative shrink-0 m-1`,t?`size-14`:`size-16`),children:[(0,Q.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 84 84`,className:`absolute pointer-events-none`,style:{left:`-17%`,top:`-17%`,width:`134%`,height:`134%`},children:[(0,Q.jsx)(`defs`,{children:(0,Q.jsxs)(`radialGradient`,{id:i,children:[(0,Q.jsx)(`stop`,{offset:`0%`,stopColor:vi}),(0,Q.jsx)(`stop`,{offset:`50%`,stopColor:yi}),(0,Q.jsx)(`stop`,{offset:`85%`,stopColor:bi}),(0,Q.jsx)(`stop`,{offset:`100%`,stopColor:bi,stopOpacity:`0.6`})]})}),(0,Q.jsx)(`path`,{d:Ci,fill:`url(#${i})`}),(0,Q.jsx)(`path`,{d:Ci,fill:`none`,stroke:`rgba(255,255,255,0.08)`,strokeWidth:`1`})]}),(0,Q.jsx)(`span`,{className:`absolute rounded-full flex items-center justify-center`,style:{inset:2,background:Si,border:`2px solid ${xi}`,boxShadow:`0 1px 3px rgba(0,0,0,0.14), inset 0 1.5px 2px rgba(255,255,255,0.18), inset 0 -1.5px 2px rgba(0,0,0,0.18)`},children:(0,Q.jsx)(a,{className:t?`size-7`:`size-8`,style:{color:`#FBE9E7`,fill:`#FBE9E7`},"aria-hidden":!0})})]}),(0,Q.jsx)(`span`,{style:{fontFamily:mi,fontSize:t?`2rem`:`2.4rem`,color:`#7a1a19`,lineHeight:1,transform:`translateY(-0.06em)`},children:`Love List`})]}),(0,Q.jsx)(`ul`,{className:`space-y-0`,children:s.map(e=>(0,Q.jsx)(ki,{pubkey:e,compact:t},e))}),c>0&&(0,Q.jsxs)(`p`,{className:`mt-3`,style:{fontFamily:mi,fontSize:t?`1.35rem`:`1.5rem`,color:`#A05252`},children:[`…and `,c,` more dearly loved`]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-2.5 mt-5`,"aria-hidden":!0,children:[(0,Q.jsx)(`span`,{className:`h-px flex-1 max-w-28`,style:{background:`linear-gradient(90deg, transparent, #C48686)`}}),(0,Q.jsx)(a,{className:`size-4`,style:{color:`#C0392B`,fill:`#E74C3C`,opacity:.7}}),(0,Q.jsx)(`span`,{className:`h-px flex-1 max-w-28`,style:{background:`linear-gradient(270deg, transparent, #C48686)`}})]})]})]})]})})})}function ji({event:e,className:t}){let n=K(),r=R(e.pubkey),i=r.data?.metadata,o=U(i),s=zn(i,e.pubkey),c=J(e.pubkey,i),l=(0,Z.useMemo)(()=>li(e).length,[e]),u=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]);return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border overflow-hidden cursor-pointer transition-colors`,t),style:{background:`linear-gradient(165deg, #FFF8F0 0%, #F9E3DC 100%)`,borderColor:`rgba(192, 57, 43, 0.25)`},role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),n(`/${u}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),n(`/${u}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2 space-y-1`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:r.isLoading?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{className:`size-5 rounded-full shrink-0`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{pubkey:e.pubkey,asChild:!0,children:(0,Q.jsx)(q,{to:c,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:o,className:`size-5`,children:[(0,Q.jsx)(W,{src:i?.picture,alt:s}),(0,Q.jsx)(H,{className:`bg-[#E74C3C]/15 text-[#A93226] text-[10px]`,children:s[0]?.toUpperCase()})]})})}),(0,Q.jsx)(Y,{pubkey:e.pubkey,asChild:!0,children:(0,Q.jsx)(q,{to:c,className:`text-sm font-semibold truncate hover:underline`,style:{color:`#6B3A3A`},onClick:e=>e.stopPropagation(),children:s})})]})}),(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 text-sm`,style:{color:`#A05252`},children:[(0,Q.jsx)(a,{className:`size-3.5 shrink-0`,style:{fill:`#E74C3C`,color:`#C0392B`},"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Updated their Love List`,l>0&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsxs)(`span`,{className:`font-medium`,style:{color:`#7a1a19`},children:[l,` loved `,l===1?`one`:`ones`]})]})]})]})]})})}var Mi=6;function Ni({event:e,className:t,disableHoverCards:n}){let r=e.kind===3,i=R(r?e.pubkey:``),a=r?i.data?.metadata:void 0,{title:o,description:s,image:c,pubkeys:l,variant:u}=(0,Z.useMemo)(()=>Jn(e,{authorMetadata:a,authorDisplayName:a?.name||a?.display_name}),[e,a]),d=(0,Z.useMemo)(()=>Un(e),[e]),f=(0,Z.useMemo)(()=>Yn(e,l).slice(0,Mi),[e,l]),{data:p}=_n(f),m=(0,Z.useMemo)(()=>L(c),[c]),h=u===`follow-list`?ge:u===`follow-set`?v:x,g=l.length===1?`1 member`:`${l.length} members`;return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:d,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(h,{className:`size-3.5 text-primary shrink-0`}),(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-1`,children:o})]}),s&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:s}),m&&(0,Q.jsx)(`div`,{className:`rounded-lg overflow-hidden`,children:(0,Q.jsx)(`img`,{src:m,alt:o,className:`w-full max-h-[140px] object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`})}),l.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex -space-x-1.5`,children:f.map(e=>{let t=p?.get(e),n=t?.metadata?.name||t?.metadata?.display_name||`Anonymous`;return(0,Q.jsxs)(G,{shape:U(t?.metadata),className:`size-5 ring-1 ring-background`,children:[(0,Q.jsx)(W,{src:t?.metadata?.picture,alt:n}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[9px]`,children:n[0]?.toUpperCase()})]},e)})}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:g})]})]})}var Pi={sm:`size-6`,md:`size-7`},Fi={sm:`-space-x-1.5`,md:`-space-x-2`},Ii={sm:`size-3`,md:`size-3.5`};function Li({relays:e,maxVisible:t=5,size:n=`md`,className:r}){let{config:i}=I(),a=(0,Z.useMemo)(()=>e.slice(0,t),[e,t]),o=(0,Z.useMemo)(()=>a.map(e=>{let t;try{t=un({template:i.faviconUrl,url:e.url})}catch{t=void 0}return{entry:e,label:Zn(e.url),iconUrl:t}}),[a,i.faviconUrl]);if(e.length===0)return null;let s=e.length-a.length;return(0,Q.jsxs)(`div`,{className:z(`flex items-center gap-2`,r),children:[(0,Q.jsx)(`div`,{className:z(`flex`,Fi[n]),children:o.map(({entry:e,label:t,iconUrl:r})=>(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(jn,{asChild:!0,children:(0,Q.jsx)(q,{to:`/r/${encodeURIComponent(e.url)}`,"aria-label":t,onClick:e=>e.stopPropagation(),className:z(`relative rounded-full 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,Q.jsxs)(G,{className:z(Pi[n],`ring-2 ring-background`),children:[(0,Q.jsx)(W,{src:r,alt:``,className:`object-contain p-0.5`}),(0,Q.jsx)(H,{className:`bg-primary/10`,children:(0,Q.jsx)(A,{className:z(`text-primary`,Ii[n])})})]})})}),(0,Q.jsx)(Mn,{side:`bottom`,className:`text-xs`,children:t})]},e.url))}),s>0&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`+`,s,` more`]})]})}var Ri=5;function zi({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>Xn(e),[e]),i=(0,Z.useMemo)(()=>Un(e),[e]);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:i,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Q.jsx)(A,{className:`size-3.5 shrink-0 text-primary`}),(0,Q.jsx)(`p`,{className:`line-clamp-1 text-sm font-semibold leading-snug`,children:(0,Q.jsx)(kt,{id:`relayList.embedTitle`,defaultMessage:`Relay list · {count, plural, one {# relay} other {# relays}}`,values:{count:r.length}})})]}),(0,Q.jsx)(Li,{relays:r,maxVisible:Ri,size:`sm`})]})}function Bi({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>{let t=Ue.json().pipe(Ue.metadata()).safeParse(e.content);return t.success?t.data:{}},[e.content]),a=(0,Z.useMemo)(()=>Un(e),[e]),o=(0,Z.useMemo)(()=>L(r.banner),[r.banner]);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:a,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Q.jsx)(i,{className:`size-3.5 shrink-0 text-primary`}),(0,Q.jsx)(`p`,{className:`line-clamp-1 text-sm font-semibold leading-snug`,children:(0,Q.jsx)(kt,{id:`profileUpdate.embedTitle`,defaultMessage:`Profile update`})})]}),o&&(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-lg empty:hidden`,children:(0,Q.jsx)(ln,{src:o,className:`max-h-[100px] w-full object-cover`,loading:`lazy`,decoding:`async`})}),r.about?.trim()&&(0,Q.jsx)(`p`,{className:`line-clamp-3 whitespace-pre-wrap break-words text-xs leading-relaxed text-muted-foreground`,children:r.about.trim()})]})}function Vi({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>{try{return ir(er(e.content))}catch{return null}},[e.content]),i=nr(e),a=rr(e),o=$n(e,`state`),s=$n(e,`filename`),c=$n(e,`region`),l=tr(c,s),u=bn(e.pubkey),d=u?`memory-cards/${u}${i?`/${encodeURIComponent(i)}`:``}`:``,f=!!r,p=a===0||o===`header`,m=r?.title||$n(e,`title`)||`(untitled save)`;return(0,Q.jsx)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:d,className:t,disableHoverCards:n,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[f?(0,Q.jsx)(Qn,{frames:r.frames,size:48}):(0,Q.jsx)(`div`,{className:`flex size-12 shrink-0 items-center justify-center rounded-md border border-border bg-muted text-muted-foreground`,children:(0,Q.jsx)(k,{className:`size-5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-semibold leading-snug`,children:f?m:p?`System block`:`Continuation block`}),f&&s&&(0,Q.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted-foreground`,children:s}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-muted-foreground`,children:[i&&(0,Q.jsx)(`span`,{className:`rounded border border-border bg-background px-1.5 py-0.5 font-mono`,children:i}),a>=0&&(0,Q.jsxs)(`span`,{className:`rounded border border-border bg-background px-1.5 py-0.5 font-mono`,children:[`block #`,a]}),c&&(0,Q.jsxs)(`span`,{className:`rounded border border-border bg-background px-1.5 py-0.5`,children:[l?`${l} `:``,c]})]})]})]})})}var Hi=31871,Ui=[`verifying`,`valid`,`invalid`,`revoked`];function Wi(e){if(!e)return;let t=Number(e);return Number.isFinite(t)&&t>0?Math.floor(t):void 0}function Gi(e){return new Date(e*1e3).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Ki(e,t){if(e!==void 0&&t!==void 0)return`Valid ${Gi(e)} – ${Gi(t)}`;if(e!==void 0)return`Valid from ${Gi(e)}`;if(t!==void 0)return`Valid until ${Gi(t)}`}function qi(e){if(e.kind!==31871)return;let t=e.tags.find(([e])=>e===`s`)?.[1]?.trim().toLowerCase(),n=Ui.find(e=>e===t);if(!n)return;let r,i=e.tags.find(([e,t])=>e===`a`&&t);if(i){let e=pn(i[1]);e&&(r={type:`addr`,addr:e,relays:i[2]?[i[2]]:void 0})}if(!r){let t=e.tags.find(([e,t])=>e===`e`&&t);t&&V(t[1])&&(r={type:`event`,id:t[1],relays:t[2]?[t[2]]:void 0,authorHint:V(t[3])?t[3]:void 0})}return{state:n,target:r,validFrom:Wi(e.tags.find(([e])=>e===`valid_from`)?.[1]),validTo:Wi(e.tags.find(([e])=>e===`valid_to`)?.[1]),description:e.content.trim()||void 0}}var Ji={valid:{label:`Valid`,Icon:Se,pill:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,icon:`text-emerald-600 dark:text-emerald-400`},invalid:{label:`Invalid`,Icon:Me,pill:`border-destructive/30 bg-destructive/10 text-destructive`,icon:`text-destructive`},verifying:{label:`Verifying`,Icon:ie,pill:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-400`,icon:`text-amber-600 dark:text-amber-400`},revoked:{label:`Revoked`,Icon:le,pill:`border-border bg-secondary text-muted-foreground`,icon:`text-muted-foreground`}};function Yi({state:e,className:t}){let n=Ji[e];return(0,Q.jsxs)(`span`,{className:z(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold`,n.pill,t),children:[(0,Q.jsx)(n.Icon,{className:`size-3.5`,"aria-hidden":`true`}),n.label]})}function Xi({event:e,expanded:t=!1,className:n,disableTargetEmbed:r=!1}){let i=(0,Z.useMemo)(()=>qi(e),[e]);if(!i)return(0,Q.jsx)(`div`,{className:z(`mt-2 rounded-xl border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,n),children:`Malformed attestation`});let{state:a,target:o,validFrom:s,validTo:c,description:l}=i,u=Ji[a],d=Ki(s,c),f=c!==void 0&&c*1e3qi(e),[e]),i=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]),a=r?Ki(r.validFrom,r.validTo):void 0;return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:i,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(Se,{className:`size-3`,"aria-hidden":`true`}),`Attestation`]}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(Yi,{state:r.state}),a&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a})]}),r.description&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm leading-relaxed whitespace-pre-wrap break-words line-clamp-3 text-foreground`,children:r.description})]}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`Malformed attestation`})]})}var Qi=30402;function $i(e,t){return e.tags.find(([e])=>e===t)?.[1]}function ea(e){return e.replace(/&#(\d+);/g,(e,t)=>{let n=parseInt(t,10);return Number.isFinite(n)&&n>0&&n<=1114111?String.fromCodePoint(n):e}).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/ /g,` `)}function ta(e){return ea(e).replace(/[#*_>`~]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function na(e){return e.replace(/(\.\.\.|…)\s*$/,``).trim()}function ra(e){let t=ta(e.title),n=e.summary?na(ta(e.summary)):void 0,r=[];for(let i of e.content.split(` `)){let e=i.trim();if(!e){r.push(i);continue}let a=ta(e);if(a!==t){if(n){let e=na(a);if(e.length>0&&(e.startsWith(n)||n.startsWith(e)))continue}/^(?:[-*+]\s+)?(?:\*\*|__)?\s*(?:price|category|type|condition|status|location|shipping)\s*(?:\*\*|__)?\s*:/i.test(e)||/^[*_]{1,2}listed by .+[*_]{1,2}$/i.test(e)||r.push(i)}}let i=r.join(` `).trim();return ta(i)?i:``}function ia(e){let t=e.tags.find(([e])=>e===`price`);if(!t)return;let n=Number(t[1]),r=t[2]?.trim();if(!Number.isFinite(n)||n<0||!r)return;let i=t[3]?.trim();return{amount:n,currency:r.toUpperCase(),frequency:i||void 0}}function aa(e){let t;try{t=new Intl.NumberFormat(void 0,{style:`currency`,currency:e.currency,minimumFractionDigits:Number.isInteger(e.amount)?0:2}).format(e.amount)}catch{t=`${e.amount.toLocaleString()} ${e.currency}`}return e.frequency?`${t}/${e.frequency}`:t}function oa(e){if(e.kind!==30402)return null;let t=$i(e,`title`)?.trim();if(!t)return null;let n=[];for(let[t,r]of e.tags){if(t!==`image`)continue;let e=L(r);e&&n.push(e)}let r=$i(e,`status`)?.trim().toLowerCase()===`sold`?`sold`:`active`,i=$i(e,`published_at`),a=i&&/^\d+$/.test(i)?parseInt(i,10):e.created_at,o=e.tags.filter(([e])=>e===`t`).map(([,e])=>e).filter(Boolean);return{event:e,pubkey:e.pubkey,identifier:$i(e,`d`)??``,title:ea(t),summary:(()=>{let t=$i(e,`summary`)?.trim();return t?ea(t):void 0})(),content:e.content,images:n,price:ia(e),status:r,location:(()=>{let t=$i(e,`location`)?.trim();return t?ea(t):void 0})(),sourceUrl:L($i(e,`r`)),hashtags:o,publishedAt:a,createdAt:e.created_at}}function sa({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>oa(e),[e]),i=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);if(!r)return null;let{title:a,images:o,price:s,status:c}=r,l=o[0],u=c===`sold`,d=s?aa(s):void 0;return(0,Q.jsx)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:i,className:t,disableHoverCards:n,children:(0,Q.jsxs)(`div`,{className:`relative isolate flex items-center gap-3 overflow-hidden rounded-xl py-1.5`,children:[(0,Q.jsx)(`div`,{className:`absolute -z-10 top-0 left-0 size-24 rounded-full bg-primary/[0.06] blur-2xl`,"aria-hidden":`true`}),l&&(0,Q.jsx)(`div`,{className:`relative size-20 shrink-0 overflow-hidden rounded-lg bg-muted sm:size-24`,children:(0,Q.jsx)(`img`,{src:l,alt:``,loading:`lazy`,decoding:`async`,className:z(`absolute inset-0 size-full object-cover`,u&&`opacity-60 grayscale`)})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-primary/15`,children:(0,Q.jsx)(S,{className:`size-3 text-primary`})}),u?`Sold`:`For Sale`]}),d&&(0,Q.jsx)(`div`,{className:z(`whitespace-nowrap text-xl font-bold leading-tight tracking-tight`,u&&`text-muted-foreground line-through decoration-2`),children:d}),(0,Q.jsx)(`p`,{dir:`auto`,className:`line-clamp-2 break-words text-sm font-medium leading-snug`,children:a})]})]})})}function ca({text:e,label:t}){let[n,r]=(0,Z.useState)(!1);return(0,Q.jsx)(B,{variant:`ghost`,size:`icon`,onClick:()=>{navigator.clipboard.writeText(e),r(!0),Rt({title:`${t} copied to clipboard`}),setTimeout(()=>r(!1),2e3)},className:`size-6 shrink-0 text-muted-foreground hover:text-foreground`,children:n?(0,Q.jsx)(_e,{className:`size-3.5 text-green-500`}):(0,Q.jsx)(o,{className:`size-3.5`})})}function la({event:e,nip19Id:t,open:n,onOpenChange:r}){let{nostr:i}=He(),[a,o]=(0,Z.useState)(!1),s=t??Un(e),c=JSON.stringify(e,null,2);return(0,Q.jsx)(Ln,{open:n,onOpenChange:r,children:(0,Q.jsxs)(In,{className:`max-w-2xl max-h-[85dvh] flex flex-col gap-0 p-0 rounded-2xl overflow-hidden`,children:[(0,Q.jsx)(Pn,{className:`px-5 pt-5 pb-3 shrink-0`,children:(0,Q.jsx)(Fn,{className:`text-base font-semibold`,children:`Event Details`})}),(0,Q.jsxs)(`div`,{className:`px-5 pb-3 shrink-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Event ID`}),(0,Q.jsxs)(`div`,{className:`relative flex items-center bg-muted rounded-lg px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`font-mono text-xs break-all text-foreground/80 flex-1 pr-2 select-all`,children:s}),(0,Q.jsx)(ca,{text:s,label:`Event ID`})]})]}),(0,Q.jsxs)(`div`,{className:`px-5 pb-5 flex flex-col flex-1 min-h-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground mb-1`,children:`Raw JSON`}),(0,Q.jsxs)(`div`,{className:`relative flex-1 min-h-0 overflow-auto rounded-lg bg-muted border border-border`,children:[(0,Q.jsx)(`div`,{className:`sticky top-2 right-2 float-right mr-2`,children:(0,Q.jsx)(ca,{text:c,label:`Event JSON`})}),(0,Q.jsx)(`pre`,{className:`p-4 text-xs font-mono text-foreground/80 whitespace-pre leading-relaxed`,children:c})]})]}),(0,Q.jsx)(`div`,{className:`px-5 pb-5 shrink-0`,children:(0,Q.jsxs)(B,{variant:`outline`,className:`w-full gap-2`,onClick:async()=>{o(!0);try{await i.event(e,{signal:AbortSignal.timeout(5e3)}),Rt({title:`Event broadcast to relays`})}catch{Rt({title:`Failed to broadcast event`,variant:`destructive`})}finally{o(!1)}},disabled:a,children:[(0,Q.jsx)(he,{className:`size-4`}),a?`Broadcasting...`:`Broadcast Event`]})})]})})}var ua=[`#f0abfc`,`#c084fc`,`#818cf8`,`#38bdf8`,`#34d399`,`#fde047`,`#fb7185`];function da(e){let t=e||1,n=()=>(t=t*1103515245+12345&2147483647,t/2147483647);return{beams:Array.from({length:18},()=>({left:`${n()*120-20}%`,top:`${n()*120-20}%`,delay:`${(n()*1.1).toFixed(3)}s`,duration:`${(.45+n()*.35).toFixed(3)}s`,color:ua[Math.floor(n()*ua.length)],length:Math.round(60+n()*90)})),stars:Array.from({length:22},()=>({left:`${n()*100}%`,top:`${n()*100}%`,delay:`${(n()*1.3).toFixed(3)}s`,size:Math.round(10+n()*14),color:ua[Math.floor(n()*ua.length)]}))}}function fa({event:e,expanded:t=!1,className:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),s=vr(e),c=Lt(e.kind),l=c!==`Kind ${e.kind}`,u=Un(e),f=JSON.stringify(e,null,2),p=(0,Z.useMemo)(()=>{let t=0;for(let n=0;n{e.stopPropagation(),o(!1),requestAnimationFrame(()=>o(!0))},onAnimationEnd:e=>{e.animationName===`mystery-shake`&&o(!1)},children:[(0,Q.jsx)(`svg`,{"aria-hidden":`true`,className:`absolute size-0`,children:(0,Q.jsxs)(`filter`,{id:`mystery-warp`,children:[(0,Q.jsx)(`feTurbulence`,{type:`fractalNoise`,baseFrequency:`0.012 0.028`,numOctaves:`2`,seed:`7`,result:`noise`}),(0,Q.jsx)(`feDisplacementMap`,{in:`SourceGraphic`,in2:`noise`,scale:`28`,xChannelSelector:`R`,yChannelSelector:`G`})]})}),(0,Q.jsx)(`div`,{className:`mystery-waves absolute -inset-4 -z-10 pointer-events-none`,"aria-hidden":`true`}),a&&(0,Q.jsxs)(`div`,{className:`mystery-storm absolute inset-0 z-20 overflow-hidden pointer-events-none`,"aria-hidden":`true`,children:[(0,Q.jsx)(`div`,{className:`mystery-bloom absolute inset-0`}),p.beams.map((e,t)=>(0,Q.jsx)(`span`,{className:`mystery-beam absolute rounded-full`,style:{left:e.left,top:e.top,width:`${e.length}px`,background:`linear-gradient(90deg, transparent, ${e.color}, #fff)`,boxShadow:`0 0 10px 2px ${e.color}`,animationDelay:e.delay,animationDuration:e.duration}},`b${t}`)),p.stars.map((e,t)=>(0,Q.jsx)(d,{className:`mystery-star absolute fill-current`,style:{left:e.left,top:e.top,width:`${e.size}px`,height:`${e.size}px`,color:e.color,filter:`drop-shadow(0 0 6px ${e.color})`,animationDelay:e.delay}},`s${t}`))]}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`bg-gradient-to-br from-fuchsia-500 via-sky-500 to-emerald-500 bg-clip-text text-5xl font-black leading-none text-transparent drop-shadow-sm`,children:`?`}),(0,Q.jsxs)(`div`,{className:`relative z-[1] mt-3 max-w-xs text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug`,children:c}),(0,Q.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[`You’ve stumbled onto `,l?`a kind ${e.kind} event`:`an event kind`,` `,`Ditto can’t render yet.`]})]}),s&&(0,Q.jsx)(`p`,{className:z(`relative z-[1] mt-3 max-w-md whitespace-pre-wrap break-words text-center text-foreground`,t?`text-[15px] leading-relaxed`:`text-sm leading-relaxed`),children:s}),(0,Q.jsxs)(gn,{open:r,onOpenChange:i,className:`relative z-[1] mt-2 w-full`,children:[(0,Q.jsx)(`div`,{className:`flex justify-center`,children:(0,Q.jsx)(hn,{asChild:!0,children:(0,Q.jsxs)(B,{variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:e=>e.stopPropagation(),children:[r?`Hide details`:`View event`,(0,Q.jsx)(ne,{className:z(`size-3.5 transition-transform`,r&&`rotate-180`)})]})})}),(0,Q.jsxs)(mn,{className:`space-y-2 pt-2 text-left`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Event ID`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 rounded-lg bg-muted px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 select-all break-all font-mono text-xs text-foreground/80`,children:u}),(0,Q.jsx)(ca,{text:u,label:`Event ID`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Raw JSON`}),(0,Q.jsxs)(`div`,{className:`relative max-h-64 overflow-auto rounded-lg border border-border bg-muted`,children:[(0,Q.jsx)(`div`,{className:`sticky right-2 top-2 float-right`,children:(0,Q.jsx)(ca,{text:f,label:`Event JSON`})}),(0,Q.jsx)(`pre`,{className:`whitespace-pre p-3 font-mono text-xs leading-relaxed text-foreground/80`,children:f})]})]})]})]})]})})}var pa=new TextDecoder(`utf-8`);new TextEncoder;var ma=1,ha=65535;function ga(e,t){let n=Ye(nt,e,t,76);return{chacha_key:n.subarray(0,32),chacha_nonce:n.subarray(32,44),hmac_key:n.subarray(44,76)}}function _a(e){if(!Number.isSafeInteger(e)||e<1)throw Error(`expected positive integer`);if(e<=32)return 32;let t=1<ha||n.length!==t||e.length!==2+_a(t))throw Error(`invalid padding`);return pa.decode(n)}function ya(e,t,n){if(n.length!==32)throw Error(`AAD associated data must be 32 bytes`);return Ke(nt,e,$e(n,t))}function ba(e){if(typeof e!=`string`)throw Error(`payload must be a valid string`);let t=e.length;if(t<132||t>87472)throw Error(`invalid payload length: `+t);if(e[0]===`#`)throw Error(`unknown encryption version`);let n;try{n=Ge.decode(e)}catch(e){throw Error(`invalid base64: `+e.message)}let r=n.length;if(r<99||r>65603)throw Error(`invalid data length: `+r);let i=n[0];if(i!==2)throw Error(`unknown encryption version `+i);return{nonce:n.subarray(1,33),ciphertext:n.subarray(33,-32),mac:n.subarray(-32)}}function xa(e,t){let{nonce:n,ciphertext:r,mac:i}=ba(e),{chacha_key:a,chacha_nonce:o,hmac_key:s}=ga(t,n);if(!Qe(ya(s,r,n),i))throw Error(`invalid MAC`);return va(We(a,o,r))}var Sa=33301,Ca=`https://armada.buzz/invite/`,wa=`https://vectorapp.io/invite/`,Ta=`/invite/`;function Ea(e){let t=e.toLowerCase().replace(/^www\./,``);return t===`vectorapp.io`||t.endsWith(`.vectorapp.io`)?`vector`:`armada`}function Da(e){try{let t=P.decode(e);return t.type!==`naddr`||t.data.kind!==33301||t.data.identifier!==``?void 0:t.data.pubkey}catch{return}}function Oa(e){let t=e.trim(),n,r=``,i=`armada`;if(/^naddr1[023456789acdefghjklmnpqrstuvwxyz]+/i.test(t)){let[e,...i]=t.split(`#`);n=e,r=i.join(`#`)}else{let e;try{e=new URL(t)}catch{return}if(!e.pathname.startsWith(Ta))return;n=decodeURIComponent(e.pathname.slice(8)).replace(/\/$/,``),r=e.hash.replace(/^#/,``),i=Ea(e.hostname)}if(!n)return;let a=Da(n);if(!a)return;let o=`${n}${r?`#${r}`:``}`,s=L(`${Ca}${o}`),c=L(`${wa}${o}`);if(!(!s||!c))return{naddr:n,linkSigner:a,fragment:r,brand:i,openUrl:i===`vector`?c:s,armadaUrl:s,vectorUrl:c,missingSecret:r.length===0}}var ka=16,Aa=3,ja=4,Ma=1,Na={1:`wss://jskitty.com/nostr`,2:`wss://asia.vectorapp.io/nostr`,3:`wss://relay.ditto.pub`,4:`wss://relay.dreamith.to`},Pa=[1,2,3,4].map(e=>Na[e]);function Fa(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=atob(t+n),i=new Uint8Array(r.length);for(let e=0;en+e<=t.length;if(!r(2)||t[n++]!==ja)return;let i=t[n++],a=[];if(i&Ma)a.push(...Pa);else{if(!r(1))return;let e=t[n++];if(e>Aa)return;let i=new TextDecoder;for(let o=0;o=1&&e<=254){let t=Na[e];t&&a.push(t)}else{if(!r(1))return;let o=t[n++];if(!r(o))return;let s=i.decode(t.slice(n,n+o));n+=o,a.push(e===255?s:`wss://${s}`)}}}if(!r(ka))return;let o=t.slice(n,n+ka);if(n+=ka,n===t.length)return{token:o,relays:a}}function La(e){let t=new TextEncoder().encode(`concord/invite-key`),n=new Uint8Array(t.length+1+32);return n.set(t,0),qe(nt,e,new Uint8Array,n,32)}var Ra=`6`;function za(e,t,n){if(e.kind!==33301||e.pubkey!==t||e.tags.find(e=>e[0]===`vsk`)?.[1]!==Ra||!Xe(e))return;let r;try{r=JSON.parse(xa(e.content,La(n)))}catch{return}if(!r||typeof r!=`object`)return;let i=typeof r.name==`string`?r.name:``,a=Array.isArray(r.channels)?r.channels:[],o=Array.isArray(r.relays)?r.relays.filter(e=>typeof e==`string`):[],s=typeof r.expires_at==`number`?r.expires_at:void 0;return{name:i,icon:Ba(r.icon)?r.icon:void 0,channelCount:a.length,relays:o.slice(0,Aa),expired:typeof s==`number`&&Date.now()>s}}function Ba(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.url==`string`&&typeof t.key==`string`&&typeof t.nonce==`string`&&typeof t.hash==`string`}function Va(e){let{nostr:t}=He(),n=(0,Z.useMemo)(()=>e&&!e.missingSecret?Ia(e.fragment):void 0,[e]),r=n?et(n.token):``;return F({queryKey:[`armada-invite-preview`,e?.linkSigner??``,r],enabled:!!e&&!!n,staleTime:300*1e3,retry:1,queryFn:async r=>{if(!e||!n)return null;let i=n.relays.filter(e=>/^wss:\/\//i.test(e)),a=await(i.length?t.group(i):t).query([{kinds:[Sa],authors:[e.linkSigner],"#d":[``],limit:1}],{signal:r.signal});if(!a.length)return null;let o=a.sort((e,t)=>t.created_at-e.created_at)[0];return za(o,e.linkSigner,n.token)??null}})}function Ha(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?`image/png`:e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?`image/jpeg`:e.length>=6&&e[0]===71&&e[1]===73&&e[2]===70?`image/gif`:e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80?`image/webp`:e.length>=5&&e[0]===60?`image/svg+xml`:`application/octet-stream`}async function Ua(e,t){let n=L(e.url);if(n)try{let r=await fetch(n,{signal:t});if(!r.ok)return;let i=await Mt(await r.arrayBuffer(),tt(e.key),tt(e.nonce)),a=new Uint8Array(i);if(et(nt(a))!==e.hash.toLowerCase())return;let o=Ha(a);return URL.createObjectURL(new Blob([a],{type:o}))}catch{return}}function Wa(e){let[t,n]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!e){n(null);return}let t,r=!1,i=new AbortController;return Ua(e,i.signal).then(e=>{if(r){e&&URL.revokeObjectURL(e);return}t=e,n(e??null)}),()=>{r=!0,i.abort(),t&&URL.revokeObjectURL(t)}},[e]),t}var Ga=`#33DB98`,Ka=`text-[#147a52] dark:text-[#33DB98]`;function qa({className:e}){let t=(0,Z.useId)().replace(/[^a-zA-Z0-9]/g,``),n=`vec-grad-${t}`,r=`vec-glow-${t}`;return(0,Q.jsxs)(`svg`,{viewBox:`46 14 120 150`,fill:`none`,role:`img`,"aria-label":`Vector`,className:e,children:[(0,Q.jsxs)(`defs`,{children:[(0,Q.jsxs)(`linearGradient`,{id:n,x1:`105.743`,y1:`146.145`,x2:`105.743`,y2:`46.193`,gradientUnits:`userSpaceOnUse`,children:[(0,Q.jsx)(`stop`,{offset:`0`,stopColor:`#2b976c`}),(0,Q.jsx)(`stop`,{offset:`.5`,stopColor:`#33db98`}),(0,Q.jsx)(`stop`,{offset:`1`,stopColor:`#59fcb3`})]}),(0,Q.jsxs)(`filter`,{id:r,x:`43.104`,y:`0`,width:`126`,height:`160`,filterUnits:`userSpaceOnUse`,children:[(0,Q.jsx)(`feGaussianBlur`,{result:`blur`,stdDeviation:`7.903`}),(0,Q.jsx)(`feFlood`,{floodColor:`#59fcb3`,floodOpacity:`.57`}),(0,Q.jsx)(`feComposite`,{in2:`blur`,operator:`in`}),(0,Q.jsx)(`feComposite`,{in:`SourceGraphic`})]})]}),(0,Q.jsx)(`path`,{d:`M143.892 69.377l-29.745 27.031a12.5 12.5 0 0 1-16.808 0L67.595 69.377l-.025-.025V88.56c0 3.314 1.401 6.499 3.843 8.739l26.317 24.133c2.193 2.011 5.038 3.118 8.013 3.118s5.821-1.107 8.013-3.118l26.317-24.132c2.442-2.24 3.843-5.425 3.843-8.739V69.352l-.025.025z`,fill:`url(#${n})`,opacity:`.57`}),(0,Q.jsx)(`path`,{d:`M143.892 101.393l-29.745 27.031a12.5 12.5 0 0 1-16.808 0l-29.745-27.031-.025-.025v19.208c0 3.314 1.401 6.499 3.843 8.739l26.317 24.133c2.193 2.011 5.038 3.118 8.013 3.118s5.821-1.107 8.013-3.118l26.317-24.132c2.442-2.24 3.843-5.425 3.843-8.739v-19.208l-.025.025z`,fill:`url(#${n})`,opacity:`.25`}),(0,Q.jsx)(`path`,{d:`M71.553 64.792l26.317 24.133c3.546 3.252 8.802 4.141 13.548 1.803.765-.377 1.465-.874 2.094-1.451l26.701-24.485c2.443-2.24 3.843-5.425 3.843-8.739V33.559c0-4.975-3.901-9.189-8.874-9.317-5.144-.132-9.356 3.998-9.356 9.112v15.794a9.33 9.33 0 0 1-3.024 6.875l-8.475 7.771a12.5 12.5 0 0 1-16.891 0l-8.475-7.771a9.33 9.33 0 0 1-3.024-6.875V33.559c0-4.975-3.901-9.189-8.874-9.317-5.144-.133-9.356 3.998-9.356 9.112v22.7c0 3.314 1.401 6.499 3.843 8.739z`,fill:`url(#${n})`,filter:`url(#${r})`}),(0,Q.jsx)(`circle`,{cx:`105.743`,cy:`42.484`,r:`12.032`,fill:`url(#${n})`,filter:`url(#${r})`})]})}function Ja({preview:e,sizeClass:t,markClass:n}){let r=Wa(e?.icon);return(0,Q.jsx)(`div`,{className:z(`relative flex shrink-0 items-center justify-center overflow-hidden rounded-xl bg-[#0a0a0a]`,t),children:r?(0,Q.jsx)(`img`,{src:r,alt:e?.name||`Community icon`,className:`size-full object-cover`,decoding:`async`}):(0,Q.jsx)(qa,{className:n})})}function Ya(e){return e<=0?`No channels`:`${e} ${e===1?`channel`:`channels`}`}function Xa({markClass:e,textClass:t}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(qa,{className:e}),(0,Q.jsx)(`span`,{className:z(`font-semibold uppercase tracking-wider`,Ka,t),children:`Vector`}),(0,Q.jsx)(`span`,{className:z(`font-medium uppercase tracking-wider text-muted-foreground`,t),children:`· Community invite`})]})}function Za({invite:e,className:t,variant:n=`embed`}){let r=L(e.vectorUrl),i=L(e.armadaUrl),[a,s]=(0,Z.useState)(!1),{data:l,isLoading:u}=Va(e),d=!e.missingSecret&&u,f=l?.name?.trim(),p=()=>{r&&(navigator.clipboard.writeText(r),s(!0),setTimeout(()=>s(!1),2e3))},m=()=>{r&&Nt(r)},h=()=>{i&&Nt(i)},g=`text-[#0a0a0a] hover:brightness-105 active:brightness-95 border-0`,_={backgroundColor:Ga},v=!e.missingSecret&&i&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline decoration-dotted underline-offset-2 hover:text-foreground transition-colors`,onClick:e=>{e.preventDefault(),e.stopPropagation(),h()},children:`Open in Armada instead`});return n===`detail`?(0,Q.jsxs)(`div`,{className:z(`relative mx-auto w-full max-w-md overflow-hidden text-center`,`rounded-xl border shadow-sm`,`bg-gradient-to-br from-[#33db98]/10 via-background to-[#59fcb3]/[0.06]`,t),style:{borderColor:`rgba(51,219,152,0.3)`},children:[(0,Q.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-14 size-40 rounded-full blur-3xl`,style:{backgroundColor:`rgba(51,219,152,0.2)`},"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`relative flex flex-col items-center px-6 py-8 space-y-4`,children:[(0,Q.jsx)(Xa,{markClass:`size-4`,textClass:`text-xs`}),(0,Q.jsx)(Ja,{preview:l,sizeClass:`size-20`,markClass:`size-16`}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[d?(0,Q.jsx)(X,{className:`mx-auto h-6 w-40`}):(0,Q.jsx)(`h2`,{className:`text-lg font-bold leading-tight`,children:f||`Encrypted community`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(ye,{className:`size-3.5 shrink-0`}),e.missingSecret?`Missing secret`:`Encrypted`]}),l&&l.channelCount>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(c,{className:`size-3.5 shrink-0`}),Ya(l.channelCount)]})]}),(0,Q.jsx)(`p`,{className:`mx-auto max-w-xs text-sm text-muted-foreground`,children:e.missingSecret?`Ask whoever shared it for a fresh link — the secret can't be recovered.`:l?.expired?`This invite has expired. Ask for a fresh link to join.`:`Ditto can't open encrypted communities. Open this invite in Vector to view and join.`})]}),(0,Q.jsxs)(`div`,{className:`flex w-full max-w-xs flex-col gap-2 pt-1`,children:[e.missingSecret?(0,Q.jsx)(B,{variant:`secondary`,disabled:!0,children:`Invite incomplete`}):(0,Q.jsxs)(B,{className:g,style:_,disabled:!r,onClick:m,children:[(0,Q.jsx)(b,{className:`size-4`}),`Open in Vector`]}),(0,Q.jsxs)(B,{type:`button`,variant:`secondary`,disabled:!r,onClick:p,children:[a?(0,Q.jsx)(_e,{className:`size-4`}):(0,Q.jsx)(o,{className:`size-4`}),a?`Copied`:`Copy invite link`]}),v&&(0,Q.jsx)(`div`,{className:`pt-0.5`,children:v})]})]})]}):(0,Q.jsxs)(`div`,{className:z(`group relative block max-w-sm w-full my-2.5 overflow-hidden`,`rounded-lg border shadow-sm`,`bg-gradient-to-br from-[#33db98]/10 via-background to-[#59fcb3]/[0.06]`,t),style:{borderColor:`rgba(51,219,152,0.3)`},onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`div`,{className:`pointer-events-none absolute -right-8 -top-10 size-28 rounded-full blur-2xl`,style:{backgroundColor:`rgba(51,219,152,0.2)`},"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`relative px-3.5 py-3 space-y-3`,children:[(0,Q.jsx)(Xa,{markClass:`size-3.5`,textClass:`text-[11px]`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,Q.jsx)(Ja,{preview:l,sizeClass:`size-12`,markClass:`size-9`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d?(0,Q.jsx)(X,{className:`h-4 w-28`}):(0,Q.jsx)(`p`,{className:`font-semibold leading-tight truncate`,children:f||`Encrypted community`}),(0,Q.jsxs)(`p`,{className:`mt-0.5 flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(ye,{className:`size-3 shrink-0`}),e.missingSecret?`Missing secret`:`Encrypted`]}),l&&l.channelCount>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(c,{className:`size-3 shrink-0`}),l.channelCount]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.missingSecret?(0,Q.jsx)(B,{variant:`secondary`,className:`flex-1`,disabled:!0,children:`Invite incomplete`}):(0,Q.jsxs)(B,{className:z(`flex-1`,g),style:_,disabled:!r,onClick:e=>{e.preventDefault(),e.stopPropagation(),m()},children:[(0,Q.jsx)(b,{className:`size-4`}),`Open in Vector`]}),(0,Q.jsx)(B,{type:`button`,variant:`secondary`,size:`icon`,className:`shrink-0`,"aria-label":a?`Link copied`:`Copy invite link`,disabled:!r,onClick:e=>{e.preventDefault(),e.stopPropagation(),p()},children:a?(0,Q.jsx)(_e,{className:`size-4`}):(0,Q.jsx)(o,{className:`size-4`})})]}),v&&(0,Q.jsx)(`div`,{className:`pt-0.5 text-center`,children:v})]})]})}function Qa(e,t=`0.4rem`){return{borderRadius:t,clipPath:`polygon(${e} 0, 100% 0, 100% calc(100% - ${e}), calc(100% - ${e}) 100%, 0 100%, 0 ${e})`}}function $a({className:e}){return(0,Q.jsxs)(`svg`,{viewBox:`0 0 256 256`,fill:`none`,role:`img`,"aria-label":`Armada`,className:e,children:[(0,Q.jsx)(`path`,{d:`M64 16 H232 a8 8 0 0 1 8 8 V192 L192 240 H24 a8 8 0 0 1 -8 -8 V64 Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`12`}),(0,Q.jsx)(`path`,{d:`M128 56 L180 162 H158 L128 100 L98 162 H76 Z`,fill:`currentColor`}),(0,Q.jsxs)(`g`,{stroke:`currentColor`,strokeLinecap:`round`,opacity:`0.55`,children:[(0,Q.jsx)(`path`,{d:`M88 184 H168`,strokeWidth:`7`}),(0,Q.jsx)(`path`,{d:`M104 200 H152`,strokeWidth:`5`,opacity:`0.7`})]})]})}function eo({preview:e,sizeClass:t,crestClass:n,cut:r}){let i=Wa(e?.icon);return(0,Q.jsx)(`div`,{className:z(`relative flex shrink-0 items-center justify-center overflow-hidden bg-primary/15`,t),style:Qa(r),children:i?(0,Q.jsx)(`img`,{src:i,alt:e?.name||`Community icon`,className:`size-full object-cover`,decoding:`async`}):(0,Q.jsx)($a,{className:z(`text-primary`,n)})})}function to(e){return e<=0?`No channels`:`${e} ${e===1?`channel`:`channels`}`}function no({invite:e,className:t,variant:n=`embed`}){return e.brand===`vector`?(0,Q.jsx)(Za,{invite:e,className:t,variant:n}):(0,Q.jsx)(ro,{invite:e,className:t,variant:n})}function ro({invite:e,className:t,variant:n=`embed`}){let r=L(e.openUrl),[i,a]=(0,Z.useState)(!1),{data:s,isLoading:l}=Va(e),u=!e.missingSecret&&l,d=s?.name?.trim(),f=()=>{r&&(navigator.clipboard.writeText(r),a(!0),setTimeout(()=>a(!1),2e3))},p=()=>{r&&Nt(r)};return n===`detail`?(0,Q.jsxs)(`div`,{className:z(`relative mx-auto w-full max-w-md overflow-hidden text-center`,`border border-primary/25 rounded-xl`,`bg-gradient-to-br from-primary/10 via-background to-primary/[0.06]`,`shadow-sm`,t),children:[(0,Q.jsx)(`div`,{className:`pointer-events-none absolute -right-10 -top-14 size-40 rounded-full bg-primary/20 blur-3xl`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`relative flex flex-col items-center px-6 py-8 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-primary`,children:`Armada`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:`· Community invite`})]}),(0,Q.jsx)(eo,{preview:s,sizeClass:`size-20`,crestClass:`size-14`,cut:`1rem`}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[u?(0,Q.jsx)(X,{className:`mx-auto h-6 w-40`}):(0,Q.jsx)(`h2`,{className:`text-lg font-bold leading-tight`,children:d||`Encrypted community`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-3 text-sm text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(ye,{className:`size-3.5 shrink-0`}),e.missingSecret?`Missing secret`:`Encrypted`]}),s&&s.channelCount>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(c,{className:`size-3.5 shrink-0`}),to(s.channelCount)]})]}),(0,Q.jsx)(`p`,{className:`mx-auto max-w-xs text-sm text-muted-foreground`,children:e.missingSecret?`Ask whoever shared it for a fresh link — the secret can't be recovered.`:s?.expired?`This invite has expired. Ask for a fresh link to join.`:`Ditto can't open encrypted communities. Open this invite in Armada to view and join.`})]}),(0,Q.jsxs)(`div`,{className:`flex w-full max-w-xs flex-col gap-2 pt-1`,children:[e.missingSecret?(0,Q.jsx)(B,{variant:`secondary`,style:Qa(`0.85rem`),disabled:!0,children:`Invite incomplete`}):(0,Q.jsxs)(B,{style:Qa(`0.85rem`),disabled:!r,onClick:p,children:[(0,Q.jsx)(b,{className:`size-4`}),`Open in Armada`]}),(0,Q.jsxs)(B,{type:`button`,variant:`secondary`,className:`bg-primary/10 text-primary hover:bg-primary/20`,style:Qa(`0.85rem`),disabled:!r,onClick:f,children:[i?(0,Q.jsx)(_e,{className:`size-4 text-primary`}):(0,Q.jsx)(o,{className:`size-4`}),i?`Copied`:`Copy invite link`]})]})]})]}):(0,Q.jsxs)(`div`,{className:z(`group relative block max-w-sm w-full my-2.5 overflow-hidden`,`border border-primary/25 rounded-lg`,`bg-gradient-to-br from-primary/10 via-background to-primary/[0.06]`,`shadow-sm`,t),onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`div`,{className:`pointer-events-none absolute -right-8 -top-10 size-28 rounded-full bg-primary/20 blur-2xl`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`relative px-3.5 py-3 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-primary`,children:`Armada`}),(0,Q.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:`· Community invite`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,Q.jsx)(eo,{preview:s,sizeClass:`size-12`,crestClass:`size-8`,cut:`0.65rem`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[u?(0,Q.jsx)(X,{className:`h-4 w-28`}):(0,Q.jsx)(`p`,{className:`font-semibold leading-tight truncate`,children:d||`Encrypted community`}),(0,Q.jsxs)(`p`,{className:`mt-0.5 flex items-center gap-2.5 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(ye,{className:`size-3 shrink-0`}),e.missingSecret?`Missing secret`:`Encrypted`]}),s&&s.channelCount>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(c,{className:`size-3 shrink-0`}),s.channelCount]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.missingSecret?(0,Q.jsx)(B,{variant:`secondary`,className:`flex-1`,style:Qa(`0.7rem`),disabled:!0,children:`Invite incomplete`}):(0,Q.jsxs)(B,{className:`flex-1`,style:Qa(`0.7rem`),disabled:!r,onClick:e=>{e.preventDefault(),e.stopPropagation(),p()},children:[(0,Q.jsx)(b,{className:`size-4`}),`Open in Armada`]}),(0,Q.jsx)(B,{type:`button`,variant:`secondary`,size:`icon`,className:`shrink-0 bg-primary/10 text-primary hover:bg-primary/20`,style:Qa(`0.7rem`),"aria-label":i?`Link copied`:`Copy invite link`,disabled:!r,onClick:e=>{e.preventDefault(),e.stopPropagation(),f()},children:i?(0,Q.jsx)(_e,{className:`size-4 text-primary`}):(0,Q.jsx)(o,{className:`size-4`})})]})]})]})}var io=24*3600;function ao(e){let t=e.tags.find(([e])=>e===`status`)?.[1]??`ended`;return t===`live`&&Math.floor(Date.now()/1e3)-e.created_at>io?`ended`:t}function oo(e){switch(e){case`live`:return{label:`LIVE`,className:`bg-red-600 hover:bg-red-600 text-white border-red-600`};case`ended`:return{label:`ENDED`,className:`bg-muted text-muted-foreground border-border`};case`planned`:return{label:`PLANNED`,className:`bg-blue-600/90 hover:bg-blue-600/90 text-white border-blue-600`};default:return{label:e?.toUpperCase()||`UNKNOWN`,className:`bg-muted text-muted-foreground border-border`}}}var so=(0,Z.lazy)(()=>ze(()=>import(`./BlobbiStateCard-BzIlF1sW.js`).then(e=>({default:e.BlobbiStateCard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171]))),co=280;function lo(e){let t=t=>e.tags.find(([e])=>e===t)?.[1],n=t(`title`)||t(`name`),r=t(`summary`)||t(`description`),i=t(`image`)||t(`thumb`)||t(`banner`),a=t(`alt`);if(e.content)try{let t=JSON.parse(e.content);typeof t==`object`&&t&&(!n&&t.title&&(n=t.title),!r&&t.description&&(r=t.description),!i&&t.images?.[0]&&(i=t.images[0]),!i&&t.image&&(i=t.image))}catch{!r&&e.content.length>0&&(r=e.content)}return!n&&a?n=a:!r&&a&&(r=a),{title:n,description:r,image:i}}function uo(e){let{addr:t}=e;return(0,Q.jsx)(Re,{fallback:(0,Q.jsx)(Wr,{compact:!0,className:e.className}),sentryLevel:`error`,sentryTags:{errorBoundary:`embedded-naddr`,kind:t.kind,pubkey:t.pubkey},resetKeys:[t.kind,t.pubkey,t.identifier],children:(0,Q.jsx)(fo,{...e})})}function fo({addr:e,className:t,disableHoverCards:n,sourceUrl:r}){let{data:i,isLoading:a,isError:o}=Wn(e);if(e.kind===33301){let n=P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:e.identifier});return(0,Q.jsx)(no,{invite:r&&Oa(r)||{naddr:n,linkSigner:e.pubkey,fragment:``,brand:`armada`,openUrl:`https://armada.buzz/invite/${n}`,armadaUrl:`https://armada.buzz/invite/${n}`,vectorUrl:`https://vectorapp.io/invite/${n}`,missingSecret:!0},className:t})}return a?(0,Q.jsx)(To,{className:t}):o||!i?(0,Q.jsx)(wo,{addr:e,className:t}):i.kind===30009?(0,Q.jsx)(po,{event:i,className:t}):nn(i)?(0,Q.jsx)(ho,{event:i,className:t}):i.kind===31124?(0,Q.jsx)(_o,{event:i,className:t,disableHoverCards:n}):i.kind===33863?(0,Q.jsx)(vo,{event:i,className:t,disableHoverCards:n}):i.kind===38192?(0,Q.jsx)(Vi,{event:i,className:t,disableHoverCards:n}):qn(i.kind)?(0,Q.jsx)(Ni,{event:i,className:t,disableHoverCards:n}):i.kind===10002?(0,Q.jsx)(zi,{event:i,className:t,disableHoverCards:n}):i.kind===0?(0,Q.jsx)(Bi,{event:i,className:t,disableHoverCards:n}):i.kind===31871?(0,Q.jsx)(Zi,{event:i,className:t,disableHoverCards:n}):i.kind===37849?(0,Q.jsx)(yo,{event:i,className:t,disableHoverCards:n}):i.kind===30315?(0,Q.jsx)(So,{event:i,className:t,disableHoverCards:n}):i.kind===30312||i.kind===30313?(0,Q.jsx)(bo,{event:i,className:t,disableHoverCards:n}):i.kind===30311?(0,Q.jsx)(xo,{event:i,className:t,disableHoverCards:n}):i.kind===39701?(0,Q.jsx)(Co,{event:i,className:t,disableHoverCards:n}):i.kind===30402&&oa(i)?(0,Q.jsx)(sa,{event:i,className:t,disableHoverCards:n}):sr.has(i.kind)?(0,Q.jsx)(or,{event:i,className:t,disableHoverCards:n,sourceUrl:r}):cr.has(i.kind)?(0,Q.jsx)(lr,{event:i,className:t,disableHoverCards:n}):(0,Q.jsx)(go,{event:i,className:t,disableHoverCards:n,sourceUrl:r})}function po({event:e,className:t}){let n=K(),r=(0,Z.useMemo)(()=>$t(e),[e]),i=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);if(!r)return(0,Q.jsx)(go,{event:e,className:t});let a=r.image??r.thumbs.find(e=>e.dimensions===`512x512`)?.url??r.thumbs[0]?.url;return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),n(`/${i}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),n(`/${i}`))},children:(0,Q.jsxs)(`div`,{className:`relative isolate flex flex-col items-center py-6 overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`absolute -z-10 pointer-events-none`,"aria-hidden":`true`,style:{width:240,height:240,top:`50%`,left:`50%`,transform:`translate(-50%, -55%)`},children:(0,Q.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,Q.jsx)(`div`,{className:`relative z-[1]`,children:a?(0,Q.jsx)(`img`,{src:a,alt:r.name,className:`size-20 rounded-xl object-cover drop-shadow-lg`,loading:`lazy`,decoding:`async`}):(0,Q.jsx)(`div`,{className:`size-20 rounded-xl bg-gradient-to-br from-primary/10 via-primary/5 to-transparent flex items-center justify-center`,children:(0,Q.jsx)(h,{className:`size-8 text-primary/30`})})}),(0,Q.jsxs)(`div`,{className:`relative z-[1] mt-3 text-center px-4 max-w-xs`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug`,children:r.name}),r.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-1`,children:r.description})]})]})})}var mo=6;function ho({event:e,className:t}){let{nostr:n}=He(),r=K(),i=R(e.pubkey),a=i.data?.metadata,o=U(a),s=a?.name||a?.display_name||`Anonymous`,c=J(e.pubkey,a),l=(0,Z.useMemo)(()=>on(e),[e]),{data:u}=F({queryKey:[`badge-definitions-embed`,l.map(e=>e.aTag).join(`,`)],queryFn:async()=>{if(l.length===0)return[];let e=l.slice(0,mo).map(e=>({kinds:[30009],authors:[e.pubkey],"#d":[e.identifier],limit:1}));return n.query(e)},enabled:l.length>0,staleTime:5*6e4}),d=(0,Z.useMemo)(()=>{let e=new Map;if(!u)return e;for(let t of u){let n=$t(t);n&&e.set(`30009:${t.pubkey}:${n.identifier}`,n)}return e},[u]),f=(0,Z.useMemo)(()=>P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:``}),[e.kind,e.pubkey]),p=l.slice(0,mo),m=Math.max(0,l.length-mo);return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),r(`/${f}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r(`/${f}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[i.isLoading?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(X,{className:`size-5 rounded-full shrink-0`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{to:c,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:o,className:`size-5`,children:[(0,Q.jsx)(W,{src:a?.picture,alt:s}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[10px]`,children:s[0]?.toUpperCase()})]})}),(0,Q.jsx)(q,{to:c,className:`text-sm font-semibold truncate hover:underline`,onClick:e=>e.stopPropagation(),children:i.data?.event?(0,Q.jsx)(Xt,{tags:i.data.event.tags,children:s}):s})]}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,Rn(e.created_at)]})]}),p.length>0&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[p.map(e=>{let t=d.get(e.aTag);return t?(0,Q.jsx)(cn,{badge:t,size:32},e.aTag):(0,Q.jsx)(`div`,{className:`size-8 rounded-md border border-border bg-background flex items-center justify-center shrink-0`,children:(0,Q.jsx)(h,{className:`size-4 text-muted-foreground`})},e.aTag)}),m>0&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-medium ml-0.5`,children:[`+`,m]})]}),(0,Q.jsxs)(`p`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Q.jsx)(h,{className:`size-3 shrink-0`}),l.length,` badge`,l.length===1?``:`s`]})]})})}function go({event:e,className:t,disableHoverCards:n,sourceUrl:r}){let i=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]),a=(0,Z.useMemo)(()=>Et(r),[r]),o=yr(e.kind),s=o!==void 0,{title:c,description:l}=(0,Z.useMemo)(()=>s?lo(e):{title:void 0,description:void 0},[s,e]),u=(0,Z.useMemo)(()=>{if(l)return l.length<=co?l:l.slice(0,co).trimEnd()+`…`},[l]),d=(0,Z.useMemo)(()=>{if(o)return{label:o,Icon:_r(e.kind)}},[o,e.kind]);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:i,className:t,disableHoverCards:n,children:[s?(0,Q.jsxs)(Q.Fragment,{children:[c&&(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2`,children:c}),u&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-3`,children:u})]}):(0,Q.jsx)(fa,{event:e,className:`mt-0`}),(d||a)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[d&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[d.Icon&&(0,Q.jsx)(d.Icon,{className:`size-3 shrink-0`}),d.label]}),(0,Q.jsx)(ar,{url:r,className:`ml-auto`})]})]})}function _o({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);return(0,Q.jsx)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:r,className:t,disableHoverCards:n,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(X,{className:`h-24 w-full rounded-lg`}),children:(0,Q.jsx)(so,{event:e})})})}function vo({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>mr(e),[e]),i=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);if(!r)return(0,Q.jsx)(go,{event:e,className:t,disableHoverCards:n});let a=L(r.banner);return(0,Q.jsxs)($,{pubkey:r.pubkey,createdAt:r.createdAt,navigateTo:i,className:t,disableHoverCards:n,children:[(0,Q.jsx)(`div`,{className:`relative w-full overflow-hidden rounded-lg aspect-[16/9] bg-gradient-to-br from-primary/15 via-primary/5 to-secondary`,children:a?(0,Q.jsx)(`img`,{src:a,alt:``,loading:`lazy`,decoding:`async`,className:`absolute inset-0 size-full object-cover`}):(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsx)(C,{className:`size-10 text-primary/40`})})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-primary`,children:[(0,Q.jsx)(C,{className:`size-3`}),`Fundraiser`]}),(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm font-semibold leading-snug line-clamp-2 break-words`,children:r.title}),r.summary&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-xs text-muted-foreground leading-relaxed line-clamp-2 break-words`,children:r.summary})]})}function yo({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>hr(e),[e]),i=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);if(!r)return(0,Q.jsx)(go,{event:e,className:t,disableHoverCards:n});let a=r.questions.length;return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:i,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-primary`,children:[(0,Q.jsx)(s,{className:`size-3`}),`Quiz`]}),(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm font-semibold leading-snug line-clamp-2 break-words`,children:r.title}),r.summary&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-xs text-muted-foreground leading-relaxed line-clamp-2 break-words`,children:r.summary}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[a,` `,a===1?`question`:`questions`]})]})}function bo({event:e,className:t,disableHoverCards:n}){let r=e.kind===30312,i=r?M:O,a=t=>e.tags.find(([e])=>e===t)?.[1],o=a(`title`)||a(`room`)||(r?`Untitled Room`:`Untitled Meeting`),s=a(`summary`),c=a(`status`),l=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:l,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-primary`,children:[(0,Q.jsx)(i,{className:`size-3`}),r?`Room`:`Meeting`,c&&(0,Q.jsx)(`span`,{className:`ml-1 rounded-full bg-secondary/60 px-2 py-0.5 text-[10px] text-muted-foreground normal-case tracking-normal`,children:c})]}),(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm font-semibold leading-snug line-clamp-2 break-words`,children:o}),s&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-xs text-muted-foreground leading-relaxed line-clamp-2 break-words`,children:s})]})}function xo({event:e,className:t,disableHoverCards:n}){let r=t=>e.tags.find(([e])=>e===t)?.[1],i=r(`title`)||`Untitled Stream`,a=r(`summary`),o=L(r(`image`)),s=r(`current_participants`),c=ao(e),l=oo(c),u=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:u,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`relative w-full overflow-hidden rounded-lg aspect-video bg-muted`,children:[o?(0,Q.jsx)(`img`,{src:o,alt:``,loading:`lazy`,decoding:`async`,className:`absolute inset-0 size-full object-cover`}):(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-gradient-to-br from-primary/15 via-primary/5 to-secondary`,children:(0,Q.jsx)(he,{className:`size-10 text-primary/40`})}),(0,Q.jsx)(`div`,{className:`absolute top-2 left-2`,children:(0,Q.jsxs)(br,{variant:`outline`,className:z(`text-[10px]`,l.className),children:[c===`live`&&(0,Q.jsx)(`div`,{className:`size-1.5 bg-white rounded-full animate-pulse mr-1`}),l.label]})}),s&&(0,Q.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,Q.jsx)(v,{className:`size-3`}),s]})]}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(he,{className:`size-4 text-primary shrink-0 mt-0.5`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm font-semibold leading-snug line-clamp-2 break-words`,children:i}),a&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-xs text-muted-foreground leading-relaxed line-clamp-2 break-words mt-0.5`,children:a})]})]})]})}function So({event:e,className:t,disableHoverCards:n}){let r=e.tags.find(([e])=>e===`d`)?.[1]??`general`,i=r===`music`,a=e.content.trim(),o=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`expiration`)?.[1];if(!t)return!1;let n=parseInt(t,10);return!Number.isNaN(n)&&Math.floor(Date.now()/1e3)>n},[e.tags]),s=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]),c=i?E:se,l=i?`Listening to`:r===`general`?`Status`:`${r} status`,u=!a||o;return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:s,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(c,{className:`size-3 shrink-0`}),l]}),u?(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:o?`This status has expired`:`No status set`}):(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm font-medium leading-snug break-words line-clamp-3 text-foreground`,children:(0,Q.jsx)(Xt,{tags:e.tags,children:a})})]})}function Co({event:e,className:t,disableHoverCards:n}){let r=t=>e.tags.find(([e])=>e===t)?.[1],i=L(r(`r`)),a=r(`title`)?.trim(),o=r(`description`)?.trim(),s=L(r(`image`)),c=i?new URL(i).hostname.replace(/^www\./,``):r(`d`),l=(0,Z.useMemo)(()=>{let t=e.tags.find(([e])=>e===`d`)?.[1]??``;return P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:t})},[e]);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:l,className:t,disableHoverCards:n,children:[s&&(0,Q.jsx)(`div`,{className:`relative w-full overflow-hidden rounded-lg bg-muted/30`,style:{aspectRatio:`1.91`},children:(0,Q.jsx)(`img`,{src:s,alt:``,loading:`lazy`,decoding:`async`,className:`absolute inset-0 size-full object-cover`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-primary`,children:[(0,Q.jsx)(y,{className:`size-3`}),`Bookmark`]}),a&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm font-semibold leading-snug line-clamp-2 break-words`,children:a}),o&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-xs text-muted-foreground leading-relaxed line-clamp-2 break-words`,children:o}),c&&(0,Q.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:c})]})}function wo({addr:e,className:t}){let n=K(),r=(0,Z.useMemo)(()=>P.naddrEncode({kind:e.kind,pubkey:e.pubkey,identifier:e.identifier}),[e]);return(0,Q.jsx)(`div`,{className:z(`rounded-2xl border border-dashed border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),n(`/${r}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),n(`/${r}`))},children:(0,Q.jsxs)(`div`,{className:`px-3.5 py-4 flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`This post could not be loaded`})]})})}function To({className:e}){return(0,Q.jsx)(`div`,{className:z(`rounded-2xl border border-border overflow-hidden`,e),children:(0,Q.jsxs)(`div`,{className:`px-3.5 py-2.5 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{className:`size-5 rounded-full`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`}),(0,Q.jsx)(X,{className:`h-3 w-10`})]}),(0,Q.jsx)(X,{className:`h-4 w-3/4`}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(X,{className:`h-3 w-full`}),(0,Q.jsx)(X,{className:`h-3 w-4/5`})]})]})})}var Eo=1984,Do=[`nudity`,`malware`,`profanity`,`illegal`,`spam`,`impersonation`,`other`],Oo={nudity:`Nudity`,malware:`Malware`,profanity:`Hateful speech`,illegal:`Illegal content`,spam:`Spam`,impersonation:`Impersonation`,other:`Other`},ko=new Set([`root`,`reply`,`mention`]);function Ao(e){return typeof e==`string`&&/^wss?:\/\//i.test(e)}function jo(e){if(!e)return;let t=e.trim().toLowerCase();if(!(!t||Ao(t)||ko.has(t)))return t}function Mo(e){if(e.kind!==1984)return;let t=e.tags.find(([e,t])=>e===`e`&&V(t)),n=e.tags.find(([e,t])=>e===`p`&&V(t)),r=e.tags.find(([e,t])=>e===`x`&&V(t));if(!t&&!n&&!r)return;let i=n&&V(n[1])?n[1]:void 0,a=jo(t?.[2])??jo(r?.[2])??jo(n?.[2]),o=Do.find(e=>e===a),s;if(t&&V(t[1])){let e=Ao(t[2])?t[2]:void 0;s={id:t[1],relays:e?[e]:void 0,authorHint:i}}let c;if(r&&V(r[1])){let t=e.tags.filter(([e])=>e===`server`).map(([,e])=>L(e)).filter(e=>!!e);c={hash:r[1],servers:t}}return{type:o,rawType:a,event:s,pubkey:i,blob:c,reason:e.content.trim()||void 0}}function No(e){let t=Mo(e);return t?.event?`post`:t?.blob?`file`:t?.pubkey?`user`:`post`}var Po=new Set([`illegal`,`malware`]),Fo=`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`;function Io({type:e,rawType:t,className:n}){let r=e?Oo[e]:t?t.charAt(0).toUpperCase()+t.slice(1):`Report`;return(0,Q.jsxs)(`span`,{className:z(`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold`,e&&Po.has(e)?`border-destructive/30 bg-destructive/10 text-destructive`:e?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-400`:`border-border bg-secondary text-muted-foreground`,n),children:[(0,Q.jsx)(je,{className:`size-3.5`,"aria-hidden":`true`}),r]})}function Lo({event:e,expanded:t=!1,className:n}){let r=(0,Z.useMemo)(()=>Mo(e),[e]),[i,a]=(0,Z.useState)(!1);if(!r)return(0,Q.jsx)(`div`,{className:z(`mt-2 rounded-xl border border-dashed border-border px-4 py-3 text-sm text-muted-foreground`,n),children:`Malformed report`});let{type:o,rawType:s,reason:c,pubkey:l,blob:u,event:d}=r;return(0,Q.jsxs)(`div`,{className:z(t?`mt-3 space-y-3`:`mt-2 space-y-2.5`,n),children:[(0,Q.jsx)(Io,{type:o,rawType:s}),c&&(0,Q.jsx)(`p`,{dir:`auto`,className:z(`whitespace-pre-wrap break-words text-foreground`,t?`text-[17px] leading-relaxed`:`text-[15px] leading-relaxed`),children:c}),d&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:Fo,children:[(0,Q.jsx)(je,{className:`size-3`,"aria-hidden":`true`}),`Reported post`]}),i?(0,Q.jsx)(pu,{eventId:d.id,relays:d.relays,authorHint:d.authorHint,className:`my-0`}):(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a(!0)},className:z(`flex w-full items-center justify-center gap-2 rounded-xl border border-dashed border-border`,`bg-muted/30 px-4 py-3 text-sm text-muted-foreground transition-colors`,`hover:bg-secondary/60 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,Q.jsx)(N,{className:`size-4`,"aria-hidden":`true`}),`Show reported post`]})]}),!d&&l&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:Fo,children:[(0,Q.jsx)(Pe,{className:`size-3`,"aria-hidden":`true`}),`Reported user`]}),(0,Q.jsx)(`div`,{className:`text-[15px]`,children:(0,Q.jsx)(an,{pubkey:l})})]}),u&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:Fo,children:[(0,Q.jsx)(ue,{className:`size-3`,"aria-hidden":`true`}),`Reported file`]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border border-border bg-muted/30 px-3 py-2 space-y-1`,children:[(0,Q.jsx)(`p`,{className:`font-mono text-xs break-all text-muted-foreground`,children:u.hash}),u.servers.length>0&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Hosted on `,u.servers.map(Dt).join(`, `)]})]})]})]})}function Ro({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>Mo(e),[e]),i=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:i,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(je,{className:`size-3`,"aria-hidden":`true`}),`Report`]}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Io,{type:r.type,rawType:r.rawType}),r.reason&&(0,Q.jsx)(`p`,{dir:`auto`,className:`text-sm leading-relaxed whitespace-pre-wrap break-words line-clamp-3 text-foreground`,children:r.reason})]}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`Malformed report`})]})}function zo({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>yn({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),i=Sr(e),a=xr(e);return r?(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:r,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(oe,{className:`size-3`}),a===`weekly`?(0,Q.jsx)(kt,{id:`tarot.card.weeklyReading`,defaultMessage:`Weekly tarot reading`}):(0,Q.jsx)(kt,{id:`tarot.card.dailyReading`,defaultMessage:`Daily tarot reading`})]}),i?(0,Q.jsx)(`ul`,{className:`space-y-0.5`,children:i.map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex items-baseline gap-2 text-sm text-foreground`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase tracking-wide text-muted-foreground w-14`,children:Cr[t]?(0,Q.jsx)(kt,{...Cr[t]}):e.position}),(0,Q.jsxs)(`span`,{className:`font-medium truncate`,children:[e.name,e.isReversed&&(0,Q.jsxs)(`span`,{className:`text-muted-foreground font-normal`,children:[` `,(0,Q.jsx)(kt,{id:`tarot.orientation.reversedParen`,defaultMessage:`(Reversed)`})]})]})]},`${e.name}-${t}`))}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:(0,Q.jsx)(kt,{id:`tarot.card.empty`,defaultMessage:`Tarot reading`})})]}):null}var Bo={sm:`size-6`,md:`size-7`,lg:`size-9`},Vo={sm:`-space-x-1.5`,md:`-space-x-2`,lg:`-space-x-3`},Ho={sm:`text-[10px]`,md:`text-[10px]`,lg:`text-xs`};function Uo({pubkeys:e,maxVisible:t=6,size:n=`md`,className:r}){let i=(0,Z.useMemo)(()=>e.slice(0,t),[e,t]),{data:a}=_n(i);if(e.length===0)return null;let o=e.length-i.length;return(0,Q.jsxs)(`div`,{className:z(`flex items-center gap-2`,r),children:[(0,Q.jsx)(`div`,{className:z(`flex`,Vo[n]),children:i.map(e=>{let t=a?.get(e),r=t?.metadata?.name||t?.metadata?.display_name||`Anonymous`,i=U(t?.metadata);return(0,Q.jsxs)(Nn,{children:[(0,Q.jsx)(jn,{asChild:!0,children:(0,Q.jsx)(q,{to:`/${P.npubEncode(e)}`,"aria-label":r,onClick:e=>e.stopPropagation(),className:z(`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,Q.jsxs)(G,{shape:i,className:z(Bo[n],`ring-2 ring-background`),children:[(0,Q.jsx)(W,{src:t?.metadata?.picture,alt:r}),(0,Q.jsx)(H,{className:z(`bg-primary/20 text-primary`,Ho[n]),children:r[0]?.toUpperCase()})]})})}),(0,Q.jsx)(Mn,{side:`bottom`,className:`text-xs`,children:r})]},e)})}),o>0&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`+`,o,` more`]})]})}function Wo(e){return F({queryKey:[`archive-org-meta`,e],queryFn:async({signal:t})=>{let n=await fetch(`https://archive.org/metadata/${e}`,{signal:t});if(!n.ok)return{dims:null,mediatype:null};let r=await n.json(),i=r.metadata?.mediatype??null,a=(r.files??[]).filter(e=>e.width&&e.height),o=a.find(e=>e.source===`original`)??a[0],s=null;if(o){let e=Number(o.width),t=Number(o.height);e&&t&&(s={width:e,height:t})}return{dims:s,mediatype:i}},staleTime:1e3*60*60,gcTime:1e3*60*60*24,retry:!1})}function Go({identifier:e,className:t}){let[n,r]=(0,Z.useState)(!1),{data:i}=Wo(e),[a,o]=(0,Z.useState)(0),s=(0,Z.useCallback)(e=>{if(!e)return;let t=new ResizeObserver(e=>{for(let t of e)o(t.contentRect.width)});t.observe(e),o(e.getBoundingClientRect().width),c.current=t},[]),c=(0,Z.useRef)(null),l=`https://archive.org/services/img/${e}`,u=i?.mediatype===`software`,d=i?.dims?.width??640,f=i?.dims?.height??480,p=`${f/d*100}%`,m=a>0?Math.min(1,a/d):1,h=f*m;return(0,Q.jsx)(`div`,{ref:s,className:z(`rounded-2xl overflow-hidden border border-border`,t),onClick:e=>e.stopPropagation(),children:n?u?(0,Q.jsx)(`div`,{className:`relative overflow-hidden bg-black`,style:{height:h},children:(0,Q.jsx)(`iframe`,{src:`https://archive.org/embed/${e}&autoplay=1`,title:`Internet Archive`,allow:`autoplay`,allowFullScreen:!0,style:{width:d,height:f,transform:`scale(${m})`,transformOrigin:`top left`,border:`none`}})}):(0,Q.jsx)(`div`,{className:`relative w-full`,style:{paddingBottom:p},children:(0,Q.jsx)(`iframe`,{src:`https://archive.org/embed/${e}&autoplay=1`,title:`Internet Archive`,allow:`autoplay`,allowFullScreen:!0,className:`absolute inset-0 w-full h-full`})}):(0,Q.jsx)(`div`,{className:`relative w-full`,style:{paddingBottom:p},children:(0,Q.jsxs)(`button`,{type:`button`,className:`absolute inset-0 w-full h-full cursor-pointer bg-black group`,onClick:()=>r(!0),"aria-label":`Load content`,children:[(0,Q.jsx)(`img`,{src:l,alt:``,className:`absolute inset-0 w-full h-full object-contain`,decoding:`async`}),(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:z(`flex items-center justify-center`,`w-[68px] h-[48px] rounded-xl`,`bg-[#212121]/80 group-hover:bg-[#428bca] transition-colors duration-200`),children:(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:`w-6 h-6 text-white ml-0.5`,children:(0,Q.jsx)(`path`,{d:`M8 5v14l11-7z`})})})})]})})})}function Ko(e){let t=new Date(e),n=Math.floor((Date.now()-t.getTime())/1e3);return n<60?`${n}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:n<604800?`${Math.floor(n/86400)}d`:n<2592e3?`${Math.floor(n/604800)}w`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function qo({post:e,hideImage:t,className:n}){let r=K();return(0,Q.jsxs)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,n),role:`link`,tabIndex:0,onClick:t=>{t.stopPropagation(),r(`/i/${encodeURIComponent(e.postUrl)}`)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),r(`/i/${encodeURIComponent(e.postUrl)}`))},children:[!t&&e.images&&e.images.length>0&&(0,Q.jsx)(`div`,{className:z(`w-full overflow-hidden`,e.images.length>1?`grid grid-cols-2 gap-px`:``),children:e.images.slice(0,4).map((t,n)=>(0,Q.jsx)(`img`,{src:t.thumb,alt:t.alt||``,className:z(`w-full object-cover`,e.images.length===1?`max-h-[300px]`:`h-[150px]`),loading:`lazy`,onError:e=>{e.currentTarget.style.display=`none`},decoding:`async`},n))}),!t&&!e.images&&e.external?.thumb&&(0,Q.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,Q.jsx)(`img`,{src:e.external.thumb,alt:``,className:`w-full h-[160px] object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`})}),(0,Q.jsxs)(`div`,{className:`px-3 py-2 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0`,onClick:t=>{t.stopPropagation(),r(`/i/${encodeURIComponent(e.profileUrl)}`)},children:(0,Q.jsxs)(G,{className:`size-5`,children:[(0,Q.jsx)(W,{src:e.avatar,alt:e.displayName}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[10px]`,children:e.displayName[0]?.toUpperCase()})]})}),(0,Q.jsx)(`button`,{type:`button`,className:`text-sm font-semibold truncate hover:underline`,onClick:t=>{t.stopPropagation(),r(`/i/${encodeURIComponent(e.profileUrl)}`)},children:e.displayName}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground truncate`,children:[`@`,e.handle]}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,Ko(e.createdAt)]})]}),e.text&&(0,Q.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words overflow-hidden line-clamp-6`,children:e.text}),e.external&&e.external.title&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:e.external.title}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 pt-0.5`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(ve,{className:`size-3.5`}),wr(e.replyCount)]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(g,{className:`size-3.5`}),wr(e.repostCount)]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(a,{className:`size-3.5`}),wr(e.likeCount)]}),e.brandIcon&&(0,Q.jsx)(`a`,{href:e.postUrl,target:`_blank`,rel:`noopener noreferrer`,className:`ml-auto text-[11px] text-muted-foreground flex items-center gap-1 hover:text-foreground transition-colors`,onClick:e=>e.stopPropagation(),children:e.brandIcon})]})]})]})}function Jo({className:e}){return(0,Q.jsx)(`div`,{className:z(`rounded-2xl border border-border overflow-hidden`,e),children:(0,Q.jsxs)(`div`,{className:`px-3 py-2.5 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{className:`size-5 rounded-full`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`}),(0,Q.jsx)(X,{className:`h-3 w-20`}),(0,Q.jsx)(X,{className:`h-3 w-10`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(X,{className:`h-3.5 w-full`}),(0,Q.jsx)(X,{className:`h-3.5 w-4/5`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 pt-0.5`,children:[(0,Q.jsx)(X,{className:`h-3 w-10`}),(0,Q.jsx)(X,{className:`h-3 w-10`}),(0,Q.jsx)(X,{className:`h-3 w-10`})]})]})})}function Yo(e,t){let n=e.startsWith(`did:`),{data:r,isLoading:i}=F({queryKey:[`bsky-resolve-handle`,e],queryFn:async({signal:t})=>{let n=await fetch(`https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=${encodeURIComponent(e)}`,{signal:t});return n.ok?(await n.json()).did??null:null},enabled:!n,staleTime:1/0,gcTime:1e3*60*60*24,retry:!1}),a=n?e:r,o=F({queryKey:[`bsky-post`,a,t],queryFn:async({signal:e})=>{let n=`at://${a}/app.bsky.feed.post/${t}`,r=await fetch(`https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread?uri=${encodeURIComponent(n)}&depth=0`,{signal:e});if(!r.ok)return null;let i=(await r.json()).thread?.post;if(!i)return null;let o=i.author.handle,s=i.embed?.$type===`app.bsky.embed.images#view`&&i.embed.images?i.embed.images.map(e=>({thumb:e.thumb,alt:e.alt})):void 0,c=i.embed?.$type===`app.bsky.embed.external#view`&&i.embed.external?{title:i.embed.external.title,thumb:i.embed.external.thumb}:void 0;return{displayName:i.author.displayName||o,handle:o,avatar:i.author.avatar,text:i.record.text??``,createdAt:i.record.createdAt??``,postUrl:`https://bsky.app/profile/${o}/post/${t}`,profileUrl:`https://bsky.app/profile/${o}`,replyCount:i.replyCount??0,repostCount:(i.repostCount??0)+(i.quoteCount??0),likeCount:i.likeCount??0,images:s,external:c}},enabled:!!a,staleTime:1e3*60*5,gcTime:1e3*60*60,retry:!1});return{...o,isLoading:i||o.isLoading}}function Xo({className:e}){return(0,Q.jsx)(`svg`,{className:e,viewBox:`0 0 600 530`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,"aria-label":`Bluesky`,children:(0,Q.jsx)(`path`,{d:`m135.72 44.03c66.496 49.921 138.02 151.14 164.28 205.46 26.262-54.316 97.782-155.54 164.28-205.46 47.98-36.021 125.72-63.892 125.72 24.795 0 17.712-10.155 148.79-16.111 170.07-20.703 73.984-96.144 92.854-163.25 81.433 117.3 19.964 147.14 86.092 82.697 152.22-122.39 125.59-175.91-31.511-189.63-71.766-2.514-7.3797-3.6904-10.832-3.7077-7.8964-0.0174-2.9357-1.1937 0.51669-3.7077 7.8964-13.714 40.255-67.233 197.36-189.63 71.766-64.444-66.128-34.605-132.26 82.697-152.22-67.108 11.421-142.55-7.4491-163.25-81.433-5.9562-21.282-16.111-152.36-16.111-170.07 0-88.687 77.742-60.816 125.72-24.795z`})})}function Zo({author:e,rkey:t,hideImage:n,className:r}){let{data:i,isLoading:a,isError:o}=Yo(e,t);return a?(0,Q.jsx)(Jo,{className:r}):o||!i?null:(0,Q.jsx)(qo,{post:{...i,brandIcon:(0,Q.jsx)(Xo,{className:`size-3.5`})},hideImage:n,className:r})}function Qo(e){try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}}function $o({url:e,className:t,hideImage:n,navigateToComments:r,showActions:i=!0}){let{data:a,isLoading:o}=Kn(e),s=K();if(o)return(0,Q.jsx)(es,{className:t});let c=a?.provider_name||Qo(e),l=a?.thumbnail_url;return(0,Q.jsxs)(`a`,{href:e,target:r?void 0:`_blank`,rel:r?void 0:`noopener noreferrer`,className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors`,t),onClick:t=>{t.stopPropagation(),r&&(t.preventDefault(),s(`/i/${encodeURIComponent(e)}`))},children:[l&&!n&&(0,Q.jsx)(`div`,{className:`w-full overflow-hidden`,children:(0,Q.jsx)(`img`,{src:l,alt:``,className:`w-full h-[180px] object-cover`,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.style.display=`none`},decoding:`async`})}),(0,Q.jsxs)(`div`,{className:`px-3.5 py-2.5 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(dn,{url:e,size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:c}),i&&(r?(0,Q.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:z(`ml-auto flex items-center gap-1 px-2 py-0.5 rounded-full`,`text-xs text-muted-foreground`,`hover:bg-primary/10 hover:text-primary transition-colors`),onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(b,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Open`})]}):(0,Q.jsxs)(`button`,{type:`button`,className:z(`ml-auto flex items-center gap-1 px-2 py-0.5 rounded-full`,`text-xs text-muted-foreground`,`hover:bg-primary/10 hover:text-primary transition-colors`),onClick:t=>{t.preventDefault(),t.stopPropagation(),s(`/i/${encodeURIComponent(e)}`)},children:[(0,Q.jsx)(xe,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Discuss`})]}))]}),a?.title&&(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2`,children:a.title}),a?.author_name&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:a.author_name})]})]})}function es({className:e}){return(0,Q.jsxs)(`div`,{className:z(`rounded-2xl border border-border overflow-hidden`,e),children:[(0,Q.jsx)(X,{className:`w-full h-[180px] rounded-none`}),(0,Q.jsxs)(`div`,{className:`px-3.5 py-2.5 space-y-1.5`,children:[(0,Q.jsx)(X,{className:`h-3 w-24`}),(0,Q.jsx)(X,{className:`h-4 w-3/4`}),(0,Q.jsx)(X,{className:`h-3 w-full`})]})]})}function ts(e){return e.replace(//gi,` `).replace(/<\/p>\s*

/gi,` `).replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/'/g,`'`).trim()}function ns(e){return F({queryKey:[`mastodon-post`,e],queryFn:async({signal:t})=>{let n;try{n=new URL(e)}catch{return null}let r=n.origin,i=n.pathname.split(`/`),a=i[i.length-1];if(!a||!/^\d+$/.test(a))return null;let o=await fetch(`${r}/api/v1/statuses/${a}`,{signal:t});if(!o.ok)return null;let s=await o.json(),c=s.media_attachments.length>0?s.media_attachments.filter(e=>e.type===`image`).map(e=>({thumb:e.preview_url||e.url,alt:e.description||``})):void 0,l=!c&&s.card?.title?{title:s.card.title,thumb:s.card.image??void 0}:void 0,u=s.account.acct.includes(`@`)?s.account.acct:`${s.account.acct}@${n.hostname}`;return{displayName:s.account.display_name||s.account.username,handle:u,avatar:s.account.avatar,text:ts(s.content),createdAt:s.created_at,postUrl:s.url||e,profileUrl:s.account.url,replyCount:s.replies_count,repostCount:s.reblogs_count,likeCount:s.favourites_count,images:c&&c.length>0?c:void 0,external:l}},staleTime:1e3*60*5,gcTime:1e3*60*60,retry:!1})}function rs({className:e}){return(0,Q.jsxs)(`svg`,{className:e,viewBox:`0 0 216.4 232`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,"aria-label":`Mastodon`,children:[(0,Q.jsx)(`path`,{d:`M211.8 139.1c-3.2 16.4-28.6 34.3-57.8 37.8-15.2 1.8-30.2 3.5-46.1 2.8-26.1-1.2-46.7-6.2-46.7-6.2 0 2.5.2 4.9.5 7.2 3.8 28.6 28.4 30.3 51.7 31.1 23.5.7 44.5-5.8 44.5-5.8l1 21.7s-16.5 8.8-45.8 10.5c-16.2.9-36.3-.4-59.7-6.7C7.5 213.8 1.2 165.4.2 116.3c-.3-14.6-.1-28.3-.1-39.8 0-50.2 32.9-64.9 32.9-64.9C49.6 3.5 78.1.2 107.8 0h.7c29.7.2 58.2 3.5 74.9 11.6 0 0 32.9 14.7 32.9 64.9 0 0 .4 37.1-4.5 62.6`}),(0,Q.jsx)(`path`,{d:`M177.5 80.5v60.3h-23.9v-58.5c0-12.3-5.2-18.6-15.5-18.6-11.4 0-17.2 7.4-17.2 22.1v32h-23.8V85.8c0-14.7-5.7-22.1-17.2-22.1-10.3 0-15.5 6.3-15.5 18.6v58.5H40.5V80.5c0-12.3 3.1-22.1 9.4-29.4 6.5-7.3 15-11 25.5-11 12.2 0 21.4 4.7 27.4 14.1l5.9 9.9 5.9-9.9c6-9.4 15.2-14.1 27.4-14.1 10.5 0 19 3.7 25.5 11 6.3 7.3 9.4 17.1 9.4 29.4`,fill:`var(--background, #fff)`})]})}function is({url:e,className:t}){let{data:n,isLoading:r,isError:i}=ns(e);return r?(0,Q.jsx)(Jo,{className:t}):i||!n?null:(0,Q.jsx)(qo,{post:{...n,brandIcon:(0,Q.jsx)(rs,{className:`size-3.5`})},className:t})}function as({url:e,className:t}){let n=(0,Z.useRef)(null),r=(()=>{try{let t=new URL(e);return t.hostname=`embed.reddit.com`,t.search=``,t.hash=``,t.toString()}catch{return e}})();return(0,Z.useEffect)(()=>{let e=e=>{if(e.origin!==`https://embed.reddit.com`||!n.current||e.source!==n.current.contentWindow)return;let t=e.data;typeof t!=`object`||!t||t.type===`resize.embed`&&typeof t.data==`number`&&t.data>0&&(n.current.style.height=`${t.data}px`,n.current.style.minHeight=`0`)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),(0,Q.jsx)(`div`,{className:z(`rounded-2xl border border-border overflow-hidden`,t),children:(0,Q.jsx)(`iframe`,{ref:n,src:r,title:`Reddit post`,className:`w-full border-0`,style:{minHeight:320},allowFullScreen:!0,loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-popups allow-forms`})})}var os={track:152,episode:152,album:352,playlist:352,show:352};function ss({type:e,id:t,className:n}){let r=os[e]??352,i=`https://open.spotify.com/embed/${e}/${t}?utm_source=generator&theme=0`;return(0,Q.jsx)(`div`,{className:z(`overflow-hidden rounded-2xl`,n),children:(0,Q.jsx)(`iframe`,{src:i,title:`Spotify`,className:`w-full border-0 rounded-2xl`,height:r,allowFullScreen:!0,loading:`lazy`,allow:`autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture`,sandbox:`allow-scripts allow-same-origin allow-popups allow-forms`})})}function cs({tweetId:e,className:t}){wt();let n=(0,Z.useRef)(null),r=Tt(),i=new URLSearchParams({id:e,dnt:`true`,theme:r});return(0,Z.useEffect)(()=>{let e=e=>{if(e.origin!==`https://platform.twitter.com`||!n.current||e.source!==n.current.contentWindow)return;let t=e.data?.[`twttr.embed`];if(!(!t||typeof t!=`object`)&&t.method===`twttr.private.resize`){let e=t.params?.[0]?.height;typeof e==`number`&&e>0&&(n.current.style.height=`${e}px`)}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),(0,Q.jsx)(`div`,{className:z(`overflow-hidden`,t),children:(0,Q.jsx)(`iframe`,{ref:n,src:`https://platform.twitter.com/embed/Tweet.html?${i}`,title:`Tweet`,className:`w-full border-0`,style:{minHeight:250},scrolling:`no`,allowFullScreen:!0,loading:`lazy`,sandbox:`allow-scripts allow-same-origin allow-popups`})})}var ls=[`sddefault`,`hqdefault`];function us(e,t){return`https://i.ytimg.com/vi/${e}/${t}.jpg`}function ds(e){return new Promise(t=>{let n=!1;function r(i){if(i>=ls.length){n||(n=!0,t(null));return}let a=new Image;a.onload=()=>{n||(a.naturalWidth<=120&&a.naturalHeight<=90?r(i+1):(n=!0,t(us(e,ls[i]))))},a.onerror=()=>{n||r(i+1)},a.src=us(e,ls[i])}r(0)})}function fs({videoId:e,className:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=!1;return a(null),ds(e).then(e=>{t||a(e)}),()=>{t=!0}},[e]),(0,Q.jsx)(`div`,{className:z(`rounded-2xl overflow-hidden border border-border`,t),onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(`div`,{className:`relative w-full`,style:{paddingBottom:`56.25%`},children:n?(0,Q.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${e}?autoplay=1`,title:`YouTube video`,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share`,allowFullScreen:!0,className:`absolute inset-0 w-full h-full`}):(0,Q.jsxs)(`button`,{type:`button`,className:`absolute inset-0 w-full h-full cursor-pointer bg-black group`,onClick:()=>r(!0),"aria-label":`Play video`,children:[i&&(0,Q.jsx)(`img`,{src:i,alt:``,className:`absolute inset-0 w-full h-full object-cover`,decoding:`async`}),(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:z(`flex items-center justify-center`,`w-[68px] h-[48px] rounded-xl`,`bg-[#212121]/80 group-hover:bg-[#ff0000] transition-colors duration-200`),children:(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:`w-6 h-6 text-white ml-0.5`,children:(0,Q.jsx)(`path`,{d:`M8 5v14l11-7z`})})})})]})})})}var ps=new Set(`23.illuminati.org,4bear.com,ailbhean.co-shaoghal.net,ani.work,apobangpo.space,archaeo.social,arvr.social,augsburg.social,aus.social,babka.social,bahn.social,balkan.fedive.rs,bark.lgbt,biplus.social,birdon.social,blorbo.social,bologna.one,bonn.social,bookstodon.com,burma.social,burningboard.net,bvb.social,bzh.social,c.im,camp.smolnet.org,ceilidh.online,ciberlandia.pt,climatejustice.social,colorid.es,computerfairi.es,corteximplant.com,cultur.social,cupoftea.social,cville.online,cwb.social,cyberplace.social,dariox.club,darmstadt.social,darticulate.com,datasci.social,defcon.social,det.social,devianze.city,disabled.social,discuss.systems,dizl.de,dmv.community,donphan.social,dresden.network,drumstodon.net,drupal.community,elekk.xyz,elizur.me,epicure.social,episcodon.net,epsilon.social,esq.social,est.social,eupolicy.social,expressional.social,fairmove.net,fairy.id,famichiki.jp,fandom.ink,fedi.at,feuerwehr.social,fikaverse.club,flipboard.social,fpl.social,freeradical.zone,freiburg.social,fribygda.no,friendsofdesoto.social,frikiverse.zone,frontrange.co,fulda.social,furries.club,furry.engineer,gamepad.club,gardenstate.social,gaygeek.social,genealysis.social,glasgow.social,graphics.social,growers.social,h-net.social,h4.io,hachyderm.io,hcommons.social,hear-me.social,hessen.social,hispagatos.space,hometech.social,hoosier.social,hostux.social,ieji.de,indieauthors.social,indieweb.social,infosec.exchange,ioc.exchange,is.nota.live,k8s.social,kanoa.de,kcmo.social,khiar.net,kjas.no,kolektiva.social,kurry.social,kzoo.to,learningdisability.social,leipzig.town,lewacki.space,lgbtqia.space,library.love,libretooth.gr,livellosegreto.it,lou.lt,lounge.town,lsbt.me,ludosphere.fr,m.cmx.im,m.otter.homes,machteburch.social,mapstodon.space,mast.dragon-fly.club,mast.hpc.social,mast.lat,masto.es,masto.nobigtech.es,masto.nu,masto.nyc,masto.pt,masto.yttrx.com,mastoart.social,mastodon-belgium.be,mastodon-swiss.org,mastodon.africa,mastodon.au,mastodon.babb.no,mastodon.bachgau.social,mastodon.bahia.no,mastodon.berlin,mastodon.bida.im,mastodon.bot,mastodon.cipherbliss.com,mastodon.com.pl,mastodon.cr,mastodon.education,mastodon.ee,mastodon.energy,mastodon.escepticos.es,mastodon.eus,mastodon.free-solutions.org,mastodon.frl,mastodon.gal,mastodon.gamedev.place,mastodon.green,mastodon.hosnet.fr,mastodon.ie,mastodon.iow.social,mastodon.london,mastodon.me.uk,mastodon.mg,mastodon.ml,mastodon.nl,mastodon.nu,mastodon.ph,mastodon.pirateparty.be,mastodon.pnpde.social,mastodon.scot,mastodon.sdf.org,mastodon.sg,mastodon.social,mastodon.uno,mastodon.uy,mastodon.vlaanderen,mastodon.wien,mastodon.world,mastodonapp.uk,mastodont.cat,mastodontech.de,mastodontti.fi,mastorol.es,mastoturk.org,mastouille.fr,mathstodon.xyz,mcr.wtf,metalhead.club,mikumikudance.cloud,mindly.social,mograph.social,mountains.social,ms.maritime.social,mstdn.animexx.de,mstdn.business,mstdn.ca,mstdn.dk,mstdn.games,mstdn.jp,mstdn.party,mstdn.plus,mstdn.social,muenchen.social,muenster.im,muri.network,musician.social,musicians.today,musicworld.social,mustard.blog,nautical.social,nfld.me,noc.social,nomanssky.social,norcal.social,norden.social,nrw.social,nutmeg.social,nwb.social,occm.cc,ohai.social,okla.social,opalstack.social,opencoaster.net,oslo.town,paktodon.asia,pawb.fun,peoplemaking.games,phpc.social,piaille.fr,planetearth.social,pnw.zone,polsci.social,pouet.chapril.org,poweredbygay.social,privacysafe.social,puntarella.party,qaf.men,qdon.space,rail.chat,raphus.social,retro.pizza,rheinhessen.social,rheinneckar.social,rivals.space,rollenspiel.social,ruby.social,ruhr.social,ruhrpott.social,sakurajima.moe,sciences.social,seocommunity.social,sfba.social,shelter.moe,silversword.online,skastodon.com,snabelen.no,socel.net,social.anoxinon.de,social.cologne,social.diva.exchange,social.ferrocarril.net,social.linux.pizza,social.politicaconciencia.org,social.seattle.wa.us,social.silicon.moe,social.sndevs.com,social.tchncs.de,social.vivaldi.net,squawk.mytransponder.com,stereodon.social,stranger.social,sueden.social,sunny.garden,synapse.cafe,tchafia.be,tea.codes,tech.lgbt,techhub.social,techtoots.com,theatl.social,theblower.au,thecanadian.social,tilde.zone,tkz.one,toad.social,tooot.im,toot.aquilenet.fr,toot.community,toot.funami.tech,toot.garden,toot.kif.rocks,toot.re,toot.si,toot.wales,tooting.ch,toots.nu,troet.cafe,troet.fediverse.at,tuiter.rocks,tyrol.social,union.place,universeodon.com,urbanists.social,uri.life,ursal.zone,urusai.social,veganism.social,vkl.world,vmst.io,voi.social,wargamers.social,wehavecookies.social,wien.rocks,witter.cz,woof.tech,wxw.moe,xarxa.cloud`.split(`,`));function ms(e){try{let t=new URL(e);if((t.hostname===`www.youtube.com`||t.hostname===`youtube.com`||t.hostname===`m.youtube.com`)&&t.pathname===`/watch`)return t.searchParams.get(`v`);if((t.hostname===`www.youtube.com`||t.hostname===`youtube.com`)&&t.pathname.startsWith(`/embed/`)||(t.hostname===`www.youtube.com`||t.hostname===`youtube.com`)&&t.pathname.startsWith(`/shorts/`))return t.pathname.split(`/`)[2]||null;if(t.hostname===`youtu.be`)return t.pathname.slice(1)||null}catch{}return null}function hs(e){try{let t=new URL(e),n=t.hostname.replace(/^www\./,``).replace(/^mobile\./,``);if(n!==`twitter.com`&&n!==`x.com`)return null;let r=t.pathname.match(/^\/[^/]+\/status\/(\d+)/);return r?r[1]:null}catch{return null}}function gs(e){try{let t=new URL(e);if(t.hostname.replace(/^www\./,``)!==`bsky.app`)return null;let n=t.pathname.match(/^\/profile\/([^/]+)\/post\/([a-z0-9]+)$/i);return n?{author:n[1],rkey:n[2]}:null}catch{return null}}function _s(e){try{let t=new URL(e),n=t.hostname.replace(/^www\./,``);return ps.has(n)&&/^\/@[^/]+\/\d+$/.test(t.pathname)?e:null}catch{return null}}function vs(e){try{let t=new URL(e);if(t.hostname.replace(/^www\./,``)!==`open.spotify.com`)return null;let n=t.pathname.match(/^\/(track|album|playlist|episode|show)\/([a-zA-Z0-9]+)/);return n?{type:n[1],id:n[2]}:null}catch{return null}}function ys(e){try{let t=new URL(e);return t.hostname.replace(/^www\./,``).replace(/^old\./,``).replace(/^new\./,``)===`reddit.com`&&/^\/r\/[^/]+\/comments\/[a-z0-9]+/i.test(t.pathname)?e:null}catch{return null}}function bs(e){try{let t=new URL(e);if(t.hostname.replace(/^www\./,``)!==`archive.org`)return null;let n=t.pathname.match(/^\/(details|embed)\/([^/?#]+)/);return n?n[2]:null}catch{return null}}function xs(e){try{let t=new URL(e);if(t.hostname.replace(/^www\./,``)!==`wikidata.org`)return null;let n=t.pathname.match(/^\/(?:entity|wiki)\/([QPL]\d+)$/);return n?n[1]:null}catch{return null}}function Ss(e){try{let t=new URL(e);if(!t.hostname.replace(/^www\./,``).endsWith(`.wikipedia.org`))return null;let n=t.pathname.match(/^\/wiki\/([^:][^#]*)$/);return n?decodeURIComponent(n[1].replace(/_/g,` `)):null}catch{return null}}function Cs(e){try{let t=new URL(e);if(t.hostname.replace(/^www\./,``)!==`gatherer.wizards.com`)return null;if(/\/Pages\/Card\/[^/]+\.aspx$/i.test(t.pathname)){let e=t.searchParams.get(`multiverseid`);return e&&/^\d+$/.test(e)?{kind:`multiverse`,multiverseId:e}:null}let n=t.pathname.match(/^\/([A-Za-z0-9]{2,6})\/([a-z]{2}(?:-[a-z]{2})?)\/([^/]+)(?:\/[^/]*)?$/);if(n){let[,e,t,r]=n;return{kind:`set`,set:e,number:decodeURIComponent(r),lang:t}}return null}catch{return null}}function ws(e){return ms(e)?`YouTube`:hs(e)?`Twitter`:gs(e)?`Bluesky`:_s(e)?`Mastodon`:vs(e)?`Spotify`:ys(e)?`Reddit`:bs(e)?`Internet Archive`:Cs(e)?`Gatherer`:null}function Ts({url:e,className:t,navigateToComments:n,showActions:r=!0,hideImage:i}){let a=(0,Z.useMemo)(()=>ms(e),[e]),o=(0,Z.useMemo)(()=>hs(e),[e]),s=(0,Z.useMemo)(()=>gs(e),[e]),c=(0,Z.useMemo)(()=>_s(e),[e]),l=(0,Z.useMemo)(()=>vs(e),[e]),u=(0,Z.useMemo)(()=>ys(e),[e]),d=(0,Z.useMemo)(()=>bs(e),[e]),f;if(a)f=(0,Q.jsx)(fs,{videoId:a});else if(o)f=(0,Q.jsx)(cs,{tweetId:o});else if(s)return(0,Q.jsx)(Zo,{author:s.author,rkey:s.rkey,hideImage:i,className:t});else if(c)return(0,Q.jsx)(is,{url:c,className:t});else if(l)f=(0,Q.jsx)(ss,{type:l.type,id:l.id});else if(u)f=(0,Q.jsx)(as,{url:u});else if(d)f=(0,Q.jsx)(Go,{identifier:d});else return(0,Q.jsx)($o,{url:e,className:t,hideImage:i,navigateToComments:n,showActions:r});return(0,Q.jsxs)(`div`,{className:z(`space-y-0`,t),children:[f,(0,Q.jsx)(Es,{url:e,showActions:r})]})}function Es({url:e,showActions:t=!0}){let n=K(),{data:r}=Kn(e),i=(0,Z.useMemo)(()=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}},[e]),a=r?.provider_name||i;return(0,Q.jsxs)(`div`,{className:`px-3.5 py-2.5 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(dn,{url:e,size:14,className:`shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:a}),(0,Q.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:z(`ml-auto flex items-center gap-1 px-2 py-0.5 rounded-full`,`text-xs text-muted-foreground`,`hover:bg-primary/10 hover:text-primary transition-colors`),onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(b,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Open`})]}),t&&(0,Q.jsxs)(`button`,{type:`button`,className:z(`flex items-center gap-1 px-2 py-0.5 rounded-full`,`text-xs text-muted-foreground`,`hover:bg-primary/10 hover:text-primary transition-colors`),onClick:t=>{t.preventDefault(),t.stopPropagation(),n(`/i/${encodeURIComponent(e)}`)},children:[(0,Q.jsx)(xe,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Discuss`})]})]}),r?.title&&(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2`,children:r.title}),r?.author_name&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-2`,children:r.author_name})]})}var Ds=3,Os=15,ks=20,As=80;function js(e){if(typeof document>`u`)return null;let t=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(!t)return null;let{h:n,s:r,l:i}=yt(t);return[n,r,i].some(isNaN)?null:{h:n,s:r,l:i}}function Ms(e,t){let n=e.l,r=Ct(e.h,e.s,n),i=St(r,t);for(;n>0&&i=Os&&t.l>=ks&&t.l<=As))return e;let r=Ct(e.h,e.s,e.l),i=Ct(t.h,t.s,t.l),a=St(r,n);return St(i,n)>a*1.5?t:e}function Fs(){let e=js(`--primary`),t=js(`--foreground`),n=js(`--background`);if(!e)return{dark:`#000000`,light:`#ffffff`};if(!(n&&bt(`${n.h} ${n.s}% ${n.l}%`))){let n=[255,255,255];return{dark:Ms(Ps(e,t,n),n),light:`#ffffff`}}if(!n)return{dark:`#ffffff`,light:`#000000`};let r=Ct(n.h,n.s,n.l);return{dark:Ns(Ps(e,t,r),r),light:xt(...r)}}var Is=e(Tr(),1);function Ls(e){let t=e.toLowerCase().match(/^ln\w+?(\d+)([munp]?)1/);if(!t)return null;let n=parseInt(t[1],10);if(isNaN(n))return null;switch(t[2]){case`m`:return n*1e5;case`u`:return n*100;case`n`:return n/10;case`p`:return n/1e4;default:return n*1e8}}function Rs(e){return e<1?`<1`:Math.round(e).toLocaleString()}function zs({invoice:e,className:t}){let{toast:n}=Bt(),[r,i]=(0,Z.useState)(!1),[a,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(!1),f=Ls(e);(0,Z.useEffect)(()=>{let t=!1,{dark:n,light:r}=Fs();return Is.toDataURL(e.toUpperCase(),{width:400,margin:2,color:{dark:n,light:r},errorCorrectionLevel:`M`}).then(e=>{t||l(e)}).catch(()=>{}),()=>{t=!0}},[e]);let p=(0,Z.useCallback)(async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e),i(!0),n({title:`Copied`,description:`Lightning invoice copied to clipboard`})}catch{n({title:`Failed to copy`,variant:`destructive`})}},[e,n]);(0,Z.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),2e3);return()=>clearTimeout(e)},[r]);let m=(0,Z.useCallback)(async t=>{t.stopPropagation();try{await Nt(`lightning:${e}`)}catch{n({title:`Could not open wallet`,description:`No lightning wallet app is installed to handle this invoice.`,variant:`destructive`})}},[e,n]),h=(0,Z.useCallback)(async t=>{t.stopPropagation();let r=globalThis.webln;if(r?.sendPayment)try{s(!0),r.enable&&await r.enable(),await r.sendPayment(e),n({title:`Payment sent`})}catch{n({title:`Payment failed`,variant:`destructive`})}finally{s(!1)}},[e,n]),g=(0,Z.useCallback)(e=>{e.stopPropagation(),d(e=>!e)},[]),_=typeof globalThis<`u`&&!!globalThis.webln,v=c?(0,Q.jsx)(`img`,{src:c,alt:`Lightning Invoice QR`,className:`rounded-xl`,style:{imageRendering:`pixelated`},decoding:`async`}):(0,Q.jsx)(`div`,{className:`aspect-square rounded-xl bg-muted animate-pulse`});return(0,Q.jsxs)(`div`,{className:z(`isolate my-2.5 relative rounded-2xl border border-border overflow-hidden @container`,t),onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`div`,{className:`absolute -z-10 top-0 left-0 w-44 h-44 bg-primary/[0.06] rounded-full blur-2xl`}),u?(0,Q.jsx)(`button`,{onClick:g,className:`w-full aspect-square cursor-pointer p-5`,children:c?(0,Q.jsx)(`img`,{src:c,alt:`Lightning Invoice QR`,className:`w-full h-full rounded-xl`,style:{imageRendering:`pixelated`},decoding:`async`}):(0,Q.jsx)(`div`,{className:`w-full h-full rounded-xl bg-muted animate-pulse`})}):(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`button`,{onClick:g,className:`shrink-0 p-3 cursor-pointer`,children:(0,Q.jsx)(`div`,{className:`size-28 sm:size-40`,children:v})}),(0,Q.jsxs)(`div`,{className:`flex flex-col justify-between py-3.5 pr-3.5 min-w-0 flex-1 gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground font-medium whitespace-nowrap`,style:{fontSize:`clamp(0.8rem, 3.5cqw, 1.05rem)`},children:[(0,Q.jsx)(`span`,{className:`flex items-center justify-center size-5 sm:size-6 rounded-full bg-primary/15 shrink-0`,children:(0,Q.jsx)(Ee,{className:`size-3 sm:size-3.5 text-primary fill-primary`})}),`Lightning Invoice`]}),f!==null&&(0,Q.jsxs)(`div`,{className:`font-bold tracking-tight leading-none mt-1 whitespace-nowrap`,style:{fontSize:`clamp(1.5rem, 8cqw, 2.5rem)`},children:[Rs(f),(0,Q.jsx)(`span`,{className:`font-normal text-muted-foreground ml-1`,style:{fontSize:`clamp(0.75rem, 3.5cqw, 1.125rem)`},children:`sats`})]})]}),(0,Q.jsxs)(`button`,{onClick:p,className:`flex items-center gap-1.5 group max-w-full`,children:[(0,Q.jsx)(`span`,{className:`truncate text-xs font-mono text-muted-foreground group-hover:text-foreground transition-colors`,children:e}),r?(0,Q.jsx)(_e,{className:`size-3.5 text-primary shrink-0`}):(0,Q.jsx)(o,{className:`size-3.5 text-muted-foreground group-hover:text-foreground shrink-0 transition-colors`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_&&(0,Q.jsxs)(B,{size:`sm`,onClick:h,disabled:a,className:`gap-1.5 h-9 rounded-xl`,children:[(0,Q.jsx)(Ee,{className:`size-3.5`}),a?`Paying...`:`Pay`]}),(0,Q.jsxs)(B,{size:`sm`,variant:`outline`,onClick:m,className:`gap-1.5 h-9 rounded-xl`,children:[(0,Q.jsx)(b,{className:`size-3.5`}),`Open in Wallet`]})]})]})]})]})}var Bs=Object.defineProperty,Vs=Object.defineProperties,Hs=Object.getOwnPropertyDescriptors,Us=Object.getOwnPropertySymbols,Ws=Object.prototype.hasOwnProperty,Gs=Object.prototype.propertyIsEnumerable,Ks=(e,t,n)=>t in e?Bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qs=(e,t)=>{for(var n in t||={})Ws.call(t,n)&&Ks(e,n,t[n]);if(Us)for(var n of Us(t))Gs.call(t,n)&&Ks(e,n,t[n]);return e},Js=(e,t)=>Vs(e,Hs(t)),Ys=(e,t)=>{var n={};for(var r in e)Ws.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Us)for(var r of Us(e))t.indexOf(r)<0&&Gs.call(e,r)&&(n[r]=e[r]);return n},Xs=class extends Z.PureComponent{constructor(){super(...arguments),this.canvas=null,this.handleRef=e=>{this.canvas=e,this.draw()},this.draw=()=>{let{hash:e,height:t,punch:n,width:r}=this.props;if(this.canvas){let i=Dn(e,r,t,n),a=this.canvas.getContext(`2d`),o=a.createImageData(r,t);o.data.set(i),a.putImageData(o,0,0)}}}componentDidUpdate(){this.draw()}render(){let e=this.props,{hash:t,height:n,width:r}=e,i=Ys(e,[`hash`,`height`,`width`]);return Z.createElement(`canvas`,Js(qs({},i),{height:n,width:r,ref:this.handleRef}))}};Xs.defaultProps={height:128,width:128};var Zs={position:`absolute`,top:0,bottom:0,left:0,right:0,width:`100%`,height:`100%`},Qs=class extends Z.PureComponent{componentDidUpdate(){if(this.props.resolutionX<=0)throw Error(`resolutionX must be larger than zero`);if(this.props.resolutionY<=0)throw Error(`resolutionY must be larger than zero`)}render(){let e=this.props,{hash:t,height:n,width:r,punch:i,resolutionX:a,resolutionY:o,style:s}=e,c=Ys(e,[`hash`,`height`,`width`,`punch`,`resolutionX`,`resolutionY`,`style`]);return Z.createElement(`div`,Js(qs({},c),{style:Js(qs({display:`inline-block`,height:n,width:r},s),{position:`relative`})}),Z.createElement(Xs,{hash:t,height:o,width:a,punch:i,style:Zs}))}};Qs.defaultProps={height:128,width:128,resolutionX:32,resolutionY:32};function $s(e){return e?xn(e).result:!1}function ec({mediaRef:e,containerRef:t,isPlaying:n}){let[r,i]=(0,Z.useState)(!0),a=(0,Z.useRef)(void 0),o=(0,Z.useCallback)(()=>{a.current&&clearTimeout(a.current),n&&(a.current=setTimeout(()=>i(!1),2500))},[n]),s=(0,Z.useCallback)(()=>{i(!0),o()},[o]);(0,Z.useEffect)(()=>(n?o():(i(!0),a.current&&clearTimeout(a.current)),()=>{a.current&&clearTimeout(a.current)}),[n,o]),(0,Z.useEffect)(()=>{let n=e.current,r=t.current;if(!n||!r)return;let i=new IntersectionObserver(([e])=>{!e.isIntersecting&&!n.paused&&n.pause()},{threshold:.25});return i.observe(r),()=>i.disconnect()},[e,t]);let[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(1),f=(0,Z.useRef)(1);return(0,Z.useEffect)(()=>{let t=e.current;if(!t)return;let n=()=>{l(t.muted),d(t.muted?0:t.volume)};return n(),t.addEventListener(`volumechange`,n),()=>t.removeEventListener(`volumechange`,n)},[e]),{showControls:r,revealControls:s,scheduleHide:o,isMuted:c,volume:u,toggleMute:(0,Z.useCallback)(t=>{t.stopPropagation();let n=e.current;if(n)if(n.muted||n.volume===0){let e=f.current>0?f.current:.5;n.muted=!1,n.volume=e,l(!1),d(e)}else f.current=n.volume,n.muted=!0,l(!0)},[e]),handleVolumeChange:(0,Z.useCallback)(t=>{t.stopPropagation();let n=e.current;if(!n)return;let r=parseFloat(t.target.value);n.volume=r,n.muted=r===0,r>0&&(f.current=r),d(r),l(r===0)},[e])}}function tc(e,t){let[n,r]=(0,Z.useState)(t);return(0,Z.useEffect)(()=>{if(t||!e)return;let n=!1;function i(e){let t=document.createElement(`video`);t.crossOrigin=`anonymous`,t.muted=!0,t.playsInline=!0,t.preload=`metadata`,t.src=e;function i(){if(!n){try{let e=document.createElement(`canvas`);e.width=t.videoWidth||320,e.height=t.videoHeight||180;let n=e.getContext(`2d`);if(n){n.drawImage(t,0,0,e.width,e.height);let i=e.toDataURL(`image/jpeg`,.7);i.length>1e3&&r(i)}}catch{}t.src=``,t.load()}}let a=()=>{t.currentTime=.1},o=()=>i();return t.addEventListener(`loadedmetadata`,a,{once:!0}),t.addEventListener(`seeked`,o,{once:!0}),()=>{t.removeEventListener(`loadedmetadata`,a),t.removeEventListener(`seeked`,o),t.src=``,t.load()}}if(/\.m3u8(\?|$)/i.test(e)){let t=document.createElement(`video`);if(t.crossOrigin=`anonymous`,t.muted=!0,t.playsInline=!0,t.canPlayType(`application/vnd.apple.mpegurl`)){let i=()=>{n||t.play().then(()=>{t.pause();try{let e=document.createElement(`canvas`);e.width=t.videoWidth||320,e.height=t.videoHeight||180;let n=e.getContext(`2d`);if(n){n.drawImage(t,0,0,e.width,e.height);let i=e.toDataURL(`image/jpeg`,.7);i.length>1e3&&r(i)}}catch{}t.src=``}).catch(()=>{})};return t.src=e,t.addEventListener(`loadeddata`,i,{once:!0}),()=>{n=!0,t.removeEventListener(`loadeddata`,i),t.src=``}}let i=null;return ze(async()=>{let{default:e}=await import(`./hls-DRk412my.js`);return{default:e}},[]).then(({default:a})=>{if(n||!a.isSupported())return;let o=()=>{n||t.play().then(()=>{t.pause();try{let e=document.createElement(`canvas`);e.width=t.videoWidth||320,e.height=t.videoHeight||180;let n=e.getContext(`2d`);if(n){n.drawImage(t,0,0,e.width,e.height);let i=e.toDataURL(`image/jpeg`,.7);i.length>1e3&&r(i)}}catch{}i?.destroy(),i=null,t.src=``}).catch(()=>{i?.destroy(),i=null})},s=new a({startLevel:-1,maxBufferLength:5});i=s,s.loadSource(e),s.attachMedia(t),s.on(a.Events.MANIFEST_PARSED,()=>{if(n){s.destroy();return}o()})}),()=>{n=!0,i?.destroy(),i=null,t.src=``}}let a=i(e);return()=>{n=!0,a()}},[e,t]),n}var nc=`data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7`;function rc(e){if(!e)return;let[t,n]=e.split(`x`).map(Number);if(!(!t||!n||isNaN(t)||isNaN(n)))return{width:t,height:n}}function ic(e,t){let n=(0,Z.useRef)(null),r=/\.m3u8(\?|$)/i.test(t),i=(0,Z.useCallback)(()=>{let i=e.current;if(!(!i||!r)){if(i.canPlayType(`application/vnd.apple.mpegurl`)){i.src=t;return}ze(async()=>{let{default:e}=await import(`./hls-DRk412my.js`);return{default:e}},[]).then(({default:r})=>{if(e.current!==i||!r.isSupported())return;let a=new r({startLevel:-1,autoStartLoad:!0});n.current=a,a.loadSource(t),a.attachMedia(i)})}},[e,t,r]);return(0,Z.useEffect)(()=>(i(),()=>{n.current?.destroy(),n.current=null}),[i]),{isHls:r}}function ac({src:e,poster:t,className:r,dim:i,blurhash:a,title:o,artist:s,autoPlay:c,encryption:d}){let f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),h=qt(e),g=Or(e,d),_=Or(t??``,t&&d?jt(d):void 0),v=g.encrypted?g.src??``:h.src,y=t?_.src:void 0,b=g.encrypted?()=>{}:h.onError,{isHls:x}=ic(f,v),{config:S}=I(),C=c??S.autoplayVideos,w=tc(v,y),[T,E]=(0,Z.useState)(!1),[O,ee]=(0,Z.useState)(0),[k,A]=(0,Z.useState)(0),[j,te]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(!1),[ne,re]=(0,Z.useState)(!1),[ie,ae]=(0,Z.useState)(void 0),oe=rc(i),se=oe?`${oe.width} / ${oe.height}`:ie??`16 / 9`,ce=k>0?O/k*100:0,{showControls:le,revealControls:ue,scheduleHide:de,isMuted:fe,volume:pe,toggleMute:me,handleVolumeChange:he}=ec({mediaRef:f,containerRef:m,isPlaying:T}),ge=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{if(!C)return;ge.current=!1;let e=f.current;if(!e)return;let t=()=>{ge.current||(ge.current=!0,e.muted=!0,e.play().catch(()=>{}))};if(e.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA)t();else return e.addEventListener(`loadeddata`,t,{once:!0}),()=>e.removeEventListener(`loadeddata`,t)},[C]),(0,Z.useEffect)(()=>{if(!(`mediaSession`in navigator)||!j)return;let e=f.current;if(!e)return;let t=w||y?[{src:w||y,sizes:`512x512`,type:`image/jpeg`}]:[];return navigator.mediaSession.metadata=new MediaMetadata({title:o||`Video`,artist:s||``,artwork:t}),navigator.mediaSession.setActionHandler(`play`,()=>e.play().catch(()=>{})),navigator.mediaSession.setActionHandler(`pause`,()=>e.pause()),navigator.mediaSession.setActionHandler(`seekto`,t=>{t.seekTime!=null&&(e.currentTime=t.seekTime)}),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),navigator.mediaSession.setActionHandler(`seekto`,null))}},[j,o,s,y,w]),(0,Z.useEffect)(()=>{!(`mediaSession`in navigator)||!j||(navigator.mediaSession.playbackState=T?`playing`:`paused`)},[T,j]),(0,Z.useEffect)(()=>{if(!(!(`mediaSession`in navigator)||!j||k<=0))try{navigator.mediaSession.setPositionState({duration:k,playbackRate:f.current?.playbackRate??1,position:Math.min(O,k)})}catch{}},[O,k,j]);let _e=e=>{e.stopPropagation();let t=f.current;t&&(t.paused?t.play():t.pause())},ve=e=>{e.stopPropagation();let t=f.current;t&&t.requestFullscreen&&t.requestFullscreen()},ye=e=>{e.stopPropagation();let t=f.current,n=p.current;if(!t||!n||!k)return;let r=n.getBoundingClientRect();t.currentTime=Math.max(0,Math.min(1,(e.clientX-r.left)/r.width))*k},be=e=>{if(e.stopPropagation(),!j){let e=f.current;e&&e.play();return}_e(e),ue()},xe=g.encrypted&&!g.src;return(0,Q.jsxs)(`div`,{ref:m,className:z(`relative mt-3 rounded-2xl overflow-hidden border border-border bg-black group`,r),style:{aspectRatio:se},onMouseMove:ue,onMouseLeave:()=>{T&&de()},onClick:e=>e.stopPropagation(),children:[$s(a)&&!j&&!(w&&ne)&&(0,Q.jsx)(Qs,{hash:a,width:`100%`,height:`100%`,resolutionX:32,resolutionY:32,punch:1,style:{position:`absolute`,inset:0}}),(0,Q.jsx)(`video`,{ref:f,src:x||!v?void 0:v,"data-no-native-poster":``,poster:nc,className:z(`w-full cursor-pointer`,`absolute inset-0 h-full object-cover`,`fullscreen:object-contain fullscreen:static fullscreen:max-h-none fullscreen:h-full fullscreen:w-full`,`transition-opacity duration-150`,j||M&&!w?`opacity-100`:`opacity-0`),playsInline:!0,preload:`metadata`,"webkit-playsinline":`true`,"x-webkit-airplay":`allow`,onClick:be,onPlay:()=>{E(!0),te(!0)},onPause:()=>E(!1),onTimeUpdate:()=>ee(f.current?.currentTime??0),onLoadedMetadata:()=>{let e=f.current;e&&(A(e.duration??0),!oe&&e.videoWidth>0&&e.videoHeight>0&&ae(t=>t??`${e.videoWidth} / ${e.videoHeight}`))},onDurationChange:()=>A(f.current?.duration??0),onLoadedData:()=>N(!0),onError:b}),xe&&(0,Q.jsx)(Er,{fill:!0,className:`bg-background`,loading:g.loading,unsupported:g.unsupported,tooLarge:g.tooLarge,byteSize:g.byteSize,onDecryptAnyway:g.decryptAnyway}),w&&!j&&(0,Q.jsx)(`img`,{src:w,alt:``,"aria-hidden":!0,className:z(`absolute inset-0 w-full h-full object-cover pointer-events-none transition-opacity duration-150`,ne?`opacity-100`:`opacity-0`),onLoad:e=>{re(!0);let t=e.currentTarget;!oe&&t.naturalWidth>0&&t.naturalHeight>0&&ae(e=>e??`${t.naturalWidth} / ${t.naturalHeight}`)},decoding:`async`}),!j&&(M||ne)&&(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/30 cursor-pointer`,onClick:be,children:(0,Q.jsx)(`div`,{className:`size-16 rounded-full bg-black/60 flex items-center justify-center backdrop-blur-sm`,children:(0,Q.jsx)(u,{className:`size-8 text-white ml-1`,fill:`white`})})}),j&&(0,Q.jsxs)(`div`,{className:z(`absolute bottom-0 left-0 right-0 transition-opacity duration-200`,`bg-gradient-to-t from-black/80 via-black/40 to-transparent pt-8 pb-2 px-3`,le?`opacity-100`:`opacity-0 pointer-events-none`),children:[(0,Q.jsx)(`div`,{ref:p,className:`w-full h-1 bg-white/30 rounded-full cursor-pointer mb-2 group/progress`,onClick:ye,children:(0,Q.jsx)(`div`,{className:`h-full bg-primary rounded-full relative`,style:{width:`${ce}%`},children:(0,Q.jsx)(`div`,{className:`absolute right-0 top-1/2 -translate-y-1/2 size-3 bg-primary rounded-full opacity-0 group-hover/progress:opacity-100 transition-opacity`})})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`button`,{onClick:_e,className:`text-white hover:text-white/80 transition-colors`,"aria-label":T?`Pause`:`Play`,children:T?(0,Q.jsx)(l,{className:`size-5`,fill:`white`}):(0,Q.jsx)(u,{className:`size-5 ml-0.5`,fill:`white`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 group/vol`,children:[(0,Q.jsx)(`button`,{onClick:me,className:`text-white hover:text-white/80 transition-colors shrink-0`,"aria-label":fe?`Unmute`:`Mute`,children:fe||pe===0?(0,Q.jsx)(D,{className:`size-5`}):pe<.5?(0,Q.jsx)(Fe,{className:`size-5`}):(0,Q.jsx)(Ne,{className:`size-5`})}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:1,step:.02,value:fe?0:pe,onChange:he,onClick:e=>e.stopPropagation(),"aria-label":`Volume`,className:z(`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,Q.jsxs)(`span`,{className:`text-white text-xs tabular-nums min-w-0`,children:[Ar(O),` / `,Ar(k)]}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(`button`,{onClick:ve,className:`text-white hover:text-white/80 transition-colors`,"aria-label":`Fullscreen`,children:(0,Q.jsx)(n,{className:`size-[18px]`})})]})]})]})}function oc({src:e,mime:t,encryption:n,avatarUrl:r,avatarFallback:i=`?`,avatarShape:a,className:o}){let s=Or(e,n),c=s.src??``,d=s.mime??t,f=(0,Z.useRef)(null),p=(0,Z.useRef)(null),m=(0,Z.useRef)(null),h=(0,Z.useRef)(null),g=(0,Z.useRef)(0),_=(0,Z.useRef)(null),v=(0,Z.useRef)(null),y=(0,Z.useRef)(0),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(0),[w,T]=(0,Z.useState)(0),[E,O]=(0,Z.useState)(!1),ee=w>0?S/w*100:0,{showControls:k,revealControls:A,scheduleHide:j,isMuted:te,volume:M,toggleMute:N,handleVolumeChange:ne}=ec({mediaRef:f,containerRef:h,isPlaying:b}),re=s.encrypted&&!s.src,ie=(0,Z.useCallback)(()=>{let e=p.current;if(!e){g.current=requestAnimationFrame(ie);return}let t=e.getContext(`2d`);if(!t)return;let n=e.clientWidth,r=e.clientHeight,i=window.devicePixelRatio||1;(e.width!==Math.round(n*i)||e.height!==Math.round(r*i))&&(e.width=Math.round(n*i),e.height=Math.round(r*i)),t.save(),t.scale(i,i),t.clearRect(0,0,n,r);let a=getComputedStyle(e).getPropertyValue(`--primary`).trim(),o=`hsl(${a})`,s=`hsl(${a} / 0.15)`,c=`hsl(${a} / 0.85)`,l=`hsl(${a} / 0.55)`,u=_.current,d=null;u&&b&&(d=new Uint8Array(u.frequencyBinCount),u.getByteTimeDomainData(d));let f=n/2,m=r/2,h=t.createLinearGradient(0,0,n,0);if(h.addColorStop(0,s),h.addColorStop(.35,c),h.addColorStop(.5,o),h.addColorStop(.65,c),h.addColorStop(1,s),t.beginPath(),t.strokeStyle=h,t.lineWidth=2.5,t.shadowBlur=10,t.shadowColor=l,d){let e=n/d.length;for(let n=0;n(cancelAnimationFrame(g.current),g.current=requestAnimationFrame(ie),()=>cancelAnimationFrame(g.current)),[ie]);let ae=(0,Z.useCallback)(()=>{let e=f.current;if(!e||v.current)return;let t=new AudioContext;v.current=t;let n=t.createAnalyser();n.fftSize=2048,_.current=n,t.createMediaElementSource(e).connect(n),n.connect(t.destination)},[]),oe=(0,Z.useCallback)(e=>{e.stopPropagation();let t=f.current;t&&(ae(),v.current?.state===`suspended`&&v.current.resume(),t.paused?t.play():t.pause())},[ae]),se=e=>{e.stopPropagation();let t=f.current,n=m.current;if(!t||!n||!w)return;let r=n.getBoundingClientRect();t.currentTime=Math.max(0,Math.min(1,(e.clientX-r.left)/r.width))*w},ce=e=>{if(e.stopPropagation(),!E){let e=f.current;e&&(ae(),e.play());return}oe(e),A()};return(0,Z.useEffect)(()=>{let e=f.current;if(!e)return;let t=()=>{x(!0),O(!0)},n=()=>x(!1),r=()=>x(!1),i=()=>C(e.currentTime),a=()=>T(e.duration);return e.addEventListener(`play`,t),e.addEventListener(`pause`,n),e.addEventListener(`ended`,r),e.addEventListener(`timeupdate`,i),e.addEventListener(`durationchange`,a),e.addEventListener(`loadedmetadata`,a),()=>{e.removeEventListener(`play`,t),e.removeEventListener(`pause`,n),e.removeEventListener(`ended`,r),e.removeEventListener(`timeupdate`,i),e.removeEventListener(`durationchange`,a),e.removeEventListener(`loadedmetadata`,a)}},[]),(0,Z.useEffect)(()=>()=>{cancelAnimationFrame(g.current),v.current?.close()},[]),(0,Q.jsxs)(`div`,{ref:h,className:z(`relative mt-3 rounded-2xl overflow-hidden border border-border bg-background group`,o),style:{aspectRatio:`16 / 9`},onMouseMove:A,onMouseLeave:()=>{b&&j()},onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`audio`,{ref:f,preload:`metadata`,crossOrigin:`anonymous`,className:`hidden`,children:c?d?(0,Q.jsx)(`source`,{src:c,type:d}):(0,Q.jsx)(`source`,{src:c}):null}),re&&(0,Q.jsx)(Er,{fill:!0,loading:s.loading,unsupported:s.unsupported,tooLarge:s.tooLarge,byteSize:s.byteSize,onDecryptAnyway:s.decryptAnyway}),!re&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`canvas`,{ref:p,className:`absolute inset-0 w-full h-full`,onClick:ce,style:{cursor:`pointer`}}),(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:(0,Q.jsx)(`div`,{className:z(`rounded-full ring-4 transition-all duration-300`,b?`ring-primary/40 shadow-[0_0_28px_8px_hsl(var(--primary)/0.4)]`:`ring-border`),children:(0,Q.jsxs)(G,{className:`size-20 border-2 border-white/20`,shape:a,children:[(0,Q.jsx)(W,{src:r,alt:i}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-2xl font-semibold`,children:i})]})})}),!E&&(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/30 cursor-pointer`,onClick:ce,children:(0,Q.jsx)(`div`,{className:`size-16 rounded-full bg-black/60 flex items-center justify-center backdrop-blur-sm`,children:(0,Q.jsx)(u,{className:`size-8 text-white ml-1`,fill:`white`})})}),E&&(0,Q.jsxs)(`div`,{className:z(`absolute bottom-0 left-0 right-0 transition-opacity duration-200`,`bg-gradient-to-t from-black/80 via-black/40 to-transparent pt-8 pb-2 px-3`,k?`opacity-100`:`opacity-0 pointer-events-none`),children:[(0,Q.jsx)(`div`,{ref:m,className:`w-full h-1 bg-white/30 rounded-full cursor-pointer mb-2 group/progress`,onClick:se,children:(0,Q.jsx)(`div`,{className:`h-full bg-primary rounded-full relative`,style:{width:`${ee}%`},children:(0,Q.jsx)(`div`,{className:`absolute right-0 top-1/2 -translate-y-1/2 size-3 bg-primary rounded-full opacity-0 group-hover/progress:opacity-100 transition-opacity`})})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`button`,{onClick:oe,className:`text-white hover:text-white/80 transition-colors`,"aria-label":b?`Pause`:`Play`,children:b?(0,Q.jsx)(l,{className:`size-5`,fill:`white`}):(0,Q.jsx)(u,{className:`size-5 ml-0.5`,fill:`white`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 group/vol`,children:[(0,Q.jsx)(`button`,{onClick:N,className:`text-white hover:text-white/80 transition-colors shrink-0`,"aria-label":te?`Unmute`:`Mute`,children:te||M===0?(0,Q.jsx)(D,{className:`size-5`}):M<.5?(0,Q.jsx)(Fe,{className:`size-5`}):(0,Q.jsx)(Ne,{className:`size-5`})}),(0,Q.jsx)(`input`,{type:`range`,min:0,max:1,step:.02,value:te?0:M,onChange:ne,onClick:e=>e.stopPropagation(),"aria-label":`Volume`,className:z(`w-0 opacity-0 group-hover/vol:w-16 group-hover/vol:opacity-100`,`transition-all duration-200 cursor-pointer accent-white h-1`)})]}),(0,Q.jsxs)(`span`,{className:`text-white text-xs tabular-nums min-w-0`,children:[Ar(S),` / `,Ar(w)]}),(0,Q.jsx)(`div`,{className:`flex-1`})]})]})]})]})}var sc={".html":`text/html`,".htm":`text/html`,".css":`text/css`,".js":`application/javascript`,".mjs":`application/javascript`,".json":`application/json`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".svg":`image/svg+xml`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`,".avif":`image/avif`,".woff":`font/woff`,".woff2":`font/woff2`,".ttf":`font/ttf`,".otf":`font/otf`,".mp3":`audio/mpeg`,".ogg":`audio/ogg`,".wav":`audio/wav`,".opus":`audio/opus`,".weba":`audio/webm`,".mp4":`video/mp4`,".webm":`video/webm`,".xml":`application/xml`,".txt":`text/plain`,".md":`text/markdown`,".wasm":`application/wasm`,".pdf":`application/pdf`,".toml":`application/toml`};function cc(e){let t=e.lastIndexOf(`.`);return t===-1?`application/octet-stream`:sc[e.slice(t).toLowerCase()]??`application/octet-stream`}function lc(e){let t=``;for(let n=0;n=0;e--){let r=n.createElement(`script`);r.src=t[e],n.head.prepend(r)}let r=/^ `+i:i}var fc=2;function pc(e,t){return t?e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e:e.slice():lc(e)}function mc(e,t){return t?new TextEncoder().encode(e):uc(e)}async function hc(e,t,n,r,i,a,o){let s=n.find(t=>e===`/${t.path}`||e===t.path);if(s){let e={"Content-Type":`application/javascript`,"Cache-Control":`no-cache`};r&&(e[`Content-Security-Policy`]=r),a({status:200,statusText:`OK`,headers:e,body:mc(s.content,i)});return}try{let o=await t(e);if(!o){let e={"Content-Type":`text/plain`};r&&(e[`Content-Security-Policy`]=r),a({status:404,statusText:`Not Found`,headers:e,body:mc(`Not Found`,i)});return}let s;s=o.contentType===`text/html`&&n.length>0?mc(dc(new TextDecoder().decode(o.body),n.map(e=>`/${e.path}`)),i):pc(o.body,i);let c={"Content-Type":o.contentType,"Cache-Control":`no-cache`};r&&(c[`Content-Security-Policy`]=r),o.contentType!==`text/html`&&(c[`Content-Length`]=String(o.body.byteLength)),a({status:o.status,statusText:`OK`,headers:c,body:s})}catch(e){o(-32002,String(e))}}var gc=`accelerometer.ambient-light-sensor.autoplay.battery.camera.clipboard-write.compute-pressure.display-capture.encrypted-media.fullscreen.gamepad.geolocation.gyroscope.idle-detection.keyboard-map.magnetometer.microphone.midi.picture-in-picture.pointer-lock.screen-wake-lock.speaker-selection.storage-access.web-share.window-management.xr-spatial-tracking`.split(`.`).join(`; `),_c=(0,Z.forwardRef)(function({id:e,resolveFile:t,onRpc:n,injectedScripts:r,csp:i,onReady:a,...o},s){let c=(0,Z.useRef)(null),{config:l}=I(),u=(0,Z.useRef)(1),d=(0,Z.useMemo)(()=>`https://${e}.${l.sandboxDomain}`,[e,l.sandboxDomain]),f=(0,Z.useRef)(t),p=(0,Z.useRef)(n),m=(0,Z.useRef)(r),h=(0,Z.useRef)(i),g=(0,Z.useRef)(a);(0,Z.useEffect)(()=>{f.current=t},[t]),(0,Z.useEffect)(()=>{p.current=n},[n]),(0,Z.useEffect)(()=>{m.current=r},[r]),(0,Z.useEffect)(()=>{h.current=i},[i]),(0,Z.useEffect)(()=>{g.current=a},[a]);let _=(0,Z.useCallback)((e,t)=>{c.current?.contentWindow?.postMessage(e,d,t??[])},[d]);return(0,Z.useImperativeHandle)(s,()=>({postMessage:(e,t)=>{c.current?.contentWindow?.postMessage(e,d,t??[])},focus:()=>{c.current?.focus()}}),[d]),(0,Z.useEffect)(()=>{function e(e){if(e.origin!==d||e.source!==c.current?.contentWindow)return;let i=e.data;if(!(!i||typeof i!=`object`||i.jsonrpc!==`2.0`)){if(i.method===`ready`&&i.id===void 0){let e=i.params?.version;u.current=typeof e==`number`?e:1,t();return}i.id!==void 0&&i.method&&(i.method===`fetch`?n(i.id,i.params):p.current&&r(i.id,i.method,i.params??{}))}}async function t(){try{await g.current?.()}catch(e){console.error(`[SandboxFrame] onReady failed:`,e)}_({jsonrpc:`2.0`,method:`init`,params:{version:fc}})}async function n(e,t){let n=t?.request?.url;if(!n){_({jsonrpc:`2.0`,id:e,error:{code:-32001,message:`Invalid request`}});return}let r;try{let t=new URL(n);if(t.origin!==d){_({jsonrpc:`2.0`,id:e,error:{code:-32003,message:`Origin mismatch`}});return}r=t.pathname}catch{_({jsonrpc:`2.0`,id:e,error:{code:-32003,message:`Invalid URL`}});return}await hc(r,f.current,m.current??[],h.current,u.current>=2,t=>_({jsonrpc:`2.0`,id:e,result:t}),(t,n)=>_({jsonrpc:`2.0`,id:e,error:{code:t,message:n}}))}async function r(e,t,n){try{let r=await p.current(t,n,_);_({jsonrpc:`2.0`,id:e,result:r??null})}catch(t){_({jsonrpc:`2.0`,id:e,error:{code:-1,message:String(t)}})}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[d,_]),(0,Q.jsx)(`iframe`,{ref:c,src:`${d}/`,allow:gc,sandbox:`allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads allow-pointer-lock`,...o})}),vc=[`default-src 'self' 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' data: blob:`,`base-uri 'self'`,`form-action 'self'`].join(`; `);async function yc(e){if(typeof e==`string`){let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch xdc: ${t.status}`);return new Uint8Array(await t.arrayBuffer())}return e}function bc(e){let t=jr(e),n=new Map;for(let[e,r]of Object.entries(t)){let t=e.replace(/^\/+/,``).replace(/\\/g,`/`);t.endsWith(`/`)||n.set(t,r)}return n}function xc(e){return`(function(){ var nextId = 1; var pending = {}; var updateListener = null; var updateListenerReady = null; var realtimeDataListener = null; var realtimeChannelId = null; function send(msg) { window.parent.postMessage(msg, "*"); } function sendRequest(method, params) { var id = nextId++; return new Promise(function(resolve, reject) { pending[id] = { resolve: resolve, reject: reject }; send({ jsonrpc: "2.0", id: id, method: method, params: params }); }); } function sendNotification(method, params) { send({ jsonrpc: "2.0", method: method, params: params }); } window.addEventListener("message", function(event) { var data = event.data; if (!data || typeof data !== "object" || data.jsonrpc !== "2.0") return; // JSON-RPC response if (data.id !== undefined && !data.method) { var p = pending[data.id]; if (p) { delete pending[data.id]; if (data.error) { p.reject(new Error(data.error.message)); } else { p.resolve(data.result); } } return; } // Notifications from parent if (data.method && data.id === undefined) { switch (data.method) { case "webxdc.update": if (updateListener) updateListener(data.params.update); break; case "webxdc.realtimeChannel.data": if (realtimeDataListener) realtimeDataListener(new Uint8Array(data.params.data)); break; case "webxdc.keyboard": var p2 = data.params; var evt = new KeyboardEvent(p2.type, { key: p2.key, code: p2.code, keyCode: p2.keyCode, bubbles: true, cancelable: true, composed: true }); window.dispatchEvent(evt); document.dispatchEvent(new KeyboardEvent(p2.type, { key: p2.key, code: p2.code, keyCode: p2.keyCode, bubbles: true, cancelable: true })); break; } } }); window.webxdc = { selfAddr: ${JSON.stringify(e.selfAddr)}, selfName: ${JSON.stringify(e.selfName)}, sendUpdateInterval: ${e.sendUpdateInterval}, sendUpdateMaxSize: ${e.sendUpdateMaxSize}, sendUpdate: function(update, descr) { sendRequest("webxdc.sendUpdate", { update: update, descr: descr }); }, setUpdateListener: function(cb, serial) { updateListener = cb; return new Promise(function(resolve) { updateListenerReady = resolve; sendRequest("webxdc.setUpdateListener", { serial: serial || 0 }).then(function() { if (updateListenerReady) { updateListenerReady(); updateListenerReady = null; } }); }); }, getAllUpdates: function() { return sendRequest("webxdc.getAllUpdates"); }, sendToChat: function(message) { return sendRequest("webxdc.sendToChat", { message: message }); }, importFiles: function(filter) { return sendRequest("webxdc.importFiles", { filter: filter || {} }); }, joinRealtimeChannel: function() { if (realtimeChannelId) throw new Error("Already joined a realtime channel. Leave first."); var channelIdPromise = sendRequest("webxdc.joinRealtimeChannel"); var joined = true; channelIdPromise.then(function(r) { realtimeChannelId = r.channelId; }); return { setListener: function(cb) { if (!joined) throw new Error("Channel has been left."); realtimeDataListener = cb; }, send: function(data) { if (!joined) throw new Error("Channel has been left."); channelIdPromise.then(function(r) { sendRequest("webxdc.realtimeChannel.send", { channelId: r.channelId, data: Array.from(data) }); }); }, leave: function() { if (!joined) return; joined = false; realtimeDataListener = null; channelIdPromise.then(function(r) { sendRequest("webxdc.realtimeChannel.leave", { channelId: r.channelId }); realtimeChannelId = null; }); } }; } }; })();`}var Sc=(0,Z.forwardRef)(function({id:e,xdc:t,webxdc:n,...r},i){let a=(0,Z.useRef)(null),o=(0,Z.useRef)(n),s=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{o.current=n},[n]),(0,Z.useEffect)(()=>{s.current=t},[t]);let c=(0,Z.useRef)(null),l=(0,Z.useRef)(``),u=(0,Z.useRef)(new Map);(0,Z.useImperativeHandle)(i,()=>({postMessage:(e,t)=>{a.current?.postMessage(e,t)},focus:()=>{a.current?.focus()}}),[]),(0,Z.useEffect)(()=>{let e=u.current;return()=>{for(let t of e.values())t.leave();e.clear()}},[]);let d=(0,Z.useCallback)(async()=>{try{let e=await yc(s.current);c.current=bc(e),l.current=xc(o.current)}catch(e){console.error(`[Webxdc] Failed to initialise:`,e)}},[]),f=(0,Z.useCallback)(async e=>{let t=c.current;if(!t)return{status:503,contentType:`text/plain`,body:new TextEncoder().encode(`Archive not loaded`)};let n=e===`/`?`index.html`:decodeURIComponent(e.slice(1)),r=t.get(n);return r?{status:200,contentType:cc(n),body:r}:null},[]);return(0,Q.jsx)(_c,{ref:a,id:e,resolveFile:(0,Z.useCallback)(async e=>{if(e===`/webxdc.js`)return{status:200,contentType:`application/javascript`,body:new TextEncoder().encode(l.current)};let t=await f(e);if(!t)return null;if(t.contentType.includes(`text/html`)){let e=dc(new TextDecoder().decode(t.body),[`/webxdc.js`]);return{...t,body:new TextEncoder().encode(e)}}return t},[f]),onRpc:(0,Z.useCallback)(async(e,t,n)=>{let r=o.current;switch(e){case`webxdc.sendUpdate`:return r.sendUpdate(t.update,``),null;case`webxdc.setUpdateListener`:{let e=t.serial??0;return await r.setUpdateListener(e=>{n({jsonrpc:`2.0`,method:`webxdc.update`,params:{update:e}})},e),null}case`webxdc.getAllUpdates`:return await r.getAllUpdates();case`webxdc.sendToChat`:return await r.sendToChat(t.message),null;case`webxdc.importFiles`:{let e=await r.importFiles(t.filter??{});return await Promise.all(e.map(async e=>({name:e.name,type:e.type,data:lc(new Uint8Array(await e.arrayBuffer()))})))}case`webxdc.joinRealtimeChannel`:{let e=r.joinRealtimeChannel(),t=crypto.randomUUID();return e.setListener(e=>{n({jsonrpc:`2.0`,method:`webxdc.realtimeChannel.data`,params:{channelId:t,data:Array.from(e)}})}),u.current.set(t,e),{channelId:t}}case`webxdc.realtimeChannel.send`:{let e=u.current.get(t.channelId);return e&&e.send(new Uint8Array(t.data)),null}case`webxdc.realtimeChannel.leave`:{let e=u.current.get(t.channelId);return e&&(e.leave(),u.current.delete(t.channelId)),null}default:throw Error(`Method not found: ${e}`)}},[]),csp:vc,onReady:d,...r})}),Cc={up:{key:`ArrowUp`,code:`ArrowUp`,keyCode:38},down:{key:`ArrowDown`,code:`ArrowDown`,keyCode:40},left:{key:`ArrowLeft`,code:`ArrowLeft`,keyCode:37},right:{key:`ArrowRight`,code:`ArrowRight`,keyCode:39},a:{key:`x`,code:`KeyX`,keyCode:88},b:{key:`z`,code:`KeyZ`,keyCode:90},start:{key:`Enter`,code:`Enter`,keyCode:13},select:{key:`Shift`,code:`ShiftRight`,keyCode:16}},wc=new Set([`a`,`b`]);function Tc(){fn()}function Ec({webxdcHandle:e,className:t}){let n=(0,Z.useRef)(new Set),r=(0,Z.useCallback)((t,r)=>{if(!e)return;let{key:i,code:a,keyCode:o}=Cc[r];if(t===`keydown`){if(n.current.has(a))return;n.current.add(a),wc.has(r)&&Tc()}else n.current.delete(a);e.postMessage({jsonrpc:`2.0`,method:`webxdc.keyboard`,params:{type:t,key:i,code:a,keyCode:o}})},[e]),i=e=>({onPointerDown:t=>{t.preventDefault(),t.target.setPointerCapture(t.pointerId),r(`keydown`,e)},onPointerUp:t=>{t.preventDefault(),r(`keyup`,e)},onPointerCancel:t=>{t.preventDefault(),r(`keyup`,e)},onContextMenu:e=>e.preventDefault()});return(0,Q.jsxs)(`div`,{className:z(`flex flex-col gap-2 px-4 pb-4 pt-2 select-none touch-none`,t),style:{WebkitTouchCallout:`none`,WebkitUserSelect:`none`},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`relative size-[132px]`,children:[(0,Q.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:[(0,Q.jsx)(`div`,{className:`w-11 h-full rounded-lg bg-muted/80 backdrop-blur-sm border border-border/50`}),(0,Q.jsx)(`div`,{className:`absolute w-full h-11 rounded-lg bg-muted/80 backdrop-blur-sm border border-border/50`})]}),(0,Q.jsx)(`button`,{className:`absolute top-0 left-1/2 -translate-x-1/2 w-11 h-11 flex items-center justify-center rounded-lg active:bg-primary/20 transition-colors z-10`,"aria-label":`D-pad up`,...i(`up`),children:(0,Q.jsx)(`svg`,{width:`16`,height:`10`,viewBox:`0 0 16 10`,className:`text-foreground/70`,children:(0,Q.jsx)(`path`,{d:`M8 1L14 9H2L8 1Z`,fill:`currentColor`})})}),(0,Q.jsx)(`button`,{className:`absolute bottom-0 left-1/2 -translate-x-1/2 w-11 h-11 flex items-center justify-center rounded-lg active:bg-primary/20 transition-colors z-10`,"aria-label":`D-pad down`,...i(`down`),children:(0,Q.jsx)(`svg`,{width:`16`,height:`10`,viewBox:`0 0 16 10`,className:`text-foreground/70`,children:(0,Q.jsx)(`path`,{d:`M8 9L2 1H14L8 9Z`,fill:`currentColor`})})}),(0,Q.jsx)(`button`,{className:`absolute left-0 top-1/2 -translate-y-1/2 w-11 h-11 flex items-center justify-center rounded-lg active:bg-primary/20 transition-colors z-10`,"aria-label":`D-pad left`,...i(`left`),children:(0,Q.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,className:`text-foreground/70`,children:(0,Q.jsx)(`path`,{d:`M1 8L9 2V14L1 8Z`,fill:`currentColor`})})}),(0,Q.jsx)(`button`,{className:`absolute right-0 top-1/2 -translate-y-1/2 w-11 h-11 flex items-center justify-center rounded-lg active:bg-primary/20 transition-colors z-10`,"aria-label":`D-pad right`,...i(`right`),children:(0,Q.jsx)(`svg`,{width:`10`,height:`16`,viewBox:`0 0 10 16`,className:`text-foreground/70`,children:(0,Q.jsx)(`path`,{d:`M9 8L1 14V2L9 8Z`,fill:`currentColor`})})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`button`,{className:`size-14 rounded-full bg-muted/80 backdrop-blur-sm border border-border/50 flex items-center justify-center active:bg-primary/20 active:scale-95 transition-all text-sm font-bold text-foreground/70`,"aria-label":`B button`,...i(`b`),children:`B`}),(0,Q.jsx)(`button`,{className:`size-14 rounded-full bg-muted/80 backdrop-blur-sm border border-border/50 flex items-center justify-center active:bg-primary/20 active:scale-95 transition-all text-sm font-bold text-foreground/70 -mt-8`,"aria-label":`A button`,...i(`a`),children:`A`})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-6`,children:[(0,Q.jsx)(`button`,{className:`h-8 px-4 rounded-full bg-muted/80 backdrop-blur-sm border border-border/50 flex items-center justify-center active:bg-primary/20 active:scale-95 transition-all text-[10px] font-bold uppercase tracking-wider text-foreground/60`,"aria-label":`Select`,...i(`select`),children:`Select`}),(0,Q.jsx)(`button`,{className:`h-8 px-4 rounded-full bg-muted/80 backdrop-blur-sm border border-border/50 flex items-center justify-center active:bg-primary/20 active:scale-95 transition-all text-[10px] font-bold uppercase tracking-wider text-foreground/60`,"aria-label":`Start`,...i(`start`),children:`Start`})]})]})}var Dc=new Map,Oc=32,kc=128,Ac=.15,jc=.08;function Mc(e,t,n){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2,l=0,u=0;if(o!==s){let e=o-s;switch(u=c>.5?e/(2-o-s):e/(o+s),o){case r:l=(i-a)/e+(i(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=n<.5?n*(1+t):n+t-n*t,o=2*n-a;return{r:Math.round(i(o,a,r+1/3)*255),g:Math.round(i(o,a,r)*255),b:Math.round(i(o,a,r-1/3)*255)}}function Pc(e){let[t,n]=(0,Z.useState)(()=>e&&Dc.has(e)?Dc.get(e):null);return(0,Z.useEffect)(()=>{if(!e){n(null);return}if(Dc.has(e)){n(Dc.get(e));return}let t=!1,r=new Image;return r.crossOrigin=`anonymous`,r.onload=()=>{if(!t)try{let t=document.createElement(`canvas`);t.width=Oc,t.height=Oc;let i=t.getContext(`2d`,{willReadFrequently:!0});if(!i){Dc.set(e,null),n(null);return}i.drawImage(r,0,0,Oc,Oc);let{data:a}=i.getImageData(0,0,Oc,Oc),o=new Float32Array(18),s=new Float32Array(18),c=new Float32Array(18),l=new Uint32Array(18);for(let e=0;e1-jc)continue;let f=Math.min(17,Math.floor(i/360*18)),p=u;o[f]+=p,s[f]+=u*p,c[f]+=d*p,l[f]+=1}let u=-1,d=0;for(let e=0;e<18;e++)o[e]>d&&(d=o[e],u=e);if(u<0||l[u]<4){Dc.set(e,null),n(null);return}let f=(u+.5)*(360/18),p=s[u]/o[u],m=c[u]/o[u],h={...Nc(f,p,m),h:f,s:p,l:m};Dc.set(e,h),n(h)}catch{Dc.set(e,null),n(null)}},r.onerror=()=>{t||(Dc.set(e,null),n(null))},r.src=e,()=>{t=!0}},[e]),t}function Fc(e){let{nostr:t}=He(),{user:n,metadata:r}=Vt(),{mutate:i}=Ht(),a=lt(),o=(0,Z.useRef)(null);o.current||=Je();let s=(0,Z.useMemo)(()=>new Ve(o.current),[]),c=(0,Z.useMemo)(()=>Ze(o.current),[]),l=(0,Z.useRef)(null),u=(0,Z.useRef)(0),{data:d}=F({queryKey:[`webxdc-updates`,e],queryFn:async()=>(await t.query([{kinds:[4932],"#i":[e],limit:500}])).sort((e,t)=>e.created_at-t.created_at),refetchInterval:3e3}),f=(0,Z.useMemo)(()=>d?d.map((e,t)=>{let n=t+1,r;try{r=JSON.parse(e.content)}catch{r=e.content}let i=e.tags.find(([e])=>e===`info`)?.[1],a=e.tags.find(([e])=>e===`document`)?.[1],o=e.tags.find(([e])=>e===`summary`)?.[1];return{payload:r,serial:n,max_serial:d.length,...i&&{info:i},...a&&{document:a},...o&&{summary:o}}}):[],[d]);(0,Z.useEffect)(()=>{if(!l.current||!f.length)return;let e=l.current,t=u.current;for(let n of f)n.serial>t&&(e(n),u.current=n.serial)},[f]);let p=(0,Z.useRef)(!1),m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>()=>{m.current&&(m.current.abort(),p.current=!1)},[]);let h=n?n.pubkey:c,g=P.npubEncode(h),_=r?.name||r?.display_name||P.npubEncode(h).slice(0,12),v=(0,Z.useCallback)(async e=>{if(n)i(e);else{let n=await s.signEvent(e);await t.event(n,{signal:AbortSignal.timeout(5e3)})}},[n,i,s,t]),y=(0,Z.useCallback)((t,n)=>{let r=[[`i`,e],[`alt`,`Webxdc update`]];t.info&&r.push([`info`,t.info]),t.document&&r.push([`document`,t.document]),t.summary&&r.push([`summary`,t.summary]),v({kind:4932,content:JSON.stringify(t.payload),tags:r,created_at:Math.floor(Date.now()/1e3)}).then(()=>{a.invalidateQueries({queryKey:[`webxdc-updates`,e]})}).catch(e=>{console.error(`Failed to publish webxdc update:`,e)})},[e,v,a]),b=(0,Z.useCallback)(async(e,t)=>{l.current=e,u.current=t??0;for(let n of f)n.serial>(t??0)&&(e(n),u.current=n.serial)},[f]),x=(0,Z.useCallback)(async()=>f,[f]),S=(0,Z.useCallback)(async()=>{throw Error(`sendToChat is not supported in Nostr`)},[]),C=(0,Z.useCallback)(async()=>[],[]),w=(0,Z.useCallback)(()=>{if(p.current)throw Error(`Already joined a realtime channel. Call leave() first.`);p.current=!0;let n=new AbortController;m.current=n;let r=null;return(async()=>{try{for await(let i of t.req([{kinds:[20932],"#i":[e],since:Math.floor(Date.now()/1e3)}],{signal:n.signal}))if(i[0]===`EVENT`){let e=i[2];if(e.pubkey===h||!r)continue;try{let t=Uint8Array.from(atob(e.content),e=>e.charCodeAt(0));r(t)}catch{}}else if(i[0]===`CLOSED`)break}catch{}})(),{setListener(e){r=e},send(t){if(!p.current)return;if(t.length>128e3)throw Error(`Realtime payload exceeds 128,000 byte limit`);let n=``;for(let e=0;e{console.error(`Failed to publish webxdc realtime event:`,e)})},leave(){p.current=!1,n.abort(),m.current=null}}},[e,t,h,v]);return(0,Z.useMemo)(()=>({selfAddr:g,selfName:_,sendUpdateInterval:1e3,sendUpdateMaxSize:65536,sendUpdate:y,setUpdateListener:b,getAllUpdates:x,sendToChat:S,importFiles:C,joinRealtimeChannel:w}),[g,_,y,b,x,S,C,w])}function Ic(e){let t=vn(e,`seed`),n=localStorage.getItem(t);if(n)return n;let r=crypto.randomUUID();return localStorage.setItem(t,r),r}function Lc(e,t,n){let r=Ic(e),i=new TextEncoder;return An(et(Ke(nt,i.encode(r),i.encode(`${t}|${n}`))))}var Rc=e(Ie(),1);function zc(e){let[t,n]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{if(!e){n(null);return}let t=()=>{let t=e.getBoundingClientRect();n({left:t.left,top:t.top,width:t.width,height:t.height})};t();let r=new ResizeObserver(t);return r.observe(e),window.addEventListener(`resize`,t),()=>{r.disconnect(),window.removeEventListener(`resize`,t)}},[e]),t}function Bc({url:e,uuid:t,name:n,icon:i,encryption:a,showNameCard:o=!0,className:s}){let[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(null),p=Mr(),m=zc(c?p:null),{config:h}=I(),g=Or(e,a),_=Or(i??``,i&&a?jt(a):void 0),v=g.src??e,y=i?_.src:void 0,b=t??e,x=Lc(h.appId,`webxdc`,b),S=(0,Z.useCallback)(()=>{l(!1),d(!1)},[]),C=(0,Z.useCallback)(()=>{d(e=>(e||f.current?.focus(),!e))},[]);if(!c){let e=n??`Webxdc App`;return(0,Q.jsxs)(`div`,{className:z(`mt-3 flex flex-col items-center`,s),onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(Vc,{appName:e,icon:y,onLaunch:()=>l(!0)}),o&&(0,Q.jsx)(`div`,{className:`mt-2.5 w-full max-w-sm rounded-xl bg-secondary/50 px-3.5 py-2.5`,children:(0,Q.jsx)(`p`,{className:`text-base font-semibold text-foreground break-words`,children:e})})]})}if(!p||!m)return null;let w=Math.max(0,m.top),T=window.innerHeight-w;return(0,Rc.createPortal)((0,Q.jsxs)(`div`,{className:`fixed z-50 flex flex-col bg-background`,style:{left:m.left,top:w,width:m.width,height:T},onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`div`,{className:`min-h-11 border-b bg-muted/30 shrink-0 safe-area-top`,children:(0,Q.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 w-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,Q.jsx)(ln,{src:y,alt:n??`Webxdc App`,className:`size-6 rounded-md object-cover shrink-0`,decoding:`async`,fallback:(0,Q.jsx)(`div`,{className:`size-6 rounded-md bg-primary/10 flex items-center justify-center shrink-0`,children:(0,Q.jsx)(r,{className:`size-3.5 text-primary/50`})})}),(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate`,children:n??`Webxdc App`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(B,{variant:`ghost`,size:`sm`,className:z(`h-7 w-7 p-0 shrink-0`,u&&`text-primary`),onClick:C,title:u?`Hide gamepad`:`Show gamepad`,children:(0,Q.jsx)(pe,{className:`size-3.5`})}),(0,Q.jsx)(B,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 shrink-0`,onClick:S,title:`Close`,children:(0,Q.jsx)(j,{className:`size-3.5`})})]})]})}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 bg-white relative`,children:(0,Q.jsx)(Hc,{ref:f,id:x,url:v,uuid:t})}),u&&(0,Q.jsx)(`div`,{className:`border-t border-border bg-background/80 backdrop-blur-sm`,children:(0,Q.jsx)(Ec,{webxdcHandle:f.current})})]}),document.body)}function Vc({appName:e,icon:t,onLaunch:n}){let i=en(18,1.03,800),a=Pc(t),o=a?`hsl(${a.h.toFixed(1)}, ${Math.min(100,Math.max(70,a.s*100+20)).toFixed(1)}%, 50%)`:null;return(0,Q.jsx)(`div`,{ref:i.ref,style:{...i.style,touchAction:`pan-y`},onPointerDown:i.onPointerDown,onPointerMove:i.onPointerMove,onPointerUp:i.onPointerUp,onPointerLeave:i.onPointerLeave,className:`w-full max-w-sm`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":`Launch ${e}`,className:z(`relative block w-full bg-transparent p-0 border-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-xl`,`isolate`),children:[(0,Q.jsx)(`img`,{src:`/cartridge.png`,alt:``,"aria-hidden":`true`,className:`w-full h-auto block select-none pointer-events-none drop-shadow-md`,draggable:!1,decoding:`async`}),o&&(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`absolute inset-0 pointer-events-none`,style:{backgroundColor:o,WebkitMaskImage:`url(/cartridge.png)`,maskImage:`url(/cartridge.png)`,WebkitMaskSize:`100% 100%`,maskSize:`100% 100%`,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,mixBlendMode:`color`}}),(0,Q.jsx)(`div`,{className:`absolute flex items-center justify-center`,style:{left:`21.48%`,top:`29.66%`,width:`57.32%`,height:`45.99%`},children:(0,Q.jsx)(ln,{src:t,"aria-hidden":`true`,className:`w-[70%] aspect-square rounded-[12%] object-cover drop-shadow-md`,draggable:!1,decoding:`async`,fallback:(0,Q.jsx)(`div`,{className:`w-[70%] aspect-square rounded-[12%] bg-primary/15 flex items-center justify-center drop-shadow-md`,children:(0,Q.jsx)(r,{className:`w-1/2 h-1/2 text-primary`})})})})]})})}var Hc=(0,Z.forwardRef)(function({id:e,url:t,uuid:n},r){return(0,Q.jsx)(Sc,{ref:r,id:e,xdc:t,webxdc:Fc(n??``),className:`w-full h-full border-0`})});function Uc(e){let t=(0,Z.useRef)(e);t.current=e,(0,Z.useEffect)(()=>{let e=!1;window.history.pushState({dittoBackDismiss:!0},``);let n=()=>{e=!0,t.current()};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),e||window.history.back()}},[])}function Wc({images:e,className:t,maxVisible:n=4,maxGridHeight:r=`400px`,imetaMap:i,lightboxBottomBar:a,lightboxTopBarLeft:o,lightboxIndex:s,onLightboxOpen:c,onLightboxClose:l}){let[u,d]=(0,Z.useState)(null),f=s===void 0?u:s,p=e.slice(0,n),m=e.length-n,h=(0,Z.useMemo)(()=>i?e.map(e=>i.get(e)??{}):void 0,[e,i]),g=(e,t)=>{t.preventDefault(),t.stopPropagation(),c?c(e):d(e)},_=(0,Z.useCallback)(e=>{e&&(e.stopPropagation(),e.preventDefault()),l?l():d(null)},[l]),v=(0,Z.useCallback)(()=>{c&&f!=null?c(f+1t===null?null:Math.min(t+1,e.length-1))},[e.length,f,c]),y=(0,Z.useCallback)(()=>{c&&f!=null?c(f-1>=0?f-1:f):d(e=>e===null?null:Math.max(e-1,0))},[f,c]);return e.length===0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:z(`mt-3 rounded-2xl overflow-hidden`,p.length>1&&`grid grid-cols-2 gap-0.5`,t),children:p.map((e,t)=>(0,Q.jsx)(Kc,{url:e,index:t,visibleCount:p.length,maxGridHeight:r,overflow:t===p.length-1?m:0,onOpen:e=>g(t,e),dim:i?.get(e)?.dim,blurhash:i?.get(e)?.blurhash,encryption:i?.get(e)?.encryption},t))}),f!=null&&(0,Q.jsx)(Jc,{images:e,currentIndex:f,onClose:_,onNext:v,onPrev:y,mediaMeta:h,topBarLeft:o,bottomBar:a})]})}function Gc(e){if(!e)return;let[t,n]=e.split(`x`).map(Number);if(!(!t||!n||isNaN(t)||isNaN(n)))return{width:t,height:n}}function Kc({url:e,index:t,visibleCount:n,maxGridHeight:r,overflow:i,onOpen:a,dim:o,blurhash:s,encryption:c}){let[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(void 0),p=(0,Z.useRef)(null),m=qt(e),{ref:h,inView:g}=Nr({rootMargin:`400px`,skip:!c}),_=Or(e,c,{enabled:g}),v=_.encrypted?_.src:m.src,y=_.encrypted?void 0:m.onError;(0,Z.useEffect)(()=>{if(p.current?.complete&&p.current.naturalWidth>0&&(u(!0),!o)){let{naturalWidth:e,naturalHeight:t}=p.current;e&&t&&f(`${e} / ${t}`)}},[o]);let b=n===1,x=Gc(o),S=x?`${x.width} / ${x.height}`:d,C=b?{aspectRatio:S,maxHeight:`85dvh`,minHeight:S?void 0:`200px`}:{height:n===3&&t===0?r:`calc(${r} / 2)`};return(0,Q.jsxs)(`button`,{ref:h,type:`button`,className:z(`relative block w-full overflow-hidden focus:outline-none focus-visible:ring-2 focus-visible:ring-primary`,n===3&&t===0&&`row-span-2`),style:C,onClick:a,children:[!l&&!_.error&&!_.tooLarge&&($s(s)?(0,Q.jsx)(Qs,{hash:s,width:32,height:32,resolutionX:32,resolutionY:32,punch:1,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`}}):(0,Q.jsx)(X,{className:`absolute inset-0 w-full h-full rounded-none`})),_.error||_.tooLarge?(0,Q.jsx)(Er,{fill:!0,unsupported:_.unsupported,tooLarge:_.tooLarge,byteSize:_.byteSize,onDecryptAnyway:_.decryptAnyway}):(0,Q.jsx)(`img`,{ref:p,src:v,alt:``,width:x?.width,height:x?.height,className:z(`absolute inset-0 w-full h-full object-cover transition-all duration-300 hover:scale-[1.02]`,l?`opacity-100`:`opacity-0`),loading:`lazy`,onLoad:e=>{if(u(!0),!o){let t=e.currentTarget;t.naturalWidth&&t.naturalHeight&&f(`${t.naturalWidth} / ${t.naturalHeight}`)}},onError:y,decoding:`async`}),i>0&&(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/50 flex items-center justify-center backdrop-blur-[2px]`,children:(0,Q.jsxs)(`span`,{className:`text-white text-2xl font-bold`,children:[`+`,i]})})]})}var qc=`__lightbox_loading__`;function Jc({images:e,currentIndex:t,onClose:n,onNext:r,onPrev:i,mediaTypes:a,mediaMeta:o,topBarLeft:s,showDownload:c=!0,maxDotIndicators:l=10,bottomBar:u}){let[d,f]=(0,Z.useState)(new Set),p=(0,Z.useCallback)(e=>{f(t=>{let n=new Set(t);return n.add(e),n})},[]),{toast:m}=Bt(),h=Ot(),[g,_]=(0,Z.useState)(!1),v=e[t],y=d.has(v),b=e.length>1,x=t0;(0,Z.useEffect)(()=>{let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[]),Uc(n),(0,Z.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n(),e.key===`ArrowRight`&&x&&r(),e.key===`ArrowLeft`&&S&&i()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n,r,i,x,S]);let C=(0,Z.useRef)(null),w=(0,Z.useRef)(0),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),D=(0,Z.useRef)(null),O=(0,Z.useRef)(!1),k=`cubic-bezier(0.25, 0.46, 0.45, 0.94)`,A=(0,Z.useRef)(0),te=(0,Z.useRef)(!1),M=(0,Z.useRef)(new Map),N=(0,Z.useCallback)((e,n,r)=>{let i=M.current.get(e);if(!i)return;let a=(e-t)*window.innerWidth;i.style.transition=r,i.style.transform=`translateX(${a+n}px)`},[t]),ne=(0,Z.useCallback)((e=0)=>{M.current.forEach((t,n)=>N(n,e,`none`))},[N]),re=(0,Z.useCallback)((e,t)=>{let n=C.current;if(!n)return;let r=Math.min(Math.abs(e)/(window.innerHeight*.4),1);n.style.transition=t?`opacity ${t.split(` `).slice(1).join(` `)}`:`none`,n.style.opacity=String(1-r*.6);let i=n.querySelector(`[data-lightbox-content]`);i&&(i.style.transition=t,i.style.transform=`translateY(${e}px)`)},[]);(0,Z.useEffect)(()=>{w.current=0,ne(0)},[t,ne]),(0,Z.useEffect)(()=>()=>{O.current=!1},[]);let ie=e=>{if(!O.current){if(e.touches.length>=2){T.current=null,E.current=null;return}T.current=e.touches[0].clientX,E.current=e.touches[0].clientY,D.current=null,M.current.forEach((e,t)=>N(t,w.current,`none`)),re(0,`none`),A.current=0}},ae=(0,Z.useRef)(e=>{});ae.current=e=>{if(T.current===null||E.current===null||O.current)return;let t=e.touches[0].clientX-T.current,n=e.touches[0].clientY-E.current;if(!D.current){if(Math.abs(t)<4&&Math.abs(n)<4)return;D.current=Math.abs(t)>=Math.abs(n)?`h`:`v`}if(D.current===`v`){if(te.current)return;e.preventDefault(),A.current=n,re(n,`none`);return}D.current===`h`&&(e.preventDefault(),w.current=t>0&&!S||t<0&&!x?t*.2:t,M.current.forEach((e,t)=>N(t,w.current,`none`)))},(0,Z.useEffect)(()=>{let e=C.current;if(!e)return;let t=e=>ae.current(e);return e.addEventListener(`touchmove`,t,{passive:!1}),()=>e.removeEventListener(`touchmove`,t)},[]);let oe=e=>{if(D.current===`v`&&E.current!==null&&!te.current){let t=e.changedTouches[0].clientY-E.current;if(T.current=null,E.current=null,D.current=null,Math.abs(t)>window.innerHeight*.15){O.current=!0;let e=t>0?window.innerHeight:-window.innerHeight;re(e,`transform 280ms ${k}`),setTimeout(()=>{A.current=0,n(),O.current=!1},280)}else re(0,`transform 280ms ${k}`),A.current=0;return}if(T.current===null||D.current!==`h`){T.current=null,E.current=null,D.current=null,M.current.forEach((e,t)=>N(t,0,`transform 280ms ${k}`)),w.current=0;return}let t=e.changedTouches[0].clientX-T.current;T.current=null,E.current=null,D.current=null;let a=Math.abs(t)>window.innerWidth*.2,o=t<0&&x&&a;if(o||t>0&&S&&a){O.current=!0;let e=o?-window.innerWidth:window.innerWidth,t=`transform 280ms ${k}`;M.current.forEach((n,r)=>N(r,e,t)),setTimeout(()=>{O.current=!1,w.current=0,o?r():i()},280)}else M.current.forEach((e,t)=>N(t,0,`transform 280ms ${k}`)),w.current=0},se=e=>{let t=e.target;t.tagName===`IMG`||t.closest(`button`)||t.closest(`[data-gallery-topbar]`)||(e.stopPropagation(),e.preventDefault(),n())},ce=async e=>{if(e.stopPropagation(),e.preventDefault(),!g){_(!0);try{let e=o?.[t]?.encryption;if((e?await Ft(v,e):await Pt(v))===`downloaded`){let e=At.getPlatform();m(e===`android`?{title:h.formatMessage({id:`gallery.savedAndroid`,defaultMessage:`Downloading`}),description:h.formatMessage({id:`gallery.savedAndroidDescription`,defaultMessage:`Saving to your Downloads folder.`})}:e===`ios`?{title:h.formatMessage({id:`gallery.savedNative`,defaultMessage:`Saved to your device`}),description:h.formatMessage({id:`gallery.savedNativeDescription`,defaultMessage:`You'll find it in the Ditto folder in Files.`})}:{title:h.formatMessage({id:`gallery.savedWeb`,defaultMessage:`Saved`}),description:h.formatMessage({id:`gallery.savedWebDescription`,defaultMessage:`Check your downloads folder.`})})}else m({title:h.formatMessage({id:`gallery.downloadOpened`,defaultMessage:`Opened in a new tab`}),description:h.formatMessage({id:`gallery.downloadOpenedDescription`,defaultMessage:`This file couldn't be downloaded directly, so it opened in a new tab. Save it from there.`})})}catch{m({title:h.formatMessage({id:`gallery.downloadFailed`,defaultMessage:`Download failed`}),description:h.formatMessage({id:`gallery.downloadFailedDescription`,defaultMessage:`Could not download this file. Please try again.`}),variant:`destructive`})}finally{_(!1)}}},le=[t-1,t,t+1].filter(t=>t>=0&&t{for(let n=-3;n<=3;n++){if(Math.abs(n)<=1)continue;let r=t+n;if(r<0||r>=e.length||(a?.[r]??`image`)!==`image`||o?.[r]?.encryption)continue;let i=e[r];if(!i||i===`__lightbox_loading__`||ue.current.has(i))continue;ue.current.add(i);let s=new Image;for(s.fetchPriority=`low`,s.onload=()=>p(i),s.src=i,de.current.push(s);de.current.length>12;)de.current.shift()}},[t,e,a,o,p]),(0,Z.useEffect)(()=>{let e=ue.current,t=de.current;return()=>{e.clear(),t.length=0}},[]),(0,Rc.createPortal)((0,Q.jsxs)(`div`,{ref:C,className:`fixed inset-0 z-[100] animate-in fade-in duration-200`,onClick:se,onTouchStart:ie,onTouchEnd:oe,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/90 backdrop-blur-md`}),(0,Q.jsxs)(`div`,{"data-lightbox-content":!0,className:`absolute inset-0`,children:[(0,Q.jsxs)(`div`,{"data-gallery-topbar":!0,className:`absolute left-0 right-0 z-10 flex items-center justify-between px-4 py-3 safe-area-inset-top`,children:[s===void 0?(0,Q.jsxs)(Q.Fragment,{children:[b&&(0,Q.jsxs)(`span`,{className:`text-white/80 text-sm font-medium tabular-nums`,children:[t+1,` / `,e.length]}),!b&&(0,Q.jsx)(`span`,{})]}):s,(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[c&&(0,Q.jsx)(`button`,{onClick:ce,disabled:g,className:`p-2.5 rounded-full text-white/70 hover:text-white hover:bg-white/10 transition-colors disabled:opacity-60 disabled:cursor-wait`,title:`Download`,children:g?(0,Q.jsx)(ee,{className:`size-5 animate-spin`}):(0,Q.jsx)(me,{className:`size-5`})}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),e.preventDefault(),n()},className:`p-2.5 rounded-full text-white/70 hover:text-white hover:bg-white/10 transition-colors`,title:`Close (Esc)`,children:(0,Q.jsx)(j,{className:`size-5`})})]})]}),S&&(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},className:`absolute left-3 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-black/40 text-white/80 hover:text-white hover:bg-black/60 backdrop-blur-sm transition-all hidden sm:flex`,title:`Previous`,children:(0,Q.jsx)(De,{className:`size-6`})}),x&&(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r()},className:`absolute right-3 top-1/2 -translate-y-1/2 z-10 p-2 rounded-full bg-black/40 text-white/80 hover:text-white hover:bg-black/60 backdrop-blur-sm transition-all hidden sm:flex`,title:`Next`,children:(0,Q.jsx)(be,{className:`size-6`})}),(0,Q.jsx)(`div`,{"data-lightbox-strip":!0,className:`absolute inset-0 overflow-hidden`,children:le.map(n=>{let r=e[n],i=n===t,s=(n-t)*window.innerWidth;return(0,Q.jsxs)(`div`,{ref:e=>{e?M.current.set(n,e):M.current.delete(n)},className:z(`absolute inset-0 flex items-center justify-center will-change-transform`,u?`pb-24 pt-14 px-4 sm:px-12`:`py-6 pt-14 px-4 sm:px-12`),style:{transform:`translateX(${s}px)`},children:[i&&!y&&(a?.[n]??`image`)===`image`&&(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:(0,Q.jsx)(`div`,{className:`size-8 border-2 border-white/20 border-t-white/80 rounded-full animate-spin`})}),(0,Q.jsx)(Qc,{url:r,type:a?.[n]??`image`,meta:o?.[n],isActive:i,isLoaded:i?y:!0,onLoad:p,onSwipeBlocked:()=>{T.current=null,D.current=null},onZoomChange:e=>{te.current=e}})]},r)})}),b&&e.length<=l&&(0,Q.jsx)(`div`,{className:z(`absolute left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 sm:hidden`,u?`bottom-20`:`bottom-6`),children:e.map((e,n)=>(0,Q.jsx)(`div`,{className:z(`rounded-full transition-all duration-200`,n===t?`size-2 bg-white`:`size-1.5 bg-white/40`)},n))}),u&&(0,Q.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 z-10`,onClick:e=>e.stopPropagation(),children:u})]})]}),document.body)}var Yc=1,Xc=8;function Zc({url:e,encryption:t,isLoaded:n,onLoad:r,onSwipeBlocked:i,onZoomChange:a}){let o=qt(e),s=Or(e,t),c=s.encrypted?s.src:o.src,l=s.encrypted?void 0:o.onError,u=(0,Z.useRef)(null),d=(0,Z.useRef)(null),f=(0,Z.useRef)(1),p=(0,Z.useRef)(0),m=(0,Z.useRef)(0),h=(0,Z.useRef)(null),g=(0,Z.useRef)(null),_=(0,Z.useRef)(0),v=(0,Z.useRef)(null),y=(0,Z.useCallback)(()=>r(e),[r,e]);(0,Z.useEffect)(()=>{u.current?.complete&&u.current.naturalWidth>0&&y()},[c,y]),(0,Z.useEffect)(()=>{(s.error||s.tooLarge)&&y()},[s.error,s.tooLarge,y]);let b=(0,Z.useCallback)(()=>{a?.(f.current>1)},[a]);(0,Z.useEffect)(()=>{f.current=1,p.current=0,m.current=0,x(),b()},[e,b]);function x(e=!1){let t=d.current;t&&(t.style.transition=e?`transform 0.25s ease`:`none`,t.style.transform=`translate(${p.current}px, ${m.current}px) scale(${f.current})`)}function S(e=f.current){let t=u.current,n=d.current;if(!t||!n)return;let r=t.offsetWidth*e,i=t.offsetHeight*e,a=n.parentElement?.offsetWidth??window.innerWidth,o=n.parentElement?.offsetHeight??window.innerHeight,s=Math.max(0,(r-a)/2),c=Math.max(0,(i-o)/2);p.current=Math.max(-s,Math.min(s,p.current)),m.current=Math.max(-c,Math.min(c,m.current))}function C(e){let t=e[1].clientX-e[0].clientX,n=e[1].clientY-e[0].clientY;return Math.sqrt(t*t+n*n)}let w=e=>{if(e.touches.length===2)h.current={dist:C(e.touches),midX:(e.touches[0].clientX+e.touches[1].clientX)/2,midY:(e.touches[0].clientY+e.touches[1].clientY)/2,scale:f.current,panX:p.current,panY:m.current},g.current=null;else if(e.touches.length===1){f.current>1&&(g.current={x:e.touches[0].clientX,y:e.touches[0].clientY,panX:p.current,panY:m.current});let t=Date.now();if(t-_.current<300){if(e.preventDefault(),f.current>1)f.current=1,p.current=0,m.current=0;else{f.current=2.5;let t=d.current?.getBoundingClientRect();if(t){let n=e.touches[0].clientX-t.left-t.width/2,r=e.touches[0].clientY-t.top-t.height/2;p.current=-n*(f.current-1)/f.current,m.current=-r*(f.current-1)/f.current,S()}}x(!0),b()}_.current=t}},T=e=>{if(e.touches.length===2&&h.current){e.preventDefault();let t=h.current,n=Math.max(Yc,Math.min(Xc,t.scale*C(e.touches)/t.dist)),r=(e.touches[0].clientX+e.touches[1].clientX)/2,i=(e.touches[0].clientY+e.touches[1].clientY)/2;f.current=n,p.current=t.panX+(r-t.midX),m.current=t.panY+(i-t.midY),S(n),x(),b()}else if(e.touches.length===1&&g.current&&f.current>1){e.preventDefault();let t=g.current;p.current=t.panX+(e.touches[0].clientX-t.x),m.current=t.panY+(e.touches[0].clientY-t.y),S(),x(),i?.()}},E=e=>{e.touches.length<2&&(h.current=null),e.touches.length===0&&(g.current=null,f.current{if(e.ctrlKey||e.metaKey){e.preventDefault();let t=e.deltaY<0?1.1:.9;f.current=Math.max(Yc,Math.min(Xc,f.current*t)),f.current===Yc?(p.current=0,m.current=0):S(),x(),b()}else f.current>1&&(e.preventDefault(),p.current-=e.deltaX,m.current-=e.deltaY,S(),x())},O=e=>{f.current<=1||(e.preventDefault(),v.current={x:e.clientX,y:e.clientY,panX:p.current,panY:m.current})},ee=e=>{v.current&&(p.current=v.current.panX+(e.clientX-v.current.x),m.current=v.current.panY+(e.clientY-v.current.y),S(),x())},k=()=>{v.current&&(v.current=null,S(),x(!0))},A=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{let e=A.current;if(!e)return;let t=e=>T(e),n=e=>D(e);return e.addEventListener(`touchmove`,t,{passive:!1}),e.addEventListener(`wheel`,n,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t),e.removeEventListener(`wheel`,n)}},[]),(0,Q.jsx)(`div`,{ref:A,className:`w-full h-full flex items-center justify-center overflow-hidden`,onTouchStart:w,onTouchEnd:E,onMouseDown:O,onMouseMove:ee,onMouseUp:k,onMouseLeave:k,style:{cursor:f.current>1?`grab`:`default`},children:(0,Q.jsx)(`div`,{ref:d,style:{transformOrigin:`center center`,willChange:`transform`,width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:s.error||s.tooLarge?(0,Q.jsx)(Er,{unsupported:s.unsupported,tooLarge:s.tooLarge,byteSize:s.byteSize,onDecryptAnyway:s.decryptAnyway,className:`max-w-sm bg-white/10 text-white/80`}):(0,Q.jsx)(`img`,{ref:u,src:c,alt:``,className:z(`block max-w-full max-h-full object-contain select-none transition-opacity duration-300`,n?`opacity-100`:`opacity-0`),onLoad:y,onError:l,draggable:!1,decoding:`async`})})})}function Qc({url:e,type:t,meta:n,isLoaded:r,onLoad:i,onSwipeBlocked:a,onZoomChange:o}){let s=R(t===`audio`?n?.pubkey:void 0).data?.metadata,c=n?.pubkey?`Anonymous`:`?`;return e===`__lightbox_loading__`?(0,Q.jsx)(`div`,{className:`size-10 border-2 border-white/20 border-t-white/80 rounded-full animate-spin`}):t===`video`?(0,Q.jsx)(`div`,{className:`w-full flex items-center justify-center px-4`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(ac,{src:e,encryption:n?.encryption,dim:n?.dim,blurhash:n?.blurhash,className:`w-full max-w-lg`})}):t===`audio`?(0,Q.jsx)(`div`,{className:`w-full flex items-center justify-center px-4`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(oc,{src:e,mime:n?.mime,encryption:n?.encryption,avatarUrl:s?.picture,avatarFallback:c[0]?.toUpperCase(),avatarShape:U(s),className:`w-full max-w-lg`})}):(0,Q.jsx)(Zc,{url:e,encryption:n?.encryption,isLoaded:r,onLoad:i,onSwipeBlocked:a,onZoomChange:o})}function $c(e){let{config:t}=I(),{user:n}=Vt(),{data:r}=Ut(),i=(0,Z.useMemo)(()=>new Set(r?.pubkeys??[]),[r]);return!(!t.hideMediaFromStrangers||!n||e===n.pubkey||i.has(e))}var el=(0,Z.createContext)({active:!1,reveal:()=>{}});function tl({pubkey:e,children:t}){let n=$c(e),[r,i]=(0,Z.useState)(!1),a=(0,Z.useMemo)(()=>({active:n&&!r,reveal:()=>i(!0)}),[n,r]);return(0,Q.jsx)(el.Provider,{value:a,children:t})}function nl(){return(0,Z.useContext)(el)}function rl({children:e,className:t}){let{active:n,reveal:r}=nl();return n?(0,Q.jsxs)(`div`,{className:z(`relative mt-2 rounded-xl overflow-hidden`,t),children:[(0,Q.jsx)(`div`,{className:`bg-muted/40 blur-lg select-none`,"aria-hidden":!0,children:(0,Q.jsx)(`div`,{className:`mx-4 my-4 h-40 rounded-lg bg-muted/60`})}),(0,Q.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2.5 px-4 text-center`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-center size-10 rounded-full bg-background/80 shadow-sm backdrop-blur-sm`,children:(0,Q.jsx)(p,{className:`size-5 text-muted-foreground`})}),(0,Q.jsxs)(`div`,{className:`space-y-1 max-w-xs`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:(0,Q.jsx)(kt,{id:`strangerMedia.title`,defaultMessage:`Media hidden`})}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:(0,Q.jsx)(kt,{id:`strangerMedia.description`,defaultMessage:`This post is from someone you don't follow.`})})]}),(0,Q.jsxs)(B,{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(),r()},children:[(0,Q.jsx)(N,{className:`size-3.5`}),(0,Q.jsx)(kt,{id:`strangerMedia.reveal`,defaultMessage:`Show`})]})]})]}):(0,Q.jsx)(Q.Fragment,{children:e})}var il=`jpg|jpeg|png|gif|webp|svg|avif`,al=`mp4|webm|mov|qt|avi|mkv|flv`,ol=`mp3|mpga|wav|ogg|flac|m4a|aac|opus`,sl=`${il}|${al}|${ol}|xdc`,cl=RegExp(`https?:\\/\\/[^\\s]+\\.(${il})(\\?[^\\s]*)?`,`i`),ll=RegExp(`https?:\\/\\/[^\\s]+\\.(${al})(\\?[^\\s]*)?`,`gi`),ul=RegExp(`https?:\\/\\/[^\\s]+\\.(${ol})(\\?[^\\s]*)?`,`gi`),dl=RegExp(`https?:\\/\\/[^\\s]+\\.(${al}|${ol}|xdc)(\\?[^\\s]*)?`,`i`),fl=RegExp(`https?:\\/\\/[^\\s]+\\.(${sl})(\\?[^\\s]*)?`,`gi`),pl=new RegExp(fl.source,`i`);function ml(e){switch(e){case`jpg`:case`jpeg`:return`image/jpeg`;case`png`:return`image/png`;case`gif`:return`image/gif`;case`webp`:return`image/webp`;case`svg`:return`image/svg+xml`;case`avif`:return`image/avif`;case`mp4`:return`video/mp4`;case`webm`:return`video/webm`;case`mov`:return`video/quicktime`;case`qt`:return`video/quicktime`;case`avi`:return`video/x-msvideo`;case`mkv`:return`video/x-matroska`;case`flv`:return`video/x-flv`;case`mp3`:case`mpga`:return`audio/mpeg`;case`wav`:return`audio/wav`;case`ogg`:return`audio/ogg`;case`flac`:return`audio/flac`;case`m4a`:return`audio/mp4`;case`aac`:return`audio/aac`;case`opus`:return`audio/opus`;case`xdc`:return`application/x-webxdc`;default:return`application/octet-stream`}}function hl(e){return e.match(new RegExp(ll.source,`gi`))??[]}function gl(e){return e.match(new RegExp(ul.source,`gi`))??[]}var _l=/blossom:[a-f0-9]{64}\.[a-z0-9]+(?:\?[^\s]*)?/i;function vl(e){if(!e.toLowerCase().startsWith(`blossom:`))return;let t=e.slice(8),n=t.indexOf(`?`),r=n===-1?t:t.slice(0,n),i=n===-1?``:t.slice(n+1),a=/^([a-f0-9]{64})\.([a-z0-9]+)$/i.exec(r);if(!a)return;let o=a[1].toLowerCase(),s=a[2].toLowerCase();if(!V(o))return;let c=new URLSearchParams(i),l=[];for(let e of c.getAll(`xs`)){let t=Sl(e);t&&!l.includes(t)&&l.push(t)}let u=[];for(let e of c.getAll(`as`)){let t=e.toLowerCase();V(t)&&!u.includes(t)&&u.push(t)}let d,f=c.get(`sz`);if(f&&/^\d+$/.test(f)){let e=Number(f);Number.isSafeInteger(e)&&e>0&&(d=e)}return{sha256:o,ext:s,path:`${o}.${s}`,servers:l,authors:u,size:d}}function yl(e,t){if(!e.toLowerCase().startsWith(`blossom:`))return e;let n=vl(e);if(n)return Cl(n,t)[0]}function bl(e){let t=e.match(new RegExp(_l.source,`gi`))??[],n=[];for(let e of t){let t=vl(e);t&&n.push({uri:t,raw:e})}return n}function xl(e,t){let n=[`url ${t}`,`x ${e.sha256}`,`m ${ml(e.ext)}`];return typeof e.size==`number`&&n.push(`size ${e.size}`),[`imeta`,...n]}function Sl(e){if(!e)return;let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:`https://${e}`;try{let e=new URL(t);return e.protocol=`https:`,e.origin}catch{return}}function Cl(e,t){let n=[],r=new Set,i=t=>{let i;try{let e=new URL(t);e.protocol=`https:`,i=e.origin}catch{return}let a=L(`${i}/${e.path}`);a&&!r.has(a)&&(r.add(a),n.push(a))};for(let t of e.servers)i(t);for(let e of t)i(e);return n}function wl(e){let{config:t}=I(),[n,r]=(0,Z.useState)(0),i=(0,Z.useRef)(!1),a=(0,Z.useMemo)(()=>Cl(e,Kt(t.blossomServerMetadata,t.useAppBlossomServers)),[e.path,e.servers,t.blossomServerMetadata,t.useAppBlossomServers]);return{src:a[n],onError:(0,Z.useCallback)(()=>{r(e=>{let t=e+1;return t{let t=/\/(?:dp|gp\/product|gp\/aw\/d)\/([A-Za-z0-9]{10})(?:[/?]|$)/.exec(e.pathname);if(t)return{pathname:`/dp/${t[1]}`,dropQuery:!0}}},{hosts:[`spotify.com`,`spotify.link`],params:[`si`,`nd`,`_branch_match_id`,`_branch_referrer`]},{hosts:[`apple.com`],params:[`at`,`ct`,`uo`,`ls`,`itscg`,`itsct`,`app`]},{hosts:[`soundcloud.com`],params:[`si`,`ref`]},{hosts:[`twitch.tv`],params:[`tt_content`,`tt_medium`,`sr`]},{hosts:[`bilibili.com`,`b23.tv`],params:[`spm_id_from`,`from_source`,`from_spmid`,`share_source`,`share_medium`,`share_plat`,`share_session_id`,`share_tag`,`unique_k`,`vd_source`,`buvid`,`is_story_h5`,`plat_id`,`bbid`,`ts`,`timestamp`,`mid`]},{hosts:[`linkedin.com`],params:[`trk`,`trkinfo`,`traceid`,`trackingid`,`originalsubdomain`,`refid`,`midtoken`,`midsig`,`ebp`,`li_fat_id`,`licu`,`lipi`,`lici`]},{hosts:[`medium.com`],params:[`source`,`sk`,`gi`]},{hosts:[`substack.com`],params:[`r`,`showwelcome`,`triedredirect`,`triggershare`,`isfreemail`,`post_id`,`publication_id`]},{hosts:[`google.com`],matchHost:kl,params:[`ved`,`ei`,`usg`,`sa`,`source`,`oq`,`aqs`,`sourceid`,`client`,`sclient`,`uact`,`sxsrf`,`iflsig`,`gws_rd`,`bih`,`biw`,`dpr`],prefixes:[`gs_`]},{hosts:[`ebay.com`,`ebay.co.uk`,`ebay.de`,`ebay.fr`,`ebay.it`,`ebay.es`,`ebay.ca`,`ebay.com.au`],params:[`_trkparms`,`_trksid`,`hash`,`amdata`,`mkevt`,`mkcid`,`mkrid`,`campid`,`customid`,`toolid`,`ul_noapp`]},{hosts:[`aliexpress.com`,`aliexpress.us`],params:[`spm`,`scm`,`scm_id`,`scm-url`,`pvid`,`btsid`,`ws_ab_test`,`gatewayadapt`,`srcsns`,`businesstype`,`curpageloguid`],prefixes:[`aff_`,`pdp_`,`algo_`]},{hosts:[`etsy.com`],params:[`click_key`,`click_sum`,`ref`,`frs`,`sts`,`organic_search_click`,`plkey`],prefixes:[`ga_`]},{hosts:[`walmart.com`],params:[`from`,`sid`,`adsredirect`,`classtype`],prefixes:[`ath`]},{hosts:[`target.com`],params:[`preselect`,`lnk`,`clkid`,`afid`,`ref`]},{hosts:[`imdb.com`],params:[`ref_`,`pf_rd_p`,`pf_rd_r`]},{hosts:[`steampowered.com`,`steamcommunity.com`],params:[`snr`]},{hosts:[`bandcamp.com`],params:[`from`,`search_item_id`,`search_page_id`,`search_rank`,`search_sig`,`label`]},{hosts:[`pinterest.com`],params:[`nic_v1`,`nic_v2`,`nic_v3`,`sender`]}];function Ol(e,t){return e===t||e.endsWith(`.${t}`)}function kl(e){return/(^|\.)google(\.[a-z]{2,3})+$/.test(e)}function Al(e){return Dl.find(t=>t.matchHost?.(e)||t.hosts.some(t=>Ol(e,t)))}function jl(e,t){let n=e.toLowerCase();return Tl.has(n)||El.some(e=>n.startsWith(e))?!0:t?!!(t.params?.includes(n)||t.prefixes?.some(e=>n.startsWith(e))):!1}function Ml(e){if(!e.includes(`?`)&&!e.includes(`/dp/`)&&!e.includes(`/gp/`))return e;let t;try{t=new URL(e)}catch{return e}if(t.protocol!==`https:`&&t.protocol!==`http:`)return e;let n=Al(t.hostname.toLowerCase()),r=e.indexOf(`#`),i=r===-1?e:e.slice(0,r),a=r===-1?``:e.slice(r),o=i.indexOf(`?`),s=o===-1?i:i.slice(0,o),c=o===-1?``:i.slice(o+1),l=!1,u=!1,d=n?.canonical?.(t);d?.pathname&&d.pathname!==t.pathname&&(s=`${t.protocol}//${t.host}${d.pathname}`,l=!0,u=d.dropQuery??!1);let f=``;if(c&&!u){let e=c.split(`&`).filter(e=>{if(!e)return!1;let t=e.indexOf(`=`),r=t===-1?e:e.slice(0,t),i=r;try{i=decodeURIComponent(r)}catch{}return!jl(i,n)});e.length!==c.split(`&`).filter(Boolean).length&&(l=!0),f=e.join(`&`)}else c&&u&&(l=!0);return l?`${s}${f?`?${f}`:``}${a}`:e}var Nl=/https?:\/\/[^\s]+/gi;function Pl(e){let t=/^(.*?)([.,;:!?)\]]+)$/.exec(e);if(!t)return[e,``];let[,n,r]=t;for(;r.startsWith(`)`)&&!((n.match(/\(/g)??[]).length<=(n.match(/\)/g)??[]).length);)n+=`)`,r=r.slice(1);return!r||!n||n.length<=10?[e,``]:[n,r]}function Fl(e,t){if(!e.includes(`http`))return e;let n=!1,r=e.replace(Nl,e=>{let[r,i]=Pl(e);if(t?.has(r))return e;let a=Ml(r);return a===r?e:(n=!0,`${a}${i}`)});return n?r:e}function Il(e,t){let n=t.replace(/\s+/g,` `).trim();if(!n)return e;let r=n.split(` `).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`\\s+`),i=new RegExp(r,`gi`),a=[],o=0;for(let t of e){if(typeof t!=`string`){a.push(t);continue}i.lastIndex=0;let e=0,n,r=!1;for(;(n=i.exec(t))!==null;)r=!0,n.index>e&&a.push(t.slice(e,n.index)),a.push((0,Q.jsx)(`mark`,{className:`rounded bg-primary/25 text-foreground`,children:n[0]},`mark-${o++}`)),e=n.index+n[0].length,n[0].length===0&&i.lastIndex++;r?ei&&r.push(e.substring(i,a.index)),r.push((0,Q.jsx)(Zt,{name:s,url:c,className:n},`emoji-${a.index}`)),i=a.index+o.length)}return i0?r:[e]}var Bl=RegExp(`naddr1[023456789acdefghjklmnpqrstuvwxyz]{10,}`,`i`),Vl=`[^\\p{L}\\p{N}_/:.@+=?&%#~\\\\-]`;function Hl(e){let t=e.match(Bl);if(!t)return null;try{let e=P.decode(t[0]);if(e.type===`naddr`)return e.data}catch{}return null}var Ul=/([\u{1F1E6}-\u{1F1FF}]{2})/gu;function Wl(e){let t=[...e];if(t.length!==2)return null;let n=t[0].codePointAt(0)-127462+65,r=t[1].codePointAt(0)-127462+65,i=String.fromCharCode(n)+String.fromCharCode(r);return pr[i]?i:null}function Gl(e){let t=[],n=0;for(let r of e){if(typeof r!=`string`){t.push(r);continue}let e=0;Ul.lastIndex=0;let i;for(;(i=Ul.exec(r))!==null;){let a=i[1],o=Wl(a);o&&(i.index>e&&t.push(r.substring(e,i.index)),t.push((0,Q.jsx)(q,{to:`/i/iso3166:${o}`,className:`hover:opacity-70 transition-opacity`,onClick:e=>e.stopPropagation(),children:a},`flag-${n++}`)),e=i.index+i[0].length)}eKt(l.blossomServerMetadata,l.useAppBlossomServers),[l.blossomServerMetadata,l.useAppBlossomServers]),d=l.stripTrackingParams!==!1,f=(0,Z.useMemo)(()=>{let t=e.content,n=new Set(Dr(e.tags).map(e=>e.url)),r=RegExp(`(?:lightning:)?(ln(?:bc|tb|bcrt|tbs)\\d*[munp]?1[023456789acdefghjklmnpqrstuvwxyz]+)|((?:https?|wss?):\\/\\/[^\\s]+)|nostr:(npub1|note1|nprofile1|nevent1|naddr1)([023456789acdefghjklmnpqrstuvwxyz]+)|(^|${Vl})@?(npub1|note1|nprofile1|nevent1|naddr1)([023456789acdefghjklmnpqrstuvwxyz]+)|(${Yt})|(blossom:[a-f0-9]{64}\\.[a-z0-9]+(?:\\?[^\\s]*)?)`,`giu`),i=[],a=0,o,s=!1;for(;(o=r.exec(t))!==null;){let[e]=o,r=o[1],c=o[2],l=o[8],f=o[9],{3:p,4:m,5:h,6:g,7:_}=o,v=o.index;if(s=!0,h&&(v+=h.length,e=e.slice(h.length)),v>a&&i.push({type:`text`,value:t.substring(a,v)}),r)i.push({type:`lightning-invoice`,invoice:r.toLowerCase()});else if(c){let r=c.match(/^(.*?)([.,;:!?)\]]+)$/);if(r){let[,t]=r;t&&t.length>10&&(c=t,e=t)}if(d&&!n.has(c)&&(c=Ml(c)),/^wss?:\/\//i.test(c)){i.push({type:`relay-link`,url:c}),a=v+e.length;continue}if(cl.test(c)){if(i.length>0){let e=i[i.length-1];e.type===`text`&&(e.value=e.value.replace(/\s+$/,``))}i.push({type:`image-embed`,url:c}),a=v+e.length;let n=t.substring(a).match(/^\s+/);n&&(a+=n[0].length);continue}if(dl.test(c)){if(i.length>0){let e=i[i.length-1];e.type===`text`&&(e.value=e.value.replace(/\s+$/,``))}i.push({type:`media-embed`,url:c}),a=v+e.length;let n=t.substring(a).match(/^\s+/);n&&(a+=n[0].length);continue}let o=t.substring(v+e.length),s=o.indexOf(` `),l=(s===-1?o:o.substring(0,s)).trim()===``,u=Hl(c),f=Oa(c);f?i.push({type:`armada-invite`,invite:f}):u?i.push({type:`naddr-embed`,addr:u,url:c}):l?i.push({type:`link-embed`,url:c}):i.push({type:`inline-link`,url:c})}else if(p&&m||g&&_){let t=p||g,n=m||_;try{let r=`${t}${n}`,a=P.decode(r);if(a.type===`npub`)i.push({type:`mention`,pubkey:a.data});else if(a.type===`nprofile`)i.push({type:`mention`,pubkey:a.data.pubkey});else if(a.type===`note`)i.push({type:`nevent-embed`,eventId:a.data});else if(a.type===`nevent`)i.push({type:`nevent-embed`,eventId:a.data.id,relays:a.data.relays,author:a.data.author});else if(a.type===`naddr`){let e=Oa(r);e?i.push({type:`armada-invite`,invite:e}):i.push({type:`naddr-embed`,addr:a.data})}else i.push({type:`nostr-link`,id:r,raw:e})}catch{i.push({type:`text`,value:e})}}else if(l){let e=l.slice(1);i.push({type:`hashtag`,tag:e,raw:l})}else if(f){let n=vl(f);if(n){if(i.length>0){let e=i[i.length-1];e.type===`text`&&(e.value=e.value.replace(/\s+$/,``))}if(ml(n.ext).startsWith(`image/`)){let[e]=Cl(n,u);e?i.push({type:`image-embed`,url:e}):i.push({type:`blossom-uri`,uri:n,raw:f})}else i.push({type:`blossom-uri`,uri:n,raw:f});a=v+e.length;let r=t.substring(a).match(/^\s+/);r&&(a+=r[0].length);continue}i.push({type:`text`,value:e})}a=v+e.length}a0){for(let e of i)if(e.type===`nevent-embed`){let t=l.get(e.eventId);t&&((!e.relays||e.relays.length===0)&&t.relay&&(e.relays=[t.relay]),!e.author&&t.author&&(e.author=t.author))}}if(new Set([1,11,1111]).has(e.kind)){let t=new Set(i.filter(e=>e.type===`media-embed`).map(e=>e.url));for(let{url:n,mime:r}of Dr(e.tags)){let e=L(n);!e||t.has(e)||(r?.startsWith(`audio/`)||r?.startsWith(`video/`)||r===`application/x-webxdc`||r===`application/vnd.webxdc+zip`)&&i.push({type:`media-embed`,url:e})}}for(let e=0;e0){let t=i[e-1];t.type===`text`&&(t.value=t.value.replace(/\s+$/,``))}if(e0){let e=i[0];e.type===`text`&&(e.value=e.value.replace(/^\s+/,``));let t=i[i.length-1];t.type===`text`&&(t.value=t.value.replace(/\s+$/,``))}return i.filter(e=>!(e.type===`text`&&e.value===``))},[e,c,u,d]),{emojis:p}=Pr(),m=(0,Z.useMemo)(()=>{let t=Jt(e.tags);for(let e of p)t.has(e.shortcode)||t.set(e.shortcode,e.url);return t},[e.tags,p]),h=(0,Z.useMemo)(()=>kr(e.tags),[e.tags]),g=R(f.some(e=>e.type===`media-embed`)?e.pubkey:void 0).data?.metadata,_=(0,Z.useMemo)(()=>zn(g,e.pubkey)??`Anonymous`,[g,e.pubkey]),v=(0,Z.useMemo)(()=>{let e=[],t=0;for(;t=2?e.push({type:`image-gallery`,urls:r}):e.push(n),t=i}else e.push(n),t++}return e},[f]),y=(0,Z.useMemo)(()=>v.flatMap(e=>e.type===`image-embed`?[e.url]:e.type===`image-gallery`?e.urls:[]),[v]),b=(0,Z.useMemo)(()=>y.map(e=>h.get(e)??{}),[y,h]),[x,S]=(0,Z.useState)(null),C=(0,Z.useCallback)(()=>S(null),[]),w=(0,Z.useCallback)(()=>S(e=>e===null?null:(e+1)%y.length),[y.length]),T=(0,Z.useCallback)(()=>S(e=>e===null?null:(e-1+y.length)%y.length),[y.length]),E=v.length===1&&v[0].type===`text`&&Jl(v[0].value,m),D=(0,Z.useMemo)(()=>{let e=new Map,t=0;return v.forEach((n,r)=>{n.type===`image-embed`?e.set(r,t++):n.type===`image-gallery`&&(e.set(r,t),t+=n.urls.length)}),e},[v]);return(0,Q.jsxs)(o,{dir:`auto`,...Br(e),className:z(`whitespace-pre-wrap break-words overflow-hidden`,t,E&&`text-5xl leading-tight`),children:[v.map((t,o)=>{switch(t.type){case`text`:return(0,Q.jsx)(`span`,{children:Gl(Ll(zl(t.value,m,E?`inline h-12 w-12 object-contain align-text-bottom`:void 0),s))},o);case`image-embed`:{if(n||a)return null;let e=D.get(o)??0;return(0,Q.jsx)(rl,{children:(0,Q.jsx)(Xl,{url:t.url,encryption:h.get(t.url)?.encryption,onClick:t=>{t.stopPropagation(),S(e)}})},o)}case`image-gallery`:{if(n||a)return null;let e=D.get(o)??0,r=x!==null&&x>=e&&x{S(e+t)},onLightboxClose:C})},o)}case`link-embed`:return n?(0,Q.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:t.url},o):(0,Q.jsx)(Ts,{url:t.url,className:`my-2.5`,hideImage:r},o);case`inline-link`:return(0,Q.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:t.url},o);case`media-embed`:{if(n||a)return null;let e=h.get(t.url),r=e?.mime??``,i=r===`application/x-webxdc`||r===`application/vnd.webxdc+zip`||t.url.endsWith(`.xdc`),s=r.startsWith(`audio/`)||/\.(mp3|mpga|wav|ogg|flac|m4a|aac|opus)(\?[^\s]*)?$/i.test(t.url);return i&&e?(0,Q.jsx)(rl,{children:(0,Q.jsx)(Bc,{url:t.url,uuid:e.webxdc,name:e.summary,icon:e.thumbnail,encryption:e.encryption})},o):(0,Q.jsx)(rl,{children:(0,Q.jsx)(Zl,{url:t.url,imeta:e,isAudio:s,authorMetadata:g,authorDisplayName:_})},o)}case`nevent-embed`:if(i){let e=P.neventEncode({id:t.eventId,...t.author?{author:t.author}:{},...t.relays?.length?{relays:t.relays}:{}});return(0,Q.jsxs)(q,{to:`/${e}`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:[e.slice(0,16),`…`]},o)}return(0,Q.jsx)(pu,{eventId:t.eventId,relays:t.relays,authorHint:t.author,fallbackAuthorHint:e.pubkey,className:`my-2.5`},o);case`naddr-embed`:if(i){let e=P.naddrEncode({kind:t.addr.kind,pubkey:t.addr.pubkey,identifier:t.addr.identifier});return(0,Q.jsxs)(q,{to:`/${e}`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:[e.slice(0,16),`…`]},o)}return(0,Q.jsx)(uo,{addr:t.addr,className:`my-2.5`,sourceUrl:t.url},o);case`armada-invite`:return(0,Q.jsx)(no,{invite:t.invite},o);case`mention`:return(0,Q.jsx)(an,{pubkey:t.pubkey},o);case`nostr-link`:return(0,Q.jsx)(q,{to:`/${t.id}`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:t.raw},o);case`hashtag`:return(0,Q.jsx)(q,{to:`/t/${t.tag}`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:t.raw},o);case`relay-link`:return(0,Q.jsx)(q,{to:`/r/${encodeURIComponent(t.url)}`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:t.url},o);case`lightning-invoice`:return n?(0,Q.jsx)(`span`,{className:`text-primary break-all`,children:t.invoice},o):(0,Q.jsx)(zs,{invoice:t.invoice},o);case`blossom-uri`:return n||a?null:(0,Q.jsx)(rl,{children:(0,Q.jsx)(Ql,{uri:t.uri,raw:t.raw,artist:_,avatarUrl:g?.picture,avatarFallback:_[0]?.toUpperCase()??`?`,avatarShape:U(g)})},o)}}),x!==null&&!v.some((e,t)=>e.type===`image-gallery`&&x>=(D.get(t)??0)&&x<(D.get(t)??0)+e.urls.length)&&(0,Q.jsx)(Jc,{images:y,currentIndex:x,onClose:C,onNext:w,onPrev:T,mediaMeta:b})]})}function Xl({url:e,encryption:t,onClick:n}){let r=qt(e),i=Or(e,t),[a,o]=(0,Z.useState)(!1);return i.encrypted&&!i.src?(0,Q.jsx)(Er,{loading:i.loading,unsupported:i.unsupported,tooLarge:i.tooLarge,byteSize:i.byteSize,onDecryptAnyway:i.decryptAnyway}):(0,Q.jsx)(`button`,{type:`button`,className:`block my-2 rounded-lg overflow-hidden w-full cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:n,children:(0,Q.jsx)(`div`,{className:z(`relative w-full rounded-lg overflow-hidden`,!a&&`bg-muted`),style:a?void 0:{minHeight:200},children:(0,Q.jsx)(`img`,{src:i.encrypted?i.src:r.src,alt:``,className:`block w-full h-auto rounded-lg hover:opacity-90 transition-opacity`,loading:`lazy`,onLoad:()=>o(!0),onError:()=>{o(!0),i.encrypted||r.onError()},decoding:`async`})})})}function Zl({url:e,imeta:t,isAudio:n,authorMetadata:r,authorDisplayName:i}){return n?(0,Q.jsx)(oc,{src:e,mime:t?.mime,encryption:t?.encryption,avatarUrl:r?.picture,avatarFallback:i[0]?.toUpperCase()??`?`,avatarShape:U(r)}):(0,Q.jsx)(ac,{src:e,poster:t?.thumbnail,encryption:t?.encryption,dim:t?.dim,blurhash:t?.blurhash,artist:i})}function Ql({uri:e,raw:t,artist:n,avatarUrl:r,avatarFallback:i,avatarShape:a}){let{src:o,onError:s,failed:c}=wl(e),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p=ml(e.ext),m=p.startsWith(`image/`)?`image`:p.startsWith(`video/`)?`video`:p.startsWith(`audio/`)?`audio`:`file`;return!o||c?(0,Q.jsx)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline break-all`,onClick:e=>e.stopPropagation(),children:t}):m===`image`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`block my-2 rounded-lg overflow-hidden w-full cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:e=>{e.stopPropagation(),f(!0)},children:(0,Q.jsx)(`div`,{className:z(`relative w-full rounded-lg overflow-hidden`,!l&&`bg-muted`),style:l?void 0:{minHeight:200},children:(0,Q.jsx)(`img`,{src:o,alt:``,className:`block w-full h-auto rounded-lg hover:opacity-90 transition-opacity`,loading:`lazy`,onLoad:()=>u(!0),onError:()=>{u(!0),s()},decoding:`async`})})}),d&&(0,Q.jsx)(Jc,{images:[o],currentIndex:0,onClose:()=>f(!1),onNext:()=>{},onPrev:()=>{}})]}):m===`video`?(0,Q.jsx)(ac,{src:o,artist:n}):m===`audio`?(0,Q.jsx)(oc,{src:o,mime:p,avatarUrl:r,avatarFallback:i,avatarShape:a}):(0,Q.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 my-2 px-3 py-2 rounded-lg border bg-muted/40 hover:bg-muted text-primary break-all`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:`Blossom file`}),(0,Q.jsxs)(`span`,{className:`text-muted-foreground text-sm`,children:[e.sha256.slice(0,8),`…`,e.ext?`.${e.ext}`:``,typeof e.size==`number`?` · ${$l(e.size)}`:``]})]})}function $l(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&re===`a`)?.[1];if(!t)return;let[n,r,...i]=t.split(`:`),a=Number(n);if(!(!Number.isFinite(a)||!V(r)))return{kind:a,pubkey:r,identifier:i.join(`:`)}}function tu({event:e,className:t}){let n=(0,Z.useMemo)(()=>eu(e),[e]),{data:r}=Wn(n),i=(0,Z.useMemo)(()=>n?P.naddrEncode({kind:n.kind,pubkey:n.pubkey,identifier:n.identifier}):void 0,[n]);if(!n||!i)return null;let a=r?.tags.find(([e])=>e===`title`)?.[1]?.trim()||`a live stream`;return(0,Q.jsxs)(`div`,{className:t||`flex items-center gap-1.5 text-sm text-muted-foreground mt-2 mb-1 min-w-0 overflow-hidden`,children:[(0,Q.jsx)(he,{className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`shrink-0`,children:`in`}),(0,Q.jsx)(q,{to:`/${i}`,className:`text-primary hover:underline truncate`,onClick:e=>e.stopPropagation(),children:a})]})}function nu(e){let t=e.tags.find(([e,t])=>e===`i`&&typeof t==`string`&&t.startsWith(`bitcoin:tx:`));if(!t?.[1])return null;let n=t[1].slice(11).toLowerCase();return/^[0-9a-f]{64}$/.test(n)?n:null}function ru(e){let t=e.tags.find(([e])=>e===`amount`);if(!t?.[1])return 0;let n=parseInt(t[1],10);return Number.isFinite(n)&&n>0?n:0}function iu(e){let t=new Set,n=[];for(let r of e.tags){if(r[0]!==`p`)continue;let e=r[1];!e||!V(e)||t.has(e)||(t.add(e),n.push(e))}return n}async function au(e,t,n){let r=nu(e),i=iu(e);if(!r||i.length===0||i.includes(e.pubkey))return null;let{nostrPubkeyToBitcoinAddress:a}=await ze(async()=>{let{nostrPubkeyToBitcoinAddress:e}=await import(`./bitcoin-DQZnWjqL.js`).then(e=>e.t);return{nostrPubkeyToBitcoinAddress:e}},__vite__mapDeps([172,1,13,6,106,99,173])),o=new Set;for(let e of i){let t=a(e);t&&o.add(t)}if(o.size===0)return null;let s=a(e.pubkey),c;try{c=await ur(r,t,n)}catch{return null}let l=c.outputs.filter(e=>e.address!==s&&o.has(e.address??``)).reduce((e,t)=>e+t.value,0);if(l===0)return null;let u=ru(e),d=Math.min(u||l,l);return{event:e,txid:r,senderPubkey:e.pubkey,recipientPubkey:i[0],recipientPubkeys:i,amountSats:d,claimedAmountSats:u,comment:e.content,createdAt:e.created_at,confirmed:c.confirmed}}function ou(e){let{nostr:t}=He(),{config:n}=I(),{esploraApis:r}=n,i=e&&e.kind>=3e4&&e.kind<4e4,a=i?e.tags.find(([e])=>e===`d`)?.[1]??``:``,o=i&&e?`${e.kind}:${e.pubkey}:${a}`:``,s=F({queryKey:[`onchain-zaps`,`events`,e?.id??``,o],queryFn:async({signal:n})=>{if(!e)return[];let r=AbortSignal.timeout(5e3),i=AbortSignal.any([n,r]),a=[{kinds:[8333],"#e":[e.id],limit:100}];o&&a.push({kinds:[8333],"#a":[o],limit:100});let s=await t.query(a,{signal:i}),c=new Map;for(let e of s)c.set(e.id,e);let l=new Map;for(let e of c.values()){let t=nu(e);if(!t)continue;let n=l.get(t);(!n||e.created_at({queryKey:[`onchain-zaps`,`verify`,r,nu(e),iu(e).slice().sort().join(`,`)],queryFn:({signal:t})=>au(e,r,t),staleTime:6e4}))}),l=c.map(e=>e.data).filter(e=>!!e);l.sort((e,t)=>t.amountSats-e.amountSats);let u=l.reduce((e,t)=>e+t.amountSats,0),d=s.isLoading||c.some(e=>e.isLoading);return{zaps:l,totalSats:u,count:l.length,isLoading:d}}function su(e){let{config:t}=I(),{esploraApis:n}=t,r=e?nu(e):null,i=e?iu(e):[],{data:a}=F({queryKey:[`onchain-zaps`,`verify`,n,r,i.slice().sort().join(`,`)],queryFn:({signal:t})=>au(e,n,t),enabled:!!e&&!!r&&i.length>0,staleTime:6e4});return e?a:null}function cu(){let{config:e}=I(),t=e.currencyDisplay??`usd`,n=(0,Z.useRef)(!1),[r,i]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{n.current&&!r&&i(!0)});let{data:a}=F({queryKey:[`btc-price`,e.esploraApis],queryFn:({signal:t})=>dr(e.esploraApis,t),staleTime:6e4,retry:1,enabled:t===`usd`&&r,select:e=>Math.round(e/10)*10});return{format:(0,Z.useCallback)((e,r)=>{let i=r?.layout??`long`;return t===`usd`&&Number.isFinite(e)&&e>0&&(n.current=!0),t===`usd`&&a&&Number.isFinite(a)&&a>0?fr(e,a):i===`compact`?wr(e):`${wr(e)} ${e===1?`sat`:`sats`}`},[t,a]),currency:t,btcPrice:a}}function lu(e){let t=(0,Z.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}=Gn(n,r?[r]:void 0,i);return(0,Z.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])}var uu=(0,Z.lazy)(()=>ze(()=>import(`./BlobbiStateCard-BzIlF1sW.js`).then(e=>({default:e.BlobbiStateCard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,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,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171]))),du=62,fu=260;function pu(e){return(0,Q.jsx)(Re,{fallback:(0,Q.jsx)(Wr,{compact:!0,className:e.className}),sentryLevel:`error`,sentryTags:{errorBoundary:`embedded-note`,eventId:e.eventId},resetKeys:[e.eventId],children:(0,Q.jsx)(mu,{...e})})}function mu({eventId:e,relays:t,authorHint:n,fallbackAuthorHint:r,className:i,disableHoverCards:a,highlightText:o}){let s=n??r,{data:c,isLoading:l,isError:u}=Gn(e,t,s);return l?(0,Q.jsx)(Ou,{className:i}):u||!c?(0,Q.jsx)(Eu,{eventId:e,relays:t,authorHint:s,className:i}):c.kind===du?(0,Q.jsx)(Tu,{event:c,className:i}):c.kind===4?(0,Q.jsx)(Qr,{event:c,className:i}):c.kind===8211?(0,Q.jsx)(oi,{event:c,className:i}):c.kind===15683?(0,Q.jsx)(ji,{event:c,className:i}):nn(c)?(0,Q.jsx)(ho,{event:c,className:i}):c.kind===9735?(0,Q.jsx)(xu,{event:c,className:i,disableHoverCards:a}):c.kind===8333?(0,Q.jsx)(Su,{event:c,className:i,disableHoverCards:a}):c.kind===8?(0,Q.jsx)(bu,{event:c,className:i,disableHoverCards:a}):c.kind===9802?(0,Q.jsx)(gu,{event:c,className:i,disableHoverCards:a}):c.kind===1311?(0,Q.jsx)(hu,{event:c,className:i,disableHoverCards:a}):c.kind===31871?(0,Q.jsx)(Zi,{event:c,className:i,disableHoverCards:a}):c.kind===1984?(0,Q.jsx)(Ro,{event:c,className:i,disableHoverCards:a}):c.kind===7849?(0,Q.jsx)(_u,{event:c,className:i,disableHoverCards:a}):c.kind===1068?(0,Q.jsx)(vu,{event:c,className:i,disableHoverCards:a}):c.kind===1018?(0,Q.jsx)(yu,{event:c,className:i,disableHoverCards:a}):Sn.has(c.kind)?(0,Q.jsx)(qr,{event:c,className:i,disableHoverCards:a}):c.kind===38192?(0,Q.jsx)(Vi,{event:c,className:i,disableHoverCards:a}):c.kind===2256?(0,Q.jsx)(zo,{event:c,className:i,disableHoverCards:a}):qn(c.kind)?(0,Q.jsx)(Ni,{event:c,className:i,disableHoverCards:a}):c.kind===10002?(0,Q.jsx)(zi,{event:c,className:i,disableHoverCards:a}):c.kind===0?(0,Q.jsx)(Bi,{event:c,className:i,disableHoverCards:a}):c.kind===30402&&oa(c)?(0,Q.jsx)(sa,{event:c,className:i,disableHoverCards:a}):sr.has(c.kind)?(0,Q.jsx)(or,{event:c,className:i,disableHoverCards:a}):cr.has(c.kind)?(0,Q.jsx)(lr,{event:c,className:i,disableHoverCards:a}):(0,Q.jsx)(Cu,{event:c,className:i,disableHoverCards:a,highlightText:o})}function hu({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),i=e.content.trim();return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:r,className:t,disableHoverCards:n,children:[(0,Q.jsx)(tu,{event:e,className:`flex items-center gap-1.5 text-xs text-muted-foreground min-w-0 overflow-hidden`}),i?(0,Q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words line-clamp-4 text-foreground`,children:i}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`Live chat message`})]})}function gu({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),i=e.content.trim(),a=i.length>0;return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:r,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(m,{className:`size-3`}),`Highlight`]}),a?(0,Q.jsx)(`blockquote`,{className:`relative rounded-r-lg border-l-[3px] border-primary/70 bg-primary/5 pl-3 pr-2 py-2`,children:(0,Q.jsx)(`p`,{className:`font-serif text-[14px] leading-relaxed whitespace-pre-wrap break-words line-clamp-4 text-foreground`,children:i})}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`Highlighted media`})]})}function _u({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),i=(0,Z.useMemo)(()=>gr(e),[e]),a=i?i.outcomes.length>0?i.outcomes.map(e=>e.label).join(`, `):i.scores.map(e=>`${e.label??e.dimension}: ${e.value}`).join(` · `):void 0,o=i?.outcomes.find(e=>e.image)?.image;return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:r,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(Te,{className:`size-3`}),`Quiz result`]}),i?.comment&&(0,Q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words line-clamp-2 text-foreground`,children:i.comment}),o&&(0,Q.jsx)(`img`,{src:o,alt:``,loading:`lazy`,decoding:`async`,className:`max-h-32 w-full rounded-lg border object-cover`}),a?(0,Q.jsx)(`p`,{className:`text-base font-bold text-foreground line-clamp-2`,children:a}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`Took a quiz`})]})}function vu({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),i=(0,Z.useMemo)(()=>e.tags.filter(([e])=>e===`option`).map(([,,e])=>(e??``).trim()).filter(e=>e.length>0),[e.tags]),a=e.tags.find(([e])=>e===`polltype`)?.[1]??`singlechoice`,o=e.tags.find(([e])=>e===`endsAt`)?.[1],s=o?Number(o):void 0,c=typeof s==`number`&&Number.isFinite(s)&&s0&&(0,Q.jsx)(`div`,{className:`text-sm leading-relaxed font-medium break-words`,children:(0,Q.jsx)(Yl,{event:e,disableMediaEmbeds:!0,disableNoteEmbeds:!0})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,Q.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,Q.jsx)(Ae,{className:`size-3`}),a===`multiplechoice`?`Multiple choice`:`Poll`]}),c&&(0,Q.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,Q.jsx)(w,{className:`size-3`}),`Ended`]})]}),l.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[l.map((e,t)=>(0,Q.jsx)(`div`,{className:`rounded-md border border-border px-2.5 py-1.5 text-xs text-foreground bg-secondary/20 break-words line-clamp-1`,children:e},t)),u>0&&(0,Q.jsxs)(`p`,{className:`text-[11px] text-muted-foreground pl-1`,children:[`+`,u,` more option`,u===1?``:`s`]})]})]})}function yu({event:e,className:t,disableHoverCards:n}){let r=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),i=lu(e);return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:r,className:t,disableHoverCards:n,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,Q.jsx)(Ae,{className:`size-3`}),`Poll vote`]}),i?(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2 break-words`,children:i}):(0,Q.jsx)(`p`,{className:`text-xs italic text-muted-foreground`,children:`Voted`})]})}function bu({event:e,className:t,disableHoverCards:n}){let r=K(),i=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),a=(0,Z.useMemo)(()=>Qt(e),[e]),o=a&&a.pubkey===e.pubkey?a:void 0,{badgeMap:s}=rn((0,Z.useMemo)(()=>o?[o]:[],[o])),c=o?`${tn}:${o.pubkey}:${o.identifier}`:void 0,l=c?s.get(c):void 0,u=l?.name||(o?sn(o.identifier):`Badge`),d=R(e.pubkey),f=d.data?.metadata,p=f?.name||f?.display_name||`Anonymous`,m=J(e.pubkey,f);return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),r(`/${i}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r(`/${i}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2.5 flex items-center gap-2.5 min-w-0`,children:[l?(0,Q.jsx)(cn,{badge:l,size:36,className:`shrink-0`}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center size-9 rounded-lg bg-gradient-to-br from-primary/10 via-primary/5 to-transparent shrink-0`,children:(0,Q.jsx)(h,{className:`size-4 text-primary`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,Q.jsx)(Du,{pubkey:e.pubkey,disabled:n,children:(0,Q.jsx)(q,{to:m,className:`text-sm font-semibold truncate hover:underline`,onClick:e=>e.stopPropagation(),children:d.data?.event?(0,Q.jsx)(Xt,{tags:d.data.event.tags,children:p}):p})}),(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`awarded a badge`}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,Rn(e.created_at)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground truncate mt-0.5`,children:u})]})]})})}function xu({event:e,className:t,disableHoverCards:n}){let r=K(),i=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),a=(0,Z.useMemo)(()=>En(e),[e]),o=(0,Z.useMemo)(()=>Math.floor(On(e)/1e3),[e]),s=(0,Z.useMemo)(()=>wn(e),[e]),c=R(a||void 0),l=c.data?.metadata,u=l?.name||l?.display_name||(a?`Anonymous`:`Someone`),d=U(l),f=J(a,l),{format:p}=cu();return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),r(`/${i}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r(`/${i}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2.5 flex items-center gap-2.5 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-center size-9 rounded-full bg-amber-500/10 shrink-0`,children:(0,Q.jsx)(Ee,{className:`size-4 text-amber-500 fill-amber-500`})}),a&&(0,Q.jsx)(Du,{pubkey:a,disabled:n,children:(0,Q.jsx)(q,{to:f,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:d,className:`size-5`,children:[(0,Q.jsx)(W,{src:l?.picture,alt:u}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[10px]`,children:u[0]?.toUpperCase()})]})})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[a?(0,Q.jsx)(Du,{pubkey:a,disabled:n,children:(0,Q.jsx)(q,{to:f,className:`text-sm font-semibold truncate hover:underline`,onClick:e=>e.stopPropagation(),children:c.data?.event?(0,Q.jsx)(Xt,{tags:c.data.event.tags,children:u}):u})}):(0,Q.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:`Someone`}),(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`zapped`}),o>0&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-amber-500 shrink-0`,children:p(o)}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,Rn(e.created_at)]})]}),s&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic mt-0.5 line-clamp-2`,children:[`“`,s,`”`]})]})]})})}function Su({event:e,className:t,disableHoverCards:n}){let r=K(),i=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),a=e.pubkey,o=(0,Z.useMemo)(()=>ru(e),[e]),s=(0,Z.useMemo)(()=>iu(e),[e]),c=s.length>1,l=su(e),u=l?.amountSats??o,d=l===void 0,f=l===null,p=e.content,m=R(a),h=m.data?.metadata,g=h?.name||h?.display_name||`Anonymous`,_=U(h),v=J(a,h),{format:y}=cu();return(0,Q.jsx)(`div`,{className:z(`group block rounded-2xl border border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),r(`/${i}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r(`/${i}`))},children:(0,Q.jsxs)(`div`,{className:`px-3 py-2.5 flex items-center gap-2.5 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-center size-9 rounded-full bg-amber-500/10 shrink-0`,children:(0,Q.jsx)(Ee,{className:`size-4 text-amber-500 fill-amber-500`})}),(0,Q.jsx)(Du,{pubkey:a,disabled:n,children:(0,Q.jsx)(q,{to:v,className:`shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsxs)(G,{shape:_,className:`size-5`,children:[(0,Q.jsx)(W,{src:h?.picture,alt:g}),(0,Q.jsx)(H,{className:`bg-primary/20 text-primary text-[10px]`,children:g[0]?.toUpperCase()})]})})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,Q.jsx)(Du,{pubkey:a,disabled:n,children:(0,Q.jsx)(q,{to:v,className:`text-sm font-semibold truncate hover:underline`,onClick:e=>e.stopPropagation(),children:m.data?.event?(0,Q.jsx)(Xt,{tags:m.data.event.tags,children:g}):g})}),(0,Q.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`zapped`,c&&` ${s.length} people`]}),c&&(0,Q.jsx)(Uo,{pubkeys:s,size:`sm`,maxVisible:4,className:`shrink-0`}),u>0&&(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-amber-500 shrink-0`,children:y(u)}),f?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground shrink-0`,children:`· unverified`}):d?(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground shrink-0`,children:`· verifying…`}):null,(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:[`· `,Rn(e.created_at)]})]}),p&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic mt-0.5 line-clamp-2`,children:[`“`,p,`”`]})]})]})})}function Cu({event:e,className:n,disableHoverCards:i,highlightText:a}){let{config:o}=I(),s=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(!1),f=e.kind===31124,p=e.kind===20,m=e.kind===21||e.kind===22||e.kind===34236,h=e.kind===1||e.kind===11||e.kind===1111||p,g=(0,Z.useMemo)(()=>f?{imgs:0,vids:0,auds:0,apps:0,links:0,photos:0}:p?{imgs:0,vids:0,auds:0,apps:0,links:0,photos:e.tags.filter(([e])=>e===`imeta`).length}:{imgs:(e.content.match(new RegExp(cl.source,`gi`))||[]).length,vids:hl(e.content).length,auds:gl(e.content).length,apps:(e.content.match(/https?:\/\/[^\s]+\.xdc(\?[^\s]*)?/gi)||[]).length,links:(e.content.match(/https?:\/\/[^\s]+/g)||[]).filter(e=>!pl.test(e)).length,photos:0},[e.content,e.tags,p,f]),_=(0,Z.useMemo)(()=>kr(e.tags),[e.tags]),v=(0,Z.useMemo)(()=>{if(f)return{images:[]};if(p)return{images:Dr(e.tags).map(e=>L(e.url)).filter(e=>!!e)};if(m)return{images:[],video:Dr(e.tags).map(e=>L(e.url)).find(e=>!!e)};let t=(e.content.match(new RegExp(cl.source,`gi`))||[]).map(e=>L(e)).filter(e=>!!e),n=hl(e.content).map(e=>L(e)).filter(e=>!!e);return{images:t,video:t.length===0?n[0]:void 0}},[e.content,e.tags,p,f,m]),y=v.images.length>0||!!v.video,x=(0,Z.useMemo)(()=>{let t=yr(e.kind);if(t)return{label:t,Icon:_r(e.kind)}},[e.kind]),S=e.content.trim().length>0,C=(0,Z.useMemo)(()=>{if(h&&S||(p||m)&&y)return;let t=vr(e);if(t)return{title:t,description:void 0}},[h,S,p,m,y,e]),w=m&&y,T=!h&&!f&&!C&&!x&&!w,D=!h&&!f&&!C&&!!x&&!w,O=e.tags.find(([e])=>e===`content-warning`),ee=!!O;if(ee&&o.contentWarningPolicy===`hide`)return null;let k=y&&!f&&!C&&!T&&!D&&!(ee&&o.contentWarningPolicy===`blur`),A=!ee&&(g.photos>0||g.imgs>0||g.vids>0||g.auds>0||g.apps>0||g.links>0||x&&!D)||c;return(0,Q.jsxs)($,{pubkey:e.pubkey,createdAt:e.created_at,navigateTo:s,className:n,disableHoverCards:i,children:[ee&&o.contentWarningPolicy===`blur`?(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground italic`,children:[`Content warning`,O?.[1]?(0,Q.jsxs)(Q.Fragment,{children:[` `,`“`,O[1],`”`]}):``]}):f?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(X,{className:`h-24 w-full rounded-lg`}),children:(0,Q.jsx)(uu,{event:e})}):C?(0,Q.jsxs)(Q.Fragment,{children:[C.title&&(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2`,children:C.title}),C.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed line-clamp-3`,children:C.description})]}):D&&x?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-1 text-muted-foreground`,children:[x.Icon&&(0,Q.jsx)(x.Icon,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium capitalize`,children:x.label})]}):T?(0,Q.jsxs)(`p`,{className:`text-sm italic text-muted-foreground`,children:[`Kind `,e.kind,` · not supported`]}):(0,Q.jsxs)(Q.Fragment,{children:[m&&(()=>{let t=e.tags.find(([e])=>e===`title`)?.[1];return t?(0,Q.jsx)(`p`,{className:`text-sm font-semibold leading-snug line-clamp-2`,children:t}):null})(),(0,Q.jsx)(wu,{event:e,expanded:u,onOverflowChange:l,highlightText:a}),k&&(0,Q.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:v.images.length>0?(0,Q.jsx)(Wc,{images:v.images,maxVisible:4,maxGridHeight:`320px`,imetaMap:_,className:`mt-1.5`}):v.video?(0,Q.jsx)(`div`,{className:`mt-1.5 overflow-hidden rounded-2xl`,children:(0,Q.jsx)(ac,{src:v.video,poster:_.get(v.video)?.thumbnail,encryption:_.get(v.video)?.encryption,dim:_.get(v.video)?.dim,blurhash:_.get(v.video)?.blurhash})}):null})]}),A&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[x&&!D&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[x.Icon&&(0,Q.jsx)(x.Icon,{className:`size-3 shrink-0`}),x.label]}),g.photos>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(t,{className:`size-3`}),g.photos>1?`${g.photos} photos`:`Photo`]}),g.imgs>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(t,{className:`size-3`}),g.imgs>1?`${g.imgs} images`:`Image`]}),g.vids>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(re,{className:`size-3`}),g.vids>1?`${g.vids} videos`:`Video`]}),g.auds>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(E,{className:`size-3`}),g.auds>1?`${g.auds} audio files`:`Audio`]}),g.apps>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(r,{className:`size-3`}),`App`]}),g.links>0&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(b,{className:`size-3`}),g.links>1?`${g.links} links`:`Link`]}),c&&(0,Q.jsx)(`button`,{className:`ml-auto text-xs text-primary hover:underline shrink-0`,onClick:e=>{e.stopPropagation(),d(e=>!e)},children:u?`Show less`:`Read more`})]})]})}function wu({event:e,expanded:t,onOverflowChange:n,highlightText:r}){let i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(0),l=(0,Z.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.scrollHeight>fu;if(o(t),n(t),!t||!r){c(0);return}let a=e.querySelector(`mark`);if(!a){c(0);return}let s=e.getBoundingClientRect().top,l=a.getBoundingClientRect(),u=l.top-s,d=l.bottom-s;if(d<=fu){c(0);return}let f=d-u,p=f>=fu?u:u-(fu-f)/2,m=e.scrollHeight-fu;c(Math.max(0,Math.min(p,m)))},[n,r]);(0,Z.useEffect)(()=>(l(),window.addEventListener(`resize`,l),()=>window.removeEventListener(`resize`,l)),[l]),(0,Z.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.querySelectorAll(`img`);if(t.length!==0)return t.forEach(e=>e.addEventListener(`load`,l,{once:!0})),()=>t.forEach(e=>e.removeEventListener(`load`,l))},[l]);let u=!t&&a,d=u?s:0;return(0,Q.jsxs)(`div`,{className:`relative overflow-hidden`,style:u?{maxHeight:fu}:void 0,children:[(0,Q.jsx)(`div`,{style:d>0?{marginTop:-d}:void 0,children:(0,Q.jsx)(`div`,{ref:i,children:(0,Q.jsx)(Yl,{event:e,className:`text-sm leading-relaxed`,disableMediaEmbeds:!0,disableNoteEmbeds:!0,highlightText:r})})}),u&&d>0&&(0,Q.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-8 bg-gradient-to-b from-background to-transparent pointer-events-none`}),u&&(0,Q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-background to-transparent pointer-events-none`})]})}function Tu({event:e,className:t}){let n=K(),r=(0,Z.useMemo)(()=>P.neventEncode({id:e.id,author:e.pubkey}),[e.id,e.pubkey]);return(0,Q.jsx)(`div`,{className:z(`group cursor-pointer`,t),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),n(`/${r}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),n(`/${r}`))},children:(0,Q.jsx)(Jr,{event:e,timestamp:Rn(e.created_at),className:`rounded-2xl group-hover:border-red-500/50 transition-colors`})})}function Eu({eventId:e,relays:t,authorHint:n,className:r}){let i=K(),a=(0,Z.useMemo)(()=>P.neventEncode({id:e,...n?{author:n}:{},...t?.length?{relays:t}:{}}),[e,n,t]);return(0,Q.jsx)(`div`,{className:z(`rounded-2xl border border-dashed border-border overflow-hidden`,`hover:bg-secondary/40 transition-colors cursor-pointer`,r),role:`link`,tabIndex:0,onClick:e=>{e.stopPropagation(),i(`/${a}`)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),i(`/${a}`))},children:(0,Q.jsxs)(`div`,{className:`px-3.5 py-4 flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(Oe,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`This post could not be loaded`})]})})}function Du({pubkey:e,disabled:t,children:n}){return t?(0,Q.jsx)(Q.Fragment,{children:n}):(0,Q.jsx)(Y,{pubkey:e,asChild:!0,children:n})}function Ou({className:e}){return(0,Q.jsx)(`div`,{className:z(`rounded-2xl border border-border overflow-hidden`,e),children:(0,Q.jsxs)(`div`,{className:`px-3.5 py-2.5 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(X,{className:`size-5 rounded-full`}),(0,Q.jsx)(X,{className:`h-3.5 w-24`}),(0,Q.jsx)(X,{className:`h-3 w-10`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(X,{className:`h-3.5 w-full`}),(0,Q.jsx)(X,{className:`h-3.5 w-4/5`})]})]})})}export{uo as $,_c as A,Ts as B,tl as C,Hr as Ct,Uc as D,Jc as E,tc as F,Ss as G,gs as H,ec as I,Yo as J,ms as K,$s as L,oc as M,ac as N,Bc as O,nc as P,No as Q,Qs as R,rl as S,Ur as St,qc as T,Rr as Tt,Cs as U,ws as V,xs as W,Lo as X,Uo as Y,Eo as Z,fl as _,ai as _t,iu as a,la as at,hl as b,Yr as bt,tu as c,ra as ct,Fl as d,Hi as dt,ao as et,xl as f,Li as ft,sl as g,pi as gt,yl as h,li as ht,ru as i,fa as it,cc as j,Lc as k,Yl as l,oa as lt,Cl as m,si as mt,lu as n,no as nt,ou as o,Qi as ot,bl as p,Ai as pt,$o as q,cu as r,Sa as rt,su as s,aa as st,pu as t,oo as tt,Ml as u,Xi as ut,pl as v,Zr as vt,Wc as w,Br as wt,ml as x,Wr as xt,gl as y,Jr as yt,Fs as z}; // @license-end