1import{j as e}from"./vendor-markdown-C-I3nZWo.js";import{r as i}from"./vendor-charts-DphG3eWF.js";import{r as O,B as u,C as R,b as A,t as W,Y as q,Z as G,_ as I,$ as M,a0 as j,aE as $,aF as V,s as v,a3 as c}from"./index-DFoQxP2Z.js";import{A as Y}from"./AdminGuard-BjBCZ7PM.js";import{B as g}from"./badge-DvZAazPQ.js";import{G as K,o as b,R as k,a0 as X,E}from"./vendor-icons-DptrxPFP.js";import{f as Z}from"./vendor-date-DwvsUr7l.js";import"./vendor-office-CYA1a3lH.js";import"./vendor-query-Csct0vqx.js";import"./vendor-radix-DiGlQgnh.js";import"./vendor-supabase-C6T5JIOu.js";import"./vendor-analytics-4JMxWFgu.js";import"./vendor-forms-Crpao7PO.js";const B={failed:0,pending:1,live:2},H=5;function J({status:n}){const o=n??"pending";return o==="live"?e.jsx(g,{className:"bg-emerald-500/15 text-emerald-700 hover:bg-emerald-500/15 border-emerald-500/30",children:"Live"}):o==="failed"?e.jsx(g,{className:"bg-red-500/15 text-red-700 hover:bg-red-500/15 border-red-500/30",children:"Failed"}):o==="pending"?e.jsx(g,{className:"bg-amber-500/15 text-amber-800 hover:bg-amber-500/15 border-amber-500/30",children:"Pending"}):e.jsx(g,{variant:"outline",children:n})}function Q(n){return[`Enable ${n}.proteinos.com in Lovable`,"1. Lovable â Project Settings â Project â Domains â Connect Domain",`2. Enter: ${n}.proteinos.com`,'3. Advanced â check "Domain uses Cloudflare or a similar proxy"',"4. Complete the TXT verification step shown by Lovable","5. Wait ~1 min, then click Re-check in /admin/domains","",`Working URL meanwhile: https://proteinos.com/w/${n}/`].join(` 2`)}function ee(){const[n,o]=i.useState([]),[h,w]=i.useState(!0),[d,z]=i.useState("all"),[N,P]=i.useState(""),[T,S]=i.useState({}),[x,y]=i.useState(!1),C=async()=>{w(!0);const{data:s,error:a}=await v.from("organizations").select("id, name, slug, subdomain_status, subdomain_checked_at");if(a){c.error("Failed to load workspaces",{description:a.message}),w(!1);return}const t=(s??[]).slice().sort((r,l)=>{const f=B[r.subdomain_status]??99,L=B[l.subdomain_status]??99;return f!==L?f-L:r.name.localeCompare(l.name)});o(t),w(!1)};i.useEffect(()=>{C()},[]);const m=i.useMemo(()=>{const s=N.trim().toLowerCase();return n.filter(a=>!(d!=="all"&&a.subdomain_status!==d||s&&!a.name.toLowerCase().includes(s)&&!a.slug.toLowerCase().includes(s)))},[n,d,N]),D=async s=>{const{data:a,error:t}=await v.from("organizations").select("id, name, slug, subdomain_status, subdomain_checked_at").eq("id",s).maybeSingle();!t&&a&&o(r=>r.map(l=>l.id===s?a:l))},_=async s=>{S(a=>({...a,[s.id]:!0}));try{const{data:a,error:t}=await v.functions.invoke("workspace-subdomain-probe",{body:{org_id:s.id}});if(t)throw t;const r=a==null?void 0:a.status;r==="live"?c.success(`${s.slug}.proteinos.com is live`):c.warning(`${s.slug}.proteinos.com is ${r??"unreachable"}`,{description:a==null?void 0:a.detail}),await D(s.id)}catch(a){const t=a instanceof Error?a.message:String(a);c.error(`Re-check failed for ${s.slug}`,{description:t})}finally{S(a=>{const t={...a};return delete t[s.id],t})}},U=async()=>{if(m.length){y(!0);try{const s=[...m];let a=0,t=0;await new Promise(r=>{const l=()=>{if(t>=s.length&&a===0)return r();for(;a<H&&t<s.length;){const f=s[t++];a++,_(f).finally(()=>{a--,l()})}};l()}),c.success(`Re-checked ${s.length} workspace${s.length===1?"":"s"}`)}finally{y(!1)}}},F=async s=>{try{await navigator.clipboard.writeText(Q(s.slug)),c.success(`Setup steps copied for ${s.slug}`)}catch{c.error("Copy failed")}},p=i.useMemo(()=>{const s={all:n.length,live:0,pending:0,failed:0};for(const a of n)s[a.subdomain_status]=(s[a.subdomain_status]??0)+1;return s},[n]);return e.jsxs("div",{className:"max-w-7xl mx-auto p-6 space-y-4",children:[" ",e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-light flex items-center gap-2",children:[e.jsx(K,{className:"h-5 w-5"})," Workspace domains"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Status of each workspace's branded subdomain. Path URL"," ",e.jsx("code",{className:"text-xs",children:"proteinos.com/w/<slug>"})," always works as a fallback."]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",onClick:C,disabled:h||x,children:h?e.jsx(b,{className:"h-4 w-4 animate-spin"}):e.jsx(k,{className:"h-4 w-4"})}),e.jsxs(u,{size:"sm",onClick:U,disabled:x||!m.length,children:[x?e.jsx(b,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),"Re-check ",d==="all"?"all":d]})]})]}),e.jsx(R,{children:e.jsxs(A,{className:"flex flex-wrap items-center gap-2 p-4",children:[e.jsx(W,{placeholder:"Search workspace or slugâ¦",value:N,onChange:s=>P(s.target.value),className:"max-w-xs"}),e.jsxs(q,{value:d,onValueChange:s=>
2z(s),children:[e.jsx(G,{className:"w-48",children:e.jsx(I,{})}),e.jsxs(M,{children:[e.jsxs(j,{value:"all",children:["All (",p.all??0,")"]}),e.jsxs(j,{value:"failed",children:["Failed (",p.failed??0,")"]}),e.jsxs(j,{value:"pending",children:["Pending (",p.pending??0,")"]}),e.jsxs(j,{value:"live",children:["Live (",p.live??0,")"]})]})]}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:[m.length," of ",n.length," shown"]})]})}),e.jsx(R,{children:e.jsx(A,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs uppercase text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Workspace"}),e.jsx("th",{className:"text-left p-3",children:"Subdomain"}),e.jsx("th",{className:"text-left p-3",children:"Status"}),e.jsx("th",{className:"text-left p-3",children:"Last checked"}),e.jsx("th",{className:"text-right p-3",children:"Actions"})]})}),e.jsxs("tbody",{children:[m.map(s=>{const a=!!T[s.id],t=s.subdomain_status==="live";return e.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[e.jsx("td",{className:"p-3 font-medium",children:s.name}),e.jsx("td",{className:"p-3 font-mono text-xs",children:e.jsxs("a",{href:$(s.slug),target:"_blank",rel:"noreferrer",className:"hover:underline",children:[s.slug,".proteinos.com"]})}),e.jsx("td",{className:"p-3",children:e.jsx(J,{status:s.subdomain_status})}),e.jsx("td",{className:"p-3 text-muted-foreground whitespace-nowrap",title:s.subdomain_checked_at??"",children:s.subdomain_checked_at?Z(new Date(s.subdomain_checked_at),{addSuffix:!0}):"Never"}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>_(s),disabled:a||x,children:[a?e.jsx(b,{className:"h-3 w-3 animate-spin"}):e.jsx(k,{className:"h-3 w-3"}),e.jsx("span",{className:"ml-1.5",children:"Re-check"})]}),!t&&e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>F(s),children:[e.jsx(X,{className:"h-3 w-3"}),e.jsx("span",{className:"ml-1.5",children:"Setup steps"})]}),e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs("a",{href:V(s.slug),target:"_blank",rel:"noreferrer",title:"Open path URL (always works)",children:[e.jsx(E,{className:"h-3 w-3"}),e.jsxs("span",{className:"ml-1.5",children:["/w/",s.slug]})]})}),t&&e.jsx(u,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx("a",{href:$(s.slug),target:"_blank",rel:"noreferrer",title:"Open subdomain",children:e.jsx(E,{className:"h-3 w-3"})})})]})})]},s.id)}),!h&&!m.length&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center text-muted-foreground",children:"No workspaces match."})}),h&&e.jsx("tr",{children:e.jsxs("td",{colSpan:5,className:"p-8 text-center text-muted-foreground",children:[e.jsx(b,{className:"h-4 w-4 animate-spin inline"})," Loadingâ¦"]})})]})]})})})})]})}function xe(){return e.jsx(O,{children:e.jsx(Y,{children:e.jsx(ee,{})})})}export{xe 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.