1import{j as e}from"./vendor-radix-dialog-Bajn-rmU.js";import{e as Te,r as a}from"./vendor-react-3efCd3Xu.js";import{f as ze,s as i,B as o,j as q,Q as qe,K as Be,D as me,aw as he,ax as B,a as xe,b as ue,c as je,k as Ee,F as ae,ah as ge,ap as d,H as He,U as $e,V as We,W as Ge,Y as Ye,Z as Ce,_ as E,C as Je,a8 as Ke,ay as Xe,$ as Se,a0 as Ze,a1 as Qe,az as Ve,d as es,aA as ke,G as ss,i as ts,a7 as as,L as rs}from"./index-BO2DrnSZ.js";import{C as j,a as H,b as $,c as g,d as ns}from"./card-aReiJtCY.js";import{A as is,a as ls,b as cs,c as os,d as ds,e as ps,f as ms,g as hs}from"./alert-dialog-DOxH7aZ-.js";import{I as re}from"./input-BUS4uccm.js";import{L as W}from"./label-6WfnpmaK.js";import{T as Fe}from"./textarea-C7hUdQoy.js";import{T as xs,a as us,b as se,c as te}from"./tabs-C6X_2Rtp.js";import{S as js}from"./switch-DcLaOA1S.js";import{F as ne}from"./file-code-BwnoHyXo.js";import{F as Oe}from"./folder-CObChmWi.js";import{T as fe}from"./trash-2-BiWoNsku.js";import{A as gs,a as fs}from"./avatar-BQHif_ax.js";import{C as ys}from"./chart-column-C8pwaIyD.js";import{D as Ns}from"./download-C__mD6Bm.js";import{R as De,B as ws,X as _e,Y as Pe,T as Ae,b as vs,L as bs,C as Cs,d as Ss}from"./vendor-recharts-CTYRDcfh.js";import{C as ks}from"./crown-L8oQqnc8.js";import"./vendor-monaco-CMWCqPY1.js";import"./vendor-radix-dropdown-ByCK_Pdu.js";import"./vendor-radix-tooltip-C2Li1WOL.js";import"./vendor-radix-select-dh3VcV8n.js";import"./vendor-radix-tabs-4sRtMwAd.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Le=ze("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Ds=({snippets:c})=>{const G=Te(),[D,b]=a.useState([]),[l,Y]=a.useState(null),[Z,Q]=a.useState([]),[V,C]=a.useState(!0),[ie,S]=a.useState(!1),[le,F]=a.useState(!1),[_,O]=a.useState(!1),[P,J]=a.useState(""),[K,M]=a.useState(""),[X,A]=a.useState(!1);a.useEffect(()=>{w()},[]),a.useEffect(()=>{l&&y(l)},[l]);const w=async()=>{try{const{data:t,error:r}=await i.from("snippet_collections").select("*").order("updated_at",{ascending:!1});if(r)throw r;const x=await Promise.all((t||[]).map(async v=>{const{count:I}=await i.from("snippet_collection_items").select("*",{count:"exact",head:!0}).eq("collection_id",v.id);return{...v,item_count:I||0}}));b(x)}catch(t){console.error("Error loading collections:",t)}finally{C(!1)}},y=async t=>{S(!0);try{const{data:r,error:x}=await i.from("snippet_collection_items").select("id, snippet_id, added_at").eq("collection_id",t).order("added_at",{ascending:!1});if(x)throw x;const v=await Promise.all((r||[]).map(async I=>{const{data:de}=await i.from("code_snippets").select("id, title, language, updated_at").eq("id",I.snippet_id).single();return{...I,snippet:de||void 0}}));Q(v)}catch(r){console.error("Error loading collection items:",r)}finally{S(!1)}},ce=async()=>{if(P.trim())try{const{data:{user:t}}=await i.auth.getUser();if(!t)return;const{error:r}=await i.from("snippet_collections").insert({name:P.trim(),description:K.trim()||null,is_public:X,user_id:t.id});if(r)throw r;d.success("Collection created!"),J(""),M(""),A(!1),F(!1),w()}catch(t){d.error(t.message||"Failed to create collection")}},ee=async(t,r)=>{r.stopPropagation();try{const{error:x}=await i.from("snippet_collections").delete().eq("id",t);if(x)throw x;d.success("Collection deleted"),l===t&&Y(null),w()}catch{d.error("Failed to delete collection")}},oe=async t=>{if(l)try{const{error:r}=await i.from("snippet_collection_items").insert({collection_id:l,snippet_id:t});if(r){if(r.code==="23505"){d.info("Snippet already in this collection");return}throw r}d.success("Snippet added to collection!"),O(!1),y(l),w()}catch{d.error("Failed to add snippet")}},f=async t=>{try{const{error:r}=await i.from("snippet_collection_items").delete().eq("id",t);if(r)throw r;d.success("Snippet removed from collection"),l&&y(l),w()}catch{d.error("Failed to remove snippet")}},k=D.find(t=>
6t.id===l);return V?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l&&e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>Y(null),children:"â Back"}),e.jsx("h3",{className:"font-semibold text-lg",children:k?k.name:"Collections"}),k&&e.jsxs(q,{variant:k.is_public?"default":"secondary",children:[k.is_public?e.jsx(qe,{className:"h-3 w-3 mr-1"}):e.jsx(Be,{className:"h-3 w-3 mr-1"}),k.is_public?"Public":"Private"]})]}),e.jsxs("div",{className:"flex gap-2",children:[l&&e.jsxs(me,{open:_,onOpenChange:O,children:[e.jsx(he,{asChild:!0,children:e.jsxs(o,{size:"sm",variant:"outline",className:"gap-1.5",children:[e.jsx(B,{className:"h-3.5 w-3.5"})," Add Snippet"]})}),e.jsxs(xe,{children:[e.jsx(ue,{children:e.jsx(je,{children:"Add Snippet to Collection"})}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto space-y-2",children:c.length===0?e.jsx("p",{className:"text-muted-foreground text-sm text-center py-4",children:"No snippets available"}):c.map(t=>e.jsxs("button",{onClick:()=>oe(t.id),className:"w-full flex items-center justify-between p-3 rounded-lg border border-border hover:bg-accent transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium truncate",children:t.title})]}),t.language&&e.jsx(q,{variant:"secondary",className:"text-xs",children:t.language})]},t.id))})]})]}),!l&&e.jsxs(me,{open:le,onOpenChange:F,children:[e.jsx(he,{asChild:!0,children:e.jsxs(o,{size:"sm",className:"gap-1.5",children:[e.jsx(Le,{className:"h-3.5 w-3.5"})," New Collection"]})}),e.jsxs(xe,{children:[e.jsx(ue,{children:e.jsx(je,{children:"Create Collection"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(W,{children:"Name"}),e.jsx(re,{value:P,onChange:t=>J(t.target.value),placeholder:"My Snippets"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(W,{children:"Description (optional)"}),e.jsx(Fe,{value:K,onChange:t=>M(t.target.value),placeholder:"What's in this collection?",rows:2})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(W,{children:"Public collection"}),e.jsx(js,{checked:X,onCheckedChange:A})]})]}),e.jsxs(Ee,{children:[e.jsx(o,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),e.jsx(o,{onClick:ce,disabled:!P.trim(),children:"Create"})]})]})]})]})]}),!l&&(D.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Oe,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No collections yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Organize your snippets into collections"}),e.jsxs(o,{onClick:()=>F(!0),className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"})," Create Collection"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:D.map(t=>e.jsxs(j,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>Y(t.id),children:[e.jsx(H,{className:"pb-2",children:e.jsxs($,{className:"flex items-start justify-between text-base",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"truncate",children:t.name})]}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:r=>ee(t.id,r),children:e.jsx(fe,{className:"h-3.5 w-3.5"})})]})}),e.jsxs(g,{children:[t.description&&e.jsx("p",{className:"text-xs text-muted-foreground mb-2 line-clamp-2",children:t.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.item_count," snippet",t.item_count!==1?"s":""]}),e.jsx(q,{variant:t.is_public?"default":"secondary",className:"text-[10px]",children:t.is_public?"Public":"Private"})]})]})]},t.id))})),l&&(ie?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):Z.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ne,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No snippets in this collection"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Add snippets to organize them"}),e.jsxs(o,{onClick:()=>O(!0),className:"gap-2",children:[e.jsx(B,{className:"h-4 w-4"})," Add Snippet"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Z.map(t=>{var r,x;return e.jsxs(j,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>t.snippet&&G(`/editor/${t.snippet.id}`),children:[e.jsx(H,{className:"pb-2",children:e.jsxs($,{className:"flex items-start justify-between text-base",children:[e.jsx("span",{className:"truncate",children:((r=t.snippet)==null?void 0:r.title)||"Unknown"}),e.jsxs("div",{className:"flex items-center gap-1",children:[((x=t.snippet)==null?void 0:x.language)&&e.jsx(q,{variant:"secondary",className:"text-xs",children:t.snippet.language}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:v=>{v.stopPropagation(),f(t.id)},children:e.jsx(fe,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center text-xs text-muted-foreground gap-1",children:[e.jsx(ge,{className:"h-3 w-3"}),e.jsxs("span",{children:["Added ",new Date(t.added_at).toLocaleDateString()]})]})})]},t.id)})}))]})},pe=[{id:"blank",name:"Blank",description:"Empty project with a single file",icon:"ð",files:[{name:"index.js",path:"/index.js",type:"file",language:"javascript",content:`// Start coding here 7console.log('Hello World');`}]},{id:"html-css-js",name:"HTML / CSS / JS",description:"Classic web project with HTML, CSS, and JavaScript",icon:"ð",files:[{name:"index.html",path:"/index.html",type:"file",language:"html",content:`<!DOCTYPE html> 8<html lang="en"> 9<head> 10 <meta charset="UTF-8"> 11 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 12 <title>My Web Project</title> 13 <link rel="stylesheet" href="style.css"> 14</head> 15<body> 16 <h1>Hello World</h1> 17 <p>Edit this page to get started.</p> 18 <script src="script.js"><\/script> 19</body> 20</html>`},{name:"style.css",path:"/style.css",type:"file",language:"css",content:`body { 21 font-family: system-ui, sans-serif; 22 max-width: 800px; 23 margin: 2rem auto; 24 padding: 0 1rem; 25 color: #333; 26} 27 28h1 { 29 color: #0066cc; 30}`},{name:"script.js",path:"/script.js",type:"file",language:"javascript",content:`// Add your JavaScript here 31document.addEventListener('DOMContentLoaded', () => { 32 console.log('Page loaded!'); 33});`}]},{id:"python",name:"Python Script",description:"Python project with a main script",icon:"ð",files:[{name:"main.py",path:"/main.py",type:"file",language:"python",content:`# Python Script 34def main(): 35 print("Hello, World!") 36 37 # Example: working with lists 38 numbers = [1, 2, 3, 4, 5] 39 squared = [n ** 2 for n in numbers] 40 print(f"Squared: {squared}") 41 42if __name__ == "__main__": 43 main()`},{name:"utils.py",path:"/utils.py",type:"file",language:"python",content:`# Utility functions 44 45def greet(name: str) -> str: 46 return f"Hello, {name}!" 47`}]},{id:"react",name:"React App",description:"React component with JSX and styles",icon:"âï¸",files:[{name:"App.jsx",path:"/App.jsx",type:"file",language:"javascript",content:`import React, { useState } from 'react'; 48 49function App() { 50 const [count, setCount] = useState(0); 51 52 return ( 53 <div className="app"> 54 <h1>React Counter</h1> 55 <p>Count: {count}</p> 56 <button onClick={() => setCount(count + 1)}> 57 Increment 58 </button> 59 </div> 60 ); 61} 62 63export default App;`},{name:"index.jsx",path:"/index.jsx",type:"file",language:"javascript",content:`import React from 'react'; 64import ReactDOM from 'react-dom/client'; 65import App from './App'; 66 67const root = ReactDOM.createRoot(document.getElementById('root')); 68root.render(<App />);`}]}
68,{id:"api-server",name:"API Server",description:"Express.js REST API starter",icon:"ð",files:[{name:"server.js",path:"/server.js",type:"file",language:"javascript",content:`const express = require('express'); 69const app = express(); 70const PORT = process.env.PORT || 3000; 71 72app.use(express.json()); 73 74// In-memory data store 75let items = [ 76 { id: 1, name: 'Item 1' }, 77 { id: 2, name: 'Item 2' }, 78]; 79 80// GET all items 81app.get('/api/items', (req, res) => { 82 res.json(items); 83}); 84 85// POST new item 86app.post('/api/items', (req, res) => { 87 const item = { id: Date.now(), name: req.body.name }; 88 items.push(item); 89 res.status(201).json(item); 90}); 91 92app.listen(PORT, () => { 93 console.log(\`Server running on port \${PORT}\`); 94});`}]},{id:"data-science",name:"Data Science",description:"Python data analysis with pandas and numpy",icon:"ð",files:[{name:"analysis.py",path:"/analysis.py",type:"file",language:"python",content:`import numpy as np 95 96# Generate sample data 97data = np.random.randn(100) 98 99# Basic statistics 100print(f"Mean: {np.mean(data):.4f}") 101print(f"Std Dev: {np.std(data):.4f}") 102print(f"Min: {np.min(data):.4f}") 103print(f"Max: {np.max(data):.4f}") 104print(f"Median: {np.median(data):.4f}")`}]}],_s={javascript:".js",typescript:".ts",python:".py",java:".java",cpp:".cpp",c:".c",csharp:".cs",go:".go",rust:".rs",ruby:".rb",php:".php",swift:".swift",kotlin:".kt",html:".html",css:".css",sql:".sql",json:".json"},Ps=c=>{const G=_s[c.language||""]||".txt",D=new Blob([c.content||""],{type:"text/plain"}),b=URL.createObjectURL(D),l=document.createElement("a");l.href=b,l.download=`${c.title||"snippet"}${G}`,l.click(),URL.revokeObjectURL(b)},Vs=()=>{var we;const c=Te(),[G,D]=a.useState([]),[b,l]=a.useState([]),[Y,Z]=a.useState(!0),[Q,V]=a.useState(!1),[C,ie]=a.useState(""),[S,le]=a.useState(""),[F,_]=a.useState(!1),[O,P]=a.useState(""),[J,K]=a.useState(""),[M,X]=a.useState(null),[A,w]=a.useState(null),[y,ce]=a.useState("projects"),[ee,oe]=a.useState("blank"),[f,k]=a.useState({langData:[],activityData:[],totalSnippets:0,totalCalls:0,totalForks:0}),[t,r]=a.useState(!1);a.useEffect(()=>{x(),v(),(async()=>{const{data:{user:h}}=await i.auth.getUser();X(h)})();const{data:{subscription:n}}=i.auth.onAuthStateChange((h,N)=>{X((N==null?void 0:N.user)??null)});return()=>n.unsubscribe()},[]),a.useEffect(()=>{(y==="snippets"||y==="collections")&&b.length===0&&!Q&&I(),y==="analytics"&&f.langData.length===0&&!t&&de()},[y]);const x=async()=>{const{data:{session:s}}=await i.auth.getSession();s||c("/auth")},v=async()=>{try{const{data:s,error:n}=await i.from("projects").select("*").order("updated_at",{ascending:!1});if(n)throw n;D(s||[])}catch(s){console.error("Error loading projects:",s),d.error("Failed to load projects")}finally{Z(!1)}},I=async()=>{V(!0);try{const{data:{user:s}}=await i.auth.getUser();if(!s)return;const{data:n,error:h}=await i.from("code_snippets").select("id, title, language, content, updated_at, created_at, forked_from").eq("owner_id",s.id).order("updated_at",{ascending:!1});if(h)throw h;l(n||[])}catch(s){console.error("Error loading snippets:",s),d.error("Failed to load snippets")}finally{V(!1)}},de=async()=>{r(!0);try{const{data:{user:s}}=await i.auth.getUser();if(!s)return;const{data:n}=await i.from("code_snippets").select("id, language, created_at").eq("owner_id",s.id),h=n||[],N=h.length,L={};h.forEach(p=>{const m=p.language||"unknown";L[m]=(L[m]||0)+1});const R=Object.entries(L).map(([p,m])=>({name:p,count:m})).sort((p,m)=>m.count-p.count).slice(0,10),u=new Date;u.setDate(u.getDate()-30);const T={};for(let p=0;p<30;p++){const m=new Date;m.setDate(m.getDate()-(29-p)),T[m.toISOString().split("T")[0]]=0}h.forEach(p=>{if(p.created_at){const m=p.created_at.split("T")[0];T[m]!==void 0&&T[m]++}});const U=Object.entries(T).map(([p,m])=>({date:p.slice(5),count:m})),z=h.map(p=>p.id);let ve=0,be=0;if(z.length>0){const[p,m]=await Promise.all([i.from("snippet_calls").select("*",{count:"exact",head:!0}).in("snippet_id",z.slice(0,50)),i.from("code_snippets").select("*",{count:"exact",head:!0}).in("forked_from",z.slice(0,50))]);ve=p.count||0,be=m.count||0}k({langData:R,activityData:U,totalSnippets:N,totalCalls:ve,totalForks:be})}catch(s){console.error("Error loading analytics:",s)}finally{r(!1)}},Me=async()=>{const s=O.trim();if(!s){d.error("Project name is required");return}if(s.length>100){d.error("Project name must be less than 100 characters");return}if(!/^[a-zA-Z0-9\s\-_]+$/.test(s)){d.error("Project name can only contain letters, numbers, space
104s, hyphens, and underscores");return}try{const{data:{user:n}}=await i.auth.getUser();if(!n)throw new Error("Not authenticated");const{data:h,error:N}=await i.from("projects").insert({name:s,description:J||null,owner_id:n.id}).select().single();if(N)throw N;const R=(pe.find(u=>u.id===ee)||pe[0]).files.map(u=>({project_id:h.id,name:u.name,type:u.type,content:u.content,language:u.language,path:u.path}));await i.from("project_files").insert(R),d.success("Project created successfully"),_(!1),P(""),K(""),c(`/project/${h.id}`)}catch(n){console.error("Error creating project:",n),d.error("Failed to create project")}},Ie=async()=>{await i.auth.signOut(),d.success("Signed out successfully"),c("/")},Re=async()=>{if(A)try{const{error:s}=await i.from("project_files").delete().eq("project_id",A);if(s)throw s;const{error:n}=await i.from("projects").delete().eq("id",A);if(n)throw n;d.success("Project deleted successfully"),w(null),v()}catch(s){console.error("Error deleting project:",s),d.error("Failed to delete project")}},ye=G.filter(s=>{var n;return s.name.toLowerCase().includes(C.toLowerCase())||((n=s.description)==null?void 0:n.toLowerCase().includes(C.toLowerCase()))}),Ne=b.filter(s=>s.title.toLowerCase().includes(S.toLowerCase()));if(Y)return e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})});const Ue=()=>{const{plan:s,isProOrAbove:n,subscriptionEnd:h,isLoading:N}=ts(),[L,R]=a.useState(!1),u=async()=>{R(!0);try{const{data:{session:T}}=await i.auth.getSession();if(!T)return;const{data:U,error:z}=await i.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${T.access_token}`}});if(z)throw z;U!=null&&U.url&&window.open(U.url,"_blank")}catch{d.error("Failed to open subscription portal")}finally{R(!1)}};return N?null:e.jsx(j,{className:"mb-6",children:e.jsxs(g,{className:"flex items-center justify-between py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[n?e.jsx(ks,{className:"h-5 w-5 text-primary"}):e.jsx(as,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:[s==="team"?"Team":s==="pro"?"Pro":"Free"," Plan"]}),h&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Renews ",new Date(h).toLocaleDateString()]})]})]}),e.jsx("div",{className:"flex gap-2",children:n?e.jsx(o,{variant:"outline",size:"sm",onClick:u,disabled:L,children:L?e.jsx(rs,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"h-4 w-4 mr-1"})," Manage"]})}):e.jsx(o,{size:"sm",onClick:()=>c("/pricing"),children:"Upgrade"})})]})})};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs(He,{children:[e.jsx("title",{children:"Your projects dashboard â CoderFile"}),e.jsx("meta",{name:"description",content:"Manage your CoderFile projects, snippets, and collaborators from your personal dashboard."}),e.jsx("meta",{name:"robots",content:"noindex, follow"}),e.jsx("link",{rel:"canonical",href:"https://coderfile.io/projects"}),e.jsx("meta",{property:"og:title",content:"Your projects dashboard â CoderFile"}),e.jsx("meta",{property:"og:description",content:"Manage your CoderFile projects, snippets, and collaborators from your personal dashboard."}),e.jsx("meta",{property:"og:url",content:"https://coderfile.io/projects"})]}),e.jsx("header",{className:"border-b border-border bg-background/50 backdrop-blur-sm sticky top-0 z-10",children:e.jsxs("div",{className:"container mx-auto px-4 py-4 flex items-center justify-between",children:[e.jsx("button",{onClick:()=>c("/"),className:"text-2xl font-bold hover:opacity-80 transition-opacity cursor-pointer",children:"CoderFile.io"}),e.jsx("div",{className:"flex items-center gap-4",children:M?e.jsxs($e,{children:[e.jsx(We,{asChild:!0,children:e.jsx(o,{variant:"ghost",size:"icon",className:"rounded-full",children:e.jsx(gs,{className:"h-8 w-8",children:e.jsx(fs,{children:((we=M.email)==null?void 0:we.charAt(0).toUpperCase())||"U"})})})}),e.jsxs(Ge,{align:"end",className:"w-56",children:[e.jsx(Ye,{children:e.jsxs("div",{className:"flex flex-col space-y-1",children:[e.jsx("p",{className:"text-sm font-medium leading-none",children:"Account"}),e.jsx("p",{className:"text-xs leading-none text-muted-foreground",children:M.email})]})}),e.jsx(Ce,{}),e.jsxs(E,{onClick:()=>c("/"),children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"</> Main Page"]}),e.jsxs(E,{children:[e.jsx(ae,{className:"mr-2 h-4 w-4"}),"My Projects"]}),e.jsxs(E,{onClick:()=>_(!0),children:[e.jsx(B,{className:"mr-2 h-4 w-4"}),"Create Project"]}),e.jsxs(E,{onClick:()=>c("/interview-practice"),children:[e.jsx(Ke,{className:"mr-2 h-4 w-4"}),"Practice"]}),e.jsxs(E,{onClick:()=>c("/leaderboard"),children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"Leaderboard"]}),e.jsxs(E,{onClick:()=>c("/settings"),children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),"Settings"]}),e.jsx(Ce,{}),e.jsxs(E,{onClick:Ie,children:[e.jsx(Ze,{className:"mr-2 h-4 w-4"}),"Sign Out"]})]})]}):e.jsxs(o,{variant:"outline",onClick:()=>c("/auth"),children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),"Sign In"]})})]})}),e.jsxs("main",{className:"container mx-auto px-4 py-8",children:[e.jsx("h1",{className:"sr-only",children:"Your Projects and Snippets"}),e.jsx(Ve,{variant:"card",className:"mb-6"}),e.jsx(Ue,{}),e.jsxs(xs,{value:y,onValueChange:ce,className:"w-full",children:[e.jsxs("div",{className:"flex items-center justify-between mb-8",children:[e.jsx("div",{children:e.jsxs(us,{children:[e.jsxs(se,{value:"projects",className:"gap-2",children:[e.jsx(ae,{className:"h-4 w-4"}),"My Projects"]}),e.jsxs(se,{value:"snippets",className:"gap-2",children:[e.jsx(ne,{className:"h-4 w-4"}),"My Snippets"]}
104),e.jsxs(se,{value:"collections",className:"gap-2",children:[e.jsx(Oe,{className:"h-4 w-4"}),"Collections"]}),e.jsxs(se,{value:"analytics",className:"gap-2",children:[e.jsx(ys,{className:"h-4 w-4"}),"Analytics"]})]})}),y==="projects"&&e.jsxs(me,{open:F,onOpenChange:_,children:[e.jsx(he,{asChild:!0,children:e.jsxs(o,{className:"gap-2","data-create-project":!0,children:[e.jsx(B,{className:"h-4 w-4"}),"New Project"]})}),e.jsxs(xe,{children:[e.jsxs(ue,{children:[e.jsx(je,{children:"Create New Project"}),e.jsx(es,{children:"Start a new project to organize your code files"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"name",children:"Project Name"}),e.jsx(re,{id:"name",placeholder:"My Awesome Project",value:O,onChange:s=>P(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{htmlFor:"description",children:"Description (Optional)"}),e.jsx(Fe,{id:"description",placeholder:"What's this project about?",value:J,onChange:s=>K(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(W,{children:"Template"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:pe.map(s=>e.jsxs("button",{type:"button",onClick:()=>oe(s.id),className:`flex items-center gap-2 p-2 rounded-md border text-left text-sm transition-colors ${ee===s.id?"border-primary bg-primary/10":"border-border hover:border-muted-foreground"}`,children:[e.jsx("span",{children:s.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.description})]})]},s.id))})]}),e.jsxs(Ee,{children:[e.jsx(o,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(o,{onClick:Me,children:"Create Project"})]})]})]})]}),e.jsxs(te,{value:"projects",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"relative w-64",children:[e.jsx(ke,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(re,{placeholder:"Search projects...",value:C,onChange:s=>ie(s.target.value),className:"pl-10"})]})}),ye.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ae,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:C?"No projects found":"No projects yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:C?"Try a different search term":"Create your first project to get started"}),!C&&e.jsxs(o,{onClick:()=>_(!0),className:"gap-2",children:[e.jsx(B,{className:"h-4 w-4"}),"Create Project"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:ye.map(s=>e.jsxs(j,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>c(`/project/${s.id}
104`),children:[e.jsxs(H,{children:[e.jsxs($,{className:"flex items-start justify-between",children:[e.jsx("span",{className:"truncate",children:s.name}),e.jsx(o,{variant:"ghost",size:"icon","aria-label":"Delete project",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:n=>{n.stopPropagation(),w(s.id)},children:e.jsx(fe,{className:"h-4 w-4","aria-hidden":"true"})})]}),e.jsx(ns,{className:"line-clamp-2",children:s.description||"No description"})]}),e.jsx(g,{children:e.jsx("div",{className:"flex items-center text-xs text-muted-foreground gap-4",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ge,{className:"h-3 w-3"}),e.jsx("span",{children:new Date(s.updated_at).toLocaleDateString()})]})})})]},s.id))})]}),e.jsxs(te,{value:"snippets",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"relative w-64",children:[e.jsx(ke,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(re,{placeholder:"Search snippets...",value:S,onChange:s=>le(s.target.value),className:"pl-10"})]})}),Q?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):Ne.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ne,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:S?"No snippets found":"No snippets yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:S?"Try a different search term":"Create your first snippet in the editor"}),!S&&e.jsxs(o,{onClick:()=>c("/editor/new"),className:"gap-2",children:[e.jsx(B,{className:"h-4 w-4"}),"New Snippet"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Ne.map(s=>e.jsxs(j,{className:"cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>c(`/editor/${s.id}`),children:[e.jsx(H,{children:e.jsxs($,{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"truncate text-base",children:s.title}),s.forked_from&&e.jsxs(q,{variant:"outline",className:"shrink-0 text-xs gap-1",children:[e.jsx(ss,{className:"h-3 w-3"}),"Forked"]})]}),s.language&&e.jsx(q,{variant:"secondary",className:"ml-2 shrink-0",children:s.language})]})}),e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center text-xs text-muted-foreground gap-1",children:[e.jsx(ge,{className:"h-3 w-3"}),e.jsx("span",{children:s.updated_at?new Date(s.updated_at).toLocaleDateString():"Unknown"})]}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Download snippet",onClick:n=>{n.stopPropagation(),Ps(s)},children:e.jsx(Ns,{className:"h-3.5 w-3.5"})})]})})]},s.id))})]}),e.jsx(te,{value:"collections",children:e.jsx(Ds,{snippets:b.map(s=>({id:s.id,title:s.title,language:s.language}))})}),e.jsx(te,{value:"analytics",children:t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(j,{children:e.jsxs(g,{className:"pt-6 text-center",children:[e.jsx("p",{className:"text-3xl font-bold",children:f.totalSnippets}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Snippets"})]})}),e.jsx(j,{children:e.jsxs(g,{className:"pt-6 text-center",children:[e.jsx("p",{className:"text-3xl font-bold",children:f.totalCalls}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Calls"})]})}),e.jsx(j,{children:e.jsxs(g,{className:"pt-6 text-center",children:[e.jsx("p",{className:"text-3xl font-bold",children:f.totalForks}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Forks"})]})}),e.jsx(j,{children:e.jsxs(g,{className:"pt-6 text-center",children:[e.jsx("p",{className:"text-3xl font-bold",children:f.langData.length}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Languages Used"})]})}),e.jsx(j,{children:e.jsxs(g,{className:"pt-6 text-center",children:[e.jsx("p",{className:"text-3xl font-bold",children:f.activityData.reduce((s,n)=>s+n.count,0)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Last 30 Days"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(j,{children:[e.jsx(H,{children:e.jsx($,{className:"text-base",children:"Language Breakdown"})}),e.jsx(g,{children:f.langData.length>0?e.jsx(De,{width:"100%",height:250,children:e.jsxs(ws,{data:f.langData,children:[e.jsx(_e,{dataKey:"name",fontSize:12}),e.jsx(Pe,{fontSize:12,allowDecimals:!1}),e.jsx(Ae,{}),e.jsx(vs,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No data yet"})})]}),e.jsxs(j,{children:[e.jsx(H,{children:e.jsx($,{className:"text-base",children:"Activity (Last 30 Days)"})}),e.jsx(g,{children:e.jsx(De,{width:"100%",height:250,children:e.jsxs(bs,{data:f.activityData,children:[e.jsx(Cs,{strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e.jsx(_e,{dataKey:"date",fontSize:10,interval:4}),e.jsx(Pe,{fontSize:12,allowDecimals:!1}),e.jsx(Ae,{}),e.jsx(Ss,{type:"monotone",dataKey:"count",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1})]})})})]})]})]})})]})]}),e.jsx(is,{open:A!==null,onOpenChange:()=>w(null),children:e.jsxs(ls,{children:[e.jsxs(cs,{children:[e.jsx(os,{children:"Are you sure?"}),e.jsx(ds,{children:"This action cannot be undone. This will permanently delete the project and all its files."})]}),e.jsxs(ps,{children:[e.jsx(ms,{children:"Cancel"}),e.jsx(hs,{onClick:Re,className:"bg-destructive hover:bg-destructive/90",children:"Yes, Delete"})]})]})})]})};export{Vs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.