1import{a as _,r as a,j as t}from"./index-DBSR3mmU.js";import{A as T}from"./AdminLayout-CulU2gKz.js";import{y as W}from"./admin-CIGbsrv7.js";import"./markdown-vvQDngQ1.js";import"./marked.esm-r2HKmrw_.js";const s={bg:"var(--mlr-bg-card, #16182a)",deep:"var(--mlr-bg-deep, #0b0b1a)",border:"1px solid var(--mlr-border, rgba(255,255,255,0.1))",text:"var(--mlr-text, #e2e8f0)",sub:"var(--mlr-text-muted, #94a3b8)",cyan:"#00d4ff",purple:"var(--mlr-purple, #a855f7)"},C={get:"#34d399",post:"#00d4ff",put:"#fbbf24",patch:"#a855f7",delete:"#f87171"},I=()=>{const{t:n}=_(),[l,g]=a.useState(null),[b,y]=a.useState(!1),[j,v]=a.useState(!0),[u,S]=a.useState(""),[h,z]=a.useState(null);a.useEffect(()=>{let e=!0;return W().then(o=>{e&&g(o)}).catch(()=>{e&&y(!0)}).finally(()=>{e&&v(!1)}),()=>{e=!1}},[]);const i=a.useMemo(()=>{if(!l)return[];const e=[];for(const[o,c]of Object.entries(l.paths))for(const[r,d]of Object.entries(c))e.push({path:o,method:r,op:d,tag:d.tags?.[0]||"other",secured:Array.isArray(d.security)&&d.security.length>0});return e},[l]),m=a.useMemo(()=>{const e=u.trim().toLowerCase();return e?i.filter(o=>o.path.toLowerCase().includes(e)||o.method.toLowerCase().includes(e)||(o.op.summary||"").toLowerCase().includes(e)||o.tag.toLowerCase().includes(e)):i},[i,u]),x=a.useMemo(()=>{const e=new Map;for(const o of m)(e.get(o.tag)??e.set(o.tag,[]).get(o.tag)).push(o);return Array.from(e.entries()).sort((o,c)=>o[0].localeCompare(c[0]))},[m]),f=a.useMemo(()=>({ops:i.length,tags:new Set(i.map(e=>e.tag)).size,unsecured:i.filter(e=>!e.secured).length}),[i]),p=(e,o)=>t.jsx("span",{style:{fontSize:10,fontWeight:700,color:o,border:`1px solid ${o}55`,borderRadius:5,padding:"1px 6px",whiteSpace:"nowrap"},children:e});return t.jsx(T,{title:n("admin.api_docs.title","API Reference"),subtitle:n("admin.api_docs.subtitle","Every endpoint the platform serves â method, path, auth, and rate limit. Generated from the live routes."),children:j?t.jsx("p",{style:{color:s.sub,padding:20},children:n("admin.api_docs.loading","Loading the API contractâ¦")}):b||!l?t.jsx("p",{style:{color:"#f87171",padding:20},children:n("admin.api_docs.error","Could not load the spec. It is admin-only â make sure you are signed in as an admin.")}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{background:s.bg,border:s.border,borderRadius:14,padding:18},children:[t.jsxs("div",{style:{fontSize:16,fontWeight:800,color:s.text},children:[l.info.title," ",t.jsxs("span",{style:{color:s.cyan,fontSize:13},children:["v",l.info.version]})]}),t.jsxs("div",{style:{display:"flex",gap:24,flexWrap:"wrap",marginTop:12},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:24,fontWeight:800,color:s.cyan},children:f.ops}),t.jsx("div",{style:{fontSize:11,color:s.sub,textTransform:"uppercase"},children:n("admin.api_docs.stat.endpoints","endpoints")})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:24,fontWeight:800,color:s.purple},children:f.tags}),t.jsx("div",{style:{fontSize:11,color:s.sub,textTransform:"uppercase"},children:n("admin.api_docs.stat.groups","groups")})]}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:24,fontWeight:800,color:f.unsecured>0?"#fbbf24":s.text},children:f.unsecured}),t.jsx("div",{style:{fontSize:11,color:s.sub,textTransform:"uppercase"},children:n("admin.api_docs.stat.public","public (no auth)")})]})]})]}),t.jsx("input",{value:u,onChange:e=>S(e.target.value),placeholder:n("admin.api_docs.search","Search path, method, or summaryâ¦"),style:{background:s.deep,border:s.border,borderRadius:10,padding:"11px 14px",color:s.text,fontSize:14,outline:"none"}}),x.length===0?t.jsx("p",{style:{color:s.sub,padding:20},children:n("admin.api_docs.no_match","No endpoints match.")}):x.map(([e,o])=>{const c=h===e||u.trim().length>0;return t.jsxs("div",{style:{background:s.bg,border:s.border,borderRadius:14,overflow:"hidden"},children:[t.jsxs("button",{type:"button",onClick:()=>z(h===e?null:e),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",background:"transparent",border:"none",cursor:"pointer",padding:"14px 18px",color:s.text,fontSize:14,fontWeight:700},children:[t.jsx("span",{style:{textTransform:"capitalize"},children:e.replace(/_/g," ")}),t.jsx("span",{style:{color:s.sub,fontSize:12,fontWeight:500},children:o.length})]}),c&&t.jsx("div",{style:{borderTop:s.border},children:o.map((r,d)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"10px 18px",borderTop:d===0?"none":s.border},children:[t.jsx("span",{style:{fontSize:11,fontWeight:800,textTransform:"uppercase",color:C[r.method]||s.sub,minWidth:52},children:r.method}),t.jsx("code",{style:{fontSize:12.5,color:s.text,fontFamily:"monospace",flex:1,minWidth:180,wordBreak:"break-all"},children:r.path}),t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[r.secured?p(n("admin.api_docs.auth","auth"),s.cyan):p(n("admin.api_docs.public_badge","public"),"#fbbf24"),r.op["x-guards"]?.map(w=>p(w.replace(/.*\\/,""),s.purple)),r.op["x-rate-limit"]&&p(`â± ${r.op["x-rate-limit"]}`,s.sub),r.op["x-unversioned"]&&p(n("admin.api_docs.legacy","legacy"),"#f87171")]}),r.op.summary&&t.jsx("div",{style:{flexBasis:"100%",fontSize:12,color:s.sub,paddingLeft:64},children:r.op.summary})]},`${r.method}-${r.path}-${d}`))})]},e)})]})})};export{I 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.