PageSourceSearch

https://morphedra.com/assets/TeamDashboard-0uMTpeCi.js

js morphedra.com collected 2026-10-09 22:54:40 UTC 25,673 bytes, 3 lines download raw bytes

1import{c as D,r,a as T,j as e,L as P,C as g,b,I as se,d as Y,e as I,f as C,T as W,g as U,u as _,S as ae,B as A,h as le,i as M,k as K,l as B,m as ne,n as ie,o as V,p as re,M as ce,q as oe,P as de}from"./index-BQoIQ5Rz.js";const me=D("LifeBuoy",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.93 4.93 4.24 4.24",key:"1ymg45"}],["path",{d:"m14.83 9.17 4.24-4.24",key:"1cb5xl"}],["path",{d:"m14.83 14.83 4.24 4.24",key:"q42g0n"}],["path",{d:"m9.17 14.83-4.24 4.24",key:"bqpfvv"}],["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}]]);const xe=D("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const q=D("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);const ue=D("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]),z=["from-indigo-500 to-blue-600","from-cyan-500 to-blue-500","from-violet-500 to-purple-600","from-amber-500 to-orange-500","from-rose-500 to-pink-600","from-emerald-500 to-teal-600"];function he(t,s){const n=t||s,i=n.split(/[.\s@]+/).filter(Boolean);return i.length>=2?(i[0][0]+i[1][0]).toUpperCase():n.slice(0,2).toUpperCase()}function pe({teamId:t}){const[s,n]=r.useState(null),[i,p]=r.useState(!0),[u,o]=r.useState(null),[f,v]=r.useState(!1);r.useEffect(()=>{let c=!0;return(async()=>{try{const d=await(await T()).get(`/teams/${t}/member-usage`);c&&n(d.data)}catch(l){c&&o(l?.response?.data?.error||l?.message||"Failed to load analytics")}finally{c&&p(!1)}})(),()=>{c=!1}},[t]),r.useEffect(()=>{if(s){const c=setTimeout(()=>v(!0),50);return()=>clearTimeout(c)}},[s]);const m=r.useMemo(()=>!s||s.members.length===0?null:s.members[0].totalIllustrations>0?s.members[0]:null,[s]),x=r.useMemo(()=>s?s.members.filter(c=>c.totalIllustrations>0).length:0,[s]);if(i)return e.jsxs("div",{className:"flex items-center justify-center py-16 text-slate-400",children:[e.jsx(P,{className:"w-6 h-6 animate-spin mr-2"}),"Loading analytics…"]});if(u)return e.jsx(g,{children:e.jsx(b,{className:"p-8 text-center text-sm text-red-600",children:u})});if(!s||s.members.length===0)return e.jsx(g,{children:e.jsx(b,{className:"p-8 text-center text-sm text-slate-500",children:"No illustrations generated yet. Once your team starts creating, usage will show up here."})});const j=s.members[0]?.totalIllustrations||1;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs(g,{className:"overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-50 to-transparent pointer-events-none"}),e.jsxs(b,{className:"p-5 relative",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500 uppercase tracking-wide",children:"Total Illustrations"}),e.jsx(se,{className:"w-4 h-4 text-blue-600"})]}),e.jsx("p",{className:"text-3xl font-bold text-slate-900 tabular-nums",children:s.totalIllustrations.toLocaleString()}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Generated by this team"})]})]}),e.jsxs(g,{className:"overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-indigo-50 to-transparent pointer-events-none"}),e.jsxs(b,{className:"p-5 relative",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500 uppercase tracking-wide",children:"Active Contributors"}),e.jsx(q,{className:"w-4 h-4 text-indigo-600"})]}),e.jsxs("p",{className:"text-3xl font-bold text-slate-900 tabular-nums",children:[x,e.jsxs("span",{className:"text-base font-medium text-slate-400",children:[" ","/ ",s.members.length]})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Have generated at least one"})]})]}),e.jsxs(g,{className:"overflow-hidden relative",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-50 to-transparent pointer-events-none"}),e.jsxs(b,{className:"p-5 relative",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-medium text-slate-500 uppercase tracking-wide",children:"Top Contributor"}),e.jsx(Y,{className:"w-4 h-4 text-amber-500"})]}),e.jsx("p",{className:"text-lg font-bold text-slate-900 truncate",children:m?m.name||m.email:"—"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:m?`${m.totalIllustrations}
1 illustrations`:"No activity yet"})]})]})]}),e.jsxs(g,{children:[e.jsxs(I,{children:[e.jsxs(C,{className:"flex items-center gap-2 text-base",children:[e.jsx(W,{className:"w-4 h-4 text-blue-600"}),"Usage by Member"]}),e.jsx(U,{children:"Share of the team's illustration quota, ranked by total generated."})]}),e.jsx(b,{className:"space-y-1",children:s.members.map((c,l)=>{const d=s.totalIllustrations>0?Math.round(c.totalIllustrations/s.totalIllustrations*100):0,k=j>0?c.totalIllustrations/j*100:0,h=z[l%z.length];return e.jsxs("div",{className:"flex items-center gap-4 py-3 border-b last:border-0 border-slate-100",children:[e.jsx("div",{className:"w-6 text-center shrink-0",children:l===0&&c.totalIllustrations>0?e.jsx(Y,{className:"w-4 h-4 text-amber-500 mx-auto"}):e.jsx("span",{className:"text-xs font-semibold text-slate-400",children:l+1})}),e.jsx("div",{className:`w-9 h-9 rounded-full bg-gradient-to-br ${h} flex items-center justify-center text-white text-xs font-semibold shrink-0`,children:he(c.name,c.email)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-slate-800 truncate",children:c.name||c.email}),e.jsx("span",{className:"text-sm font-semibold text-slate-900 tabular-nums ml-2 shrink-0",children:c.totalIllustrations})]}),e.jsx("div",{className:"h-1.5 bg-slate-100 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full bg-gradient-to-r ${h} transition-all duration-700 ease-out`,style:{width:f?`${k}%`:"0%"}})})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-1.5 shrink-0",children:[e.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-blue-50 text-blue-700",children:[c.illustrations2D," 2D"]}),e.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-violet-50 text-violet-700",children:[c.illustrations3D," 3D"]}),e.jsxs("span",{className:"text-xs text-slate-400 w-9 text-right tabular-nums",children:[d,"%"]})]})]},c.userId)})})]})]})}const J=["from-indigo-500 to-blue-600","from-cyan-500 to-blue-500","from-violet-500 to-purple-600","from-amber-500 to-orange-500","from-rose-500 to-pink-600","from-emerald-500 to-teal-600"];function fe(t,s){const n=t||s,i=n.split(/[.\s@]+/).filter(Boolean);return i.length>=2?(i[0][0]+i[1][0]).toUpperCase():n.slice(0,2).toUpperCase()}function je({pct:t,status:s,size:n=104,strokeWidth:i=9,mounted:p}){const u=(n-i)/2,o=2*Math.PI*u,f=Math.max(0,Math.min(100,t)),v=o-(p?f:0)/100*o,m=s==="at"?"text-rose-500":s==="near"?"text-amber-500":s==="healthy"?"text-blue-600":"text-slate-300";return e.jsxs("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:"-rotate-90 shrink-0",children:[e.jsx("circle",{cx:n/2,cy:n/2,r:u,stroke:"currentColor",strokeWidth:i,fill:"none",className:"text-slate-100"}),s!=="unset"&&e.jsx("circle",{cx:n/2,cy:n/2,r:u,stroke:"currentColor",strokeWidth:i,fill:"none",strokeDasharray:o,strokeDashoffset:v,strokeLinecap:"round",className:`${m} transition-all duration-700 ease-out`})]})}function ge({member:t,colorClass:s,mounted:n,onSave:i}){const[p,u]=r.useState(!1),[o,f]=r.useState(t.allocation===null?"":String(t.allocation)),[v,m]=r.useState(!1),[x,j]=r.useState(!1),{toast:c}=_(),l=t.allocation!==null,d=l&&t.allocation>0?Math.min(100,Math.round(t.allocationUsed/t.allocation*100)):0,k=l?d>=100?"at":d>=80?"near":"healthy":"unset",h={unset:"Shared pool",healthy:"Healthy",near:"Near limit",at:"At limit"}[k],$={unset:"text-slate-400",healthy:"text-blue-600",near:"text-amber-600",at:"text-rose-600"}[k],F=()=>{f(t.allocation===null?"":String(t.allocation)),m(!1),u(!0)},a=async()=>{const y=o.trim(),S=y===""?null:Number(y);if(S!==null&&(isNaN(S)||S<0)){c({title:"Enter a valid number",description:"Use a non-negative number, or clear the field for no limit.",variant:"destructive"});return}j(!0);try{await i(t.userId,S,v),u(!1)}finally{j(!1)}},N=async()=>{j(!0);try{await i(t.userId,null,!1),u(!1)}finally{j(!1)}};return e.jsxs("div",{className:`rounded-2xl border bg-white p-5 flex flex-col items-center text-center transition-all duration-300 ${p?"border-blue-300 shadow-md ring-1 ring-blue-100":"border-slate-200 hover:border-slate-300 hover:shadow-sm"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 self-stretch mb-4",children:[e.jsx("div",{className:`w-8 h-8 rounded-full bg-gradient-to-br ${s} flex items-center justify-center text-white text-[11px] font-semibold shrink-0`,children:fe(t.name,t.email)}),e.jsxs("div",{className:"min-w-0 text-left",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800 truncate",children:t.name||t.email}),t.name&&e.jsx("p",{className:"text-[11px] text-slate-400 truncate",children:t.email})]})]}),p?e.jsxs("div",{className:"w-full space-y-3 py-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-slate-500 uppercase tracking-wide mb-1.5 text-left",children:"Total illustrations allowed"}),e.jsx("input",{type:"number",min:0,autoFocus:!0,placeholder:"No limit",value:o,onChange:y=>f(y.target.value),className:"w-full text-center text-2xl font-bold tabular-nums text-slate-900 border border-slate-300 rounded-lg py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1.5 text-left",children:"Doesn't reset automatically — update it anytime."})]}),l&&e.jsxs("label",{className:"flex items-center gap-2 text-xs text-slate-600 justify-start cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:y=>m(y.target.checked),className:"rounded border-slate-300 focus:ring-blue-500"}
1),"Also reset their usage back to 0"]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(A,{size:"sm",onClick:a,disabled:x,className:"flex-1",children:x?e.jsx(P,{className:"w-3.5 h-3.5 animate-spin"}):"Save"}),e.jsx(A,{size:"sm",variant:"outline",onClick:()=>u(!1),disabled:x,className:"flex-1",children:"Cancel"})]}),l&&e.jsx("button",{onClick:N,disabled:x,className:"text-[11px] text-slate-400 hover:text-rose-600 underline disabled:opacity-50",children:"Remove limit — return to shared pool"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative flex items-center justify-center my-1",children:[e.jsx(je,{pct:d,status:k,mounted:n}),e.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:l?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-2xl font-bold text-slate-900 tabular-nums leading-none",children:t.allocationUsed}),e.jsxs("span",{className:"text-[11px] text-slate-400 mt-0.5",children:["of ",t.allocation]})]}):e.jsx(ue,{className:"w-6 h-6 text-slate-300"})})]}),e.jsx("span",{className:`text-xs font-medium mb-4 ${$}`,children:h}),e.jsx(A,{size:"sm",variant:l?"outline":"default",onClick:F,className:"w-full",children:l?"Edit limit":"Set a limit"})]})]})}function be({teamId:t}){const[s,n]=r.useState(null),[i,p]=r.useState(!0),[u,o]=r.useState(null),[f,v]=r.useState(!1),{toast:m}=_(),x=async()=>{try{const d=await(await T()).get(`/teams/${t}/member-usage`);n(d.data)}catch(l){o(l?.response?.data?.error||l?.message||"Failed to load")}finally{p(!1)}};r.useEffect(()=>{x()},[t]),r.useEffect(()=>{if(s){const l=setTimeout(()=>v(!0),80);return()=>clearTimeout(l)}},[s]);const j=async(l,d,k)=>{try{await(await T()).put(`/teams/${t}/members/${l}/allocation`,{allocation:d,resetUsage:k}),m({title:d===null?"Limit removed":"Limit saved",description:d===null?"This teammate now shares the team pool freely.":`They can generate up to ${d} illustrations.`,variant:"success"}),await x()}catch(h){throw m({title:"Couldn't save",description:h?.response?.data?.error||h?.message,variant:"destructive"}),h}};if(i)return e.jsxs("div",{className:"flex items-center justify-center py-16 text-slate-400",children:[e.jsx(P,{className:"w-6 h-6 animate-spin mr-2"}),"Loading allocations…"]});if(u||!s)return e.jsx(g,{children:e.jsx(b,{className:"p-8 text-center text-sm text-red-600",children:u||"Failed to load allocations"})});const c=s.members.filter(l=>l.allocation!==null).length;return e.jsxs(g,{children:[e.jsxs(I,{children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("span",{className:"text-[11px] font-semibold text-blue-600 uppercase tracking-widest",children:"Team Allocations"})}),e.jsxs(C,{className:"flex items-center gap-2 text-lg",children:[e.jsx(ae,{className:"w-5 h-5 text-blue-600"}),"Give each teammate a fixed share"]}),e.jsx(U,{children:"Assign a personal limit to keep usage fair across the team — great for splitting a lab or department budget. Anyone without a limit keeps drawing from the shared pool as usual."}),s.members.length>0&&e.jsxs("p",{className:"text-xs text-slate-400 pt-1",children:[c," of ",s.members.length," members have a personal limit set"]})]}),e.jsx(b,{children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:s.members.map((l,d)=>e.jsx(ge,{member:l,colorClass:J[d%J.length],mounted:f,onSave:j},l.userId))})})]})}const ve={TRIAL_MONTHLY:["1 seat","03 illustrations","20 posts"],BASIC_MONTHLY:["1 seat","10 illustrations","100 posts","Email support"],BASIC_ANNUAL:["1 seat","10 illustrations/month","100 posts","Email support"],PRO_MONTHLY:["1 seat","20 illustrations","200 posts","Email support"],PRO_ANNUAL:["1 seat","20 illustrations/month","200 posts","Email support"],LAB_LICENSE:["5 seats","750 illustrations","Unlimited posts","Dedicated support"],LAB_PRO:["12 seats","1500 illustrations","Unlimited posts","Dedicated support"],DEPARTMENT:["25 seats","3000 illustrations","Unlimited posts","Full API","Priority support"],INSTITUTION:["50 seats","6000 illustrations","Unlimited posts","Full API","Priority support"],ENTERPRISE:["100 seats","Unlimited posts","Full features","Full API","Advanced analytics","Priority support"],ENTERPRISE_PLUS:["150 seats","Unlimited posts","Full features","Full API","Advanced analytics","Priority support"],ENTERPRISE_ELITE:["200 seats","Unlimited posts","Full features","Full API","Advanced analytics","Priority support"]};function we(){const[t,s]=r.useState(null),[n,i]=r.useState([]),[p,u]=r.useState(!0),[o,f]=r.useState(""),[v,m]=r.useState(null),{toast:x}=_(),[,j]=le(),[c,l]=r.useState(!1),[d,k]=r.useState(0),[h,$]=r.useState("overview");if(r.useEffect(()=>{(async()=>{try{const N=await T(),S=(await N.get("/me")).data.user,E=String(S.id),O=S.role,L=S.email,H=S.teamRole,R=await N.get("/teams/me");if(!R.data||R.data.error||!R.data.ownerId){x({title:"⚠️ No team found",description:"You are not part of any team. Redirecting to home.",variant:"destructive"}),j("/home");return}const w=R.data;s(w);const X=w.isTrialing||w.trialEndsAt&&new Date(w.trialEndsAt)>
1new Date,G=w.trialEndsAt?Math.max(0,Math.ceil((new Date(w.trialEndsAt).getTime()-Date.now())/(1e3*60*60*24))):0;l(X&&G>0),k(G);const Z=O==="admin"||L===void 0,ee=H==="owner"||String(w.ownerId)===String(E);if(!Z&&!ee){x({title:"⚠️ Access Denied",description:"Only the team owner or admin can access this dashboard.",variant:"destructive"}),j("/home");return}const te=await N.get(`/subscription/teams/${w.id}/invites`).catch(()=>({data:[]}));i(te.data)}catch(N){s(null),x({title:"⚠️ Failed to load team",description:N?.message||"Could not fetch your team data.",variant:"destructive"}),j("/home")}finally{u(!1)}})()},[]),p)return e.jsx("p",{className:"p-8",children:"Loading dashboard…"});if(!t)return e.jsx("p",{className:"p-8",children:"No team found."});const F=Math.round(t.seatsUsed/t.maxSeats*100);return e.jsxs("div",{className:"flex flex-col sm:flex-row p-4 sm:p-6 pt-6 sm:pt-8 min-h-screen",children:[e.jsx("aside",{className:"w-full sm:w-64 border-r bg-gray-100 p-4 sm:p-6 flex flex-col justify-between",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold mb-6",children:t.name}),e.jsx("nav",{className:"flex sm:flex-col gap-2",children:[{key:"overview",label:"Overview",icon:M},{key:"members",label:"Members",icon:q},{key:"billing",label:"Billing",icon:K},{key:"credits",label:"Buy Credits",icon:M},{key:"analytics",label:"Analytics",icon:W},{key:"support",label:"Support",icon:me}].map(({key:a,label:N,icon:y})=>e.jsxs("button",{onClick:()=>$(a),className:`flex items-center gap-2 w-max sm:w-full text-left px-3 py-2 rounded ${h===a?"bg-blue-800 text-white":"hover:bg-foreground
1/10"}`,children:[e.jsx(y,{className:"w-4 h-4"})," ",N]},a))})]})}),e.jsxs("main",{className:"flex-1 p-4 sm:p-8 space-y-4 sm:space-y-6",children:[c&&d>0&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(M,{className:"w-5 h-5 text-blue-600"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-blue-900",children:["🎉 Trial Active - ",d," days remaining"]}),e.jsx("p",{className:"text-sm text-blue-700",children:"You're enjoying Business plan features. Upgrade before trial ends to keep them!"})]})]}),e.jsx(A,{onClick:()=>j("/pricing"),size:"sm",children:"Upgrade Now"})]}),h==="overview"&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6",children:[e.jsxs(g,{children:[e.jsxs(I,{children:[e.jsx(C,{children:"Plan Overview"}),e.jsx(U,{children:"Seats usage"})]}),e.jsx(b,{className:"space-y-4 pt-3",children:e.jsx(Ne,{label:"Seats",used:t.seatsUsed,max:t.maxSeats,percent:F})})]}),e.jsxs(g,{children:[e.jsx(I,{children:e.jsx(C,{children:"Features"})}),e.jsxs(b,{className:"space-y-2 pt-3",children:[ve[t.planKey]?.map(a=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(M,{className:"w-4 h-4 text-blue-800"}),e.jsx("span",{children:a})]},a)),t.hasGenerator&&e.jsx("div",{className:"pt-3",children:e.jsx(B,{href:"/home",children:e.jsx(A,{size:"sm",children:"Open Generator"})})})]})]})]}),h==="members"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(g,{children:[e.jsx(I,{children:e.jsx(C,{children:"Team Members"})}),e.jsx(b,{children:e.jsx("ul",{className:"divide-y",children:t.members.map(a=>e.jsxs("li",{className:"flex items-center justify-between py-2",children:[e.jsxs("span",{className:"text-sm",children:[a.email,a.id===t.ownerId&&e.jsx("span",{className:"ml-2 text-xs bg-primary/10 text-blue-800 px-2 py-0.5 rounded",children:"Admin"})]}),a.id!==t.ownerId&&e.jsx(A,{size:"sm",variant:"ghost",disabled:v===a.id,onClick:async()=>{const N=a.email,y=a.id;if(window.confirm(`Are you sure you want to remove ${N} from the team?
2
3This action cannot be undone.`))try{m(y),x({title:"Removing member...",description:`Removing ${N} from the team`});const E=await T();await E.delete(`/teams/${t.id}/members/${y}`),await new Promise(w=>setTimeout(w,300));const L=(await E.get("/teams/me")).data;if(L.members.some(w=>w.id===y))throw new Error("Member removal failed - still exists in team");s(L);const R=await E.get(`/subscription/teams/${t.id}/invites`).catch(()=>({data:[]}));i(R.data),x({title:"✅ Member Removed",description:`${N} has been removed from the team.`,variant:"success"})}catch(E){try{const L=await(await T()).get("/teams/me");s(L.data)}catch{}x({title:"❌ Removal Failed",description:E?.message||"Could not remove member",variant:"destructive"})}finally{m(null)}},children:v===a.id?e.jsx(P,{className:"w-4 h-4 animate-spin"}):"Remove"})]},a.id))})}),e.jsxs(ne,{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(ie,{placeholder:"[email protected]",type:"email",value:o,onChange:a=>f(a.target.value),onKeyDown:a=>{a.key==="Enter"&&Q(t.id,o,f,i,x)}}),e.jsxs(A,{onClick:()=>{Q(t.id,o,f,i,x)},children:[e.jsx(q,{className:"w-4 h-4 mr-2"}),"Invite Member "]})]})]}),e.jsxs(g,{children:[e.jsxs(I,{children:[e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-5 h-5"}),"Pending Invites"]}),e.jsx(U,{children:"Share these links with your teammates. Links expire in 7 days."})]}),e.jsx(b,{children:n.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4",children:"No invites yet. Generate a link above to invite teammates."}):e.jsx("div",{className:"space-y-3",children:n.map(a=>e.jsxs("div",{className:"flex flex-col gap-2 p-3 border rounded-lg bg-gray-50",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium truncate",children:a.targetEmail}),a.used?e.jsx(V,{className:"bg-green-600",children:"Accepted"}):e.jsx(V,{variant:"secondary",children:"Pending"})]}),a.used?e.jsxs("p",{className:"text-xs text-gray-500",children:["Joined"," ",new Date(a.usedAt).toLocaleDateString()]}):e.jsxs("p",{className:"text-xs text-gray-500",children:["Expires"," ",new Date(a.expiresAt).toLocaleDateString()]})]})}),!a.used&&e.jsxs("div",{className:"flex items-center gap-2 bg-white p-2 rounded border",children:[e.jsx("code",{className:"text-xs flex-1 truncate text-blue-600",children:a.link}),e.jsx(re,{text:a.link})]})]},a._id))})})]})]}),h==="billing"&&e.jsxs(g,{className:"shadow-md rounded-2xl",children:[e.jsxs(I,{className:"flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-x-3",children:[e.jsx(K,{className:"h-6 w-6 text-blue-600"}),e.jsxs("div",{children:[e.jsx(C,{className:"text-lg",children:"Subscription"}),e.jsx(U,{children:"Manage billing, cancellations, and plan changes."})]})]}),e.jsxs(b,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("p",{className:"text-sm text-foreground",children:["Current Plan:"," ",e.jsx("span",{className:"font-medium",children:t.planKey})]}),e.jsx("div",{className:"mt-4 px-6 pb-6"}),t.lemonSqueezySubscriptionId?e.jsx("div",{className:"flex flex-col items-start gap-2",children:e.jsx(ce,{subscriptionId:t.lemonSqueezySubscriptionId,status:t.subscriptionStatus})}):e.jsxs("p",{className:"text-sm text-gray-500",children:["No active subscription found."," ",e.jsx(A,{variant:"link",className:"text-blue-600",onClick:()=>j("/pricing"),children:"Upgrade now"})]})]}),e.jsxs("div",{className:"mt-4 text-sm",children:["Seats: ",t.seatsUsed," / ",t.maxSeats]}),t.lemonSqueezySubscriptionId&&e.jsxs("div",{className:"text-xs text-foreground",children:["Subscription ID: ",t.lemonSqueezySubscriptionId]}),e.jsxs("div",{className:"mt-6 border-t pt-3 text-xs text-gray-500 leading-relaxed",children:[e.jsx("p",{className:"font-medium text-gray-600",children:"Refund & Cancellation Policy:"}),e.jsxs("ul",{className:"list-disc ml-4 mt-1 space-y-1",children:[e.jsxs("li",{children:["Monthly: Cancel within"," ",e.jsx("span",{className:"text-red-400 font-medium",children:"24 hours"})," ","for a full refund (upon request)."]}),e.jsxs("li",{children:["Annual: Cancel within"," ",e.jsx("span",{className:"text-red-400 font-medium",children:"15 days"})," ","for a full refund."]})]})]})]})]}),h==="support"&&e.jsxs(g,{children:[e.jsx(I,{children:e.jsx(C,{children:"Support & Resources"})}),e.jsxs(b,{className:"space-y-2",children:[e.jsx(B,{href:"/docs",className:"text-blue-800 hover:underline text-sm",children:"📘 Documentation"}),e.jsx("a",{href:"mailto:[email protected]",className:"text-blue-800 hover:underline text-sm",children:"✉️ Contact Support"}),e.jsx(B,{href:"/faq",className:"text-blue-800 hover:underline text-sm",children:"❓ FAQ"})]})]}),h==="credits"&&e.jsx("div",{className:"space-y-4",children:e.jsx(oe,{compact:!1})}),h==="analytics"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(pe,{teamId:t.id}),e.jsx(be,{teamId:t.id})]})]})]})}function Ne({label:t,used:s,max:n,percent:i}){return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{children:t}),e.jsx("span",{children:n===-1?"Unlimited":`${s} / ${n}`})]}),e.jsx(de,{value:i,className:"h-2"})]})}async function Q(t,s,n,i,p){if(!s.trim()){p({title:"Error",description:"Please enter an email address",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)){p({title:"Invalid Email",description:"Please enter a valid email address",variant:"destructive"});return}try{const o=await T();p({title:"Sending invitation...",description:`Inviting ${s} to your team`});const f=await o.post(`/subscription/teams/${t}/invite-member`,{email:s}),v={_id:Date.now().toString(),token:f.data.link.split("token=")[1],targetEmail:s,expiresAt:f.data.expiresAt,used:!1,link:f.data.link};i(m=>[v,...m]),p({title:"✅ Invitation Sent!",description:`${s} will receive an email with instructions to join your team`,variant:"success"}),n("")}catch(o){p({title:"Failed to Send Invite",description:o?.response?.data?.error||o?.message||"Could not send invitation email",variant:"destructive"})}}export{we as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.