// @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/EmojiPackDialog-Bs3LIBnO.js","assets/rolldown-runtime-QTnfLwEv.js","assets/lucide-icons-BdRF0moN.js","assets/jsx-runtime-By8HlURe.js","assets/dist-DQ82bf9M.js","assets/esm-CRVqHnq2.js","assets/sha256-Cx9u8cje.js","assets/useQuery-rCAlChE8.js","assets/fetchFreshEvent-Kkz3MzZN.js","assets/useCurrentUser-C6OJJlWo.js","assets/preload-helper-CZgWQFsJ.js","assets/dist-DQ_zK-Nr.js","assets/utils-BFSTDHdM.js","assets/button-Cs26nq0r.js","assets/dist-CrweAx5r.js","assets/dist-BI-be9Ir.js","assets/dist-DEYuuXMO.js","assets/useNostrPublish-CrMjnYm4.js","assets/useMutation-CgsR0O-3.js","assets/useAppContext-Ughdk2-Z.js","assets/CustomEmoji-DRcU63lJ.js","assets/useBlossomFallback-DY_46Uqi.js","assets/sanitizeUrl-Bk5f35GN.js","assets/appBlossom-CsMDSd4h.js","assets/customEmoji-kpim4Htm.js","assets/input-CM5Fnyvy.js","assets/useUploadFile-BpPXwoE0.js","assets/dialog-C3CFmras.js","assets/dist-DW2GM_Ig.js","assets/react-dom-YCZzGcHh.js","assets/dist-Bz2abD7M.js","assets/dist-BMrfXngQ.js","assets/dist-D9YQw-T8.js","assets/dist-DTSySAaw.js","assets/dist-CxcvWxxD.js","assets/dist-CpRh64jj.js","assets/dist-CX38Lmo0.js","assets/dist-BeEGgqo9.js","assets/Combination-C1QBaE03.js","assets/textarea-B93xm6Zg.js","assets/label-BBIj2Nkw.js","assets/checkbox-CM1MZiSJ.js","assets/dist-wmZSqlsD.js","assets/dist-DjUhKbpW.js","assets/scroll-area-D2CmkWvj.js","assets/dist-B2RAV5d5.js","assets/dist-C2J943E6.js"])))=>i.map(i=>d[i]); import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$ as t,Bt as n,F as r,_n as i,qi as a}from"./lucide-icons-BdRF0moN.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{t as s}from"./preload-helper-CZgWQFsJ.js";import{t as c}from"./dist-DQ82bf9M.js";import{t as l}from"./useInfiniteQuery-BFtb_-3K.js";import{t as u}from"./useAppContext-Ughdk2-Z.js";import{s as d,t as f}from"./useCurrentUser-C6OJJlWo.js";import{t as p}from"./button-Cs26nq0r.js";import{n as m}from"./useFollowActions-cve70R08.js";import{t as h}from"./CustomEmoji-DRcU63lJ.js";import{t as g}from"./FallbackImage-Dlnc8809.js";import{t as _}from"./skeleton-CVls4GW9.js";import{s as v}from"./extraKinds-BydAXtVV.js";import{g as y}from"./sidebarItems-BFr7FKBa.js";import{n as b,t as x}from"./card-CthSADjg.js";import{c as S}from"./LayoutContext-CjQBLGO-.js";import{r as C}from"./NoteCard-COwLfrJJ.js";import{t as w}from"./SubHeaderBar-BYwNp4Nc.js";import{t as T}from"./usePageRefresh-BuJEOs2u.js";import{t as E}from"./useMutedAuthorFilter-CTggZCaG.js";import{C as D,S as O,o as k,w as A,x as j}from"./index-CYEZWNq6.js";import{t as M}from"./PageHeader-CMi4aeE4.js";import{t as N}from"./useInfiniteScroll-BXunlzay.js";import{t as P}from"./deduplicateEvents-BUUuuRQu.js";import{t as F}from"./KindInfoButton-BL9_-Fdi.js";import{a as I,d as L,i as R,l as z,o as B,t as V,u as H}from"./useEmojiPacks-NxGstnl1.js";var U=e(a(),1),W=o(),G=(0,U.lazy)(()=>s(()=>import(`./EmojiPackDialog-Bs3LIBnO.js`).then(e=>({default:e.EmojiPackDialog})),__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]))),K=10;function q(e){return e.split(`:`)[1]??``}function J(){let{user:e}=f(),n=H(),r=z(),[i,a]=(0,U.useState)(null),o=(0,U.useMemo)(()=>(r.data??[]).filter(t=>q(t.coord)!==e?.pubkey),[r.data,e?.pubkey]);if(!e)return(0,W.jsx)(x,{className:`border-dashed mx-4 my-6`,children:(0,W.jsx)(b,{className:`py-12 px-8 text-center`,children:(0,W.jsx)(`p`,{className:`text-muted-foreground max-w-sm mx-auto`,children:`Log in to create emoji packs and manage your collection.`})})});if(n.isLoading&&!n.data||r.isLoading&&!r.data)return(0,W.jsx)(`div`,{className:`px-4 py-4 space-y-3`,children:Array.from({length:3}).map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(_,{className:`size-10 rounded-lg shrink-0`}),(0,W.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,W.jsx)(_,{className:`h-4 w-32`}),(0,W.jsx)(_,{className:`h-5 w-40`})]})]},t))});let s=n.data??[];return s.length===0&&o.length===0?(0,W.jsx)(x,{className:`border-dashed mx-4 my-6`,children:(0,W.jsxs)(b,{className:`py-12 px-8 text-center space-y-1`,children:[(0,W.jsx)(t,{className:`size-8 mx-auto text-muted-foreground/60`}),(0,W.jsx)(`p`,{className:`text-muted-foreground max-w-sm mx-auto`,children:`No emoji packs yet. Browse the Global tab and tap Add on a pack, or create your own with the + button.`})]})}):(0,W.jsxs)(W.Fragment,{children:[s.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.jsx)(Y,{title:`Published`,count:s.length}),(0,W.jsx)(`div`,{className:`divide-y divide-border`,children:s.map(e=>(0,W.jsx)(X,{pack:e,mode:`published`,onEdit:a},e.coord))})]}),o.length>0&&(0,W.jsxs)(`section`,{children:[(0,W.jsx)(Y,{title:`Added`,count:o.length}),(0,W.jsx)(`div`,{className:`divide-y divide-border`,children:o.map(e=>(0,W.jsx)(X,{pack:e,mode:`added`},e.coord))})]}),i&&(0,W.jsx)(U.Suspense,{fallback:null,children:(0,W.jsx)(G,{open:!!i,onOpenChange:e=>!e&&a(null),editEvent:i})})]})}function Y({title:e,count:t}){return(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-4 pb-1.5`,children:[(0,W.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground/70 tabular-nums`,children:t})]})}function X({pack:e,mode:a,onEdit:o}){let{mutateAsync:s,isPending:c}=L(),{toast:l}=d(),[u,f]=(0,U.useState)(!1),m=e.event?I(e.event):e.coord.split(`:`)[2]||`Emoji pack`,_=e.event?B(e.event):void 0,v=e.event?R(e.event):[],y=v.slice(0,K),b=v.length-y.length;return u?null:(0,W.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3`,children:[(0,W.jsx)(g,{src:_,className:`size-10 shrink-0 rounded-lg object-cover border border-border`,decoding:`async`,fallback:(0,W.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-secondary text-primary`,children:(0,W.jsx)(t,{className:`size-5`})})}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,W.jsx)(`div`,{className:`text-sm font-semibold leading-tight truncate`,children:m}),y.length>0?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[y.map(e=>(0,W.jsx)(h,{name:e.shortcode,url:e.url,className:`size-6 object-contain`},e.shortcode)),b>0&&(0,W.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`+`,b]})]}):(0,W.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.event?`This pack has no emojis.`:`Pack details couldn’t be loaded.`})]}),a===`published`?(0,W.jsx)(p,{variant:`ghost`,size:`icon`,className:`size-9 shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>e.event&&o?.(e.event),disabled:!e.event,"aria-label":`Edit ${m}`,children:(0,W.jsx)(n,{className:`size-4`})}):(0,W.jsx)(p,{variant:`ghost`,size:`icon`,className:`size-9 shrink-0 text-muted-foreground hover:text-destructive`,onClick:async()=>{try{await s({coord:e.coord}),f(!0),l({title:`Emoji pack removed`,description:m})}catch(e){l({title:`Couldn't remove pack`,description:e instanceof Error?e.message:`Publishing failed.`,variant:`destructive`})}},disabled:c,"aria-label":`Remove ${m}`,children:c?(0,W.jsx)(i,{className:`size-4 animate-spin`}):(0,W.jsx)(r,{className:`size-4`})})]})}var Z=20;function Q(e){return e.tags.some(([e,t,n])=>e===`emoji`&&t&&n)}function ee(e=`global`){let{nostr:t}=c(),{user:n}=f(),{data:r}=m(),i=r?.pubkeys,{excludeMuted:a,mutedKey:o}=E(),s=e!==`follows`||!!n&&i!==void 0;return l({queryKey:[`emoji-pack-feed`,e,n?.pubkey??``,o],queryFn:async({pageParam:r})=>{let o=AbortSignal.timeout(5e3),s=r,c;if(e===`follows`&&n&&i){let e=a(i);c=e.length>0?[...e,n.pubkey]:[n.pubkey]}let l=await t.query([{kinds:[V],limit:Z,...s?{until:s}:{},...c?{authors:c}:{}}],{signal:o}),u=new Set;return l.filter(e=>u.has(e.id)||!Q(e)?!1:(u.add(e.id),!0)).sort((e,t)=>t.created_at-e.created_at).slice(0,Z)},getNextPageParam:e=>{if(e.length!==0)return e[e.length-1].created_at-1},initialPageParam:void 0,enabled:s,staleTime:120*1e3})}var te=(0,U.lazy)(()=>s(()=>import(`./EmojiPackDialog-Bs3LIBnO.js`).then(e=>({default:e.EmojiPackDialog})),__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]))),$=v(`emojis`);function ne(){let{config:e}=u(),{user:t}=f(),[n,r]=j(`emojis`,[`my-packs`,`follows`,`global`]),[a,o]=(0,U.useState)(!1);A({title:`${$.label} | ${e.appName}`,description:`Browse, collect, and create custom emoji packs`});let s=(0,U.useCallback)(()=>o(!0),[]);S({showFAB:n===`my-packs`,fabKind:$.kind,onFabClick:s,hasSubHeader:!0});let c=n===`follows`?`follows`:`global`,{data:l,isPending:d,isLoading:p,fetchNextPage:m,hasNextPage:h,isFetchingNextPage:g}=ee(c),{scrollRef:_}=N({hasNextPage:h,isFetchingNextPage:g,fetchNextPage:m,pageCount:l?.pages?.length,enabled:n!==`my-packs`}),v=P(l?.pages),b=T([`emoji-pack-feed`,c]),x=n!==`my-packs`&&(d||p&&!l),E=y(`emojis`,`size-5`);return(0,W.jsxs)(`main`,{className:`pb-16 sidebar:pb-0`,children:[(0,W.jsx)(M,{title:$.label,icon:E,backTo:`/`,children:(0,W.jsx)(F,{kindDef:$,icon:E})}),(0,W.jsxs)(w,{children:[(0,W.jsx)(k,{label:`My Packs`,active:n===`my-packs`,onClick:()=>r(`my-packs`)}),(0,W.jsx)(k,{label:`Follows`,active:n===`follows`,onClick:()=>r(`follows`),disabled:!t}),(0,W.jsx)(k,{label:`Global`,active:n===`global`,onClick:()=>r(`global`)})]}),(0,W.jsx)(`div`,{style:{height:20}}),n===`my-packs`?(0,W.jsx)(J,{}):(0,W.jsx)(D,{onRefresh:b,children:x?(0,W.jsx)(`div`,{className:`divide-y divide-border`,children:Array.from({length:5}).map((e,t)=>(0,W.jsx)(re,{},t))}):v.length>0?(0,W.jsxs)(`div`,{children:[v.map(e=>(0,W.jsx)(C,{event:e},e.id)),h&&(0,W.jsx)(`div`,{ref:_,className:`py-4`,children:g&&(0,W.jsx)(`div`,{className:`flex justify-center`,children:(0,W.jsx)(i,{className:`size-5 animate-spin text-muted-foreground`})})})]}):(0,W.jsx)(O,{message:n===`follows`?`No emoji packs from people you follow yet.`:`No emoji packs found. Be the first to share one!`,onSwitchToGlobal:n===`follows`?()=>r(`global`):void 0})}),a&&(0,W.jsx)(U.Suspense,{fallback:null,children:(0,W.jsx)(te,{open:a,onOpenChange:o})})]})}function re(){return(0,W.jsxs)(`div`,{className:`px-4 py-3 border-b border-border`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(_,{className:`size-12 rounded-lg shrink-0`}),(0,W.jsxs)(`div`,{className:`min-w-0 space-y-1.5`,children:[(0,W.jsx)(_,{className:`h-4 w-32`}),(0,W.jsx)(_,{className:`h-3 w-40`})]})]}),(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:Array.from({length:8}).map((e,t)=>(0,W.jsx)(_,{className:`size-8 rounded`},t))})]})}export{ne as EmojiPacksPage}; // @license-end