From b38afbd8693fda96f1e6d39340604d5b1e74fc1b Mon Sep 17 00:00:00 2001 From: "release-police-please[bot]" <192060759+release-police-please[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2026 22:25:26 +0000 Subject: [PATCH] feat: Auto update UI from onetime repo --- app/assets/interface/{bundle-mBaJepD3.js => bundle-HSVNZER1.js} | 2 +- app/assets/interface/levelcode-BHbONQeU.js | 2 -- app/assets/interface/levelcode-DGHAu_R4.js | 2 ++ app/assets/interface/{main-B04oQiJI.js => main-BqCeSOyb.js} | 2 +- app/views/static/ui.html | 2 +- app/views/static/ui_levelcode.html.erb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename app/assets/interface/{bundle-mBaJepD3.js => bundle-HSVNZER1.js} (99%) delete mode 100644 app/assets/interface/levelcode-BHbONQeU.js create mode 100644 app/assets/interface/levelcode-DGHAu_R4.js rename app/assets/interface/{main-B04oQiJI.js => main-BqCeSOyb.js} (99%) diff --git a/app/assets/interface/bundle-mBaJepD3.js b/app/assets/interface/bundle-HSVNZER1.js similarity index 99% rename from app/assets/interface/bundle-mBaJepD3.js rename to app/assets/interface/bundle-HSVNZER1.js index 3520e3ef..dd28dc02 100644 --- a/app/assets/interface/bundle-mBaJepD3.js +++ b/app/assets/interface/bundle-HSVNZER1.js @@ -1,4 +1,4 @@ -import{j as e,L as G}from"./preload-helper-CAFW0lxO.js";import{u as l}from"./levelcode-BHbONQeU.js";function S(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Warning:a}=n;return t||f("Card"),i||f("CardGroup"),r||f("Kbd"),d||f("Note"),a||f("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"agent",children:"Agent"}),` +import{j as e,L as G}from"./preload-helper-CAFW0lxO.js";import{u as l}from"./levelcode-DGHAu_R4.js";function S(s){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",figure:"figure",h1:"h1",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",span:"span",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...l(),...s.components},{Card:t,CardGroup:i,Kbd:r,Note:d,Warning:a}=n;return t||f("Card"),i||f("CardGroup"),r||f("Kbd"),d||f("Note"),a||f("Warning"),e.jsxs(e.Fragment,{children:[e.jsx(n.h1,{id:"agent",children:"Agent"}),` `,e.jsxs(n.blockquote,{children:[` `,e.jsx(n.p,{children:"State a goal. The agent plans it, edits across files, runs commands behind approval gates, checks its own work, and reports back."}),` `]}),` diff --git a/app/assets/interface/levelcode-BHbONQeU.js b/app/assets/interface/levelcode-BHbONQeU.js deleted file mode 100644 index 535e5c20..00000000 --- a/app/assets/interface/levelcode-BHbONQeU.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bundle-mBaJepD3.js","assets/preload-helper-CAFW0lxO.js"])))=>i.map(i=>d[i]); -var nt=Object.defineProperty;var lt=(t,r,a)=>r in t?nt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[r]=a;var ie=(t,r,a)=>lt(t,typeof r!="symbol"?r+"":r,a);import{r as l,j as e,L as C,u as X,R as ne,b as J,_ as ot,d as it,e as ct,f as P,c as dt,g as xt,B as ut}from"./preload-helper-CAFW0lxO.js";const ht=typeof window<"u"&&window.__ENV__||{},ye=String(ht.API_BASE??"").replace(/\/+$/,"");let ce=null;async function mt(){const t=typeof document<"u"?document.querySelector('meta[name="csrf-token"]'):null,r=t==null?void 0:t.getAttribute("content");return r||(ce||(ce=fetch(`${ye}/ai/csrf`,{credentials:"include"}).then(a=>a.ok?a.json():{token:""}).then(a=>a.token??"").catch(()=>"")),ce)}class z extends Error{constructor(a,s,n){super(s);ie(this,"status");ie(this,"code");this.name="ApiError",this.status=a,this.code=n}}async function E(t,r={}){const a=r.method??(r.body!==void 0?"POST":"GET"),s={Accept:"application/json",...r.headers};r.body!==void 0&&(s["Content-Type"]="application/json"),a!=="GET"&&a!=="HEAD"&&(s["X-CSRF-Token"]=await mt());const n=await fetch(`${ye}${t}`,{method:a,headers:s,credentials:"include",body:r.body!==void 0?JSON.stringify(r.body):void 0}),o=await n.text();let d=null;if(o)try{d=JSON.parse(o)}catch{d=null}if(!n.ok){const c=d==null?void 0:d.error;throw new z(n.status,(c==null?void 0:c.message)??`Request failed (${n.status})`,c==null?void 0:c.code)}return d}function K(t){window.location.href=t}function Y(){const[t,r]=l.useState({loading:!0,profile:null});return l.useEffect(()=>{let a=!0;return E("/api/levelcode/v1/account/profile").then(s=>{a&&r({loading:!1,profile:s})}).catch(()=>{a&&r({loading:!1,profile:null})}),()=>{a=!1}},[]),t}function We(t,r){const a=(t||r||"").trim();if(!a)return"··";const s=a.split(/[\s@._-]+/).filter(Boolean);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():a.slice(0,2).toUpperCase()}const ae="https://github.com/levelcodeai/levelcode";function pt(){try{const t=localStorage.getItem("lc-theme");return t==="dark"||t==="light"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{return"light"}}function D({children:t,strip:r=!1}){const[a,s]=l.useState(pt),n=()=>s(o=>{const d=o==="light"?"dark":"light";try{localStorage.setItem("lc-theme",d)}catch{}return d});return e.jsxs("div",{className:`classic ${a==="dark"?"classic--dark":""} flex min-h-screen flex-col bg-[var(--c-bg)] text-[16px] leading-relaxed text-[var(--c-text2)]`,children:[e.jsx(ft,{theme:a,onToggleTheme:n}),r?e.jsxs("p",{className:"border-b border-[var(--c-line)] bg-[var(--c-strip)] px-5 py-2 text-center text-[13px] text-[var(--c-text)]",children:["Atom was sunset on December 15, 2022."," ",e.jsx("a",{href:`${ae}#readme`,className:"font-medium text-[var(--c-accent)] hover:underline",children:"LevelCode carries the hackable spirit forward →"})]}):null,e.jsx("div",{className:"flex-1",children:t}),e.jsx("footer",{className:"bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col items-center justify-between gap-4 px-5 py-8 text-[14px] sm:flex-row",children:[e.jsxs("ul",{className:"flex flex-wrap items-center justify-center gap-x-5 gap-y-2",children:[e.jsx("li",{children:e.jsx(C,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/terms",children:"Terms of Service"})}),e.jsx("li",{children:e.jsx(C,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/privacy",children:"Privacy"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${ae}/releases`,children:"Releases"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${ae}/discussions`,children:"Discussions"})}),e.jsx("li",{children:e.jsx(C,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/pricing",children:"Pricing"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--c-text3)]",children:[e.jsx(vt,{})," with ",e.jsx(bt,{})," by LevelCode"]})]})})]})}function ft({theme:t,onToggleTheme:r}){const{profile:a}=Y();return e.jsx("nav",{"aria-label":"Primary",className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex h-12 max-w-5xl items-center justify-between px-5",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs(C,{to:"/",className:"text-[15px] font-bold text-[var(--c-text)]",children:["Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsxs("ul",{className:"hidden items-center gap-5 sm:flex",children:[e.jsx("li",{children:e.jsx(C,{to:"/docs",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Documentation"})}),e.jsx("li",{children:e.jsx("a",{href:"https://open-vsx.org/",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Packages"})}),e.jsx("li",{children:e.jsx("a",{href:`${ae}/releases`,className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Releases"})}),e.jsx("li",{children:e.jsx(C,{to:"/pricing",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Pricing"})})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{type:"button",onClick:r,"aria-label":t==="light"?"Switch to dark mode":"Switch to light mode",title:t==="light"?"Dark mode (One Dark)":"Light mode",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:t==="light"?e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M13.3 9.9A5.6 5.6 0 0 1 6.1 2.7a.4.4 0 0 0-.5-.5 6.4 6.4 0 1 0 8.2 8.2.4.4 0 0 0-.5-.5z"})}):e.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("circle",{cx:"8",cy:"8",r:"3.2"}),e.jsx("path",{d:"M8 1.2v1.8M8 13v1.8M1.2 8H3M13 8h1.8M3.2 3.2l1.3 1.3M11.5 11.5l1.3 1.3M12.8 3.2l-1.3 1.3M4.5 11.5l-1.3 1.3"})]})}),a?e.jsx(C,{to:"/account",title:"Account","aria-label":"Account",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[12px] font-semibold text-[var(--c-text)] hover:border-[var(--c-accent)]",children:We(a.name,a.email)}):e.jsxs(C,{to:"/login",className:"flex items-center gap-1.5 text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M10 3.75a.75.75 0 0 1 .75-.75h2.5A1.75 1.75 0 0 1 15 4.75v6.5A1.75 1.75 0 0 1 13.25 13h-2.5a.75.75 0 0 1 0-1.5h2.5a.25.25 0 0 0 .25-.25v-6.5a.25.25 0 0 0-.25-.25h-2.5a.75.75 0 0 1-.75-.75Zm-3.28.72a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H1.75a.75.75 0 0 1 0-1.5h6.69L6.72 5.53a.75.75 0 0 1 0-1.06Z"})}),"Sign in"]})]})]})})}function gt({size:t=56}){return e.jsx("svg",{viewBox:"0 0 120 120",width:t,height:t,"aria-hidden":!0,children:e.jsxs("g",{fill:"none",stroke:"var(--c-accent)",strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:"0.4"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:"0.7"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})})}function vt(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m5.5 4.5-3.5 3.5 3.5 3.5M10.5 4.5 14 8l-3.5 3.5"})})}function bt(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"var(--c-accent)","aria-hidden":!0,children:e.jsx("path",{d:"m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002Z"})})}const jt=1e4,Q="en-US";function we(t){return(t??0)/jt}function yt(t){const r=we(t);return(r>0?Math.round(r):0).toLocaleString(Q)}function ve(t){const r=we(t);return r>0?r>=10?Math.round(r).toLocaleString(Q):r<.05?"<0.1":r.toFixed(1):"0"}function be(t){return(t??0).toLocaleString(Q)}const wt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ke=["bg-[var(--c-line)]","bg-flame/25","bg-flame/50","bg-flame/75","bg-[var(--c-accent)]"];function Nt(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}`}function kt(t){return t<=0?0:t<=2?1:t<=6?2:t<=14?3:4}function V(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:be(t)}function de(t){const[r,a,s]=t.split("-").map(Number);return new Date(Date.UTC(r,a-1,s)).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function Ct({activity:t,year:r,years:a,onYear:s}){const[n,o]=l.useState(null),d=(t==null?void 0:t.days)??{},{weeks:c,monthCols:m}=l.useMemo(()=>{var S;const i=new Date(Date.UTC(r,0,1)),f=new Date(i);f.setUTCDate(i.getUTCDate()-i.getUTCDay());const v=new Date(Date.UTC(r,11,31)),w=new Date(v);w.setUTCDate(v.getUTCDate()+(6-v.getUTCDay()));const y=[],x=[],p=new Date(f);let b=-1;for(;p<=w;){const h=[];let T=null;for(let A=0;A<7;A++){const q=p.getUTCFullYear()===r;if(A===0&&(T=q?p.getUTCMonth():null),q){const ee=Nt(p);h.push({key:ee,count:((S=d[ee])==null?void 0:S.count)??0,date:new Date(p)})}else h.push({key:null,count:0,date:null});p.setUTCDate(p.getUTCDate()+1)}T!=null&&T!==b?(x.push(wt[T]),b=T):x.push(null),y.push(h)}return{weeks:y,monthCols:x}},[r,d]),u=n?d[n]??null:null,g=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"activity"}),e.jsxs("div",{className:"mt-1 text-lg font-semibold tracking-tight text-[var(--c-text)]",children:[be((t==null?void 0:t.total)??0)," request",((t==null?void 0:t.total)??0)===1?"":"s"," in ",r]})]}),a.length>1?e.jsx("div",{className:"flex flex-wrap gap-1",children:a.map(i=>e.jsx("button",{type:"button",onClick:()=>{o(null),s(i)},className:`rounded-md px-2.5 py-1 font-mono text-[12px] transition-colors ${i===r?"bg-[var(--c-accent)] text-white":"text-[var(--c-text2)] hover:bg-[var(--c-line)]"}`,children:i},i))}):null]}),e.jsx("div",{className:"mt-5 overflow-x-auto",children:e.jsxs("div",{className:"inline-flex flex-col gap-1",children:[e.jsx("div",{className:"flex gap-[3px] pl-8",children:m.map((i,f)=>e.jsx("div",{className:"w-[11px] font-mono text-[10px] text-[var(--c-text3)]",children:i?e.jsx("span",{className:"relative -left-[1px] whitespace-nowrap",children:i}):null},f))}),e.jsxs("div",{className:"flex gap-[3px]",children:[e.jsx("div",{className:"mr-1 flex w-7 flex-col gap-[3px]",children:["","Mon","","Wed","","Fri",""].map((i,f)=>e.jsx("div",{className:"h-[11px] font-mono text-[9px] leading-[11px] text-[var(--c-text3)]",children:i},f))}),c.map((i,f)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:i.map((v,w)=>{var S,h;if(!v.key)return e.jsx("div",{className:"h-[11px] w-[11px]"},w);const y=kt(v.count),x=n===v.key,p=(h=(S=d[v.key])==null?void 0:S.models)==null?void 0:h[0],b=v.count>0?`${de(v.key)} · ${v.count} request${v.count===1?"":"s"}${p?` · ${xe(p.model)} ${p.count}`:""}`:`${de(v.key)} · no activity`;return e.jsx("button",{type:"button",title:b,onClick:()=>o(x?null:v.key),className:`h-[11px] w-[11px] rounded-[2px] ${ke[y]} ${x?"ring-1 ring-ink ring-offset-1":""} transition-colors hover:ring-1 hover:ring-ink/40`},w)})},f))]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 pl-8 font-mono text-[10px] text-[var(--c-text3)]",children:[e.jsx("span",{className:"mr-1",children:"Less"}),ke.map((i,f)=>e.jsx("span",{className:`h-[11px] w-[11px] rounded-[2px] ${i}`},f)),e.jsx("span",{className:"ml-1",children:"More"})]})]})}),n&&u?e.jsxs("div",{className:"mt-6 rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"font-mono text-[12px] text-[var(--c-text2)]",children:de(n)}),e.jsxs("div",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[u.count," req · ",V(u.input)," in · ",V(u.output)," out ·"," ",ve(u.cost_micros)," credits"]})]}),e.jsx("ul",{className:"mt-3 space-y-1.5",children:u.models.map(i=>e.jsxs("li",{className:"flex items-center justify-between gap-3 font-mono text-[12px]",children:[e.jsx("span",{className:"truncate text-[var(--c-text)]",children:xe(i.model)}),e.jsxs("span",{className:"whitespace-nowrap text-[var(--c-text3)]",children:[i.count," · ",V(i.input+i.output)," tok"]})]},i.model))})]}):e.jsx("p",{className:"mt-4 font-mono text-[11px] text-[var(--c-text3)]",children:"Click a day to see its per-model breakdown."}),g.length?e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"classic-label mb-3",children:["by model · ",r]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[520px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"requests"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"input"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"output"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"reactions"})]})}),e.jsx("tbody",{children:g.map(i=>e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:xe(i.model)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:be(i.count)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:V(i.input)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:V(i.output)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:ve(i.cost_micros)}),e.jsx("td",{className:"py-1.5 pl-3 text-right tabular-nums text-[var(--c-text3)]",children:e.jsxs("span",{className:"inline-flex items-center justify-end gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(St,{className:"text-[var(--c-text2)]"})," ",i.up]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Lt,{className:"text-[var(--c-text2)]"})," ",i.down]})]})})]},i.model))})]})})]}):null]})}function xe(t){const r=t||"unknown",a=r.indexOf("/");return a>=0?r.slice(a+1):r}function St({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M12.999 6.00002H10.672L11.207 4.21802C11.278 3.98102 11.314 3.73902 11.314 3.49602C11.314 2.12002 10.192 0.999023 8.81298 0.999023C8.42998 0.999023 8.08498 1.21202 7.91398 1.55402L5.82998 5.72202C5.74498 5.89202 5.57398 5.99802 5.38298 5.99802H3.00098C1.89798 5.99802 1.00098 6.89502 1.00098 7.99802V12.998C1.00098 14.101 1.89798 14.998 3.00098 14.998H11.163C12.727 14.998 13.283 13.796 13.565 12.893L14.908 8.59602C14.969 8.40102 15 8.19902 15 7.99602C15 6.89402 14.103 5.99802 12.999 5.99802V6.00002ZM1.99998 13V8.00002C1.99998 7.44902 2.44898 7.00002 2.99998 7.00002H3.99998V14H2.99998C2.44898 14 1.99998 13.551 1.99998 13ZM13.954 8.29802L12.611 12.596C12.247 13.761 11.769 13.999 11.163 13.999H5.00098V6.99902H5.38298C5.95498 6.99902 6.46898 6.68102 6.72498 6.17002L8.80898 2.00202C8.80898 2.00202 8.81098 2.00002 8.81298 2.00002C9.64098 2.00002 10.314 2.67102 10.314 3.49702C10.314 3.64202 10.292 3.78802 10.249 3.93202L9.52098 6.35702C9.47598 6.50802 9.50398 6.67202 9.59898 6.79902C9.69398 6.92602 9.84198 7.00102 9.99998 7.00102H12.999C13.551 7.00102 14 7.44802 14 7.99902C14 8.10002 13.984 8.20102 13.954 8.30002V8.29802Z"})})}function Lt({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M13 1H4.838C3.274 1 2.717 2.202 2.435 3.105L1.092 7.404C1.031 7.6 1 7.801 1 8.002C1 9.104 1.897 10 3.001 10H5.328L4.794 11.781C4.723 12.016 4.687 12.26 4.687 12.504C4.687 13.88 5.809 15.001 7.189 15.001C7.571 15.001 7.915 14.789 8.087 14.446L10.171 10.277C10.256 10.107 10.427 10.001 10.618 10.001H13C14.103 10.001 15 9.104 15 8.001V3C15 1.897 14.103 1 13 1ZM9.276 9.829L7.193 13.996L7.188 13.999C6.36 13.999 5.686 13.328 5.686 12.502C5.686 12.356 5.707 12.21 5.75 12.067L6.478 9.642C6.524 9.491 6.495 9.327 6.401 9.2C6.306 9.073 6.158 8.998 6 8.998H3.001C2.449 8.998 2 8.551 2 8C2 7.9 2.016 7.799 2.047 7.699L3.39 3.401C3.753 2.236 4.232 1.998 4.838 1.998H11V8.998H10.618C10.046 8.998 9.531 9.316 9.276 9.827V9.829ZM14 8C14 8.551 13.552 9 13 9H12V2H13C13.552 2 14 2.449 14 3V8Z"})})}function _t(){const t=X(),{loading:r,profile:a}=Y(),[s,n]=l.useState(null),[o,d]=l.useState(null),[c,m]=l.useState(null),[u,g]=l.useState(new Date().getFullYear()),[i,f]=l.useState(null);l.useEffect(()=>{!r&&!a&&t("/login",{replace:!0})},[r,a,t]),l.useEffect(()=>{if(!a)return;let p=!0;return E("/api/levelcode/v1/account/usage").then(b=>{p&&n(b)}).catch(()=>{p&&f("We couldn’t load your usage right now. Please try again shortly.")}),()=>{p=!1}},[a]),l.useEffect(()=>{if(!a)return;let p=!0;return E("/api/levelcode/v1/account/models").then(b=>{p&&d(b)}).catch(()=>{}),()=>{p=!1}},[a]),l.useEffect(()=>{if(!a)return;let p=!0;return E(`/api/levelcode/v1/account/activity?year=${u}`).then(b=>{p&&m(b)}).catch(()=>{}),()=>{p=!1}},[a,u]);async function v(){try{const p=await E("/ai/billing",{method:"POST"});p.url&&K(p.url)}catch{f("Could not open billing. Please try again.")}}async function w(){try{await E("/ai/signout",{method:"POST"})}catch{}t("/login",{replace:!0})}if(r||!a)return e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-4xl px-5 py-12"})});const y=s?Se(s.input_used,s.input_cap):0,x=s?Se(s.output_used,s.output_cap):0;return e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-4xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:a.name?`Hi, ${a.name}`:"Your account"}),a.email?e.jsx("p",{className:"mt-2 font-mono text-[13px] text-[var(--c-text3)]",children:a.email}):null]}),e.jsxs("span",{className:"flex flex-wrap items-center gap-4",children:[a.role==="admin"?e.jsxs(e.Fragment,{children:[e.jsx(C,{to:"/admin",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"System dashboard →"}),e.jsx(C,{to:"/admin/referrals",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"Referrals →"})]}):null,e.jsxs("span",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-2.5 py-1 font-mono text-[12px] text-[var(--c-text2)]",children:["plan · ",(s==null?void 0:s.plan)??a.plan??"free"]})]})]}),i?e.jsx("div",{className:"classic-card mt-10 p-8 text-[15px] text-[var(--c-text2)]",children:i}):s?e.jsxs("div",{className:"mt-10 grid gap-5 sm:grid-cols-2",children:[e.jsx(Ce,{label:"Input tokens",used:s.input_used,cap:s.input_cap,pct:y}),e.jsx(Ce,{label:"Output tokens",used:s.output_used,cap:s.output_cap,pct:x}),e.jsx("div",{className:"classic-card p-6 sm:col-span-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"billing period resets"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--c-text)]",children:Mt(s.period_end)}),e.jsxs("div",{className:"mt-1 font-mono text-[12px] text-[var(--c-text3)]",children:["overage policy · ",s.overage_policy]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:v,className:"classic-button--quiet",children:"Manage billing"}),e.jsx(C,{to:"/pricing",className:"classic-button",children:"Upgrade"})]})]})})]}):null,o&&o.models.length?e.jsx(Tt,{models:o}):null,e.jsx("div",{className:"mt-6",children:e.jsx(Ct,{activity:c,year:u,years:(c==null?void 0:c.years)??[u],onYear:g})}),e.jsx("button",{type:"button",onClick:w,className:"mt-10 text-[13px] text-[var(--c-accent)] hover:underline",children:"Sign out"})]})})}function Tt({models:t}){const r=t.budget_micros||0,a=t.ceiling_micros??r,s=t.spent_micros||0,n=t.credits_remaining_micros||0,o=a0?Math.min(Math.round(s/a*100),100):0,m=yt,u=i=>we(i)>0?ve(i):"—",g=i=>i.includes("/")?i.slice(i.indexOf("/")+1):i;return e.jsxs("div",{className:"classic-card mt-5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsx("div",{className:"classic-label",children:o?"usage available now":"compute credits"}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[m(s)," / ",m(a)," · ",c,"%"]})]}),e.jsxs("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[m(n),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" ","credits ",o?"available now":"left this period"]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${c>=100?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${c}%`}})}),o&&d?e.jsxs("div",{className:"mt-2 font-mono text-[11px] text-[var(--c-text3)]",children:["More unlocks ",d.toLocaleDateString(void 0,{month:"short",day:"numeric"})," · ",m(r)," ","credits total this cycle"]}):null,e.jsx("div",{className:"mt-6 lineno",children:"models on your plan"}),e.jsx("div",{className:"mt-3 overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[460px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits/turn"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"≈ turns left"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"status"})]})}),e.jsx("tbody",{children:t.models.map(i=>e.jsxs("tr",{className:`border-b border-[var(--c-line)] ${i.live?"":"opacity-55"}`,children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:g(i.id)}),e.jsxs("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",title:`${i.multiplier}× the baseline model`,children:[u(i.per_turn_micros),e.jsxs("span",{className:"sr-only",children:[" credits per turn, ",i.multiplier,"× the baseline model"]})]}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:i.live?(i.turns_left??0).toLocaleString(Q):"—"}),e.jsx("td",{className:"py-1.5 pl-3 text-right",children:i.live?e.jsx("span",{className:"text-[11px] text-[var(--c-accent)]",children:"live"}):e.jsx("span",{className:"rounded bg-[var(--c-line)] px-1.5 py-0.5 text-[10px] text-[var(--c-text3)]",children:"soon"})})]},i.id))})]})})]})}function Ce({label:t,used:r,cap:a,pct:s}){const n=s>=100;return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[s,"%"]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[Le(r),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" / ",Le(a)]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${n?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${Math.min(s,100)}%`}})})]})}function Se(t,r){return!r||r<=0?0:Math.round(t/r*100)}function Le(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString(Q)}function Mt(t){if(!t)return"—";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}function At(){const t=X(),{loading:r,profile:a}=Y(),[s,n]=l.useState(null),[o,d]=l.useState(null),[c,m]=l.useState("input"),[u,g]=l.useState("desc"),[i,f]=l.useState(""),[v,w]=l.useState(""),[y,x]=l.useState(null),p=(a==null?void 0:a.role)==="admin";l.useEffect(()=>{r||(a?p||t("/account",{replace:!0}):t("/login",{replace:!0}))},[r,a,p,t]),l.useEffect(()=>{if(!p)return;let h=!0;return E("/api/levelcode/v1/admin/summary").then(T=>h&&n(T)).catch(()=>h&&x("Couldn’t load the admin summary.")),()=>{h=!1}},[p]),l.useEffect(()=>{if(!p)return;let h=!0;const T=new URLSearchParams({sort:c,dir:u,limit:"200"});return i.trim()&&T.set("q",i.trim()),v&&T.set("plan",v),E(`/api/levelcode/v1/admin/users?${T.toString()}`).then(A=>h&&d(A)).catch(()=>h&&x("Couldn’t load users.")),()=>{h=!1}},[p,c,u,i,v]);const b=l.useMemo(()=>Object.keys((s==null?void 0:s.plans)??{}).sort(),[s]);function S(h){c===h?g(T=>T==="desc"?"asc":"desc"):(m(h),g(h==="email"||h==="plan"?"asc":"desc"))}return r||!p?e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-6xl px-5 py-12"})}):e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"System dashboard"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"tokens burned · plans · geography · login health"})]}),e.jsx(C,{to:"/admin/referrals",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Referrals →"})]}),y?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:y}):null,e.jsxs("div",{className:"mt-10 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Z,{label:"users",value:H(s==null?void 0:s.users),sub:`${H(s==null?void 0:s.active_users)} active`}),e.jsx(Z,{label:"requests",value:H(s==null?void 0:s.requests),sub:_e(s==null?void 0:s.cost_micros)}),e.jsx(Z,{label:"input tokens",value:te(s==null?void 0:s.input)}),e.jsx(Z,{label:"output tokens",value:te(s==null?void 0:s.output)}),e.jsx(Z,{label:"auth attempts",value:H(s==null?void 0:s.auth_attempts),sub:`${H(s==null?void 0:s.auth_failures)} failed`,alert:((s==null?void 0:s.auth_failures)??0)>0}),e.jsx(ue,{label:"plans",map:s==null?void 0:s.plans}),e.jsx(ue,{label:"countries",map:s==null?void 0:s.countries}),e.jsx(ue,{label:"auth failures · country",map:s==null?void 0:s.auth_failures_by_country,alert:!0})]}),e.jsxs("div",{className:"mt-10 flex flex-wrap items-center gap-3",children:[e.jsx("input",{value:i,onChange:h=>f(h.target.value),placeholder:"Search email…",className:"w-full max-w-xs rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)] sm:w-auto"}),e.jsxs("select",{value:v,onChange:h=>w(h.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text2)] outline-none focus:border-[var(--c-accent)]",children:[e.jsx("option",{value:"",children:"all plans"}),b.map(h=>e.jsx("option",{value:h,children:h},h))]}),e.jsxs("span",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[H(o==null?void 0:o.total)," users"]})]}),e.jsx("div",{className:"classic-card mt-4 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[880px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx(F,{label:"email",col:"email",sort:c,dir:u,onClick:S,align:"left"}),e.jsx(F,{label:"plan",col:"plan",sort:c,dir:u,onClick:S,align:"left"}),e.jsx(F,{label:"input",col:"input",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"output",col:"output",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"requests",col:"requests",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"cost",col:"cost",sort:c,dir:u,onClick:S}),e.jsx("th",{className:"px-3 py-2 text-left font-normal",children:"country"}),e.jsx(F,{label:"auth",col:"auth_attempts",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"last seen",col:"last_seen",sort:c,dir:u,onClick:S}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"reach"})]})}),e.jsxs("tbody",{children:[((o==null?void 0:o.users)??[]).map(h=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] hover:bg-[var(--c-surface)]",children:[e.jsxs("td",{className:"px-3 py-2 text-[var(--c-text)]",children:[h.email,h.role==="admin"?e.jsx("span",{className:"ml-2 rounded border border-[var(--c-accent)] px-1.5 py-0.5 text-[10px] text-[var(--c-accent)]",children:"admin"}):null]}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:h.plan}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:te(h.input)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:te(h.output)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:H(h.requests)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:_e(h.cost_micros)}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:h.country??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:e.jsxs("span",{className:h.auth_failures>0?"text-red-500":"text-[var(--c-text3)]",children:[h.auth_attempts,h.auth_failures>0?` · ${h.auth_failures}✗`:""]})}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text3)]",children:Et(h.last_seen_at)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("a",{className:"text-[var(--c-accent)] underline decoration-[var(--c-line)] underline-offset-2 hover:decoration-[var(--c-accent)]",href:`mailto:${h.email}`,children:"email"})})]},h.id)),o&&o.users.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:"px-3 py-6 text-center text-[var(--c-text3)]",children:"No users match."})}):null]})]})})]})})}function F({label:t,col:r,sort:a,dir:s,onClick:n,align:o="right"}){const d=a===r;return e.jsx("th",{className:`px-3 py-2 font-normal ${o==="right"?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>n(r),className:`inline-flex items-center gap-1 ${d?"text-[var(--c-text)]":"hover:text-[var(--c-text)]"}`,children:[t,e.jsx("span",{className:"text-[9px]",children:d?s==="desc"?"▼":"▲":"↕"})]})})}function Z({label:t,value:r,sub:a,alert:s}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsx("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:r}),a?e.jsx("div",{className:`mt-1 font-mono text-[11px] ${s?"text-red-500":"text-[var(--c-text3)]"}`,children:a}):null]})}function ue({label:t,map:r,alert:a}){const s=Object.entries(r??{}).sort((n,o)=>o[1]-n[1]);return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),s.length?e.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[12px]",children:s.slice(0,5).map(([n,o])=>e.jsxs("li",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--c-text2)]",children:n}),e.jsx("span",{className:`tabular-nums ${a?"text-red-500":"text-[var(--c-text3)]"}`,children:o})]},n))}):e.jsx("div",{className:"mt-2 font-mono text-[12px] text-[var(--c-text3)]",children:"—"})]})}function H(t){return(t??0).toLocaleString()}function te(t){const r=t??0;return r>=1e6?`${+(r/1e6).toFixed(1)}M`:r>=1e3?`${+(r/1e3).toFixed(0)}K`:r.toLocaleString()}function _e(t){return`$${((t??0)/1e6).toFixed(2)}`}function Et(t){if(!t)return"—";const r=new Date(t);return Number.isNaN(r.getTime())?"—":r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const je={},Ye=ne.createContext(je);function $t(t){const r=ne.useContext(Ye);return ne.useMemo(function(){return typeof t=="function"?t(r):{...r,...t}},[r,t])}function Dt(t){let r;return t.disableParentContext?r=typeof t.components=="function"?t.components(je):t.components||je:r=$t(t.components),ne.createElement(Ye.Provider,{value:r},t.children)}const Ve=[{group:"Get started",items:[{title:"Overview",href:"/docs",blurb:"What LevelCode is, how the AI layer is wired, and where to go next."},{title:"Quickstart",href:"/docs/quickstart",blurb:"Install the editor, connect a model provider, and run your first agent task end to end."},{title:"Install and setup",href:"/docs/setup",blurb:"Download and verify a build, run from source, and handle macOS first-launch prompts."}]},{group:"AI",items:[{title:"Chat",href:"/docs/chat",blurb:"Ask questions about your codebase, with context pulled in automatically or pinned by hand."},{title:"Agent",href:"/docs/agent",blurb:"The autonomous loop: planning, multi-file edits, approval-gated commands, self-verification, and checkpoints."},{title:"Edit",href:"/docs/edit",blurb:"Select code, describe the change, and review it as a diff before anything lands."},{title:"Autocomplete",href:"/docs/autocomplete",blurb:"Inline ghost-text completion as you type, and how to tune it."},{title:"Providers and models",href:"/docs/providers",blurb:"Bring your own key for any supported provider, run models locally with Ollama, or use the metered gateway."}]},{group:"MCP",items:[{title:"MCP servers",href:"/docs/mcp",blurb:"Connect Model Context Protocol servers to give the agent tools LevelCode doesn't ship, and the approval model that governs them."},{title:"Server recipes",href:"/docs/mcp-recipes",blurb:"Working configurations for GitHub, the filesystem, image generation, and hosted servers — plus how to keep API tokens out of settings.json."}]},{group:"The editor",items:[{title:"Power editing",href:"/docs/power-editing",blurb:"The Notepad++ pack: macros, column mode, line operations, encoding and line-ending control, big-file mode."},{title:"Hackability",href:"/docs/hackability",blurb:"The init script, package authoring with hot reload, keymap presets, and themes."},{title:"Import and updates",href:"/docs/import-and-updates",blurb:"Bring your settings over from VS Code, VSCodium, or Cursor, install extensions from Open VSX, and stay on the latest build."}]},{group:"Account",items:[{title:"Cloud and billing",href:"/docs/cloud",blurb:"Sign in, understand credits and usage, and decide between your own key and the metered gateway."}]},{group:"Help",items:[{title:"Troubleshooting",href:"/docs/troubleshooting",blurb:"Fixes for first-launch blocks, provider and key errors, agent and terminal problems, and update failures."}]}],G=Ve.flatMap(t=>t.items);function Pt(t){const r=G.findIndex(a=>a.href===t);return r===-1?{prev:null,next:null}:{prev:r>0?G[r-1]:null,next:re.jsxs("div",{className:"mb-6 last:mb-0",children:[e.jsx("p",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wide text-[var(--c-text3)]",children:a.group}),e.jsx("ul",{className:"space-y-0.5 border-l border-[var(--c-line)]",children:a.items.map(s=>{const n=r===s.href;return e.jsx("li",{children:e.jsx(C,{to:s.href,onClick:t,"aria-current":n?"page":void 0,className:`-ml-px block border-l py-1 pl-3 transition-colors ${n?"border-[var(--c-accent)] font-medium text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:s.title})},s.href)})})]},a.group))})}function Rt(){const{pathname:t}=J(),[r,a]=l.useState(!1);return l.useEffect(()=>a(!1),[t]),e.jsxs("div",{className:"border-b border-[var(--c-line)] lg:hidden",children:[e.jsxs("button",{type:"button",onClick:()=>a(s=>!s),"aria-expanded":r,"aria-controls":"docs-mobile-nav",className:"flex w-full items-center gap-2 px-5 py-3 text-[14px] font-medium text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:`text-[var(--c-text3)] transition-transform duration-150 ${r?"rotate-90":""}`,children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),"Documentation menu"]}),r?e.jsx("div",{id:"docs-mobile-nav",className:"px-5 pb-5",children:e.jsx(Ze,{onNavigate:()=>a(!1)})}):null]})}function Ot(){return e.jsx("aside",{className:"hidden lg:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12 pr-6",children:e.jsx(Ze,{})})})}function Bt({revision:t=0}){const{pathname:r}=J(),[a,s]=l.useState([]),[n,o]=l.useState("");return l.useEffect(()=>{const d=document.querySelector("article");if(!d)return;const c=Array.from(d.querySelectorAll("h2[id], h3[id]")).map(m=>{const u=m.cloneNode(!0);return u.querySelectorAll("a").forEach(g=>g.remove()),{id:m.id,text:(u.textContent??"").trim(),level:Number(m.tagName[1])}});s(m=>m.length===c.length&&m.every((u,g)=>u.id===c[g].id)?m:c)},[r,t]),l.useEffect(()=>{if(a.length===0)return;const d=()=>{let m=a[0].id;for(const u of a){const g=document.getElementById(u.id);g&&g.getBoundingClientRect().top<=120&&(m=u.id)}window.innerHeight+window.scrollY>=document.body.offsetHeight-2&&(m=a[a.length-1].id),o(m)};return d(),window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[a]),a.length<2?null:e.jsxs("nav",{"aria-labelledby":"toc-heading",className:"text-[13.5px]",children:[e.jsx("p",{id:"toc-heading",className:"mb-3 font-semibold text-[var(--c-text)]",children:"On this page"}),e.jsx("ul",{className:"space-y-1.5 border-l border-[var(--c-line)]",children:a.map(d=>e.jsx("li",{children:e.jsx("a",{href:`#${d.id}`,"aria-current":n===d.id?"location":void 0,className:`-ml-px block border-l py-0.5 leading-snug transition-colors ${d.level===3?"pl-6":"pl-3"} ${n===d.id?"border-[var(--c-accent)] text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:text-[var(--c-text)]"}`,children:d.text})},d.id))})]})}function Ge(t,r=24){const a=Math.max(0,t.getBoundingClientRect().top+window.scrollY-r);return window.scrollTo({top:a,behavior:"instant"}),Math.abs(window.scrollY-a)<=2}function qt(){window.scrollTo({top:0,behavior:"instant"})}function Ft(t){return t.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-")}function Ut({title:t,defaultOpen:r=!1,children:a}){const s=Ft(t),n=l.useRef(null),[o,d]=l.useState(r);return l.useEffect(()=>{const c=()=>{decodeURIComponent(window.location.hash.slice(1))===s&&(d(!0),requestAnimationFrame(()=>{n.current&&Ge(n.current)}))};return c(),window.addEventListener("hashchange",c),()=>window.removeEventListener("hashchange",c)},[s]),e.jsxs("details",{ref:n,id:s,open:o,onToggle:c=>d(c.currentTarget.open),className:"group scroll-mt-8 border-b border-[var(--c-line)] last:border-b-0 [&_>_summary_>_svg]:open:rotate-90",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 py-3 text-[15px] font-medium text-[var(--c-text)] marker:content-none hover:text-[var(--c-accent)] [&::-webkit-details-marker]:hidden",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"shrink-0 text-[var(--c-text3)] transition-transform duration-150",children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),t]}),e.jsx("div",{className:"pb-4 pl-[20px]",children:a})]})}function Ht({children:t}){return e.jsx("div",{className:"my-6 rounded-md border border-[var(--c-line)] px-4",children:t})}function Wt({title:t,href:r,children:a}){const s=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[15px] font-semibold text-[var(--c-text)]",children:[t,r?e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"text-[var(--c-text3)] transition-transform duration-150 group-hover:translate-x-0.5 group-hover:text-[var(--c-accent)]",children:e.jsx("path",{d:"M8.22 2.97a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06l2.97-2.97H3.75a.75.75 0 0 1 0-1.5h7.44L8.22 4.03a.75.75 0 0 1 0-1.06Z"})}):null]}),a?e.jsx("span",{className:"mt-1.5 block text-[14px] leading-relaxed text-[var(--c-text2)]",children:a}):null]}),n="group block rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-4 no-underline transition-colors";return r?e.jsx(C,{to:r,className:`${n} hover:border-[var(--c-accent)]`,children:s}):e.jsx("div",{className:n,children:s})}function Yt({cols:t=2,children:r}){const a=t===1?"sm:grid-cols-1":t===3?"sm:grid-cols-3":"sm:grid-cols-2";return e.jsx("div",{className:`my-6 grid grid-cols-1 gap-3 ${a}`,children:r})}const Vt={note:{wrap:"border-[var(--c-line)] bg-[var(--c-surface)]",icon:"text-[var(--c-text3)]",label:"Note",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},tip:{wrap:"border-[#149963]/30 bg-[#149963]/[0.08]",icon:"text-[#149963]",label:"Tip",path:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"},info:{wrap:"border-[var(--c-accent)]/30 bg-[var(--c-accent)]/[0.07]",icon:"text-[var(--c-accent)]",label:"Info",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},warning:{wrap:"border-[#d19a66]/40 bg-[#d19a66]/[0.1]",icon:"text-[#b3701a]",label:"Warning",path:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}};function oe({variant:t,children:r}){const a=Vt[t];return e.jsxs("div",{className:`my-5 flex gap-3 rounded-md border px-4 py-3 ${a.wrap}`,children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor","aria-hidden":!0,className:`mt-[3px] shrink-0 ${a.icon}`,children:e.jsx("path",{d:a.path})}),e.jsxs("div",{className:"min-w-0 text-[15px] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:[e.jsxs("span",{className:"sr-only",children:[a.label,": "]}),r]})]})}const Zt=({children:t})=>e.jsx(oe,{variant:"note",children:t}),Gt=({children:t})=>e.jsx(oe,{variant:"tip",children:t}),zt=({children:t})=>e.jsx(oe,{variant:"info",children:t}),Kt=({children:t})=>e.jsx(oe,{variant:"warning",children:t});function Xt({children:t,...r}){const a=l.useRef(null),[s,n]=l.useState(!1),[o,d]=l.useState(null);l.useEffect(()=>{var m,u;d(((u=(m=a.current)==null?void 0:m.querySelector("pre"))==null?void 0:u.getAttribute("data-language"))??null)},[]);async function c(){var u,g;const m=((g=(u=a.current)==null?void 0:u.querySelector("pre"))==null?void 0:g.textContent)??"";try{await navigator.clipboard.writeText(m),n(!0),window.setTimeout(()=>n(!1),1600)}catch{}}return e.jsxs("figure",{ref:a,...r,className:"group relative my-5 overflow-hidden rounded-md border border-black/20 bg-[#0d1321] text-[#abb2bf] [&_code]:grid [&_code]:rounded-none [&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0 [&_code]:font-mono [&_code]:text-[13.5px] [&_code]:leading-[1.65] [&_code]:text-inherit [&_pre]:overflow-x-auto [&_pre]:bg-transparent [&_pre]:py-4 [&_[data-line]]:px-4",children:[e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex items-center gap-2",children:[o?e.jsx("span",{className:"select-none font-mono text-[11px] uppercase tracking-wide text-[#7d8695] opacity-0 transition-opacity group-hover:opacity-100",children:o}):null,e.jsx("button",{type:"button",onClick:c,"aria-label":s?"Copied to clipboard":"Copy code",className:"rounded-[4px] border border-white/10 bg-white/5 px-2 py-1 font-mono text-[11px] text-[#b9c0cb] opacity-0 transition-all hover:border-white/25 hover:bg-white/10 focus-visible:opacity-100 group-hover:opacity-100",children:s?"Copied":"Copy"})]}),t]})}const Te={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",opt:"⌥",shift:"⇧",enter:"↩",return:"↩",tab:"⇥",escape:"⎋",esc:"⎋",space:"Space",backspace:"⌫",delete:"⌦",up:"↑",down:"↓",left:"←",right:"→"};function Jt(t){const r=t.trim().toLowerCase();return Te[r]?Te[r]:t.trim().length===1?t.trim().toUpperCase():t.trim()}function Qt({keys:t}){const r=t.trim().split(/\s+/);return e.jsx("span",{className:"inline-flex items-baseline gap-1 whitespace-nowrap align-baseline",children:r.map((a,s)=>e.jsx("kbd",{className:"inline-flex items-center rounded-[4px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[6px] py-[2px] font-mono text-[12.5px] font-medium text-[var(--c-text)]",children:a.split("+").map(Jt).join("")},`${a}-${s}`))})}function er({children:t}){return e.jsx(e.Fragment,{children:t})}function tr(t){var r;return l.isValidElement(t)&&typeof((r=t.props)==null?void 0:r.title)=="string"}function rr({children:t}){const r=l.Children.toArray(t).filter(tr);return r.length===0?null:e.jsx("ol",{className:"my-6 list-none space-y-0 pl-0",children:r.map((a,s)=>e.jsxs("li",{className:"relative pb-6 pl-10 last:pb-0",children:[s*:first-child]:mt-0 [&>*:last-child]:mb-0",children:a.props.children})]},`${a.props.title}-${s}`))})}function ar({children:t}){return e.jsx(e.Fragment,{children:t})}function sr(t){var r;return l.isValidElement(t)&&typeof((r=t.props)==null?void 0:r.title)=="string"}function nr({children:t}){const r=l.Children.toArray(t).filter(sr),[a,s]=l.useState(0),n=l.useId();if(r.length===0)return null;const o=r[Math.min(a,r.length-1)];return e.jsxs("div",{className:"my-6",children:[e.jsx("div",{role:"tablist","aria-orientation":"horizontal",className:"flex flex-wrap gap-1 border-b border-[var(--c-line)]",children:r.map((d,c)=>{const m=c===a;return e.jsx("button",{type:"button",role:"tab",id:`${n}-tab-${c}`,"aria-selected":m,"aria-controls":`${n}-panel-${c}`,onClick:()=>s(c),className:`-mb-px border-b-2 px-3 py-2 text-[14px] font-medium transition-colors ${m?"border-[var(--c-accent)] text-[var(--c-text)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:d.props.title},`${d.props.title}-${c}`)})}),e.jsx("div",{role:"tabpanel",id:`${n}-panel-${a}`,"aria-labelledby":`${n}-tab-${a}`,className:"pt-4",children:o.props.children})]})}function he(t){const r=`h${t}`,a=t===2?"mt-12 text-[24px] font-semibold":t===3?"mt-9 text-[18.5px] font-semibold":"mt-7 text-[16px] font-semibold";return function({id:n,children:o,...d}){return e.jsxs(r,{id:n,className:`group mb-3 scroll-mt-8 text-[var(--c-text)] ${a}`,...d,children:[o,n?e.jsx("a",{href:`#${n}`,"aria-label":"Link to this section",className:"ml-2 text-[var(--c-text3)] opacity-0 transition-opacity hover:text-[var(--c-accent)] focus-visible:opacity-100 group-hover:opacity-100",children:"#"}):null]})}}const Me="font-medium text-[var(--c-accent)] underline decoration-[var(--c-accent)]/30 underline-offset-2 transition-colors hover:decoration-[var(--c-accent)]",lr={h1:({children:t,...r})=>e.jsx("h1",{className:"mb-4 text-[34px] font-bold leading-tight tracking-tight text-[var(--c-text)]",...r,children:t}),h2:he(2),h3:he(3),h4:he(4),p:t=>e.jsx("p",{className:"my-4 text-[16px] leading-[1.7] pretty",...t}),a:({href:t="",children:r,...a})=>{if(t.startsWith("/"))return e.jsx(C,{to:t,className:Me,...a,children:r});const s=!t.startsWith("#");return e.jsx("a",{href:t,className:Me,...s?{target:"_blank",rel:"noopener noreferrer"}:{},...a,children:r})},ul:t=>e.jsx("ul",{className:"my-4 list-disc space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),ol:t=>e.jsx("ol",{className:"my-4 list-decimal space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),li:t=>e.jsx("li",{className:"leading-[1.7] [&>ol]:my-2 [&>ul]:my-2",...t}),strong:t=>e.jsx("strong",{className:"font-semibold text-[var(--c-text)]",...t}),code:t=>e.jsx("code",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[5px] py-[1.5px] font-mono text-[0.875em] text-[var(--c-text)]",...t}),figure:({children:t,...r})=>"data-rehype-pretty-code-figure"in r?e.jsx(Xt,{...r,children:t}):e.jsx("figure",{className:"my-6",...r,children:t}),blockquote:t=>e.jsx("blockquote",{className:"my-5 border-l-2 border-[var(--c-line)] pl-4 text-[var(--c-text2)] [&>p]:my-2",...t}),hr:()=>e.jsx("hr",{className:"my-10 border-[var(--c-line)]"}),table:t=>e.jsx("div",{className:"my-6 overflow-x-auto rounded-md border border-[var(--c-line)]",children:e.jsx("table",{className:"w-full border-collapse text-left text-[14.5px]",...t})}),thead:t=>e.jsx("thead",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",...t}),th:t=>e.jsx("th",{className:"px-4 py-2.5 font-semibold text-[var(--c-text)] [&_code]:text-[0.9em]",...t}),td:t=>e.jsx("td",{className:"border-t border-[var(--c-line)] px-4 py-2.5 align-top leading-[1.6] [&_code]:text-[0.9em]",...t}),Tabs:nr,Tab:ar,Accordion:Ut,AccordionGroup:Ht,Card:Wt,CardGroup:Yt,Steps:rr,Step:er,Note:Zt,Tip:Gt,Info:zt,Warning:Kt,Kbd:Qt};function or(){const[t,r]=l.useState(0);return l.useEffect(()=>{const a=document.querySelector("article");if(!a)return;const s=new MutationObserver(()=>r(n=>n+1));return s.observe(a,{childList:!0,subtree:!0}),()=>s.disconnect()},[]),t}function ir(t){l.useEffect(()=>{const r=G.find(d=>d.href===t),a=document.title;document.title=r?`${r.title} — LevelCode Docs`:"LevelCode Docs";const s=document.querySelector('meta[name="description"]'),n=(s==null?void 0:s.hasAttribute("content"))??!1,o=(s==null?void 0:s.getAttribute("content"))??null;return s&&r&&s.setAttribute("content",r.blurb),()=>{document.title=a,s&&(n&&o!==null?s.setAttribute("content",o):s.removeAttribute("content"))}},[t])}function cr(t,r,a){const s=l.useRef("");l.useEffect(()=>{const n=t+r;if(!r){s.current!==n&&(s.current=n,qt());return}if(s.current===n)return;const o=document.getElementById(decodeURIComponent(r.slice(1)));if(!o)return;const d=()=>{Ge(o)&&(s.current=n)};d(),requestAnimationFrame(d)},[t,r,a])}function dr({children:t}){const{pathname:r,hash:a}=J(),s=or();return ir(r),cr(r,a,s),e.jsxs(D,{children:[e.jsx(Rt,{}),e.jsx("div",{className:"mx-auto max-w-[88rem] px-5",children:e.jsxs("div",{className:"lg:grid lg:grid-cols-[14rem_minmax(0,1fr)] lg:gap-10 xl:grid-cols-[14rem_minmax(0,1fr)_13rem]",children:[e.jsx(Ot,{}),e.jsxs("main",{className:"min-w-0 py-10 lg:py-12",children:[e.jsx("article",{className:"max-w-[46rem]",children:e.jsx(Dt,{components:lr,children:t})}),e.jsx("div",{className:"max-w-[46rem]",children:e.jsx(It,{})})]}),e.jsx("div",{className:"hidden xl:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12",children:e.jsx(Bt,{revision:s})})})]})})]})}const xr=l.lazy(()=>ot(()=>import("./bundle-mBaJepD3.js"),__vite__mapDeps([0,1])));function ze({slug:t=""}){return e.jsx(dr,{children:e.jsx(l.Suspense,{fallback:e.jsx(ur,{}),children:e.jsx(xr,{slug:t})})})}function ur(){return e.jsxs("div",{"aria-hidden":!0,className:"animate-pulse",children:[e.jsx("div",{className:"h-9 w-2/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-6 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-11/12 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-4/5 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-10 h-6 w-1/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-5 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-10/12 rounded bg-[var(--c-surface)]"}),e.jsx("span",{className:"sr-only",children:"Loading documentation…"})]})}const hr="https://github.com/levelcodeai/levelcode",mr="levelcode://levelcode.levelcode-ai/launch";function pr(){const{profile:t}=Y();return e.jsx("header",{className:"fixed inset-x-0 top-0 z-50 border-b border-rule bg-paper/85 backdrop-blur-md",children:e.jsxs("nav",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-5",children:[e.jsxs(C,{to:"/",className:"font-display text-[15px] font-bold tracking-tightest",children:["LevelCode ",e.jsx("span",{className:"font-medium text-faint",children:"Cloud"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{to:"/pricing",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Pricing"}),e.jsx("a",{href:hr,target:"_blank",rel:"noreferrer",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"GitHub"}),e.jsx(C,{to:"/download",className:"rounded-full bg-ink px-4 py-1.5 text-sm font-semibold text-paper transition-colors hover:bg-flame",children:"Download"}),t?e.jsxs(e.Fragment,{children:[t.role==="admin"?e.jsx(C,{to:"/admin",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Admin"}):null,e.jsxs("a",{href:mr,title:"Open the LevelCode editor (signs it into this account)",className:"inline-flex items-center gap-1 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink",children:["IDE ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}),e.jsx(C,{to:"/account",title:"Account","aria-label":"Account",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-rule bg-card text-[12px] font-semibold text-ink transition-colors hover:border-ink",children:We(t.name,t.email)})]}):e.jsx(C,{to:"/login",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"Sign in"})]})]})})}const Ae="https://github.com/levelcodeai/levelcode/releases/latest",me={arm64:`${Ae}/download/LevelCode-arm64.dmg`,x64:`${Ae}/download/LevelCode-x64.dmg`};async function fr(){var n,o;const t=navigator,r=navigator.userAgent,a=/Mac/i.test(navigator.platform)||/Macintosh/.test(r),s=a&&(navigator.maxTouchPoints??0)>1;if(!a||s)return"not-mac";try{const d=await((o=(n=t.userAgentData)==null?void 0:n.getHighEntropyValues)==null?void 0:o.call(n,["architecture"]));if((d==null?void 0:d.architecture)==="arm")return"arm64";if((d==null?void 0:d.architecture)==="x86")return"x64"}catch{}try{const d=document.createElement("canvas"),c=d.getContext("webgl")||d.getContext("experimental-webgl"),m=c==null?void 0:c.getExtension("WEBGL_debug_renderer_info"),u=m&&c?String(c.getParameter(m.UNMASKED_RENDERER_WEBGL)):"";if(/apple/i.test(u))return"arm64";if(/intel|amd|radeon/i.test(u))return"x64"}catch{}return"unknown-mac"}function gr(){const[t,r]=l.useState("unknown-mac");l.useEffect(()=>{let o=!0;return fr().then(d=>{o&&r(d)}),()=>{o=!1}},[]);const a=t==="x64"?"x64":"arm64",s=a==="arm64"?"Apple Silicon":"Intel",n=t==="not-mac";return e.jsxs(e.Fragment,{children:[e.jsx(pr,{}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-24",children:[e.jsx("div",{className:"lineno mb-4",children:"06 · download"}),e.jsxs("h1",{className:"font-display text-[clamp(2rem,5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-balance",children:["Download ",e.jsx("span",{className:"pp",children:"LevelCode"})," for macOS"]}),e.jsx("p",{className:"mt-5 max-w-xl text-[17px] leading-relaxed text-sub pretty",children:"The AI-native editor — your plan, keys, and usage in one place. Universal on any modern Mac; pick Intel if you’re on an older one."}),n?e.jsx("div",{className:"surface mt-8 p-5 text-[14px] text-sub",children:"LevelCode is a macOS app for now. Grab it on your Mac — or download a build below to move over."}):null,e.jsxs("div",{className:"mt-9 flex flex-col items-start gap-3",children:[e.jsxs("a",{href:me[a],className:"btn-primary text-[15px]",download:!0,children:["Download for ",s," Mac"]}),e.jsx("p",{className:"font-mono text-[12px] text-faint",children:"Universal .dmg · latest release · macOS 12 Monterey or later"})]}),e.jsx("div",{className:"mt-10 lineno",children:"all builds"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[e.jsx("a",{href:me.arm64,className:"btn-ghost text-[14px]",download:!0,children:"Apple Silicon (M1–M4)"}),e.jsx("a",{href:me.x64,className:"btn-ghost text-[14px]",download:!0,children:"Intel Mac (x64)"})]}),e.jsx("p",{className:"mt-4 font-mono text-[12px] text-faint",children:"Not sure which Mac you have? Apple menu → About This Mac. “Apple M…” chip → Apple Silicon; “Intel” → Intel."})]})]})}const I=t=>({t,c:"text-[#c58aff]"}),Ee=t=>({t,c:"text-[#7fd88f]"}),W=t=>({t,c:"text-[#9fb4ff]"}),pe=t=>({t,c:"text-[#5b6172]"}),fe=t=>({t,c:"text-[#e6a86b]"}),j=t=>({t}),R=[{id:"generate",label:"Generate",file:"payments/refund_service.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Generate."})," Describe the change in plain language — LevelCode writes idiomatic code in your project’s style, right in the buffer."]}),chat:[{who:"you",text:"Add idempotency to RefundService — same request twice must not double-refund."},{who:"ai",text:"Adding an idempotency key check backed by Redis, with a 24h TTL. Writing it now…"}],code:[{no:"12",toks:[I("class"),j(" "),W("RefundService")]},{no:"13",toks:[j(" "),I("def"),j(" "),W("call"),j("(charge, key:)")]},{no:"14",toks:[j(" "),I("return"),j(" cached(key) "),I("if"),j(" seen?(key)")]},{no:"15",toks:[j(" result = gateway.refund(charge)")]},{no:"16",toks:[j(" remember(key, result, ttl: "),fe("24"),j(".hours)")]},{no:"17",toks:[j(" result")]},{no:"18",toks:[j(" "),I("end")]},{no:"19",toks:[I("end")]}]},{id:"refactor",label:"Refactor",file:"api/orders_controller.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Refactor."})," Select any block and ask. LevelCode restructures across files, keeping behavior identical and diffs reviewable."]}),chat:[{who:"you",text:"This controller does too much. Extract the pricing logic."},{who:"ai",text:"Extracting to app/services/pricing_calculator.rb and updating 3 call sites. Behavior unchanged — diff ready."}],code:[{no:"40",toks:[pe("# before: 62 lines in controller")]},{no:"41",toks:[I("def"),j(" "),W("create")]},{no:"42",toks:[j(" total = "),W("PricingCalculator")]},{no:"43",toks:[j(" .new(cart, coupon: params[:coupon])")]},{no:"44",toks:[j(" .total")]},{no:"45",toks:[j(" order = "),W("Order"),j(".create!(total:)")]},{no:"46",toks:[j(" render json: order")]},{no:"47",toks:[I("end")]}]},{id:"explain",label:"Explain",file:"legacy/billing_engine.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Explain."})," Point at unfamiliar code — get a walkthrough of what it does, why it exists, and where it’s called from."]}),chat:[{who:"you",text:"What is this proration branch actually doing?"},{who:"ai",text:"It splits the billing period at the plan-change date, credits unused time on the old plan, and charges the remainder at the new rate. Called from 2 places — both webhooks."}],code:[{no:"88",toks:[I("if"),j(" plan_changed_mid_cycle?")]},{no:"89",toks:[j(" credit = unused_ratio * old_rate")]},{no:"90",toks:[j(" charge = remaining_ratio * new_rate")]},{no:"91",toks:[j(" invoice.adjust(credit:, charge:)")]},{no:"92",toks:[I("end")]},{no:"93",toks:[pe("# ← LevelCode: proration on plan change")]}]},{id:"test",label:"Test",file:"spec/refund_service_spec.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Test."})," LevelCode drafts the spec, runs it, reads the failure, and fixes the code — a full red-green loop without leaving the editor."]}),chat:[{who:"you",text:"Write specs for the double-refund case."},{who:"ai",text:"Spec written. Running… 1 failure: cache key ignored currency. Patched — all green ✓"}],code:[{no:"05",toks:[W("it"),j(" "),Ee('"refunds only once per key"'),j(" "),I("do")]},{no:"06",toks:[j(" "),fe("2"),j(".times { service.call(charge, key:) }")]},{no:"07",toks:[j(" expect(gateway.refunds.count).to eq("),fe("1"),j(")")]},{no:"08",toks:[I("end")]},{no:"09",toks:[j("")]},{no:"10",toks:[Ee("✓ 14 examples, 0 failures — 0.42s")]}]},{id:"review",label:"Review",file:"PR #241 · fix race in webhook retry — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Review."})," Before you push, LevelCode flags edge cases, security issues, and style drift — like a senior reviewer on every commit."]}),chat:[{who:"you",text:"Review this PR before I push."},{who:"ai",text:"One real issue: retry loop can fire twice if the worker restarts between enqueue and ack. Suggesting a fix inline."}],code:[{no:"21",toks:[pe("# ⚠ LevelCode: not restart-safe")]},{no:"22",toks:[{t:"- retry_later(webhook)",c:"text-[#e06c75]"}]},{no:"23",toks:[{t:"+ ",c:"text-[#7fd88f]"},W("WebhookRetryJob")]},{no:"24",toks:[{t:"+ ",c:"text-[#7fd88f]"},j(" .set(wait: backoff(attempt))")]},{no:"25",toks:[{t:"+ ",c:"text-[#7fd88f]"},j(" .perform_later(webhook.id,")]},{no:"26",toks:[{t:"+ ",c:"text-[#7fd88f]"},j(" lock: webhook.lock_token)")]}]}];function vr(){const[t,r]=l.useState(!1),[a,s]=l.useState(0),[n,o]=l.useState(!0),[d,c]=l.useState(!0),[m,u]=l.useState(0),[g,i]=l.useState(0),[f,v]=l.useState(0),[w,y]=l.useState(!1),[x,p]=l.useState(0),b=l.useRef(null),S=l.useRef(null),h=l.useRef([]),T=l.useRef([]),A=l.useRef([]),q=R[a],ee=q.duration??9;l.useEffect(()=>{window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(r(!0),o(!1),i(R[a].code.length))},[]),l.useLayoutEffect(()=>{var L;const k=()=>{const N=h.current[a],M=S.current;if(!N||!M||!N.parentElement)return;const $=N.getBoundingClientRect(),U=N.parentElement.getBoundingClientRect();M.style.width=`${$.width}px`,M.style.transform=`translateX(${$.left-U.left}px)`};return k(),window.addEventListener("resize",k),(L=document.fonts)==null||L.ready.then(k).catch(()=>{}),()=>window.removeEventListener("resize",k)},[a,t]),l.useEffect(()=>{const k=b.current;if(!k)return;const L=new IntersectionObserver(([N])=>c(N.isIntersecting),{threshold:.25});return L.observe(k),()=>L.disconnect()},[]),l.useEffect(()=>{if(a===f)return;y(!0);const k=setTimeout(()=>{v(a),y(!1)},200);return()=>clearTimeout(k)},[a,f]),l.useEffect(()=>{if(t||(A.current.forEach(clearTimeout),A.current=[],!n||!d))return;const k=T.current[a],L=k?Array.from(k.querySelectorAll("[data-text]")):[];L.forEach(M=>M.textContent=""),i(0),p(M=>M+1);let N=300;return L.forEach(M=>{const $=M.dataset.text??"";for(let U=1;U<=$.length;U++)N+=14,A.current.push(setTimeout(()=>M.textContent=$.slice(0,U),N));N+=350}),R[a].code.forEach((M,$)=>{N+=320,A.current.push(setTimeout(()=>i($+1),N))}),A.current.push(setTimeout(()=>s(M=>(M+1)%R.length),(R[a].duration??9)*1e3)),()=>{A.current.forEach(clearTimeout),A.current=[]}},[a,n,d,m,t]);const st=()=>{o(k=>{const L=!k;return L&&u(N=>N+1),L})},Ne=k=>t?R[k].code.length:k===a?g:0;return e.jsxs("div",{ref:b,className:"relative",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-1/2 top-1/2 h-[70%] w-[85%] -translate-x-1/2 -translate-y-1/2 rounded-full bg-flame/10 blur-3xl"}),e.jsxs("div",{role:"tablist","aria-label":"LevelCode capabilities",className:"relative mx-auto mb-6 flex w-max max-w-full gap-1 overflow-x-auto rounded-full border border-rule bg-card p-1.5 [scrollbar-width:none]",children:[e.jsx("span",{ref:S,"aria-hidden":!0,className:"absolute left-0 top-1.5 h-[calc(100%-12px)] rounded-full bg-flame shadow-[0_0_18px_rgb(var(--accent-rgb)/0.45)] transition-[transform,width] duration-300 ease-out"}),R.map((k,L)=>e.jsx("button",{ref:N=>{h.current[L]=N},role:"tab",id:`sc-tab-${k.id}`,"aria-selected":L===a,"aria-controls":`sc-pane-${k.id}`,onClick:()=>{L===a?u(N=>N+1):s(L)},onKeyDown:N=>{var M,$;N.key==="ArrowRight"&&((M=h.current[(L+1)%R.length])==null||M.focus()),N.key==="ArrowLeft"&&(($=h.current[(L-1+R.length)%R.length])==null||$.focus())},className:`relative z-10 whitespace-nowrap rounded-full px-5 py-2 text-sm font-semibold transition-colors ${L===a?"text-paper":"text-sub hover:text-ink"}`,children:k.label},k.id))]}),e.jsx("p",{"aria-live":"polite",className:`mx-auto mb-8 min-h-[48px] max-w-xl text-center text-[15px] leading-relaxed text-sub transition-opacity duration-200 ${w?"opacity-0":"opacity-100"}`,children:R[f].caption}),e.jsxs("div",{className:"shot-shadow relative overflow-hidden rounded-2xl border border-[#20232f] bg-[#0a0c16]",children:[e.jsxs("div",{className:"flex h-10 items-center gap-2 border-b border-[#1b1e2b] bg-[#0d1020] px-4",children:[e.jsxs("span",{className:"flex gap-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#ff5f57]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#febc2e]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#28c840]"})]}),e.jsx("span",{className:"ml-2 truncate font-mono text-[12px] text-[#6b7280]",children:q.file}),e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-[#7d6bff]/40 bg-[#7d6bff]/15 px-2.5 py-0.5 font-mono text-[10.5px] text-[#c6bfff]",children:"AI session · live"})]}),e.jsxs("div",{className:"relative aspect-video bg-black/20",children:[R.map((k,L)=>e.jsx("div",{ref:N=>{T.current[L]=N},role:"tabpanel",id:`sc-pane-${k.id}`,"aria-labelledby":`sc-tab-${k.id}`,className:`absolute inset-0 transition-opacity duration-300 ${L===a?"opacity-100":"pointer-events-none opacity-0"}`,children:e.jsxs("div",{className:"grid h-full grid-cols-1 md:grid-cols-[minmax(200px,300px)_1fr]",children:[e.jsx("div",{className:"hidden flex-col gap-4 border-r border-[#1b1e2b] bg-black/15 p-5 font-mono text-[12.5px] leading-relaxed md:flex",children:k.chat.map((N,M)=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px] uppercase tracking-[0.14em] text-[#a99bff]",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-[#7d6bff] shadow-[0_0_8px_rgba(125,107,255,0.9)]"}),N.who==="you"?"You":"LevelCode"]}),e.jsx("div",{"data-text":N.text,className:N.who==="you"?"text-[#c7cbe0]":"text-[#8b93ad]",children:t?N.text:""})]},M))}),e.jsx("div",{className:"overflow-hidden whitespace-pre p-5 font-mono text-[12px] leading-[1.9] text-[#c7cbe0] md:text-[13px]",children:k.code.slice(0,Ne(L)).map((N,M)=>e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.6em] select-none text-[#3b4157]",children:N.no}),N.toks.map(($,U)=>e.jsx("span",{className:$.c??"text-[#c7cbe0]",children:$.t},U)),M===Ne(L)-1&&!t&&e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]},M))})]})},k.id)),!t&&e.jsx("button",{type:"button",onClick:st,"aria-label":n?"Pause showcase":"Play showcase",className:"absolute bottom-4 right-4 z-10 grid h-10 w-10 place-items-center rounded-full border border-white/20 bg-black/50 text-white backdrop-blur transition-colors hover:bg-[#7d6bff]/30",children:n?e.jsxs("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:[e.jsx("rect",{x:"3",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"9",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsx("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:e.jsx("path",{d:"M4 2.5v11a1 1 0 0 0 1.53.85l9-5.5a1 1 0 0 0 0-1.7l-9-5.5A1 1 0 0 0 4 2.5z"})})}),e.jsx("div",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-0 h-[3px]",children:e.jsx("i",{className:"block h-full w-0 bg-[#7d6bff] shadow-[0_0_10px_rgba(125,107,255,0.8)]",style:n&&d&&!t?{animation:`scfill ${ee}s linear forwards`}:void 0},x)})]})]})]})}const br={amber:"#e2a43c",blue:"#57a2e8",green:"#7cb85c"},jr={name:"Design a Key-Value Store",goal:"Build and test a distributed, highly-available key-value store — implement it in C.",reference:"https://bytebytego.com/courses/system-design-interview/design-a-key-value-store",w:1740,h:700,nodes:[{id:"req",label:"requirements",tier:"powerful",color:"amber",x:20,y:300},{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:320,y:300},{id:"storage",label:"storage-engine",tier:"balanced",color:"amber",x:620,y:130},{id:"hash",label:"consistent-hash",tier:"balanced",color:"blue",x:620,y:245},{id:"repl",label:"replication+quorum",tier:"balanced",color:"amber",x:620,y:360},{id:"vclock",label:"vector-clocks",tier:"balanced",color:"amber",x:620,y:475},{id:"gossip",label:"gossip+failover",tier:"balanced",color:"blue",x:620,y:590},{id:"integrate",label:"integrate+server",tier:"balanced",color:"blue",x:920,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1220,y:240},{id:"build",label:"build+validate",tier:"balanced",color:"green",x:1220,y:360},{id:"review",label:"review+run-guide",tier:"balanced",color:"amber",x:1520,y:300}],edges:[{from:"req",to:"arch"},{from:"arch",to:"storage"},{from:"arch",to:"hash"},{from:"arch",to:"repl"},{from:"arch",to:"vclock"},{from:"arch",to:"gossip"},{from:"storage",to:"integrate"},{from:"hash",to:"integrate"},{from:"repl",to:"integrate"},{from:"vclock",to:"integrate"},{from:"gossip",to:"integrate"},{from:"integrate",to:"tests"},{from:"integrate",to:"build"},{from:"tests",to:"review"},{from:"build",to:"review"}]},yr={name:"Real-time Gaming Leaderboard",goal:"Design and test a real-time gaming leaderboard — top 10 by score, a user's rank, and ±4 neighbours around them.",reference:"https://bytebytego.com/courses/system-design-interview/real-time-gaming-leaderboard",w:1740,h:640,nodes:[{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:20,y:300},{id:"api",label:"public-api",tier:"balanced",color:"blue",x:320,y:130},{id:"gateway",label:"api-gateway",tier:"balanced",color:"blue",x:320,y:300},{id:"game",label:"game-service",tier:"balanced",color:"blue",x:320,y:470},{id:"relational",label:"relational-baseline",tier:"balanced",color:"amber",x:620,y:130},{id:"redis",label:"redis-sorted-set",tier:"balanced",color:"amber",x:620,y:300},{id:"nosql",label:"nosql-dynamodb",tier:"balanced",color:"amber",x:620,y:470},{id:"persist",label:"persistence-mysql",tier:"balanced",color:"amber",x:920,y:130},{id:"shard",label:"sharding",tier:"balanced",color:"blue",x:920,y:300},{id:"cache",label:"rank-cache",tier:"balanced",color:"amber",x:920,y:470},{id:"service",label:"leaderboard-service",tier:"balanced",color:"blue",x:1220,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1520,y:300}],edges:[{from:"arch",to:"api"},{from:"arch",to:"gateway"},{from:"arch",to:"game"},{from:"api",to:"relational"},{from:"api",to:"redis"},{from:"gateway",to:"redis"},{from:"game",to:"redis"},{from:"relational",to:"redis"},{from:"redis",to:"persist"},{from:"redis",to:"nosql"},{from:"redis",to:"shard"},{from:"shard",to:"cache"},{from:"persist",to:"service"},{from:"cache",to:"service"},{from:"nosql",to:"service"},{from:"service",to:"tests"}]},$e=[jr,yr],wr={"Design a Key-Value Store":"KV","Real-time Gaming Leaderboard":"LB"},Nr=200,re=44;function kr(){const[t,r]=l.useState(null),[a,s]=l.useState(""),[n,o]=l.useState(!1),[d,c]=l.useState(!1),[m,u]=l.useState(new Set),g=l.useRef(null),i=l.useRef([]),f=l.useCallback(x=>{r(x),s(x.goal),u(new Set)},[]),v=l.useCallback(()=>{t&&(i.current.forEach(clearTimeout),i.current=[],u(new Set),t.nodes.forEach((x,p)=>{const b=setTimeout(()=>{u(h=>new Set(h).add(x.id))},p*900),S=setTimeout(()=>{u(h=>{const T=new Set(h);return T.delete(x.id),T})},p*900+1600);i.current.push(b,S)}))},[t]);l.useEffect(()=>()=>i.current.forEach(clearTimeout),[]);const w=x=>{x.preventDefault(),c(!1),o(!1);const p=x.dataTransfer.getData("text/levelcode-sketch"),b=$e.find(S=>S.name===p);b&&f(b)},y=x=>t==null?void 0:t.nodes.find(p=>p.id===x);return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[260px_1fr]",children:[e.jsxs("div",{className:"surface p-4",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.24em] text-flame",children:"template palette"}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-sub",children:"Drag a card onto the canvas to lay down a fully-configured agent topology."}),e.jsx("div",{className:"mt-4 space-y-3",children:$e.map(x=>e.jsxs("button",{type:"button",draggable:!0,onDragStart:p=>{p.dataTransfer.setData("text/levelcode-sketch",x.name),p.dataTransfer.effectAllowed="copy",o(!0)},onDragEnd:()=>o(!1),onClick:()=>f(x),className:"group w-full cursor-grab rounded-md border border-rule bg-paper p-3 text-left transition-colors hover:border-flame/60 active:cursor-grabbing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid h-7 w-7 place-items-center rounded border border-flame/30 bg-flame/10 font-mono text-[13px] text-flame",children:wr[x.name]??"◆"}),e.jsx("span",{className:"font-display text-[13.5px] font-semibold leading-tight text-ink",children:x.name})]}),e.jsxs("p",{className:"mt-2 font-mono text-[10px] uppercase tracking-[0.14em] text-faint",children:[x.nodes.length," agents · ",x.edges.length," links · bytebytego"]}),e.jsx("span",{className:"mt-2 inline-block font-mono text-[10px] text-flame/70 group-hover:text-flame",children:"⠿ drag onto canvas →"})]},x.name))})]}),e.jsxs("div",{ref:g,onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy",c(!0)},onDragLeave:()=>c(!1),onDrop:w,className:`relative min-h-[440px] overflow-hidden rounded-xl border bg-[#f2f0ea] transition-colors ${d?"border-flame/70":"border-rule"}`,children:[e.jsx("div",{"aria-hidden":!0,className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle, rgba(27,26,23,0.13) 1px, transparent 1.4px)",backgroundSize:"22px 22px"}}),t&&e.jsxs("div",{className:"relative z-10 flex items-center gap-2 border-b border-rule bg-card/80 px-3 py-2 backdrop-blur-sm",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-flame",children:"goal"}),e.jsx("input",{value:a,onChange:x=>s(x.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[12.5px] text-ink outline-none placeholder:text-faint",placeholder:"Describe what to build…"}),e.jsx("button",{type:"button",onClick:v,className:"shrink-0 rounded bg-flame px-3 py-1 font-mono text-[11px] font-semibold text-paper transition-colors hover:bg-flamedeep",children:"▶ Run"})]}),!t&&e.jsx("div",{className:"relative z-10 grid h-full min-h-[440px] place-items-center px-6 text-center",children:e.jsxs("div",{children:[e.jsx("div",{className:`mx-auto mb-4 grid h-14 w-14 place-items-center rounded-lg border-2 border-dashed transition-colors ${n||d?"border-flame text-flame":"border-faint/50 text-faint"}`,children:"⠿"}),e.jsx("p",{className:"font-display text-[15px] font-semibold text-ink",children:"Drop a template here"}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-xs text-[12.5px] leading-relaxed text-sub",children:"Drag a template card in — or just click it — to materialise the full topology."})]})}),t&&e.jsx("div",{className:"relative z-10 w-full overflow-auto p-3",children:e.jsxs("div",{className:"relative",style:{width:t.w,height:t.h},children:[e.jsx("svg",{className:"pointer-events-none absolute inset-0 h-full w-full",viewBox:`0 0 ${t.w} ${t.h}`,children:t.edges.map((x,p)=>{const b=y(x.from),S=y(x.to);if(!b||!S)return null;const h=b.x+Nr,T=b.y+re,A=S.x,q=S.y+re;return e.jsx("path",{d:`M${h},${T} C ${h+70},${T} ${A-70},${q} ${A},${q}`,fill:"none",stroke:"#b9b4a8",strokeWidth:1.5},p)})}),t.nodes.map(x=>{const p=br[x.color],b=m.has(x.id);return e.jsxs("div",{className:`sb-node absolute w-[200px] rounded-lg border bg-white p-3 shadow-[0_2px_10px_rgba(27,26,23,0.08)] ${b?"sb-node--running":""}`,style:{left:x.x,top:x.y,borderColor:b?"transparent":"#e2ddd2"},children:[b&&e.jsx("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full overflow-visible",children:e.jsx("rect",{className:"sb-ants",x:"0.75",y:"0.75",rx:"8",fill:"none",stroke:"#65a34a",strokeWidth:"1.5",strokeDasharray:"6 6",style:{width:"calc(100% - 1.5px)",height:"calc(100% - 1.5px)"}})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 shrink-0 rounded-[3px] ${b?"sb-pulse":""}`,style:{background:b?"#65a34a":p}}),e.jsx("span",{className:"truncate text-[13px] font-semibold text-[#2a2822]",children:x.label}),b?e.jsx("span",{className:"ml-auto shrink-0 font-mono text-[9px] uppercase tracking-[0.14em] text-[#65a34a]",children:"running"}):e.jsx("span",{"aria-hidden":!0,className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[#3f3c34]/50"})]}),e.jsxs("p",{className:"mt-1 text-[11px] text-[#8a8578]",children:["tier: ",x.tier]}),e.jsx("span",{"aria-hidden":!0,className:"absolute -left-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:re-5}}),e.jsx("span",{"aria-hidden":!0,className:"absolute -right-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:re-5}})]},x.id)})]})}),t&&e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-3 right-3 z-10 flex items-center gap-1.5 font-mono text-[11px] text-sub",children:["−","99%","+","⤢","⇄ Tidy"].map(x=>e.jsx("span",{className:"rounded-md border border-[#e2ddd2] bg-white px-2 py-1 shadow-sm",children:x},x))})]})]})}const O="https://github.com/levelcodeai/levelcode",Ke=`${O}/releases/latest`,De=`${Ke}/download/LevelCode-arm64.dmg`,Pe=`${Ke}/download/LevelCode-x64.dmg`,Ie="0.9.2";function Cr(){const[t,r]=l.useState(()=>{try{return sessionStorage.getItem("lc-latest-version")||Ie}catch{return Ie}});return l.useEffect(()=>{try{if(sessionStorage.getItem("lc-latest-version"))return}catch{}let a=!0;return fetch("https://api.github.com/repos/levelcodeai/levelcode/releases/latest",{headers:{Accept:"application/vnd.github+json"}}).then(s=>s.ok?s.json():null).then(s=>{const n=String((s==null?void 0:s.tag_name)??"").replace(/^v/,"");if(a&&n){r(n);try{sessionStorage.setItem("lc-latest-version",n)}catch{}}}).catch(()=>{}),()=>{a=!1}},[]),t}function Re(){const t=Cr();return e.jsxs(D,{strip:!0,children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 pb-14 pt-10",children:[e.jsxs("header",{className:"flex flex-col items-center gap-10 md:flex-row md:items-center md:justify-between",children:[e.jsx("div",{"aria-hidden":!0,className:"relative h-[280px] w-[300px] shrink-0",children:e.jsxs("svg",{viewBox:"0 0 300 280",className:"h-full w-full",children:[e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"118",cy:"128",r:"104",fill:"var(--c-accent)",opacity:"0.14"})}),e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"186",cy:"104",r:"86",fill:"#7d6bff",opacity:"0.16"})}),e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"120",cy:"180",r:"72",fill:"#5fb4ff",opacity:"0.18"})}),e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"204",cy:"182",r:"58",fill:"#a8ecff",opacity:"0.28"})}),e.jsxs("g",{className:"portal-layer",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M96 196 L152 152 L208 196",stroke:"#5b3fd6",strokeWidth:"21",opacity:"0.55"}),e.jsx("path",{d:"M96 152 L152 108 L208 152",stroke:"#7d6bff",strokeWidth:"21",opacity:"0.8"}),e.jsx("path",{d:"M96 108 L152 64 L208 108",stroke:"#5fb4ff",strokeWidth:"21"})]})]})}),e.jsxs("ul",{className:"w-full max-w-sm space-y-3 text-center md:text-left",children:[e.jsxs("li",{className:"text-[34px] font-bold leading-none tracking-tight text-[var(--c-text)]",children:["Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsxs("li",{className:"text-[14px]",children:[e.jsx("span",{className:"mr-2 font-mono font-semibold text-[var(--c-text)]",children:t}),e.jsx("a",{href:`${O}/releases/tag/v${t}`,className:"text-[var(--c-accent)] hover:underline",children:"Release notes"})]}),e.jsxs("li",{className:"pt-1",children:[e.jsx("span",{className:"block font-semibold text-[var(--c-text)]",children:"macOS"}),e.jsx("span",{className:"text-[13px] text-[var(--c-text3)]",children:"For Apple Silicon and Intel Macs"})]}),e.jsx("li",{children:e.jsxs("a",{href:De,className:"classic-button w-full",download:!0,children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M7.47 10.78a.75.75 0 0 0 1.06 0l3.75-3.75a.75.75 0 0 0-1.06-1.06L8.75 8.44V1.75a.75.75 0 0 0-1.5 0v6.69L4.78 5.97a.75.75 0 0 0-1.06 1.06l3.75 3.75ZM3.75 13a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z"})}),"Download"]})}),e.jsxs("li",{className:"text-[13px] text-[var(--c-text3)]",children:["Intel Mac?"," ",e.jsx("a",{href:Pe,className:"text-[var(--c-accent)] hover:underline",download:!0,children:"Download x64"})," · ",e.jsx("a",{href:`${O}/releases`,className:"text-[var(--c-accent)] hover:underline",children:"Other builds"})]}),e.jsxs("li",{className:"text-[13px] text-[var(--c-text3)]",children:["Free and open source under the"," ",e.jsx("a",{href:`${O}/blob/HEAD/LICENSE`,className:"text-[var(--c-accent)] hover:underline",children:"MIT license"}),". No account required."]})]})]}),e.jsxs("h1",{className:"mx-auto mt-12 max-w-3xl text-center text-[34px] font-bold leading-tight tracking-tight text-[var(--c-text)] text-balance sm:text-[42px]",children:["A hackable editor for the ",e.jsx("span",{className:"text-[var(--c-accent)]",children:"AI era"})]})]})}),e.jsx("section",{id:"agent",className:"border-b border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Agent for LevelCode"}),e.jsx("p",{className:"mt-3 max-w-3xl pretty",children:"Great software happens when the editor works with you. The LevelCode agent plans, edits across files, runs commands, and verifies its own work — right in your editor, on your own API key, with no middleman between you and the model."}),e.jsx("div",{className:"mt-8",children:e.jsx(vr,{})}),e.jsx("p",{className:"mt-8 max-w-3xl pretty",children:"Every edit lands as a reviewable Keep/Undo change. Every command waits at an approval gate. Before the agent says done, it checks diagnostics and runs your tests — and every turn is a checkpoint you can rewind."}),e.jsx("p",{className:"mt-6",children:e.jsx("a",{href:"#download",className:"classic-button",children:"Download for macOS"})})]})}),e.jsx("section",{id:"sketches",className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Sketches for LevelCode"}),e.jsx("p",{className:"mt-3 max-w-3xl pretty",children:"Some systems are too big for one prompt. Sketches let you drag a whole agent topology onto a canvas — eleven wired agents for a key-value store, a full leaderboard build — set the goal, hit Run, and watch them light up in order."}),e.jsx("div",{className:"classic-demo-sketch mt-8",children:e.jsx(kr,{})}),e.jsx("p",{className:"mt-8",children:e.jsx("a",{href:`${O}/tree/HEAD/docs`,className:"classic-button--quiet",children:"Learn more"})})]})}),e.jsx("section",{className:"border-b border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-center text-[26px] font-semibold text-[var(--c-text)]",children:"Everything you would expect"}),e.jsx("div",{className:"mt-10 grid gap-x-10 gap-y-10 sm:grid-cols-2 lg:grid-cols-3",children:Sr.map(r=>e.jsxs("div",{className:"text-center sm:text-left",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:r.icon}),e.jsx("h4",{className:"mt-3 text-[17px] font-semibold text-[var(--c-text)]",children:r.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:r.body})]},r.title))})]})}),e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-center text-[26px] font-semibold text-[var(--c-text)]",children:"Make it your editor"}),e.jsx("div",{className:"mt-10 grid gap-x-10 gap-y-10 sm:grid-cols-2",children:Lr.map(r=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:r.icon}),e.jsx("h4",{className:"mt-3 text-[17px] font-semibold text-[var(--c-text)]",children:r.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:r.body})]},r.title))})]})}),e.jsx("section",{id:"download",className:"scroll-mt-14 border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 text-center",children:[e.jsx("svg",{viewBox:"0 0 120 120",width:"64",height:"64",className:"mx-auto","aria-hidden":!0,children:e.jsxs("g",{fill:"none",stroke:"var(--c-accent)",strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:"0.4"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:"0.7"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})}),e.jsx("h2",{className:"mt-4 text-[34px] font-bold tracking-tight text-[var(--c-text)] text-balance sm:text-[42px]",children:"Download LevelCode"}),e.jsxs("p",{className:"mt-2 font-mono text-[14px] text-[var(--c-text3)]",children:["v",t," ·"," ",e.jsx("a",{href:`${O}/releases/tag/v${t}`,className:"text-[var(--c-accent)] hover:underline",children:"Release notes"})]}),e.jsx("p",{className:"mx-auto mt-4 max-w-xl text-[17px] pretty",children:"Free and open. Drag the .dmg to Applications, add a key — or run fully offline on local Ollama — and the editor starts editing with you."}),e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-4",children:[e.jsxs("a",{href:De,className:"classic-button px-10 py-4 text-[17px]",download:!0,children:[e.jsx(Oe,{}),"Download for Apple Silicon"]}),e.jsxs("a",{href:Pe,className:"classic-button--quiet px-10 py-4 text-[17px]",download:!0,children:[e.jsx(Oe,{}),"Intel Mac"]})]}),e.jsxs("p",{className:"mt-6 text-[14px] text-[var(--c-text3)]",children:["free · MIT · no account required ·"," ",e.jsx("a",{href:`${O}/releases`,className:"text-[var(--c-accent)] hover:underline",children:"all releases →"})]})]})}),e.jsx("section",{className:"border-b border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto grid max-w-5xl gap-12 px-5 py-14 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Open source"}),e.jsx("p",{className:"mt-3 pretty",children:"LevelCode is open source, built on Code-OSS and released under MIT. Be part of the community — or help improve your favorite editor."}),e.jsx("p",{className:"mt-5",children:e.jsxs("a",{href:O,className:"classic-button",children:[e.jsx(Tr,{}),"Fork on GitHub"]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Keep in touch"}),e.jsx("table",{className:"mt-4 w-full text-[15px]",children:e.jsx("tbody",{children:_r.map(r=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-0",children:[e.jsx("td",{className:"py-2 pr-6 text-[var(--c-text3)]",children:r.label}),e.jsx("td",{className:"py-2",children:r.to?e.jsx(C,{to:r.to,className:"text-[var(--c-accent)] hover:underline",children:r.text}):e.jsx("a",{href:r.href,className:"text-[var(--c-accent)] hover:underline",children:r.text})})]},r.label))})})]})]})})]})}const Sr=[{title:"Native AI agent",body:"Chat, edit, autocomplete, and a full agent mode — first-class in the editor, not a bolted-on plugin. Bring your own key or run local Ollama.",icon:e.jsx(B,{d:"M13 1 3.5 12.5h5L7 23l9.5-11.5h-5L13 1Z",filled:!0})},{title:"Power editing",body:"The Notepad++ toolkit: keystroke macros, line operations, column mode with incrementing numbers, encoding and EOL control, huge-file mode.",icon:e.jsx(B,{d:"M4 5h16M4 9h10M4 13h16M4 17h7"})},{title:"Smart autocompletion",body:"Debounced ghost text over every file, cancelled the instant you keep typing — routed to a fast model per provider.",icon:e.jsx(B,{d:"M12 3a6 6 0 0 1 3.5 10.9c-.6.45-1 1.1-1 1.85V17h-5v-1.25c0-.75-.4-1.4-1-1.85A6 6 0 0 1 12 3ZM10 20h4"})},{title:"Built-in package manager",body:"Thousands of open-source extensions from Open VSX — search, install, and update without leaving the editor.",icon:e.jsx(B,{d:"M12 3 4 7v10l8 4 8-4V7l-8-4Zm0 0v8m8-4-8 4M4 7l8 4"})},{title:"Multiple panes",body:"Split the interface into panes to compare and edit code across files — plus a real approval-gated terminal.",icon:e.jsx(B,{d:"M4 5h16v14H4V5Zm8 0v14"})},{title:"Find and replace",body:"Find, preview, and replace as you type — in a file or across every project, powered by ripgrep.",icon:e.jsx(B,{d:"M10.5 4a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13Zm5.2 11.7L20 20"})}],Lr=[{title:"Packages",body:"Choose from thousands of open-source packages on Open VSX that add features and functionality — or build one from scratch with the live package-dev loop.",icon:e.jsx(B,{d:"M12 3 4 7v10l8 4 8-4V7l-8-4Zm0 0v8m8-4-8 4M4 7l8 4"})},{title:"Themes",body:"One Dark ships built in — Atom's own palette lives on in the editor. Install community themes or restyle everything with CSS.",icon:e.jsx(B,{d:"M12 3a9 9 0 1 0 0 18c1.5 0 2-1 1.4-2-.5-.9-.2-2 .9-2H16a5 5 0 0 0 5-5c0-5-4-9-9-9Zm-4.5 9a1.2 1.2 0 1 1 0-2.4 1.2 1.2 0 0 1 0 2.4Zm3-4a1.2 1.2 0 1 1 0-2.4 1.2 1.2 0 0 1 0 2.4Zm5 0a1.2 1.2 0 1 1 0-2.4 1.2 1.2 0 0 1 0 2.4Z"})},{title:"Customization",body:"An init script that runs at boot and hot-reloads on save, keymap presets for Atom, Sublime, and Notepad++ muscle memory, and skills that teach the agent your workflows.",icon:e.jsx(B,{d:"M14.5 4.5a4 4 0 0 0-5.4 4.8L3 15.4V19h3.6l6.1-6.1a4 4 0 0 0 4.8-5.4l-2.6 2.6-2.4-2.4 2-2.2Z"})},{title:"Under the hood",body:"A desktop app built on Code-OSS and Electron — the same battle-tested core as VS Code, bent back toward Atom's hackable soul. MIT, forkable, yours.",icon:e.jsx(B,{d:"M9 5 3 12l6 7m6-14 6 7-6 7"})}],_r=[{label:"GitHub",href:"https://github.com/levelcodeai",text:"github.com/levelcodeai"},{label:"Discussions",href:`${O}/discussions`,text:"GitHub Discussions"},{label:"Releases",href:`${O}/releases`,text:"Release notes & builds"},{label:"Cloud",to:"/pricing",text:"Plans & pricing"}];function B({d:t,filled:r=!1}){return e.jsx("svg",{viewBox:"0 0 24 24",width:"30",height:"30",fill:r?"currentColor":"none",stroke:r?"none":"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"inline-block",children:e.jsx("path",{d:t})})}function Oe(){return e.jsx("svg",{viewBox:"0 0 814 1000",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M788 341c-6 4-107 61-107 187 0 146 128 198 132 199-1 3-20 70-67 138-42 60-86 120-153 120s-84-39-161-39c-75 0-102 40-163 40s-104-56-153-124C60 782 13 660 13 544c0-186 121-285 240-285 63 0 116 42 156 42 38 0 97-44 169-44 27 0 125 2 210 84zM554 172c31-37 53-88 53-139 0-7-1-14-2-20-50 2-110 34-146 76-29 32-55 83-55 135 0 8 1 16 2 18 3 1 8 2 13 2 45 0 102-30 135-72z"})})}function Tr(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})})}const Xe="lc_attribution",Je=["linkedin","youtube","ref","utm_source","utm_medium","utm_campaign","utm_content"],Qe=120,Mr=40,le=300,Ar=40;function Er(t){if(!t||typeof t!="object")return null;const r=t,a={},s=r.params;if(s&&typeof s=="object")for(const d of Je){const c=s[d];typeof c=="string"&&c&&(a[d]=c.slice(0,Qe))}const n=typeof r.source=="string"?r.source.slice(0,Mr):"";if(Object.keys(a).length===0&&!n)return null;const o=(d,c)=>typeof d=="string"?d.slice(0,c):"";return{source:n||"other",params:a,landing:o(r.landing,le),referrer:o(r.referrer,le),ts:o(r.ts,Ar)}}function et(){try{const t=localStorage.getItem(Xe);return t?Er(JSON.parse(t)):null}catch{return null}}function $r(){if(!(typeof window>"u"))try{if(et())return;const t=new URLSearchParams(window.location.search),r={};for(const n of Je){const o=t.get(n);o&&(r[n]=o.slice(0,Qe))}if(Object.keys(r).length===0)return;const s={source:r.linkedin?"linkedin":r.youtube?"youtube":r.utm_source||r.ref||"other",params:r,landing:window.location.pathname.slice(0,le),referrer:(document.referrer||"").slice(0,le),ts:new Date().toISOString()};localStorage.setItem(Xe,JSON.stringify(s))}catch{}}function tt(){return typeof window>"u"?null:et()}function Dr({redirectUri:t,codeChallenge:r}){const[a,s]=l.useState("email"),[n,o]=l.useState(""),[d,c]=l.useState(""),[m,u]=l.useState(!1),[g,i]=l.useState(null);async function f(w){w.preventDefault(),u(!0),i(null);try{await E("/ai/auth/email",{body:{email:n}}),s("code")}catch(y){i(y instanceof z?y.message:"Couldn't send a code. Try again.")}finally{u(!1)}}async function v(w){w.preventDefault(),u(!0),i(null);try{const y=await E("/ai/auth/verify",{body:{email:n,code:d,redirect_uri:t,code_challenge:r,attribution:tt()}});if(!y.redirect)throw new z(422,"That code is invalid or has expired.");if(!y.redirect.startsWith("/")){const x=window.setTimeout(()=>{u(!1),i("Open LevelCode to finish signing in. If nothing happened, the editor may not be installed on this device.")},1500);window.addEventListener("pagehide",()=>window.clearTimeout(x),{once:!0}),K(y.redirect);return}K(y.redirect)}catch(y){i(y instanceof z?y.message:"That code is invalid or has expired."),u(!1)}}return a==="email"?e.jsxs("form",{onSubmit:f,className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Email"}),e.jsx("input",{type:"email",required:!0,autoFocus:!0,autoComplete:"email",value:n,onChange:w=>o(w.target.value),placeholder:"you@studio.dev",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-[15px] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),g?e.jsx("p",{className:"text-[13px] text-red-500",children:g}):null,e.jsx("button",{type:"submit",disabled:m,className:"classic-button w-full",children:m?"Sending…":"Email me a sign-in code"})]}):e.jsxs("form",{onSubmit:v,className:"flex flex-col gap-3",children:[e.jsxs("p",{className:"text-[13px]",children:["We sent a 6-digit code to ",e.jsx("span",{className:"font-medium text-[var(--c-text)]",children:n}),". Enter it below."]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Verification code"}),e.jsx("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]*",maxLength:6,required:!0,autoFocus:!0,value:d,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-center font-mono text-[22px] font-semibold tracking-[0.4em] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),g?e.jsx("p",{className:"text-[13px] text-red-500",children:g}):null,e.jsx("button",{type:"submit",disabled:m||d.length<6,className:"classic-button w-full",children:m?"Verifying…":"Verify & continue"}),e.jsxs("div",{className:"flex items-center justify-between text-[13px]",children:[e.jsx("button",{type:"button",onClick:f,disabled:m,className:"text-[var(--c-accent)] hover:underline",children:"Resend code"}),e.jsx("button",{type:"button",onClick:()=>{s("email"),c(""),i(null)},className:"text-[var(--c-accent)] hover:underline",children:"Use a different email"})]})]})}function Pr({redirectUri:t,codeChallenge:r}){return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Be,{provider:"google",label:"Continue with Google",redirectUri:t,codeChallenge:r,children:e.jsx(Rr,{})}),e.jsx(Be,{provider:"github",label:"Continue with GitHub",redirectUri:t,codeChallenge:r,children:e.jsx(Or,{})})]})}function Be({provider:t,label:r,redirectUri:a,codeChallenge:s,children:n}){return e.jsxs("a",{href:Ir(t,a,s),className:"classic-button--quiet w-full gap-2.5",children:[n,r]})}function Ir(t,r,a){const s=new URLSearchParams;r&&a&&(s.set("redirect_uri",r),s.set("code_challenge",a));const n=tt();n&&s.set("attribution",JSON.stringify({source:n.source,params:n.params,landing:n.landing,ts:n.ts}));const o=s.toString();return`${ye}/ai/auth/oauth/${t}${o?`?${o}`:""}`}function Rr(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",className:"shrink-0",children:[e.jsx("path",{fill:"#4285F4",d:"M17.64 9.2045c0-.6381-.0573-1.2518-.1636-1.8409H9v3.4814h4.8436c-.2086 1.125-.8427 2.0782-1.7959 2.7164v2.2581h2.9086c1.7018-1.5668 2.6837-3.874 2.6837-6.615z"}),e.jsx("path",{fill:"#34A853",d:"M9 18c2.43 0 4.4673-.806 5.9564-2.1805l-2.9086-2.2581c-.8059.54-1.8368.859-3.0478.859-2.344 0-4.3282-1.5832-5.036-3.7105H.9573v2.3318C2.4382 15.9832 5.4818 18 9 18z"}),e.jsx("path",{fill:"#FBBC05",d:"M3.964 10.71c-.18-.54-.2822-1.1168-.2822-1.71s.1023-1.17.2823-1.71V4.9582H.9573C.3477 6.1732 0 7.5477 0 9s.3477 2.8268.9573 4.0418L3.964 10.71z"}),e.jsx("path",{fill:"#EA4335",d:"M9 3.5795c1.3214 0 2.5077.4541 3.4405 1.346l2.5813-2.5814C13.4636.8918 11.426 0 9 0 5.4818 0 2.4382 2.0168.9573 4.9582L3.964 7.29C4.6718 5.1627 6.656 3.5795 9 3.5795z"})]})}function Or(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:"shrink-0",children:e.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}const Br={session_expired:"Your sign-in session expired. Please try again.",link_expired:"That sign-in link expired. Please try again from the editor."};function qr(){const t=X(),[r]=it(),a=r.get("redirect_uri"),s=r.get("code_challenge"),n=r.get("error"),o=a&&s?{redirectUri:a,codeChallenge:s}:null,d=!!o,{loading:c,profile:m}=Y(),[u,g]=l.useState("idle");return l.useEffect(()=>{if(!c){if(!m){g("form");return}if(a&&s){g("completing");let i=!0;return E("/ai/authorize_editor",{method:"POST",body:{redirect_uri:a,code_challenge:s}}).then(f=>{i&&(f.redirect?K(f.redirect):g("form"))}).catch(()=>{i&&g("form")}),()=>{i=!1}}t("/account",{replace:!0})}},[c,m,a,s,t]),u==="completing"?e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-24",children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-[var(--c-text)]",children:"Opening LevelCode…"}),e.jsx("p",{className:"mt-3 text-[14px] pretty",children:"Signing the editor into your account. You can return to LevelCode — this tab can be closed."})]})})}):u!=="form"?e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex min-h-[60vh] max-w-5xl flex-col px-5 py-24"})}):e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-16",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block",children:e.jsx(gt,{})}),e.jsxs("h1",{className:"mt-3 text-[28px] font-bold tracking-tight text-[var(--c-text)]",children:["Sign in to Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsx("p",{className:"mt-2 text-[15px] pretty",children:d?"Connect the editor to your account — you'll be sent back to LevelCode when you're done.":"Manage your plan, keys, and usage."})]}),e.jsxs("div",{className:"mt-8 rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-7",children:[n?e.jsx("div",{role:"alert",className:"mb-5 rounded-[4px] border border-red-500/50 bg-red-500/10 px-4 py-3 text-[13px] text-red-500",children:Br[n]??"Sign-in failed. Please try again."}):null,e.jsx(Pr,{redirectUri:o==null?void 0:o.redirectUri,codeChallenge:o==null?void 0:o.codeChallenge}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-[var(--c-text3)]","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",children:"or"}),e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"})]}),e.jsx(Dr,{redirectUri:o==null?void 0:o.redirectUri,codeChallenge:o==null?void 0:o.codeChallenge})]}),e.jsxs("p",{className:"mt-5 text-center text-[13px] text-[var(--c-text3)]",children:["By continuing you agree to the"," ",e.jsx(C,{to:"/terms",className:"text-[var(--c-accent)] hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx(C,{to:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),". Bring your own key — we never resell provider access."]})]})})})}function Fr({tiers:t,authed:r,currentPlan:a}){const s=X(),[n,o]=l.useState(null),[d,c]=l.useState(null),m=i=>(i??"").trim().toLowerCase(),u=i=>r&&!!a&&m(a)===m(i.name);async function g(i){if(c(null),!r){s("/login");return}o(i.key);try{const f=await E("/ai/checkout",{body:{lookup_key:i.key}});if(f.url){K(f.url);return}if(f.status==="plan_changed"){s("/account?checkout=changed");return}c("Could not start checkout."),o(null)}catch(f){c(f instanceof z?f.message:"Could not start checkout."),o(null)}}return e.jsxs(e.Fragment,{children:[d?e.jsx("p",{className:"mb-4 text-center text-[13px] text-red-500",role:"alert",children:d}):null,e.jsx("div",{className:"grid gap-5 sm:grid-cols-2 lg:grid-cols-4",children:t.map((i,f)=>{const v=f===1,w=u(i);return e.jsxs("div",{className:`flex flex-col rounded-md border bg-[var(--c-bg)] p-6 ${w||v?"border-[var(--c-accent)]":"border-[var(--c-line)]"} ${w?"shadow-[0_0_0_1px_var(--c-accent)]":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--c-text)]",children:i.name}),w?e.jsx("span",{className:"rounded-[3px] bg-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-white",children:"current"}):v?e.jsx("span",{className:"rounded-[3px] border border-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-[var(--c-accent)]",children:"popular"}):null]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-bold tracking-tight text-[var(--c-text)]",children:Ur(i.price_cents)}),e.jsxs("span",{className:"text-sm text-[var(--c-text3)]",children:["/",i.interval||"mo"]})]}),e.jsxs("dl",{className:"mt-5 space-y-1.5 font-mono text-[12px] text-[var(--c-text2)]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"input"}),e.jsx("dd",{className:"tabular-nums",children:qe(i.input_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"output"}),e.jsx("dd",{className:"tabular-nums",children:qe(i.output_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"turns"}),e.jsx("dd",{className:"tabular-nums",children:(i.turns??0).toLocaleString()})]})]}),e.jsx("ul",{className:"mt-5 flex-1 space-y-2 text-[13px] text-[var(--c-text2)]",children:(i.features??[]).map(y=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"mt-1.5 h-1 w-1 flex-none rounded-full bg-[var(--c-accent)]"}),e.jsx("span",{className:"pretty",children:y})]},y))}),w?e.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"classic-button--quiet mt-6 w-full cursor-default opacity-70",children:"✓ Current plan"}):e.jsx("button",{onClick:()=>g(i),disabled:n===i.key,className:`mt-6 w-full ${v?"classic-button":"classic-button--quiet"}`,children:n===i.key?"Starting…":r?"Choose plan":"Sign in to start"})]},i.key)})})]})}function Ur(t){const r=t/100;return`$${r%1===0?r.toFixed(0):r.toFixed(2)}`}function qe(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString()}function Hr(){const{profile:t}=Y(),[r,a]=l.useState([]),[s,n]=l.useState(null);return l.useEffect(()=>{let o=!0;return E("/api/levelcode/v1/pricing").then(d=>{o&&a(d.tiers??[])}).catch(()=>{o&&n("Pricing is temporarily unavailable. Please try again shortly.")}),()=>{o=!1}},[]),e.jsxs(D,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:"Plans that scale as you ship"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl pretty",children:"Every plan is bring-your-own-key by default — free, forever. Switch on the gateway and your monthly credit is all you pay; we never mark up the provider."})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12",children:[s?e.jsx("div",{className:"rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center text-[15px]",children:s}):e.jsx(Fr,{tiers:r,authed:!!t,currentPlan:(t==null?void 0:t.plan)??null}),e.jsx("p",{className:"mt-10 text-center text-[13px] text-[var(--c-text3)]",children:"All plans include the full editor — it’s free and open source. Plans meter the managed AI gateway only."})]})})]})}function rt({title:t,updated:r,intro:a,children:s}){return e.jsxs(D,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-3xl px-5 py-10 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:t}),e.jsxs("p",{className:"mt-2 text-[13px] text-[var(--c-text3)]",children:["Last updated: ",r]})]})}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-12",children:[e.jsx("p",{className:"text-[16px] leading-relaxed pretty",children:a}),e.jsx("div",{className:"mt-10 space-y-9",children:s})]})]})}function _({id:t,heading:r,children:a}){return e.jsxs("section",{id:t,className:"scroll-mt-24",children:[e.jsx("h2",{className:"text-xl font-semibold tracking-tight text-[var(--c-text)]",children:r}),e.jsx("div",{className:"mt-3 space-y-3 text-[15px] leading-relaxed pretty",children:a})]})}function Wr(){return e.jsxs(rt,{title:"Privacy Policy",updated:"July 9, 2026",intro:e.jsx(e.Fragment,{children:"This policy explains what LevelCode collects, how we use it, and who we share it with when you use the LevelCode editor and LevelCode Cloud (levelcode.ai). The most important thing to know: to generate AI responses, we send your prompts and selected code to third-party model providers."}),children:[e.jsxs(_,{id:"collect",heading:"1. What we collect",children:[e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Account"})," — your email and basic profile, and the authentication tokens the editor uses to talk to the service."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Prompts & code"})," — the prompts and code you submit to the AI gateway, so we can generate responses and meter usage."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Usage & billing"})," — model used, token counts, timestamps, plan, and spend, used to meter your allowance and support billing. Payments are handled by Stripe; we do not receive or store your full card number."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Technical"})," — IP address, device/browser info, and server logs, used for security and to operate the Service."]})]}),e.jsx("p",{children:"Product telemetry in the editor is off by default. If you use bring-your-own-key (BYOK), those requests go directly to your provider and your prompts and code do not pass through our gateway."})]}),e.jsx(_,{id:"use",heading:"2. How we use it",children:e.jsx("p",{children:"To provide, secure, and improve the Service — including generating AI responses, metering your usage against your plan, processing subscriptions, providing support, preventing abuse, and meeting legal obligations. We do not sell your personal information, and we do not use the content of your prompts or code to advertise to you."})}),e.jsxs(_,{id:"share",heading:"3. Who we share it with",children:[e.jsx("p",{children:"We share information only with service providers that help us run LevelCode:"}),e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"AI model providers & routing"})," — your prompts and selected code are sent to the AI provider(s) that generate your response, via our routing partner. They process this content to return a result and under their own terms and privacy policies."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Payments"})," — Stripe, to process subscriptions and payments."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Hosting & infrastructure"})," — our cloud hosting provider, which stores and serves the Service on our behalf."]})]}),e.jsx("p",{children:"We may also disclose information if required by law, to enforce our terms, or to protect the rights, safety, and security of LevelCode and its users. If we’re involved in a merger or acquisition, your information may transfer as part of that transaction."})]}),e.jsx(_,{id:"retention",heading:"4. Retention",children:e.jsxs("p",{children:["We keep account and billing records for as long as your account is active and as needed to meet legal, tax, and security obligations. Prompts, code, and usage records are retained only as long as needed to operate the Service and support your account, after which they are deleted or anonymized."," "]})}),e.jsx(_,{id:"cookies",heading:"5. Cookies",children:e.jsx("p",{children:"We use strictly necessary cookies to keep you signed in and to operate the site. We do not use third-party advertising cookies. Your browser settings let you control cookies, though the Service may not work properly without the essential ones."})}),e.jsx(_,{id:"security",heading:"6. Security",children:e.jsx("p",{children:"We use technical and organizational measures — including encryption in transit and access controls — to protect your information. No method of transmission or storage is perfectly secure, so we cannot guarantee absolute security."})}),e.jsx(_,{id:"rights",heading:"7. Your rights",children:e.jsx("p",{children:"Depending on where you live (for example, under GDPR or the CCPA), you may have the right to access, correct, delete, or export your personal information, and to object to or restrict certain processing. To make a request, email us at the address below; we will respond as required by applicable law."})}),e.jsx(_,{id:"children",heading:"8. Children",children:e.jsx("p",{children:"The Service is not directed to children under 13, and we do not knowingly collect their personal information. If you believe a child has provided us information, contact us and we will delete it."})}),e.jsx(_,{id:"international",heading:"9. International transfers",children:e.jsx("p",{children:"We and our providers may process your information in countries other than yours. Where required, we rely on appropriate safeguards for such transfers."})}),e.jsx(_,{id:"changes",heading:"10. Changes",children:e.jsx("p",{children:"We may update this policy from time to time. Material changes will be reflected in the date above and, where appropriate, communicated to you."})}),e.jsx(_,{id:"contact",heading:"11. Contact",children:e.jsxs("p",{children:["Privacy questions or requests? Email"," ",e.jsx("a",{href:"mailto:privacy@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"privacy@levelcode.ai"}),"."]})})]})}function at(t){const r=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${r}-${a}`}function Fe(t){const r=new Date;return r.setDate(r.getDate()-t),at(r)}const se=()=>at(new Date),Ue=/^\d{4}-\d{2}-\d{2}$/;function Yr(t,r){return!Ue.test(t)||!Ue.test(r)?"Pick both a start and an end date.":t>r?"The start date is after the end date.":r>se()?"The end date is in the future.":null}function Vr(){const t=X(),{loading:r,profile:a}=Y(),[s,n]=l.useState(()=>Fe(29)),[o,d]=l.useState(se),[c,m]=l.useState(null),[u,g]=l.useState(null),[i,f]=l.useState(!0),v=(a==null?void 0:a.role)==="admin";l.useEffect(()=>{r||(a?v||t("/account",{replace:!0}):t("/login",{replace:!0}))},[r,a,v,t]);const w=Yr(s,o);if(l.useEffect(()=>{if(!v)return;if(w){f(!1);return}let x=!0;f(!0),g(null);const p=new URLSearchParams({from:s,to:o});return E(`/api/levelcode/v1/admin/referrals?${p.toString()}`).then(b=>{x&&(m(b),f(!1))}).catch(()=>{x&&(m(null),g("Couldn’t load the referral funnel."),f(!1))}),()=>{x=!1}},[v,s,o,w]),r||!v)return e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-5xl px-5 py-12"})});const y=(c==null?void 0:c.rows)??[];return e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-5xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"Referrals"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"clicks · signups · paid, per marketing channel"})]}),e.jsx(C,{to:"/admin",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"← System dashboard"})]}),u?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:u}):null,w?e.jsxs("div",{role:"alert",className:"mt-8 rounded-md border border-[#d19a66]/40 bg-[#d19a66]/[0.1] px-4 py-3 text-[14px] text-[var(--c-text)]",children:[w,c?" Showing the last loaded range below.":null]}):null,e.jsxs("div",{className:"mt-8 flex flex-wrap items-center gap-3",children:[e.jsx(He,{label:"from",value:s,max:o,onChange:n}),e.jsx(He,{label:"to",value:o,min:s,max:se(),onChange:d}),e.jsx("div",{className:"flex gap-2",children:[{label:"7d",days:6},{label:"30d",days:29},{label:"90d",days:89}].map(x=>e.jsx("button",{type:"button",onClick:()=>{n(Fe(x.days)),d(se())},className:"rounded-md border border-[var(--c-line)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:x.label},x.label))})]}),e.jsxs("div",{className:"mt-6 grid gap-4 sm:grid-cols-3",children:[e.jsx(ge,{label:"clicks",value:c==null?void 0:c.totals.clicks}),e.jsx(ge,{label:"signups",value:c==null?void 0:c.totals.signups}),e.jsx(ge,{label:"paid",value:c==null?void 0:c.totals.paid})]}),c?e.jsxs("p",{className:"mt-3 font-mono text-[12px] text-[var(--c-text3)]",children:["covering ",c.from," → ",c.to]}):null,e.jsx("div",{className:"classic-card mt-6 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[620px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"px-3 py-2 font-normal",children:"channel"}),e.jsx("th",{className:"px-3 py-2 font-normal",children:"handle"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"clicks"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"signups"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"paid"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"click → signup"})]})}),e.jsxs("tbody",{children:[y.map(x=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-b-0 hover:bg-[var(--c-surface)]",children:[e.jsx("td",{className:"px-3 py-2 text-[var(--c-text)]",children:x.channel}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:x.handle??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:x.clicks}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text)]",children:x.signups}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:x.paid}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text3)]",children:x.clicks>0?`${(x.signups/x.clicks*100).toFixed(1)}%`:"—"})]},`${x.channel}-${x.handle??""}`)),c&&y.length===0&&!i?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-[var(--c-text3)]",children:"No referral activity in this range."})}):null]})]})}),e.jsxs("div",{className:"mt-4 space-y-1.5 text-[12px] leading-relaxed text-[var(--c-text3)]",children:[c?e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:c.unattributed_signups})," ","signup",c.unattributed_signups===1?"":"s"," in this range carried no channel — organic, or the visitor’s browser dropped the stored attribution. They are not in the table."]}):null,e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"paid"})," counts people who signed up in this range and are on a paid plan ",e.jsx("em",{children:"right now"})," — there is no “became paid” timestamp to measure conversions inside the range."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"clicks"})," are matched to a channel through the short link’s current destination and exclude bots. Editing a link’s destination re-attributes its past clicks."]}),e.jsx("p",{children:"Clicks and signups are counted independently and joined only by channel name, so click → signup is a ratio between two populations, not a tracked journey."})]})]})})}function He({label:t,value:r,min:a,max:s,onChange:n}){return e.jsxs("label",{className:"flex items-center gap-2 font-mono text-[12px] text-[var(--c-text3)]",children:[t,e.jsx("input",{type:"date",value:r,min:a,max:s,onChange:o=>n(o.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)]"})]})}function ge({label:t,value:r}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("p",{className:"classic-label",children:t}),e.jsx("p",{className:"mt-1 text-[26px] font-bold tabular-nums text-[var(--c-text)]",children:r===void 0?"—":r.toLocaleString("en-US")})]})}function Zr(){return e.jsxs(rt,{title:"Terms of Service",updated:"July 9, 2026",intro:e.jsxs(e.Fragment,{children:["These Terms govern your use of LevelCode — the LevelCode editor and the LevelCode Cloud service at levelcode.ai (together, the “Service”). By creating an account or using the Service, you agree to these Terms and to our"," ",e.jsx("a",{href:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),"."]}),children:[e.jsx(_,{heading:"1. The Service",children:e.jsx("p",{children:"LevelCode is an AI-native code editor and a metered AI gateway. On a paid plan or the free tier, the editor sends your prompts and selected code to our gateway, which routes them to third-party AI model providers to generate responses. You may also use your own provider API key (“bring-your-own-key” / BYOK); in that mode requests go directly to your provider and do not run through our gateway or metering."})}),e.jsx(_,{heading:"2. Eligibility & accounts",children:e.jsx("p",{children:"You must be at least 13 years old (and, if under the age of majority where you live, have your parent or guardian’s consent) to use the Service. You are responsible for your account and for keeping your credentials and API keys secure. Notify us promptly of any unauthorized use."})}),e.jsxs(_,{heading:"3. Plans, billing & usage limits",children:[e.jsx("p",{children:"Paid plans are subscriptions billed in advance through our payment processor (Stripe) and renew automatically each period until canceled. You can cancel anytime; cancellation takes effect at the end of the current billing period, and, except where required by law, payments are non-refundable."}),e.jsx("p",{children:"Each plan includes a monthly usage allowance, expressed as approximate model “turns.” To keep the Service reliable, that allowance is metered and may be made available progressively over the billing cycle rather than all at once (rolling usage windows) — heavy use may be paced or, on some plans, temporarily served by a lighter model until more of your allowance becomes available or the period renews. We show your current usage and when more becomes available in your account. We may change plans, prices, allowances, or limits prospectively, with notice for existing subscribers."})]}),e.jsxs(_,{heading:"4. Your content and code",children:[e.jsx("p",{children:"You retain all rights to the code, prompts, and other content you submit (“Your Content”). You grant us a limited license to process, transmit, and store Your Content solely to operate and improve the Service — including sending it to the AI model providers needed to generate responses. We do not claim ownership of Your Content or of the outputs generated for you."}),e.jsx("p",{children:"You are responsible for having the rights to submit Your Content and for ensuring your use complies with any licenses that apply to code you work on."})]}),e.jsx(_,{heading:"5. AI output — no warranty",children:e.jsx("p",{children:"AI-generated code and text may be inaccurate, insecure, or unsuitable for your purpose, and similar outputs may be generated for other users. You are responsible for reviewing, testing, and deciding whether to use any output. The Service is not a substitute for professional judgment, and outputs are not legal, financial, security, or other professional advice."})}),e.jsxs(_,{heading:"6. Acceptable use",children:[e.jsx("p",{children:"You agree not to use the Service to:"}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5",children:[e.jsx("li",{children:"break the law or infringe others’ rights;"}),e.jsx("li",{children:"generate malware, or content intended to harm, harass, defraud, or deceive;"}),e.jsx("li",{children:"abuse, overload, reverse-engineer, or circumvent the gateway, metering, or usage limits;"}),e.jsx("li",{children:"resell or provide the Service to third parties except as expressly permitted; or"}),e.jsx("li",{children:"violate the terms of the underlying AI providers or other third-party services."})]})]}),e.jsx(_,{heading:"7. Third-party services",children:e.jsx("p",{children:"The Service relies on third parties — including the AI model providers and routing partner behind our gateway, our payment processor, and our hosting provider. Your use of the Service through these providers is also subject to their terms, and we are not responsible for their acts or omissions."})}),e.jsx(_,{heading:"8. Intellectual property & open source",children:e.jsx("p",{children:"The LevelCode name, site, and service are owned by us or our licensors. The editor is built on open-source software, which remains governed by its own licenses; nothing here restricts your rights under those licenses. Except for those open-source components and Your Content, you may not copy, modify, or create derivative works of the Service without permission."})}),e.jsx(_,{heading:"9. Disclaimers & limitation of liability",children:e.jsx("p",{children:"The Service is provided “as is” and “as available,” without warranties of any kind to the fullest extent permitted by law. To the extent permitted by law, we are not liable for indirect, incidental, or consequential damages, and our total liability for any claim relating to the Service will not exceed the amount you paid us for the Service in the twelve months before the claim."})}),e.jsx(_,{heading:"10. Termination",children:e.jsx("p",{children:"You may stop using the Service at any time. We may suspend or terminate access if you violate these Terms or to protect the Service or other users. Sections that by their nature should survive termination (for example, ownership, disclaimers, and limitations of liability) will survive."})}),e.jsx(_,{heading:"11. Changes to these Terms",children:e.jsx("p",{children:"We may update these Terms from time to time. If we make material changes we will update the date above and, where appropriate, notify you. Your continued use of the Service after changes take effect means you accept the updated Terms."})}),e.jsx(_,{heading:"12. Governing law",children:e.jsx("p",{children:"These Terms are governed by the laws of [governing-law jurisdiction], without regard to conflict-of-laws rules, and any disputes will be resolved in the courts located there. "})}),e.jsx(_,{heading:"13. Contact",children:e.jsxs("p",{children:["Questions about these Terms? Email"," ",e.jsx("a",{href:"mailto:legal@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"legal@levelcode.ai"}),"."]})})]})}function Gr(){return e.jsxs(ct,{children:[e.jsx(P,{path:"/",element:e.jsx(Re,{})}),e.jsx(P,{path:"/login",element:e.jsx(qr,{})}),e.jsx(P,{path:"/pricing",element:e.jsx(Hr,{})}),e.jsx(P,{path:"/account",element:e.jsx(_t,{})}),e.jsx(P,{path:"/admin",element:e.jsx(At,{})}),e.jsx(P,{path:"/admin/referrals",element:e.jsx(Vr,{})}),e.jsx(P,{path:"/terms",element:e.jsx(Zr,{})}),e.jsx(P,{path:"/privacy",element:e.jsx(Wr,{})}),e.jsx(P,{path:"/download",element:e.jsx(gr,{})}),e.jsx(P,{path:"/docs",element:e.jsx(ze,{})}),e.jsx(P,{path:"/docs/:slug",element:e.jsx(zr,{})}),e.jsx(P,{path:"*",element:e.jsx(Re,{})})]})}function zr(){const{slug:t}=dt();return e.jsx(ze,{slug:t})}$r();xt(document.getElementById("root")).render(e.jsx(l.StrictMode,{children:e.jsx(ut,{basename:"/ai",children:e.jsx(Gr,{})})}));export{$t as u}; diff --git a/app/assets/interface/levelcode-DGHAu_R4.js b/app/assets/interface/levelcode-DGHAu_R4.js new file mode 100644 index 00000000..62bb2407 --- /dev/null +++ b/app/assets/interface/levelcode-DGHAu_R4.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bundle-HSVNZER1.js","assets/preload-helper-CAFW0lxO.js"])))=>i.map(i=>d[i]); +var lt=Object.defineProperty;var ot=(t,r,s)=>r in t?lt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var ie=(t,r,s)=>ot(t,typeof r!="symbol"?r+"":r,s);import{r as l,j as e,L as C,u as X,R as ne,b as J,_ as it,d as ct,e as dt,f as P,c as xt,g as ut,B as ht}from"./preload-helper-CAFW0lxO.js";const mt=typeof window<"u"&&window.__ENV__||{},ye=String(mt.API_BASE??"").replace(/\/+$/,"");let ce=null;async function pt(){const t=typeof document<"u"?document.querySelector('meta[name="csrf-token"]'):null,r=t==null?void 0:t.getAttribute("content");return r||(ce||(ce=fetch(`${ye}/ai/csrf`,{credentials:"include"}).then(s=>s.ok?s.json():{token:""}).then(s=>s.token??"").catch(()=>"")),ce)}class z extends Error{constructor(s,a,n){super(a);ie(this,"status");ie(this,"code");this.name="ApiError",this.status=s,this.code=n}}async function E(t,r={}){const s=r.method??(r.body!==void 0?"POST":"GET"),a={Accept:"application/json",...r.headers};r.body!==void 0&&(a["Content-Type"]="application/json"),s!=="GET"&&s!=="HEAD"&&(a["X-CSRF-Token"]=await pt());const n=await fetch(`${ye}${t}`,{method:s,headers:a,credentials:"include",body:r.body!==void 0?JSON.stringify(r.body):void 0}),o=await n.text();let d=null;if(o)try{d=JSON.parse(o)}catch{d=null}if(!n.ok){const c=d==null?void 0:d.error;throw new z(n.status,(c==null?void 0:c.message)??`Request failed (${n.status})`,c==null?void 0:c.code)}return d}function K(t){window.location.href=t}function U(){const[t,r]=l.useState({loading:!0,profile:null});return l.useEffect(()=>{let s=!0;return E("/api/levelcode/v1/account/profile").then(a=>{s&&r({loading:!1,profile:a})}).catch(()=>{s&&r({loading:!1,profile:null})}),()=>{s=!1}},[]),t}function We(t,r){const s=(t||r||"").trim();if(!s)return"··";const a=s.split(/[\s@._-]+/).filter(Boolean);return a.length>=2?(a[0][0]+a[1][0]).toUpperCase():s.slice(0,2).toUpperCase()}const ae="https://github.com/levelcodeai/levelcode";function ft(){try{const t=localStorage.getItem("lc-theme");return t==="dark"||t==="light"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch{return"light"}}function D({children:t,strip:r=!1}){const[s,a]=l.useState(ft),n=()=>a(o=>{const d=o==="light"?"dark":"light";try{localStorage.setItem("lc-theme",d)}catch{}return d});return e.jsxs("div",{className:`classic ${s==="dark"?"classic--dark":""} flex min-h-screen flex-col bg-[var(--c-bg)] text-[16px] leading-relaxed text-[var(--c-text2)]`,children:[e.jsx(gt,{theme:s,onToggleTheme:n}),r?e.jsxs("p",{className:"border-b border-[var(--c-line)] bg-[var(--c-strip)] px-5 py-2 text-center text-[13px] text-[var(--c-text)]",children:["Atom was sunset on December 15, 2022."," ",e.jsx("a",{href:`${ae}#readme`,className:"font-medium text-[var(--c-accent)] hover:underline",children:"LevelCode carries the hackable spirit forward →"})]}):null,e.jsx("div",{className:"flex-1",children:t}),e.jsx("footer",{className:"bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex max-w-5xl flex-col items-center justify-between gap-4 px-5 py-8 text-[14px] sm:flex-row",children:[e.jsxs("ul",{className:"flex flex-wrap items-center justify-center gap-x-5 gap-y-2",children:[e.jsx("li",{children:e.jsx(C,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/terms",children:"Terms of Service"})}),e.jsx("li",{children:e.jsx(C,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/privacy",children:"Privacy"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${ae}/releases`,children:"Releases"})}),e.jsx("li",{children:e.jsx("a",{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",href:`${ae}/discussions`,children:"Discussions"})}),e.jsx("li",{children:e.jsx(C,{className:"text-[var(--c-text2)] hover:text-[var(--c-text)]",to:"/pricing",children:"Pricing"})})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[var(--c-text3)]",children:[e.jsx(bt,{})," with ",e.jsx(jt,{})," by LevelCode"]})]})})]})}function gt({theme:t,onToggleTheme:r}){const{profile:s}=U();return e.jsx("nav",{"aria-label":"Primary",className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto flex h-12 max-w-5xl items-center justify-between px-5",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs(C,{to:"/",className:"text-[15px] font-bold text-[var(--c-text)]",children:["Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsxs("ul",{className:"hidden items-center gap-5 sm:flex",children:[e.jsx("li",{children:e.jsx(C,{to:"/docs",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Documentation"})}),e.jsx("li",{children:e.jsx("a",{href:"https://open-vsx.org/",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Packages"})}),e.jsx("li",{children:e.jsx("a",{href:`${ae}/releases`,className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Releases"})}),e.jsx("li",{children:e.jsx(C,{to:"/pricing",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Pricing"})})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{type:"button",onClick:r,"aria-label":t==="light"?"Switch to dark mode":"Switch to light mode",title:t==="light"?"Dark mode (One Dark)":"Light mode",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:t==="light"?e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M13.3 9.9A5.6 5.6 0 0 1 6.1 2.7a.4.4 0 0 0-.5-.5 6.4 6.4 0 1 0 8.2 8.2.4.4 0 0 0-.5-.5z"})}):e.jsxs("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("circle",{cx:"8",cy:"8",r:"3.2"}),e.jsx("path",{d:"M8 1.2v1.8M8 13v1.8M1.2 8H3M13 8h1.8M3.2 3.2l1.3 1.3M11.5 11.5l1.3 1.3M12.8 3.2l-1.3 1.3M4.5 11.5l-1.3 1.3"})]})}),s?e.jsx(C,{to:"/account",title:"Account","aria-label":"Account",className:"flex h-8 w-8 items-center justify-center rounded-full border border-[var(--c-line)] bg-[var(--c-bg)] text-[12px] font-semibold text-[var(--c-text)] hover:border-[var(--c-accent)]",children:We(s.name,s.email)}):e.jsxs(C,{to:"/login",className:"flex items-center gap-1.5 text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M10 3.75a.75.75 0 0 1 .75-.75h2.5A1.75 1.75 0 0 1 15 4.75v6.5A1.75 1.75 0 0 1 13.25 13h-2.5a.75.75 0 0 1 0-1.5h2.5a.25.25 0 0 0 .25-.25v-6.5a.25.25 0 0 0-.25-.25h-2.5a.75.75 0 0 1-.75-.75Zm-3.28.72a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H1.75a.75.75 0 0 1 0-1.5h6.69L6.72 5.53a.75.75 0 0 1 0-1.06Z"})}),"Sign in"]})]})]})})}function vt({size:t=56}){return e.jsx("svg",{viewBox:"0 0 120 120",width:t,height:t,"aria-hidden":!0,children:e.jsxs("g",{fill:"none",stroke:"var(--c-accent)",strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:"0.4"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:"0.7"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})})}function bt(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"m5.5 4.5-3.5 3.5 3.5 3.5M10.5 4.5 14 8l-3.5 3.5"})})}function jt(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"var(--c-accent)","aria-hidden":!0,children:e.jsx("path",{d:"m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002Z"})})}const yt=1e4,Q="en-US";function we(t){return(t??0)/yt}function wt(t){const r=we(t);return(r>0?Math.round(r):0).toLocaleString(Q)}function ve(t){const r=we(t);return r>0?r>=10?Math.round(r).toLocaleString(Q):r<.05?"<0.1":r.toFixed(1):"0"}function be(t){return(t??0).toLocaleString(Q)}const Nt=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ke=["bg-[var(--c-line)]","bg-flame/25","bg-flame/50","bg-flame/75","bg-[var(--c-accent)]"];function kt(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}`}function Ct(t){return t<=0?0:t<=2?1:t<=6?2:t<=14?3:4}function V(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:be(t)}function de(t){const[r,s,a]=t.split("-").map(Number);return new Date(Date.UTC(r,s-1,a)).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function St({activity:t,year:r,years:s,onYear:a}){const[n,o]=l.useState(null),d=(t==null?void 0:t.days)??{},{weeks:c,monthCols:p}=l.useMemo(()=>{var S;const i=new Date(Date.UTC(r,0,1)),f=new Date(i);f.setUTCDate(i.getUTCDate()-i.getUTCDay());const v=new Date(Date.UTC(r,11,31)),w=new Date(v);w.setUTCDate(v.getUTCDate()+(6-v.getUTCDay()));const y=[],x=[],m=new Date(f);let b=-1;for(;m<=w;){const h=[];let T=null;for(let A=0;A<7;A++){const q=m.getUTCFullYear()===r;if(A===0&&(T=q?m.getUTCMonth():null),q){const ee=kt(m);h.push({key:ee,count:((S=d[ee])==null?void 0:S.count)??0,date:new Date(m)})}else h.push({key:null,count:0,date:null});m.setUTCDate(m.getUTCDate()+1)}T!=null&&T!==b?(x.push(Nt[T]),b=T):x.push(null),y.push(h)}return{weeks:y,monthCols:x}},[r,d]),u=n?d[n]??null:null,g=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"activity"}),e.jsxs("div",{className:"mt-1 text-lg font-semibold tracking-tight text-[var(--c-text)]",children:[be((t==null?void 0:t.total)??0)," request",((t==null?void 0:t.total)??0)===1?"":"s"," in ",r]})]}),s.length>1?e.jsx("div",{className:"flex flex-wrap gap-1",children:s.map(i=>e.jsx("button",{type:"button",onClick:()=>{o(null),a(i)},className:`rounded-md px-2.5 py-1 font-mono text-[12px] transition-colors ${i===r?"bg-[var(--c-accent)] text-white":"text-[var(--c-text2)] hover:bg-[var(--c-line)]"}`,children:i},i))}):null]}),e.jsx("div",{className:"mt-5 overflow-x-auto",children:e.jsxs("div",{className:"inline-flex flex-col gap-1",children:[e.jsx("div",{className:"flex gap-[3px] pl-8",children:p.map((i,f)=>e.jsx("div",{className:"w-[11px] font-mono text-[10px] text-[var(--c-text3)]",children:i?e.jsx("span",{className:"relative -left-[1px] whitespace-nowrap",children:i}):null},f))}),e.jsxs("div",{className:"flex gap-[3px]",children:[e.jsx("div",{className:"mr-1 flex w-7 flex-col gap-[3px]",children:["","Mon","","Wed","","Fri",""].map((i,f)=>e.jsx("div",{className:"h-[11px] font-mono text-[9px] leading-[11px] text-[var(--c-text3)]",children:i},f))}),c.map((i,f)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:i.map((v,w)=>{var S,h;if(!v.key)return e.jsx("div",{className:"h-[11px] w-[11px]"},w);const y=Ct(v.count),x=n===v.key,m=(h=(S=d[v.key])==null?void 0:S.models)==null?void 0:h[0],b=v.count>0?`${de(v.key)} · ${v.count} request${v.count===1?"":"s"}${m?` · ${xe(m.model)} ${m.count}`:""}`:`${de(v.key)} · no activity`;return e.jsx("button",{type:"button",title:b,onClick:()=>o(x?null:v.key),className:`h-[11px] w-[11px] rounded-[2px] ${ke[y]} ${x?"ring-1 ring-ink ring-offset-1":""} transition-colors hover:ring-1 hover:ring-ink/40`},w)})},f))]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 pl-8 font-mono text-[10px] text-[var(--c-text3)]",children:[e.jsx("span",{className:"mr-1",children:"Less"}),ke.map((i,f)=>e.jsx("span",{className:`h-[11px] w-[11px] rounded-[2px] ${i}`},f)),e.jsx("span",{className:"ml-1",children:"More"})]})]})}),n&&u?e.jsxs("div",{className:"mt-6 rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"font-mono text-[12px] text-[var(--c-text2)]",children:de(n)}),e.jsxs("div",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[u.count," req · ",V(u.input)," in · ",V(u.output)," out ·"," ",ve(u.cost_micros)," credits"]})]}),e.jsx("ul",{className:"mt-3 space-y-1.5",children:u.models.map(i=>e.jsxs("li",{className:"flex items-center justify-between gap-3 font-mono text-[12px]",children:[e.jsx("span",{className:"truncate text-[var(--c-text)]",children:xe(i.model)}),e.jsxs("span",{className:"whitespace-nowrap text-[var(--c-text3)]",children:[i.count," · ",V(i.input+i.output)," tok"]})]},i.model))})]}):e.jsx("p",{className:"mt-4 font-mono text-[11px] text-[var(--c-text3)]",children:"Click a day to see its per-model breakdown."}),g.length?e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"classic-label mb-3",children:["by model · ",r]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[520px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"requests"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"input"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"output"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"reactions"})]})}),e.jsx("tbody",{children:g.map(i=>e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:xe(i.model)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:be(i.count)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:V(i.input)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:V(i.output)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:ve(i.cost_micros)}),e.jsx("td",{className:"py-1.5 pl-3 text-right tabular-nums text-[var(--c-text3)]",children:e.jsxs("span",{className:"inline-flex items-center justify-end gap-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Lt,{className:"text-[var(--c-text2)]"})," ",i.up]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(_t,{className:"text-[var(--c-text2)]"})," ",i.down]})]})})]},i.model))})]})})]}):null]})}function xe(t){const r=t||"unknown",s=r.indexOf("/");return s>=0?r.slice(s+1):r}function Lt({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M12.999 6.00002H10.672L11.207 4.21802C11.278 3.98102 11.314 3.73902 11.314 3.49602C11.314 2.12002 10.192 0.999023 8.81298 0.999023C8.42998 0.999023 8.08498 1.21202 7.91398 1.55402L5.82998 5.72202C5.74498 5.89202 5.57398 5.99802 5.38298 5.99802H3.00098C1.89798 5.99802 1.00098 6.89502 1.00098 7.99802V12.998C1.00098 14.101 1.89798 14.998 3.00098 14.998H11.163C12.727 14.998 13.283 13.796 13.565 12.893L14.908 8.59602C14.969 8.40102 15 8.19902 15 7.99602C15 6.89402 14.103 5.99802 12.999 5.99802V6.00002ZM1.99998 13V8.00002C1.99998 7.44902 2.44898 7.00002 2.99998 7.00002H3.99998V14H2.99998C2.44898 14 1.99998 13.551 1.99998 13ZM13.954 8.29802L12.611 12.596C12.247 13.761 11.769 13.999 11.163 13.999H5.00098V6.99902H5.38298C5.95498 6.99902 6.46898 6.68102 6.72498 6.17002L8.80898 2.00202C8.80898 2.00202 8.81098 2.00002 8.81298 2.00002C9.64098 2.00002 10.314 2.67102 10.314 3.49702C10.314 3.64202 10.292 3.78802 10.249 3.93202L9.52098 6.35702C9.47598 6.50802 9.50398 6.67202 9.59898 6.79902C9.69398 6.92602 9.84198 7.00102 9.99998 7.00102H12.999C13.551 7.00102 14 7.44802 14 7.99902C14 8.10002 13.984 8.20102 13.954 8.30002V8.29802Z"})})}function _t({className:t=""}){return e.jsx("svg",{viewBox:"0 0 16 16",width:"13",height:"13",fill:"currentColor","aria-hidden":"true",className:t,children:e.jsx("path",{d:"M13 1H4.838C3.274 1 2.717 2.202 2.435 3.105L1.092 7.404C1.031 7.6 1 7.801 1 8.002C1 9.104 1.897 10 3.001 10H5.328L4.794 11.781C4.723 12.016 4.687 12.26 4.687 12.504C4.687 13.88 5.809 15.001 7.189 15.001C7.571 15.001 7.915 14.789 8.087 14.446L10.171 10.277C10.256 10.107 10.427 10.001 10.618 10.001H13C14.103 10.001 15 9.104 15 8.001V3C15 1.897 14.103 1 13 1ZM9.276 9.829L7.193 13.996L7.188 13.999C6.36 13.999 5.686 13.328 5.686 12.502C5.686 12.356 5.707 12.21 5.75 12.067L6.478 9.642C6.524 9.491 6.495 9.327 6.401 9.2C6.306 9.073 6.158 8.998 6 8.998H3.001C2.449 8.998 2 8.551 2 8C2 7.9 2.016 7.799 2.047 7.699L3.39 3.401C3.753 2.236 4.232 1.998 4.838 1.998H11V8.998H10.618C10.046 8.998 9.531 9.316 9.276 9.827V9.829ZM14 8C14 8.551 13.552 9 13 9H12V2H13C13.552 2 14 2.449 14 3V8Z"})})}function Tt(){const t=X(),{loading:r,profile:s}=U(),[a,n]=l.useState(null),[o,d]=l.useState(null),[c,p]=l.useState(null),[u,g]=l.useState(new Date().getFullYear()),[i,f]=l.useState(null);l.useEffect(()=>{!r&&!s&&t("/login",{replace:!0})},[r,s,t]),l.useEffect(()=>{if(!s)return;let m=!0;return E("/api/levelcode/v1/account/usage").then(b=>{m&&n(b)}).catch(()=>{m&&f("We couldn’t load your usage right now. Please try again shortly.")}),()=>{m=!1}},[s]),l.useEffect(()=>{if(!s)return;let m=!0;return E("/api/levelcode/v1/account/models").then(b=>{m&&d(b)}).catch(()=>{}),()=>{m=!1}},[s]),l.useEffect(()=>{if(!s)return;let m=!0;return E(`/api/levelcode/v1/account/activity?year=${u}`).then(b=>{m&&p(b)}).catch(()=>{}),()=>{m=!1}},[s,u]);async function v(){try{const m=await E("/ai/billing",{method:"POST"});m.url&&K(m.url)}catch{f("Could not open billing. Please try again.")}}async function w(){try{await E("/ai/signout",{method:"POST"})}catch{}t("/login",{replace:!0})}if(r||!s)return e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-4xl px-5 py-12"})});const y=a?Se(a.input_used,a.input_cap):0,x=a?Se(a.output_used,a.output_cap):0;return e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-4xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:s.name?`Hi, ${s.name}`:"Your account"}),s.email?e.jsx("p",{className:"mt-2 font-mono text-[13px] text-[var(--c-text3)]",children:s.email}):null]}),e.jsxs("span",{className:"flex flex-wrap items-center gap-4",children:[s.role==="admin"?e.jsxs(e.Fragment,{children:[e.jsx(C,{to:"/admin",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"System dashboard →"}),e.jsx(C,{to:"/admin/referrals",className:"text-[13px] text-[var(--c-accent)] hover:underline",children:"Referrals →"})]}):null,e.jsxs("span",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-2.5 py-1 font-mono text-[12px] text-[var(--c-text2)]",children:["plan · ",(a==null?void 0:a.plan)??s.plan??"free"]})]})]}),i?e.jsx("div",{className:"classic-card mt-10 p-8 text-[15px] text-[var(--c-text2)]",children:i}):a?e.jsxs("div",{className:"mt-10 grid gap-5 sm:grid-cols-2",children:[e.jsx(Ce,{label:"Input tokens",used:a.input_used,cap:a.input_cap,pct:y}),e.jsx(Ce,{label:"Output tokens",used:a.output_used,cap:a.output_cap,pct:x}),e.jsx("div",{className:"classic-card p-6 sm:col-span-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"classic-label",children:"billing period resets"}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-[var(--c-text)]",children:At(a.period_end)}),e.jsxs("div",{className:"mt-1 font-mono text-[12px] text-[var(--c-text3)]",children:["overage policy · ",a.overage_policy]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:v,className:"classic-button--quiet",children:"Manage billing"}),e.jsx(C,{to:"/pricing",className:"classic-button",children:"Upgrade"})]})]})})]}):null,o&&o.models.length?e.jsx(Mt,{models:o}):null,e.jsx("div",{className:"mt-6",children:e.jsx(St,{activity:c,year:u,years:(c==null?void 0:c.years)??[u],onYear:g})}),e.jsx("button",{type:"button",onClick:w,className:"mt-10 text-[13px] text-[var(--c-accent)] hover:underline",children:"Sign out"})]})})}function Mt({models:t}){const r=t.budget_micros||0,s=t.ceiling_micros??r,a=t.spent_micros||0,n=t.credits_remaining_micros||0,o=s0?Math.min(Math.round(a/s*100),100):0,p=wt,u=i=>we(i)>0?ve(i):"—",g=i=>i.includes("/")?i.slice(i.indexOf("/")+1):i;return e.jsxs("div",{className:"classic-card mt-5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsx("div",{className:"classic-label",children:o?"usage available now":"compute credits"}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[p(a)," / ",p(s)," · ",c,"%"]})]}),e.jsxs("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[p(n),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" ","credits ",o?"available now":"left this period"]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${c>=100?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${c}%`}})}),o&&d?e.jsxs("div",{className:"mt-2 font-mono text-[11px] text-[var(--c-text3)]",children:["More unlocks ",d.toLocaleDateString(void 0,{month:"short",day:"numeric"})," · ",p(r)," ","credits total this cycle"]}):null,e.jsx("div",{className:"mt-6 lineno",children:"models on your plan"}),e.jsx("div",{className:"mt-3 overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[460px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"py-1.5 pr-3 font-normal",children:"model"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"credits/turn"}),e.jsx("th",{className:"py-1.5 px-3 text-right font-normal",children:"≈ turns left"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"status"})]})}),e.jsx("tbody",{children:t.models.map(i=>e.jsxs("tr",{className:`border-b border-[var(--c-line)] ${i.live?"":"opacity-55"}`,children:[e.jsx("td",{className:"py-1.5 pr-3 text-[var(--c-text)]",children:g(i.id)}),e.jsxs("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",title:`${i.multiplier}× the baseline model`,children:[u(i.per_turn_micros),e.jsxs("span",{className:"sr-only",children:[" credits per turn, ",i.multiplier,"× the baseline model"]})]}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-[var(--c-text2)]",children:i.live?(i.turns_left??0).toLocaleString(Q):"—"}),e.jsx("td",{className:"py-1.5 pl-3 text-right",children:i.live?e.jsx("span",{className:"text-[11px] text-[var(--c-accent)]",children:"live"}):e.jsx("span",{className:"rounded bg-[var(--c-line)] px-1.5 py-0.5 text-[10px] text-[var(--c-text3)]",children:"soon"})})]},i.id))})]})})]})}function Ce({label:t,used:r,cap:s,pct:a}){const n=a>=100;return e.jsxs("div",{className:"classic-card p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-[var(--c-text2)]",children:[a,"%"]})]}),e.jsxs("div",{className:"mt-3 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:[Le(r),e.jsxs("span",{className:"text-sm font-normal text-[var(--c-text3)]",children:[" / ",Le(s)]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-[var(--c-line)]",children:e.jsx("div",{className:`h-full rounded-full ${n?"bg-red-500":"bg-[var(--c-accent)]"}`,style:{width:`${Math.min(a,100)}%`}})})]})}function Se(t,r){return!r||r<=0?0:Math.round(t/r*100)}function Le(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString(Q)}function At(t){if(!t)return"—";const r=new Date(t);return Number.isNaN(r.getTime())?t:r.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}function Et(){const t=X(),{loading:r,profile:s}=U(),[a,n]=l.useState(null),[o,d]=l.useState(null),[c,p]=l.useState("input"),[u,g]=l.useState("desc"),[i,f]=l.useState(""),[v,w]=l.useState(""),[y,x]=l.useState(null),m=(s==null?void 0:s.role)==="admin";l.useEffect(()=>{r||(s?m||t("/account",{replace:!0}):t("/login",{replace:!0}))},[r,s,m,t]),l.useEffect(()=>{if(!m)return;let h=!0;return E("/api/levelcode/v1/admin/summary").then(T=>h&&n(T)).catch(()=>h&&x("Couldn’t load the admin summary.")),()=>{h=!1}},[m]),l.useEffect(()=>{if(!m)return;let h=!0;const T=new URLSearchParams({sort:c,dir:u,limit:"200"});return i.trim()&&T.set("q",i.trim()),v&&T.set("plan",v),E(`/api/levelcode/v1/admin/users?${T.toString()}`).then(A=>h&&d(A)).catch(()=>h&&x("Couldn’t load users.")),()=>{h=!1}},[m,c,u,i,v]);const b=l.useMemo(()=>Object.keys((a==null?void 0:a.plans)??{}).sort(),[a]);function S(h){c===h?g(T=>T==="desc"?"asc":"desc"):(p(h),g(h==="email"||h==="plan"?"asc":"desc"))}return r||!m?e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-6xl px-5 py-12"})}):e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"System dashboard"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"tokens burned · plans · geography · login health"})]}),e.jsx(C,{to:"/admin/referrals",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"Referrals →"})]}),y?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:y}):null,e.jsxs("div",{className:"mt-10 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Z,{label:"users",value:W(a==null?void 0:a.users),sub:`${W(a==null?void 0:a.active_users)} active`}),e.jsx(Z,{label:"requests",value:W(a==null?void 0:a.requests),sub:_e(a==null?void 0:a.cost_micros)}),e.jsx(Z,{label:"input tokens",value:te(a==null?void 0:a.input)}),e.jsx(Z,{label:"output tokens",value:te(a==null?void 0:a.output)}),e.jsx(Z,{label:"auth attempts",value:W(a==null?void 0:a.auth_attempts),sub:`${W(a==null?void 0:a.auth_failures)} failed`,alert:((a==null?void 0:a.auth_failures)??0)>0}),e.jsx(ue,{label:"plans",map:a==null?void 0:a.plans}),e.jsx(ue,{label:"countries",map:a==null?void 0:a.countries}),e.jsx(ue,{label:"auth failures · country",map:a==null?void 0:a.auth_failures_by_country,alert:!0})]}),e.jsxs("div",{className:"mt-10 flex flex-wrap items-center gap-3",children:[e.jsx("input",{value:i,onChange:h=>f(h.target.value),placeholder:"Search email…",className:"w-full max-w-xs rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)] sm:w-auto"}),e.jsxs("select",{value:v,onChange:h=>w(h.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2 font-mono text-[13px] text-[var(--c-text2)] outline-none focus:border-[var(--c-accent)]",children:[e.jsx("option",{value:"",children:"all plans"}),b.map(h=>e.jsx("option",{value:h,children:h},h))]}),e.jsxs("span",{className:"font-mono text-[12px] text-[var(--c-text3)]",children:[W(o==null?void 0:o.total)," users"]})]}),e.jsx("div",{className:"classic-card mt-4 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[880px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx(F,{label:"email",col:"email",sort:c,dir:u,onClick:S,align:"left"}),e.jsx(F,{label:"plan",col:"plan",sort:c,dir:u,onClick:S,align:"left"}),e.jsx(F,{label:"input",col:"input",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"output",col:"output",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"requests",col:"requests",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"cost",col:"cost",sort:c,dir:u,onClick:S}),e.jsx("th",{className:"px-3 py-2 text-left font-normal",children:"country"}),e.jsx(F,{label:"auth",col:"auth_attempts",sort:c,dir:u,onClick:S}),e.jsx(F,{label:"last seen",col:"last_seen",sort:c,dir:u,onClick:S}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"reach"})]})}),e.jsxs("tbody",{children:[((o==null?void 0:o.users)??[]).map(h=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] hover:bg-[var(--c-surface)]",children:[e.jsxs("td",{className:"px-3 py-2 text-[var(--c-text)]",children:[h.email,h.role==="admin"?e.jsx("span",{className:"ml-2 rounded border border-[var(--c-accent)] px-1.5 py-0.5 text-[10px] text-[var(--c-accent)]",children:"admin"}):null]}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:h.plan}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:te(h.input)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:te(h.output)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:W(h.requests)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:_e(h.cost_micros)}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:h.country??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:e.jsxs("span",{className:h.auth_failures>0?"text-red-500":"text-[var(--c-text3)]",children:[h.auth_attempts,h.auth_failures>0?` · ${h.auth_failures}✗`:""]})}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text3)]",children:$t(h.last_seen_at)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("a",{className:"text-[var(--c-accent)] underline decoration-[var(--c-line)] underline-offset-2 hover:decoration-[var(--c-accent)]",href:`mailto:${h.email}`,children:"email"})})]},h.id)),o&&o.users.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:"px-3 py-6 text-center text-[var(--c-text3)]",children:"No users match."})}):null]})]})})]})})}function F({label:t,col:r,sort:s,dir:a,onClick:n,align:o="right"}){const d=s===r;return e.jsx("th",{className:`px-3 py-2 font-normal ${o==="right"?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>n(r),className:`inline-flex items-center gap-1 ${d?"text-[var(--c-text)]":"hover:text-[var(--c-text)]"}`,children:[t,e.jsx("span",{className:"text-[9px]",children:d?a==="desc"?"▼":"▲":"↕"})]})})}function Z({label:t,value:r,sub:s,alert:a}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),e.jsx("div",{className:"mt-1 text-2xl font-semibold tracking-tight tabular-nums text-[var(--c-text)]",children:r}),s?e.jsx("div",{className:`mt-1 font-mono text-[11px] ${a?"text-red-500":"text-[var(--c-text3)]"}`,children:s}):null]})}function ue({label:t,map:r,alert:s}){const a=Object.entries(r??{}).sort((n,o)=>o[1]-n[1]);return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("div",{className:"classic-label",children:t}),a.length?e.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[12px]",children:a.slice(0,5).map(([n,o])=>e.jsxs("li",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--c-text2)]",children:n}),e.jsx("span",{className:`tabular-nums ${s?"text-red-500":"text-[var(--c-text3)]"}`,children:o})]},n))}):e.jsx("div",{className:"mt-2 font-mono text-[12px] text-[var(--c-text3)]",children:"—"})]})}function W(t){return(t??0).toLocaleString()}function te(t){const r=t??0;return r>=1e6?`${+(r/1e6).toFixed(1)}M`:r>=1e3?`${+(r/1e3).toFixed(0)}K`:r.toLocaleString()}function _e(t){return`$${((t??0)/1e6).toFixed(2)}`}function $t(t){if(!t)return"—";const r=new Date(t);return Number.isNaN(r.getTime())?"—":r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const je={},Ye=ne.createContext(je);function Dt(t){const r=ne.useContext(Ye);return ne.useMemo(function(){return typeof t=="function"?t(r):{...r,...t}},[r,t])}function Pt(t){let r;return t.disableParentContext?r=typeof t.components=="function"?t.components(je):t.components||je:r=Dt(t.components),ne.createElement(Ye.Provider,{value:r},t.children)}const Ve=[{group:"Get started",items:[{title:"Overview",href:"/docs",blurb:"What LevelCode is, how the AI layer is wired, and where to go next."},{title:"Quickstart",href:"/docs/quickstart",blurb:"Install the editor, connect a model provider, and run your first agent task end to end."},{title:"Install and setup",href:"/docs/setup",blurb:"Download and verify a build, run from source, and handle macOS first-launch prompts."}]},{group:"AI",items:[{title:"Chat",href:"/docs/chat",blurb:"Ask questions about your codebase, with context pulled in automatically or pinned by hand."},{title:"Agent",href:"/docs/agent",blurb:"The autonomous loop: planning, multi-file edits, approval-gated commands, self-verification, and checkpoints."},{title:"Edit",href:"/docs/edit",blurb:"Select code, describe the change, and review it as a diff before anything lands."},{title:"Autocomplete",href:"/docs/autocomplete",blurb:"Inline ghost-text completion as you type, and how to tune it."},{title:"Providers and models",href:"/docs/providers",blurb:"Bring your own key for any supported provider, run models locally with Ollama, or use the metered gateway."}]},{group:"MCP",items:[{title:"MCP servers",href:"/docs/mcp",blurb:"Connect Model Context Protocol servers to give the agent tools LevelCode doesn't ship, and the approval model that governs them."},{title:"Server recipes",href:"/docs/mcp-recipes",blurb:"Working configurations for GitHub, the filesystem, image generation, and hosted servers — plus how to keep API tokens out of settings.json."}]},{group:"The editor",items:[{title:"Power editing",href:"/docs/power-editing",blurb:"The Notepad++ pack: macros, column mode, line operations, encoding and line-ending control, big-file mode."},{title:"Hackability",href:"/docs/hackability",blurb:"The init script, package authoring with hot reload, keymap presets, and themes."},{title:"Import and updates",href:"/docs/import-and-updates",blurb:"Bring your settings over from VS Code, VSCodium, or Cursor, install extensions from Open VSX, and stay on the latest build."}]},{group:"Account",items:[{title:"Cloud and billing",href:"/docs/cloud",blurb:"Sign in, understand credits and usage, and decide between your own key and the metered gateway."}]},{group:"Help",items:[{title:"Troubleshooting",href:"/docs/troubleshooting",blurb:"Fixes for first-launch blocks, provider and key errors, agent and terminal problems, and update failures."}]}],G=Ve.flatMap(t=>t.items);function It(t){const r=G.findIndex(s=>s.href===t);return r===-1?{prev:null,next:null}:{prev:r>0?G[r-1]:null,next:re.jsxs("div",{className:"mb-6 last:mb-0",children:[e.jsx("p",{className:"mb-2 text-[12px] font-semibold uppercase tracking-wide text-[var(--c-text3)]",children:s.group}),e.jsx("ul",{className:"space-y-0.5 border-l border-[var(--c-line)]",children:s.items.map(a=>{const n=r===a.href;return e.jsx("li",{children:e.jsx(C,{to:a.href,onClick:t,"aria-current":n?"page":void 0,className:`-ml-px block border-l py-1 pl-3 transition-colors ${n?"border-[var(--c-accent)] font-medium text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:a.title})},a.href)})})]},s.group))})}function Ot(){const{pathname:t}=J(),[r,s]=l.useState(!1);return l.useEffect(()=>s(!1),[t]),e.jsxs("div",{className:"border-b border-[var(--c-line)] lg:hidden",children:[e.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":r,"aria-controls":"docs-mobile-nav",className:"flex w-full items-center gap-2 px-5 py-3 text-[14px] font-medium text-[var(--c-text)]",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:`text-[var(--c-text3)] transition-transform duration-150 ${r?"rotate-90":""}`,children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),"Documentation menu"]}),r?e.jsx("div",{id:"docs-mobile-nav",className:"px-5 pb-5",children:e.jsx(Ze,{onNavigate:()=>s(!1)})}):null]})}function Bt(){return e.jsx("aside",{className:"hidden lg:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12 pr-6",children:e.jsx(Ze,{})})})}function qt({revision:t=0}){const{pathname:r}=J(),[s,a]=l.useState([]),[n,o]=l.useState("");return l.useEffect(()=>{const d=document.querySelector("article");if(!d)return;const c=Array.from(d.querySelectorAll("h2[id], h3[id]")).map(p=>{const u=p.cloneNode(!0);return u.querySelectorAll("a").forEach(g=>g.remove()),{id:p.id,text:(u.textContent??"").trim(),level:Number(p.tagName[1])}});a(p=>p.length===c.length&&p.every((u,g)=>u.id===c[g].id)?p:c)},[r,t]),l.useEffect(()=>{if(s.length===0)return;const d=()=>{let p=s[0].id;for(const u of s){const g=document.getElementById(u.id);g&&g.getBoundingClientRect().top<=120&&(p=u.id)}window.innerHeight+window.scrollY>=document.body.offsetHeight-2&&(p=s[s.length-1].id),o(p)};return d(),window.addEventListener("scroll",d,{passive:!0}),()=>window.removeEventListener("scroll",d)},[s]),s.length<2?null:e.jsxs("nav",{"aria-labelledby":"toc-heading",className:"text-[13.5px]",children:[e.jsx("p",{id:"toc-heading",className:"mb-3 font-semibold text-[var(--c-text)]",children:"On this page"}),e.jsx("ul",{className:"space-y-1.5 border-l border-[var(--c-line)]",children:s.map(d=>e.jsx("li",{children:e.jsx("a",{href:`#${d.id}`,"aria-current":n===d.id?"location":void 0,className:`-ml-px block border-l py-0.5 leading-snug transition-colors ${d.level===3?"pl-6":"pl-3"} ${n===d.id?"border-[var(--c-accent)] text-[var(--c-accent)]":"border-transparent text-[var(--c-text2)] hover:text-[var(--c-text)]"}`,children:d.text})},d.id))})]})}function Ge(t,r=24){const s=Math.max(0,t.getBoundingClientRect().top+window.scrollY-r);return window.scrollTo({top:s,behavior:"instant"}),Math.abs(window.scrollY-s)<=2}function Ft(){window.scrollTo({top:0,behavior:"instant"})}function Ut(t){return t.toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-")}function Ht({title:t,defaultOpen:r=!1,children:s}){const a=Ut(t),n=l.useRef(null),[o,d]=l.useState(r);return l.useEffect(()=>{const c=()=>{decodeURIComponent(window.location.hash.slice(1))===a&&(d(!0),requestAnimationFrame(()=>{n.current&&Ge(n.current)}))};return c(),window.addEventListener("hashchange",c),()=>window.removeEventListener("hashchange",c)},[a]),e.jsxs("details",{ref:n,id:a,open:o,onToggle:c=>d(c.currentTarget.open),className:"group scroll-mt-8 border-b border-[var(--c-line)] last:border-b-0 [&_>_summary_>_svg]:open:rotate-90",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 py-3 text-[15px] font-medium text-[var(--c-text)] marker:content-none hover:text-[var(--c-accent)] [&::-webkit-details-marker]:hidden",children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"shrink-0 text-[var(--c-text3)] transition-transform duration-150",children:e.jsx("path",{d:"M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"})}),t]}),e.jsx("div",{className:"pb-4 pl-[20px]",children:s})]})}function Wt({children:t}){return e.jsx("div",{className:"my-6 rounded-md border border-[var(--c-line)] px-4",children:t})}function Yt({title:t,href:r,children:s}){const a=e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[15px] font-semibold text-[var(--c-text)]",children:[t,r?e.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"currentColor","aria-hidden":!0,className:"text-[var(--c-text3)] transition-transform duration-150 group-hover:translate-x-0.5 group-hover:text-[var(--c-accent)]",children:e.jsx("path",{d:"M8.22 2.97a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06l2.97-2.97H3.75a.75.75 0 0 1 0-1.5h7.44L8.22 4.03a.75.75 0 0 1 0-1.06Z"})}):null]}),s?e.jsx("span",{className:"mt-1.5 block text-[14px] leading-relaxed text-[var(--c-text2)]",children:s}):null]}),n="group block rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-4 no-underline transition-colors";return r?e.jsx(C,{to:r,className:`${n} hover:border-[var(--c-accent)]`,children:a}):e.jsx("div",{className:n,children:a})}function Vt({cols:t=2,children:r}){const s=t===1?"sm:grid-cols-1":t===3?"sm:grid-cols-3":"sm:grid-cols-2";return e.jsx("div",{className:`my-6 grid grid-cols-1 gap-3 ${s}`,children:r})}const Zt={note:{wrap:"border-[var(--c-line)] bg-[var(--c-surface)]",icon:"text-[var(--c-text3)]",label:"Note",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},tip:{wrap:"border-[#149963]/30 bg-[#149963]/[0.08]",icon:"text-[#149963]",label:"Tip",path:"M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z"},info:{wrap:"border-[var(--c-accent)]/30 bg-[var(--c-accent)]/[0.07]",icon:"text-[var(--c-accent)]",label:"Info",path:"M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"},warning:{wrap:"border-[#d19a66]/40 bg-[#d19a66]/[0.1]",icon:"text-[#b3701a]",label:"Warning",path:"M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"}};function oe({variant:t,children:r}){const s=Zt[t];return e.jsxs("div",{className:`my-5 flex gap-3 rounded-md border px-4 py-3 ${s.wrap}`,children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"15",height:"15",fill:"currentColor","aria-hidden":!0,className:`mt-[3px] shrink-0 ${s.icon}`,children:e.jsx("path",{d:s.path})}),e.jsxs("div",{className:"min-w-0 text-[15px] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:[e.jsxs("span",{className:"sr-only",children:[s.label,": "]}),r]})]})}const Gt=({children:t})=>e.jsx(oe,{variant:"note",children:t}),zt=({children:t})=>e.jsx(oe,{variant:"tip",children:t}),Kt=({children:t})=>e.jsx(oe,{variant:"info",children:t}),Xt=({children:t})=>e.jsx(oe,{variant:"warning",children:t});function Jt({children:t,...r}){const s=l.useRef(null),[a,n]=l.useState(!1),[o,d]=l.useState(null);l.useEffect(()=>{var p,u;d(((u=(p=s.current)==null?void 0:p.querySelector("pre"))==null?void 0:u.getAttribute("data-language"))??null)},[]);async function c(){var u,g;const p=((g=(u=s.current)==null?void 0:u.querySelector("pre"))==null?void 0:g.textContent)??"";try{await navigator.clipboard.writeText(p),n(!0),window.setTimeout(()=>n(!1),1600)}catch{}}return e.jsxs("figure",{ref:s,...r,className:"group relative my-5 overflow-hidden rounded-md border border-black/20 bg-[#0d1321] text-[#abb2bf] [&_code]:grid [&_code]:rounded-none [&_code]:border-0 [&_code]:bg-transparent [&_code]:p-0 [&_code]:font-mono [&_code]:text-[13.5px] [&_code]:leading-[1.65] [&_code]:text-inherit [&_pre]:overflow-x-auto [&_pre]:bg-transparent [&_pre]:py-4 [&_[data-line]]:px-4",children:[e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex items-center gap-2",children:[o?e.jsx("span",{className:"select-none font-mono text-[11px] uppercase tracking-wide text-[#7d8695] opacity-0 transition-opacity group-hover:opacity-100",children:o}):null,e.jsx("button",{type:"button",onClick:c,"aria-label":a?"Copied to clipboard":"Copy code",className:"rounded-[4px] border border-white/10 bg-white/5 px-2 py-1 font-mono text-[11px] text-[#b9c0cb] opacity-0 transition-all hover:border-white/25 hover:bg-white/10 focus-visible:opacity-100 group-hover:opacity-100",children:a?"Copied":"Copy"})]}),t]})}const Te={cmd:"⌘",command:"⌘",meta:"⌘",ctrl:"⌃",control:"⌃",alt:"⌥",option:"⌥",opt:"⌥",shift:"⇧",enter:"↩",return:"↩",tab:"⇥",escape:"⎋",esc:"⎋",space:"Space",backspace:"⌫",delete:"⌦",up:"↑",down:"↓",left:"←",right:"→"};function Qt(t){const r=t.trim().toLowerCase();return Te[r]?Te[r]:t.trim().length===1?t.trim().toUpperCase():t.trim()}function er({keys:t}){const r=t.trim().split(/\s+/);return e.jsx("span",{className:"inline-flex items-baseline gap-1 whitespace-nowrap align-baseline",children:r.map((s,a)=>e.jsx("kbd",{className:"inline-flex items-center rounded-[4px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[6px] py-[2px] font-mono text-[12.5px] font-medium text-[var(--c-text)]",children:s.split("+").map(Qt).join("")},`${s}-${a}`))})}function tr({children:t}){return e.jsx(e.Fragment,{children:t})}function rr(t){var r;return l.isValidElement(t)&&typeof((r=t.props)==null?void 0:r.title)=="string"}function ar({children:t}){const r=l.Children.toArray(t).filter(rr);return r.length===0?null:e.jsx("ol",{className:"my-6 list-none space-y-0 pl-0",children:r.map((s,a)=>e.jsxs("li",{className:"relative pb-6 pl-10 last:pb-0",children:[a*:first-child]:mt-0 [&>*:last-child]:mb-0",children:s.props.children})]},`${s.props.title}-${a}`))})}function sr({children:t}){return e.jsx(e.Fragment,{children:t})}function nr(t){var r;return l.isValidElement(t)&&typeof((r=t.props)==null?void 0:r.title)=="string"}function lr({children:t}){const r=l.Children.toArray(t).filter(nr),[s,a]=l.useState(0),n=l.useId();if(r.length===0)return null;const o=r[Math.min(s,r.length-1)];return e.jsxs("div",{className:"my-6",children:[e.jsx("div",{role:"tablist","aria-orientation":"horizontal",className:"flex flex-wrap gap-1 border-b border-[var(--c-line)]",children:r.map((d,c)=>{const p=c===s;return e.jsx("button",{type:"button",role:"tab",id:`${n}-tab-${c}`,"aria-selected":p,"aria-controls":`${n}-panel-${c}`,onClick:()=>a(c),className:`-mb-px border-b-2 px-3 py-2 text-[14px] font-medium transition-colors ${p?"border-[var(--c-accent)] text-[var(--c-text)]":"border-transparent text-[var(--c-text2)] hover:border-[var(--c-line)] hover:text-[var(--c-text)]"}`,children:d.props.title},`${d.props.title}-${c}`)})}),e.jsx("div",{role:"tabpanel",id:`${n}-panel-${s}`,"aria-labelledby":`${n}-tab-${s}`,className:"pt-4",children:o.props.children})]})}function he(t){const r=`h${t}`,s=t===2?"mt-12 text-[24px] font-semibold":t===3?"mt-9 text-[18.5px] font-semibold":"mt-7 text-[16px] font-semibold";return function({id:n,children:o,...d}){return e.jsxs(r,{id:n,className:`group mb-3 scroll-mt-8 text-[var(--c-text)] ${s}`,...d,children:[o,n?e.jsx("a",{href:`#${n}`,"aria-label":"Link to this section",className:"ml-2 text-[var(--c-text3)] opacity-0 transition-opacity hover:text-[var(--c-accent)] focus-visible:opacity-100 group-hover:opacity-100",children:"#"}):null]})}}const Me="font-medium text-[var(--c-accent)] underline decoration-[var(--c-accent)]/30 underline-offset-2 transition-colors hover:decoration-[var(--c-accent)]",or={h1:({children:t,...r})=>e.jsx("h1",{className:"mb-4 text-[34px] font-bold leading-tight tracking-tight text-[var(--c-text)]",...r,children:t}),h2:he(2),h3:he(3),h4:he(4),p:t=>e.jsx("p",{className:"my-4 text-[16px] leading-[1.7] pretty",...t}),a:({href:t="",children:r,...s})=>{if(t.startsWith("/"))return e.jsx(C,{to:t,className:Me,...s,children:r});const a=!t.startsWith("#");return e.jsx("a",{href:t,className:Me,...a?{target:"_blank",rel:"noopener noreferrer"}:{},...s,children:r})},ul:t=>e.jsx("ul",{className:"my-4 list-disc space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),ol:t=>e.jsx("ol",{className:"my-4 list-decimal space-y-2 pl-5 marker:text-[var(--c-text3)]",...t}),li:t=>e.jsx("li",{className:"leading-[1.7] [&>ol]:my-2 [&>ul]:my-2",...t}),strong:t=>e.jsx("strong",{className:"font-semibold text-[var(--c-text)]",...t}),code:t=>e.jsx("code",{className:"rounded-[3px] border border-[var(--c-line)] bg-[var(--c-surface)] px-[5px] py-[1.5px] font-mono text-[0.875em] text-[var(--c-text)]",...t}),figure:({children:t,...r})=>"data-rehype-pretty-code-figure"in r?e.jsx(Jt,{...r,children:t}):e.jsx("figure",{className:"my-6",...r,children:t}),blockquote:t=>e.jsx("blockquote",{className:"my-5 border-l-2 border-[var(--c-line)] pl-4 text-[var(--c-text2)] [&>p]:my-2",...t}),hr:()=>e.jsx("hr",{className:"my-10 border-[var(--c-line)]"}),table:t=>e.jsx("div",{className:"my-6 overflow-x-auto rounded-md border border-[var(--c-line)]",children:e.jsx("table",{className:"w-full border-collapse text-left text-[14.5px]",...t})}),thead:t=>e.jsx("thead",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",...t}),th:t=>e.jsx("th",{className:"px-4 py-2.5 font-semibold text-[var(--c-text)] [&_code]:text-[0.9em]",...t}),td:t=>e.jsx("td",{className:"border-t border-[var(--c-line)] px-4 py-2.5 align-top leading-[1.6] [&_code]:text-[0.9em]",...t}),Tabs:lr,Tab:sr,Accordion:Ht,AccordionGroup:Wt,Card:Yt,CardGroup:Vt,Steps:ar,Step:tr,Note:Gt,Tip:zt,Info:Kt,Warning:Xt,Kbd:er};function ir(){const[t,r]=l.useState(0);return l.useEffect(()=>{const s=document.querySelector("article");if(!s)return;const a=new MutationObserver(()=>r(n=>n+1));return a.observe(s,{childList:!0,subtree:!0}),()=>a.disconnect()},[]),t}function cr(t){l.useEffect(()=>{const r=G.find(d=>d.href===t),s=document.title;document.title=r?`${r.title} — LevelCode Docs`:"LevelCode Docs";const a=document.querySelector('meta[name="description"]'),n=(a==null?void 0:a.hasAttribute("content"))??!1,o=(a==null?void 0:a.getAttribute("content"))??null;return a&&r&&a.setAttribute("content",r.blurb),()=>{document.title=s,a&&(n&&o!==null?a.setAttribute("content",o):a.removeAttribute("content"))}},[t])}function dr(t,r,s){const a=l.useRef("");l.useEffect(()=>{const n=t+r;if(!r){a.current!==n&&(a.current=n,Ft());return}if(a.current===n)return;const o=document.getElementById(decodeURIComponent(r.slice(1)));if(!o)return;const d=()=>{Ge(o)&&(a.current=n)};d(),requestAnimationFrame(d)},[t,r,s])}function xr({children:t}){const{pathname:r,hash:s}=J(),a=ir();return cr(r),dr(r,s,a),e.jsxs(D,{children:[e.jsx(Ot,{}),e.jsx("div",{className:"mx-auto max-w-[88rem] px-5",children:e.jsxs("div",{className:"lg:grid lg:grid-cols-[14rem_minmax(0,1fr)] lg:gap-10 xl:grid-cols-[14rem_minmax(0,1fr)_13rem]",children:[e.jsx(Bt,{}),e.jsxs("main",{className:"min-w-0 py-10 lg:py-12",children:[e.jsx("article",{className:"max-w-[46rem]",children:e.jsx(Pt,{components:or,children:t})}),e.jsx("div",{className:"max-w-[46rem]",children:e.jsx(Rt,{})})]}),e.jsx("div",{className:"hidden xl:block",children:e.jsx("div",{className:"sticky top-0 max-h-screen overflow-y-auto py-12",children:e.jsx(qt,{revision:a})})})]})})]})}const ur=l.lazy(()=>it(()=>import("./bundle-HSVNZER1.js"),__vite__mapDeps([0,1])));function ze({slug:t=""}){return e.jsx(xr,{children:e.jsx(l.Suspense,{fallback:e.jsx(hr,{}),children:e.jsx(ur,{slug:t})})})}function hr(){return e.jsxs("div",{"aria-hidden":!0,className:"animate-pulse",children:[e.jsx("div",{className:"h-9 w-2/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-6 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-11/12 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-4/5 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-10 h-6 w-1/3 rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-5 h-4 w-full rounded bg-[var(--c-surface)]"}),e.jsx("div",{className:"mt-3 h-4 w-10/12 rounded bg-[var(--c-surface)]"}),e.jsx("span",{className:"sr-only",children:"Loading documentation…"})]})}const mr="https://github.com/levelcodeai/levelcode",pr="levelcode://levelcode.levelcode-ai/launch";function fr(){const{profile:t}=U();return e.jsx("header",{className:"fixed inset-x-0 top-0 z-50 border-b border-rule bg-paper/85 backdrop-blur-md",children:e.jsxs("nav",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-5",children:[e.jsxs(C,{to:"/",className:"font-display text-[15px] font-bold tracking-tightest",children:["LevelCode ",e.jsx("span",{className:"font-medium text-faint",children:"Cloud"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(C,{to:"/pricing",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Pricing"}),e.jsx("a",{href:mr,target:"_blank",rel:"noreferrer",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"GitHub"}),e.jsx(C,{to:"/download",className:"rounded-full bg-ink px-4 py-1.5 text-sm font-semibold text-paper transition-colors hover:bg-flame",children:"Download"}),t?e.jsxs(e.Fragment,{children:[t.role==="admin"?e.jsx(C,{to:"/admin",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Admin"}):null,e.jsxs("a",{href:pr,title:"Open the LevelCode editor (signs it into this account)",className:"inline-flex items-center gap-1 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink",children:["IDE ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}),e.jsx(C,{to:"/account",title:"Account","aria-label":"Account",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-rule bg-card text-[12px] font-semibold text-ink transition-colors hover:border-ink",children:We(t.name,t.email)})]}):e.jsx(C,{to:"/login",className:"hidden items-center gap-2 rounded-full border border-rule bg-card px-3 py-1.5 text-sm text-sub transition-colors hover:border-ink hover:text-ink sm:inline-flex",children:"Sign in"})]})]})})}function Ke(){if(typeof navigator>"u")return!1;const t=navigator.userAgent||"",r=/Mac/i.test(navigator.platform||"")||/Macintosh/.test(t),s=r&&(navigator.maxTouchPoints??0)>1;return r&&!s}async function gr(){var r,s;if(!Ke())return"not-mac";const t=navigator;try{const a=await((s=(r=t.userAgentData)==null?void 0:r.getHighEntropyValues)==null?void 0:s.call(r,["architecture"]));if((a==null?void 0:a.architecture)==="arm")return"arm64";if((a==null?void 0:a.architecture)==="x86")return"x64"}catch{}try{const a=document.createElement("canvas"),n=a.getContext("webgl")||a.getContext("experimental-webgl"),o=n==null?void 0:n.getExtension("WEBGL_debug_renderer_info"),d=o&&n?String(n.getParameter(o.UNMASKED_RENDERER_WEBGL)):"";if(/apple/i.test(d))return"arm64";if(/intel|amd|radeon/i.test(d))return"x64"}catch{}return"unknown-mac"}const Ae="https://github.com/levelcodeai/levelcode/releases/latest",me={arm64:`${Ae}/download/LevelCode-arm64.dmg`,x64:`${Ae}/download/LevelCode-x64.dmg`};function vr(){const[t,r]=l.useState("unknown-mac");l.useEffect(()=>{let o=!0;return gr().then(d=>{o&&r(d)}),()=>{o=!1}},[]);const s=t==="x64"?"x64":"arm64",a=s==="arm64"?"Apple Silicon":"Intel",n=t==="not-mac";return e.jsxs(e.Fragment,{children:[e.jsx(fr,{}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-24",children:[e.jsx("div",{className:"lineno mb-4",children:"06 · download"}),e.jsxs("h1",{className:"font-display text-[clamp(2rem,5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-balance",children:["Download ",e.jsx("span",{className:"pp",children:"LevelCode"})," for macOS"]}),e.jsx("p",{className:"mt-5 max-w-xl text-[17px] leading-relaxed text-sub pretty",children:"The AI-native editor — your plan, keys, and usage in one place. Universal on any modern Mac; pick Intel if you’re on an older one."}),n?e.jsx("div",{className:"surface mt-8 p-5 text-[14px] text-sub",children:"LevelCode is a macOS app for now. Grab it on your Mac — or download a build below to move over."}):null,e.jsxs("div",{className:"mt-9 flex flex-col items-start gap-3",children:[e.jsxs("a",{href:me[s],className:"btn-primary text-[15px]",download:!0,children:["Download for ",a," Mac"]}),e.jsx("p",{className:"font-mono text-[12px] text-faint",children:"Universal .dmg · latest release · macOS 12 Monterey or later"})]}),e.jsx("div",{className:"mt-10 lineno",children:"all builds"}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3",children:[e.jsx("a",{href:me.arm64,className:"btn-ghost text-[14px]",download:!0,children:"Apple Silicon (M1–M4)"}),e.jsx("a",{href:me.x64,className:"btn-ghost text-[14px]",download:!0,children:"Intel Mac (x64)"})]}),e.jsx("p",{className:"mt-4 font-mono text-[12px] text-faint",children:"Not sure which Mac you have? Apple menu → About This Mac. “Apple M…” chip → Apple Silicon; “Intel” → Intel."})]})]})}const I=t=>({t,c:"text-[#c58aff]"}),Ee=t=>({t,c:"text-[#7fd88f]"}),Y=t=>({t,c:"text-[#9fb4ff]"}),pe=t=>({t,c:"text-[#5b6172]"}),fe=t=>({t,c:"text-[#e6a86b]"}),j=t=>({t}),R=[{id:"generate",label:"Generate",file:"payments/refund_service.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Generate."})," Describe the change in plain language — LevelCode writes idiomatic code in your project’s style, right in the buffer."]}),chat:[{who:"you",text:"Add idempotency to RefundService — same request twice must not double-refund."},{who:"ai",text:"Adding an idempotency key check backed by Redis, with a 24h TTL. Writing it now…"}],code:[{no:"12",toks:[I("class"),j(" "),Y("RefundService")]},{no:"13",toks:[j(" "),I("def"),j(" "),Y("call"),j("(charge, key:)")]},{no:"14",toks:[j(" "),I("return"),j(" cached(key) "),I("if"),j(" seen?(key)")]},{no:"15",toks:[j(" result = gateway.refund(charge)")]},{no:"16",toks:[j(" remember(key, result, ttl: "),fe("24"),j(".hours)")]},{no:"17",toks:[j(" result")]},{no:"18",toks:[j(" "),I("end")]},{no:"19",toks:[I("end")]}]},{id:"refactor",label:"Refactor",file:"api/orders_controller.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Refactor."})," Select any block and ask. LevelCode restructures across files, keeping behavior identical and diffs reviewable."]}),chat:[{who:"you",text:"This controller does too much. Extract the pricing logic."},{who:"ai",text:"Extracting to app/services/pricing_calculator.rb and updating 3 call sites. Behavior unchanged — diff ready."}],code:[{no:"40",toks:[pe("# before: 62 lines in controller")]},{no:"41",toks:[I("def"),j(" "),Y("create")]},{no:"42",toks:[j(" total = "),Y("PricingCalculator")]},{no:"43",toks:[j(" .new(cart, coupon: params[:coupon])")]},{no:"44",toks:[j(" .total")]},{no:"45",toks:[j(" order = "),Y("Order"),j(".create!(total:)")]},{no:"46",toks:[j(" render json: order")]},{no:"47",toks:[I("end")]}]},{id:"explain",label:"Explain",file:"legacy/billing_engine.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Explain."})," Point at unfamiliar code — get a walkthrough of what it does, why it exists, and where it’s called from."]}),chat:[{who:"you",text:"What is this proration branch actually doing?"},{who:"ai",text:"It splits the billing period at the plan-change date, credits unused time on the old plan, and charges the remainder at the new rate. Called from 2 places — both webhooks."}],code:[{no:"88",toks:[I("if"),j(" plan_changed_mid_cycle?")]},{no:"89",toks:[j(" credit = unused_ratio * old_rate")]},{no:"90",toks:[j(" charge = remaining_ratio * new_rate")]},{no:"91",toks:[j(" invoice.adjust(credit:, charge:)")]},{no:"92",toks:[I("end")]},{no:"93",toks:[pe("# ← LevelCode: proration on plan change")]}]},{id:"test",label:"Test",file:"spec/refund_service_spec.rb — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Test."})," LevelCode drafts the spec, runs it, reads the failure, and fixes the code — a full red-green loop without leaving the editor."]}),chat:[{who:"you",text:"Write specs for the double-refund case."},{who:"ai",text:"Spec written. Running… 1 failure: cache key ignored currency. Patched — all green ✓"}],code:[{no:"05",toks:[Y("it"),j(" "),Ee('"refunds only once per key"'),j(" "),I("do")]},{no:"06",toks:[j(" "),fe("2"),j(".times { service.call(charge, key:) }")]},{no:"07",toks:[j(" expect(gateway.refunds.count).to eq("),fe("1"),j(")")]},{no:"08",toks:[I("end")]},{no:"09",toks:[j("")]},{no:"10",toks:[Ee("✓ 14 examples, 0 failures — 0.42s")]}]},{id:"review",label:"Review",file:"PR #241 · fix race in webhook retry — LevelCode",caption:e.jsxs(e.Fragment,{children:[e.jsx("strong",{className:"font-semibold text-ink",children:"Review."})," Before you push, LevelCode flags edge cases, security issues, and style drift — like a senior reviewer on every commit."]}),chat:[{who:"you",text:"Review this PR before I push."},{who:"ai",text:"One real issue: retry loop can fire twice if the worker restarts between enqueue and ack. Suggesting a fix inline."}],code:[{no:"21",toks:[pe("# ⚠ LevelCode: not restart-safe")]},{no:"22",toks:[{t:"- retry_later(webhook)",c:"text-[#e06c75]"}]},{no:"23",toks:[{t:"+ ",c:"text-[#7fd88f]"},Y("WebhookRetryJob")]},{no:"24",toks:[{t:"+ ",c:"text-[#7fd88f]"},j(" .set(wait: backoff(attempt))")]},{no:"25",toks:[{t:"+ ",c:"text-[#7fd88f]"},j(" .perform_later(webhook.id,")]},{no:"26",toks:[{t:"+ ",c:"text-[#7fd88f]"},j(" lock: webhook.lock_token)")]}]}];function br(){const[t,r]=l.useState(!1),[s,a]=l.useState(0),[n,o]=l.useState(!0),[d,c]=l.useState(!0),[p,u]=l.useState(0),[g,i]=l.useState(0),[f,v]=l.useState(0),[w,y]=l.useState(!1),[x,m]=l.useState(0),b=l.useRef(null),S=l.useRef(null),h=l.useRef([]),T=l.useRef([]),A=l.useRef([]),q=R[s],ee=q.duration??9;l.useEffect(()=>{window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(r(!0),o(!1),i(R[s].code.length))},[]),l.useLayoutEffect(()=>{var L;const k=()=>{const N=h.current[s],M=S.current;if(!N||!M||!N.parentElement)return;const $=N.getBoundingClientRect(),H=N.parentElement.getBoundingClientRect();M.style.width=`${$.width}px`,M.style.transform=`translateX(${$.left-H.left}px)`};return k(),window.addEventListener("resize",k),(L=document.fonts)==null||L.ready.then(k).catch(()=>{}),()=>window.removeEventListener("resize",k)},[s,t]),l.useEffect(()=>{const k=b.current;if(!k)return;const L=new IntersectionObserver(([N])=>c(N.isIntersecting),{threshold:.25});return L.observe(k),()=>L.disconnect()},[]),l.useEffect(()=>{if(s===f)return;y(!0);const k=setTimeout(()=>{v(s),y(!1)},200);return()=>clearTimeout(k)},[s,f]),l.useEffect(()=>{if(t||(A.current.forEach(clearTimeout),A.current=[],!n||!d))return;const k=T.current[s],L=k?Array.from(k.querySelectorAll("[data-text]")):[];L.forEach(M=>M.textContent=""),i(0),m(M=>M+1);let N=300;return L.forEach(M=>{const $=M.dataset.text??"";for(let H=1;H<=$.length;H++)N+=14,A.current.push(setTimeout(()=>M.textContent=$.slice(0,H),N));N+=350}),R[s].code.forEach((M,$)=>{N+=320,A.current.push(setTimeout(()=>i($+1),N))}),A.current.push(setTimeout(()=>a(M=>(M+1)%R.length),(R[s].duration??9)*1e3)),()=>{A.current.forEach(clearTimeout),A.current=[]}},[s,n,d,p,t]);const nt=()=>{o(k=>{const L=!k;return L&&u(N=>N+1),L})},Ne=k=>t?R[k].code.length:k===s?g:0;return e.jsxs("div",{ref:b,className:"relative",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute left-1/2 top-1/2 h-[70%] w-[85%] -translate-x-1/2 -translate-y-1/2 rounded-full bg-flame/10 blur-3xl"}),e.jsxs("div",{role:"tablist","aria-label":"LevelCode capabilities",className:"relative mx-auto mb-6 flex w-max max-w-full gap-1 overflow-x-auto rounded-full border border-rule bg-card p-1.5 [scrollbar-width:none]",children:[e.jsx("span",{ref:S,"aria-hidden":!0,className:"absolute left-0 top-1.5 h-[calc(100%-12px)] rounded-full bg-flame shadow-[0_0_18px_rgb(var(--accent-rgb)/0.45)] transition-[transform,width] duration-300 ease-out"}),R.map((k,L)=>e.jsx("button",{ref:N=>{h.current[L]=N},role:"tab",id:`sc-tab-${k.id}`,"aria-selected":L===s,"aria-controls":`sc-pane-${k.id}`,onClick:()=>{L===s?u(N=>N+1):a(L)},onKeyDown:N=>{var M,$;N.key==="ArrowRight"&&((M=h.current[(L+1)%R.length])==null||M.focus()),N.key==="ArrowLeft"&&(($=h.current[(L-1+R.length)%R.length])==null||$.focus())},className:`relative z-10 whitespace-nowrap rounded-full px-5 py-2 text-sm font-semibold transition-colors ${L===s?"text-paper":"text-sub hover:text-ink"}`,children:k.label},k.id))]}),e.jsx("p",{"aria-live":"polite",className:`mx-auto mb-8 min-h-[48px] max-w-xl text-center text-[15px] leading-relaxed text-sub transition-opacity duration-200 ${w?"opacity-0":"opacity-100"}`,children:R[f].caption}),e.jsxs("div",{className:"shot-shadow relative overflow-hidden rounded-2xl border border-[#20232f] bg-[#0a0c16]",children:[e.jsxs("div",{className:"flex h-10 items-center gap-2 border-b border-[#1b1e2b] bg-[#0d1020] px-4",children:[e.jsxs("span",{className:"flex gap-1.5","aria-hidden":!0,children:[e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#ff5f57]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#febc2e]"}),e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-[#28c840]"})]}),e.jsx("span",{className:"ml-2 truncate font-mono text-[12px] text-[#6b7280]",children:q.file}),e.jsx("span",{className:"ml-auto shrink-0 rounded-full border border-[#7d6bff]/40 bg-[#7d6bff]/15 px-2.5 py-0.5 font-mono text-[10.5px] text-[#c6bfff]",children:"AI session · live"})]}),e.jsxs("div",{className:"relative aspect-video bg-black/20",children:[R.map((k,L)=>e.jsx("div",{ref:N=>{T.current[L]=N},role:"tabpanel",id:`sc-pane-${k.id}`,"aria-labelledby":`sc-tab-${k.id}`,className:`absolute inset-0 transition-opacity duration-300 ${L===s?"opacity-100":"pointer-events-none opacity-0"}`,children:e.jsxs("div",{className:"grid h-full grid-cols-1 md:grid-cols-[minmax(200px,300px)_1fr]",children:[e.jsx("div",{className:"hidden flex-col gap-4 border-r border-[#1b1e2b] bg-black/15 p-5 font-mono text-[12.5px] leading-relaxed md:flex",children:k.chat.map((N,M)=>e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px] uppercase tracking-[0.14em] text-[#a99bff]",children:[e.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 rounded-full bg-[#7d6bff] shadow-[0_0_8px_rgba(125,107,255,0.9)]"}),N.who==="you"?"You":"LevelCode"]}),e.jsx("div",{"data-text":N.text,className:N.who==="you"?"text-[#c7cbe0]":"text-[#8b93ad]",children:t?N.text:""})]},M))}),e.jsx("div",{className:"overflow-hidden whitespace-pre p-5 font-mono text-[12px] leading-[1.9] text-[#c7cbe0] md:text-[13px]",children:k.code.slice(0,Ne(L)).map((N,M)=>e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.6em] select-none text-[#3b4157]",children:N.no}),N.toks.map(($,H)=>e.jsx("span",{className:$.c??"text-[#c7cbe0]",children:$.t},H)),M===Ne(L)-1&&!t&&e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]},M))})]})},k.id)),!t&&e.jsx("button",{type:"button",onClick:nt,"aria-label":n?"Pause showcase":"Play showcase",className:"absolute bottom-4 right-4 z-10 grid h-10 w-10 place-items-center rounded-full border border-white/20 bg-black/50 text-white backdrop-blur transition-colors hover:bg-[#7d6bff]/30",children:n?e.jsxs("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:[e.jsx("rect",{x:"3",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"9",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsx("svg",{viewBox:"0 0 16 16",className:"h-4 w-4 fill-current","aria-hidden":!0,children:e.jsx("path",{d:"M4 2.5v11a1 1 0 0 0 1.53.85l9-5.5a1 1 0 0 0 0-1.7l-9-5.5A1 1 0 0 0 4 2.5z"})})}),e.jsx("div",{"aria-hidden":!0,className:"absolute inset-x-0 bottom-0 h-[3px]",children:e.jsx("i",{className:"block h-full w-0 bg-[#7d6bff] shadow-[0_0_10px_rgba(125,107,255,0.8)]",style:n&&d&&!t?{animation:`scfill ${ee}s linear forwards`}:void 0},x)})]})]})]})}const jr={amber:"#e2a43c",blue:"#57a2e8",green:"#7cb85c"},yr={name:"Design a Key-Value Store",goal:"Build and test a distributed, highly-available key-value store — implement it in C.",reference:"https://bytebytego.com/courses/system-design-interview/design-a-key-value-store",w:1740,h:700,nodes:[{id:"req",label:"requirements",tier:"powerful",color:"amber",x:20,y:300},{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:320,y:300},{id:"storage",label:"storage-engine",tier:"balanced",color:"amber",x:620,y:130},{id:"hash",label:"consistent-hash",tier:"balanced",color:"blue",x:620,y:245},{id:"repl",label:"replication+quorum",tier:"balanced",color:"amber",x:620,y:360},{id:"vclock",label:"vector-clocks",tier:"balanced",color:"amber",x:620,y:475},{id:"gossip",label:"gossip+failover",tier:"balanced",color:"blue",x:620,y:590},{id:"integrate",label:"integrate+server",tier:"balanced",color:"blue",x:920,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1220,y:240},{id:"build",label:"build+validate",tier:"balanced",color:"green",x:1220,y:360},{id:"review",label:"review+run-guide",tier:"balanced",color:"amber",x:1520,y:300}],edges:[{from:"req",to:"arch"},{from:"arch",to:"storage"},{from:"arch",to:"hash"},{from:"arch",to:"repl"},{from:"arch",to:"vclock"},{from:"arch",to:"gossip"},{from:"storage",to:"integrate"},{from:"hash",to:"integrate"},{from:"repl",to:"integrate"},{from:"vclock",to:"integrate"},{from:"gossip",to:"integrate"},{from:"integrate",to:"tests"},{from:"integrate",to:"build"},{from:"tests",to:"review"},{from:"build",to:"review"}]},wr={name:"Real-time Gaming Leaderboard",goal:"Design and test a real-time gaming leaderboard — top 10 by score, a user's rank, and ±4 neighbours around them.",reference:"https://bytebytego.com/courses/system-design-interview/real-time-gaming-leaderboard",w:1740,h:640,nodes:[{id:"arch",label:"architecture",tier:"powerful",color:"amber",x:20,y:300},{id:"api",label:"public-api",tier:"balanced",color:"blue",x:320,y:130},{id:"gateway",label:"api-gateway",tier:"balanced",color:"blue",x:320,y:300},{id:"game",label:"game-service",tier:"balanced",color:"blue",x:320,y:470},{id:"relational",label:"relational-baseline",tier:"balanced",color:"amber",x:620,y:130},{id:"redis",label:"redis-sorted-set",tier:"balanced",color:"amber",x:620,y:300},{id:"nosql",label:"nosql-dynamodb",tier:"balanced",color:"amber",x:620,y:470},{id:"persist",label:"persistence-mysql",tier:"balanced",color:"amber",x:920,y:130},{id:"shard",label:"sharding",tier:"balanced",color:"blue",x:920,y:300},{id:"cache",label:"rank-cache",tier:"balanced",color:"amber",x:920,y:470},{id:"service",label:"leaderboard-service",tier:"balanced",color:"blue",x:1220,y:300},{id:"tests",label:"tests",tier:"balanced",color:"green",x:1520,y:300}],edges:[{from:"arch",to:"api"},{from:"arch",to:"gateway"},{from:"arch",to:"game"},{from:"api",to:"relational"},{from:"api",to:"redis"},{from:"gateway",to:"redis"},{from:"game",to:"redis"},{from:"relational",to:"redis"},{from:"redis",to:"persist"},{from:"redis",to:"nosql"},{from:"redis",to:"shard"},{from:"shard",to:"cache"},{from:"persist",to:"service"},{from:"cache",to:"service"},{from:"nosql",to:"service"},{from:"service",to:"tests"}]},$e=[yr,wr],Nr={"Design a Key-Value Store":"KV","Real-time Gaming Leaderboard":"LB"},kr=200,re=44;function Cr(){const[t,r]=l.useState(null),[s,a]=l.useState(""),[n,o]=l.useState(!1),[d,c]=l.useState(!1),[p,u]=l.useState(new Set),g=l.useRef(null),i=l.useRef([]),f=l.useCallback(x=>{r(x),a(x.goal),u(new Set)},[]),v=l.useCallback(()=>{t&&(i.current.forEach(clearTimeout),i.current=[],u(new Set),t.nodes.forEach((x,m)=>{const b=setTimeout(()=>{u(h=>new Set(h).add(x.id))},m*900),S=setTimeout(()=>{u(h=>{const T=new Set(h);return T.delete(x.id),T})},m*900+1600);i.current.push(b,S)}))},[t]);l.useEffect(()=>()=>i.current.forEach(clearTimeout),[]);const w=x=>{x.preventDefault(),c(!1),o(!1);const m=x.dataTransfer.getData("text/levelcode-sketch"),b=$e.find(S=>S.name===m);b&&f(b)},y=x=>t==null?void 0:t.nodes.find(m=>m.id===x);return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[260px_1fr]",children:[e.jsxs("div",{className:"surface p-4",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.24em] text-flame",children:"template palette"}),e.jsx("p",{className:"mt-1.5 text-[12px] leading-relaxed text-sub",children:"Drag a card onto the canvas to lay down a fully-configured agent topology."}),e.jsx("div",{className:"mt-4 space-y-3",children:$e.map(x=>e.jsxs("button",{type:"button",draggable:!0,onDragStart:m=>{m.dataTransfer.setData("text/levelcode-sketch",x.name),m.dataTransfer.effectAllowed="copy",o(!0)},onDragEnd:()=>o(!1),onClick:()=>f(x),className:"group w-full cursor-grab rounded-md border border-rule bg-paper p-3 text-left transition-colors hover:border-flame/60 active:cursor-grabbing",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid h-7 w-7 place-items-center rounded border border-flame/30 bg-flame/10 font-mono text-[13px] text-flame",children:Nr[x.name]??"◆"}),e.jsx("span",{className:"font-display text-[13.5px] font-semibold leading-tight text-ink",children:x.name})]}),e.jsxs("p",{className:"mt-2 font-mono text-[10px] uppercase tracking-[0.14em] text-faint",children:[x.nodes.length," agents · ",x.edges.length," links · bytebytego"]}),e.jsx("span",{className:"mt-2 inline-block font-mono text-[10px] text-flame/70 group-hover:text-flame",children:"⠿ drag onto canvas →"})]},x.name))})]}),e.jsxs("div",{ref:g,onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy",c(!0)},onDragLeave:()=>c(!1),onDrop:w,className:`relative min-h-[440px] overflow-hidden rounded-xl border bg-[#f2f0ea] transition-colors ${d?"border-flame/70":"border-rule"}`,children:[e.jsx("div",{"aria-hidden":!0,className:"absolute inset-0",style:{backgroundImage:"radial-gradient(circle, rgba(27,26,23,0.13) 1px, transparent 1.4px)",backgroundSize:"22px 22px"}}),t&&e.jsxs("div",{className:"relative z-10 flex items-center gap-2 border-b border-rule bg-card/80 px-3 py-2 backdrop-blur-sm",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-[0.2em] text-flame",children:"goal"}),e.jsx("input",{value:s,onChange:x=>a(x.target.value),className:"min-w-0 flex-1 bg-transparent font-mono text-[12.5px] text-ink outline-none placeholder:text-faint",placeholder:"Describe what to build…"}),e.jsx("button",{type:"button",onClick:v,className:"shrink-0 rounded bg-flame px-3 py-1 font-mono text-[11px] font-semibold text-paper transition-colors hover:bg-flamedeep",children:"▶ Run"})]}),!t&&e.jsx("div",{className:"relative z-10 grid h-full min-h-[440px] place-items-center px-6 text-center",children:e.jsxs("div",{children:[e.jsx("div",{className:`mx-auto mb-4 grid h-14 w-14 place-items-center rounded-lg border-2 border-dashed transition-colors ${n||d?"border-flame text-flame":"border-faint/50 text-faint"}`,children:"⠿"}),e.jsx("p",{className:"font-display text-[15px] font-semibold text-ink",children:"Drop a template here"}),e.jsx("p",{className:"mx-auto mt-1.5 max-w-xs text-[12.5px] leading-relaxed text-sub",children:"Drag a template card in — or just click it — to materialise the full topology."})]})}),t&&e.jsx("div",{className:"relative z-10 w-full overflow-auto p-3",children:e.jsxs("div",{className:"relative",style:{width:t.w,height:t.h},children:[e.jsx("svg",{className:"pointer-events-none absolute inset-0 h-full w-full",viewBox:`0 0 ${t.w} ${t.h}`,children:t.edges.map((x,m)=>{const b=y(x.from),S=y(x.to);if(!b||!S)return null;const h=b.x+kr,T=b.y+re,A=S.x,q=S.y+re;return e.jsx("path",{d:`M${h},${T} C ${h+70},${T} ${A-70},${q} ${A},${q}`,fill:"none",stroke:"#b9b4a8",strokeWidth:1.5},m)})}),t.nodes.map(x=>{const m=jr[x.color],b=p.has(x.id);return e.jsxs("div",{className:`sb-node absolute w-[200px] rounded-lg border bg-white p-3 shadow-[0_2px_10px_rgba(27,26,23,0.08)] ${b?"sb-node--running":""}`,style:{left:x.x,top:x.y,borderColor:b?"transparent":"#e2ddd2"},children:[b&&e.jsx("svg",{"aria-hidden":!0,className:"pointer-events-none absolute inset-0 h-full w-full overflow-visible",children:e.jsx("rect",{className:"sb-ants",x:"0.75",y:"0.75",rx:"8",fill:"none",stroke:"#65a34a",strokeWidth:"1.5",strokeDasharray:"6 6",style:{width:"calc(100% - 1.5px)",height:"calc(100% - 1.5px)"}})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 shrink-0 rounded-[3px] ${b?"sb-pulse":""}`,style:{background:b?"#65a34a":m}}),e.jsx("span",{className:"truncate text-[13px] font-semibold text-[#2a2822]",children:x.label}),b?e.jsx("span",{className:"ml-auto shrink-0 font-mono text-[9px] uppercase tracking-[0.14em] text-[#65a34a]",children:"running"}):e.jsx("span",{"aria-hidden":!0,className:"ml-auto h-1.5 w-1.5 shrink-0 rounded-full bg-[#3f3c34]/50"})]}),e.jsxs("p",{className:"mt-1 text-[11px] text-[#8a8578]",children:["tier: ",x.tier]}),e.jsx("span",{"aria-hidden":!0,className:"absolute -left-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:re-5}}),e.jsx("span",{"aria-hidden":!0,className:"absolute -right-[5px] h-2.5 w-2.5 rounded-full border-2 border-[#8a8578] bg-white",style:{top:re-5}})]},x.id)})]})}),t&&e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute bottom-3 right-3 z-10 flex items-center gap-1.5 font-mono text-[11px] text-sub",children:["−","99%","+","⤢","⇄ Tidy"].map(x=>e.jsx("span",{className:"rounded-md border border-[#e2ddd2] bg-white px-2 py-1 shadow-sm",children:x},x))})]})]})}const O="https://github.com/levelcodeai/levelcode",Xe=`${O}/releases/latest`,De=`${Xe}/download/LevelCode-arm64.dmg`,Pe=`${Xe}/download/LevelCode-x64.dmg`,Ie="0.9.2";function Sr(){const[t,r]=l.useState(()=>{try{return sessionStorage.getItem("lc-latest-version")||Ie}catch{return Ie}});return l.useEffect(()=>{try{if(sessionStorage.getItem("lc-latest-version"))return}catch{}let s=!0;return fetch("https://api.github.com/repos/levelcodeai/levelcode/releases/latest",{headers:{Accept:"application/vnd.github+json"}}).then(a=>a.ok?a.json():null).then(a=>{const n=String((a==null?void 0:a.tag_name)??"").replace(/^v/,"");if(s&&n){r(n);try{sessionStorage.setItem("lc-latest-version",n)}catch{}}}).catch(()=>{}),()=>{s=!1}},[]),t}function Re(){const t=Sr(),{profile:r}=U(),[s]=l.useState(Ke);return e.jsxs(D,{strip:!0,children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 pb-14 pt-10",children:[e.jsxs("header",{className:"flex flex-col items-center gap-10 md:flex-row md:items-center md:justify-between",children:[e.jsx("div",{"aria-hidden":!0,className:"relative h-[280px] w-[300px] shrink-0",children:e.jsxs("svg",{viewBox:"0 0 300 280",className:"h-full w-full",children:[e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"118",cy:"128",r:"104",fill:"var(--c-accent)",opacity:"0.14"})}),e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"186",cy:"104",r:"86",fill:"#7d6bff",opacity:"0.16"})}),e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"120",cy:"180",r:"72",fill:"#5fb4ff",opacity:"0.18"})}),e.jsx("g",{className:"portal-layer",children:e.jsx("circle",{cx:"204",cy:"182",r:"58",fill:"#a8ecff",opacity:"0.28"})}),e.jsxs("g",{className:"portal-layer",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M96 196 L152 152 L208 196",stroke:"#5b3fd6",strokeWidth:"21",opacity:"0.55"}),e.jsx("path",{d:"M96 152 L152 108 L208 152",stroke:"#7d6bff",strokeWidth:"21",opacity:"0.8"}),e.jsx("path",{d:"M96 108 L152 64 L208 108",stroke:"#5fb4ff",strokeWidth:"21"})]})]})}),e.jsxs("ul",{className:"w-full max-w-sm space-y-3 text-center md:text-left",children:[e.jsxs("li",{className:"text-[34px] font-bold leading-none tracking-tight text-[var(--c-text)]",children:["Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsxs("li",{className:"text-[14px]",children:[e.jsx("span",{className:"mr-2 font-mono font-semibold text-[var(--c-text)]",children:t}),e.jsx("a",{href:`${O}/releases/tag/v${t}`,className:"text-[var(--c-accent)] hover:underline",children:"Release notes"})]}),e.jsxs("li",{className:"pt-1",children:[e.jsx("span",{className:"block font-semibold text-[var(--c-text)]",children:"macOS"}),e.jsx("span",{className:"text-[13px] text-[var(--c-text3)]",children:s?"For Apple Silicon and Intel Macs":"LevelCode is a desktop editor for Apple Silicon and Intel Macs"})]}),s?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:e.jsxs("a",{href:De,className:"classic-button w-full",download:!0,children:[e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M7.47 10.78a.75.75 0 0 0 1.06 0l3.75-3.75a.75.75 0 0 0-1.06-1.06L8.75 8.44V1.75a.75.75 0 0 0-1.5 0v6.69L4.78 5.97a.75.75 0 0 0-1.06 1.06l3.75 3.75ZM3.75 13a.75.75 0 0 0 0 1.5h8.5a.75.75 0 0 0 0-1.5h-8.5Z"})}),"Download"]})}),e.jsxs("li",{className:"text-[13px] text-[var(--c-text3)]",children:["Intel Mac?"," ",e.jsx("a",{href:Pe,className:"text-[var(--c-accent)] hover:underline",download:!0,children:"Download x64"})," · ",e.jsx("a",{href:`${O}/releases`,className:"text-[var(--c-accent)] hover:underline",children:"Other builds"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:e.jsx(C,{to:r?"/account":"/login",className:"classic-button w-full",children:r?"Your account":"Sign in"})}),e.jsxs("li",{className:"text-[13px] text-[var(--c-text3)]",children:["Open this page on your Mac to download, or see"," ",e.jsx("a",{href:`${O}/releases`,className:"text-[var(--c-accent)] hover:underline",children:"all builds"}),"."]})]}),e.jsxs("li",{className:"text-[13px] text-[var(--c-text3)]",children:["Free and open source under the"," ",e.jsx("a",{href:`${O}/blob/HEAD/LICENSE`,className:"text-[var(--c-accent)] hover:underline",children:"MIT license"}),".",s?" No account required.":""]})]})]}),e.jsxs("h1",{className:"mx-auto mt-12 max-w-3xl text-center text-[34px] font-bold leading-tight tracking-tight text-[var(--c-text)] text-balance sm:text-[42px]",children:["A hackable editor for the ",e.jsx("span",{className:"text-[var(--c-accent)]",children:"AI era"})]})]})}),e.jsx("section",{id:"agent",className:"border-b border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Agent for LevelCode"}),e.jsx("p",{className:"mt-3 max-w-3xl pretty",children:"Great software happens when the editor works with you. The LevelCode agent plans, edits across files, runs commands, and verifies its own work — right in your editor, on your own API key, with no middleman between you and the model."}),e.jsx("div",{className:"mt-8",children:e.jsx(br,{})}),e.jsx("p",{className:"mt-8 max-w-3xl pretty",children:"Every edit lands as a reviewable Keep/Undo change. Every command waits at an approval gate. Before the agent says done, it checks diagnostics and runs your tests — and every turn is a checkpoint you can rewind."}),e.jsx("p",{className:"mt-6",children:e.jsx("a",{href:"#download",className:"classic-button",children:"Download for macOS"})})]})}),e.jsx("section",{id:"sketches",className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Sketches for LevelCode"}),e.jsx("p",{className:"mt-3 max-w-3xl pretty",children:"Some systems are too big for one prompt. Sketches let you drag a whole agent topology onto a canvas — eleven wired agents for a key-value store, a full leaderboard build — set the goal, hit Run, and watch them light up in order."}),e.jsx("div",{className:"classic-demo-sketch mt-8",children:e.jsx(Cr,{})}),e.jsx("p",{className:"mt-8",children:e.jsx("a",{href:`${O}/tree/HEAD/docs`,className:"classic-button--quiet",children:"Learn more"})})]})}),e.jsx("section",{className:"border-b border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-center text-[26px] font-semibold text-[var(--c-text)]",children:"Everything you would expect"}),e.jsx("div",{className:"mt-10 grid gap-x-10 gap-y-10 sm:grid-cols-2 lg:grid-cols-3",children:Lr.map(a=>e.jsxs("div",{className:"text-center sm:text-left",children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:a.icon}),e.jsx("h4",{className:"mt-3 text-[17px] font-semibold text-[var(--c-text)]",children:a.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:a.body})]},a.title))})]})}),e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-14",children:[e.jsx("h3",{className:"text-center text-[26px] font-semibold text-[var(--c-text)]",children:"Make it your editor"}),e.jsx("div",{className:"mt-10 grid gap-x-10 gap-y-10 sm:grid-cols-2",children:_r.map(a=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[var(--c-accent)]",children:a.icon}),e.jsx("h4",{className:"mt-3 text-[17px] font-semibold text-[var(--c-text)]",children:a.title}),e.jsx("p",{className:"mt-1.5 text-[15px] pretty",children:a.body})]},a.title))})]})}),e.jsx("section",{id:"download",className:"scroll-mt-14 border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-20 text-center",children:[e.jsx("svg",{viewBox:"0 0 120 120",width:"64",height:"64",className:"mx-auto","aria-hidden":!0,children:e.jsxs("g",{fill:"none",stroke:"var(--c-accent)",strokeWidth:"13",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M28 92 L60 69 L92 92",opacity:"0.4"}),e.jsx("path",{d:"M28 68 L60 45 L92 68",opacity:"0.7"}),e.jsx("path",{d:"M28 44 L60 21 L92 44"})]})}),e.jsx("h2",{className:"mt-4 text-[34px] font-bold tracking-tight text-[var(--c-text)] text-balance sm:text-[42px]",children:"Download LevelCode"}),e.jsxs("p",{className:"mt-2 font-mono text-[14px] text-[var(--c-text3)]",children:["v",t," ·"," ",e.jsx("a",{href:`${O}/releases/tag/v${t}`,className:"text-[var(--c-accent)] hover:underline",children:"Release notes"})]}),e.jsx("p",{className:"mx-auto mt-4 max-w-xl text-[17px] pretty",children:"Free and open. Drag the .dmg to Applications, add a key — or run fully offline on local Ollama — and the editor starts editing with you."}),e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-4",children:[e.jsxs("a",{href:De,className:"classic-button px-10 py-4 text-[17px]",download:!0,children:[e.jsx(Oe,{}),"Download for Apple Silicon"]}),e.jsxs("a",{href:Pe,className:"classic-button--quiet px-10 py-4 text-[17px]",download:!0,children:[e.jsx(Oe,{}),"Intel Mac"]})]}),e.jsxs("p",{className:"mt-6 text-[14px] text-[var(--c-text3)]",children:["free · MIT · no account required ·"," ",e.jsx("a",{href:`${O}/releases`,className:"text-[var(--c-accent)] hover:underline",children:"all releases →"})]})]})}),e.jsx("section",{className:"border-b border-[var(--c-line)]",children:e.jsxs("div",{className:"mx-auto grid max-w-5xl gap-12 px-5 py-14 md:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Open source"}),e.jsx("p",{className:"mt-3 pretty",children:"LevelCode is open source, built on Code-OSS and released under MIT. Be part of the community — or help improve your favorite editor."}),e.jsx("p",{className:"mt-5",children:e.jsxs("a",{href:O,className:"classic-button",children:[e.jsx(Mr,{}),"Fork on GitHub"]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[26px] font-semibold text-[var(--c-text)]",children:"Keep in touch"}),e.jsx("table",{className:"mt-4 w-full text-[15px]",children:e.jsx("tbody",{children:Tr.map(a=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-0",children:[e.jsx("td",{className:"py-2 pr-6 text-[var(--c-text3)]",children:a.label}),e.jsx("td",{className:"py-2",children:a.to?e.jsx(C,{to:a.to,className:"text-[var(--c-accent)] hover:underline",children:a.text}):e.jsx("a",{href:a.href,className:"text-[var(--c-accent)] hover:underline",children:a.text})})]},a.label))})})]})]})})]})}const Lr=[{title:"Native AI agent",body:"Chat, edit, autocomplete, and a full agent mode — first-class in the editor, not a bolted-on plugin. Bring your own key or run local Ollama.",icon:e.jsx(B,{d:"M13 1 3.5 12.5h5L7 23l9.5-11.5h-5L13 1Z",filled:!0})},{title:"Power editing",body:"The Notepad++ toolkit: keystroke macros, line operations, column mode with incrementing numbers, encoding and EOL control, huge-file mode.",icon:e.jsx(B,{d:"M4 5h16M4 9h10M4 13h16M4 17h7"})},{title:"Smart autocompletion",body:"Debounced ghost text over every file, cancelled the instant you keep typing — routed to a fast model per provider.",icon:e.jsx(B,{d:"M12 3a6 6 0 0 1 3.5 10.9c-.6.45-1 1.1-1 1.85V17h-5v-1.25c0-.75-.4-1.4-1-1.85A6 6 0 0 1 12 3ZM10 20h4"})},{title:"Built-in package manager",body:"Thousands of open-source extensions from Open VSX — search, install, and update without leaving the editor.",icon:e.jsx(B,{d:"M12 3 4 7v10l8 4 8-4V7l-8-4Zm0 0v8m8-4-8 4M4 7l8 4"})},{title:"Multiple panes",body:"Split the interface into panes to compare and edit code across files — plus a real approval-gated terminal.",icon:e.jsx(B,{d:"M4 5h16v14H4V5Zm8 0v14"})},{title:"Find and replace",body:"Find, preview, and replace as you type — in a file or across every project, powered by ripgrep.",icon:e.jsx(B,{d:"M10.5 4a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13Zm5.2 11.7L20 20"})}],_r=[{title:"Packages",body:"Choose from thousands of open-source packages on Open VSX that add features and functionality — or build one from scratch with the live package-dev loop.",icon:e.jsx(B,{d:"M12 3 4 7v10l8 4 8-4V7l-8-4Zm0 0v8m8-4-8 4M4 7l8 4"})},{title:"Themes",body:"One Dark ships built in — Atom's own palette lives on in the editor. Install community themes or restyle everything with CSS.",icon:e.jsx(B,{d:"M12 3a9 9 0 1 0 0 18c1.5 0 2-1 1.4-2-.5-.9-.2-2 .9-2H16a5 5 0 0 0 5-5c0-5-4-9-9-9Zm-4.5 9a1.2 1.2 0 1 1 0-2.4 1.2 1.2 0 0 1 0 2.4Zm3-4a1.2 1.2 0 1 1 0-2.4 1.2 1.2 0 0 1 0 2.4Zm5 0a1.2 1.2 0 1 1 0-2.4 1.2 1.2 0 0 1 0 2.4Z"})},{title:"Customization",body:"An init script that runs at boot and hot-reloads on save, keymap presets for Atom, Sublime, and Notepad++ muscle memory, and skills that teach the agent your workflows.",icon:e.jsx(B,{d:"M14.5 4.5a4 4 0 0 0-5.4 4.8L3 15.4V19h3.6l6.1-6.1a4 4 0 0 0 4.8-5.4l-2.6 2.6-2.4-2.4 2-2.2Z"})},{title:"Under the hood",body:"A desktop app built on Code-OSS and Electron — the same battle-tested core as VS Code, bent back toward Atom's hackable soul. MIT, forkable, yours.",icon:e.jsx(B,{d:"M9 5 3 12l6 7m6-14 6 7-6 7"})}],Tr=[{label:"GitHub",href:"https://github.com/levelcodeai",text:"github.com/levelcodeai"},{label:"Discussions",href:`${O}/discussions`,text:"GitHub Discussions"},{label:"Releases",href:`${O}/releases`,text:"Release notes & builds"},{label:"Cloud",to:"/pricing",text:"Plans & pricing"}];function B({d:t,filled:r=!1}){return e.jsx("svg",{viewBox:"0 0 24 24",width:"30",height:"30",fill:r?"currentColor":"none",stroke:r?"none":"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,className:"inline-block",children:e.jsx("path",{d:t})})}function Oe(){return e.jsx("svg",{viewBox:"0 0 814 1000",width:"14",height:"14",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M788 341c-6 4-107 61-107 187 0 146 128 198 132 199-1 3-20 70-67 138-42 60-86 120-153 120s-84-39-161-39c-75 0-102 40-163 40s-104-56-153-124C60 782 13 660 13 544c0-186 121-285 240-285 63 0 116 42 156 42 38 0 97-44 169-44 27 0 125 2 210 84zM554 172c31-37 53-88 53-139 0-7-1-14-2-20-50 2-110 34-146 76-29 32-55 83-55 135 0 8 1 16 2 18 3 1 8 2 13 2 45 0 102-30 135-72z"})})}function Mr(){return e.jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})})}const Je="lc_attribution",Qe=["linkedin","youtube","ref","utm_source","utm_medium","utm_campaign","utm_content"],et=120,Ar=40,le=300,Er=40;function $r(t){if(!t||typeof t!="object")return null;const r=t,s={},a=r.params;if(a&&typeof a=="object")for(const d of Qe){const c=a[d];typeof c=="string"&&c&&(s[d]=c.slice(0,et))}const n=typeof r.source=="string"?r.source.slice(0,Ar):"";if(Object.keys(s).length===0&&!n)return null;const o=(d,c)=>typeof d=="string"?d.slice(0,c):"";return{source:n||"other",params:s,landing:o(r.landing,le),referrer:o(r.referrer,le),ts:o(r.ts,Er)}}function tt(){try{const t=localStorage.getItem(Je);return t?$r(JSON.parse(t)):null}catch{return null}}function Dr(){if(!(typeof window>"u"))try{if(tt())return;const t=new URLSearchParams(window.location.search),r={};for(const n of Qe){const o=t.get(n);o&&(r[n]=o.slice(0,et))}if(Object.keys(r).length===0)return;const a={source:r.linkedin?"linkedin":r.youtube?"youtube":r.utm_source||r.ref||"other",params:r,landing:window.location.pathname.slice(0,le),referrer:(document.referrer||"").slice(0,le),ts:new Date().toISOString()};localStorage.setItem(Je,JSON.stringify(a))}catch{}}function rt(){return typeof window>"u"?null:tt()}function Pr({redirectUri:t,codeChallenge:r}){const[s,a]=l.useState("email"),[n,o]=l.useState(""),[d,c]=l.useState(""),[p,u]=l.useState(!1),[g,i]=l.useState(null);async function f(w){w.preventDefault(),u(!0),i(null);try{await E("/ai/auth/email",{body:{email:n}}),a("code")}catch(y){i(y instanceof z?y.message:"Couldn't send a code. Try again.")}finally{u(!1)}}async function v(w){w.preventDefault(),u(!0),i(null);try{const y=await E("/ai/auth/verify",{body:{email:n,code:d,redirect_uri:t,code_challenge:r,attribution:rt()}});if(!y.redirect)throw new z(422,"That code is invalid or has expired.");if(!y.redirect.startsWith("/")){const x=window.setTimeout(()=>{u(!1),i("Open LevelCode to finish signing in. If nothing happened, the editor may not be installed on this device.")},1500);window.addEventListener("pagehide",()=>window.clearTimeout(x),{once:!0}),K(y.redirect);return}K(y.redirect)}catch(y){i(y instanceof z?y.message:"That code is invalid or has expired."),u(!1)}}return s==="email"?e.jsxs("form",{onSubmit:f,className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Email"}),e.jsx("input",{type:"email",required:!0,autoFocus:!0,autoComplete:"email",value:n,onChange:w=>o(w.target.value),placeholder:"you@studio.dev",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-[15px] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),g?e.jsx("p",{className:"text-[13px] text-red-500",children:g}):null,e.jsx("button",{type:"submit",disabled:p,className:"classic-button w-full",children:p?"Sending…":"Email me a sign-in code"})]}):e.jsxs("form",{onSubmit:v,className:"flex flex-col gap-3",children:[e.jsxs("p",{className:"text-[13px]",children:["We sent a 6-digit code to ",e.jsx("span",{className:"font-medium text-[var(--c-text)]",children:n}),". Enter it below."]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest text-[var(--c-text3)]",children:"Verification code"}),e.jsx("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]*",maxLength:6,required:!0,autoFocus:!0,value:d,onChange:w=>c(w.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"rounded-[4px] border border-[var(--c-line)] bg-[var(--c-bg)] px-3 py-2.5 text-center font-mono text-[22px] font-semibold tracking-[0.4em] text-[var(--c-text)] outline-none transition-colors focus:border-[var(--c-accent)]"})]}),g?e.jsx("p",{className:"text-[13px] text-red-500",children:g}):null,e.jsx("button",{type:"submit",disabled:p||d.length<6,className:"classic-button w-full",children:p?"Verifying…":"Verify & continue"}),e.jsxs("div",{className:"flex items-center justify-between text-[13px]",children:[e.jsx("button",{type:"button",onClick:f,disabled:p,className:"text-[var(--c-accent)] hover:underline",children:"Resend code"}),e.jsx("button",{type:"button",onClick:()=>{a("email"),c(""),i(null)},className:"text-[var(--c-accent)] hover:underline",children:"Use a different email"})]})]})}function Ir({redirectUri:t,codeChallenge:r}){return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Be,{provider:"google",label:"Continue with Google",redirectUri:t,codeChallenge:r,children:e.jsx(Or,{})}),e.jsx(Be,{provider:"github",label:"Continue with GitHub",redirectUri:t,codeChallenge:r,children:e.jsx(Br,{})})]})}function Be({provider:t,label:r,redirectUri:s,codeChallenge:a,children:n}){return e.jsxs("a",{href:Rr(t,s,a),className:"classic-button--quiet w-full gap-2.5",children:[n,r]})}function Rr(t,r,s){const a=new URLSearchParams;r&&s&&(a.set("redirect_uri",r),a.set("code_challenge",s));const n=rt();n&&a.set("attribution",JSON.stringify({source:n.source,params:n.params,landing:n.landing,ts:n.ts}));const o=a.toString();return`${ye}/ai/auth/oauth/${t}${o?`?${o}`:""}`}function Or(){return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18","aria-hidden":"true",className:"shrink-0",children:[e.jsx("path",{fill:"#4285F4",d:"M17.64 9.2045c0-.6381-.0573-1.2518-.1636-1.8409H9v3.4814h4.8436c-.2086 1.125-.8427 2.0782-1.7959 2.7164v2.2581h2.9086c1.7018-1.5668 2.6837-3.874 2.6837-6.615z"}),e.jsx("path",{fill:"#34A853",d:"M9 18c2.43 0 4.4673-.806 5.9564-2.1805l-2.9086-2.2581c-.8059.54-1.8368.859-3.0478.859-2.344 0-4.3282-1.5832-5.036-3.7105H.9573v2.3318C2.4382 15.9832 5.4818 18 9 18z"}),e.jsx("path",{fill:"#FBBC05",d:"M3.964 10.71c-.18-.54-.2822-1.1168-.2822-1.71s.1023-1.17.2823-1.71V4.9582H.9573C.3477 6.1732 0 7.5477 0 9s.3477 2.8268.9573 4.0418L3.964 10.71z"}),e.jsx("path",{fill:"#EA4335",d:"M9 3.5795c1.3214 0 2.5077.4541 3.4405 1.346l2.5813-2.5814C13.4636.8918 11.426 0 9 0 5.4818 0 2.4382 2.0168.9573 4.9582L3.964 7.29C4.6718 5.1627 6.656 3.5795 9 3.5795z"})]})}function Br(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",className:"shrink-0",children:e.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}const qr={session_expired:"Your sign-in session expired. Please try again.",link_expired:"That sign-in link expired. Please try again from the editor."};function Fr(){const t=X(),[r]=ct(),s=r.get("redirect_uri"),a=r.get("code_challenge"),n=r.get("error"),o=s&&a?{redirectUri:s,codeChallenge:a}:null,d=!!o,{loading:c,profile:p}=U(),[u,g]=l.useState("idle");return l.useEffect(()=>{if(!c){if(!p){g("form");return}if(s&&a){g("completing");let i=!0;return E("/ai/authorize_editor",{method:"POST",body:{redirect_uri:s,code_challenge:a}}).then(f=>{i&&(f.redirect?K(f.redirect):g("form"))}).catch(()=>{i&&g("form")}),()=>{i=!1}}t("/account",{replace:!0})}},[c,p,s,a,t]),u==="completing"?e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-24",children:e.jsxs("div",{className:"w-full max-w-md rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-[var(--c-text)]",children:"Opening LevelCode…"}),e.jsx("p",{className:"mt-3 text-[14px] pretty",children:"Signing the editor into your account. You can return to LevelCode — this tab can be closed."})]})})}):u!=="form"?e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex min-h-[60vh] max-w-5xl flex-col px-5 py-24"})}):e.jsx(D,{children:e.jsx("main",{className:"mx-auto flex max-w-5xl flex-col items-center px-5 py-16",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block",children:e.jsx(vt,{})}),e.jsxs("h1",{className:"mt-3 text-[28px] font-bold tracking-tight text-[var(--c-text)]",children:["Sign in to Level",e.jsx("span",{className:"text-[var(--c-accent)]",children:"Code"})]}),e.jsx("p",{className:"mt-2 text-[15px] pretty",children:d?"Connect the editor to your account — you'll be sent back to LevelCode when you're done.":"Manage your plan, keys, and usage."})]}),e.jsxs("div",{className:"mt-8 rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-7",children:[n?e.jsx("div",{role:"alert",className:"mb-5 rounded-[4px] border border-red-500/50 bg-red-500/10 px-4 py-3 text-[13px] text-red-500",children:qr[n]??"Sign-in failed. Please try again."}):null,e.jsx(Ir,{redirectUri:o==null?void 0:o.redirectUri,codeChallenge:o==null?void 0:o.codeChallenge}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-[var(--c-text3)]","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",children:"or"}),e.jsx("span",{className:"flex-1 border-t border-[var(--c-line)]"})]}),e.jsx(Pr,{redirectUri:o==null?void 0:o.redirectUri,codeChallenge:o==null?void 0:o.codeChallenge})]}),e.jsxs("p",{className:"mt-5 text-center text-[13px] text-[var(--c-text3)]",children:["By continuing you agree to the"," ",e.jsx(C,{to:"/terms",className:"text-[var(--c-accent)] hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx(C,{to:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),". Bring your own key — we never resell provider access."]})]})})})}function Ur({tiers:t,authed:r,currentPlan:s}){const a=X(),[n,o]=l.useState(null),[d,c]=l.useState(null),p=i=>(i??"").trim().toLowerCase(),u=i=>r&&!!s&&p(s)===p(i.name);async function g(i){if(c(null),!r){a("/login");return}o(i.key);try{const f=await E("/ai/checkout",{body:{lookup_key:i.key}});if(f.url){K(f.url);return}if(f.status==="plan_changed"){a("/account?checkout=changed");return}c("Could not start checkout."),o(null)}catch(f){c(f instanceof z?f.message:"Could not start checkout."),o(null)}}return e.jsxs(e.Fragment,{children:[d?e.jsx("p",{className:"mb-4 text-center text-[13px] text-red-500",role:"alert",children:d}):null,e.jsx("div",{className:"grid gap-5 sm:grid-cols-2 lg:grid-cols-4",children:t.map((i,f)=>{const v=f===1,w=u(i);return e.jsxs("div",{className:`flex flex-col rounded-md border bg-[var(--c-bg)] p-6 ${w||v?"border-[var(--c-accent)]":"border-[var(--c-line)]"} ${w?"shadow-[0_0_0_1px_var(--c-accent)]":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-[var(--c-text)]",children:i.name}),w?e.jsx("span",{className:"rounded-[3px] bg-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-white",children:"current"}):v?e.jsx("span",{className:"rounded-[3px] border border-[var(--c-accent)] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-[var(--c-accent)]",children:"popular"}):null]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-bold tracking-tight text-[var(--c-text)]",children:Hr(i.price_cents)}),e.jsxs("span",{className:"text-sm text-[var(--c-text3)]",children:["/",i.interval||"mo"]})]}),e.jsxs("dl",{className:"mt-5 space-y-1.5 font-mono text-[12px] text-[var(--c-text2)]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"input"}),e.jsx("dd",{className:"tabular-nums",children:qe(i.input_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"output"}),e.jsx("dd",{className:"tabular-nums",children:qe(i.output_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-[var(--c-text3)]",children:"turns"}),e.jsx("dd",{className:"tabular-nums",children:(i.turns??0).toLocaleString()})]})]}),e.jsx("ul",{className:"mt-5 flex-1 space-y-2 text-[13px] text-[var(--c-text2)]",children:(i.features??[]).map(y=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"mt-1.5 h-1 w-1 flex-none rounded-full bg-[var(--c-accent)]"}),e.jsx("span",{className:"pretty",children:y})]},y))}),w?e.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"classic-button--quiet mt-6 w-full cursor-default opacity-70",children:"✓ Current plan"}):e.jsx("button",{onClick:()=>g(i),disabled:n===i.key,className:`mt-6 w-full ${v?"classic-button":"classic-button--quiet"}`,children:n===i.key?"Starting…":r?"Choose plan":"Sign in to start"})]},i.key)})})]})}function Hr(t){const r=t/100;return`$${r%1===0?r.toFixed(0):r.toFixed(2)}`}function qe(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString()}function Wr(){const{profile:t}=U(),[r,s]=l.useState([]),[a,n]=l.useState(null);return l.useEffect(()=>{let o=!0;return E("/api/levelcode/v1/pricing").then(d=>{o&&s(d.tiers??[])}).catch(()=>{o&&n("Pricing is temporarily unavailable. Please try again shortly.")}),()=>{o=!1}},[]),e.jsxs(D,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:"Plans that scale as you ship"}),e.jsx("p",{className:"mx-auto mt-3 max-w-xl pretty",children:"Every plan is bring-your-own-key by default — free, forever. Switch on the gateway and your monthly credit is all you pay; we never mark up the provider."})]})}),e.jsx("section",{children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-12",children:[a?e.jsx("div",{className:"rounded-md border border-[var(--c-line)] bg-[var(--c-surface)] p-8 text-center text-[15px]",children:a}):e.jsx(Ur,{tiers:r,authed:!!t,currentPlan:(t==null?void 0:t.plan)??null}),e.jsx("p",{className:"mt-10 text-center text-[13px] text-[var(--c-text3)]",children:"All plans include the full editor — it’s free and open source. Plans meter the managed AI gateway only."})]})})]})}function at({title:t,updated:r,intro:s,children:a}){return e.jsxs(D,{children:[e.jsx("section",{className:"border-b border-[var(--c-line)] bg-[var(--c-surface)]",children:e.jsxs("div",{className:"mx-auto max-w-3xl px-5 py-10 text-center",children:[e.jsx("h1",{className:"text-[30px] font-bold tracking-tight text-[var(--c-text)] sm:text-[36px]",children:t}),e.jsxs("p",{className:"mt-2 text-[13px] text-[var(--c-text3)]",children:["Last updated: ",r]})]})}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-12",children:[e.jsx("p",{className:"text-[16px] leading-relaxed pretty",children:s}),e.jsx("div",{className:"mt-10 space-y-9",children:a})]})]})}function _({id:t,heading:r,children:s}){return e.jsxs("section",{id:t,className:"scroll-mt-24",children:[e.jsx("h2",{className:"text-xl font-semibold tracking-tight text-[var(--c-text)]",children:r}),e.jsx("div",{className:"mt-3 space-y-3 text-[15px] leading-relaxed pretty",children:s})]})}function Yr(){return e.jsxs(at,{title:"Privacy Policy",updated:"July 9, 2026",intro:e.jsx(e.Fragment,{children:"This policy explains what LevelCode collects, how we use it, and who we share it with when you use the LevelCode editor and LevelCode Cloud (levelcode.ai). The most important thing to know: to generate AI responses, we send your prompts and selected code to third-party model providers."}),children:[e.jsxs(_,{id:"collect",heading:"1. What we collect",children:[e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Account"})," — your email and basic profile, and the authentication tokens the editor uses to talk to the service."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Prompts & code"})," — the prompts and code you submit to the AI gateway, so we can generate responses and meter usage."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Usage & billing"})," — model used, token counts, timestamps, plan, and spend, used to meter your allowance and support billing. Payments are handled by Stripe; we do not receive or store your full card number."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Technical"})," — IP address, device/browser info, and server logs, used for security and to operate the Service."]})]}),e.jsx("p",{children:"Product telemetry in the editor is off by default. If you use bring-your-own-key (BYOK), those requests go directly to your provider and your prompts and code do not pass through our gateway."})]}),e.jsx(_,{id:"use",heading:"2. How we use it",children:e.jsx("p",{children:"To provide, secure, and improve the Service — including generating AI responses, metering your usage against your plan, processing subscriptions, providing support, preventing abuse, and meeting legal obligations. We do not sell your personal information, and we do not use the content of your prompts or code to advertise to you."})}),e.jsxs(_,{id:"share",heading:"3. Who we share it with",children:[e.jsx("p",{children:"We share information only with service providers that help us run LevelCode:"}),e.jsxs("ul",{className:"list-disc space-y-1.5 pl-5",children:[e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"AI model providers & routing"})," — your prompts and selected code are sent to the AI provider(s) that generate your response, via our routing partner. They process this content to return a result and under their own terms and privacy policies."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Payments"})," — Stripe, to process subscriptions and payments."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-[var(--c-text)]",children:"Hosting & infrastructure"})," — our cloud hosting provider, which stores and serves the Service on our behalf."]})]}),e.jsx("p",{children:"We may also disclose information if required by law, to enforce our terms, or to protect the rights, safety, and security of LevelCode and its users. If we’re involved in a merger or acquisition, your information may transfer as part of that transaction."})]}),e.jsx(_,{id:"retention",heading:"4. Retention",children:e.jsxs("p",{children:["We keep account and billing records for as long as your account is active and as needed to meet legal, tax, and security obligations. Prompts, code, and usage records are retained only as long as needed to operate the Service and support your account, after which they are deleted or anonymized."," "]})}),e.jsx(_,{id:"cookies",heading:"5. Cookies",children:e.jsx("p",{children:"We use strictly necessary cookies to keep you signed in and to operate the site. We do not use third-party advertising cookies. Your browser settings let you control cookies, though the Service may not work properly without the essential ones."})}),e.jsx(_,{id:"security",heading:"6. Security",children:e.jsx("p",{children:"We use technical and organizational measures — including encryption in transit and access controls — to protect your information. No method of transmission or storage is perfectly secure, so we cannot guarantee absolute security."})}),e.jsx(_,{id:"rights",heading:"7. Your rights",children:e.jsx("p",{children:"Depending on where you live (for example, under GDPR or the CCPA), you may have the right to access, correct, delete, or export your personal information, and to object to or restrict certain processing. To make a request, email us at the address below; we will respond as required by applicable law."})}),e.jsx(_,{id:"children",heading:"8. Children",children:e.jsx("p",{children:"The Service is not directed to children under 13, and we do not knowingly collect their personal information. If you believe a child has provided us information, contact us and we will delete it."})}),e.jsx(_,{id:"international",heading:"9. International transfers",children:e.jsx("p",{children:"We and our providers may process your information in countries other than yours. Where required, we rely on appropriate safeguards for such transfers."})}),e.jsx(_,{id:"changes",heading:"10. Changes",children:e.jsx("p",{children:"We may update this policy from time to time. Material changes will be reflected in the date above and, where appropriate, communicated to you."})}),e.jsx(_,{id:"contact",heading:"11. Contact",children:e.jsxs("p",{children:["Privacy questions or requests? Email"," ",e.jsx("a",{href:"mailto:privacy@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"privacy@levelcode.ai"}),"."]})})]})}function st(t){const r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${r}-${s}`}function Fe(t){const r=new Date;return r.setDate(r.getDate()-t),st(r)}const se=()=>st(new Date),Ue=/^\d{4}-\d{2}-\d{2}$/;function Vr(t,r){return!Ue.test(t)||!Ue.test(r)?"Pick both a start and an end date.":t>r?"The start date is after the end date.":r>se()?"The end date is in the future.":null}function Zr(){const t=X(),{loading:r,profile:s}=U(),[a,n]=l.useState(()=>Fe(29)),[o,d]=l.useState(se),[c,p]=l.useState(null),[u,g]=l.useState(null),[i,f]=l.useState(!0),v=(s==null?void 0:s.role)==="admin";l.useEffect(()=>{r||(s?v||t("/account",{replace:!0}):t("/login",{replace:!0}))},[r,s,v,t]);const w=Vr(a,o);if(l.useEffect(()=>{if(!v)return;if(w){f(!1);return}let x=!0;f(!0),g(null);const m=new URLSearchParams({from:a,to:o});return E(`/api/levelcode/v1/admin/referrals?${m.toString()}`).then(b=>{x&&(p(b),f(!1))}).catch(()=>{x&&(p(null),g("Couldn’t load the referral funnel."),f(!1))}),()=>{x=!1}},[v,a,o,w]),r||!v)return e.jsx(D,{children:e.jsx("main",{className:"mx-auto max-w-5xl px-5 py-12"})});const y=(c==null?void 0:c.rows)??[];return e.jsx(D,{children:e.jsxs("main",{className:"mx-auto max-w-5xl px-5 py-12",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[28px] font-bold tracking-tight text-[var(--c-text)] sm:text-[32px]",children:"Referrals"}),e.jsx("p",{className:"mt-2 text-[14px] text-[var(--c-text3)]",children:"clicks · signups · paid, per marketing channel"})]}),e.jsx(C,{to:"/admin",className:"text-[14px] text-[var(--c-text2)] hover:text-[var(--c-text)]",children:"← System dashboard"})]}),u?e.jsx("div",{className:"classic-card mt-8 p-6 text-[14px] text-red-500",children:u}):null,w?e.jsxs("div",{role:"alert",className:"mt-8 rounded-md border border-[#d19a66]/40 bg-[#d19a66]/[0.1] px-4 py-3 text-[14px] text-[var(--c-text)]",children:[w,c?" Showing the last loaded range below.":null]}):null,e.jsxs("div",{className:"mt-8 flex flex-wrap items-center gap-3",children:[e.jsx(He,{label:"from",value:a,max:o,onChange:n}),e.jsx(He,{label:"to",value:o,min:a,max:se(),onChange:d}),e.jsx("div",{className:"flex gap-2",children:[{label:"7d",days:6},{label:"30d",days:29},{label:"90d",days:89}].map(x=>e.jsx("button",{type:"button",onClick:()=>{n(Fe(x.days)),d(se())},className:"rounded-md border border-[var(--c-line)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text2)] transition-colors hover:border-[var(--c-accent)] hover:text-[var(--c-text)]",children:x.label},x.label))})]}),e.jsxs("div",{className:"mt-6 grid gap-4 sm:grid-cols-3",children:[e.jsx(ge,{label:"clicks",value:c==null?void 0:c.totals.clicks}),e.jsx(ge,{label:"signups",value:c==null?void 0:c.totals.signups}),e.jsx(ge,{label:"paid",value:c==null?void 0:c.totals.paid})]}),c?e.jsxs("p",{className:"mt-3 font-mono text-[12px] text-[var(--c-text3)]",children:["covering ",c.from," → ",c.to]}):null,e.jsx("div",{className:"classic-card mt-6 overflow-x-auto p-0",children:e.jsxs("table",{className:"w-full min-w-[620px] border-collapse text-left font-mono text-[12px]",children:[e.jsx("thead",{className:"text-[var(--c-text3)]",children:e.jsxs("tr",{className:"border-b border-[var(--c-line)]",children:[e.jsx("th",{className:"px-3 py-2 font-normal",children:"channel"}),e.jsx("th",{className:"px-3 py-2 font-normal",children:"handle"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"clicks"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"signups"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"paid"}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"click → signup"})]})}),e.jsxs("tbody",{children:[y.map(x=>e.jsxs("tr",{className:"border-b border-[var(--c-line)] last:border-b-0 hover:bg-[var(--c-surface)]",children:[e.jsx("td",{className:"px-3 py-2 text-[var(--c-text)]",children:x.channel}),e.jsx("td",{className:"px-3 py-2 text-[var(--c-text2)]",children:x.handle??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:x.clicks}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text)]",children:x.signups}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text2)]",children:x.paid}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-[var(--c-text3)]",children:x.clicks>0?`${(x.signups/x.clicks*100).toFixed(1)}%`:"—"})]},`${x.channel}-${x.handle??""}`)),c&&y.length===0&&!i?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-3 py-8 text-center text-[var(--c-text3)]",children:"No referral activity in this range."})}):null]})]})}),e.jsxs("div",{className:"mt-4 space-y-1.5 text-[12px] leading-relaxed text-[var(--c-text3)]",children:[c?e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:c.unattributed_signups})," ","signup",c.unattributed_signups===1?"":"s"," in this range carried no channel — organic, or the visitor’s browser dropped the stored attribution. They are not in the table."]}):null,e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"paid"})," counts people who signed up in this range and are on a paid plan ",e.jsx("em",{children:"right now"})," — there is no “became paid” timestamp to measure conversions inside the range."]}),e.jsxs("p",{children:[e.jsx("strong",{className:"font-semibold text-[var(--c-text2)]",children:"clicks"})," are matched to a channel through the short link’s current destination and exclude bots. Editing a link’s destination re-attributes its past clicks."]}),e.jsx("p",{children:"Clicks and signups are counted independently and joined only by channel name, so click → signup is a ratio between two populations, not a tracked journey."})]})]})})}function He({label:t,value:r,min:s,max:a,onChange:n}){return e.jsxs("label",{className:"flex items-center gap-2 font-mono text-[12px] text-[var(--c-text3)]",children:[t,e.jsx("input",{type:"date",value:r,min:s,max:a,onChange:o=>n(o.target.value),className:"rounded-md border border-[var(--c-line)] bg-[var(--c-bg)] px-2.5 py-1.5 font-mono text-[12px] text-[var(--c-text)] outline-none focus:border-[var(--c-accent)]"})]})}function ge({label:t,value:r}){return e.jsxs("div",{className:"classic-card p-5",children:[e.jsx("p",{className:"classic-label",children:t}),e.jsx("p",{className:"mt-1 text-[26px] font-bold tabular-nums text-[var(--c-text)]",children:r===void 0?"—":r.toLocaleString("en-US")})]})}function Gr(){return e.jsxs(at,{title:"Terms of Service",updated:"July 9, 2026",intro:e.jsxs(e.Fragment,{children:["These Terms govern your use of LevelCode — the LevelCode editor and the LevelCode Cloud service at levelcode.ai (together, the “Service”). By creating an account or using the Service, you agree to these Terms and to our"," ",e.jsx("a",{href:"/privacy",className:"text-[var(--c-accent)] hover:underline",children:"Privacy Policy"}),"."]}),children:[e.jsx(_,{heading:"1. The Service",children:e.jsx("p",{children:"LevelCode is an AI-native code editor and a metered AI gateway. On a paid plan or the free tier, the editor sends your prompts and selected code to our gateway, which routes them to third-party AI model providers to generate responses. You may also use your own provider API key (“bring-your-own-key” / BYOK); in that mode requests go directly to your provider and do not run through our gateway or metering."})}),e.jsx(_,{heading:"2. Eligibility & accounts",children:e.jsx("p",{children:"You must be at least 13 years old (and, if under the age of majority where you live, have your parent or guardian’s consent) to use the Service. You are responsible for your account and for keeping your credentials and API keys secure. Notify us promptly of any unauthorized use."})}),e.jsxs(_,{heading:"3. Plans, billing & usage limits",children:[e.jsx("p",{children:"Paid plans are subscriptions billed in advance through our payment processor (Stripe) and renew automatically each period until canceled. You can cancel anytime; cancellation takes effect at the end of the current billing period, and, except where required by law, payments are non-refundable."}),e.jsx("p",{children:"Each plan includes a monthly usage allowance, expressed as approximate model “turns.” To keep the Service reliable, that allowance is metered and may be made available progressively over the billing cycle rather than all at once (rolling usage windows) — heavy use may be paced or, on some plans, temporarily served by a lighter model until more of your allowance becomes available or the period renews. We show your current usage and when more becomes available in your account. We may change plans, prices, allowances, or limits prospectively, with notice for existing subscribers."})]}),e.jsxs(_,{heading:"4. Your content and code",children:[e.jsx("p",{children:"You retain all rights to the code, prompts, and other content you submit (“Your Content”). You grant us a limited license to process, transmit, and store Your Content solely to operate and improve the Service — including sending it to the AI model providers needed to generate responses. We do not claim ownership of Your Content or of the outputs generated for you."}),e.jsx("p",{children:"You are responsible for having the rights to submit Your Content and for ensuring your use complies with any licenses that apply to code you work on."})]}),e.jsx(_,{heading:"5. AI output — no warranty",children:e.jsx("p",{children:"AI-generated code and text may be inaccurate, insecure, or unsuitable for your purpose, and similar outputs may be generated for other users. You are responsible for reviewing, testing, and deciding whether to use any output. The Service is not a substitute for professional judgment, and outputs are not legal, financial, security, or other professional advice."})}),e.jsxs(_,{heading:"6. Acceptable use",children:[e.jsx("p",{children:"You agree not to use the Service to:"}),e.jsxs("ul",{className:"list-disc space-y-1 pl-5",children:[e.jsx("li",{children:"break the law or infringe others’ rights;"}),e.jsx("li",{children:"generate malware, or content intended to harm, harass, defraud, or deceive;"}),e.jsx("li",{children:"abuse, overload, reverse-engineer, or circumvent the gateway, metering, or usage limits;"}),e.jsx("li",{children:"resell or provide the Service to third parties except as expressly permitted; or"}),e.jsx("li",{children:"violate the terms of the underlying AI providers or other third-party services."})]})]}),e.jsx(_,{heading:"7. Third-party services",children:e.jsx("p",{children:"The Service relies on third parties — including the AI model providers and routing partner behind our gateway, our payment processor, and our hosting provider. Your use of the Service through these providers is also subject to their terms, and we are not responsible for their acts or omissions."})}),e.jsx(_,{heading:"8. Intellectual property & open source",children:e.jsx("p",{children:"The LevelCode name, site, and service are owned by us or our licensors. The editor is built on open-source software, which remains governed by its own licenses; nothing here restricts your rights under those licenses. Except for those open-source components and Your Content, you may not copy, modify, or create derivative works of the Service without permission."})}),e.jsx(_,{heading:"9. Disclaimers & limitation of liability",children:e.jsx("p",{children:"The Service is provided “as is” and “as available,” without warranties of any kind to the fullest extent permitted by law. To the extent permitted by law, we are not liable for indirect, incidental, or consequential damages, and our total liability for any claim relating to the Service will not exceed the amount you paid us for the Service in the twelve months before the claim."})}),e.jsx(_,{heading:"10. Termination",children:e.jsx("p",{children:"You may stop using the Service at any time. We may suspend or terminate access if you violate these Terms or to protect the Service or other users. Sections that by their nature should survive termination (for example, ownership, disclaimers, and limitations of liability) will survive."})}),e.jsx(_,{heading:"11. Changes to these Terms",children:e.jsx("p",{children:"We may update these Terms from time to time. If we make material changes we will update the date above and, where appropriate, notify you. Your continued use of the Service after changes take effect means you accept the updated Terms."})}),e.jsx(_,{heading:"12. Governing law",children:e.jsx("p",{children:"These Terms are governed by the laws of [governing-law jurisdiction], without regard to conflict-of-laws rules, and any disputes will be resolved in the courts located there. "})}),e.jsx(_,{heading:"13. Contact",children:e.jsxs("p",{children:["Questions about these Terms? Email"," ",e.jsx("a",{href:"mailto:legal@levelcode.ai",className:"text-[var(--c-accent)] hover:underline",children:"legal@levelcode.ai"}),"."]})})]})}function zr(){return e.jsxs(dt,{children:[e.jsx(P,{path:"/",element:e.jsx(Re,{})}),e.jsx(P,{path:"/login",element:e.jsx(Fr,{})}),e.jsx(P,{path:"/pricing",element:e.jsx(Wr,{})}),e.jsx(P,{path:"/account",element:e.jsx(Tt,{})}),e.jsx(P,{path:"/admin",element:e.jsx(Et,{})}),e.jsx(P,{path:"/admin/referrals",element:e.jsx(Zr,{})}),e.jsx(P,{path:"/terms",element:e.jsx(Gr,{})}),e.jsx(P,{path:"/privacy",element:e.jsx(Yr,{})}),e.jsx(P,{path:"/download",element:e.jsx(vr,{})}),e.jsx(P,{path:"/docs",element:e.jsx(ze,{})}),e.jsx(P,{path:"/docs/:slug",element:e.jsx(Kr,{})}),e.jsx(P,{path:"*",element:e.jsx(Re,{})})]})}function Kr(){const{slug:t}=xt();return e.jsx(ze,{slug:t})}Dr();ut(document.getElementById("root")).render(e.jsx(l.StrictMode,{children:e.jsx(ht,{basename:"/ai",children:e.jsx(zr,{})})}));export{Dt as u}; diff --git a/app/assets/interface/main-B04oQiJI.js b/app/assets/interface/main-BqCeSOyb.js similarity index 99% rename from app/assets/interface/main-B04oQiJI.js rename to app/assets/interface/main-BqCeSOyb.js index b63e2613..e1b74f23 100644 --- a/app/assets/interface/main-B04oQiJI.js +++ b/app/assets/interface/main-BqCeSOyb.js @@ -13,7 +13,7 @@ import{r as l,u as Je,j as e,R as q,a as zt,t as Yr,b as Ra,L as X,c as xr,d as */var Xr;function zc(){if(Xr)return ye;Xr=1;var t=typeof Symbol=="function"&&Symbol.for,a=t?Symbol.for("react.element"):60103,s=t?Symbol.for("react.portal"):60106,n=t?Symbol.for("react.fragment"):60107,r=t?Symbol.for("react.strict_mode"):60108,i=t?Symbol.for("react.profiler"):60114,o=t?Symbol.for("react.provider"):60109,d=t?Symbol.for("react.context"):60110,c=t?Symbol.for("react.async_mode"):60111,u=t?Symbol.for("react.concurrent_mode"):60111,m=t?Symbol.for("react.forward_ref"):60112,h=t?Symbol.for("react.suspense"):60113,x=t?Symbol.for("react.suspense_list"):60120,p=t?Symbol.for("react.memo"):60115,y=t?Symbol.for("react.lazy"):60116,g=t?Symbol.for("react.block"):60121,f=t?Symbol.for("react.fundamental"):60117,b=t?Symbol.for("react.responder"):60118,j=t?Symbol.for("react.scope"):60119;function w(k){if(typeof k=="object"&&k!==null){var N=k.$$typeof;switch(N){case a:switch(k=k.type,k){case c:case u:case n:case i:case r:case h:return k;default:switch(k=k&&k.$$typeof,k){case d:case m:case y:case p:case o:return k;default:return N}}case s:return N}}}function v(k){return w(k)===u}return ye.AsyncMode=c,ye.ConcurrentMode=u,ye.ContextConsumer=d,ye.ContextProvider=o,ye.Element=a,ye.ForwardRef=m,ye.Fragment=n,ye.Lazy=y,ye.Memo=p,ye.Portal=s,ye.Profiler=i,ye.StrictMode=r,ye.Suspense=h,ye.isAsyncMode=function(k){return v(k)||w(k)===c},ye.isConcurrentMode=v,ye.isContextConsumer=function(k){return w(k)===d},ye.isContextProvider=function(k){return w(k)===o},ye.isElement=function(k){return typeof k=="object"&&k!==null&&k.$$typeof===a},ye.isForwardRef=function(k){return w(k)===m},ye.isFragment=function(k){return w(k)===n},ye.isLazy=function(k){return w(k)===y},ye.isMemo=function(k){return w(k)===p},ye.isPortal=function(k){return w(k)===s},ye.isProfiler=function(k){return w(k)===i},ye.isStrictMode=function(k){return w(k)===r},ye.isSuspense=function(k){return w(k)===h},ye.isValidElementType=function(k){return typeof k=="string"||typeof k=="function"||k===n||k===u||k===i||k===r||k===h||k===x||typeof k=="object"&&k!==null&&(k.$$typeof===y||k.$$typeof===p||k.$$typeof===o||k.$$typeof===d||k.$$typeof===m||k.$$typeof===f||k.$$typeof===b||k.$$typeof===j||k.$$typeof===g)},ye.typeOf=w,ye}var Zr;function _c(){return Zr||(Zr=1,gn.exports=zc()),gn.exports}var fn,Jr;function Lc(){if(Jr)return fn;Jr=1;var t=_c(),a={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},s={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},n={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},r={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};i[t.ForwardRef]=n,i[t.Memo]=r;function o(y){return t.isMemo(y)?r:i[y.$$typeof]||a}var d=Object.defineProperty,c=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,h=Object.getPrototypeOf,x=Object.prototype;function p(y,g,f){if(typeof g!="string"){if(x){var b=h(g);b&&b!==x&&p(y,b,f)}var j=c(g);u&&(j=j.concat(u(g)));for(var w=o(y),v=o(g),k=0;k");const r=Object.assign(Object.assign({},{doNotUpdate:!0}),a),[i,o]=l.useState(()=>s.getAll(r));Rc()&&l.useLayoutEffect(()=>{function m(){const h=s.getAll(r);Tc(t||null,h,i)&&o(h)}return s.addChangeListener(m),()=>{s.removeChangeListener(m)}},[s,i]);const d=l.useMemo(()=>s.set.bind(s),[s]),c=l.useMemo(()=>s.remove.bind(s),[s]),u=l.useMemo(()=>s.update.bind(s),[s]);return[i,d,c,u]}function Tc(t,a,s){if(!t)return!0;for(let n of t)if(a[n]!==s[n])return!0;return!1}const he="https://thin.ly",$s="https://thin.ly",$c=async t=>{const a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};try{const s=await fetch(`${he}/users`,a);return s.ok?[s,null]:s.status===422?[null,"User already exists."]:[null,`Server side error: ${(await s.json()).message}`]}catch(s){return[null,`Server down: ${s}`]}},Pc=async t=>{const a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};try{const s=await fetch(`${he}/users/sign_in`,a);return s.ok?[s,null]:s.status===401?[null,"Invalid email or password"]:[null,`Server side error: ${(await s.json()).message}`]}catch(s){return[null,`Server down: ${s}`]}},Mc=async t=>{const a={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};try{const s=await fetch(`${he}/users/auth/google`,a);return s.ok?[s,null]:s.status===401?[null,"Google sign-in was rejected. Please try again."]:[null,`Server side error: ${(await s.json()).message}`]}catch(s){return[null,`Server down: ${s}`]}},ol=async t=>{const a={method:"DELETE",headers:{"Content-Type":"application/json",Authorization:t}};try{const s=await fetch(`${he}/users/sign_out`,a);return s.ok?[s,""]:s.status===401?["","Invalid email or password"]:["",`Server side error: ${(await s.json()).message}`]}catch(s){return["",`Server down: ${s}`]}},ya=async t=>{const a={method:"GET",headers:{"Content-Type":"application/json",Authorization:t}};try{const s=await fetch(`${he}/api/v1/current_user`,a);return s.ok?[s,""]:s.status===401?["","Invalid email or password"]:["",`Server side error: ${(await s.json()).message}`]}catch(s){return["",`Server down: ${s}`]}},cl=async(t,a)=>{const s=new FormData;s.append("avatar",a);const n={method:"PATCH",headers:{Authorization:t},body:s};try{const r=await fetch(`${he}/api/v1/user/avatar`,n);return r.ok?[await r.json(),""]:["",(await r.json()).message||"Failed to upload avatar"]}catch(r){return["",`Server down: ${r}`]}},dl=async t=>{const a={method:"DELETE",headers:{"Content-Type":"application/json",Authorization:t}};try{const s=await fetch(`${he}/api/v1/user/avatar`,a);return s.ok?[s,""]:["",(await s.json()).message||"Failed to delete avatar"]}catch(s){return["",`Server down: ${s}`]}},ka="/features",Ac="/resources",gr="/about",hs="/contact_us",it="/register",Qe="/login",Tt="/",Dc="/branding",fr="/pages/create",ul="/settings/profile",Ic="/:handle",br=t=>`/@${t.replace(/^@/,"")}`,Vt="/pages",Oc="/analytics",dt="/plans",Fc="/settings",Bc="/stats",Re="/governance",Ht="/governance/campaigns",Ta="/terms",It="/privacy_policy",vr="/cookie_policy",Ps="/user_policy",Ve=({children:t,allowedRoles:a})=>{const[s,n,r]=je(["token","email","plan"]),[i,o]=l.useState(null),[d,c]=l.useState(!0),u=Je();return l.useEffect(()=>{const m=async()=>{try{const[h,x]=await ya(s.token);if(x)console.error("Error fetching user:",x),r("token"),u(Qe);else if(h){const p=await h.json();o(p.user),n("email",p.user.email),n("plan",p.user.plan)}else console.error("Unexpected response structure"),r("token"),u(Qe)}catch(h){console.error("Fetch error:",h),r("token"),u(Qe)}finally{c(!1)}};s.token?m():u(Qe)},[s.token,u,r,n]),d?"":i?a&&!a.includes(i.role)?e.jsx("h1",{children:"Error 404 -- Page Not Found"}):t:e.jsx("h1",{children:"Error 404 -- Page Not Found"})},ml=typeof document<"u"?q.useLayoutEffect:()=>{};function Uc(t){const a=l.useRef(null);return ml(()=>{a.current=t},[t]),l.useCallback((...s)=>{const n=a.current;return n==null?void 0:n(...s)},[])}const $a=t=>{var a;return(a=t==null?void 0:t.ownerDocument)!==null&&a!==void 0?a:document},_t=t=>t&&"window"in t&&t.window===t?t:$a(t).defaultView||window;function hl(t){var a,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(a=0;a"u"||window.navigator==null?!1:((a=window.navigator.userAgentData)===null||a===void 0?void 0:a.brands.some(s=>t.test(s.brand)))||t.test(window.navigator.userAgent)}function Wc(t){var a;return typeof window<"u"&&window.navigator!=null?t.test(((a=window.navigator.userAgentData)===null||a===void 0?void 0:a.platform)||window.navigator.platform):!1}function pl(t){let a=null;return()=>(a==null&&(a=t()),a)}const Vc=pl(function(){return Wc(/^Mac/i)}),Gc=pl(function(){return Hc(/Android/i)});function qc(t){return t.mozInputSource===0&&t.isTrusted?!0:Gc()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}class Yc{isDefaultPrevented(){return this.nativeEvent.defaultPrevented}preventDefault(){this.defaultPrevented=!0,this.nativeEvent.preventDefault()}stopPropagation(){this.nativeEvent.stopPropagation(),this.isPropagationStopped=()=>!0}isPropagationStopped(){return!1}persist(){}constructor(a,s){this.nativeEvent=s,this.target=s.target,this.currentTarget=s.currentTarget,this.relatedTarget=s.relatedTarget,this.bubbles=s.bubbles,this.cancelable=s.cancelable,this.defaultPrevented=s.defaultPrevented,this.eventPhase=s.eventPhase,this.isTrusted=s.isTrusted,this.timeStamp=s.timeStamp,this.type=a}}function xl(t){let a=l.useRef({isFocused:!1,observer:null});ml(()=>{const n=a.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]);let s=Uc(n=>{t==null||t(n)});return l.useCallback(n=>{if(n.target instanceof HTMLButtonElement||n.target instanceof HTMLInputElement||n.target instanceof HTMLTextAreaElement||n.target instanceof HTMLSelectElement){a.current.isFocused=!0;let r=n.target,i=o=>{a.current.isFocused=!1,r.disabled&&s(new Yc("blur",o)),a.current.observer&&(a.current.observer.disconnect(),a.current.observer=null)};r.addEventListener("focusout",i,{once:!0}),a.current.observer=new MutationObserver(()=>{if(a.current.isFocused&&r.disabled){var o;(o=a.current.observer)===null||o===void 0||o.disconnect();let d=r===document.activeElement?null:document.activeElement;r.dispatchEvent(new FocusEvent("blur",{relatedTarget:d})),r.dispatchEvent(new FocusEvent("focusout",{bubbles:!0,relatedTarget:d}))}}),a.current.observer.observe(r,{attributes:!0,attributeFilter:["disabled"]})}},[s])}function Kc(t){let{isDisabled:a,onFocus:s,onBlur:n,onFocusChange:r}=t;const i=l.useCallback(c=>{if(c.target===c.currentTarget)return n&&n(c),r&&r(!1),!0},[n,r]),o=xl(i),d=l.useCallback(c=>{const u=$a(c.target);c.target===c.currentTarget&&u.activeElement===c.target&&(s&&s(c),r&&r(!0),o(c))},[r,s,o]);return{focusProps:{onFocus:!a&&(s||r||n)?d:void 0,onBlur:!a&&(n||r)?i:void 0}}}let Pa=null,Wn=new Set,ha=new Map,At=!1,Vn=!1;const Xc={Tab:!0,Escape:!0};function yr(t,a){for(let s of Wn)s(t,a)}function Zc(t){return!(t.metaKey||!Vc()&&t.altKey||t.ctrlKey||t.key==="Control"||t.key==="Shift"||t.key==="Meta")}function ps(t){At=!0,Zc(t)&&(Pa="keyboard",yr("keyboard",t))}function Xe(t){Pa="pointer",(t.type==="mousedown"||t.type==="pointerdown")&&(At=!0,yr("pointer",t))}function gl(t){qc(t)&&(At=!0,Pa="virtual")}function fl(t){t.target===window||t.target===document||(!At&&!Vn&&(Pa="virtual",yr("virtual",t)),At=!1,Vn=!1)}function bl(){At=!1,Vn=!0}function Gn(t){if(typeof window>"u"||ha.get(_t(t)))return;const a=_t(t),s=$a(t);let n=a.HTMLElement.prototype.focus;a.HTMLElement.prototype.focus=function(){At=!0,n.apply(this,arguments)},s.addEventListener("keydown",ps,!0),s.addEventListener("keyup",ps,!0),s.addEventListener("click",gl,!0),a.addEventListener("focus",fl,!0),a.addEventListener("blur",bl,!1),typeof PointerEvent<"u"?(s.addEventListener("pointerdown",Xe,!0),s.addEventListener("pointermove",Xe,!0),s.addEventListener("pointerup",Xe,!0)):(s.addEventListener("mousedown",Xe,!0),s.addEventListener("mousemove",Xe,!0),s.addEventListener("mouseup",Xe,!0)),a.addEventListener("beforeunload",()=>{vl(t)},{once:!0}),ha.set(a,{focus:n})}const vl=(t,a)=>{const s=_t(t),n=$a(t);a&&n.removeEventListener("DOMContentLoaded",a),ha.has(s)&&(s.HTMLElement.prototype.focus=ha.get(s).focus,n.removeEventListener("keydown",ps,!0),n.removeEventListener("keyup",ps,!0),n.removeEventListener("click",gl,!0),s.removeEventListener("focus",fl,!0),s.removeEventListener("blur",bl,!1),typeof PointerEvent<"u"?(n.removeEventListener("pointerdown",Xe,!0),n.removeEventListener("pointermove",Xe,!0),n.removeEventListener("pointerup",Xe,!0)):(n.removeEventListener("mousedown",Xe,!0),n.removeEventListener("mousemove",Xe,!0),n.removeEventListener("mouseup",Xe,!0)),ha.delete(s))};function Jc(t){const a=$a(t);let s;return a.readyState!=="loading"?Gn(t):(s=()=>{Gn(t)},a.addEventListener("DOMContentLoaded",s)),()=>vl(t,s)}typeof document<"u"&&Jc();function yl(){return Pa!=="pointer"}const Qc=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function e0(t,a,s){var n;const r=typeof window<"u"?_t(s==null?void 0:s.target).HTMLInputElement:HTMLInputElement,i=typeof window<"u"?_t(s==null?void 0:s.target).HTMLTextAreaElement:HTMLTextAreaElement,o=typeof window<"u"?_t(s==null?void 0:s.target).HTMLElement:HTMLElement,d=typeof window<"u"?_t(s==null?void 0:s.target).KeyboardEvent:KeyboardEvent;return t=t||(s==null?void 0:s.target)instanceof r&&!Qc.has(s==null||(n=s.target)===null||n===void 0?void 0:n.type)||(s==null?void 0:s.target)instanceof i||(s==null?void 0:s.target)instanceof o&&(s==null?void 0:s.target.isContentEditable),!(t&&a==="keyboard"&&s instanceof d&&!Xc[s.key])}function t0(t,a,s){Gn(),l.useEffect(()=>{let n=(r,i)=>{e0(!!(s!=null&&s.isTextInput),r,i)&&t(yl())};return Wn.add(n),()=>{Wn.delete(n)}},a)}function a0(t){let{isDisabled:a,onBlurWithin:s,onFocusWithin:n,onFocusWithinChange:r}=t,i=l.useRef({isFocusWithin:!1}),o=l.useCallback(u=>{i.current.isFocusWithin&&!u.currentTarget.contains(u.relatedTarget)&&(i.current.isFocusWithin=!1,s&&s(u),r&&r(!1))},[s,r,i]),d=xl(o),c=l.useCallback(u=>{!i.current.isFocusWithin&&document.activeElement===u.target&&(n&&n(u),r&&r(!0),i.current.isFocusWithin=!0,d(u))},[n,r,d]);return a?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:c,onBlur:o}}}let xs=!1,bn=0;function qn(){xs=!0,setTimeout(()=>{xs=!1},50)}function Qr(t){t.pointerType==="touch"&&qn()}function s0(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Qr):document.addEventListener("touchend",qn),bn++,()=>{bn--,!(bn>0)&&(typeof PointerEvent<"u"?document.removeEventListener("pointerup",Qr):document.removeEventListener("touchend",qn))}}function Ms(t){let{onHoverStart:a,onHoverChange:s,onHoverEnd:n,isDisabled:r}=t,[i,o]=l.useState(!1),d=l.useRef({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:"",target:null}).current;l.useEffect(s0,[]);let{hoverProps:c,triggerHoverEnd:u}=l.useMemo(()=>{let m=(p,y)=>{if(d.pointerType=y,r||y==="touch"||d.isHovered||!p.currentTarget.contains(p.target))return;d.isHovered=!0;let g=p.currentTarget;d.target=g,a&&a({type:"hoverstart",target:g,pointerType:y}),s&&s(!0),o(!0)},h=(p,y)=>{if(d.pointerType="",d.target=null,y==="touch"||!d.isHovered)return;d.isHovered=!1;let g=p.currentTarget;n&&n({type:"hoverend",target:g,pointerType:y}),s&&s(!1),o(!1)},x={};return typeof PointerEvent<"u"?(x.onPointerEnter=p=>{xs&&p.pointerType==="mouse"||m(p,p.pointerType)},x.onPointerLeave=p=>{!r&&p.currentTarget.contains(p.target)&&h(p,p.pointerType)}):(x.onTouchStart=()=>{d.ignoreEmulatedMouseEvents=!0},x.onMouseEnter=p=>{!d.ignoreEmulatedMouseEvents&&!xs&&m(p,"mouse"),d.ignoreEmulatedMouseEvents=!1},x.onMouseLeave=p=>{!r&&p.currentTarget.contains(p.target)&&h(p,"mouse")}),{hoverProps:x,triggerHoverEnd:h}},[a,s,n,r,d]);return l.useEffect(()=>{r&&u({currentTarget:d.target},d.pointerType)},[r]),{hoverProps:c,isHovered:i}}function As(t={}){let{autoFocus:a=!1,isTextInput:s,within:n}=t,r=l.useRef({isFocused:!1,isFocusVisible:a||yl()}),[i,o]=l.useState(!1),[d,c]=l.useState(()=>r.current.isFocused&&r.current.isFocusVisible),u=l.useCallback(()=>c(r.current.isFocused&&r.current.isFocusVisible),[]),m=l.useCallback(p=>{r.current.isFocused=p,o(p),u()},[u]);t0(p=>{r.current.isFocusVisible=p,u()},[],{isTextInput:s});let{focusProps:h}=Kc({isDisabled:n,onFocusChange:m}),{focusWithinProps:x}=a0({isDisabled:!n,onFocusWithinChange:m});return{isFocused:i,isFocusVisible:d,focusProps:n?x:h}}var n0=Object.defineProperty,r0=(t,a,s)=>a in t?n0(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,vn=(t,a,s)=>(r0(t,typeof a!="symbol"?a+"":a,s),s);let i0=class{constructor(){vn(this,"current",this.detect()),vn(this,"handoffState","pending"),vn(this,"currentId",0)}set(a){this.current!==a&&(this.handoffState="pending",this.currentId=0,this.current=a)}reset(){this.set(this.detect())}nextId(){return++this.currentId}get isServer(){return this.current==="server"}get isClient(){return this.current==="client"}detect(){return typeof window>"u"||typeof document>"u"?"server":"client"}handoff(){this.handoffState==="pending"&&(this.handoffState="complete")}get isHandoffComplete(){return this.handoffState==="complete"}},$t=new i0;function Xt(t){return $t.isServer?null:t instanceof Node?t.ownerDocument:t!=null&&t.hasOwnProperty("current")&&t.current instanceof Node?t.current.ownerDocument:document}function Ds(t){typeof queueMicrotask=="function"?queueMicrotask(t):Promise.resolve().then(t).catch(a=>setTimeout(()=>{throw a}))}function kt(){let t=[],a={addEventListener(s,n,r,i){return s.addEventListener(n,r,i),a.add(()=>s.removeEventListener(n,r,i))},requestAnimationFrame(...s){let n=requestAnimationFrame(...s);return a.add(()=>cancelAnimationFrame(n))},nextFrame(...s){return a.requestAnimationFrame(()=>a.requestAnimationFrame(...s))},setTimeout(...s){let n=setTimeout(...s);return a.add(()=>clearTimeout(n))},microTask(...s){let n={current:!0};return Ds(()=>{n.current&&s[0]()}),a.add(()=>{n.current=!1})},style(s,n,r){let i=s.style.getPropertyValue(n);return Object.assign(s.style,{[n]:r}),this.add(()=>{Object.assign(s.style,{[n]:i})})},group(s){let n=kt();return s(n),this.add(()=>n.dispose())},add(s){return t.includes(s)||t.push(s),()=>{let n=t.indexOf(s);if(n>=0)for(let r of t.splice(n,1))r()}},dispose(){for(let s of t.splice(0))s()}};return a}function Ma(){let[t]=l.useState(kt);return l.useEffect(()=>()=>t.dispose(),[t]),t}let Me=(t,a)=>{$t.isServer?l.useEffect(t,a):l.useLayoutEffect(t,a)};function mt(t){let a=l.useRef(t);return Me(()=>{a.current=t},[t]),a}let ve=function(t){let a=mt(t);return q.useCallback((...s)=>a.current(...s),[a])};function l0(t){let a=t.width/2,s=t.height/2;return{top:t.clientY-s,right:t.clientX+a,bottom:t.clientY+s,left:t.clientX-a}}function o0(t,a){return!(!t||!a||t.righta.right||t.bottoma.bottom)}function kl({disabled:t=!1}={}){let a=l.useRef(null),[s,n]=l.useState(!1),r=Ma(),i=ve(()=>{a.current=null,n(!1),r.dispose()}),o=ve(d=>{if(r.dispose(),a.current===null){a.current=d.currentTarget,n(!0);{let c=Xt(d.currentTarget);r.addEventListener(c,"pointerup",i,!1),r.addEventListener(c,"pointermove",u=>{if(a.current){let m=l0(u);n(o0(m,a.current.getBoundingClientRect()))}},!1),r.addEventListener(c,"pointercancel",i,!1)}}});return{pressed:s,pressProps:t?{}:{onPointerDown:o,onPointerUp:i,onClick:i}}}let c0=l.createContext(void 0);function Aa(){return l.useContext(c0)}function Yn(...t){return Array.from(new Set(t.flatMap(a=>typeof a=="string"?a.split(" "):[]))).filter(Boolean).join(" ")}function ut(t,a,...s){if(t in a){let r=a[t];return typeof r=="function"?r(...s):r}let n=new Error(`Tried to handle "${t}" but there is no handler defined. Only defined handlers are: ${Object.keys(a).map(r=>`"${r}"`).join(", ")}.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,ut),n}var gs=(t=>(t[t.None=0]="None",t[t.RenderStrategy=1]="RenderStrategy",t[t.Static=2]="Static",t))(gs||{}),yt=(t=>(t[t.Unmount=0]="Unmount",t[t.Hidden=1]="Hidden",t))(yt||{});function Ae(){let t=u0();return l.useCallback(a=>d0({mergeRefs:t,...a}),[t])}function d0({ourProps:t,theirProps:a,slot:s,defaultTag:n,features:r,visible:i=!0,name:o,mergeRefs:d}){d=d??m0;let c=jl(a,t);if(i)return Za(c,s,n,o,d);let u=r??0;if(u&2){let{static:m=!1,...h}=c;if(m)return Za(h,s,n,o,d)}if(u&1){let{unmount:m=!0,...h}=c;return ut(m?0:1,{0(){return null},1(){return Za({...h,hidden:!0,style:{display:"none"}},s,n,o,d)}})}return Za(c,s,n,o,d)}function Za(t,a={},s,n,r){let{as:i=s,children:o,refName:d="ref",...c}=yn(t,["unmount","static"]),u=t.ref!==void 0?{[d]:t.ref}:{},m=typeof o=="function"?o(a):o;"className"in c&&c.className&&typeof c.className=="function"&&(c.className=c.className(a)),c["aria-labelledby"]&&c["aria-labelledby"]===c.id&&(c["aria-labelledby"]=void 0);let h={};if(a){let x=!1,p=[];for(let[y,g]of Object.entries(a))typeof g=="boolean"&&(x=!0),g===!0&&p.push(y.replace(/([A-Z])/g,f=>`-${f.toLowerCase()}`));if(x){h["data-headlessui-state"]=p.join(" ");for(let y of p)h[`data-${y}`]=""}}if(i===l.Fragment&&(Object.keys(gt(c)).length>0||Object.keys(gt(h)).length>0))if(!l.isValidElement(m)||Array.isArray(m)&&m.length>1){if(Object.keys(gt(c)).length>0)throw new Error(['Passing props on "Fragment"!',"",`The current component <${n} /> is rendering a "Fragment".`,"However we need to passthrough the following props:",Object.keys(gt(c)).concat(Object.keys(gt(h))).map(x=>` - ${x}`).join(` `),"","You can apply a few solutions:",['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".',"Render a single element as the child so that we can forward the props onto that element."].map(x=>` - ${x}`).join(` `)].join(` -`))}else{let x=m.props,p=x==null?void 0:x.className,y=typeof p=="function"?(...b)=>Yn(p(...b),c.className):Yn(p,c.className),g=y?{className:y}:{},f=jl(m.props,gt(yn(c,["ref"])));for(let b in h)b in f&&delete h[b];return l.cloneElement(m,Object.assign({},f,h,u,{ref:r(h0(m),u.ref)},g))}return l.createElement(i,Object.assign({},yn(c,["ref"]),i!==l.Fragment&&u,i!==l.Fragment&&h),m)}function u0(){let t=l.useRef([]),a=l.useCallback(s=>{for(let n of t.current)n!=null&&(typeof n=="function"?n(s):n.current=s)},[]);return(...s)=>{if(!s.every(n=>n==null))return t.current=s,a}}function m0(...t){return t.every(a=>a==null)?void 0:a=>{for(let s of t)s!=null&&(typeof s=="function"?s(a):s.current=a)}}function jl(...t){if(t.length===0)return{};if(t.length===1)return t[0];let a={},s={};for(let n of t)for(let r in n)r.startsWith("on")&&typeof n[r]=="function"?(s[r]!=null||(s[r]=[]),s[r].push(n[r])):a[r]=n[r];if(a.disabled||a["aria-disabled"])for(let n in s)/^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(n)&&(s[n]=[r=>{var i;return(i=r==null?void 0:r.preventDefault)==null?void 0:i.call(r)}]);for(let n in s)Object.assign(a,{[n](r,...i){let o=s[n];for(let d of o){if((r instanceof Event||(r==null?void 0:r.nativeEvent)instanceof Event)&&r.defaultPrevented)return;d(r,...i)}}});return a}function Is(...t){if(t.length===0)return{};if(t.length===1)return t[0];let a={},s={};for(let n of t)for(let r in n)r.startsWith("on")&&typeof n[r]=="function"?(s[r]!=null||(s[r]=[]),s[r].push(n[r])):a[r]=n[r];for(let n in s)Object.assign(a,{[n](...r){let i=s[n];for(let o of i)o==null||o(...r)}});return a}function ze(t){var a;return Object.assign(l.forwardRef(t),{displayName:(a=t.displayName)!=null?a:t.name})}function gt(t){let a=Object.assign({},t);for(let s in a)a[s]===void 0&&delete a[s];return a}function yn(t,a=[]){let s=Object.assign({},t);for(let n of a)n in s&&delete s[n];return s}function h0(t){return q.version.split(".")[0]>="19"?t.props.ref:t.ref}let p0="button";function x0(t,a){var s;let n=Aa(),{disabled:r=n||!1,autoFocus:i=!1,...o}=t,{isFocusVisible:d,focusProps:c}=As({autoFocus:i}),{isHovered:u,hoverProps:m}=Ms({isDisabled:r}),{pressed:h,pressProps:x}=kl({disabled:r}),p=Is({ref:a,type:(s=o.type)!=null?s:"button",disabled:r||void 0,autoFocus:i},c,m,x),y=l.useMemo(()=>({disabled:r,hover:u,focus:d,active:h,autofocus:i}),[r,u,d,h,i]);return Ae()({ourProps:p,theirProps:o,slot:y,defaultTag:p0,name:"Button"})}let g0=ze(x0);function f0(t,a,s){let[n,r]=l.useState(s),i=t!==void 0,o=l.useRef(i),d=l.useRef(!1),c=l.useRef(!1);return i&&!o.current&&!d.current?(d.current=!0,o.current=i,console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")):!i&&o.current&&!c.current&&(c.current=!0,o.current=i,console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")),[i?t:n,ve(u=>(i||r(u),a==null?void 0:a(u)))]}function b0(t){let[a]=l.useState(t);return a}function wl(t={},a=null,s=[]){for(let[n,r]of Object.entries(t))Cl(s,Nl(a,n),r);return s}function Nl(t,a){return t?t+"["+a+"]":a}function Cl(t,a,s){if(Array.isArray(s))for(let[n,r]of s.entries())Cl(t,Nl(a,n.toString()),r);else s instanceof Date?t.push([a,s.toISOString()]):typeof s=="boolean"?t.push([a,s?"1":"0"]):typeof s=="string"?t.push([a,s]):typeof s=="number"?t.push([a,`${s}`]):s==null?t.push([a,""]):wl(s,a,t)}function v0(t){var a,s;let n=(a=t==null?void 0:t.form)!=null?a:t.closest("form");if(n){for(let r of n.elements)if(r!==t&&(r.tagName==="INPUT"&&r.type==="submit"||r.tagName==="BUTTON"&&r.type==="submit"||r.nodeName==="INPUT"&&r.type==="image")){r.click();return}(s=n.requestSubmit)==null||s.call(n)}}let y0="span";var Gt=(t=>(t[t.None=1]="None",t[t.Focusable=2]="Focusable",t[t.Hidden=4]="Hidden",t))(Gt||{});function k0(t,a){var s;let{features:n=1,...r}=t,i={ref:a,"aria-hidden":(n&2)===2?!0:(s=r["aria-hidden"])!=null?s:void 0,hidden:(n&4)===4?!0:void 0,style:{position:"fixed",top:1,left:1,width:1,height:0,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0",...(n&4)===4&&(n&2)!==2&&{display:"none"}}};return Ae()({ourProps:i,theirProps:r,slot:{},defaultTag:y0,name:"Hidden"})}let ja=ze(k0),j0=l.createContext(null);function w0({children:t}){let a=l.useContext(j0);if(!a)return q.createElement(q.Fragment,null,t);let{target:s}=a;return s?zt.createPortal(q.createElement(q.Fragment,null,t),s):null}function N0({data:t,form:a,disabled:s,onReset:n,overrides:r}){let[i,o]=l.useState(null),d=Ma();return l.useEffect(()=>{if(n&&i)return d.addEventListener(i,"reset",n)},[i,a,n]),q.createElement(w0,null,q.createElement(C0,{setForm:o,formId:a}),wl(t).map(([c,u])=>q.createElement(ja,{features:Gt.Hidden,...gt({key:c,as:"input",type:"hidden",hidden:!0,readOnly:!0,form:a,disabled:s,name:c,value:u,...r})})))}function C0({setForm:t,formId:a}){return l.useEffect(()=>{if(a){let s=document.getElementById(a);s&&t(s)}},[t,a]),a?null:q.createElement(ja,{features:Gt.Hidden,as:"input",type:"hidden",hidden:!0,readOnly:!0,ref:s=>{if(!s)return;let n=s.closest("form");n&&t(n)}})}let S0=l.createContext(void 0);function Sl(){return l.useContext(S0)}function El(t){let a=t.parentElement,s=null;for(;a&&!(a instanceof HTMLFieldSetElement);)a instanceof HTMLLegendElement&&(s=a),a=a.parentElement;let n=(a==null?void 0:a.getAttribute("disabled"))==="";return n&&E0(s)?!1:n}function E0(t){if(!t)return!1;let a=t.previousElementSibling;for(;a!==null;){if(a instanceof HTMLLegendElement)return!1;a=a.previousElementSibling}return!0}let zl=Symbol();function z0(t,a=!0){return Object.assign(t,{[zl]:a})}function He(...t){let a=l.useRef(t);l.useEffect(()=>{a.current=t},[t]);let s=ve(n=>{for(let r of a.current)r!=null&&(typeof r=="function"?r(n):r.current=n)});return t.every(n=>n==null||(n==null?void 0:n[zl]))?void 0:s}let Os=l.createContext(null);Os.displayName="DescriptionContext";function _l(){let t=l.useContext(Os);if(t===null){let a=new Error("You used a component, but it is not inside a relevant parent.");throw Error.captureStackTrace&&Error.captureStackTrace(a,_l),a}return t}function _0(){var t,a;return(a=(t=l.useContext(Os))==null?void 0:t.value)!=null?a:void 0}function kr(){let[t,a]=l.useState([]);return[t.length>0?t.join(" "):void 0,l.useMemo(()=>function(s){let n=ve(i=>(a(o=>[...o,i]),()=>a(o=>{let d=o.slice(),c=d.indexOf(i);return c!==-1&&d.splice(c,1),d}))),r=l.useMemo(()=>({register:n,slot:s.slot,name:s.name,props:s.props,value:s.value}),[n,s.slot,s.name,s.props,s.value]);return q.createElement(Os.Provider,{value:r},s.children)},[a])]}let L0="p";function R0(t,a){let s=l.useId(),n=Aa(),{id:r=`headlessui-description-${s}`,...i}=t,o=_l(),d=He(a);Me(()=>o.register(r),[r,o.register]);let c=n||!1,u=l.useMemo(()=>({...o.slot,disabled:c}),[o.slot,c]),m={ref:d,...o.props,id:r};return Ae()({ourProps:m,theirProps:i,slot:u,defaultTag:L0,name:o.name||"Description"})}let T0=ze(R0),Ll=Object.assign(T0,{});var ft=(t=>(t.Space=" ",t.Enter="Enter",t.Escape="Escape",t.Backspace="Backspace",t.Delete="Delete",t.ArrowLeft="ArrowLeft",t.ArrowUp="ArrowUp",t.ArrowRight="ArrowRight",t.ArrowDown="ArrowDown",t.Home="Home",t.End="End",t.PageUp="PageUp",t.PageDown="PageDown",t.Tab="Tab",t))(ft||{});let Fs=l.createContext(null);Fs.displayName="LabelContext";function Rl(){let t=l.useContext(Fs);if(t===null){let a=new Error("You used a