const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmojiPicker-Bj-YkY3r.js","assets/rolldown-runtime-QTnfLwEv.js","assets/lucide-icons-BjbcRgLk.js","assets/jsx-runtime-By8HlURe.js","assets/useTheme-DAiZ1C6g.js","assets/useQuery-CQCUTxAw.js","assets/useAppContext-ZpOJAKgd.js","assets/useEncryptedSettings-Mj6Bzp-m.js","assets/dist-DPmmj29U.js","assets/esm-CRVqHnq2.js","assets/sha256-Cx9u8cje.js","assets/useMutation-Du3NQIud.js","assets/fetchFreshEvent-Kkz3MzZN.js","assets/useCurrentUser-boOMG5Xx.js","assets/preload-helper-CZgWQFsJ.js","assets/dist-DQ_zK-Nr.js","assets/fontLoader-B9KxicFi.js","assets/sanitizeUrl-Bk5f35GN.js","assets/useNostrPublish-D1pQ9KV-.js","assets/useIsMobile-brkrNavj.js","assets/native-GDBYL4Zp.js"])))=>i.map(i=>d[i]); import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Kr as t,N as n,Nt as r,Ot as i,Sn as a,Y as o,a as s,gi as c,ki as l,zr as u}from"./lucide-icons-BjbcRgLk.js";import{t as d}from"./jsx-runtime-By8HlURe.js";import{t as f}from"./preload-helper-CZgWQFsJ.js";import{u as p}from"./esm-CRVqHnq2.js";import{r as ee}from"./sanitizeUrl-Bk5f35GN.js";import{t as te}from"./useCurrentUser-boOMG5Xx.js";import{t as m}from"./utils-BFSTDHdM.js";import{t as h}from"./button-PfnADMEc.js";import{a as ne,c as re,l as ie,n as g,r as _,t as v,u as y}from"./avatar-BQAt2c6L.js";import{n as b}from"./chunk-62JRHF6Z-BC2Zeguv.js";import{S as ae,i as x,o as S,t as C,x as oe,y as w}from"./BioContent-DDUa8M5F.js";import{t as se}from"./ExternalFavicon-C4RKLGFC.js";import{t as T}from"./input-CspJi8Oq.js";import{n as ce,r as le,t as ue}from"./collapsible-D6IpicA3.js";import{a as de,n as fe,r as E,t as pe}from"./dropdown-menu-DFQx4ARb.js";import{n as me,r as he,t as ge}from"./popover-CpFQm40Y.js";import{t as D}from"./skeleton-CVls4GW9.js";var O=e(l(),1),k=d();function _e({items:e,maxVisible:t=12,thumbnailSize:n=48,showNames:i=!0,showEditButton:a,editPath:o=`/badges`,isLoading:s,gridCols:l=`grid-cols-4 sm:grid-cols-6`,className:u}){if(s)return(0,k.jsx)(`div`,{className:m(`grid gap-3`,l,u),children:Array.from({length:4}).map((e,t)=>(0,k.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,k.jsx)(D,{className:`rounded-lg`,style:{width:n,height:n}}),i&&(0,k.jsx)(D,{className:`h-3 w-12`})]},t))});if(e.length===0)return null;let d=e.slice(0,t),f=Math.max(0,e.length-t);return(0,k.jsxs)(`div`,{className:m(`space-y-2`,u),children:[(0,k.jsxs)(`div`,{className:m(`grid gap-3`,l),children:[d.map(e=>(0,k.jsxs)(b,{to:`/${p.naddrEncode({kind:30009,pubkey:e.pubkey,identifier:e.identifier})}`,className:`flex flex-col items-center gap-1.5 group`,title:e.badge?.description||e.badge?.name||e.identifier,onClick:e=>e.stopPropagation(),children:[e.badge?(0,k.jsx)(w,{badge:e.badge,size:n}):(0,k.jsx)(`div`,{className:`rounded-lg border border-border bg-background flex items-center justify-center`,style:{width:n,height:n},children:(0,k.jsx)(c,{className:`size-6 text-muted-foreground`})}),i&&(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground text-center leading-tight line-clamp-2 max-w-[4.5rem] group-hover:text-foreground transition-colors`,children:e.badge?.name||e.identifier})]},e.aTag)),f>0&&(0,k.jsx)(`div`,{className:`flex flex-col items-center justify-center gap-1.5`,children:(0,k.jsxs)(`div`,{className:`rounded-lg bg-muted flex items-center justify-center text-muted-foreground text-xs font-medium`,style:{width:n,height:n},children:[`+`,f]})})]}),a&&o&&(0,k.jsx)(`div`,{className:`flex justify-end`,children:(0,k.jsx)(h,{variant:`ghost`,size:`sm`,className:`h-7 text-xs gap-1 text-muted-foreground`,asChild:!0,children:(0,k.jsxs)(b,{to:o,children:[(0,k.jsx)(r,{className:`size-3`}),`Edit Badges`]})})})]})}var A=(0,O.lazy)(()=>f(()=>import(`./EmojiPicker-Bj-YkY3r.js`).then(e=>({default:e.EmojiPicker})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))),j=[`rounded-lg px-2`,`border-2 border-transparent`,`bg-muted/40`,`hover:bg-muted/60 hover:border-border`,`focus:bg-transparent focus:border-primary`,`transition-colors duration-150`,`placeholder:text-muted-foreground/40`,`outline-none`].join(` `);function M({value:e,placeholder:t,onChange:n,className:r}){return(0,k.jsx)(`input`,{type:`text`,value:e,placeholder:t,onChange:e=>n(e.target.value),className:m(j,`w-full min-w-0 py-0.5`,r)})}function N({value:e,placeholder:t,onChange:n,className:r}){return(0,k.jsx)(`textarea`,{value:e,placeholder:t,onChange:e=>{n(e.target.value),e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},onFocus:e=>{e.target.style.height=`auto`,e.target.style.height=e.target.scrollHeight+`px`},rows:1,className:m(j,`w-full min-w-0 py-1 resize-none overflow-hidden text-base md:text-sm text-muted-foreground leading-relaxed`,r)})}function P({pubkey:e,metadata:c,onChange:l,onPickImage:d,onAvatarShape:f,onRemoveAvatar:p,showNip05:b=!0,extraFields:w,onExtraFieldsChange:D}){let P=!!l,[F,I]=(0,O.useState)(!1),[ve,ye]=(0,O.useState)(!1),[be,L]=(0,O.useState)(!1),{user:R}=te(),xe=!!e&&!!R&&e===R.pubkey,{refs:z,isLoading:B}=S(e),{badgeMap:Se,isLoading:Ce}=x(z),V=c.name||c.display_name||`Anonymous`,H=V[0]?.toUpperCase()??`?`,U=e=>t=>l?.({[e]:t}),W=ee(c.banner),G=c.shape,K=ie(G)?G:void 0,q=!!K&&re(K),[J,Y]=(0,O.useState)(``);(0,O.useEffect)(()=>{if(!q||!K){Y(``);return}let e=!1;return ne(K).then(t=>{e||Y(t)}),()=>{e=!0}},[q,K]);let we=(0,O.useMemo)(()=>{if(J)return{WebkitMaskImage:`url(${J})`,maskImage:`url(${J})`,WebkitMaskSize:`contain`,maskSize:`contain`,WebkitMaskRepeat:`no-repeat`,maskRepeat:`no-repeat`,WebkitMaskPosition:`center`,maskPosition:`center`}},[J]),X=c.nip05,Z=X?ae(X):void 0,Q=()=>D?.([...w??[],{label:``,value:``}]),Te=e=>D?.((w??[]).filter((t,n)=>n!==e)),$=(e,t,n)=>D?.((w??[]).map((r,i)=>i===e?{...r,[t]:n}:r));return(0,k.jsxs)(`div`,{className:`bg-card border rounded-xl overflow-hidden`,children:[(0,k.jsxs)(`div`,{className:m(`relative h-36 bg-secondary`,P&&`cursor-pointer group`),style:W?{backgroundImage:`url("${W}")`,backgroundSize:`cover`,backgroundPosition:`center`}:void 0,onClick:()=>P&&d?.(`banner`),children:[!c.banner&&(0,k.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-accent/10 via-transparent to-primary/5`}),P&&!c.banner&&(0,k.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,k.jsx)(i,{className:`size-6 text-muted-foreground`,strokeWidth:4})}),P&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center`,children:(0,k.jsxs)(`span`,{className:`opacity-0 group-hover:opacity-100 transition-opacity flex items-center gap-1.5 text-white text-xs font-medium bg-black/50 rounded-full px-3 py-1.5 backdrop-blur-sm`,children:[(0,k.jsx)(r,{className:`size-3.5`}),` `,c.banner?`Change banner`:`Add banner`]})}),c.banner&&(0,k.jsx)(`div`,{className:`absolute bottom-2 right-2 size-7 rounded-full bg-background border border-border shadow-sm flex items-center justify-center transition-opacity`,children:(0,k.jsx)(r,{className:`size-3.5 text-muted-foreground`})})]})]}),(0,k.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,k.jsx)(`div`,{className:`flex justify-between items-start -mt-12 mb-3`,children:P?(0,k.jsxs)(ge,{open:be,onOpenChange:L,children:[(0,k.jsx)(me,{asChild:!0,children:(0,k.jsx)(`div`,{className:`shrink-0`,children:(0,k.jsxs)(pe,{children:[(0,k.jsx)(de,{asChild:!0,children:(0,k.jsxs)(`button`,{type:`button`,className:`relative shrink-0 cursor-pointer group outline-none`,children:[(0,k.jsx)(`div`,{style:q?y:void 0,children:(0,k.jsxs)(v,{shape:K,className:m(`shadow-sm`,q?`size-[88px]`:`size-24 border-4 border-background`),children:[(0,k.jsx)(_,{src:c.picture,alt:V,className:`object-cover`}),(0,k.jsx)(g,{className:`bg-primary/20 text-primary text-2xl font-bold`,children:c.picture?H:(0,k.jsx)(i,{className:`size-8 text-muted-foreground`,strokeWidth:4})})]})}),(0,k.jsx)(`div`,{className:m(`absolute inset-0 bg-black/0 group-hover:bg-black/45 transition-colors flex items-center justify-center`,!q&&`rounded-full`),style:we,children:(0,k.jsx)(r,{className:`size-6 text-white opacity-0 group-hover:opacity-100 transition-opacity drop-shadow`})}),c.picture&&(0,k.jsx)(`div`,{className:`absolute bottom-0 right-0 size-7 rounded-full bg-background border border-border shadow-sm flex items-center justify-center transition-opacity`,children:(0,k.jsx)(r,{className:`size-3.5 text-muted-foreground`})})]})}),(0,k.jsxs)(fe,{align:`start`,sideOffset:6,children:[(0,k.jsxs)(E,{onClick:()=>d?.(`picture`),children:[(0,k.jsx)(a,{className:`size-4 mr-2`}),`Change avatar`]}),(0,k.jsxs)(E,{onClick:()=>setTimeout(()=>L(!0),0),children:[(0,k.jsx)(o,{className:`size-4 mr-2`}),`Set avatar shape`]}),c.picture&&(0,k.jsxs)(E,{onClick:()=>p?.(),className:`text-destructive focus:text-destructive`,children:[(0,k.jsx)(s,{className:`size-4 mr-2`}),`Remove avatar`]})]})]})})}),(0,k.jsxs)(he,{align:`start`,sideOffset:8,className:`w-[340px] max-w-[calc(100vw-2rem)] p-0 overflow-hidden`,onOpenAutoFocus:e=>e.preventDefault(),onFocusOutside:e=>e.preventDefault(),children:[(0,k.jsx)(O.Suspense,{fallback:(0,k.jsx)(`div`,{className:`h-[360px] flex items-center justify-center text-sm text-muted-foreground`,children:`Loading…`}),children:(0,k.jsx)(A,{height:360,onSelect:e=>{e.type===`native`&&(f?.(e.emoji),L(!1))}})}),q&&(0,k.jsx)(`div`,{className:`p-2 border-t`,children:(0,k.jsxs)(h,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{f?.(``),L(!1)},children:[(0,k.jsx)(s,{className:`size-3.5 mr-1.5`}),`Remove avatar shape`]})})]})]}):(0,k.jsx)(`div`,{className:`relative shrink-0`,style:q?y:void 0,children:(0,k.jsxs)(v,{shape:K,className:m(`shadow-sm`,q?`size-[88px]`:`size-24 border-4 border-background`),children:[(0,k.jsx)(_,{src:c.picture,alt:V,className:`object-cover`}),(0,k.jsx)(g,{className:`bg-primary/20 text-primary text-2xl font-bold`,children:H})]})})}),P?(0,k.jsx)(M,{value:c.name??``,placeholder:`Your name`,onChange:U(`name`),className:`text-xl font-bold`}):(0,k.jsx)(`h2`,{className:`text-xl font-bold truncate`,children:V}),b&&(P||X)&&(0,k.jsxs)(`div`,{className:`flex items-center gap-1 mt-2 min-w-0 text-sm text-muted-foreground ml-2`,children:[(0,k.jsx)(u,{className:`size-3.5 text-primary shrink-0`}),P&&F?(0,k.jsx)(`input`,{type:`text`,value:X??``,placeholder:`you@domain.com`,autoFocus:!0,onChange:e=>U(`nip05`)(e.target.value),onBlur:()=>I(!1),size:Math.max((X?.length??0)+1,4),className:m(j,`py-0.5 h-6 text-base md:text-sm text-muted-foreground border-primary bg-transparent`)}):(0,k.jsxs)(`span`,{className:m(`inline-flex items-center gap-1 min-w-0`,P&&m(j,`py-0.5 h-6 cursor-text`)),onClick:()=>P&&I(!0),children:[(0,k.jsx)(`span`,{className:`shrink min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:X?oe(X):P?`you@domain.com`:``}),Z&&(0,k.jsx)(se,{url:`https://${Z}`,size:14,className:`shrink-0`})]})]}),(0,k.jsx)(`div`,{className:`mt-2`,children:P?(0,k.jsx)(N,{value:c.about??``,placeholder:`Write a short bio…`,onChange:U(`about`)}):c.about?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap`,children:(0,k.jsx)(C,{children:c.about})}):null}),w!==void 0&&(0,k.jsxs)(ue,{open:ve,onOpenChange:ye,className:`mt-3`,children:[(0,k.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,k.jsx)(le,{asChild:!0,children:(0,k.jsxs)(h,{type:`button`,variant:`ghost`,className:`w-full justify-between px-0 h-auto hover:bg-transparent text-sm font-medium text-muted-foreground`,children:[`Profile Fields`,(0,k.jsx)(t,{className:`size-4 transition-transform duration-200 [[data-state=open]_&]:rotate-180`,strokeWidth:4})]})})}),(0,k.jsxs)(ce,{className:`space-y-2 pt-2`,children:[(0,k.jsxs)(`div`,{className:`grid grid-cols-[1fr,2fr] gap-2 items-center`,children:[(0,k.jsx)(`span`,{className:`text-sm text-muted-foreground px-1`,children:`Website`}),(0,k.jsx)(T,{placeholder:`https://yourwebsite.com`,value:c.website??``,onChange:e=>U(`website`)(e.target.value),className:`h-8 text-base md:text-sm`})]}),w.map((e,t)=>(0,k.jsxs)(`div`,{className:`grid grid-cols-[1fr,2fr,auto] gap-2 items-center`,children:[(0,k.jsx)(T,{placeholder:`Label`,value:e.label,onChange:e=>$(t,`label`,e.target.value),className:`h-8 text-base md:text-sm`}),(0,k.jsx)(T,{placeholder:`Value or URL`,value:e.value,onChange:e=>$(t,`value`,e.target.value),className:`h-8 text-base md:text-sm`}),(0,k.jsx)(h,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>Te(t),className:`h-8 w-8 text-destructive hover:text-destructive`,children:(0,k.jsx)(n,{className:`size-3.5`})})]},t)),(0,k.jsxs)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:Q,className:`w-full h-8 text-xs`,children:[(0,k.jsx)(i,{className:`size-3 mr-1`,strokeWidth:4}),` Add Field`]})]})]})]}),(z.length>0||B)&&(0,k.jsx)(`div`,{className:`px-4 pb-3`,children:(0,k.jsx)(_e,{items:z.map(e=>({aTag:e.aTag,pubkey:e.pubkey,identifier:e.identifier,badge:Se.get(e.aTag)})),maxVisible:8,thumbnailSize:44,showEditButton:xe,isLoading:B||Ce,gridCols:`grid-cols-4 sm:grid-cols-5`})})]})}export{P as t};