better-auth-studio 1.0.23-beta.1 → 1.0.23-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-auth-studio",
3
- "version": "1.0.23-beta.1",
3
+ "version": "1.0.23-beta.2",
4
4
  "description": "Studio for Better Auth",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -360,4 +360,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
360
360
  }
361
361
  `;document.head.appendChild(vx);const me=h.forwardRef(({className:e,type:t,...r},s)=>n.jsx("input",{type:t,className:`flex h-10 w-full border border-dashed border-white/20 bg-black/30 px-3 py-2 text-sm text-white placeholder:text-gray-400 focus:outline-none focus:ring-1 focus:ring-white focus:border-white/40 disabled:cursor-not-allowed disabled:opacity-50 rounded-none ${e}`,ref:s,...r}));me.displayName="Input";const xe=h.forwardRef(({className:e,...t},r)=>n.jsx("label",{className:`text-sm font-light text-white ${e}`,ref:r,...t}));xe.displayName="Label";function yx({currentPage:e,totalPages:t,onPageChange:r,totalItems:s,startIndex:a,endIndex:i}){const l=()=>{const d=[],m=[];for(let u=Math.max(2,e-2);u<=Math.min(t-1,e+2);u++)d.push(u);return e-2>2?m.push(1,"..."):m.push(1),m.push(...d),e+2<t-1?m.push("...",t):t>1&&m.push(t),m};if(t<=1)return null;const o=l();return n.jsxs("div",{className:"flex items-center justify-between mt-6",children:[n.jsxs("div",{className:"text-sm text-gray-400",children:["Showing ",a+1," to ",Math.min(i,s)," of ",s," items"]}),n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>r(e-1),disabled:e===1,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[n.jsx(E0,{className:"w-4 h-4"}),"Previous"]}),o.map((c,d)=>{if(c==="...")return n.jsx(T,{variant:"outline",size:"sm",disabled:!0,className:"border border-dashed border-white/20 text-white rounded-none",children:n.jsx(M0,{className:"w-4 h-4"})},`dots-${d}`);const m=c,u=e===m;return n.jsx(T,{variant:u?"default":"outline",size:"sm",onClick:()=>r(m),className:u?"bg-white text-black rounded-none":"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:m},m)}),n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>r(e+1),disabled:e===t,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:["Next",n.jsx(T0,{className:"w-4 h-4"})]})]})]})}const Ea=h.createContext({isOpen:!1,setIsOpen:()=>{}}),hs=h.forwardRef(({className:e,value:t,onValueChange:r,children:s,...a},i)=>{const[l,o]=h.useState(!1);return n.jsx(Ea.Provider,{value:{value:t,onValueChange:r,isOpen:l,setIsOpen:o},children:n.jsx("div",{ref:i,className:`relative ${e}`,...a,children:s})})});hs.displayName="Select";const ms=h.forwardRef(({className:e,children:t,...r},s)=>{const{isOpen:a,setIsOpen:i}=h.useContext(Ea);return n.jsxs("button",{ref:s,type:"button",className:`flex h-10 w-full items-center justify-between border border-dashed border-white/20 bg-black/30 px-3 py-2 text-sm text-white focus:outline-none focus:ring-1 focus:ring-white focus:border-white/40 disabled:cursor-not-allowed disabled:opacity-50 rounded-none ${e}`,onClick:()=>i(!a),...r,children:[t,n.jsx(Cf,{className:`h-4 w-4 text-gray-400 transition-transform ${a?"rotate-180":""}`})]})});ms.displayName="SelectTrigger";const fs=h.forwardRef(({className:e,placeholder:t,...r},s)=>{const{value:a}=h.useContext(Ea);return n.jsx("span",{ref:s,className:`text-sm text-white ${e}`,...r,children:a||t})});fs.displayName="SelectValue";const xs=h.forwardRef(({className:e,children:t,...r},s)=>{const{isOpen:a}=h.useContext(Ea);return a?n.jsx("div",{ref:s,className:`absolute top-full left-0 right-0 z-50 mt-1 border border-dashed border-white/20 bg-black/90 rounded-none shadow-lg ${e}`,...r,children:t}):null});xs.displayName="SelectContent";const Dt=h.forwardRef(({className:e,children:t,value:r,...s},a)=>{const{onValueChange:i,setIsOpen:l}=h.useContext(Ea);return n.jsx("div",{ref:a,className:`px-3 py-2 text-sm text-white hover:bg-white/10 cursor-pointer ${e}`,onClick:()=>{i==null||i(r),l(!1)},...s,children:t})});Dt.displayName="SelectItem";function wx(){const e=En(),{refetchCounts:t}=qc(),[r,s]=h.useState([]),[a,i]=h.useState(!0),[l,o]=h.useState(null),[c,d]=h.useState(""),[m,u]=h.useState("all"),[p,y]=h.useState(1),[w]=h.useState(20),[v,j]=h.useState(!1),[x,f]=h.useState(!1),[g,N]=h.useState(!1),[C,P]=h.useState(!1),[k,R]=h.useState(!1),[J,W]=h.useState(!1),[q,Y]=h.useState(null),[te,ee]=h.useState([]),[ie,X]=h.useState(!1),[_,S]=h.useState({name:"",slug:""}),[O,B]=h.useState({name:"",organizationId:""}),[z,b]=h.useState({name:"",slug:""});h.useEffect(()=>{$()},[]);const E=F=>F.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,""),L=F=>{const Q=E(F);S({name:F,slug:Q})},M=F=>{S(Q=>({...Q,slug:E(F)}))},A=F=>{const Q=E(F);b({name:F,slug:Q})},K=F=>{b(Q=>({...Q,slug:E(F)}))},$=async()=>{try{const Q=await(await fetch("/api/plugins")).json(),oe=(Q==null?void 0:Q.plugins).find(Ee=>Ee.id==="organization");o({enabled:!!oe,availablePlugins:(Q==null?void 0:Q.plugins).map(Ee=>Ee.id),configPath:Q.configPath,organizationPlugin:(Q==null?void 0:Q.plugins).find(Ee=>Ee.id==="organization")}),oe?await Z():i(!1)}catch(F){console.error("Failed to check plugin status:",F),o({enabled:!1,error:"Failed to check plugin status"}),i(!1)}},Z=async()=>{try{const Q=await(await fetch("/api/organizations?limit=10000")).json();s(Q.organizations||[])}catch(F){console.error("Failed to fetch organizations:",F),D.error("Failed to fetch organizations")}finally{i(!1)}},de=async F=>{ee([]),X(!0),ee([{id:"start",type:"info",message:`Starting organization seeding process for ${F} organizations...`,timestamp:new Date}]);try{const oe=await(await fetch("/api/seed/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:F})})).json();if(oe.success){const Ee=oe.results.map((ye,Te)=>ye.success?{id:`org-${Te}`,type:"progress",message:`Creating organization: ${ye.organization.name} (${ye.organization.slug})`,timestamp:new Date,status:"completed"}:{id:`org-${Te}`,type:"error",message:`Failed to create organization ${Te+1}: ${ye.error}`,timestamp:new Date});ee(ye=>[...ye,...Ee]);const Fe=oe.results.filter(ye=>ye.success).length;ee(ye=>[...ye,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${Fe}/${F} organizations successfully`,timestamp:new Date}]),await Z(),await t()}else ee(Ee=>[...Ee,{id:"error",type:"error",message:`❌ Seeding failed: ${oe.error||"Unknown error"}`,timestamp:new Date}])}catch(Q){ee(oe=>[...oe,{id:"error",type:"error",message:`❌ Network error: ${Q}`,timestamp:new Date}])}finally{X(!1)}},we=async F=>{ee([]),X(!0),ee([{id:"start",type:"info",message:`Starting team seeding process for ${F} teams...`,timestamp:new Date}]);try{const oe=await(await fetch("/api/seed/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:F})})).json();if(oe.success){const Ee=oe.results.map((ye,Te)=>ye.success?{id:`team-${Te}`,type:"progress",message:`Creating team: ${ye.team.name}`,timestamp:new Date,status:"completed"}:{id:`team-${Te}`,type:"error",message:`Failed to create team ${Te+1}: ${ye.error}`,timestamp:new Date});ee(ye=>[...ye,...Ee]);const Fe=oe.results.filter(ye=>ye.success).length;ee(ye=>[...ye,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${Fe}/${F} teams successfully`,timestamp:new Date}]),await Z(),await t()}else ee(Ee=>[...Ee,{id:"error",type:"error",message:`❌ Seeding failed: ${oe.error||"Unknown error"}`,timestamp:new Date}])}catch(Q){ee(oe=>[...oe,{id:"error",type:"error",message:`❌ Network error: ${Q}`,timestamp:new Date}])}finally{X(!1)}},ge=F=>{Y(F),R(!0)},Ne=F=>{Y(F),b({name:F.name,slug:F.slug}),N(!0)},ve=F=>{Y(F),P(!0)},Gt=async()=>{if(!_.name){D.error("Please fill in the organization name");return}const F=D.loading("Creating organization...");try{const oe=await(await fetch("/api/organizations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:_.name,slug:_.slug})})).json();oe.success?(await Z(),j(!1),S({name:"",slug:""}),D.success("Organization created successfully!",{id:F})):D.error(`Error creating organization: ${oe.error||"Unknown error"}`,{id:F})}catch(Q){console.error("Error creating organization:",Q),D.error("Error creating organization",{id:F})}},ir=async()=>{if(!O.name){D.error("Please fill in the team name");return}if(!O.organizationId){D.error("Please select an organization");return}const F=D.loading("Creating team...");try{const oe=await(await fetch("/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:O.name,organizationId:O.organizationId})})).json();oe.success?(f(!1),B({name:"",organizationId:""}),D.success("Team created successfully!",{id:F})):D.error(`Error creating team: ${oe.error||"Unknown error"}`,{id:F})}catch(Q){console.error("Error creating team:",Q),D.error("Error creating team",{id:F})}},lr=async()=>{if(!q){D.error("No organization selected");return}if(!z.name){D.error("Please fill in the organization name");return}const F=D.loading("Updating organization...");try{const oe=await(await fetch(`/api/organizations/${q.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z.name,slug:z.slug})})).json();oe.success?(await Z(),N(!1),Y(null),b({name:"",slug:""}),D.success("Organization updated successfully!",{id:F})):D.error(`Error updating organization: ${oe.error||"Unknown error"}`,{id:F})}catch(Q){console.error("Error updating organization:",Q),D.error("Error updating organization",{id:F})}},Lt=async()=>{if(!q){D.error("No organization selected");return}const F=D.loading("Deleting organization...");try{const oe=await(await fetch(`/api/organizations/${q.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();oe.success?(await Z(),await t(),P(!1),Y(null),D.success("Organization deleted successfully!",{id:F})):D.error(`Error deleting organization: ${oe.error||"Unknown error"}`,{id:F})}catch(Q){console.error("Error deleting organization:",Q),D.error("Error deleting organization",{id:F})}},Ye=()=>{if(r.length===0){D.error("No organizations to export");return}const F=["ID","Name","Slug","Created At","Updated At"],Q=r.map(Te=>[Te.id,Te.name||"",Te.slug||"",new Date(Te.createdAt).toLocaleString(),new Date(Te.updatedAt).toLocaleString()]),oe=[F.join(","),...Q.map(Te=>Te.map(Ns=>`"${Ns}"`).join(","))].join(`
362
362
  `),Ee=new Blob([oe],{type:"text/csv;charset=utf-8;"}),Fe=document.createElement("a"),ye=URL.createObjectURL(Ee);Fe.setAttribute("href",ye),Fe.setAttribute("download",`organizations-export-${new Date().toISOString().split("T")[0]}.csv`),Fe.style.visibility="hidden",document.body.appendChild(Fe),Fe.click(),document.body.removeChild(Fe),D.success(`Exported ${r.length} organizations to CSV`)},Ot=r.filter(F=>{var Ee;const Q=F.name.toLowerCase().includes(c.toLowerCase())||F.slug.toLowerCase().includes(c.toLowerCase()),oe=m==="all"||((Ee=F.metadata)==null?void 0:Ee.status)===m;return Q&&oe}),bs=Math.ceil(Ot.length/w),$e=(p-1)*w,At=$e+w,rn=Ot.slice($e,At),js=F=>{y(F)};return a?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading organizations..."})]})}):l&&!l.enabled?n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-light",children:"Organizations"}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your application organizations"})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:n.jsxs("div",{className:"flex items-start space-x-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx(Le,{className:"w-12 h-12 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Organization Plugin Required"}),n.jsx("p",{className:"text-gray-300 mb-6",children:"To use Organizations in Better Auth Studio, you need to enable the organization plugin in your Better Auth configuration."}),n.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[n.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),n.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:n.jsxs("li",{children:["Import the plugin in your auth configuration file",l.configPath&&n.jsxs("span",{className:"text-gray-400",children:[" (",l.configPath,")"]}),":"]})}),n.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:n.jsxs("pre",{className:"text-sm text-gray-300",children:[n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"export const"})," ",n.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",n.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",n.jsx("br",{}),n.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",n.jsx("br",{}),n.jsxs("span",{className:"text-yellow-300 pl-12",children:["organization(",")"]}),n.jsx("br",{}),n.jsx("span",{className:"pl-10",children:"]"})," ",n.jsx("br",{}),"}",") ",n.jsx("br",{})]})}),n.jsx("div",{className:"mt-4",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"2. Do migrations to create the organizations table"})}),n.jsx("div",{className:"mt-2",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),l.availablePlugins&&l.availablePlugins.length>0&&n.jsx("div",{className:"mb-4",children:n.jsxs("p",{className:"text-gray-400 text-sm",children:["Currently enabled plugins: ",l.availablePlugins.join(", ")]})}),n.jsx(T,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),n.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",n.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl text-white font-light",children:["Organizations (",r.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your organizations and teams"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:Ye,children:[n.jsx(Ef,{className:"w-4 h-4 mr-2"}),"Export CSV"]}),n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:()=>W(!0),children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed"]}),n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:()=>f(!0),children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Create Team"]}),n.jsxs(T,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>j(!0),children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Add Organization"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{placeholder:"Search organizations...",value:c,onChange:F=>d(F.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Jc,{className:"w-4 h-4 text-gray-400"}),n.jsxs(hs,{value:m,onValueChange:u,children:[n.jsx(ms,{children:n.jsx(fs,{})}),n.jsxs(xs,{children:[n.jsx(Dt,{value:"all",children:"All"}),n.jsx(Dt,{value:"active",children:"Active"}),n.jsx(Dt,{value:"inactive",children:"Inactive"})]})]})]})]}),n.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Organization"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Slug"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:Ot.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:4,className:"py-12 px-4 text-center",children:n.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Le,{className:"w-8 h-8 text-white/50"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium text-lg",children:"No organizations found"}),n.jsx("p",{className:"text-gray-400 text-sm mt-1",children:c||m!=="all"?"Try adjusting your search or filter criteria":"Get started by creating your first organization"})]}),!c&&m==="all"&&n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:()=>j(!0),className:"bg-white text-black hover:bg-gray-200 rounded-none",children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Create Organization"]}),n.jsxs(T,{onClick:()=>W(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Data"]})]})]})})}):rn.map(F=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>e(`/organizations/${F.id}`),children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Le,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:F.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",F.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:F.slug}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:n.jsxs("div",{className:"flex flex-col",children:[new Date(F.createdAt).toLocaleDateString(),n.jsx("p",{className:"text-xs",children:new Date(F.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]})}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:Q=>{Q.stopPropagation(),ge(F)},children:n.jsx(sl,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:Q=>{Q.stopPropagation(),Ne(F)},children:n.jsx(wn,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:Q=>{Q.stopPropagation(),ve(F)},children:n.jsx(fn,{className:"w-4 h-4"})})]})})]},F.id))})]})}),n.jsx(yx,{currentPage:p,totalPages:bs,onPageChange:js,totalItems:Ot.length,startIndex:$e,endIndex:At})]}),J&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Data"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>W(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Le,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Organizations"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"organization-count",className:"text-sm text-gray-400 font-light",children:"Number of organizations"}),n.jsx(me,{id:"organization-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var Q;const F=parseInt(((Q=document.getElementById("organization-count"))==null?void 0:Q.value)||"5");de(F)},disabled:ie,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:ie?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-3 h-3 mr-2"}),"Seed Organizations"]})})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Lr,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Teams"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"team-count",className:"text-sm text-gray-400 font-light",children:"Number of teams"}),n.jsx(me,{id:"team-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var Q;const F=parseInt(((Q=document.getElementById("team-count"))==null?void 0:Q.value)||"5");we(F)},disabled:ie,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:ie?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-3 h-3 mr-2"}),"Seed Teams"]})})]})]}),te.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Organization Seeding Terminal",lines:te,isRunning:ie,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>W(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),x&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>f(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),n.jsx(me,{id:"team-name",value:O.name,onChange:F=>B(Q=>({...Q,name:F.target.value})),placeholder:"Enter team name",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"team-organization",className:"text-sm text-gray-400 font-light",children:"Organization"}),n.jsxs(hs,{value:O.organizationId,onValueChange:F=>B(Q=>({...Q,organizationId:F})),children:[n.jsx(ms,{className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none",children:n.jsx(fs,{placeholder:"Select organization"})}),n.jsx(xs,{children:r.map(F=>n.jsx(Dt,{value:F.id,children:F.name},F.id))})]})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{f(!1),B({name:"",organizationId:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:ir,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),v&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create Organization"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-name",className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx(me,{id:"create-name",value:_.name,onChange:F=>L(F.target.value),placeholder:"e.g. Acme Corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-slug",className:"text-sm text-gray-400 font-light",children:"Slug"}),n.jsx(me,{id:"create-slug",value:_.slug,onChange:F=>M(F.target.value),placeholder:"e.g. acme-corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"}),n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Auto-generated from name. You can edit it manually."})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{j(!1),S({name:"",slug:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:Gt,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),g&&q&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Organization"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Le,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:q.name}),n.jsx("div",{className:"text-sm text-gray-400",children:q.slug})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-name",className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx(me,{id:"edit-name",value:z.name,onChange:F=>A(F.target.value),placeholder:"e.g. Acme Corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-slug",className:"text-sm text-gray-400 font-light",children:"Slug"}),n.jsx(me,{id:"edit-slug",value:z.slug,onChange:F=>K(F.target.value),placeholder:"e.g. acme-corp",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"}),n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Auto-generated from name. You can edit it manually."})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{N(!1),b({name:"",slug:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:lr,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),C&&q&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Organization"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>P(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Le,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:q.name}),n.jsx("div",{className:"text-sm text-gray-400",children:q.slug})]})]}),n.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this organization? This action cannot be undone."})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>P(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:Lt,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),k&&q&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Organization Details"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>R(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Le,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:q.name}),n.jsx("div",{className:"text-sm text-gray-400",children:q.slug})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"ID:"}),n.jsx("span",{className:"text-white text-sm",children:q.id})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Created:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(q.createdAt).toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Updated:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(q.updatedAt).toLocaleString()})]})]})]}),n.jsx("div",{className:"flex justify-end mt-6",children:n.jsx(T,{onClick:()=>R(!1),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Close"})})]})})]})}function bx(){const e=En(),{refetchCounts:t}=qc(),[r,s]=h.useState([]),[a,i]=h.useState(!0),[l,o]=h.useState(""),[c,d]=h.useState("all"),[m,u]=h.useState(1),[p]=h.useState(20),[y,w]=h.useState(!1),[v,j]=h.useState(!1),[x,f]=h.useState(!1),[g,N]=h.useState(!1),[C,P]=h.useState(!1),[k,R]=h.useState(null),[J,W]=h.useState([]),[q,Y]=h.useState(!1);h.useEffect(()=>{te()},[]);const te=async()=>{try{const Z=await(await fetch("/api/users?limit=10000")).json();s(Z.users||[])}catch($){console.error("Failed to fetch users:",$)}finally{i(!1)}},ee=async $=>{W([]),Y(!0),W([{id:"start",type:"info",message:`Starting user seeding process for ${$} users...`,timestamp:new Date}]);try{const de=await(await fetch("/api/seed/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:$})})).json();if(de.success){const we=de.results.map((Ne,ve)=>Ne.success?{id:`user-${ve}`,type:"progress",message:`Creating user: ${Ne.user.name} (${Ne.user.email})`,timestamp:new Date,status:"completed"}:{id:`user-${ve}`,type:"error",message:`Failed to create user ${ve+1}: ${Ne.error}`,timestamp:new Date});W(Ne=>[...Ne,...we]);const ge=de.results.filter(Ne=>Ne.success).length;W(Ne=>[...Ne,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${ge}/${$} users successfully`,timestamp:new Date}]),await te(),await t()}else W(we=>[...we,{id:"error",type:"error",message:`❌ Seeding failed: ${de.error||"Unknown error"}`,timestamp:new Date}])}catch(Z){W(de=>[...de,{id:"error",type:"error",message:`❌ Network error: ${Z}`,timestamp:new Date}])}finally{Y(!1)}},ie=$=>{R($),N(!0)},X=$=>{R($),j(!0)},_=$=>{R($),f(!0)},S=async()=>{var ge,Ne,ve;const $=(ge=document.getElementById("create-name"))==null?void 0:ge.value,Z=(Ne=document.getElementById("create-email"))==null?void 0:Ne.value,de=(ve=document.getElementById("create-password"))==null?void 0:ve.value;if(!$||!Z||!de){D.error("Please fill in all fields");return}const we=D.loading("Creating user...");try{const ir=await(await fetch("/api/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$,email:Z,password:de})})).json();ir.success?(await te(),w(!1),document.getElementById("create-name").value="",document.getElementById("create-email").value="",document.getElementById("create-password").value="",D.success("User created successfully!",{id:we})):D.error(`Error creating user: ${ir.error||"Unknown error"}`,{id:we})}catch(Gt){console.error("Error creating user:",Gt),D.error("Error creating user",{id:we})}},O=async()=>{var we,ge;if(!k){D.error("No user selected");return}const $=(we=document.getElementById("edit-name"))==null?void 0:we.value,Z=(ge=document.getElementById("edit-email"))==null?void 0:ge.value;if(!$||!Z){D.error("Please fill in all fields");return}const de=D.loading("Updating user...");try{const ve=await(await fetch(`/api/users/${k.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$,email:Z})})).json();ve.success?(await te(),j(!1),R(null),D.success("User updated successfully!",{id:de})):D.error(`Error updating user: ${ve.error||"Unknown error"}`,{id:de})}catch(Ne){console.error("Error updating user:",Ne),D.error("Error updating user",{id:de})}},B=async()=>{if(!k){D.error("No user selected");return}const $=D.loading("Deleting user...");try{const de=await(await fetch(`/api/users/${k.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();de.success?(await te(),await t(),f(!1),R(null),D.success("User deleted successfully!",{id:$})):D.error(`Error deleting user: ${de.error||"Unknown error"}`,{id:$})}catch(Z){console.error("Error deleting user:",Z),D.error("Error deleting user",{id:$})}},z=()=>{if(r.length===0){D.error("No users to export");return}const $=["ID","Name","Email","Email Verified","Created At","Updated At"],Z=r.map(ve=>[ve.id,ve.name||"",ve.email||"",!!ve.emailVerified,new Date(ve.createdAt).toLocaleString(),new Date(ve.updatedAt).toLocaleString()]),de=[$.join(","),...Z.map(ve=>ve.map(Gt=>`"${Gt}"`).join(","))].join(`
363
- `),we=new Blob([de],{type:"text/csv;charset=utf-8;"}),ge=document.createElement("a"),Ne=URL.createObjectURL(we);ge.setAttribute("href",Ne),ge.setAttribute("download",`users-export-${new Date().toISOString().split("T")[0]}.csv`),ge.style.visibility="hidden",document.body.appendChild(ge),ge.click(),document.body.removeChild(ge),D.success(`Exported ${r.length} users to CSV`)},b=r.filter($=>($.name.toLowerCase().includes(l.toLowerCase())||$.email.toLowerCase().includes(l.toLowerCase()))&&c==="all"),E=Math.ceil(b.length/p),L=(m-1)*p,M=L+p,A=b.slice(L,M),K=$=>{u($)};return a?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading users..."})]})}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl text-white font-light",children:["Users (",r.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your application users"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:z,children:[n.jsx(Ef,{className:"w-4 h-4 mr-2"}),"Export CSV"]}),n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:()=>P(!0),children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed"]}),n.jsxs(T,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>w(!0),children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add User"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{placeholder:"Search users...",value:l,onChange:$=>o($.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Jc,{className:"w-4 h-4 text-gray-400"}),n.jsxs(hs,{value:c,onValueChange:d,children:[n.jsx(ms,{children:n.jsx(fs,{})}),n.jsxs(xs,{children:[n.jsx(Dt,{value:"all",children:"All"}),n.jsx(Dt,{value:"active",children:"Active"}),n.jsx(Dt,{value:"inactive",children:"Inactive"})]})]})]})]}),n.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email Verified"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:A.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"py-12 px-4 text-center",children:n.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white/50"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium text-lg",children:"No users found"}),n.jsx("p",{className:"text-gray-400 text-sm mt-1",children:l||c!=="all"?"Try adjusting your search or filter criteria":"Get started by creating your first user or seeding some data"})]}),!l&&c==="all"&&n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:()=>w(!0),className:"bg-white text-black hover:bg-gray-200 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Create User"]}),n.jsxs(T,{onClick:()=>P(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Data"]})]})]})})}):A.map($=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>e(`/users/${$.id}`),children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:$.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${$.id}`,alt:$.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:$.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",$.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:$.email}),n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-2",children:[$.emailVerified?n.jsx(C0,{className:"w-4 h-4 text-green-400"}):n.jsx(Et,{className:"w-4 h-4 text-yellow-400"}),n.jsx("span",{className:"text-sm text-gray-400",children:$.emailVerified?"Verified":"Not Verified"})]})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:n.jsxs("div",{className:"flex flex-col",children:[new Date($.createdAt).toLocaleDateString(),n.jsx("p",{className:"text-xs",children:new Date($.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]})}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:Z=>{Z.stopPropagation(),ie($)},children:n.jsx(sl,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:Z=>{Z.stopPropagation(),X($)},children:n.jsx(wn,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:Z=>{Z.stopPropagation(),_($)},children:n.jsx(fn,{className:"w-4 h-4"})})]})})]},$.id))})]})}),n.jsx(yx,{currentPage:m,totalPages:E,onPageChange:K,totalItems:b.length,startIndex:L,endIndex:M})]}),C&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Data"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>P(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Users"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"user-count",className:"text-sm text-gray-400 font-light",children:"Number of users"}),n.jsx(me,{id:"user-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var Z;const $=parseInt(((Z=document.getElementById("user-count"))==null?void 0:Z.value)||"5");ee($)},disabled:q,className:"bg-transparent hover:bg-white/90 bg-white text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:q?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-3 h-3 mr-2"}),"Seed Users"]})})]})]}),J.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"User Seeding Terminal",lines:J,isRunning:q,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>P(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),y&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>w(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-name",className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx(me,{id:"create-name",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-email",className:"text-sm text-gray-400 font-light",children:"Email"}),n.jsx(me,{id:"create-email",type:"email",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-password",className:"text-sm text-gray-400 font-light",children:"Password"}),n.jsx(me,{id:"create-password",type:"password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>w(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:S,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),v&&k&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:k.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${k.id}`,alt:k.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:k.name}),n.jsx("div",{className:"text-sm text-gray-400",children:k.email})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-name",className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx(me,{id:"edit-name",defaultValue:k.name,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-email",className:"text-sm text-gray-400 font-light",children:"Email"}),n.jsx(me,{id:"edit-email",type:"email",defaultValue:k.email,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>j(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:O,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),x&&k&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Delete User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>f(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:k.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${k.id}`,alt:k.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:k.name}),n.jsx("div",{className:"text-sm text-gray-400",children:k.email})]})]}),n.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this user? This action cannot be undone."})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>f(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:B,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),g&&k&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"User Details"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:k.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${k.id}`,alt:k.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:k.name}),n.jsx("div",{className:"text-sm text-gray-400",children:k.email})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"ID:"}),n.jsx("span",{className:"text-white text-sm",children:k.id})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Email Verified:"}),n.jsx("span",{className:"text-white text-sm",children:k.emailVerified?"Yes":"No"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Created:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(k.createdAt).toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Updated:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(k.updatedAt).toLocaleString()})]})]})]}),n.jsx("div",{className:"flex justify-end mt-6",children:n.jsx(T,{onClick:()=>N(!1),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Close"})})]})})]})}function Pb(){const[e,t]=h.useState("overview"),r=()=>n.jsxs("div",{className:"space-y-8 animate-fade-in px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-normal",children:"Better Auth Studio"}),n.jsx("p",{className:"text-gray-400 mt-1 font-light",children:"Manage your authentication system"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(he,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Active"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"User Management"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"Manage user accounts, profiles, and permissions"}),n.jsxs(T,{onClick:()=>t("users"),className:"w-full bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:["Manage Users",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(Le,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Active"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Organizations"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"Manage organizations, teams, and memberships"}),n.jsxs(T,{onClick:()=>t("organizations"),className:"w-full bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:["Manage Organizations",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(ts,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Configured"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Configuration"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"View and manage auth configuration"}),n.jsxs(T,{variant:"outline",className:"w-full border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:["View Config",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(Ko,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Coming Soon"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Analytics"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"View authentication analytics and insights"}),n.jsxs(T,{variant:"outline",disabled:!0,className:"w-full border border-dashed border-white/20 text-gray-400 rounded-none",children:["View Analytics",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(ui,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Available"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Quick Actions"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"Common tasks and shortcuts"}),n.jsxs(T,{variant:"outline",className:"w-full border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:["View Actions",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})})]})]});return n.jsx("div",{className:"min-h-screen bg-black text-white",children:e==="overview"?r():e==="users"?n.jsx(bx,{}):e==="organizations"?n.jsx(wx,{}):r()})}function zb(){const{orgId:e}=Xc(),t=En(),[r,s]=h.useState(null),[a,i]=h.useState([]),[l,o]=h.useState([]),[c,d]=h.useState([]),[m,u]=h.useState(!0),[p,y]=h.useState("details"),[w,v]=h.useState(!1),[j,x]=h.useState(!1),[f,g]=h.useState(!1),[N,C]=h.useState(!1),[P,k]=h.useState(!1),[R,J]=h.useState(!1),[W,q]=h.useState(!1),[Y,te]=h.useState(!1),[ee,ie]=h.useState(null),[X,_]=h.useState(""),[S,O]=h.useState(""),[B,z]=h.useState([]),[b,E]=h.useState({name:""}),[L,M]=h.useState(!1),[A,K]=h.useState([]),[$,Z]=h.useState(!1),[de,we]=h.useState([]),[ge,Ne]=h.useState(!1);h.useEffect(()=>{e&&(Gt(),lr(),ir(),Ye(),Ot(),Lt())},[e]),h.useEffect(()=>{w&&e&&Lt()},[]),h.useEffect(()=>{p==="members"&&e&&Ot()},[p,e]),h.useEffect(()=>{p==="invitations"&&e&&Ye()},[p,e]);const ve=I=>{E({name:I})},Gt=async()=>{try{const G=await(await fetch(`/api/organizations/${e}`)).json();G.success&&G.organization||G.organization?s(G.organization):D.error("Organization not found")}catch(I){console.error("Failed to fetch organization:",I),D.error("Failed to load organization")}finally{u(!1)}},ir=async()=>{try{const G=await(await fetch("/api/plugins/teams/status")).json();v(G.organizationPlugin.options.teams.enabled)}catch(I){console.error("Failed to check teams status:",I),v(!1)}},lr=async()=>{try{const G=await(await fetch("/api/plugins/organization/status")).json();x(G.enabled)}catch(I){console.error("Failed to check organization status:",I),x(!1)}},Lt=async()=>{try{const G=await(await fetch(`/api/organizations/${e}/teams`)).json();G.success&&i(G.teams||[])}catch(I){console.error("Failed to fetch teams:",I),D.error("Failed to load teams")}},Ye=async()=>{try{const G=await(await fetch(`/api/organizations/${e}/invitations`)).json();G.success&&o(G.invitations||[])}catch(I){console.error("Failed to fetch invitations:",I),D.error("Failed to load invitations")}},Ot=async()=>{try{const G=await(await fetch(`/api/organizations/${e}/members`)).json();G.success&&d(G.members||[])}catch(I){console.error("Failed to fetch members:",I),D.error("Failed to load members")}},bs=async I=>{K([]),Z(!0),K([{id:"start",type:"info",message:`Starting member seeding process for ${I} members...`,timestamp:new Date}]);try{const ne=await(await fetch(`/api/organizations/${e}/seed-members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:I})})).json();if(ne.success){const We=ne.results.map((fe,or)=>fe.success?{id:`member-${or}`,type:"progress",message:`Adding member: ${fe.member.user.name} (${fe.member.user.email})`,timestamp:new Date,status:"completed"}:{id:`member-${or}`,type:"error",message:`Failed to add member ${or+1}: ${fe.error}`,timestamp:new Date});K(fe=>[...fe,...We]);const it=ne.results.filter(fe=>fe.success).length;K(fe=>[...fe,{id:"complete",type:"success",message:`✅ Seeding completed! Added ${it}/${I} members successfully`,timestamp:new Date}]),await Ot(),D.success(`Successfully added ${it} members!`)}else K(We=>[...We,{id:"error",type:"error",message:`❌ Seeding failed: ${ne.error||"Unknown error"}`,timestamp:new Date}]),D.error(ne.error||"Failed to seed members")}catch(G){K(ne=>[...ne,{id:"error",type:"error",message:`❌ Network error: ${G}`,timestamp:new Date}]),D.error("Failed to seed members")}finally{Z(!1)}},$e=async I=>{we([]),Ne(!0),we([{id:"start",type:"info",message:`Starting team seeding process for ${I} teams...`,timestamp:new Date}]);try{const ne=await(await fetch(`/api/organizations/${e}/seed-teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:I})})).json();if(ne.success){const We=ne.results.map((fe,or)=>fe.success?{id:`team-${or}`,type:"progress",message:`Creating team: ${fe.team.name}`,timestamp:new Date,status:"completed"}:{id:`team-${or}`,type:"error",message:`Failed to create team ${or+1}: ${fe.error}`,timestamp:new Date});we(fe=>[...fe,...We]);const it=ne.results.filter(fe=>fe.success).length;we(fe=>[...fe,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${it}/${I} teams successfully`,timestamp:new Date}]),await Lt(),D.success(`Successfully created ${it} teams!`)}else we(We=>[...We,{id:"error",type:"error",message:`❌ Seeding failed: ${ne.error||"Unknown error"}`,timestamp:new Date}]),D.error(ne.error||"Failed to seed teams")}catch(G){we(ne=>[...ne,{id:"error",type:"error",message:`❌ Network error: ${G}`,timestamp:new Date}]),D.error("Failed to seed teams")}finally{Ne(!1)}},At=async()=>{try{const G=await(await fetch("/api/users/all")).json();G.success&&z(G.users||[])}catch(I){console.error("Failed to fetch users:",I)}},rn=()=>{At(),g(!0)},js=async()=>{if(!X){D.error("Please enter an email address");return}if(!S){D.error("Please select an inviter");return}M(!0);const I=D.loading("Sending invitation...");try{const ne=await(await fetch(`/api/organizations/${e}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:X,role:"member",inviterId:S})})).json();ne.success?(await Ye(),g(!1),_(""),O(""),D.success("Invitation sent successfully!",{id:I})):D.error(`Error sending invitation: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error sending invitation:",G),D.error("Error sending invitation",{id:I})}finally{M(!1)}},F=async I=>{const G=D.loading("Cancelling invitation...");try{const We=await(await fetch(`/api/invitations/${I}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();We.success?(await Ye(),D.success("Invitation cancelled successfully!",{id:G})):D.error(`Error cancelling invitation: ${We.error||"Unknown error"}`,{id:G})}catch(ne){console.error("Error cancelling invitation:",ne),D.error("Error cancelling invitation",{id:G})}},Q=async(I,G)=>{const ne=D.loading("Resending invitation...");try{const it=await(await fetch(`/api/invitations/${I}/resend`,{method:"POST",headers:{"Content-Type":"application/json"}})).json();it.success?(await Ye(),D.success(`Invitation resent to ${G}!`,{id:ne})):D.error(`Error resending invitation: ${it.error||"Unknown error"}`,{id:ne})}catch(We){console.error("Error resending invitation:",We),D.error("Error resending invitation",{id:ne})}},oe=async(I,G)=>{const ne=D.loading(`Removing ${G}...`);try{const it=await(await fetch(`/api/members/${I}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();it.success?(await Ot(),D.success(`${G} removed from organization!`,{id:ne})):D.error(`Error removing member: ${it.error||"Unknown error"}`,{id:ne})}catch(We){console.error("Error removing member:",We),D.error("Error removing member",{id:ne})}},Ee=async()=>{if(!b.name){D.error("Please enter a team name");return}const I=D.loading("Creating team...");try{const ne=await(await fetch(`/api/organizations/${e}/teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,organizationId:e})})).json();ne.success?(await Lt(),J(!1),E({name:""}),D.success("Team created successfully!",{id:I})):D.error(`Error creating team: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error creating team:",G),D.error("Error creating team",{id:I})}},Fe=async()=>{if(!ee||!b.name){D.error("Please enter a team name");return}const I=D.loading("Updating team...");try{const ne=await(await fetch(`/api/teams/${ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name})})).json();ne.success?(await Lt(),q(!1),ie(null),E({name:""}),D.success("Team updated successfully!",{id:I})):D.error(`Error updating team: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error updating team:",G),D.error("Error updating team",{id:I})}},ye=async()=>{if(!ee){D.error("No team selected");return}const I=D.loading("Deleting team...");try{const ne=await(await fetch(`/api/teams/${ee.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();ne.success?(await Lt(),te(!1),ie(null),D.success("Team deleted successfully!",{id:I})):D.error(`Error deleting team: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error deleting team:",G),D.error("Error deleting team",{id:I})}},Te=I=>{ie(I),E({name:I.name}),q(!0)},Ns=I=>{ie(I),te(!0)};return m?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading organization details..."})]})}):r?n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:"/organizations",children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:()=>C(!0),className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[n.jsx(he,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),n.jsxs(T,{onClick:rn,className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[n.jsx(Et,{className:"w-4 h-4 mr-2"}),"Invite User"]}),n.jsxs(T,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(wn,{className:"w-4 h-4 mr-2"}),"Edit Organization"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(Le,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-light",children:r.name}),n.jsx("p",{className:"text-gray-400",children:r.slug})]})]}),n.jsx("div",{className:"border-b border-white/10",children:n.jsxs("nav",{className:"flex space-x-8",children:[n.jsxs("button",{onClick:()=>y("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(Le,{className:"w-4 h-4"}),n.jsx("span",{children:"Details"}),n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length+l.length+a.length})]}),n.jsxs("button",{onClick:()=>y("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Members"}),c.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length})]}),n.jsxs("button",{onClick:()=>y("invitations"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="invitations"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(Et,{className:"w-4 h-4"}),n.jsx("span",{children:"Invitations"}),l.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:l.length})]}),n.jsxs("button",{onClick:()=>y("teams"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="teams"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Teams"}),a.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:a.length})]})]})}),p==="details"&&n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[n.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Organization Information"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx("p",{className:"text-white mt-1",children:r.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Slug"}),n.jsx("p",{className:"text-white mt-1",children:r.slug})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Last Updated"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.updatedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:c.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:a.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Teams"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Et,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:l.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Invitations"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx($i,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(r.createdAt).getTime())/(1e3*60*60*24))}),n.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})})]})]}),p==="teams"&&n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Teams (",a.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage teams within this organization"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:()=>k(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Teams"]}),n.jsxs(T,{onClick:()=>J(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]})]}),w?a.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Team"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Members"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:a.map(I=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>t(`/organizations/${e}/teams/${I.id}`),children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:I.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",I.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:I.memberCount||0}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(I.createdAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:G=>{G.stopPropagation(),Te(I)},children:[n.jsx(wn,{className:"w-4 h-4 mr-1"}),"Edit"]}),n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:G=>{G.stopPropagation(),Ns(I)},children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Delete"]})]})})]},I.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Teams Yet"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Create your first team to start organizing members within this organization."}),n.jsxs(T,{onClick:()=>J(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Create First Team"]})]})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:n.jsxs("div",{className:"flex items-start space-x-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx(he,{className:"w-12 h-12 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Teams Feature Required"}),n.jsx("p",{className:"text-gray-300 mb-6",children:"To use Teams in Better Auth Studio, you need to enable the teams feature in your organization plugin configuration."}),n.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[n.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),n.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:n.jsx("li",{children:"Update your auth configuration file to enable teams:"})}),n.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:n.jsxs("pre",{className:"text-sm text-gray-300",children:[n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"export const"})," ",n.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",n.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",n.jsx("br",{}),n.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",n.jsx("br",{}),n.jsx("span",{className:"text-yellow-300 pl-12",children:"organization"}),"(","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-red-300 pl-16",children:"teams"}),": ","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-yellow-300 pl-20",children:"enabled"}),":"," ",n.jsx("span",{className:"text-blue-400",children:"true"})," ",n.jsx("br",{}),n.jsx("span",{className:"pl-16",children:"}"})," ",n.jsx("br",{}),n.jsx("span",{className:"pl-12",children:"})"})," ",n.jsx("br",{}),n.jsx("span",{className:"pl-10",children:"]"})," ",n.jsx("br",{}),"}",") ",n.jsx("br",{})]})}),n.jsx("div",{className:"mt-4",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"2. Run migrations to create the teams table"})}),n.jsx("div",{className:"mt-2",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),n.jsx(T,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),n.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",n.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]}),p==="members"&&n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Members (",c.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage organization members and their roles"})]})}),c.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:c.map(I=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:I.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${I.user.id}`,alt:I.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:I.user.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",I.user.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:I.user.email}),n.jsx("td",{className:"py-4 px-4",children:n.jsx(le,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed rounded-none border-blue-500/30 text-blue-400/70 capitalize",children:I.role})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(I.joinedAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsx("div",{className:"flex items-center justify-end space-x-2",children:n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>oe(I.id,I.user.name),children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},I.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Invite users or seed members from existing users to get started."}),n.jsxs("div",{className:"flex items-center justify-center space-x-3",children:[n.jsxs(T,{onClick:()=>C(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(he,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),n.jsxs(T,{onClick:rn,className:"bg-white text-white hover:bg-white/90 bg-transparent border border-white/20 rounded-none",children:[n.jsx(Et,{className:"w-4 h-4 mr-2"}),"Invite User"]})]})]})})]}),p==="invitations"&&n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Invitations (",l.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage pending invitations to this organization"})]})}),l.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:l.map(I=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(Et,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:I.email}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Expires on"," ",new Date(I.expiresAt).toLocaleDateString("en-US",{month:"short",year:"numeric",day:"numeric"})]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white capitalize",children:I.role}),n.jsx("td",{className:"py-4 px-4",children:n.jsxs(le,{variant:"secondary",className:`text-xs font-normal rounded-none border-dashed flex items-center gap-1 w-fit ${I.status==="pending"?"bg-yellow-900/10 border border-yellow-500/30 text-yellow-400/70":I.status==="accepted"?"bg-green-900/10 border border-green-500/30 text-green-400/70":"bg-red-900/10 border border-red-500/30 text-red-400/70"}`,children:[I.status==="pending"&&n.jsx(pr,{className:"w-3 h-3"}),I.status==="accepted"&&n.jsx(Ue,{className:"w-3 h-3"}),I.status==="expired"&&n.jsx(be,{className:"w-3 h-3"}),I.status]})}),n.jsxs("td",{className:"py-4 px-4 text-sm text-gray-400",children:[new Date(I.expiresAt).toLocaleDateString(),n.jsx("br",{}),n.jsx("span",{className:"text-xs text-gray-400",children:new Date(I.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>Q(I.id,I.email),children:[n.jsx(zu,{className:"w-4 h-4 mr-1"}),"Resend"]}),n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>F(I.id),children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Cancel"]})]})})]},I.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(Et,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Invitations"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Start inviting users to join this organization."}),n.jsxs(T,{onClick:rn,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Et,{className:"w-4 h-4 mr-2"}),"Send First Invitation"]})]})})]}),f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Invite User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{g(!1),_(""),O("")},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"invite-email",className:"text-sm text-gray-400 font-light",children:"Email Address"}),n.jsx(me,{id:"invite-email",type:"email",value:X,onChange:I=>_(I.target.value),placeholder:"user@example.com",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"inviter-select",className:"text-sm text-gray-400 font-light",children:"Inviter"}),n.jsxs(hs,{value:S,onValueChange:O,children:[n.jsx(ms,{children:n.jsx(fs,{placeholder:"Select an inviter..."})}),n.jsx(xs,{children:B.map(I=>n.jsx(Dt,{value:I.id,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("img",{src:I.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${I.id}`,alt:I.name,className:"w-6 h-6 rounded-none border border-dashed border-white/20"}),n.jsxs("span",{children:[I.name," (",I.email,")"]})]})},I.id))})]})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{g(!1),_(""),O("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsxs(T,{onClick:js,disabled:L,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[L?n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}):n.jsx(zu,{className:"w-4 h-4 mr-2"}),L?"Sending...":"Send Invitation"]})]})]})}),R&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{J(!1),E({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),n.jsx(me,{id:"team-name",value:b.name,onChange:I=>ve(I.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{J(!1),E({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:Ee,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create Team"})]})]})}),W&&ee&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{q(!1),E({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:ee.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",ee.id]})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),n.jsx(me,{id:"edit-team-name",value:b.name,onChange:I=>ve(I.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{q(!1),E({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:Fe,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})}),Y&&ee&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>te(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:ee.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",ee.id]})]})]}),n.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this team? This action cannot be undone."})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>te(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:ye,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete Team"})]})]})}),N&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Members"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>C(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Add Members from Existing Users"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"member-count",className:"text-sm text-gray-400 font-light",children:"Number of members to add"}),n.jsx(me,{id:"member-count",type:"number",min:"1",max:"50",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var G;const I=parseInt(((G=document.getElementById("member-count"))==null?void 0:G.value)||"5");bs(I)},disabled:$,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:$?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(he,{className:"w-3 h-3 mr-2"}),"Seed Members"]})})]})]}),A.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Member Seeding Terminal",lines:A,isRunning:$,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>C(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),P&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Teams"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>k(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Le,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Create Teams"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"team-count",className:"text-sm text-gray-400 font-light",children:"Number of teams to create"}),n.jsx(me,{id:"team-count",type:"number",min:"1",max:"20",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var G;const I=parseInt(((G=document.getElementById("team-count"))==null?void 0:G.value)||"3");$e(I)},disabled:ge,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:ge?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Le,{className:"w-3 h-3 mr-2"}),"Seed Teams"]})})]})]}),de.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Team Seeding Terminal",lines:de,isRunning:ge,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>k(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})})]}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:"/organizations",children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),n.jsx("br",{}),n.jsxs("div",{className:"text-center py-12",children:[n.jsx(Le,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Organization Not Found"}),n.jsx("p",{className:"text-gray-400",children:"The organization you're looking for doesn't exist."})]})]})}function Db(){const[e,t]=h.useState([]),[r,s]=h.useState(!0),[a,i]=h.useState(""),[l,o]=h.useState("all"),[c,d]=h.useState(!1),[m,u]=h.useState(!1),[p,y]=h.useState(!1),[w,v]=h.useState(!1),[j,x]=h.useState(!1),[f,g]=h.useState(null),[N,C]=h.useState([]),[P,k]=h.useState(!1);h.useEffect(()=>{R()},[]);const R=async()=>{try{const O=await(await fetch("/api/sessions")).json();t(O.sessions||[])}catch(S){console.error("Failed to fetch sessions:",S)}finally{s(!1)}},J=async S=>{C([]),k(!0),C([{id:"start",type:"info",message:`Starting session seeding process for ${S} sessions...`,timestamp:new Date}]);try{const B=await(await fetch("/api/seed/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:S})})).json();if(B.success){const z=B.results.map((E,L)=>E.success?{id:`session-${L}`,type:"progress",message:`Creating session: ${E.session.id}`,timestamp:new Date,status:"completed"}:{id:`session-${L}`,type:"error",message:`Failed to create session ${L+1}: ${E.error}`,timestamp:new Date});C(E=>[...E,...z]);const b=B.results.filter(E=>E.success).length;C(E=>[...E,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${b}/${S} sessions successfully`,timestamp:new Date}]),await R()}else C(z=>[...z,{id:"error",type:"error",message:`❌ Seeding failed: ${B.error||"Unknown error"}`,timestamp:new Date}])}catch(O){C(B=>[...B,{id:"error",type:"error",message:`❌ Network error: ${O}`,timestamp:new Date}])}finally{k(!1)}},W=async S=>{C([]),k(!0),C([{id:"start",type:"info",message:`Starting account seeding process for ${S} accounts...`,timestamp:new Date}]);try{const B=await(await fetch("/api/seed/accounts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:S})})).json();if(B.success){const z=B.results.map((E,L)=>E.success?{id:`account-${L}`,type:"progress",message:`Creating account: ${E.account.provider}`,timestamp:new Date,status:"completed"}:{id:`account-${L}`,type:"error",message:`Failed to create account ${L+1}: ${E.error}`,timestamp:new Date});C(E=>[...E,...z]);const b=B.results.filter(E=>E.success).length;C(E=>[...E,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${b}/${S} accounts successfully`,timestamp:new Date}]),await R()}else C(z=>[...z,{id:"error",type:"error",message:`❌ Seeding failed: ${B.error||"Unknown error"}`,timestamp:new Date}])}catch(O){C(B=>[...B,{id:"error",type:"error",message:`❌ Network error: ${O}`,timestamp:new Date}])}finally{k(!1)}},q=S=>{g(S),v(!0)},Y=S=>{g(S),u(!0)},te=S=>{g(S),y(!0)},ee=async S=>{console.log("Creating session:",S),d(!1)},ie=async S=>{console.log("Updating session:",S),u(!1)},X=async()=>{console.log("Deleting session:",f==null?void 0:f.id),y(!1)},_=e.filter(S=>{const O=S.id.toLowerCase().includes(a.toLowerCase())||S.userId.toLowerCase().includes(a.toLowerCase()),B=l==="all"||l==="active"&&new Date(S.expiresAt)>new Date||l==="expired"&&new Date(S.expiresAt)<=new Date;return O&&B});return r?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading sessions..."})]})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl text-white font-light",children:["Sessions (",e.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage user sessions and accounts"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>x(!0),children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed"]}),n.jsxs(T,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>d(!0),children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Add Session"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{placeholder:"Search sessions...",value:a,onChange:S=>i(S.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Jc,{className:"w-4 h-4 text-gray-400"}),n.jsxs(hs,{value:l,onValueChange:o,children:[n.jsx(ms,{children:n.jsx(fs,{})}),n.jsxs(xs,{children:[n.jsx(Dt,{value:"all",children:"All"}),n.jsx(Dt,{value:"active",children:"Active"}),n.jsx(Dt,{value:"expired",children:"Expired"})]})]})]})]}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Session"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User ID"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:_.map(S=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",S.id.slice(0,8),"..."]}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",S.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:S.userId}),n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-2",children:[new Date(S.expiresAt)>new Date?n.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}):n.jsx("div",{className:"w-2 h-2 bg-red-400 rounded-full"}),n.jsx("span",{className:"text-sm text-gray-400",children:new Date(S.expiresAt)>new Date?"Active":"Expired"})]})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(S.expiresAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>q(S),children:n.jsx(sl,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>Y(S),children:n.jsx(wn,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:()=>te(S),children:n.jsx(fn,{className:"w-4 h-4"})})]})})]},S.id))})]})})}),j&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Data"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>x(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Sessions"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),n.jsx(me,{id:"session-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var O;const S=parseInt(((O=document.getElementById("session-count"))==null?void 0:O.value)||"5");J(S)},disabled:P,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:P?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-3 h-3 mr-2"}),"Seed Sessions"]})})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Xs,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Accounts"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"account-count",className:"text-sm text-gray-400 font-light",children:"Number of accounts"}),n.jsx(me,{id:"account-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var O;const S=parseInt(((O=document.getElementById("account-count"))==null?void 0:O.value)||"5");W(S)},disabled:P,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:P?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Xs,{className:"w-3 h-3 mr-2"}),"Seed Accounts"]})})]})]}),N.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Session Seeding Terminal",lines:N,isRunning:P,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),c&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create Session"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>d(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),n.jsx(me,{id:"create-user-id",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),n.jsx(me,{id:"create-expires",type:"datetime-local",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>d(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:()=>ee({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),m&&f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Session"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>u(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",f.id.slice(0,8),"..."]}),n.jsx("div",{className:"text-sm text-gray-400",children:f.userId})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),n.jsx(me,{id:"edit-user-id",defaultValue:f.userId,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),n.jsx(me,{id:"edit-expires",type:"datetime-local",defaultValue:new Date(f.expiresAt).toISOString().slice(0,16),className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>u(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:()=>ie({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),p&&f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Session"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",f.id.slice(0,8),"..."]}),n.jsx("div",{className:"text-sm text-gray-400",children:f.userId})]})]}),n.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this session? This action cannot be undone."})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>y(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:X,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),w&&f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Session Details"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>v(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",f.id.slice(0,8),"..."]}),n.jsx("div",{className:"text-sm text-gray-400",children:f.userId})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"ID:"}),n.jsx("span",{className:"text-white text-sm",children:f.id})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"User ID:"}),n.jsx("span",{className:"text-white text-sm",children:f.userId})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Status:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.expiresAt)>new Date?"Active":"Expired"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Expires:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.expiresAt).toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Created:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.createdAt).toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Updated:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.updatedAt).toLocaleString()})]})]})]}),n.jsx("div",{className:"flex justify-end mt-6",children:n.jsx(T,{onClick:()=>v(!1),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Close"})})]})})]})}function Rb(e){const t=h.useRef(null),r=h.useRef(null),s=h.useRef(0),a=5;h.useEffect(()=>{const i=()=>{try{const o=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`;console.log("🔌 Attempting to connect to WebSocket:",o),t.current=new WebSocket(o),t.current.onopen=()=>{console.log("✅ WebSocket connected successfully"),s.current=0,r.current&&(clearTimeout(r.current),r.current=null)},t.current.onmessage=c=>{try{const d=JSON.parse(c.data);console.log("📨 WebSocket message received:",d),e(d)}catch(d){console.error("❌ Failed to parse WebSocket message:",d)}},t.current.onclose=c=>{if(console.log("🔌 WebSocket disconnected:",c.code,c.reason),c.code===1006||c.code===1001){console.log("ℹ️ WebSocket server not available (running in normal mode)");return}if(s.current<a){s.current++;const d=Math.min(1e3*2**s.current,1e4);console.log(`🔄 Attempting to reconnect in ${d}ms (attempt ${s.current}/${a})`),r.current=setTimeout(()=>{i()},d)}else console.log("❌ Max reconnection attempts reached")},t.current.onerror=c=>{console.error("❌ WebSocket error:",c)}}catch(l){console.error("❌ Failed to connect WebSocket:",l)}};return i(),()=>{t.current&&t.current.close(),r.current&&clearTimeout(r.current)}},[e])}function Mb(){var v,j,x,f,g,N,C,P,k,R,J,W,q,Y,te,ee,ie,X,_,S,O,B,z,b,E,L,M;const[e,t]=h.useState(null),[r,s]=h.useState(null),[a,i]=h.useState(null),[l,o]=h.useState(!0),[c,d]=h.useState(null);Rb(A=>{A.type==="config_changed"?(console.log("🔄 Config changed, refreshing data..."),setTimeout(()=>{m(),u(),p()},500)):A.type==="connected"&&console.log("✅ Connected to Better Auth Studio WebSocket")}),h.useEffect(()=>{m(),u(),p()},[]);const m=async()=>{var A;try{const $=await(await fetch("/api/config")).json();(A=$.studio)!=null&&A.version&&d(`v${$.studio.version}`),t($)}catch(K){console.error("Failed to fetch config:",K)}finally{o(!1)}},u=async()=>{try{const K=await(await fetch("/api/health")).json();s(K.system||{studioVersion:c||"v1.0.0",nodeVersion:process.version,platform:navigator.platform,uptime:"2h 15m"})}catch(A){console.error("Failed to fetch system info:",A),s({studioVersion:c||"v1.0.0",nodeVersion:"v18.0.0",platform:"macOS",uptime:"2h 15m"})}},p=async()=>{try{const K=await(await fetch("/api/plugins")).json();i(K)}catch(A){console.error("Failed to fetch plugins:",A),i({plugins:[],configPath:null,totalPlugins:0,error:"Failed to fetch plugins"})}},y=A=>{switch(A==null?void 0:A.toLowerCase()){case"postgresql":case"postgres":return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(Ue,{className:"w-3 h-3"}),"Connected"]});case"mysql":return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(Ue,{className:"w-3 h-3"}),"Connected"]});case"sqlite":return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(Rs,{className:"w-3 h-3"}),"Local"]});default:return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(cr,{className:"w-3 h-3"}),"Unknown"]})}},w=A=>{switch(A.toLowerCase()){case"google":return n.jsx(ln,{className:"w-5 h-5 text-white"});case"github":return n.jsx(dr,{className:"w-5 h-5 text-white"});case"discord":return n.jsx(ln,{className:"w-5 h-5 text-white"});case"twitter":return n.jsx(ln,{className:"w-5 h-5 text-white"});default:return n.jsx(ln,{className:"w-5 h-5 text-white"})}};return l?n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-white"})}):n.jsxs("div",{className:"space-y-8 animate-fade-in",children:[n.jsx("div",{className:"flex items-center justify-between p-5 pt-7",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-normal text-white tracking-tight",children:"Settings"}),n.jsx("p",{className:"text-gray-300 mt-2",children:"Configure your Better Auth application"})]})}),n.jsx("hr",{className:"w-full border-white/15 h-px"}),n.jsx("hr",{className:"w-full border-white/15 h-px"}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 p-5",children:[n.jsxs(ot,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[n.jsxs(qt,{children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(ts,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Application"})]}),n.jsx(er,{children:"Basic application configuration"})]}),n.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),n.jsxs(ct,{className:"space-y-0 px-0 pb-0 border-b-none",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ln,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"App Name"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Application display name"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.appName)||"Better Auth"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(z0,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Base URL"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Application base URL"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.baseURL)||"http://localhost:3000"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ol,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Base Path"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Auth API base path"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.basePath)||"/api/auth"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Secret"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Encryption secret"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.secret)==="Configured"?"Configured":"Not set"})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[n.jsxs(qt,{children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Database"})]}),n.jsx(er,{children:"Database connection and configuration"})]}),n.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),n.jsxs(ct,{className:"space-y-0 px-0 pb-0 border-b-none",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:((v=e==null?void 0:e.database)==null?void 0:v.type)&&((j=e==null?void 0:e.database)==null?void 0:j.type.charAt(0).toUpperCase())+((x=e==null?void 0:e.database)==null?void 0:x.type.slice(1))||"Unknown"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Database Type"})]})]}),((f=e==null?void 0:e.database)==null?void 0:f.type)&&y(e.database.type)]}),((g=e==null?void 0:e.database)==null?void 0:g.dialect)&&n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Dialect"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Database dialect"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:e.database.dialect})})]}),((N=e==null?void 0:e.database)==null?void 0:N.casing)&&n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ts,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Casing"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Table name casing"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white capitalize",children:e.database.casing})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Pu,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Debug Logs"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Database debug logging"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(C=e==null?void 0:e.database)!=null&&C.debugLogs?n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Providers"})]}),n.jsx(er,{children:"Configured authentication providers"})]}),n.jsx(ct,{className:"p-0",children:e!=null&&e.socialProviders&&e.socialProviders.length>0?e.socialProviders.map((A,K)=>n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[w(A.type),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white capitalize",children:A.type}),n.jsx("p",{className:"text-xs text-gray-400",children:A.clientId?"Configured":"Not configured"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:A.clientId?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Active"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Setup Required"]})})]},K)):n.jsxs("div",{className:"text-center py-8",children:[n.jsx(dr,{className:"w-8 h-8 text-white mx-auto mb-2"}),n.jsx("p",{className:"text-sm text-gray-400",children:"No providers configured"})]})})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Et,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Email & Password"})]}),n.jsx(er,{children:"Email authentication settings"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Et,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Email Authentication"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Allow users to sign up with email"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(P=e==null?void 0:e.emailAndPassword)!=null&&P.enabled?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]})})]}),((k=e==null?void 0:e.emailAndPassword)==null?void 0:k.enabled)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Sign Up"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Allow new user registration"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(R=e==null?void 0:e.emailAndPassword)!=null&&R.disableSignUp?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Email Verification"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Require email verification"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(J=e==null?void 0:e.emailAndPassword)!=null&&J.requireEmailVerification?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Required"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Optional"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ol,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Password Length"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Min/Max password length"})]})]}),n.jsx("div",{className:"text-right",children:n.jsxs("p",{className:"text-sm font-medium text-white",children:[((W=e==null?void 0:e.emailAndPassword)==null?void 0:W.minPasswordLength)||8," -"," ",((q=e==null?void 0:e.emailAndPassword)==null?void 0:q.maxPasswordLength)||128]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ui,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Auto Sign In"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Auto sign in after registration"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(Y=e==null?void 0:e.emailAndPassword)!=null&&Y.autoSignIn?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Disabled"]})})]})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Session"})]}),n.jsx(er,{children:"Session management settings"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Session Duration"}),n.jsx("p",{className:"text-xs text-gray-400",children:"How long sessions last"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(te=e==null?void 0:e.session)!=null&&te.expiresIn?`${Math.floor(e.session.expiresIn/(60*60*24))} days`:"7 days"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Default"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Pu,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Update Age"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Session refresh interval"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:(ee=e==null?void 0:e.session)!=null&&ee.updateAge?`${Math.floor(e.session.updateAge/(60*60))} hours`:"24 hours"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ui,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Session Refresh"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Auto refresh sessions"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(ie=e==null?void 0:e.session)!=null&&ie.disableSessionRefresh?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Store in Database"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Store sessions in database"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(X=e==null?void 0:e.session)!=null&&X.storeSessionInDatabase?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Rs,{className:"w-3 h-3"}),"Secondary Storage"]})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Rate Limiting"})]}),n.jsx(er,{children:"API rate limiting configuration"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limiting"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Enable rate limiting"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(_=e==null?void 0:e.rateLimit)!=null&&_.enabled?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Disabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(pr,{className:"w-5 h-5 text-red-400"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limit Window"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Time window for rate limiting"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(S=e==null?void 0:e.rateLimit)!=null&&S.window?`${e.rateLimit.window} seconds`:"10 seconds"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Window"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Max Requests"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Maximum requests per window"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:((O=e==null?void 0:e.rateLimit)==null?void 0:O.max)||100}),n.jsx("p",{className:"text-xs text-gray-400",children:"Requests"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Storage"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Rate limit storage type"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white capitalize",children:((B=e==null?void 0:e.rateLimit)==null?void 0:B.storage)||"memory"})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(ts,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Advanced"})]}),n.jsx(er,{children:"Advanced configuration options"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ol,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Secure Cookies"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Use secure cookies"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(z=e==null?void 0:e.advanced)!=null&&z.useSecureCookies?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Disabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"CSRF Check"}),n.jsx("p",{className:"text-xs text-gray-400",children:"CSRF protection"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(b=e==null?void 0:e.advanced)!=null&&b.disableCSRFCheck?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(sl,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"IP Tracking"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Track IP addresses"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(L=(E=e==null?void 0:e.advanced)==null?void 0:E.ipAddress)!=null&&L.disableIpTracking?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(S0,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Telemetry"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Usage analytics"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(M=e==null?void 0:e.telemetry)!=null&&M.enabled?n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Rs,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"System Info"})]}),n.jsx(er,{children:"Better Auth Studio system information"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ui,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Studio Version"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Better Auth Studio"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:c||"v1.0.0"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Latest"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Rs,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Node.js Version"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Runtime environment"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(r==null?void 0:r.nodeVersion)||"v18.0.0"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Current"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ln,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Platform"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Operating system"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(r==null?void 0:r.platform)||"macOS"}),n.jsx("p",{className:"text-xs text-gray-400",children:"System"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Uptime"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Service uptime"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(r==null?void 0:r.uptime)||"2h 15m"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Running"})]})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none lg:col-span-2",children:[n.jsxs(qt,{children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Tu,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Plugins"})]}),n.jsx(er,{children:"Better Auth plugins enabled in your configuration"})]}),n.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),n.jsx(ct,{className:"space-y-0 px-0 pb-0 border-b-none",children:a!=null&&a.plugins&&a.plugins.length>0?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Rs,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Total Plugins"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Currently enabled plugins"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:a.totalPlugins}),n.jsx("p",{className:"text-xs text-gray-400",children:"Active"})]})]}),a.plugins.map((A,K)=>n.jsxs("div",{className:`flex items-center justify-between p-4 px-5 ${K<a.plugins.length-1?"border-b border-white/15":""}`,children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Tu,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:A.name}),n.jsx("p",{className:"text-xs text-gray-400",children:A.description})]})]}),n.jsx("div",{className:"text-right flex items-center space-x-2",children:n.jsxs(le,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400 flex items-center gap-1",children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]},A.id)),a.configPath&&n.jsx("div",{className:"p-4 px-5 bg-black/30 border-t border-white/10",children:n.jsxs("p",{className:"text-xs text-gray-400",children:["Config file:"," ",n.jsx("span",{className:"text-white font-mono",children:a.configPath})]})})]}):n.jsxs("div",{className:"flex items-center justify-between p-4 px-5",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(cr,{className:"w-5 h-5 text-yellow-400"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"No Plugins Enabled"}),n.jsx("p",{className:"text-xs text-gray-400",children:(a==null?void 0:a.error)||"No plugins are currently configured in your Better Auth setup"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs bg-yellow-900/50 border border-yellow-500/30 text-yellow-400 rounded-sm",children:"None"})]})})]})]})]})}function qu(){var ie,X;const{orgId:e,teamId:t}=Xc(),[r,s]=h.useState(null),[a,i]=h.useState([]),[l,o]=h.useState(!0),[c,d]=h.useState("details"),[m,u]=h.useState(!1),[p,y]=h.useState(!1),[w,v]=h.useState(""),[j,x]=h.useState([]),[f,g]=h.useState([]),[N,C]=h.useState({name:""});h.useEffect(()=>{t&&(P(),k())},[t]);const P=async()=>{try{const S=await(await fetch(`/api/teams/${t}`)).json();S.success&&S.team?(s(S.team),C({name:S.team.name})):S.team?(s(S.team),C({name:S.team.name})):D.error("Team not found")}catch(_){console.error("Failed to fetch team:",_),D.error("Failed to load team")}finally{o(!1)}},k=async()=>{try{const S=await(await fetch(`/api/teams/${t}/members`)).json();S.success&&i(S.members||[])}catch(_){console.error("Failed to fetch team members:",_),D.error("Failed to load team members")}},R=async()=>{try{const S=await(await fetch("/api/users?limit=10000")).json(),O=a.map(z=>z.userId),B=(S.users||[]).filter(z=>!O.includes(z.id));x(B)}catch(_){console.error("Failed to fetch available users:",_),D.error("Failed to load users")}},J=async()=>{if(!N.name){D.error("Please enter a team name");return}const _=D.loading("Updating team...");try{const O=await(await fetch(`/api/teams/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N.name})})).json();O.success?(await P(),y(!1),D.success("Team updated successfully!",{id:_})):D.error(`Error updating team: ${O.error||"Unknown error"}`,{id:_})}catch(S){console.error("Error updating team:",S),D.error("Error updating team",{id:_})}},W=async()=>{if(f.length===0){D.error("Please select at least one user");return}const _=D.loading(`Adding ${f.length} members...`);try{const O=await(await fetch(`/api/teams/${t}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userIds:f})})).json();O.success?(await k(),u(!1),g([]),v(""),D.success(`Successfully added ${f.length} members!`,{id:_})):D.error(`Error adding members: ${O.error||"Unknown error"}`,{id:_})}catch(S){console.error("Error adding members:",S),D.error("Error adding members",{id:_})}},q=async(_,S)=>{const O=D.loading(`Removing ${S}...`);try{const z=await(await fetch(`/api/team-members/${_}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();z.success?(await k(),D.success(`${S} removed from team!`,{id:O})):D.error(`Error removing member: ${z.error||"Unknown error"}`,{id:O})}catch(B){console.error("Error removing team member:",B),D.error("Error removing team member",{id:O})}},Y=()=>{R(),u(!0)},te=_=>{g(S=>S.includes(_)?S.filter(O=>O!==_):[...S,_])},ee=j.filter(_=>_.name.toLowerCase().includes(w.toLowerCase())||_.email.toLowerCase().includes(w.toLowerCase()));return l?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading team details..."})]})}):r?n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:`/organizations/${r.organizationId}`,children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:Y,className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add Members"]}),n.jsxs(T,{onClick:()=>y(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(wn,{className:"w-4 h-4 mr-2"}),"Edit Team"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-light",children:r.name}),n.jsx("div",{className:"flex items-center space-x-2",children:r.organization&&n.jsxs(es,{to:`/organizations/${r.organizationId}`,className:"text-gray-400 hover:text-white text-sm",children:[n.jsx(Le,{className:"w-4 h-4 inline mr-1"}),r.organization.name]})})]})]}),n.jsx("div",{className:"border-b border-white/10",children:n.jsxs("nav",{className:"flex space-x-8",children:[n.jsxs("button",{onClick:()=>d("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Details"})]}),n.jsxs("button",{onClick:()=>d("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Members"}),a.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:a.length})]})]})}),c==="details"&&n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[n.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Team Information"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx("p",{className:"text-white mt-1",children:r.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Organization"}),n.jsx("p",{className:"text-white mt-1",children:((ie=r.organization)==null?void 0:ie.name)||"Unknown"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Last Updated"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.updatedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:a.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx($i,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(r.createdAt).getTime())/(1e3*60*60*24))}),n.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Le,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:"1"}),n.jsx("p",{className:"text-sm text-gray-400",children:"Organization"})]})]})})]})]}),c==="members"&&n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Team Members (",a.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage members of this team"})]})}),a.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:a.map(_=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:_.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.user.id}`,alt:_.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:_.user.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",_.user.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:_.user.email}),n.jsx("td",{className:"py-4 px-4",children:n.jsx(le,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed border-blue-500/30 text-blue-400/70 rounded-none capitalize",children:_.role})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(_.joinedAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsx("div",{className:"flex items-center justify-end space-x-2",children:n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>q(_.id,_.user.name),children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},_.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Add members to this team to get started."}),n.jsxs(T,{onClick:Y,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add First Members"]})]})})]}),m&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Add Team Members"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{u(!1),g([]),v("")},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"relative",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{placeholder:"Search users by name or email...",value:w,onChange:_=>v(_.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),f.length>0&&n.jsx("div",{className:"bg-blue-900/20 border border-blue-500/30 rounded-none p-3",children:n.jsxs("p",{className:"text-blue-400 text-sm",children:[f.length," user",f.length!==1?"s":""," selected"]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none max-h-96 overflow-y-auto",children:ee.length>0?n.jsx("div",{className:"divide-y divide-white/5",children:ee.map(_=>n.jsxs("div",{className:`flex items-center space-x-3 p-4 cursor-pointer hover:bg-white/5 ${f.includes(_.id)?"bg-blue-900/20":""}`,onClick:()=>te(_.id),children:[n.jsx("input",{type:"checkbox",checked:f.includes(_.id),onChange:()=>te(_.id),className:"rounded border-gray-300"}),n.jsx("img",{src:_.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.id}`,alt:_.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"text-white font-light",children:_.name}),n.jsx("div",{className:"text-sm text-gray-400",children:_.email})]})]},_.id))}):n.jsx("div",{className:"p-8 text-center",children:n.jsx("p",{className:"text-gray-400",children:"No users found matching your search."})})})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{u(!1),g([]),v("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsxs(T,{onClick:W,disabled:f.length===0,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add ",f.length," Member",f.length!==1?"s":""]})]})]})}),p&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:r.name}),n.jsx("div",{className:"text-sm text-gray-400",children:(X=r.organization)==null?void 0:X.name})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),n.jsx(me,{id:"edit-team-name",value:N.name,onChange:_=>C({name:_.target.value}),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>y(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:J,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})})]}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:`/organizations/${e}`,children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),n.jsxs("div",{className:"text-center py-12",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Team Not Found"}),n.jsx("p",{className:"text-gray-400",children:"The team you're looking for doesn't exist."})]})]})}function Ib(){const e=En(),[t,r]=h.useState([]),[s,a]=h.useState(!0),[i,l]=h.useState(null),[o,c]=h.useState(""),[d,m]=h.useState("all"),[u,p]=h.useState(1),[y]=h.useState(20);h.useEffect(()=>{w()},[]);const w=async()=>{try{const P=await(await fetch("/api/plugins")).json(),k=(P==null?void 0:P.plugins).find(R=>R.id==="teams");l({enabled:!!k,availablePlugins:(P==null?void 0:P.plugins).map(R=>R.id),configPath:P.configPath,teamsPlugin:(P==null?void 0:P.plugins).find(R=>R.id==="teams")}),k?await v():a(!1)}catch(C){console.error("Failed to check teams plugin status:",C),l({enabled:!1,error:"Failed to check plugin status"}),a(!1)}},v=async()=>{try{const P=await(await fetch("/api/teams")).json();P.success&&r(P.teams||[])}catch(C){console.error("Failed to fetch teams:",C),D.error("Failed to load teams")}finally{a(!1)}},j=t.filter(C=>{var k;const P=C.name.toLowerCase().includes(o.toLowerCase())||((k=C.organization)==null?void 0:k.name.toLowerCase().includes(o.toLowerCase()));if(d==="all")return P;if(d==="recent"){const R=new Date;return R.setDate(R.getDate()-7),P&&new Date(C.createdAt)>R}return P}),x=u*y,f=x-y,g=j.slice(f,x),N=Math.ceil(j.length/y);return s?n.jsx("div",{className:"flex items-center justify-center min-h-screen",children:n.jsx(st,{className:"w-8 h-8 animate-spin text-white"})}):i!=null&&i.enabled?n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-light tracking-tight text-white",children:"Teams"}),n.jsxs("p",{className:"text-gray-400 mt-1",children:[j.length," team",j.length!==1?"s":""," found"]})]}),n.jsx("div",{className:"flex items-center space-x-3",children:n.jsxs(T,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Create Team"]})})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"relative flex-1 max-w-md",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{type:"text",placeholder:"Search teams...",value:o,onChange:C=>c(C.target.value),className:"pl-10 bg-black border-dashed border-white/20 text-white placeholder-gray-400 focus:ring-2 focus:ring-white focus:border-transparent"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(T,{variant:d==="all"?"default":"outline",size:"sm",onClick:()=>m("all"),className:d==="all"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"All"}),n.jsx(T,{variant:d==="recent"?"default":"outline",size:"sm",onClick:()=>m("recent"),className:d==="recent"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"Recent"})]})]}),g.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(he,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-light text-white mb-2",children:"No teams found"}),n.jsx("p",{className:"text-gray-400 mb-6",children:o?"Try adjusting your search terms":"Get started by creating your first team"}),!o&&n.jsxs(T,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]}):n.jsx("div",{className:"grid gap-4",children:g.map(C=>{var P;return n.jsx("div",{className:"bg-black/30 border border-white/15 rounded-none p-4 hover:bg-black/40 transition-colors cursor-pointer",onClick:()=>e(`/teams/${C.id}`),children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-10 h-10 bg-white/10 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium",children:C.name}),n.jsxs("p",{className:"text-gray-400 text-sm",children:[(P=C.organization)==null?void 0:P.name," • ",C.memberCount||0," members"]})]})]}),n.jsx("div",{className:"flex items-center space-x-2",children:n.jsx(le,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400",children:"Active"})})]})},C.id)})}),N>1&&n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx(T,{variant:"outline",size:"sm",onClick:()=>p(Math.max(1,u-1)),disabled:u===1,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Previous"}),n.jsxs("span",{className:"text-gray-400 text-sm",children:["Page ",u," of ",N]}),n.jsx(T,{variant:"outline",size:"sm",onClick:()=>p(Math.min(N,u+1)),disabled:u===N,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Next"})]})]}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-light",children:"Teams"}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your application organizations"})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:n.jsxs("div",{className:"flex items-start space-x-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx(Le,{className:"w-12 h-12 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Organization Plugin Required"}),n.jsx("p",{className:"text-gray-300 mb-6",children:"To use Organizations in Better Auth Studio, you need to enable the organization plugin in your Better Auth configuration."}),n.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[n.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),n.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:n.jsxs("li",{children:["Import the plugin in your auth configuration file",(i==null?void 0:i.configPath)&&n.jsxs("span",{className:"text-gray-400",children:[" (",i.configPath,")"]}),":"]})}),n.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:n.jsxs("pre",{className:"text-sm text-gray-300",children:[n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"export const"})," ",n.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",n.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",n.jsx("br",{}),n.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",n.jsx("br",{}),n.jsxs("span",{className:"text-yellow-300 pl-12",children:["organization(",")"]}),n.jsx("br",{}),n.jsx("span",{className:"pl-10",children:"]"})," ",n.jsx("br",{}),"}",") ",n.jsx("br",{})]})}),n.jsx("div",{className:"mt-4",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"2. Do migrations to create the organizations table"})}),n.jsx("div",{className:"mt-2",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),(i==null?void 0:i.availablePlugins)&&i.availablePlugins.length>0&&n.jsx("div",{className:"mb-4",children:n.jsxs("p",{className:"text-gray-400 text-sm",children:["Currently enabled plugins: ",i.availablePlugins.join(", ")]})}),n.jsx(T,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),n.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",n.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]})}function Lb(){const{userId:e}=Xc(),t=En(),[r,s]=h.useState(null),[a,i]=h.useState([]),[l,o]=h.useState([]),[c,d]=h.useState([]),[m,u]=h.useState(!0),[p,y]=h.useState("details"),[w,v]=h.useState(!1),[j,x]=h.useState(!1),[f,g]=h.useState(!1),[N,C]=h.useState([]),[P,k]=h.useState(!1),[R,J]=h.useState({});h.useEffect(()=>{e&&(te(),ee())},[e]);const W=async z=>{try{const b=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:z})});if(b.ok){const E=await b.json();if(E.success&&E.location)return E.location}return null}catch(b){return console.error("Failed to resolve IP location:",b),null}},q=async z=>{const b=z.map(async M=>{if(!R[M.id]){const A=await W(M.ipAddress);if(A)return{sessionId:M.id,location:A}}return null}),E=await Promise.all(b),L={};E.forEach(M=>{M&&(L[M.sessionId]=M.location)}),Object.keys(L).length>0&&J(M=>({...M,...L}))},Y=z=>{if(!z)return"🌍";const b=z.toUpperCase().split("").map(E=>127397+E.charCodeAt(0));return String.fromCodePoint(...b)},te=async()=>{try{const z=await fetch(`/api/users/${e}`);if(z.ok){const b=await z.json();s(b.user)}else D.error("Failed to fetch user details"),t("/users")}catch(z){console.error("Failed to fetch user details:",z),D.error("Failed to fetch user details"),t("/users")}finally{u(!1)}},ee=async()=>{try{const[z,b,E]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(z.ok){const L=await z.json();i(L.memberships||[])}if(b.ok){const L=await b.json();o(L.memberships||[])}if(E.ok){const M=(await E.json()).sessions||[];d(M),q(M)}}catch(z){console.error("Failed to fetch user memberships:",z)}},ie=async()=>{var L,M;if(!r)return;const z=(L=document.getElementById("edit-name"))==null?void 0:L.value,b=(M=document.getElementById("edit-email"))==null?void 0:M.value;if(!z||!b){D.error("Please fill in all fields");return}const E=D.loading("Updating user...");try{const K=await(await fetch(`/api/users/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,email:b})})).json();K.success?(s({...r,name:z,email:b}),v(!1),D.success("User updated successfully!",{id:E})):D.error(`Error updating user: ${K.error||"Unknown error"}`,{id:E})}catch(A){console.error("Error updating user:",A),D.error("Error updating user",{id:E})}},X=async()=>{if(!r)return;const z=D.loading("Banning user...");try{const E=await(await fetch(`/api/users/${e}/ban`,{method:"POST"})).json();E.success?(D.success("User banned successfully!",{id:z}),t("/users")):D.error(`Error banning user: ${E.error||"Unknown error"}`,{id:z})}catch(b){console.error("Error banning user:",b),D.error("Error banning user",{id:z})}},_=async z=>{const b=D.loading("Removing user from organization...");try{const L=await(await fetch(`/api/organizations/members/${z}`,{method:"DELETE"})).json();L.success?(i(M=>M.filter(A=>A.id!==z)),D.success("User removed from organization!",{id:b})):D.error(`Error removing user: ${L.error||"Unknown error"}`,{id:b})}catch(E){console.error("Error removing user from organization:",E),D.error("Error removing user from organization",{id:b})}},S=async z=>{const b=D.loading("Removing user from team...");try{const L=await(await fetch(`/api/teams/members/${z}`,{method:"DELETE"})).json();L.success?(o(M=>M.filter(A=>A.id!==z)),D.success("User removed from team!",{id:b})):D.error(`Error removing user: ${L.error||"Unknown error"}`,{id:b})}catch(E){console.error("Error removing user from team:",E),D.error("Error removing user from team",{id:b})}},O=async z=>{const b=D.loading("Deleting session...");try{const L=await(await fetch(`/api/sessions/${z}`,{method:"DELETE"})).json();L.success?(d(M=>M.filter(A=>A.id!==z)),D.success("Session deleted successfully!",{id:b})):D.error(`Error deleting session: ${L.error||"Unknown error"}`,{id:b})}catch(E){console.error("Error deleting session:",E),D.error("Error deleting session",{id:b})}},B=async(z=3)=>{if(e){C([]),k(!0),C([{id:"start",type:"info",message:`Starting session seeding process for ${z} sessions...`,timestamp:new Date}]);try{const E=await(await fetch(`/api/users/${e}/seed-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:z})})).json();if(E.success){const L=E.results.map((A,K)=>A.success?{id:`session-${K}`,type:"progress",message:`Creating session ${K+1}: ${A.session.token.substring(0,20)}... from ${A.session.ipAddress}`,timestamp:new Date,status:"completed"}:{id:`session-${K}`,type:"error",message:`Failed to create session ${K+1}: ${A.error}`,timestamp:new Date});C(A=>[...A,...L]);const M=E.results.filter(A=>A.success).length;C(A=>[...A,{id:"complete",type:"success",message:`✅ Session seeding completed! Created ${M}/${z} sessions successfully`,timestamp:new Date}]),ee()}else C(L=>[...L,{id:"error",type:"error",message:`❌ Session seeding failed: ${E.error||"Unknown error"}`,timestamp:new Date}])}catch(b){C(E=>[...E,{id:"error",type:"error",message:`❌ Network error: ${b}`,timestamp:new Date}])}finally{k(!1)}}};return m?n.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:n.jsx("div",{className:"text-white text-lg",children:"Loading user details..."})}):r?n.jsxs("div",{className:"min-h-screen bg-black w-full",children:[n.jsxs("div",{className:"w-full px-6 py-8",children:[n.jsxs("div",{className:"mb-8",children:[n.jsxs(T,{variant:"outline",onClick:()=>t("/users"),className:"mb-4 border-none text-white",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Users"]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-16 h-16 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:r.image?n.jsx("img",{src:r.image,alt:r.name,className:"w-16 h-16 object-cover"}):n.jsx(Xs,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold text-white",children:r.name}),n.jsx("p",{className:"text-gray-400",children:r.email}),n.jsx("div",{className:"flex items-center space-x-2 mt-2",children:n.jsx(le,{variant:r.emailVerified?"default":"destructive",className:"rounded-none",children:r.emailVerified?"Verified":"Unverified"})})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs(T,{variant:"outline",onClick:()=>v(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[n.jsx(wn,{className:"w-4 h-4 mr-2"}),"Edit User"]}),n.jsxs(T,{variant:"outline",onClick:()=>x(!0),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Eu,{className:"w-4 h-4 mr-2"}),"Ban User"]})]})]})]}),n.jsxs("div",{className:"border border-dashed border-white/10 rounded-none",children:[n.jsx("div",{className:"border-b border-dashed border-white/10",children:n.jsx("nav",{className:"flex space-x-8 px-6",children:[{id:"details",name:"Details",icon:Xs},{id:"organizations",name:"Organizations",icon:Le,count:a.length},{id:"teams",name:"Teams",icon:he,count:l.length},{id:"sessions",name:"Sessions",icon:pr,count:c.length}].map(z=>n.jsxs("button",{onClick:()=>y(z.id),className:`flex items-center space-x-2 py-4 px-2 border-b-2 font-medium text-sm ${p===z.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-white/50"}`,children:[n.jsx(z.icon,{className:"w-4 h-4"}),n.jsx("span",{children:z.name}),z.count!==void 0&&n.jsx(le,{variant:"outline",className:"rounded-none text-xs",children:z.count})]},z.id))})}),n.jsxs("div",{className:"p-6",children:[p==="details"&&n.jsx("div",{className:"space-y-6",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),n.jsx("div",{className:"text-white",children:r.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),n.jsxs("div",{className:"text-white flex items-center space-x-2",children:[n.jsx(Et,{className:"w-4 h-4"}),n.jsx("span",{children:r.email})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email Status"}),n.jsx(le,{variant:r.emailVerified?"default":"destructive",className:"rounded-none",children:r.emailVerified?"Verified":"Unverified"})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Created"}),n.jsxs("div",{className:"text-white flex items-center space-x-2",children:[n.jsx($i,{className:"w-4 h-4"}),n.jsx("span",{children:new Date(r.createdAt).toLocaleDateString()})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Last Updated"}),n.jsxs("div",{className:"text-white flex items-center space-x-2",children:[n.jsx($i,{className:"w-4 h-4"}),n.jsx("span",{children:new Date(r.updatedAt).toLocaleDateString()})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"User ID"}),n.jsx("div",{className:"text-white font-mono text-sm",children:r.id})]})]})]})}),p==="organizations"&&n.jsx("div",{className:"space-y-4",children:a.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(Le,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Organizations"}),n.jsx("p",{className:"text-gray-400",children:"This user is not a member of any organizations."})]}):n.jsx("div",{className:"grid gap-4",children:a.map(z=>n.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-12 h-12 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:z.organization.image?n.jsx("img",{src:z.organization.image,alt:z.organization.name,className:"w-12 h-12 object-cover"}):n.jsx(Le,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium",children:z.organization.name}),n.jsxs("p",{className:"text-gray-400 text-sm",children:["@",z.organization.slug]}),n.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[n.jsx(le,{variant:"outline",className:"rounded-none text-xs",children:z.role}),n.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(z.joinedAt).toLocaleDateString()]})]})]})]}),n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>_(z.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Du,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},z.id))})}),p==="teams"&&n.jsx("div",{className:"space-y-4",children:l.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(he,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Teams"}),n.jsx("p",{className:"text-gray-400",children:"This user is not a member of any teams."})]}):n.jsx("div",{className:"grid gap-4",children:l.map(z=>n.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:n.jsx(he,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium",children:z.team.name}),n.jsxs("p",{className:"text-gray-400 text-sm",children:["in ",z.team.organizationName]}),n.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[n.jsx(le,{variant:"outline",className:"rounded-none text-xs",children:z.role}),n.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(z.joinedAt).toLocaleDateString()]})]})]})]}),n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>S(z.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Du,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},z.id))})}),p==="sessions"&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-medium text-white",children:"Sessions"}),n.jsx("p",{className:"text-gray-400 text-sm",children:"Manage user authentication sessions"})]}),n.jsxs(T,{variant:"outline",onClick:()=>{C([]),k(!1),g(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})]}),c.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(pr,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Sessions"}),n.jsx("p",{className:"text-gray-400",children:"This user has no active sessions."})]}):n.jsx("div",{className:"grid gap-4",children:c.map(z=>{var b,E,L,M;return n.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[n.jsx("div",{className:"w-12 -mt-2 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:n.jsx(R0,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center space-x-3 mb-2",children:n.jsxs("h3",{className:"text-white font-medium",children:["Session ",z.id.substring(0,8),"..."]})}),n.jsxs("div",{className:"flex items-center space-x-4 mb-1",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ln,{className:"w-4 h-4 text-white"}),n.jsx("span",{className:"text-white text-sm",children:z.ipAddress})]}),n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{className:"text-gray-400 text-xs",children:"📍"}),n.jsxs("span",{className:"text-gray-300 text-sm",children:[((b=R[z.id])==null?void 0:b.city)||"...",","," ",((E=R[z.id])==null?void 0:E.country)||"..."]}),((L=R[z.id])==null?void 0:L.countryCode)&&n.jsx("span",{className:"text-sm ml-1",children:Y((M=R[z.id])==null?void 0:M.countryCode)})]})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(pr,{className:"w-4 h-4 text-white"}),n.jsx("span",{className:"text-gray-400 text-sm",children:"Expires:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(z.expiresAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})})]}),n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>O(z.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Eu,{className:"w-4 h-4 mr-1"}),"Revoke"]})]})]})]})})},z.id)})})]})]})]})]}),w&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 rounded-none p-6 w-full max-w-md",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>v(!1),className:"text-gray-400 hover:text-white rounded-none",children:"×"})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:r!=null&&r.image?n.jsx("img",{src:r.image,alt:r.name,className:"w-16 h-16 object-cover"}):n.jsx(Xs,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h4",{className:"text-white font-medium",children:r==null?void 0:r.name}),n.jsx("p",{className:"text-gray-400 text-sm",children:r==null?void 0:r.email})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),n.jsx("input",{id:"edit-name",type:"text",defaultValue:(r==null?void 0:r.name)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),n.jsx("input",{id:"edit-email",type:"email",defaultValue:(r==null?void 0:r.email)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>v(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:ie,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),j&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black border border-dashed border-red-400/50 rounded-none p-6 w-full max-w-md",children:[n.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),n.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to ban ",n.jsx("strong",{children:r.name}),"? This will prevent them from accessing the system."]}),n.jsxs("div",{className:"flex justify-end space-x-2",children:[n.jsx(T,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:X,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Sessions"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsxs("h4",{className:"text-white font-light",children:["Create Sessions for ",r==null?void 0:r.name]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),n.jsx(me,{id:"session-count",type:"number",min:"1",max:"50",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx("p",{className:"text-xs text-gray-400",children:"Each session will have a unique token, IP address, and 7-day expiration."})]})]}),N.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Session Seeding Terminal",lines:N,isRunning:P,className:"w-full",defaultCollapsed:!1})})]}),n.jsxs("div",{className:"flex justify-end space-x-2 mt-6 pt-6 border-t border-dashed border-white/10",children:[n.jsx(T,{variant:"outline",onClick:()=>g(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:()=>{var b;const z=parseInt(((b=document.getElementById("session-count"))==null?void 0:b.value)||"3");B(z)},disabled:P,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:P?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-4 h-4 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})})]})]})})]}):n.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:n.jsx("div",{className:"text-white text-lg",children:"User not found"})})}function Ob(){return n.jsx(L0,{children:n.jsxs(Kv,{children:[n.jsx(Eb,{children:n.jsxs($v,{children:[n.jsx(Ut,{path:"/",element:n.jsx(Pb,{})}),n.jsx(Ut,{path:"/users",element:n.jsx(bx,{})}),n.jsx(Ut,{path:"/users/:userId",element:n.jsx(Lb,{})}),n.jsx(Ut,{path:"/organizations",element:n.jsx(wx,{})}),n.jsx(Ut,{path:"/organizations/:orgId",element:n.jsx(zb,{})}),n.jsx(Ut,{path:"/teams",element:n.jsx(Ib,{})}),n.jsx(Ut,{path:"/teams/:teamId",element:n.jsx(qu,{})}),n.jsx(Ut,{path:"/organizations/:orgId/teams/:teamId",element:n.jsx(qu,{})}),n.jsx(Ut,{path:"/sessions",element:n.jsx(Db,{})}),n.jsx(Ut,{path:"/settings",element:n.jsx(Mb,{})})]})}),n.jsx(j0,{theme:"dark",position:"top-right",richColors:!0,closeButton:!0})]})})}Yl.createRoot(document.getElementById("root")).render(n.jsx(V.StrictMode,{children:n.jsx(Ob,{})}));
363
+ `),we=new Blob([de],{type:"text/csv;charset=utf-8;"}),ge=document.createElement("a"),Ne=URL.createObjectURL(we);ge.setAttribute("href",Ne),ge.setAttribute("download",`users-export-${new Date().toISOString().split("T")[0]}.csv`),ge.style.visibility="hidden",document.body.appendChild(ge),ge.click(),document.body.removeChild(ge),D.success(`Exported ${r.length} users to CSV`)},b=r.filter($=>($.name.toLowerCase().includes(l.toLowerCase())||$.email.toLowerCase().includes(l.toLowerCase()))&&c==="all"),E=Math.ceil(b.length/p),L=(m-1)*p,M=L+p,A=b.slice(L,M),K=$=>{u($)};return a?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading users..."})]})}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl text-white font-light",children:["Users (",r.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your application users"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:z,children:[n.jsx(Ef,{className:"w-4 h-4 mr-2"}),"Export CSV"]}),n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",onClick:()=>P(!0),children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed"]}),n.jsxs(T,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>w(!0),children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add User"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{placeholder:"Search users...",value:l,onChange:$=>o($.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Jc,{className:"w-4 h-4 text-gray-400"}),n.jsxs(hs,{value:c,onValueChange:d,children:[n.jsx(ms,{children:n.jsx(fs,{})}),n.jsxs(xs,{children:[n.jsx(Dt,{value:"all",children:"All"}),n.jsx(Dt,{value:"active",children:"Active"}),n.jsx(Dt,{value:"inactive",children:"Inactive"})]})]})]})]}),n.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email Verified"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:A.length===0?n.jsx("tr",{children:n.jsx("td",{colSpan:5,className:"py-12 px-4 text-center",children:n.jsxs("div",{className:"flex flex-col items-center space-y-4",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white/50"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium text-lg",children:"No users found"}),n.jsx("p",{className:"text-gray-400 text-sm mt-1",children:l||c!=="all"?"Try adjusting your search or filter criteria":"Get started by creating your first user or seeding some data"})]}),!l&&c==="all"&&n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:()=>w(!0),className:"bg-white text-black hover:bg-gray-200 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Create User"]}),n.jsxs(T,{onClick:()=>P(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Data"]})]})]})})}):A.map($=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>e(`/users/${$.id}`),children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:$.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${$.id}`,alt:$.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:$.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",$.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:$.email}),n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-2",children:[$.emailVerified?n.jsx(C0,{className:"w-4 h-4 text-green-400"}):n.jsx(Et,{className:"w-4 h-4 text-yellow-400"}),n.jsx("span",{className:"text-sm text-gray-400",children:$.emailVerified?"Verified":"Not Verified"})]})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:n.jsxs("div",{className:"flex flex-col",children:[new Date($.createdAt).toLocaleDateString(),n.jsx("p",{className:"text-xs",children:new Date($.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]})}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:Z=>{Z.stopPropagation(),ie($)},children:n.jsx(sl,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:Z=>{Z.stopPropagation(),X($)},children:n.jsx(wn,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:Z=>{Z.stopPropagation(),_($)},children:n.jsx(fn,{className:"w-4 h-4"})})]})})]},$.id))})]})}),n.jsx(yx,{currentPage:m,totalPages:E,onPageChange:K,totalItems:b.length,startIndex:L,endIndex:M})]}),C&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Data"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>P(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Users"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"user-count",className:"text-sm text-gray-400 font-light",children:"Number of users"}),n.jsx(me,{id:"user-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var Z;const $=parseInt(((Z=document.getElementById("user-count"))==null?void 0:Z.value)||"5");ee($)},disabled:q,className:"bg-transparent hover:bg-white/90 bg-white text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:q?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-3 h-3 mr-2"}),"Seed Users"]})})]})]}),J.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"User Seeding Terminal",lines:J,isRunning:q,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>P(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),y&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>w(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-name",className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx(me,{id:"create-name",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-email",className:"text-sm text-gray-400 font-light",children:"Email"}),n.jsx(me,{id:"create-email",type:"email",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-password",className:"text-sm text-gray-400 font-light",children:"Password"}),n.jsx(me,{id:"create-password",type:"password",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>w(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:S,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),v&&k&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:k.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${k.id}`,alt:k.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:k.name}),n.jsx("div",{className:"text-sm text-gray-400",children:k.email})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-name",className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx(me,{id:"edit-name",defaultValue:k.name,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-email",className:"text-sm text-gray-400 font-light",children:"Email"}),n.jsx(me,{id:"edit-email",type:"email",defaultValue:k.email,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>j(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:O,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),x&&k&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Delete User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>f(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:k.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${k.id}`,alt:k.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:k.name}),n.jsx("div",{className:"text-sm text-gray-400",children:k.email})]})]}),n.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this user? This action cannot be undone."})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>f(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:B,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),g&&k&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"User Details"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>N(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:k.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${k.id}`,alt:k.name,className:"w-16 h-16 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:k.name}),n.jsx("div",{className:"text-sm text-gray-400",children:k.email})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"ID:"}),n.jsx("span",{className:"text-white text-sm",children:k.id})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Email Verified:"}),n.jsx("span",{className:"text-white text-sm",children:k.emailVerified?"Yes":"No"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Created:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(k.createdAt).toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Updated:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(k.updatedAt).toLocaleString()})]})]})]}),n.jsx("div",{className:"flex justify-end mt-6",children:n.jsx(T,{onClick:()=>N(!1),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Close"})})]})})]})}function Pb(){const[e,t]=h.useState("overview"),r=()=>n.jsxs("div",{className:"space-y-8 animate-fade-in px-6 py-8",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-normal",children:"Better Auth Studio"}),n.jsx("p",{className:"text-gray-400 mt-1 font-light",children:"Manage your authentication system"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(he,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Active"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"User Management"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"Manage user accounts, profiles, and permissions"}),n.jsxs(T,{onClick:()=>t("users"),className:"w-full bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:["Manage Users",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(Le,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Active"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Organizations"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"Manage organizations, teams, and memberships"}),n.jsxs(T,{onClick:()=>t("organizations"),className:"w-full bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:["Manage Organizations",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(ts,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Configured"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Configuration"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"View and manage auth configuration"}),n.jsxs(T,{variant:"outline",className:"w-full border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:["View Config",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(Ko,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Coming Soon"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Analytics"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"View authentication analytics and insights"}),n.jsxs(T,{variant:"outline",disabled:!0,className:"w-full border border-dashed border-white/20 text-gray-400 rounded-none",children:["View Analytics",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})}),n.jsx(ot,{className:"border border-dashed border-white/20 bg-black/30 rounded-none hover:bg-black/50 transition-colors",children:n.jsxs(ct,{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("div",{className:"p-3 bg-white/10 rounded-none",children:n.jsx(ui,{className:"w-6 h-6 text-white"})}),n.jsx(le,{className:"bg-white/10 text-white border border-dashed border-white/20 rounded-none",children:"Available"})]}),n.jsx("h3",{className:"text-lg text-white font-light mb-2",children:"Quick Actions"}),n.jsx("p",{className:"text-gray-400 font-light mb-4",children:"Common tasks and shortcuts"}),n.jsxs(T,{variant:"outline",className:"w-full border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:["View Actions",n.jsx(Mn,{className:"w-4 h-4 ml-2"})]})]})})]})]});return n.jsx("div",{className:"min-h-screen bg-black text-white",children:e==="overview"?r():e==="users"?n.jsx(bx,{}):e==="organizations"?n.jsx(wx,{}):r()})}function zb(){const{orgId:e}=Xc(),t=En(),[r,s]=h.useState(null),[a,i]=h.useState([]),[l,o]=h.useState([]),[c,d]=h.useState([]),[m,u]=h.useState(!0),[p,y]=h.useState("details"),[w,v]=h.useState(!1),[j,x]=h.useState(!1),[f,g]=h.useState(!1),[N,C]=h.useState(!1),[P,k]=h.useState(!1),[R,J]=h.useState(!1),[W,q]=h.useState(!1),[Y,te]=h.useState(!1),[ee,ie]=h.useState(null),[X,_]=h.useState(""),[S,O]=h.useState(""),[B,z]=h.useState([]),[b,E]=h.useState({name:""}),[L,M]=h.useState(!1),[A,K]=h.useState([]),[$,Z]=h.useState(!1),[de,we]=h.useState([]),[ge,Ne]=h.useState(!1);h.useEffect(()=>{e&&(Gt(),lr(),ir(),Ye(),Ot(),Lt())},[e]),h.useEffect(()=>{w&&e&&Lt()},[]),h.useEffect(()=>{p==="members"&&e&&Ot()},[p,e]),h.useEffect(()=>{p==="invitations"&&e&&Ye()},[p,e]);const ve=I=>{E({name:I})},Gt=async()=>{try{const G=await(await fetch(`/api/organizations/${e}`)).json();G.success&&G.organization||G.organization?s(G.organization):D.error("Organization not found")}catch(I){console.error("Failed to fetch organization:",I),D.error("Failed to load organization")}finally{u(!1)}},ir=async()=>{try{const G=await(await fetch("/api/plugins/teams/status")).json();v(G.organizationPlugin.options.teams.enabled)}catch(I){console.error("Failed to check teams status:",I),v(!1)}},lr=async()=>{try{const G=await(await fetch("/api/plugins/organization/status")).json();x(G.enabled)}catch(I){console.error("Failed to check organization status:",I),x(!1)}},Lt=async()=>{try{const G=await(await fetch(`/api/organizations/${e}/teams`)).json();G.success&&i(G.teams||[])}catch(I){console.error("Failed to fetch teams:",I),D.error("Failed to load teams")}},Ye=async()=>{try{const G=await(await fetch(`/api/organizations/${e}/invitations`)).json();G.success&&o(G.invitations||[])}catch(I){console.error("Failed to fetch invitations:",I),D.error("Failed to load invitations")}},Ot=async()=>{try{const G=await(await fetch(`/api/organizations/${e}/members`)).json();G.success&&d(G.members||[])}catch(I){console.error("Failed to fetch members:",I),D.error("Failed to load members")}},bs=async I=>{K([]),Z(!0),K([{id:"start",type:"info",message:`Starting member seeding process for ${I} members...`,timestamp:new Date}]);try{const ne=await(await fetch(`/api/organizations/${e}/seed-members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:I})})).json();if(ne.success){const We=ne.results.map((fe,or)=>fe.success?{id:`member-${or}`,type:"progress",message:`Adding member: ${fe.member.user.name} (${fe.member.user.email})`,timestamp:new Date,status:"completed"}:{id:`member-${or}`,type:"error",message:`Failed to add member ${or+1}: ${fe.error}`,timestamp:new Date});K(fe=>[...fe,...We]);const it=ne.results.filter(fe=>fe.success).length;K(fe=>[...fe,{id:"complete",type:"success",message:`✅ Seeding completed! Added ${it}/${I} members successfully`,timestamp:new Date}]),await Ot(),D.success(`Successfully added ${it} members!`)}else K(We=>[...We,{id:"error",type:"error",message:`❌ Seeding failed: ${ne.error||"Unknown error"}`,timestamp:new Date}]),D.error(ne.error||"Failed to seed members")}catch(G){K(ne=>[...ne,{id:"error",type:"error",message:`❌ Network error: ${G}`,timestamp:new Date}]),D.error("Failed to seed members")}finally{Z(!1)}},$e=async I=>{we([]),Ne(!0),we([{id:"start",type:"info",message:`Starting team seeding process for ${I} teams...`,timestamp:new Date}]);try{const ne=await(await fetch(`/api/organizations/${e}/seed-teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:I})})).json();if(ne.success){const We=ne.results.map((fe,or)=>fe.success?{id:`team-${or}`,type:"progress",message:`Creating team: ${fe.team.name}`,timestamp:new Date,status:"completed"}:{id:`team-${or}`,type:"error",message:`Failed to create team ${or+1}: ${fe.error}`,timestamp:new Date});we(fe=>[...fe,...We]);const it=ne.results.filter(fe=>fe.success).length;we(fe=>[...fe,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${it}/${I} teams successfully`,timestamp:new Date}]),await Lt(),D.success(`Successfully created ${it} teams!`)}else we(We=>[...We,{id:"error",type:"error",message:`❌ Seeding failed: ${ne.error||"Unknown error"}`,timestamp:new Date}]),D.error(ne.error||"Failed to seed teams")}catch(G){we(ne=>[...ne,{id:"error",type:"error",message:`❌ Network error: ${G}`,timestamp:new Date}]),D.error("Failed to seed teams")}finally{Ne(!1)}},At=async()=>{try{const G=await(await fetch("/api/users/all")).json();G.success&&z(G.users||[])}catch(I){console.error("Failed to fetch users:",I)}},rn=()=>{At(),g(!0)},js=async()=>{if(!X){D.error("Please enter an email address");return}if(!S){D.error("Please select an inviter");return}M(!0);const I=D.loading("Sending invitation...");try{const ne=await(await fetch(`/api/organizations/${e}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:X,role:"member",inviterId:S})})).json();ne.success?(await Ye(),g(!1),_(""),O(""),D.success("Invitation sent successfully!",{id:I})):D.error(`Error sending invitation: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error sending invitation:",G),D.error("Error sending invitation",{id:I})}finally{M(!1)}},F=async I=>{const G=D.loading("Cancelling invitation...");try{const We=await(await fetch(`/api/invitations/${I}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();We.success?(await Ye(),D.success("Invitation cancelled successfully!",{id:G})):D.error(`Error cancelling invitation: ${We.error||"Unknown error"}`,{id:G})}catch(ne){console.error("Error cancelling invitation:",ne),D.error("Error cancelling invitation",{id:G})}},Q=async(I,G)=>{const ne=D.loading("Resending invitation...");try{const it=await(await fetch(`/api/invitations/${I}/resend`,{method:"POST",headers:{"Content-Type":"application/json"}})).json();it.success?(await Ye(),D.success(`Invitation resent to ${G}!`,{id:ne})):D.error(`Error resending invitation: ${it.error||"Unknown error"}`,{id:ne})}catch(We){console.error("Error resending invitation:",We),D.error("Error resending invitation",{id:ne})}},oe=async(I,G)=>{const ne=D.loading(`Removing ${G}...`);try{const it=await(await fetch(`/api/members/${I}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();it.success?(await Ot(),D.success(`${G} removed from organization!`,{id:ne})):D.error(`Error removing member: ${it.error||"Unknown error"}`,{id:ne})}catch(We){console.error("Error removing member:",We),D.error("Error removing member",{id:ne})}},Ee=async()=>{if(!b.name){D.error("Please enter a team name");return}const I=D.loading("Creating team...");try{const ne=await(await fetch(`/api/organizations/${e}/teams`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name,organizationId:e})})).json();ne.success?(await Lt(),J(!1),E({name:""}),D.success("Team created successfully!",{id:I})):D.error(`Error creating team: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error creating team:",G),D.error("Error creating team",{id:I})}},Fe=async()=>{if(!ee||!b.name){D.error("Please enter a team name");return}const I=D.loading("Updating team...");try{const ne=await(await fetch(`/api/teams/${ee.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b.name})})).json();ne.success?(await Lt(),q(!1),ie(null),E({name:""}),D.success("Team updated successfully!",{id:I})):D.error(`Error updating team: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error updating team:",G),D.error("Error updating team",{id:I})}},ye=async()=>{if(!ee){D.error("No team selected");return}const I=D.loading("Deleting team...");try{const ne=await(await fetch(`/api/teams/${ee.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();ne.success?(await Lt(),te(!1),ie(null),D.success("Team deleted successfully!",{id:I})):D.error(`Error deleting team: ${ne.error||"Unknown error"}`,{id:I})}catch(G){console.error("Error deleting team:",G),D.error("Error deleting team",{id:I})}},Te=I=>{ie(I),E({name:I.name}),q(!0)},Ns=I=>{ie(I),te(!0)};return m?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading organization details..."})]})}):r?n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:"/organizations",children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:()=>C(!0),className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[n.jsx(he,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),n.jsxs(T,{onClick:rn,className:"border border-dashed border-white/20 text-white bg-transparent hover:bg-white/10 rounded-none",children:[n.jsx(Et,{className:"w-4 h-4 mr-2"}),"Invite User"]}),n.jsxs(T,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(wn,{className:"w-4 h-4 mr-2"}),"Edit Organization"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(Le,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-light",children:r.name}),n.jsx("p",{className:"text-gray-400",children:r.slug})]})]}),n.jsx("div",{className:"border-b border-white/10",children:n.jsxs("nav",{className:"flex space-x-8",children:[n.jsxs("button",{onClick:()=>y("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(Le,{className:"w-4 h-4"}),n.jsx("span",{children:"Details"}),n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length+l.length+a.length})]}),n.jsxs("button",{onClick:()=>y("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Members"}),c.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:c.length})]}),n.jsxs("button",{onClick:()=>y("invitations"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="invitations"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(Et,{className:"w-4 h-4"}),n.jsx("span",{children:"Invitations"}),l.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:l.length})]}),n.jsxs("button",{onClick:()=>y("teams"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${p==="teams"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Teams"}),a.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:a.length})]})]})}),p==="details"&&n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[n.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Organization Information"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx("p",{className:"text-white mt-1",children:r.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Slug"}),n.jsx("p",{className:"text-white mt-1",children:r.slug})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Last Updated"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.updatedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-6",children:[n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:c.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:a.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Teams"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Et,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:l.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Invitations"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx($i,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(r.createdAt).getTime())/(1e3*60*60*24))}),n.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})})]})]}),p==="teams"&&n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Teams (",a.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage teams within this organization"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:()=>k(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Teams"]}),n.jsxs(T,{onClick:()=>J(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]})]}),w?a.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Team"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Members"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Created"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:a.map(I=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5 cursor-pointer",onClick:()=>t(`/organizations/${e}/teams/${I.id}`),children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:I.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",I.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:I.memberCount||0}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(I.createdAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:G=>{G.stopPropagation(),Te(I)},children:[n.jsx(wn,{className:"w-4 h-4 mr-1"}),"Edit"]}),n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:G=>{G.stopPropagation(),Ns(I)},children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Delete"]})]})})]},I.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Teams Yet"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Create your first team to start organizing members within this organization."}),n.jsxs(T,{onClick:()=>J(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Create First Team"]})]})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:n.jsxs("div",{className:"flex items-start space-x-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx(he,{className:"w-12 h-12 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Teams Feature Required"}),n.jsx("p",{className:"text-gray-300 mb-6",children:"To use Teams in Better Auth Studio, you need to enable the teams feature in your organization plugin configuration."}),n.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[n.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),n.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:n.jsx("li",{children:"Update your auth configuration file to enable teams:"})}),n.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:n.jsxs("pre",{className:"text-sm text-gray-300",children:[n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"export const"})," ",n.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",n.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",n.jsx("br",{}),n.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",n.jsx("br",{}),n.jsx("span",{className:"text-yellow-300 pl-12",children:"organization"}),"(","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-red-300 pl-16",children:"teams"}),": ","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-yellow-300 pl-20",children:"enabled"}),":"," ",n.jsx("span",{className:"text-blue-400",children:"true"})," ",n.jsx("br",{}),n.jsx("span",{className:"pl-16",children:"}"})," ",n.jsx("br",{}),n.jsx("span",{className:"pl-12",children:"})"})," ",n.jsx("br",{}),n.jsx("span",{className:"pl-10",children:"]"})," ",n.jsx("br",{}),"}",") ",n.jsx("br",{})]})}),n.jsx("div",{className:"mt-4",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"2. Run migrations to create the teams table"})}),n.jsx("div",{className:"mt-2",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),n.jsx(T,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),n.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",n.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]}),p==="members"&&n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Members (",c.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage organization members and their roles"})]})}),c.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:c.map(I=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:I.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${I.user.id}`,alt:I.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:I.user.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",I.user.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:I.user.email}),n.jsx("td",{className:"py-4 px-4",children:n.jsx(le,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed rounded-none border-blue-500/30 text-blue-400/70 capitalize",children:I.role})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(I.joinedAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsx("div",{className:"flex items-center justify-end space-x-2",children:n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>oe(I.id,I.user.name),children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},I.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Invite users or seed members from existing users to get started."}),n.jsxs("div",{className:"flex items-center justify-center space-x-3",children:[n.jsxs(T,{onClick:()=>C(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(he,{className:"w-4 h-4 mr-2"}),"Seed Members"]}),n.jsxs(T,{onClick:rn,className:"bg-white text-white hover:bg-white/90 bg-transparent border border-white/20 rounded-none",children:[n.jsx(Et,{className:"w-4 h-4 mr-2"}),"Invite User"]})]})]})})]}),p==="invitations"&&n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Invitations (",l.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage pending invitations to this organization"})]})}),l.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:l.map(I=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(Et,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:I.email}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Expires on"," ",new Date(I.expiresAt).toLocaleDateString("en-US",{month:"short",year:"numeric",day:"numeric"})]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white capitalize",children:I.role}),n.jsx("td",{className:"py-4 px-4",children:n.jsxs(le,{variant:"secondary",className:`text-xs font-normal rounded-none border-dashed flex items-center gap-1 w-fit ${I.status==="pending"?"bg-yellow-900/10 border border-yellow-500/30 text-yellow-400/70":I.status==="accepted"?"bg-green-900/10 border border-green-500/30 text-green-400/70":"bg-red-900/10 border border-red-500/30 text-red-400/70"}`,children:[I.status==="pending"&&n.jsx(pr,{className:"w-3 h-3"}),I.status==="accepted"&&n.jsx(Ue,{className:"w-3 h-3"}),I.status==="expired"&&n.jsx(be,{className:"w-3 h-3"}),I.status]})}),n.jsxs("td",{className:"py-4 px-4 text-sm text-gray-400",children:[new Date(I.expiresAt).toLocaleDateString(),n.jsx("br",{}),n.jsx("span",{className:"text-xs text-gray-400",children:new Date(I.expiresAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>Q(I.id,I.email),children:[n.jsx(zu,{className:"w-4 h-4 mr-1"}),"Resend"]}),n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>F(I.id),children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Cancel"]})]})})]},I.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(Et,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Invitations"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Start inviting users to join this organization."}),n.jsxs(T,{onClick:rn,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Et,{className:"w-4 h-4 mr-2"}),"Send First Invitation"]})]})})]}),f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Invite User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{g(!1),_(""),O("")},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"invite-email",className:"text-sm text-gray-400 font-light",children:"Email Address"}),n.jsx(me,{id:"invite-email",type:"email",value:X,onChange:I=>_(I.target.value),placeholder:"user@example.com",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"inviter-select",className:"text-sm text-gray-400 font-light",children:"Inviter"}),n.jsxs(hs,{value:S,onValueChange:O,children:[n.jsx(ms,{children:n.jsx(fs,{placeholder:"Select an inviter..."})}),n.jsx(xs,{children:B.map(I=>n.jsx(Dt,{value:I.id,children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("img",{src:I.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${I.id}`,alt:I.name,className:"w-6 h-6 rounded-none border border-dashed border-white/20"}),n.jsxs("span",{children:[I.name," (",I.email,")"]})]})},I.id))})]})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{g(!1),_(""),O("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsxs(T,{onClick:js,disabled:L,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[L?n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}):n.jsx(zu,{className:"w-4 h-4 mr-2"}),L?"Sending...":"Send Invitation"]})]})]})}),R&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{J(!1),E({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),n.jsx(me,{id:"team-name",value:b.name,onChange:I=>ve(I.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{J(!1),E({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:Ee,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create Team"})]})]})}),W&&ee&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{q(!1),E({name:""})},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:ee.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",ee.id]})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),n.jsx(me,{id:"edit-team-name",value:b.name,onChange:I=>ve(I.target.value),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{q(!1),E({name:""})},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:Fe,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})}),Y&&ee&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>te(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:ee.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["Team ID: ",ee.id]})]})]}),n.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this team? This action cannot be undone."})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>te(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:ye,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete Team"})]})]})}),N&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Members"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>C(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(he,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Add Members from Existing Users"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"member-count",className:"text-sm text-gray-400 font-light",children:"Number of members to add"}),n.jsx(me,{id:"member-count",type:"number",min:"1",max:"50",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var G;const I=parseInt(((G=document.getElementById("member-count"))==null?void 0:G.value)||"5");bs(I)},disabled:$,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:$?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(he,{className:"w-3 h-3 mr-2"}),"Seed Members"]})})]})]}),A.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Member Seeding Terminal",lines:A,isRunning:$,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>C(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),P&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Teams"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>k(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Le,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Create Teams"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"team-count",className:"text-sm text-gray-400 font-light",children:"Number of teams to create"}),n.jsx(me,{id:"team-count",type:"number",min:"1",max:"20",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var G;const I=parseInt(((G=document.getElementById("team-count"))==null?void 0:G.value)||"3");$e(I)},disabled:ge,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:ge?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Le,{className:"w-3 h-3 mr-2"}),"Seed Teams"]})})]})]}),de.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Team Seeding Terminal",lines:de,isRunning:ge,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>k(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})})]}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:"/organizations",children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organizations"]})})}),n.jsx("br",{}),n.jsxs("div",{className:"text-center py-12",children:[n.jsx(Le,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Organization Not Found"}),n.jsx("p",{className:"text-gray-400",children:"The organization you're looking for doesn't exist."})]})]})}function Db(){const[e,t]=h.useState([]),[r,s]=h.useState(!0),[a,i]=h.useState(""),[l,o]=h.useState("all"),[c,d]=h.useState(!1),[m,u]=h.useState(!1),[p,y]=h.useState(!1),[w,v]=h.useState(!1),[j,x]=h.useState(!1),[f,g]=h.useState(null),[N,C]=h.useState([]),[P,k]=h.useState(!1);h.useEffect(()=>{R()},[]);const R=async()=>{try{const O=await(await fetch("/api/sessions")).json();t(O.sessions||[])}catch(S){console.error("Failed to fetch sessions:",S)}finally{s(!1)}},J=async S=>{C([]),k(!0),C([{id:"start",type:"info",message:`Starting session seeding process for ${S} sessions...`,timestamp:new Date}]);try{const B=await(await fetch("/api/seed/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:S})})).json();if(B.success){const z=B.results.map((E,L)=>E.success?{id:`session-${L}`,type:"progress",message:`Creating session: ${E.session.id}`,timestamp:new Date,status:"completed"}:{id:`session-${L}`,type:"error",message:`Failed to create session ${L+1}: ${E.error}`,timestamp:new Date});C(E=>[...E,...z]);const b=B.results.filter(E=>E.success).length;C(E=>[...E,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${b}/${S} sessions successfully`,timestamp:new Date}]),await R()}else C(z=>[...z,{id:"error",type:"error",message:`❌ Seeding failed: ${B.error||"Unknown error"}`,timestamp:new Date}])}catch(O){C(B=>[...B,{id:"error",type:"error",message:`❌ Network error: ${O}`,timestamp:new Date}])}finally{k(!1)}},W=async S=>{C([]),k(!0),C([{id:"start",type:"info",message:`Starting account seeding process for ${S} accounts...`,timestamp:new Date}]);try{const B=await(await fetch("/api/seed/accounts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:S})})).json();if(B.success){const z=B.results.map((E,L)=>E.success?{id:`account-${L}`,type:"progress",message:`Creating account: ${E.account.provider}`,timestamp:new Date,status:"completed"}:{id:`account-${L}`,type:"error",message:`Failed to create account ${L+1}: ${E.error}`,timestamp:new Date});C(E=>[...E,...z]);const b=B.results.filter(E=>E.success).length;C(E=>[...E,{id:"complete",type:"success",message:`✅ Seeding completed! Created ${b}/${S} accounts successfully`,timestamp:new Date}]),await R()}else C(z=>[...z,{id:"error",type:"error",message:`❌ Seeding failed: ${B.error||"Unknown error"}`,timestamp:new Date}])}catch(O){C(B=>[...B,{id:"error",type:"error",message:`❌ Network error: ${O}`,timestamp:new Date}])}finally{k(!1)}},q=S=>{g(S),v(!0)},Y=S=>{g(S),u(!0)},te=S=>{g(S),y(!0)},ee=async S=>{console.log("Creating session:",S),d(!1)},ie=async S=>{console.log("Updating session:",S),u(!1)},X=async()=>{console.log("Deleting session:",f==null?void 0:f.id),y(!1)},_=e.filter(S=>{const O=S.id.toLowerCase().includes(a.toLowerCase())||S.userId.toLowerCase().includes(a.toLowerCase()),B=l==="all"||l==="active"&&new Date(S.expiresAt)>new Date||l==="expired"&&new Date(S.expiresAt)<=new Date;return O&&B});return r?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading sessions..."})]})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs("h1",{className:"text-2xl text-white font-light",children:["Sessions (",e.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage user sessions and accounts"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",onClick:()=>x(!0),children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed"]}),n.jsxs(T,{className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",onClick:()=>d(!0),children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Add Session"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"flex-1 relative",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{placeholder:"Search sessions...",value:a,onChange:S=>i(S.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Jc,{className:"w-4 h-4 text-gray-400"}),n.jsxs(hs,{value:l,onValueChange:o,children:[n.jsx(ms,{children:n.jsx(fs,{})}),n.jsxs(xs,{children:[n.jsx(Dt,{value:"all",children:"All"}),n.jsx(Dt,{value:"active",children:"Active"}),n.jsx(Dt,{value:"expired",children:"Expired"})]})]})]})]}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Session"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User ID"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Status"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Expires"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:_.map(S=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",S.id.slice(0,8),"..."]}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",S.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:S.userId}),n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-2",children:[new Date(S.expiresAt)>new Date?n.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}):n.jsx("div",{className:"w-2 h-2 bg-red-400 rounded-full"}),n.jsx("span",{className:"text-sm text-gray-400",children:new Date(S.expiresAt)>new Date?"Active":"Expired"})]})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(S.expiresAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsxs("div",{className:"flex items-center justify-end space-x-2",children:[n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>q(S),children:n.jsx(sl,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-white rounded-none",onClick:()=>Y(S),children:n.jsx(wn,{className:"w-4 h-4"})}),n.jsx(T,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 rounded-none",onClick:()=>te(S),children:n.jsx(fn,{className:"w-4 h-4"})})]})})]},S.id))})]})})}),j&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Data"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>x(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Sessions"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),n.jsx(me,{id:"session-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var O;const S=parseInt(((O=document.getElementById("session-count"))==null?void 0:O.value)||"5");J(S)},disabled:P,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:P?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-3 h-3 mr-2"}),"Seed Sessions"]})})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Xs,{className:"w-5 h-5 text-white"}),n.jsx("h4",{className:"text-white font-light",children:"Seed Accounts"})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(xe,{htmlFor:"account-count",className:"text-sm text-gray-400 font-light",children:"Number of accounts"}),n.jsx(me,{id:"account-count",type:"number",min:"1",max:"100",defaultValue:"5",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx(T,{onClick:()=>{var O;const S=parseInt(((O=document.getElementById("account-count"))==null?void 0:O.value)||"5");W(S)},disabled:P,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none mt-6 disabled:opacity-50",children:P?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-3 h-3 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Xs,{className:"w-3 h-3 mr-2"}),"Seed Accounts"]})})]})]}),N.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Session Seeding Terminal",lines:N,isRunning:P,className:"w-full",defaultCollapsed:!0})})]}),n.jsx("div",{className:"flex justify-end mt-6 pt-6 border-t border-dashed border-white/10",children:n.jsx(T,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Close"})})]})}),c&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Create Session"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>d(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),n.jsx(me,{id:"create-user-id",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"create-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),n.jsx(me,{id:"create-expires",type:"datetime-local",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>d(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:()=>ee({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Create"})]})]})}),m&&f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Session"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>u(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",f.id.slice(0,8),"..."]}),n.jsx("div",{className:"text-sm text-gray-400",children:f.userId})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-user-id",className:"text-sm text-gray-400 font-light",children:"User ID"}),n.jsx(me,{id:"edit-user-id",defaultValue:f.userId,className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-expires",className:"text-sm text-gray-400 font-light",children:"Expires At"}),n.jsx(me,{id:"edit-expires",type:"datetime-local",defaultValue:new Date(f.expiresAt).toISOString().slice(0,16),className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>u(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:()=>ie({}),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),p&&f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Delete Session"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",f.id.slice(0,8),"..."]}),n.jsx("div",{className:"text-sm text-gray-400",children:f.userId})]})]}),n.jsx("p",{className:"text-gray-400",children:"Are you sure you want to delete this session? This action cannot be undone."})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>y(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:X,className:"bg-red-600 hover:bg-red-700 text-white border border-red-600 rounded-none",children:"Delete"})]})]})}),w&&f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Session Details"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>v(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 rounded-none border border-dashed border-white/20 bg-white/10 flex items-center justify-center",children:n.jsx(Ie,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"text-white font-light",children:["Session ",f.id.slice(0,8),"..."]}),n.jsx("div",{className:"text-sm text-gray-400",children:f.userId})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"ID:"}),n.jsx("span",{className:"text-white text-sm",children:f.id})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"User ID:"}),n.jsx("span",{className:"text-white text-sm",children:f.userId})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Status:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.expiresAt)>new Date?"Active":"Expired"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Expires:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.expiresAt).toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Created:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.createdAt).toLocaleString()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{className:"text-gray-400",children:"Updated:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(f.updatedAt).toLocaleString()})]})]})]}),n.jsx("div",{className:"flex justify-end mt-6",children:n.jsx(T,{onClick:()=>v(!1),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Close"})})]})})]})}function Rb(e){const t=h.useRef(null),r=h.useRef(null),s=h.useRef(0),a=5;h.useEffect(()=>{const i=()=>{try{const o=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}`;console.log("🔌 Attempting to connect to WebSocket:",o),t.current=new WebSocket(o),t.current.onopen=()=>{console.log("✅ WebSocket connected successfully"),s.current=0,r.current&&(clearTimeout(r.current),r.current=null)},t.current.onmessage=c=>{try{const d=JSON.parse(c.data);console.log("📨 WebSocket message received:",d),e(d)}catch(d){console.error("❌ Failed to parse WebSocket message:",d)}},t.current.onclose=c=>{if(console.log("🔌 WebSocket disconnected:",c.code,c.reason),c.code===1006||c.code===1001){console.log("ℹ️ WebSocket server not available (running in normal mode)");return}if(s.current<a){s.current++;const d=Math.min(1e3*2**s.current,1e4);console.log(`🔄 Attempting to reconnect in ${d}ms (attempt ${s.current}/${a})`),r.current=setTimeout(()=>{i()},d)}else console.log("❌ Max reconnection attempts reached")},t.current.onerror=c=>{console.error("❌ WebSocket error:",c)}}catch(l){console.error("❌ Failed to connect WebSocket:",l)}};return i(),()=>{t.current&&t.current.close(),r.current&&clearTimeout(r.current)}},[e])}function Mb(){var v,j,x,f,g,N,C,P,k,R,J,W,q,Y,te,ee,ie,X,_,S,O,B,z,b,E,L,M;const[e,t]=h.useState(null),[r,s]=h.useState(null),[a,i]=h.useState(null),[l,o]=h.useState(!0),[c,d]=h.useState(null);Rb(A=>{A.type==="config_changed"?(console.log("🔄 Config changed, refreshing data..."),setTimeout(()=>{m(),u(),p()},500)):A.type==="connected"&&console.log("✅ Connected to Better Auth Studio WebSocket")}),h.useEffect(()=>{m(),u(),p()},[]);const m=async()=>{var A;try{const $=await(await fetch("/api/config")).json();(A=$.studio)!=null&&A.version&&d(`v${$.studio.version}`),t($)}catch(K){console.error("Failed to fetch config:",K)}finally{o(!1)}},u=async()=>{try{const K=await(await fetch("/api/health")).json();s(K.system||{studioVersion:c||"v1.0.0",nodeVersion:process.version,platform:navigator.platform,uptime:"2h 15m"})}catch(A){console.error("Failed to fetch system info:",A),s({studioVersion:c||"v1.0.0",nodeVersion:"v18.0.0",platform:"macOS",uptime:"2h 15m"})}},p=async()=>{try{const K=await(await fetch("/api/plugins")).json();i(K)}catch(A){console.error("Failed to fetch plugins:",A),i({plugins:[],configPath:null,totalPlugins:0,error:"Failed to fetch plugins"})}},y=A=>{switch(A==null?void 0:A.toLowerCase()){case"postgresql":case"postgres":return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(Ue,{className:"w-3 h-3"}),"Connected"]});case"mysql":return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(Ue,{className:"w-3 h-3"}),"Connected"]});case"sqlite":return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(Rs,{className:"w-3 h-3"}),"Local"]});default:return n.jsxs(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:[n.jsx(cr,{className:"w-3 h-3"}),"Unknown"]})}},w=A=>{switch(A.toLowerCase()){case"google":return n.jsx(ln,{className:"w-5 h-5 text-white"});case"github":return n.jsx(dr,{className:"w-5 h-5 text-white"});case"discord":return n.jsx(ln,{className:"w-5 h-5 text-white"});case"twitter":return n.jsx(ln,{className:"w-5 h-5 text-white"});default:return n.jsx(ln,{className:"w-5 h-5 text-white"})}};return l?n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-white"})}):n.jsxs("div",{className:"space-y-8 animate-fade-in",children:[n.jsx("div",{className:"flex items-center justify-between p-5 pt-7",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-normal text-white tracking-tight",children:"Settings"}),n.jsx("p",{className:"text-gray-300 mt-2",children:"Configure your Better Auth application"})]})}),n.jsx("hr",{className:"w-full border-white/15 h-px"}),n.jsx("hr",{className:"w-full border-white/15 h-px"}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 p-5",children:[n.jsxs(ot,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[n.jsxs(qt,{children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(ts,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Application"})]}),n.jsx(er,{children:"Basic application configuration"})]}),n.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),n.jsxs(ct,{className:"space-y-0 px-0 pb-0 border-b-none",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ln,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"App Name"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Application display name"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.appName)||"Better Auth"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(z0,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Base URL"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Application base URL"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.baseURL)||"http://localhost:3000"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ol,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Base Path"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Auth API base path"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-mono font-medium text-white",children:(e==null?void 0:e.basePath)||"/api/auth"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Secret"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Encryption secret"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:(e==null?void 0:e.secret)==="Configured"?"Configured":"Not set"})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none",children:[n.jsxs(qt,{children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Database"})]}),n.jsx(er,{children:"Database connection and configuration"})]}),n.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),n.jsxs(ct,{className:"space-y-0 px-0 pb-0 border-b-none",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:((v=e==null?void 0:e.database)==null?void 0:v.type)&&((j=e==null?void 0:e.database)==null?void 0:j.type.charAt(0).toUpperCase())+((x=e==null?void 0:e.database)==null?void 0:x.type.slice(1))||"Unknown"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Database Type"})]})]}),((f=e==null?void 0:e.database)==null?void 0:f.type)&&y(e.database.type)]}),((g=e==null?void 0:e.database)==null?void 0:g.dialect)&&n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Dialect"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Database dialect"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:e.database.dialect})})]}),((N=e==null?void 0:e.database)==null?void 0:N.casing)&&n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ts,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Casing"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Table name casing"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white capitalize",children:e.database.casing})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Pu,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Debug Logs"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Database debug logging"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(C=e==null?void 0:e.database)!=null&&C.debugLogs?n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Providers"})]}),n.jsx(er,{children:"Configured authentication providers"})]}),n.jsx(ct,{className:"p-0",children:e!=null&&e.socialProviders&&e.socialProviders.length>0?e.socialProviders.map((A,K)=>n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[w(A.type),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white capitalize",children:A.type}),n.jsx("p",{className:"text-xs text-gray-400",children:A.clientId?"Configured":"Not configured"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:A.clientId?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Active"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Setup Required"]})})]},K)):n.jsxs("div",{className:"text-center py-8",children:[n.jsx(dr,{className:"w-8 h-8 text-white mx-auto mb-2"}),n.jsx("p",{className:"text-sm text-gray-400",children:"No providers configured"})]})})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Et,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Email & Password"})]}),n.jsx(er,{children:"Email authentication settings"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Et,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Email Authentication"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Allow users to sign up with email"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(P=e==null?void 0:e.emailAndPassword)!=null&&P.enabled?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]})})]}),((k=e==null?void 0:e.emailAndPassword)==null?void 0:k.enabled)&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Sign Up"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Allow new user registration"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(R=e==null?void 0:e.emailAndPassword)!=null&&R.disableSignUp?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Email Verification"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Require email verification"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(J=e==null?void 0:e.emailAndPassword)!=null&&J.requireEmailVerification?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Required"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Optional"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ol,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Password Length"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Min/Max password length"})]})]}),n.jsx("div",{className:"text-right",children:n.jsxs("p",{className:"text-sm font-medium text-white",children:[((W=e==null?void 0:e.emailAndPassword)==null?void 0:W.minPasswordLength)||8," -"," ",((q=e==null?void 0:e.emailAndPassword)==null?void 0:q.maxPasswordLength)||128]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ui,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Auto Sign In"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Auto sign in after registration"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(Y=e==null?void 0:e.emailAndPassword)!=null&&Y.autoSignIn?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Disabled"]})})]})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Session"})]}),n.jsx(er,{children:"Session management settings"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Session Duration"}),n.jsx("p",{className:"text-xs text-gray-400",children:"How long sessions last"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(te=e==null?void 0:e.session)!=null&&te.expiresIn?`${Math.floor(e.session.expiresIn/(60*60*24))} days`:"7 days"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Default"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Pu,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Update Age"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Session refresh interval"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white",children:(ee=e==null?void 0:e.session)!=null&&ee.updateAge?`${Math.floor(e.session.updateAge/(60*60))} hours`:"24 hours"})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ui,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Session Refresh"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Auto refresh sessions"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(ie=e==null?void 0:e.session)!=null&&ie.disableSessionRefresh?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Store in Database"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Store sessions in database"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(X=e==null?void 0:e.session)!=null&&X.storeSessionInDatabase?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Rs,{className:"w-3 h-3"}),"Secondary Storage"]})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Rate Limiting"})]}),n.jsx(er,{children:"API rate limiting configuration"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limiting"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Enable rate limiting"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(_=e==null?void 0:e.rateLimit)!=null&&_.enabled?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Disabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(pr,{className:"w-5 h-5 text-red-400"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Rate Limit Window"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Time window for rate limiting"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(S=e==null?void 0:e.rateLimit)!=null&&S.window?`${e.rateLimit.window} seconds`:"10 seconds"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Window"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Max Requests"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Maximum requests per window"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:((O=e==null?void 0:e.rateLimit)==null?void 0:O.max)||100}),n.jsx("p",{className:"text-xs text-gray-400",children:"Requests"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ie,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Storage"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Rate limit storage type"})]})]}),n.jsx("div",{className:"text-right",children:n.jsx("p",{className:"text-sm font-medium text-white capitalize",children:((B=e==null?void 0:e.rateLimit)==null?void 0:B.storage)||"memory"})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(ts,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Advanced"})]}),n.jsx(er,{children:"Advanced configuration options"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Ol,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Secure Cookies"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Use secure cookies"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(z=e==null?void 0:e.advanced)!=null&&z.useSecureCookies?n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Disabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(dr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"CSRF Check"}),n.jsx("p",{className:"text-xs text-gray-400",children:"CSRF protection"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(b=e==null?void 0:e.advanced)!=null&&b.disableCSRFCheck?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(sl,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"IP Tracking"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Track IP addresses"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(L=(E=e==null?void 0:e.advanced)==null?void 0:E.ipAddress)!=null&&L.disableIpTracking?n.jsxs(n.Fragment,{children:[n.jsx(on,{className:"w-3 h-3"}),"Disabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(S0,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Telemetry"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Usage analytics"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs group-hover:bg-white group-hover:border-black group-hover:text-black bg-black/70 border border-white/15 rounded-none border-dashed flex items-center gap-1",children:(M=e==null?void 0:e.telemetry)!=null&&M.enabled?n.jsxs(n.Fragment,{children:[n.jsx(cr,{className:"w-3 h-3"}),"Enabled"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ue,{className:"w-3 h-3"}),"Disabled"]})})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black rounded-none",children:[n.jsxs(qt,{className:"border-b border-white/15",children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Rs,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"System Info"})]}),n.jsx(er,{children:"Better Auth Studio system information"})]}),n.jsxs(ct,{className:"p-0",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ui,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Studio Version"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Better Auth Studio"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:c||"v1.0.0"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Latest"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Rs,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Node.js Version"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Runtime environment"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(r==null?void 0:r.nodeVersion)||"v18.0.0"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Current"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(ln,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Platform"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Operating system"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(r==null?void 0:r.platform)||"macOS"}),n.jsx("p",{className:"text-xs text-gray-400",children:"System"})]})]}),n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15 last:border-b-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Uptime"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Service uptime"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:(r==null?void 0:r.uptime)||"2h 15m"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Running"})]})]})]})]}),n.jsxs(ot,{className:"border-white/15 bg-black/70 px-0 sm:px-0 md:px-0 lg:px-0 xl:px-0 rounded-none lg:col-span-2",children:[n.jsxs(qt,{children:[n.jsxs(Zt,{className:"text-white flex items-center space-x-2",children:[n.jsx(Tu,{className:"w-5 h-5 text-white"}),n.jsx("span",{children:"Plugins"})]}),n.jsx(er,{children:"Better Auth plugins enabled in your configuration"})]}),n.jsx("hr",{className:"w-full border-white/15 h-px -mt-3 mb-1"}),n.jsx(ct,{className:"space-y-0 px-0 pb-0 border-b-none",children:a!=null&&a.plugins&&a.plugins.length>0?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between p-4 px-5 border-b border-white/15",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Rs,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"Total Plugins"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Currently enabled plugins"})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"text-sm font-medium text-white",children:a.totalPlugins}),n.jsx("p",{className:"text-xs text-gray-400",children:"Active"})]})]}),a.plugins.map((A,K)=>n.jsxs("div",{className:`flex items-center justify-between p-4 px-5 ${K<a.plugins.length-1?"border-b border-white/15":""}`,children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Tu,{className:"w-5 h-5 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:A.name.slice(0,1).toUpperCase()+A.name.slice(1).replace("-"," ")}),n.jsx("p",{className:"text-xs text-gray-400",children:A.description})]})]}),n.jsx("div",{className:"text-right flex items-center space-x-2",children:n.jsxs(le,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400 flex items-center gap-1",children:[n.jsx(Ue,{className:"w-3 h-3"}),"Enabled"]})})]},A.id)),a.configPath&&n.jsx("div",{className:"p-4 px-5 bg-black/30 border-t border-white/10",children:n.jsxs("p",{className:"text-xs text-gray-400",children:["Config file:"," ",n.jsx("span",{className:"text-white font-mono",children:a.configPath})]})})]}):n.jsxs("div",{className:"flex items-center justify-between p-4 px-5",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(cr,{className:"w-5 h-5 text-yellow-400"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium text-white",children:"No Plugins Enabled"}),n.jsx("p",{className:"text-xs text-gray-400",children:(a==null?void 0:a.error)||"No plugins are currently configured in your Better Auth setup"})]})]}),n.jsx(le,{variant:"secondary",className:"text-xs bg-yellow-900/50 border border-yellow-500/30 text-yellow-400 rounded-sm",children:"None"})]})})]})]})]})}function qu(){var ie,X;const{orgId:e,teamId:t}=Xc(),[r,s]=h.useState(null),[a,i]=h.useState([]),[l,o]=h.useState(!0),[c,d]=h.useState("details"),[m,u]=h.useState(!1),[p,y]=h.useState(!1),[w,v]=h.useState(""),[j,x]=h.useState([]),[f,g]=h.useState([]),[N,C]=h.useState({name:""});h.useEffect(()=>{t&&(P(),k())},[t]);const P=async()=>{try{const S=await(await fetch(`/api/teams/${t}`)).json();S.success&&S.team?(s(S.team),C({name:S.team.name})):S.team?(s(S.team),C({name:S.team.name})):D.error("Team not found")}catch(_){console.error("Failed to fetch team:",_),D.error("Failed to load team")}finally{o(!1)}},k=async()=>{try{const S=await(await fetch(`/api/teams/${t}/members`)).json();S.success&&i(S.members||[])}catch(_){console.error("Failed to fetch team members:",_),D.error("Failed to load team members")}},R=async()=>{try{const S=await(await fetch("/api/users?limit=10000")).json(),O=a.map(z=>z.userId),B=(S.users||[]).filter(z=>!O.includes(z.id));x(B)}catch(_){console.error("Failed to fetch available users:",_),D.error("Failed to load users")}},J=async()=>{if(!N.name){D.error("Please enter a team name");return}const _=D.loading("Updating team...");try{const O=await(await fetch(`/api/teams/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:N.name})})).json();O.success?(await P(),y(!1),D.success("Team updated successfully!",{id:_})):D.error(`Error updating team: ${O.error||"Unknown error"}`,{id:_})}catch(S){console.error("Error updating team:",S),D.error("Error updating team",{id:_})}},W=async()=>{if(f.length===0){D.error("Please select at least one user");return}const _=D.loading(`Adding ${f.length} members...`);try{const O=await(await fetch(`/api/teams/${t}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userIds:f})})).json();O.success?(await k(),u(!1),g([]),v(""),D.success(`Successfully added ${f.length} members!`,{id:_})):D.error(`Error adding members: ${O.error||"Unknown error"}`,{id:_})}catch(S){console.error("Error adding members:",S),D.error("Error adding members",{id:_})}},q=async(_,S)=>{const O=D.loading(`Removing ${S}...`);try{const z=await(await fetch(`/api/team-members/${_}`,{method:"DELETE",headers:{"Content-Type":"application/json"}})).json();z.success?(await k(),D.success(`${S} removed from team!`,{id:O})):D.error(`Error removing member: ${z.error||"Unknown error"}`,{id:O})}catch(B){console.error("Error removing team member:",B),D.error("Error removing team member",{id:O})}},Y=()=>{R(),u(!0)},te=_=>{g(S=>S.includes(_)?S.filter(O=>O!==_):[...S,_])},ee=j.filter(_=>_.name.toLowerCase().includes(w.toLowerCase())||_.email.toLowerCase().includes(w.toLowerCase()));return l?n.jsx("div",{className:"flex items-center justify-center h-32",children:n.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[n.jsx(st,{className:"w-6 h-6 text-white animate-spin"}),n.jsx("div",{className:"text-white text-sm",children:"Loading team details..."})]})}):r?n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:`/organizations/${r.organizationId}`,children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsxs(T,{onClick:Y,className:"border border-dashed border-white/20 text-white hover:bg-white/10 bg-transparent rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add Members"]}),n.jsxs(T,{onClick:()=>y(!0),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(wn,{className:"w-4 h-4 mr-2"}),"Edit Team"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-12 h-12 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-light",children:r.name}),n.jsx("div",{className:"flex items-center space-x-2",children:r.organization&&n.jsxs(es,{to:`/organizations/${r.organizationId}`,className:"text-gray-400 hover:text-white text-sm",children:[n.jsx(Le,{className:"w-4 h-4 inline mr-1"}),r.organization.name]})})]})]}),n.jsx("div",{className:"border-b border-white/10",children:n.jsxs("nav",{className:"flex space-x-8",children:[n.jsxs("button",{onClick:()=>d("details"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="details"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Details"})]}),n.jsxs("button",{onClick:()=>d("members"),className:`flex items-center space-x-2 px-3 py-4 text-sm font-medium border-b-2 transition-all duration-200 ${c==="members"?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-gray-300"}`,children:[n.jsx(he,{className:"w-4 h-4"}),n.jsx("span",{children:"Members"}),a.length>0&&n.jsx(le,{variant:"secondary",className:"text-xs bg-white/10 border border-white/20 rounded-sm",children:a.length})]})]})}),c==="details"&&n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:[n.jsx("h3",{className:"text-lg text-white font-light mb-4",children:"Team Information"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Name"}),n.jsx("p",{className:"text-white mt-1",children:r.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Organization"}),n.jsx("p",{className:"text-white mt-1",children:((ie=r.organization)==null?void 0:ie.name)||"Unknown"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Created"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm text-gray-400 font-light",children:"Last Updated"}),n.jsx("p",{className:"text-white mt-1",children:new Date(r.updatedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})})]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(he,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:a.length}),n.jsx("p",{className:"text-sm text-gray-400",children:"Members"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx($i,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:Math.ceil((new Date().getTime()-new Date(r.createdAt).getTime())/(1e3*60*60*24))}),n.jsx("p",{className:"text-sm text-gray-400",children:"Days Active"})]})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-6",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx(Le,{className:"w-8 h-8 text-white"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl text-white font-light",children:"1"}),n.jsx("p",{className:"text-sm text-gray-400",children:"Organization"})]})]})})]})]}),c==="members"&&n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsxs("h3",{className:"text-lg text-white font-light",children:["Team Members (",a.length,")"]}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage members of this team"})]})}),a.length>0?n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none",children:n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b border-dashed border-white/10",children:[n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"User"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Email"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Role"}),n.jsx("th",{className:"text-left py-4 px-4 text-white font-light",children:"Joined"}),n.jsx("th",{className:"text-right py-4 px-4 text-white font-light",children:"Actions"})]})}),n.jsx("tbody",{children:a.map(_=>n.jsxs("tr",{className:"border-b border-dashed border-white/5 hover:bg-white/5",children:[n.jsx("td",{className:"py-4 px-4",children:n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("img",{src:_.user.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.user.id}`,alt:_.user.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:_.user.name}),n.jsxs("div",{className:"text-sm text-gray-400",children:["ID: ",_.user.id]})]})]})}),n.jsx("td",{className:"py-4 px-4 text-white",children:_.user.email}),n.jsx("td",{className:"py-4 px-4",children:n.jsx(le,{variant:"secondary",className:"text-xs bg-blue-900/10 border border-dashed border-blue-500/30 text-blue-400/70 rounded-none capitalize",children:_.role})}),n.jsx("td",{className:"py-4 px-4 text-sm text-gray-400",children:new Date(_.joinedAt).toLocaleDateString()}),n.jsx("td",{className:"py-4 px-4 text-right",children:n.jsx("div",{className:"flex items-center justify-end space-x-2",children:n.jsxs(T,{variant:"outline",size:"sm",className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",onClick:()=>q(_.id,_.user.name),children:[n.jsx(fn,{className:"w-4 h-4 mr-1"}),"Remove"]})})})]},_.id))})]})})}):n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-12",children:n.jsxs("div",{className:"text-center",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"No Members Yet"}),n.jsx("p",{className:"text-gray-400 mb-6",children:"Add members to this team to get started."}),n.jsxs(T,{onClick:Y,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add First Members"]})]})})]}),m&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Add Team Members"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>{u(!1),g([]),v("")},className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"relative",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{placeholder:"Search users by name or email...",value:w,onChange:_=>v(_.target.value),className:"pl-10 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),f.length>0&&n.jsx("div",{className:"bg-blue-900/20 border border-blue-500/30 rounded-none p-3",children:n.jsxs("p",{className:"text-blue-400 text-sm",children:[f.length," user",f.length!==1?"s":""," selected"]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none max-h-96 overflow-y-auto",children:ee.length>0?n.jsx("div",{className:"divide-y divide-white/5",children:ee.map(_=>n.jsxs("div",{className:`flex items-center space-x-3 p-4 cursor-pointer hover:bg-white/5 ${f.includes(_.id)?"bg-blue-900/20":""}`,onClick:()=>te(_.id),children:[n.jsx("input",{type:"checkbox",checked:f.includes(_.id),onChange:()=>te(_.id),className:"rounded border-gray-300"}),n.jsx("img",{src:_.image||`https://api.dicebear.com/7.x/avataaars/svg?seed=${_.id}`,alt:_.name,className:"w-10 h-10 rounded-none border border-dashed border-white/20"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"text-white font-light",children:_.name}),n.jsx("div",{className:"text-sm text-gray-400",children:_.email})]})]},_.id))}):n.jsx("div",{className:"p-8 text-center",children:n.jsx("p",{className:"text-gray-400",children:"No users found matching your search."})})})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>{u(!1),g([]),v("")},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsxs(T,{onClick:W,disabled:f.length===0,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:[n.jsx(Hr,{className:"w-4 h-4 mr-2"}),"Add ",f.length," Member",f.length!==1?"s":""]})]})]})}),p&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-md rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit Team"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>y(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-white/10 border border-dashed border-white/20 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("div",{className:"text-white font-light",children:r.name}),n.jsx("div",{className:"text-sm text-gray-400",children:(X=r.organization)==null?void 0:X.name})]})]}),n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"edit-team-name",className:"text-sm text-gray-400 font-light",children:"Team Name"}),n.jsx(me,{id:"edit-team-name",value:N.name,onChange:_=>C({name:_.target.value}),placeholder:"e.g. Development Team",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-3 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>y(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:J,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update Team"})]})]})})]}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsx("div",{className:"flex items-center space-x-4",children:n.jsx(es,{to:`/organizations/${e}`,children:n.jsxs(T,{variant:"ghost",className:"text-gray-400 hover:text-white rounded-none",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Organization"]})})}),n.jsxs("div",{className:"text-center py-12",children:[n.jsx(he,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),n.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Team Not Found"}),n.jsx("p",{className:"text-gray-400",children:"The team you're looking for doesn't exist."})]})]})}function Ib(){const e=En(),[t,r]=h.useState([]),[s,a]=h.useState(!0),[i,l]=h.useState(null),[o,c]=h.useState(""),[d,m]=h.useState("all"),[u,p]=h.useState(1),[y]=h.useState(20);h.useEffect(()=>{w()},[]);const w=async()=>{try{const P=await(await fetch("/api/plugins")).json(),k=(P==null?void 0:P.plugins).find(R=>R.id==="teams");l({enabled:!!k,availablePlugins:(P==null?void 0:P.plugins).map(R=>R.id),configPath:P.configPath,teamsPlugin:(P==null?void 0:P.plugins).find(R=>R.id==="teams")}),k?await v():a(!1)}catch(C){console.error("Failed to check teams plugin status:",C),l({enabled:!1,error:"Failed to check plugin status"}),a(!1)}},v=async()=>{try{const P=await(await fetch("/api/teams")).json();P.success&&r(P.teams||[])}catch(C){console.error("Failed to fetch teams:",C),D.error("Failed to load teams")}finally{a(!1)}},j=t.filter(C=>{var k;const P=C.name.toLowerCase().includes(o.toLowerCase())||((k=C.organization)==null?void 0:k.name.toLowerCase().includes(o.toLowerCase()));if(d==="all")return P;if(d==="recent"){const R=new Date;return R.setDate(R.getDate()-7),P&&new Date(C.createdAt)>R}return P}),x=u*y,f=x-y,g=j.slice(f,x),N=Math.ceil(j.length/y);return s?n.jsx("div",{className:"flex items-center justify-center min-h-screen",children:n.jsx(st,{className:"w-8 h-8 animate-spin text-white"})}):i!=null&&i.enabled?n.jsxs("div",{className:"p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-light tracking-tight text-white",children:"Teams"}),n.jsxs("p",{className:"text-gray-400 mt-1",children:[j.length," team",j.length!==1?"s":""," found"]})]}),n.jsx("div",{className:"flex items-center space-x-3",children:n.jsxs(T,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Create Team"]})})]}),n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"relative flex-1 max-w-md",children:[n.jsx(Gr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),n.jsx(me,{type:"text",placeholder:"Search teams...",value:o,onChange:C=>c(C.target.value),className:"pl-10 bg-black border-dashed border-white/20 text-white placeholder-gray-400 focus:ring-2 focus:ring-white focus:border-transparent"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(T,{variant:d==="all"?"default":"outline",size:"sm",onClick:()=>m("all"),className:d==="all"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"All"}),n.jsx(T,{variant:d==="recent"?"default":"outline",size:"sm",onClick:()=>m("recent"),className:d==="recent"?"bg-white text-black":"border-dashed border-white/20 text-white hover:bg-white/10",children:"Recent"})]})]}),g.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(he,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-light text-white mb-2",children:"No teams found"}),n.jsx("p",{className:"text-gray-400 mb-6",children:o?"Try adjusting your search terms":"Get started by creating your first team"}),!o&&n.jsxs(T,{onClick:()=>e("/teams/new"),className:"bg-white text-black hover:bg-gray-200 border-dashed",children:[n.jsx(Lr,{className:"w-4 h-4 mr-2"}),"Create Team"]})]}):n.jsx("div",{className:"grid gap-4",children:g.map(C=>{var P;return n.jsx("div",{className:"bg-black/30 border border-white/15 rounded-none p-4 hover:bg-black/40 transition-colors cursor-pointer",onClick:()=>e(`/teams/${C.id}`),children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-10 h-10 bg-white/10 rounded-none flex items-center justify-center",children:n.jsx(he,{className:"w-5 h-5 text-white"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium",children:C.name}),n.jsxs("p",{className:"text-gray-400 text-sm",children:[(P=C.organization)==null?void 0:P.name," • ",C.memberCount||0," members"]})]})]}),n.jsx("div",{className:"flex items-center space-x-2",children:n.jsx(le,{variant:"secondary",className:"text-xs bg-green-900/50 border border-dashed rounded-none border-green-500/30 text-green-400",children:"Active"})})]})},C.id)})}),N>1&&n.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[n.jsx(T,{variant:"outline",size:"sm",onClick:()=>p(Math.max(1,u-1)),disabled:u===1,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Previous"}),n.jsxs("span",{className:"text-gray-400 text-sm",children:["Page ",u," of ",N]}),n.jsx(T,{variant:"outline",size:"sm",onClick:()=>p(Math.min(N,u+1)),disabled:u===N,className:"border-dashed border-white/20 text-white hover:bg-white/10 disabled:opacity-50",children:"Next"})]})]}):n.jsxs("div",{className:"space-y-6 p-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl text-white font-light",children:"Teams"}),n.jsx("p",{className:"text-gray-400 mt-1",children:"Manage your application organizations"})]})}),n.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:n.jsxs("div",{className:"flex items-start space-x-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx(Le,{className:"w-12 h-12 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h3",{className:"text-xl text-white font-light mb-2",children:"Organization Plugin Required"}),n.jsx("p",{className:"text-gray-300 mb-6",children:"To use Organizations in Better Auth Studio, you need to enable the organization plugin in your Better Auth configuration."}),n.jsxs("div",{className:"bg-black/50 border border-dashed border-white/20 rounded-none p-4 mb-6",children:[n.jsx("h4",{className:"text-white font-light mb-3",children:"Follow these steps:"}),n.jsx("ol",{className:"text-gray-300 space-y-2 text-sm list-decimal list-inside",children:n.jsxs("li",{children:["Import the plugin in your auth configuration file",(i==null?void 0:i.configPath)&&n.jsxs("span",{className:"text-gray-400",children:[" (",i.configPath,")"]}),":"]})}),n.jsx("div",{className:"mt-4 bg-black/70 border border-dashed border-white/10 rounded-none p-3 overflow-x-auto",children:n.jsxs("pre",{className:"text-sm text-gray-300",children:[n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ betterAuth }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"import"})," ","{ organization }"," ",n.jsx("span",{className:"text-blue-400",children:"from"})," ",n.jsx("span",{className:"text-green-400",children:'"better-auth/plugins/organization"'})," ",n.jsx("br",{}),n.jsx("span",{className:"text-blue-400",children:"export const"})," ",n.jsx("span",{className:"text-yellow-300",children:"auth"})," ="," ",n.jsx("span",{className:"text-yellow-300",children:"betterAuth"}),"(","{"," ",n.jsx("br",{}),n.jsx("span",{className:"text-gray-500 pl-10",children:"// ... your existing configuration"})," ",n.jsx("br",{}),n.jsx("span",{className:"text-red-300 pl-10",children:"plugins"}),": [ ",n.jsx("br",{}),n.jsxs("span",{className:"text-yellow-300 pl-12",children:["organization(",")"]}),n.jsx("br",{}),n.jsx("span",{className:"pl-10",children:"]"})," ",n.jsx("br",{}),"}",") ",n.jsx("br",{})]})}),n.jsx("div",{className:"mt-4",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"2. Do migrations to create the organizations table"})}),n.jsx("div",{className:"mt-2",children:n.jsx("p",{className:"text-gray-400 text-sm",children:"3. Restart your application to apply the changes"})})]}),(i==null?void 0:i.availablePlugins)&&i.availablePlugins.length>0&&n.jsx("div",{className:"mb-4",children:n.jsxs("p",{className:"text-gray-400 text-sm",children:["Currently enabled plugins: ",i.availablePlugins.join(", ")]})}),n.jsx(T,{onClick:()=>window.location.reload(),className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Check Again"}),n.jsxs("div",{className:"mt-4 text-xs text-gray-500",children:["Need help? Check the"," ",n.jsx("a",{href:"https://better-auth.com/docs/plugins/organization",target:"_blank",rel:"noopener noreferrer",className:"text-white hover:underline",children:"Better Auth Organization Plugin Documentation"})]})]})]})})]})}function Lb(){const{userId:e}=Xc(),t=En(),[r,s]=h.useState(null),[a,i]=h.useState([]),[l,o]=h.useState([]),[c,d]=h.useState([]),[m,u]=h.useState(!0),[p,y]=h.useState("details"),[w,v]=h.useState(!1),[j,x]=h.useState(!1),[f,g]=h.useState(!1),[N,C]=h.useState([]),[P,k]=h.useState(!1),[R,J]=h.useState({});h.useEffect(()=>{e&&(te(),ee())},[e]);const W=async z=>{try{const b=await fetch("/api/geo/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ipAddress:z})});if(b.ok){const E=await b.json();if(E.success&&E.location)return E.location}return null}catch(b){return console.error("Failed to resolve IP location:",b),null}},q=async z=>{const b=z.map(async M=>{if(!R[M.id]){const A=await W(M.ipAddress);if(A)return{sessionId:M.id,location:A}}return null}),E=await Promise.all(b),L={};E.forEach(M=>{M&&(L[M.sessionId]=M.location)}),Object.keys(L).length>0&&J(M=>({...M,...L}))},Y=z=>{if(!z)return"🌍";const b=z.toUpperCase().split("").map(E=>127397+E.charCodeAt(0));return String.fromCodePoint(...b)},te=async()=>{try{const z=await fetch(`/api/users/${e}`);if(z.ok){const b=await z.json();s(b.user)}else D.error("Failed to fetch user details"),t("/users")}catch(z){console.error("Failed to fetch user details:",z),D.error("Failed to fetch user details"),t("/users")}finally{u(!1)}},ee=async()=>{try{const[z,b,E]=await Promise.all([fetch(`/api/users/${e}/organizations`),fetch(`/api/users/${e}/teams`),fetch(`/api/users/${e}/sessions`)]);if(z.ok){const L=await z.json();i(L.memberships||[])}if(b.ok){const L=await b.json();o(L.memberships||[])}if(E.ok){const M=(await E.json()).sessions||[];d(M),q(M)}}catch(z){console.error("Failed to fetch user memberships:",z)}},ie=async()=>{var L,M;if(!r)return;const z=(L=document.getElementById("edit-name"))==null?void 0:L.value,b=(M=document.getElementById("edit-email"))==null?void 0:M.value;if(!z||!b){D.error("Please fill in all fields");return}const E=D.loading("Updating user...");try{const K=await(await fetch(`/api/users/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,email:b})})).json();K.success?(s({...r,name:z,email:b}),v(!1),D.success("User updated successfully!",{id:E})):D.error(`Error updating user: ${K.error||"Unknown error"}`,{id:E})}catch(A){console.error("Error updating user:",A),D.error("Error updating user",{id:E})}},X=async()=>{if(!r)return;const z=D.loading("Banning user...");try{const E=await(await fetch(`/api/users/${e}/ban`,{method:"POST"})).json();E.success?(D.success("User banned successfully!",{id:z}),t("/users")):D.error(`Error banning user: ${E.error||"Unknown error"}`,{id:z})}catch(b){console.error("Error banning user:",b),D.error("Error banning user",{id:z})}},_=async z=>{const b=D.loading("Removing user from organization...");try{const L=await(await fetch(`/api/organizations/members/${z}`,{method:"DELETE"})).json();L.success?(i(M=>M.filter(A=>A.id!==z)),D.success("User removed from organization!",{id:b})):D.error(`Error removing user: ${L.error||"Unknown error"}`,{id:b})}catch(E){console.error("Error removing user from organization:",E),D.error("Error removing user from organization",{id:b})}},S=async z=>{const b=D.loading("Removing user from team...");try{const L=await(await fetch(`/api/teams/members/${z}`,{method:"DELETE"})).json();L.success?(o(M=>M.filter(A=>A.id!==z)),D.success("User removed from team!",{id:b})):D.error(`Error removing user: ${L.error||"Unknown error"}`,{id:b})}catch(E){console.error("Error removing user from team:",E),D.error("Error removing user from team",{id:b})}},O=async z=>{const b=D.loading("Deleting session...");try{const L=await(await fetch(`/api/sessions/${z}`,{method:"DELETE"})).json();L.success?(d(M=>M.filter(A=>A.id!==z)),D.success("Session deleted successfully!",{id:b})):D.error(`Error deleting session: ${L.error||"Unknown error"}`,{id:b})}catch(E){console.error("Error deleting session:",E),D.error("Error deleting session",{id:b})}},B=async(z=3)=>{if(e){C([]),k(!0),C([{id:"start",type:"info",message:`Starting session seeding process for ${z} sessions...`,timestamp:new Date}]);try{const E=await(await fetch(`/api/users/${e}/seed-sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({count:z})})).json();if(E.success){const L=E.results.map((A,K)=>A.success?{id:`session-${K}`,type:"progress",message:`Creating session ${K+1}: ${A.session.token.substring(0,20)}... from ${A.session.ipAddress}`,timestamp:new Date,status:"completed"}:{id:`session-${K}`,type:"error",message:`Failed to create session ${K+1}: ${A.error}`,timestamp:new Date});C(A=>[...A,...L]);const M=E.results.filter(A=>A.success).length;C(A=>[...A,{id:"complete",type:"success",message:`✅ Session seeding completed! Created ${M}/${z} sessions successfully`,timestamp:new Date}]),ee()}else C(L=>[...L,{id:"error",type:"error",message:`❌ Session seeding failed: ${E.error||"Unknown error"}`,timestamp:new Date}])}catch(b){C(E=>[...E,{id:"error",type:"error",message:`❌ Network error: ${b}`,timestamp:new Date}])}finally{k(!1)}}};return m?n.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:n.jsx("div",{className:"text-white text-lg",children:"Loading user details..."})}):r?n.jsxs("div",{className:"min-h-screen bg-black w-full",children:[n.jsxs("div",{className:"w-full px-6 py-8",children:[n.jsxs("div",{className:"mb-8",children:[n.jsxs(T,{variant:"outline",onClick:()=>t("/users"),className:"mb-4 border-none text-white",children:[n.jsx(pa,{className:"w-4 h-4 mr-2"}),"Back to Users"]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-16 h-16 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:r.image?n.jsx("img",{src:r.image,alt:r.name,className:"w-16 h-16 object-cover"}):n.jsx(Xs,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold text-white",children:r.name}),n.jsx("p",{className:"text-gray-400",children:r.email}),n.jsx("div",{className:"flex items-center space-x-2 mt-2",children:n.jsx(le,{variant:r.emailVerified?"default":"destructive",className:"rounded-none",children:r.emailVerified?"Verified":"Unverified"})})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs(T,{variant:"outline",onClick:()=>v(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[n.jsx(wn,{className:"w-4 h-4 mr-2"}),"Edit User"]}),n.jsxs(T,{variant:"outline",onClick:()=>x(!0),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Eu,{className:"w-4 h-4 mr-2"}),"Ban User"]})]})]})]}),n.jsxs("div",{className:"border border-dashed border-white/10 rounded-none",children:[n.jsx("div",{className:"border-b border-dashed border-white/10",children:n.jsx("nav",{className:"flex space-x-8 px-6",children:[{id:"details",name:"Details",icon:Xs},{id:"organizations",name:"Organizations",icon:Le,count:a.length},{id:"teams",name:"Teams",icon:he,count:l.length},{id:"sessions",name:"Sessions",icon:pr,count:c.length}].map(z=>n.jsxs("button",{onClick:()=>y(z.id),className:`flex items-center space-x-2 py-4 px-2 border-b-2 font-medium text-sm ${p===z.id?"border-white text-white":"border-transparent text-gray-400 hover:text-white hover:border-white/50"}`,children:[n.jsx(z.icon,{className:"w-4 h-4"}),n.jsx("span",{children:z.name}),z.count!==void 0&&n.jsx(le,{variant:"outline",className:"rounded-none text-xs",children:z.count})]},z.id))})}),n.jsxs("div",{className:"p-6",children:[p==="details"&&n.jsx("div",{className:"space-y-6",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),n.jsx("div",{className:"text-white",children:r.name})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),n.jsxs("div",{className:"text-white flex items-center space-x-2",children:[n.jsx(Et,{className:"w-4 h-4"}),n.jsx("span",{children:r.email})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email Status"}),n.jsx(le,{variant:r.emailVerified?"default":"destructive",className:"rounded-none",children:r.emailVerified?"Verified":"Unverified"})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Created"}),n.jsxs("div",{className:"text-white flex items-center space-x-2",children:[n.jsx($i,{className:"w-4 h-4"}),n.jsx("span",{children:new Date(r.createdAt).toLocaleDateString()})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Last Updated"}),n.jsxs("div",{className:"text-white flex items-center space-x-2",children:[n.jsx($i,{className:"w-4 h-4"}),n.jsx("span",{children:new Date(r.updatedAt).toLocaleDateString()})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"User ID"}),n.jsx("div",{className:"text-white font-mono text-sm",children:r.id})]})]})]})}),p==="organizations"&&n.jsx("div",{className:"space-y-4",children:a.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(Le,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Organizations"}),n.jsx("p",{className:"text-gray-400",children:"This user is not a member of any organizations."})]}):n.jsx("div",{className:"grid gap-4",children:a.map(z=>n.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-12 h-12 bg-gray-800 border border-dashed border-white/20 flex items-center justify-center",children:z.organization.image?n.jsx("img",{src:z.organization.image,alt:z.organization.name,className:"w-12 h-12 object-cover"}):n.jsx(Le,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium",children:z.organization.name}),n.jsxs("p",{className:"text-gray-400 text-sm",children:["@",z.organization.slug]}),n.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[n.jsx(le,{variant:"outline",className:"rounded-none text-xs",children:z.role}),n.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(z.joinedAt).toLocaleDateString()]})]})]})]}),n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>_(z.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Du,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},z.id))})}),p==="teams"&&n.jsx("div",{className:"space-y-4",children:l.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(he,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Teams"}),n.jsx("p",{className:"text-gray-400",children:"This user is not a member of any teams."})]}):n.jsx("div",{className:"grid gap-4",children:l.map(z=>n.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx("div",{className:"w-12 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:n.jsx(he,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{children:[n.jsx("h3",{className:"text-white font-medium",children:z.team.name}),n.jsxs("p",{className:"text-gray-400 text-sm",children:["in ",z.team.organizationName]}),n.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[n.jsx(le,{variant:"outline",className:"rounded-none text-xs",children:z.role}),n.jsxs("span",{className:"text-gray-400 text-xs",children:["Joined ",new Date(z.joinedAt).toLocaleDateString()]})]})]})]}),n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>S(z.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Du,{className:"w-4 h-4 mr-1"}),"Remove"]})]})},z.id))})}),p==="sessions"&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-medium text-white",children:"Sessions"}),n.jsx("p",{className:"text-gray-400 text-sm",children:"Manage user authentication sessions"})]}),n.jsxs(T,{variant:"outline",onClick:()=>{C([]),k(!1),g(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})]}),c.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(pr,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:"No Sessions"}),n.jsx("p",{className:"text-gray-400",children:"This user has no active sessions."})]}):n.jsx("div",{className:"grid gap-4",children:c.map(z=>{var b,E,L,M;return n.jsx("div",{className:"border border-dashed border-white/10 rounded-none p-4 hover:bg-white/5 transition-colors",children:n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{className:"flex items-center space-x-4 flex-1",children:[n.jsx("div",{className:"w-12 -mt-2 h-12 bg-black/80 border border-dashed border-white/20 flex items-center justify-center rounded-none",children:n.jsx(R0,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center space-x-3 mb-2",children:n.jsxs("h3",{className:"text-white font-medium",children:["Session ",z.id.substring(0,8),"..."]})}),n.jsxs("div",{className:"flex items-center space-x-4 mb-1",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ln,{className:"w-4 h-4 text-white"}),n.jsx("span",{className:"text-white text-sm",children:z.ipAddress})]}),n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx("span",{className:"text-gray-400 text-xs",children:"📍"}),n.jsxs("span",{className:"text-gray-300 text-sm",children:[((b=R[z.id])==null?void 0:b.city)||"...",","," ",((E=R[z.id])==null?void 0:E.country)||"..."]}),((L=R[z.id])==null?void 0:L.countryCode)&&n.jsx("span",{className:"text-sm ml-1",children:Y((M=R[z.id])==null?void 0:M.countryCode)})]})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(pr,{className:"w-4 h-4 text-white"}),n.jsx("span",{className:"text-gray-400 text-sm",children:"Expires:"}),n.jsx("span",{className:"text-white text-sm",children:new Date(z.expiresAt).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})})]}),n.jsxs(T,{variant:"outline",size:"sm",onClick:()=>O(z.id),className:"border border-dashed border-red-400/50 text-red-400 hover:bg-red-400/10 rounded-none",children:[n.jsx(Eu,{className:"w-4 h-4 mr-1"}),"Revoke"]})]})]})]})})},z.id)})})]})]})]})]}),w&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 rounded-none p-6 w-full max-w-md",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Edit User"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>v(!1),className:"text-gray-400 hover:text-white rounded-none",children:"×"})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-16 h-16 bg-black/80 border border-dashed border-white/20 flex items-center justify-center",children:r!=null&&r.image?n.jsx("img",{src:r.image,alt:r.name,className:"w-16 h-16 object-cover"}):n.jsx(Xs,{className:"w-8 h-8 text-white"})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("h4",{className:"text-white font-medium",children:r==null?void 0:r.name}),n.jsx("p",{className:"text-gray-400 text-sm",children:r==null?void 0:r.email})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Name"}),n.jsx("input",{id:"edit-name",type:"text",defaultValue:(r==null?void 0:r.name)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-2",children:"Email"}),n.jsx("input",{id:"edit-email",type:"email",defaultValue:(r==null?void 0:r.email)||"",className:"w-full px-3 py-2 bg-gray-800 border border-dashed border-white/20 rounded-none text-white placeholder-gray-400 focus:outline-none focus:border-white/50"})]})]}),n.jsxs("div",{className:"flex justify-end space-x-2 mt-6",children:[n.jsx(T,{variant:"outline",onClick:()=>v(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:ie,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none",children:"Update"})]})]})}),j&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black border border-dashed border-red-400/50 rounded-none p-6 w-full max-w-md",children:[n.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"Ban User"}),n.jsxs("p",{className:"text-gray-400 mb-6",children:["Are you sure you want to ban ",n.jsx("strong",{children:r.name}),"? This will prevent them from accessing the system."]}),n.jsxs("div",{className:"flex justify-end space-x-2",children:[n.jsx(T,{variant:"outline",onClick:()=>x(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:X,className:"bg-red-600 text-white hover:bg-red-700 rounded-none",children:"Ban User"})]})]})}),f&&n.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:n.jsxs("div",{className:"bg-black/90 border border-dashed border-white/20 p-6 w-full max-w-2xl rounded-none",children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h3",{className:"text-lg text-white font-light",children:"Seed Sessions"}),n.jsx(T,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:n.jsx(be,{className:"w-4 h-4"})})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(pr,{className:"w-5 h-5 text-white"}),n.jsxs("h4",{className:"text-white font-light",children:["Create Sessions for ",r==null?void 0:r.name]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{children:[n.jsx(xe,{htmlFor:"session-count",className:"text-sm text-gray-400 font-light",children:"Number of sessions"}),n.jsx(me,{id:"session-count",type:"number",min:"1",max:"50",defaultValue:"3",className:"mt-1 border border-dashed border-white/20 bg-black/30 text-white rounded-none"})]}),n.jsx("p",{className:"text-xs text-gray-400",children:"Each session will have a unique token, IP address, and 7-day expiration."})]})]}),N.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(us,{title:"Session Seeding Terminal",lines:N,isRunning:P,className:"w-full",defaultCollapsed:!1})})]}),n.jsxs("div",{className:"flex justify-end space-x-2 mt-6 pt-6 border-t border-dashed border-white/10",children:[n.jsx(T,{variant:"outline",onClick:()=>g(!1),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Cancel"}),n.jsx(T,{onClick:()=>{var b;const z=parseInt(((b=document.getElementById("session-count"))==null?void 0:b.value)||"3");B(z)},disabled:P,className:"bg-white hover:bg-white/90 text-black border border-white/20 rounded-none disabled:opacity-50",children:P?n.jsxs(n.Fragment,{children:[n.jsx(st,{className:"w-4 h-4 mr-2 animate-spin"}),"Seeding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ie,{className:"w-4 h-4 mr-2"}),"Seed Sessions"]})})]})]})})]}):n.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:n.jsx("div",{className:"text-white text-lg",children:"User not found"})})}function Ob(){return n.jsx(L0,{children:n.jsxs(Kv,{children:[n.jsx(Eb,{children:n.jsxs($v,{children:[n.jsx(Ut,{path:"/",element:n.jsx(Pb,{})}),n.jsx(Ut,{path:"/users",element:n.jsx(bx,{})}),n.jsx(Ut,{path:"/users/:userId",element:n.jsx(Lb,{})}),n.jsx(Ut,{path:"/organizations",element:n.jsx(wx,{})}),n.jsx(Ut,{path:"/organizations/:orgId",element:n.jsx(zb,{})}),n.jsx(Ut,{path:"/teams",element:n.jsx(Ib,{})}),n.jsx(Ut,{path:"/teams/:teamId",element:n.jsx(qu,{})}),n.jsx(Ut,{path:"/organizations/:orgId/teams/:teamId",element:n.jsx(qu,{})}),n.jsx(Ut,{path:"/sessions",element:n.jsx(Db,{})}),n.jsx(Ut,{path:"/settings",element:n.jsx(Mb,{})})]})}),n.jsx(j0,{theme:"dark",position:"top-right",richColors:!0,closeButton:!0})]})})}Yl.createRoot(document.getElementById("root")).render(n.jsx(V.StrictMode,{children:n.jsx(Ob,{})}));
package/public/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Better Auth Studio</title>
8
- <script type="module" crossorigin src="/assets/main-Cpdra9l2.js"></script>
8
+ <script type="module" crossorigin src="/assets/main-jcB2p8Xw.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/main-DBAg_Mbk.css">
10
10
  </head>
11
11
  <body>