ExportTab-CRuJ5QIA.js raw

   1  import{u as f,a as b,r as g,j as s,B as i,b as d,t as o}from"./index-DfKg850Q.js";function h(){const{pubkey:n}=f(),{isAdmin:x,isOwner:p}=b(),[t,a]=g.useState(!1),l=(e,E)=>{const c=URL.createObjectURL(e),r=document.createElement("a");r.href=c,r.download=E,r.click(),URL.revokeObjectURL(c)},m=async()=>{if(n){a(!0);try{const e=await d.exportEvents([n]);l(e,`my-events-${Date.now()}.jsonl`),o.success("Export complete")}catch(e){o.error(`Export failed: ${e instanceof Error?e.message:String(e)}`)}finally{a(!1)}}},u=async()=>{a(!0);try{const e=await d.exportEvents();l(e,`all-events-${Date.now()}.jsonl`),o.success("Export complete")}catch(e){o.error(`Export failed: ${e instanceof Error?e.message:String(e)}`)}finally{a(!1)}};return s.jsxs("div",{className:"space-y-4 p-4 max-w-lg",children:[n&&s.jsxs("div",{className:"rounded-lg bg-card p-4 space-y-3",children:[s.jsx("h3",{className:"text-lg font-semibold",children:"Export My Events"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Download your personal events as a JSONL file."}),s.jsx(i,{onClick:m,disabled:t,children:t?"Exporting...":"Export My Events"})]}),(x||p)&&s.jsxs("div",{className:"rounded-lg bg-card p-4 space-y-3",children:[s.jsx("h3",{className:"text-lg font-semibold",children:"Export All Events"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Download the complete database as a JSONL file. This includes all events from all users."}),s.jsx(i,{onClick:u,disabled:t,children:t?"Exporting...":"Export All Events"})]})]})}export{h as default};
   2