// @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
import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{N as n,_n as r,qi as i}from"./lucide-icons-BdRF0moN.js";import{t as a}from"./jsx-runtime-By8HlURe.js";import{t as o}from"./dist-DQ82bf9M.js";import{t as s}from"./useMutation-CgsR0O-3.js";import{t as c}from"./useAppContext-Ughdk2-Z.js";import{o as l,t as u}from"./useCurrentUser-C6OJJlWo.js";import{t as d}from"./button-Cs26nq0r.js";import{t as f}from"./useLoginActions-CynKtWLl.js";import{t as p}from"./checkbox-CM1MZiSJ.js";import{a as m,c as h,i as g,t as _}from"./alert-dialog-n1eT_Aa8.js";var v=t(i(),1);function y(){let{nostr:e}=o(),{user:t}=u(),{config:n}=c();return s({mutationFn:async({relayUrls:r,content:i})=>{if(!t)throw Error(`User is not logged in`);let a=r.includes(`ALL_RELAYS`),o=r.map(e=>[`relay`,e]),s=await t.signer.signEvent({kind:62,content:i,tags:o,created_at:Math.floor(Date.now()/1e3)});if(a){await e.event(s,{signal:AbortSignal.timeout(1e4)});let t=[...new Set(n.relayMetadata.relays.map(e=>e.url))].map(t=>e.relay(t).event(s,{signal:AbortSignal.timeout(1e4)}).catch(()=>{}));await Promise.allSettled(t)}else{let t=r.map(t=>e.relay(t).event(s,{signal:AbortSignal.timeout(1e4)}).catch(()=>{}));await Promise.allSettled(t)}return s}})}var b=e({RequestToVanishDialog:()=>C}),x=a(),S=[{id:`profile`,label:`Your profile and metadata`},{id:`posts`,label:`All posts, replies, and reactions`},{id:`messages`,label:`Direct messages`},{id:`settings`,label:`Follow lists and settings`},{id:`other`,label:`All other events submitted to the network`}];function C({open:e,onOpenChange:t}){let{mutateAsync:i,isPending:a}=y(),{logout:o}=f(),[s,c]=(0,v.useState)(new Set),u=S.every(e=>s.has(e.id)),b=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=(0,v.useCallback)(()=>{c(new Set)},[]);return(0,v.useEffect)(()=>{e||C()},[e,C]),(0,x.jsx)(_,{open:e,onOpenChange:t,children:(0,x.jsxs)(g,{className:`max-w-[400px] rounded-2xl p-6 gap-0 border-destructive/40`,children:[(0,x.jsxs)(`div`,{className:`mb-4`,children:[(0,x.jsxs)(h,{className:`text-base font-bold flex items-center gap-2`,children:[(0,x.jsx)(n,{className:`size-5 text-destructive shrink-0`}),`Delete Account`]}),(0,x.jsxs)(m,{className:`text-sm text-muted-foreground mt-1`,children:[`This will `,(0,x.jsx)(`span`,{className:`font-semibold text-destructive`,children:`permanently delete your data`}),`. Check each box to confirm you understand what will be removed:`]})]}),(0,x.jsx)(`div`,{className:`space-y-3 mb-5`,children:S.map(e=>(0,x.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer select-none`,children:[(0,x.jsx)(p,{checked:s.has(e.id),onCheckedChange:()=>b(e.id),className:`border-destructive/60 data-[state=checked]:bg-destructive data-[state=checked]:border-destructive`}),(0,x.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.label})]},e.id))}),(0,x.jsxs)(`p`,{className:`text-xs text-muted-foreground leading-relaxed mb-5`,children:[`This action is `,(0,x.jsx)(`span`,{className:`font-semibold text-destructive`,children:`irreversible`}),`. Your account cannot be recovered after deletion. You will be logged out immediately.`]}),(0,x.jsxs)(`div`,{className:`flex gap-3`,children:[(0,x.jsx)(d,{variant:`outline`,className:`flex-1`,onClick:()=>t(!1),disabled:a,children:`Cancel`}),(0,x.jsx)(d,{className:`flex-1 gap-1.5 bg-destructive text-destructive-foreground hover:bg-destructive/90 disabled:opacity-40`,onClick:async()=>{if(u)try{await i({relayUrls:[`ALL_RELAYS`],content:``}),l({title:`Account deleted`,description:`Your deletion request has been broadcast. You have been logged out.`}),t(!1),await o()}catch{l({title:`Failed to delete account`,description:`Something went wrong. You can try again.`,variant:`destructive`})}},disabled:!u||a,children:a?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r,{className:`size-3.5 animate-spin`}),`Deleting...`]}):`Delete Account`})]})]})})}export{b as n,C as t};
// @license-end
