From bc5237dc501c07c6ca40afcfd3fa5049b526fe57 Mon Sep 17 00:00:00 2001 From: "release-police-please[bot]" <192060759+release-police-please[bot]@users.noreply.github.com> Date: Fri, 24 Jul 2026 02:19:32 +0000 Subject: [PATCH] feat: Auto update UI from onetime repo --- app/assets/interface/levelcode-BdyYiNYr.js | 1 - app/assets/interface/levelcode-TaNaT5-t.js | 1 + .../{main-BZoV021O.js => main-BVjw8FfB.js} | 24 +++++++++---------- app/views/static/ui.html | 2 +- app/views/static/ui_levelcode.html.erb | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) delete mode 100644 app/assets/interface/levelcode-BdyYiNYr.js create mode 100644 app/assets/interface/levelcode-TaNaT5-t.js rename app/assets/interface/{main-BZoV021O.js => main-BVjw8FfB.js} (96%) diff --git a/app/assets/interface/levelcode-BdyYiNYr.js b/app/assets/interface/levelcode-BdyYiNYr.js deleted file mode 100644 index 58eff542..00000000 --- a/app/assets/interface/levelcode-BdyYiNYr.js +++ /dev/null @@ -1 +0,0 @@ -var Re=Object.defineProperty;var Ie=(t,n,r)=>n in t?Re(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r;var ae=(t,n,r)=>Ie(t,typeof n!="symbol"?n+"":n,r);import{r as i,j as e,L as D,u as re,d as Oe,e as Fe,f as U,g as qe,B as Be}from"./chunk-7R3XDUXW-BMhzTiu5.js";const Ye=typeof window<"u"&&window.__ENV__||{},me=String(Ye.API_BASE??"").replace(/\/+$/,"");let oe=null;async function Ue(){const t=typeof document<"u"?document.querySelector('meta[name="csrf-token"]'):null,n=t==null?void 0:t.getAttribute("content");return n||(oe||(oe=fetch(`${me}/ai/csrf`,{credentials:"include"}).then(r=>r.ok?r.json():{token:""}).then(r=>r.token??"").catch(()=>"")),oe)}class X extends Error{constructor(r,s,a){super(s);ae(this,"status");ae(this,"code");this.name="ApiError",this.status=r,this.code=a}}async function P(t,n={}){const r=n.method??(n.body!==void 0?"POST":"GET"),s={Accept:"application/json",...n.headers};n.body!==void 0&&(s["Content-Type"]="application/json"),r!=="GET"&&r!=="HEAD"&&(s["X-CSRF-Token"]=await Ue());const a=await fetch(`${me}${t}`,{method:r,headers:s,credentials:"include",body:n.body!==void 0?JSON.stringify(n.body):void 0}),l=await a.text();let c=null;if(l)try{c=JSON.parse(l)}catch{c=null}if(!a.ok){const d=c==null?void 0:c.error;throw new X(a.status,(d==null?void 0:d.message)??`Request failed (${a.status})`,d==null?void 0:d.code)}return c}function Z(t){window.location.href=t}function H(){const[t,n]=i.useState({loading:!0,profile:null});return i.useEffect(()=>{let r=!0;return P("/api/levelcode/v1/account/profile").then(s=>{r&&n({loading:!1,profile:s})}).catch(()=>{r&&n({loading:!1,profile:null})}),()=>{r=!1}},[]),t}function Le(t,n){const r=(t||n||"").trim();if(!r)return"··";const s=r.split(/[\s@._-]+/).filter(Boolean);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():r.slice(0,2).toUpperCase()}const ze="https://github.com/levelcodeai/levelcode",Ge="levelcode://levelcode.levelcode-ai/launch";function B(){const{profile:t}=H();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(D,{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(D,{to:"/pricing",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Pricing"}),e.jsx("a",{href:ze,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(D,{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(D,{to:"/admin",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Admin"}):null,e.jsxs("a",{href:Ge,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(D,{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:Le(t.name,t.email)})]}):e.jsx(D,{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 We=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],pe=["bg-rule/50","bg-flame/25","bg-flame/50","bg-flame/75","bg-flame"];function He(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}`}function Ve(t){return t<=0?0:t<=2?1:t<=6?2:t<=14?3:4}function fe(t){return(t??0).toLocaleString()}function V(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString()}function ge(t){return`$${(t/1e6).toFixed(2)}`}function le(t){const[n,r,s]=t.split("-").map(Number);return new Date(Date.UTC(n,r-1,s)).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function Ke({activity:t,year:n,years:r,onYear:s}){const[a,l]=i.useState(null),c=(t==null?void 0:t.days)??{},{weeks:d,monthCols:N}=i.useMemo(()=>{var E;const o=new Date(Date.UTC(n,0,1)),g=new Date(o);g.setUTCDate(o.getUTCDate()-o.getUTCDay());const x=new Date(Date.UTC(n,11,31)),b=new Date(x);b.setUTCDate(x.getUTCDate()+(6-x.getUTCDay()));const S=[],m=[],p=new Date(g);let y=-1;for(;p<=b;){const u=[];let f=null;for(let v=0;v<7;v++){const j=p.getUTCFullYear()===n;if(v===0&&(f=j?p.getUTCMonth():null),j){const R=He(p);u.push({key:R,count:((E=c[R])==null?void 0:E.count)??0,date:new Date(p)})}else u.push({key:null,count:0,date:null});p.setUTCDate(p.getUTCDate()+1)}f!=null&&f!==y?(m.push(We[f]),y=f):m.push(null),S.push(u)}return{weeks:S,monthCols:m}},[n,c]),h=a?c[a]??null:null,k=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"surface 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:"lineno",children:"activity"}),e.jsxs("div",{className:"mt-1 font-display text-lg font-semibold tracking-tightest",children:[fe((t==null?void 0:t.total)??0)," request",((t==null?void 0:t.total)??0)===1?"":"s"," in ",n]})]}),r.length>1?e.jsx("div",{className:"flex flex-wrap gap-1",children:r.map(o=>e.jsx("button",{type:"button",onClick:()=>{l(null),s(o)},className:`rounded-md px-2.5 py-1 font-mono text-[12px] transition-colors ${o===n?"bg-flame text-white":"text-sub hover:bg-rule/60"}`,children:o},o))}):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:N.map((o,g)=>e.jsx("div",{className:"w-[11px] font-mono text-[10px] text-faint",children:o?e.jsx("span",{className:"relative -left-[1px] whitespace-nowrap",children:o}):null},g))}),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((o,g)=>e.jsx("div",{className:"h-[11px] font-mono text-[9px] leading-[11px] text-faint",children:o},g))}),d.map((o,g)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:o.map((x,b)=>{var E,u;if(!x.key)return e.jsx("div",{className:"h-[11px] w-[11px]"},b);const S=Ve(x.count),m=a===x.key,p=(u=(E=c[x.key])==null?void 0:E.models)==null?void 0:u[0],y=x.count>0?`${le(x.key)} · ${x.count} request${x.count===1?"":"s"}${p?` · ${ie(p.model)} ${p.count}`:""}`:`${le(x.key)} · no activity`;return e.jsx("button",{type:"button",title:y,onClick:()=>l(m?null:x.key),className:`h-[11px] w-[11px] rounded-[2px] ${pe[S]} ${m?"ring-1 ring-ink ring-offset-1":""} transition-colors hover:ring-1 hover:ring-ink/40`},b)})},g))]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 pl-8 font-mono text-[10px] text-faint",children:[e.jsx("span",{className:"mr-1",children:"Less"}),pe.map((o,g)=>e.jsx("span",{className:`h-[11px] w-[11px] rounded-[2px] ${o}`},g)),e.jsx("span",{className:"ml-1",children:"More"})]})]})}),a&&h?e.jsxs("div",{className:"mt-6 rounded-lg border border-rule bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"font-mono text-[12px] text-sub",children:le(a)}),e.jsxs("div",{className:"font-mono text-[12px] text-faint",children:[h.count," req · ",V(h.input)," in · ",V(h.output)," out ·"," ",ge(h.cost_micros)]})]}),e.jsx("ul",{className:"mt-3 space-y-1.5",children:h.models.map(o=>e.jsxs("li",{className:"flex items-center justify-between gap-3 font-mono text-[12px]",children:[e.jsx("span",{className:"truncate text-ink",children:ie(o.model)}),e.jsxs("span",{className:"whitespace-nowrap text-faint",children:[o.count," · ",V(o.input+o.output)," tok"]})]},o.model))})]}):e.jsx("p",{className:"mt-4 font-mono text-[11px] text-faint",children:"Click a day to see its per-model breakdown."}),k.length?e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"lineno mb-3",children:["by model · ",n]}),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-faint",children:e.jsxs("tr",{className:"border-b border-rule",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:"cost"}),e.jsx("th",{className:"py-1.5 pl-3 text-right font-normal",children:"reactions"})]})}),e.jsx("tbody",{children:k.map(o=>e.jsxs("tr",{className:"border-b border-rule/60",children:[e.jsx("td",{className:"py-1.5 pr-3 text-ink",children:ie(o.model)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:fe(o.count)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:V(o.input)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:V(o.output)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:ge(o.cost_micros)}),e.jsx("td",{className:"py-1.5 pl-3 text-right tabular-nums text-faint",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(Je,{className:"text-sub"})," ",o.up]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Xe,{className:"text-sub"})," ",o.down]})]})})]},o.model))})]})})]}):null]})}function ie(t){const n=t||"unknown",r=n.indexOf("/");return r>=0?n.slice(r+1):n}function Je({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 Xe({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"})})}const se="en-US";function Ze(){const t=re(),{loading:n,profile:r}=H(),[s,a]=i.useState(null),[l,c]=i.useState(null),[d,N]=i.useState(null),[h,k]=i.useState(new Date().getFullYear()),[o,g]=i.useState(null);i.useEffect(()=>{!n&&!r&&t("/login",{replace:!0})},[n,r,t]),i.useEffect(()=>{if(!r)return;let p=!0;return P("/api/levelcode/v1/account/usage").then(y=>{p&&a(y)}).catch(()=>{p&&g("We couldn’t load your usage right now. Please try again shortly.")}),()=>{p=!1}},[r]),i.useEffect(()=>{if(!r)return;let p=!0;return P("/api/levelcode/v1/account/models").then(y=>{p&&c(y)}).catch(()=>{}),()=>{p=!1}},[r]),i.useEffect(()=>{if(!r)return;let p=!0;return P(`/api/levelcode/v1/account/activity?year=${h}`).then(y=>{p&&N(y)}).catch(()=>{}),()=>{p=!1}},[r,h]);async function x(){try{const p=await P("/ai/billing",{method:"POST"});p.url&&Z(p.url)}catch{g("Could not open billing. Please try again.")}}async function b(){try{await P("/ai/signout",{method:"POST"})}catch{}t("/login",{replace:!0})}if(n||!r)return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto max-w-4xl px-5 py-28"})]});const S=s?ye(s.input_used,s.input_cap):0,m=s?ye(s.output_used,s.output_cap):0;return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-4xl px-5 py-28",children:[e.jsx("div",{className:"lineno mb-4",children:"05 · account"}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-[clamp(1.9rem,4vw,2.8rem)] font-semibold leading-[1.05] tracking-tightest",children:r.name?`Hi, ${r.name}`:"Your account"}),r.email?e.jsx("p",{className:"mt-2 font-mono text-[13px] text-faint",children:r.email}):null]}),e.jsxs("span",{className:"rounded-full border border-rule bg-card px-3 py-1 font-mono text-[12px] text-sub",children:["plan · ",(s==null?void 0:s.plan)??r.plan??"free"]})]}),o?e.jsx("div",{className:"surface mt-10 p-8 text-[15px] text-sub",children:o}):s?e.jsxs("div",{className:"mt-10 grid gap-5 sm:grid-cols-2",children:[e.jsx(be,{label:"Input tokens",used:s.input_used,cap:s.input_cap,pct:S}),e.jsx(be,{label:"Output tokens",used:s.output_used,cap:s.output_cap,pct:m}),e.jsx("div",{className:"surface 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:"lineno",children:"billing period resets"}),e.jsx("div",{className:"mt-1 font-display text-lg font-semibold",children:et(s.period_end)}),e.jsxs("div",{className:"mt-1 font-mono text-[12px] text-faint",children:["overage policy · ",s.overage_policy]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:x,className:"btn-ghost",children:"Manage billing"}),e.jsx(D,{to:"/pricing",className:"btn-primary",children:"Upgrade"})]})]})})]}):null,l&&l.models.length?e.jsx(Qe,{models:l}):null,e.jsx("div",{className:"mt-6",children:e.jsx(Ke,{activity:d,year:h,years:(d==null?void 0:d.years)??[h],onYear:k})}),e.jsx("button",{type:"button",onClick:b,className:"mt-10 font-mono text-[12px] text-faint underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"Sign out"})]})]})}function Qe({models:t}){const n=t.budget_micros||0,r=t.ceiling_micros??n,s=t.spent_micros||0,a=t.credits_remaining_micros||0,l=r0?Math.min(Math.round(s/r*100),100):0,N=1e4,h=x=>(x||0)/N,k=x=>Math.round(h(x)).toLocaleString(se),o=x=>{const b=h(x);return b>0?b>=10?Math.round(b).toLocaleString(se):b<.05?"<0.1":b.toFixed(1):"—"},g=x=>x.includes("/")?x.slice(x.indexOf("/")+1):x;return e.jsxs("div",{className:"surface mt-5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsx("div",{className:"lineno",children:l?"usage available now":"compute credits"}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-sub",children:[k(s)," / ",k(r)," · ",d,"%"]})]}),e.jsxs("div",{className:"mt-1 font-display text-2xl font-semibold tracking-tightest tabular-nums",children:[k(a),e.jsxs("span",{className:"text-sm font-normal text-faint",children:[" ","credits ",l?"available now":"left this period"]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-rule",children:e.jsx("div",{className:`h-full rounded-full ${d>=100?"bg-flamedeep":"bg-flame"}`,style:{width:`${d}%`}})}),l&&c?e.jsxs("div",{className:"mt-2 font-mono text-[11px] text-faint",children:["More unlocks ",c.toLocaleDateString(void 0,{month:"short",day:"numeric"})," · ",k(n)," ","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-faint",children:e.jsxs("tr",{className:"border-b border-rule",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(x=>e.jsxs("tr",{className:`border-b border-rule/60 ${x.live?"":"opacity-55"}`,children:[e.jsx("td",{className:"py-1.5 pr-3 text-ink",children:g(x.id)}),e.jsxs("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",title:`${x.multiplier}× the baseline model`,children:[o(x.per_turn_micros),e.jsxs("span",{className:"sr-only",children:[" credits per turn, ",x.multiplier,"× the baseline model"]})]}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:x.live?(x.turns_left??0).toLocaleString(se):"—"}),e.jsx("td",{className:"py-1.5 pl-3 text-right",children:x.live?e.jsx("span",{className:"text-[11px] text-flame",children:"live"}):e.jsx("span",{className:"rounded bg-rule/60 px-1.5 py-0.5 text-[10px] text-faint",children:"soon"})})]},x.id))})]})})]})}function be({label:t,used:n,cap:r,pct:s}){const a=s>=100;return e.jsxs("div",{className:"surface p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"lineno",children:t}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-sub",children:[s,"%"]})]}),e.jsxs("div",{className:"mt-3 font-display text-2xl font-semibold tracking-tightest tabular-nums",children:[ve(n),e.jsxs("span",{className:"text-sm font-normal text-faint",children:[" / ",ve(r)]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-rule",children:e.jsx("div",{className:`h-full rounded-full ${a?"bg-flamedeep":"bg-flame"}`,style:{width:`${Math.min(s,100)}%`}})})]})}function ye(t,n){return!n||n<=0?0:Math.round(t/n*100)}function ve(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString(se)}function et(t){if(!t)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}function tt(){const t=re(),{loading:n,profile:r}=H(),[s,a]=i.useState(null),[l,c]=i.useState(null),[d,N]=i.useState("input"),[h,k]=i.useState("desc"),[o,g]=i.useState(""),[x,b]=i.useState(""),[S,m]=i.useState(null),p=(r==null?void 0:r.role)==="admin";i.useEffect(()=>{n||(r?p||t("/account",{replace:!0}):t("/login",{replace:!0}))},[n,r,p,t]),i.useEffect(()=>{if(!p)return;let u=!0;return P("/api/levelcode/v1/admin/summary").then(f=>u&&a(f)).catch(()=>u&&m("Couldn’t load the admin summary.")),()=>{u=!1}},[p]),i.useEffect(()=>{if(!p)return;let u=!0;const f=new URLSearchParams({sort:d,dir:h,limit:"200"});return o.trim()&&f.set("q",o.trim()),x&&f.set("plan",x),P(`/api/levelcode/v1/admin/users?${f.toString()}`).then(v=>u&&c(v)).catch(()=>u&&m("Couldn’t load users.")),()=>{u=!1}},[p,d,h,o,x]);const y=i.useMemo(()=>Object.keys((s==null?void 0:s.plans)??{}).sort(),[s]);function E(u){d===u?k(f=>f==="desc"?"asc":"desc"):(N(u),k(u==="email"||u==="plan"?"asc":"desc"))}return n||!p?e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto max-w-6xl px-5 py-28"})]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-28",children:[e.jsx("div",{className:"lineno mb-4",children:"06 · admin"}),e.jsx("h1",{className:"font-display text-[clamp(1.9rem,4vw,2.8rem)] font-semibold leading-[1.05] tracking-tightest",children:"System dashboard"}),e.jsx("p",{className:"mt-2 font-mono text-[13px] text-faint",children:"tokens burned · plans · geography · login health"}),S?e.jsx("div",{className:"surface mt-8 p-6 text-[14px] text-flame",children:S}):null,e.jsxs("div",{className:"mt-10 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(K,{label:"users",value:G(s==null?void 0:s.users),sub:`${G(s==null?void 0:s.active_users)} active`}),e.jsx(K,{label:"requests",value:G(s==null?void 0:s.requests),sub:je(s==null?void 0:s.cost_micros)}),e.jsx(K,{label:"input tokens",value:Q(s==null?void 0:s.input)}),e.jsx(K,{label:"output tokens",value:Q(s==null?void 0:s.output)}),e.jsx(K,{label:"auth attempts",value:G(s==null?void 0:s.auth_attempts),sub:`${G(s==null?void 0:s.auth_failures)} failed`,alert:((s==null?void 0:s.auth_failures)??0)>0}),e.jsx(ce,{label:"plans",map:s==null?void 0:s.plans}),e.jsx(ce,{label:"countries",map:s==null?void 0:s.countries}),e.jsx(ce,{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:o,onChange:u=>g(u.target.value),placeholder:"Search email…",className:"w-full max-w-xs rounded-lg border border-rule bg-card px-3 py-2 font-mono text-[13px] text-ink outline-none focus:border-ink sm:w-auto"}),e.jsxs("select",{value:x,onChange:u=>b(u.target.value),className:"rounded-lg border border-rule bg-card px-3 py-2 font-mono text-[13px] text-sub outline-none focus:border-ink",children:[e.jsx("option",{value:"",children:"all plans"}),y.map(u=>e.jsx("option",{value:u,children:u},u))]}),e.jsxs("span",{className:"font-mono text-[12px] text-faint",children:[G(l==null?void 0:l.total)," users"]})]}),e.jsx("div",{className:"surface 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-faint",children:e.jsxs("tr",{className:"border-b border-rule",children:[e.jsx(z,{label:"email",col:"email",sort:d,dir:h,onClick:E,align:"left"}),e.jsx(z,{label:"plan",col:"plan",sort:d,dir:h,onClick:E,align:"left"}),e.jsx(z,{label:"input",col:"input",sort:d,dir:h,onClick:E}),e.jsx(z,{label:"output",col:"output",sort:d,dir:h,onClick:E}),e.jsx(z,{label:"requests",col:"requests",sort:d,dir:h,onClick:E}),e.jsx(z,{label:"cost",col:"cost",sort:d,dir:h,onClick:E}),e.jsx("th",{className:"px-3 py-2 text-left font-normal",children:"country"}),e.jsx(z,{label:"auth",col:"auth_attempts",sort:d,dir:h,onClick:E}),e.jsx(z,{label:"last seen",col:"last_seen",sort:d,dir:h,onClick:E}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"reach"})]})}),e.jsxs("tbody",{children:[((l==null?void 0:l.users)??[]).map(u=>e.jsxs("tr",{className:"border-b border-rule/60 hover:bg-rule/20",children:[e.jsxs("td",{className:"px-3 py-2 text-ink",children:[u.email,u.role==="admin"?e.jsx("span",{className:"ml-2 rounded bg-flame/15 px-1.5 py-0.5 text-[10px] text-flame",children:"admin"}):null]}),e.jsx("td",{className:"px-3 py-2 text-sub",children:u.plan}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:Q(u.input)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:Q(u.output)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:G(u.requests)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:je(u.cost_micros)}),e.jsx("td",{className:"px-3 py-2 text-sub",children:u.country??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:e.jsxs("span",{className:u.auth_failures>0?"text-flame":"text-faint",children:[u.auth_attempts,u.auth_failures>0?` · ${u.auth_failures}✗`:""]})}),e.jsx("td",{className:"px-3 py-2 text-faint",children:st(u.last_seen_at)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("a",{className:"text-flame underline decoration-rule underline-offset-2 hover:decoration-flame",href:`mailto:${u.email}`,children:"email"})})]},u.id)),l&&l.users.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:"px-3 py-6 text-center text-faint",children:"No users match."})}):null]})]})})]})]})}function z({label:t,col:n,sort:r,dir:s,onClick:a,align:l="right"}){const c=r===n;return e.jsx("th",{className:`px-3 py-2 font-normal ${l==="right"?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>a(n),className:`inline-flex items-center gap-1 ${c?"text-ink":"hover:text-ink"}`,children:[t,e.jsx("span",{className:"text-[9px]",children:c?s==="desc"?"▼":"▲":"↕"})]})})}function K({label:t,value:n,sub:r,alert:s}){return e.jsxs("div",{className:"surface p-5",children:[e.jsx("div",{className:"lineno",children:t}),e.jsx("div",{className:"mt-1 font-display text-2xl font-semibold tracking-tightest tabular-nums",children:n}),r?e.jsx("div",{className:`mt-1 font-mono text-[11px] ${s?"text-flame":"text-faint"}`,children:r}):null]})}function ce({label:t,map:n,alert:r}){const s=Object.entries(n??{}).sort((a,l)=>l[1]-a[1]);return e.jsxs("div",{className:"surface p-5",children:[e.jsx("div",{className:"lineno",children:t}),s.length?e.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[12px]",children:s.slice(0,5).map(([a,l])=>e.jsxs("li",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sub",children:a}),e.jsx("span",{className:`tabular-nums ${r?"text-flame":"text-faint"}`,children:l})]},a))}):e.jsx("div",{className:"mt-2 font-mono text-[12px] text-faint",children:"—"})]})}function G(t){return(t??0).toLocaleString()}function Q(t){const n=t??0;return n>=1e6?`${+(n/1e6).toFixed(1)}M`:n>=1e3?`${+(n/1e3).toFixed(0)}K`:n.toLocaleString()}function je(t){return`$${((t??0)/1e6).toFixed(2)}`}function st(t){if(!t)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const we="https://github.com/levelcodeai/levelcode/releases/latest",de={arm64:`${we}/download/LevelCode-arm64.dmg`,x64:`${we}/download/LevelCode-x64.dmg`};async function nt(){var a,l;const t=navigator,n=navigator.userAgent,r=/Mac/i.test(navigator.platform)||/Macintosh/.test(n),s=r&&(navigator.maxTouchPoints??0)>1;if(!r||s)return"not-mac";try{const c=await((l=(a=t.userAgentData)==null?void 0:a.getHighEntropyValues)==null?void 0:l.call(a,["architecture"]));if((c==null?void 0:c.architecture)==="arm")return"arm64";if((c==null?void 0:c.architecture)==="x86")return"x64"}catch{}try{const c=document.createElement("canvas"),d=c.getContext("webgl")||c.getContext("experimental-webgl"),N=d==null?void 0:d.getExtension("WEBGL_debug_renderer_info"),h=N&&d?String(d.getParameter(N.UNMASKED_RENDERER_WEBGL)):"";if(/apple/i.test(h))return"arm64";if(/intel|amd|radeon/i.test(h))return"x64"}catch{}return"unknown-mac"}function rt(){const[t,n]=i.useState("unknown-mac");i.useEffect(()=>{let l=!0;return nt().then(c=>{l&&n(c)}),()=>{l=!1}},[]);const r=t==="x64"?"x64":"arm64",s=r==="arm64"?"Apple Silicon":"Intel",a=t==="not-mac";return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),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."}),a?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:de[r],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:de.arm64,className:"btn-ghost text-[14px]",download:!0,children:"Apple Silicon (M1–M4)"}),e.jsx("a",{href:de.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 O=t=>({t,c:"text-[#c58aff]"}),Ne=t=>({t,c:"text-[#7fd88f]"}),W=t=>({t,c:"text-[#9fb4ff]"}),ue=t=>({t,c:"text-[#5b6172]"}),xe=t=>({t,c:"text-[#e6a86b]"}),_=t=>({t}),F=[{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:[O("class"),_(" "),W("RefundService")]},{no:"13",toks:[_(" "),O("def"),_(" "),W("call"),_("(charge, key:)")]},{no:"14",toks:[_(" "),O("return"),_(" cached(key) "),O("if"),_(" seen?(key)")]},{no:"15",toks:[_(" result = gateway.refund(charge)")]},{no:"16",toks:[_(" remember(key, result, ttl: "),xe("24"),_(".hours)")]},{no:"17",toks:[_(" result")]},{no:"18",toks:[_(" "),O("end")]},{no:"19",toks:[O("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:[ue("# before: 62 lines in controller")]},{no:"41",toks:[O("def"),_(" "),W("create")]},{no:"42",toks:[_(" total = "),W("PricingCalculator")]},{no:"43",toks:[_(" .new(cart, coupon: params[:coupon])")]},{no:"44",toks:[_(" .total")]},{no:"45",toks:[_(" order = "),W("Order"),_(".create!(total:)")]},{no:"46",toks:[_(" render json: order")]},{no:"47",toks:[O("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:[O("if"),_(" plan_changed_mid_cycle?")]},{no:"89",toks:[_(" credit = unused_ratio * old_rate")]},{no:"90",toks:[_(" charge = remaining_ratio * new_rate")]},{no:"91",toks:[_(" invoice.adjust(credit:, charge:)")]},{no:"92",toks:[O("end")]},{no:"93",toks:[ue("# ← 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"),_(" "),Ne('"refunds only once per key"'),_(" "),O("do")]},{no:"06",toks:[_(" "),xe("2"),_(".times { service.call(charge, key:) }")]},{no:"07",toks:[_(" expect(gateway.refunds.count).to eq("),xe("1"),_(")")]},{no:"08",toks:[O("end")]},{no:"09",toks:[_("")]},{no:"10",toks:[Ne("✓ 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:[ue("# ⚠ 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]"},_(" .set(wait: backoff(attempt))")]},{no:"25",toks:[{t:"+ ",c:"text-[#7fd88f]"},_(" .perform_later(webhook.id,")]},{no:"26",toks:[{t:"+ ",c:"text-[#7fd88f]"},_(" lock: webhook.lock_token)")]}]}];function at(){const[t,n]=i.useState(!1),[r,s]=i.useState(0),[a,l]=i.useState(!0),[c,d]=i.useState(!0),[N,h]=i.useState(0),[k,o]=i.useState(0),[g,x]=i.useState(0),[b,S]=i.useState(!1),[m,p]=i.useState(0),y=i.useRef(null),E=i.useRef(null),u=i.useRef([]),f=i.useRef([]),v=i.useRef([]),j=F[r],R=j.duration??9;i.useEffect(()=>{window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(n(!0),l(!1),o(F[r].code.length))},[]),i.useLayoutEffect(()=>{var T;const w=()=>{const C=u.current[r],L=E.current;if(!C||!L||!C.parentElement)return;const M=C.getBoundingClientRect(),q=C.parentElement.getBoundingClientRect();L.style.width=`${M.width}px`,L.style.transform=`translateX(${M.left-q.left}px)`};return w(),window.addEventListener("resize",w),(T=document.fonts)==null||T.ready.then(w).catch(()=>{}),()=>window.removeEventListener("resize",w)},[r,t]),i.useEffect(()=>{const w=y.current;if(!w)return;const T=new IntersectionObserver(([C])=>d(C.isIntersecting),{threshold:.25});return T.observe(w),()=>T.disconnect()},[]),i.useEffect(()=>{if(r===g)return;S(!0);const w=setTimeout(()=>{x(r),S(!1)},200);return()=>clearTimeout(w)},[r,g]),i.useEffect(()=>{if(t||(v.current.forEach(clearTimeout),v.current=[],!a||!c))return;const w=f.current[r],T=w?Array.from(w.querySelectorAll("[data-text]")):[];T.forEach(L=>L.textContent=""),o(0),p(L=>L+1);let C=300;return T.forEach(L=>{const M=L.dataset.text??"";for(let q=1;q<=M.length;q++)C+=14,v.current.push(setTimeout(()=>L.textContent=M.slice(0,q),C));C+=350}),F[r].code.forEach((L,M)=>{C+=320,v.current.push(setTimeout(()=>o(M+1),C))}),v.current.push(setTimeout(()=>s(L=>(L+1)%F.length),(F[r].duration??9)*1e3)),()=>{v.current.forEach(clearTimeout),v.current=[]}},[r,a,c,N,t]);const I=()=>{l(w=>{const T=!w;return T&&h(C=>C+1),T})},Y=w=>t?F[w].code.length:w===r?k:0;return e.jsxs("div",{ref:y,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:E,"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"}),F.map((w,T)=>e.jsx("button",{ref:C=>{u.current[T]=C},role:"tab",id:`sc-tab-${w.id}`,"aria-selected":T===r,"aria-controls":`sc-pane-${w.id}`,onClick:()=>{T===r?h(C=>C+1):s(T)},onKeyDown:C=>{var L,M;C.key==="ArrowRight"&&((L=u.current[(T+1)%F.length])==null||L.focus()),C.key==="ArrowLeft"&&((M=u.current[(T-1+F.length)%F.length])==null||M.focus())},className:`relative z-10 whitespace-nowrap rounded-full px-5 py-2 text-sm font-semibold transition-colors ${T===r?"text-paper":"text-sub hover:text-ink"}`,children:w.label},w.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 ${b?"opacity-0":"opacity-100"}`,children:F[g].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:j.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:[F.map((w,T)=>e.jsx("div",{ref:C=>{f.current[T]=C},role:"tabpanel",id:`sc-pane-${w.id}`,"aria-labelledby":`sc-tab-${w.id}`,className:`absolute inset-0 transition-opacity duration-300 ${T===r?"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:w.chat.map((C,L)=>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)]"}),C.who==="you"?"You":"LevelCode"]}),e.jsx("div",{"data-text":C.text,className:C.who==="you"?"text-[#c7cbe0]":"text-[#8b93ad]",children:t?C.text:""})]},L))}),e.jsx("div",{className:"overflow-hidden whitespace-pre p-5 font-mono text-[12px] leading-[1.9] text-[#c7cbe0] md:text-[13px]",children:w.code.slice(0,Y(T)).map((C,L)=>e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.6em] select-none text-[#3b4157]",children:C.no}),C.toks.map((M,q)=>e.jsx("span",{className:M.c??"text-[#c7cbe0]",children:M.t},q)),L===Y(T)-1&&!t&&e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]},L))})]})},w.id)),!t&&e.jsx("button",{type:"button",onClick:I,"aria-label":a?"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:a?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:a&&c&&!t?{animation:`scfill ${R}s linear forwards`}:void 0},m)})]})]})]})}const he="https://github.com/levelcodeai/levelcode/releases/latest",ot=`${he}/download/LevelCode-arm64.dmg`,lt=`${he}/download/LevelCode-x64.dmg`;function it(){return e.jsx("div",{className:"w-full max-w-2xl text-left",children:e.jsxs("div",{className:"surface p-8",children:[e.jsx("h3",{className:"font-display text-xl font-semibold text-frost",children:"Install in one drag"}),e.jsxs("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:["Download the ",e.jsx("span",{className:"font-mono text-[13px]",children:".dmg"}),", open it, drag LevelCode to Applications. Add your API key — or point it at local Ollama — and the editor starts editing with you."]}),e.jsxs("div",{className:"mt-6 flex flex-wrap gap-3",children:[e.jsxs("a",{href:ot,className:"btn-primary",download:!0,children:[e.jsx(ke,{}),"Download for Apple Silicon"]}),e.jsxs("a",{href:lt,className:"btn-ghost",download:!0,children:[e.jsx(ke,{}),"Intel Mac"]})]}),e.jsxs("p",{className:"mt-4 font-mono text-[12px] text-ghost/70",children:["free · MIT · no account required ·"," ",e.jsx("a",{href:he,target:"_blank",rel:"noreferrer",className:"underline decoration-line underline-offset-4 transition-colors hover:text-frost",children:"all releases →"})]})]})})}function ke(){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"})})}const ct="https://github.com/levelcodeai/levelcode",dt=[{href:"#runtime",label:"Runtime"},{href:"#sketches",label:"Sketches"},{href:"#systems",label:"Systems"},{href:"#models",label:"Models"}];function ut(){const{profile:t}=H(),[n,r]=i.useState(!1);return i.useEffect(()=>{const s=()=>r(window.scrollY>12);return s(),window.addEventListener("scroll",s,{passive:!0}),()=>window.removeEventListener("scroll",s)},[]),e.jsx("header",{className:`fixed inset-x-0 top-0 z-50 transition-colors duration-300 ${n?"border-b border-rule bg-paper/85 backdrop-blur-md":"border-b border-transparent"}`,children:e.jsxs("nav",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-5",children:[e.jsxs("a",{href:"#top",className:"font-display text-[15px] font-bold tracking-tightest text-ink",children:["Level",e.jsx("span",{className:"pp",children:"Code"}),".ai"]}),e.jsx("div",{className:"hidden items-center gap-7 lg:flex",children:dt.map(s=>e.jsx("a",{href:s.href,className:"text-sm text-sub transition-colors hover:text-flame",children:s.label},s.href))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("a",{href:ct,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(D,{to:"/download",className:"rounded-full bg-flame px-4 py-1.5 text-sm font-semibold text-paper transition-colors hover:bg-flamedeep",children:"Download"}),t?e.jsx(D,{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:Le(t.name,t.email)}):e.jsx(D,{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 ee=[{tilt:-.52,rx:.46,ry:.16,speed:.5,viz:1,electrons:[{a:.3,label:"plan"},{a:Math.PI+.6,label:"verify"}]},{tilt:.55,rx:.42,ry:.15,speed:-.38,viz:2,electrons:[{a:1.4,label:"edit"},{a:4.2,label:"chat"}]},{tilt:1.38,rx:.44,ry:.17,speed:.3,viz:3,electrons:[{a:2.6,label:"run"},{a:5.6,label:"skill"}]}];function xt({className:t="",labels:n=!0}){const r=i.useRef(null);return i.useEffect(()=>{const s=r.current;if(!s)return;const a=s.getContext("2d");if(!a)return;const l=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let c=0,d=1;const N=ee.map(f=>f.electrons.map(v=>v.a));let h=["#7d6bff","#5fb4ff","#a8ecff"],k="rgba(125, 107, 255, 0.05)";const o=()=>{const f=getComputedStyle(document.documentElement);h=[1,2,3].map(j=>f.getPropertyValue(`--viz-${j}`).trim()||h[j-1]);const v=f.getPropertyValue("--accent-rgb").trim();v&&(k=`rgba(${v.split(/\s+/).join(", ")}, 0.05)`)};o();const g=new MutationObserver(()=>{o(),l&&S()});g.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const x=()=>{var v;const f=(v=s.parentElement)==null?void 0:v.getBoundingClientRect();c=Math.min(720,f?Math.min(f.width,f.height):640),d=Math.min(2,window.devicePixelRatio||1),s.width=c*d,s.height=c*d,s.style.width=`${c}px`,s.style.height=`${c}px`,a.setTransform(d,0,0,d,0,0)},b=(f,v)=>{const j=c/2,R=Math.cos(v)*f.rx*c,I=Math.sin(v)*f.ry*c,Y=Math.cos(f.tilt),w=Math.sin(f.tilt);return{x:j+R*Y-I*w,y:j+R*w+I*Y}},S=()=>{const f=c/2;a.clearRect(0,0,c,c),a.save(),a.translate(f,f),a.strokeStyle=k,a.lineWidth=1;const v=c/18;for(let j=-10;j<=10;j++)a.beginPath(),a.moveTo(j*v,-f),a.lineTo(j*v,f),a.stroke(),a.beginPath(),a.moveTo(-f,j*v),a.lineTo(f,j*v),a.stroke();a.restore(),ee.forEach(j=>{a.save(),a.translate(f,f),a.rotate(j.tilt),a.strokeStyle=h[j.viz-1]+"4d",a.lineWidth=1,a.setLineDash([3,7]),a.beginPath(),a.ellipse(0,0,j.rx*c,j.ry*c,0,0,Math.PI*2),a.stroke(),a.restore()}),ee.forEach((j,R)=>{const I=h[j.viz-1];j.electrons.forEach((Y,w)=>{const T=N[R][w],C=Math.sign(j.speed)||1;for(let M=14;M>=1;M--){const q=b(j,T-C*M*.045);a.globalAlpha=.45*(1-M/15),a.fillStyle=I,a.beginPath(),a.arc(q.x,q.y,2.4*(1-M/18),0,Math.PI*2),a.fill()}a.globalAlpha=1;const L=b(j,T);a.save(),a.shadowColor=I,a.shadowBlur=14,a.fillStyle=I,a.beginPath(),a.arc(L.x,L.y,5.4,0,Math.PI*2),a.fill(),a.fillStyle="#ffffff",a.beginPath(),a.arc(L.x,L.y,2.2,0,Math.PI*2),a.fill(),a.restore(),n&&(a.fillStyle=I,a.font="10px ui-monospace, monospace",a.textAlign="left",a.textBaseline="middle",a.fillText(Y.label,L.x+11,L.y-1))})})};if(x(),window.addEventListener("resize",x),l)return S(),()=>{g.disconnect(),window.removeEventListener("resize",x)};let m=0,p=performance.now(),y=window.scrollY,E=1;const u=f=>{m=requestAnimationFrame(u);const v=Math.min(.05,(f-p)/1e3);p=f;const j=Math.abs(window.scrollY-y);y=window.scrollY,E=Math.min(4,E+j*.012),E+=(1-E)*.03,ee.forEach((I,Y)=>{I.electrons.forEach((w,T)=>{N[Y][T]+=I.speed*E*v*2})});const R=s.getBoundingClientRect();R.bottom<-100||R.top>window.innerHeight+100||S()};return m=requestAnimationFrame(u),()=>{cancelAnimationFrame(m),g.disconnect(),window.removeEventListener("resize",x)}},[n]),e.jsx("canvas",{ref:r,"aria-hidden":!0,className:`pointer-events-none ${t}`})}function J({no:t,children:n}){return e.jsxs("div",{className:"mb-5 flex items-baseline gap-3",children:[e.jsxs("span",{className:"lineno",children:["L",t]}),e.jsx("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-flame",children:n})]})}const mt=["Anthropic Claude","OpenAI","OpenRouter","Groq","Together","Fireworks","DeepSeek","xAI Grok","Mistral","Ollama — local","Any OpenAI-compatible"];function ht(){return e.jsxs("div",{className:"relative overflow-hidden py-2",children:[e.jsx("div",{className:"flex w-max animate-marquee items-center",style:{animationDuration:"42s"},children:[0,1].map(t=>e.jsx("div",{"aria-hidden":t===1,className:"flex items-center gap-4 pr-4",children:mt.map(n=>e.jsxs("span",{className:"flex items-center gap-2.5 whitespace-nowrap rounded-full border border-rule bg-card px-5 py-2.5 font-display text-[15px] font-semibold text-ink",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-flame"}),n]},n))},t))}),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-paper to-transparent"}),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-paper to-transparent"})]})}function $({children:t,delay:n=0,className:r=""}){const s=i.useRef(null),[a,l]=i.useState(!1);return i.useEffect(()=>{const c=s.current;if(!c)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){l(!0);return}const d=new IntersectionObserver(([N])=>{N.isIntersecting&&(l(!0),d.disconnect())},{rootMargin:"-12% 0px -8% 0px"});return d.observe(c),()=>d.disconnect()},[]),e.jsx("div",{ref:s,className:r,style:{opacity:a?1:0,transform:a?"none":"translateY(14px)",transition:`opacity 0.7s cubic-bezier(0.16,1,0.3,1) ${n}s, transform 0.7s cubic-bezier(0.16,1,0.3,1) ${n}s`},children:t})}function pt(){const[t,n]=i.useState(0);return i.useEffect(()=>{let r=0;const s=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{const a=document.documentElement.scrollHeight-window.innerHeight;n(a>0?Math.min(1,window.scrollY/a):0)})};return s(),window.addEventListener("scroll",s,{passive:!0}),window.addEventListener("resize",s),()=>{cancelAnimationFrame(r),window.removeEventListener("scroll",s),window.removeEventListener("resize",s)}},[]),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none fixed inset-x-0 top-0 z-[60] h-[2px]",children:e.jsx("div",{className:"h-full bg-flame/90 transition-[width] duration-150 ease-out",style:{width:`${t*100}%`}})})}const ft={amber:"#e2a43c",blue:"#57a2e8",green:"#7cb85c"},gt={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"}]},bt={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"}]},Se=[gt,bt],yt={"Design a Key-Value Store":"KV","Real-time Gaming Leaderboard":"LB"},vt=200,te=44;function jt(){const[t,n]=i.useState(null),[r,s]=i.useState(""),[a,l]=i.useState(!1),[c,d]=i.useState(!1),[N,h]=i.useState(new Set),k=i.useRef(null),o=i.useRef([]),g=i.useCallback(m=>{n(m),s(m.goal),h(new Set)},[]),x=i.useCallback(()=>{t&&(o.current.forEach(clearTimeout),o.current=[],h(new Set),t.nodes.forEach((m,p)=>{const y=setTimeout(()=>{h(u=>new Set(u).add(m.id))},p*900),E=setTimeout(()=>{h(u=>{const f=new Set(u);return f.delete(m.id),f})},p*900+1600);o.current.push(y,E)}))},[t]);i.useEffect(()=>()=>o.current.forEach(clearTimeout),[]);const b=m=>{m.preventDefault(),d(!1),l(!1);const p=m.dataTransfer.getData("text/levelcode-sketch"),y=Se.find(E=>E.name===p);y&&g(y)},S=m=>t==null?void 0:t.nodes.find(p=>p.id===m);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:Se.map(m=>e.jsxs("button",{type:"button",draggable:!0,onDragStart:p=>{p.dataTransfer.setData("text/levelcode-sketch",m.name),p.dataTransfer.effectAllowed="copy",l(!0)},onDragEnd:()=>l(!1),onClick:()=>g(m),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:yt[m.name]??"◆"}),e.jsx("span",{className:"font-display text-[13.5px] font-semibold leading-tight text-ink",children:m.name})]}),e.jsxs("p",{className:"mt-2 font-mono text-[10px] uppercase tracking-[0.14em] text-faint",children:[m.nodes.length," agents · ",m.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 →"})]},m.name))})]}),e.jsxs("div",{ref:k,onDragOver:m=>{m.preventDefault(),m.dataTransfer.dropEffect="copy",d(!0)},onDragLeave:()=>d(!1),onDrop:b,className:`relative min-h-[440px] overflow-hidden rounded-xl border bg-[#f2f0ea] transition-colors ${c?"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:r,onChange:m=>s(m.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:x,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 ${a||c?"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((m,p)=>{const y=S(m.from),E=S(m.to);if(!y||!E)return null;const u=y.x+vt,f=y.y+te,v=E.x,j=E.y+te;return e.jsx("path",{d:`M${u},${f} C ${u+70},${f} ${v-70},${j} ${v},${j}`,fill:"none",stroke:"#b9b4a8",strokeWidth:1.5},p)})}),t.nodes.map(m=>{const p=ft[m.color],y=N.has(m.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)] ${y?"sb-node--running":""}`,style:{left:m.x,top:m.y,borderColor:y?"transparent":"#e2ddd2"},children:[y&&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] ${y?"sb-pulse":""}`,style:{background:y?"#65a34a":p}}),e.jsx("span",{className:"truncate text-[13px] font-semibold text-[#2a2822]",children:m.label}),y?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: ",m.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:te-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:te-5}})]},m.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(m=>e.jsx("span",{className:"rounded-md border border-[#e2ddd2] bg-white px-2 py-1 shadow-sm",children:m},m))})]})]})}const wt=[{value:0,suffix:" ",label:"telemetry events phoned home"},{value:0,suffix:" ",label:"servers between you and your model"},{value:10,suffix:"+",label:"providers · hundreds of models"},{value:100,suffix:"%",label:"of AI runs on your own key"}];function Nt(t,n,r=1100){const[s,a]=i.useState(0);return i.useEffect(()=>{if(!n)return;if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){a(t);return}let l=0;const c=performance.now(),d=N=>{const h=Math.min(1,(N-c)/r),k=1-Math.pow(1-h,3);a(Math.round(k*t)),h<1&&(l=requestAnimationFrame(d))};return l=requestAnimationFrame(d),()=>cancelAnimationFrame(l)},[t,n,r]),s}function kt({stat:t,run:n}){const r=Nt(t.value,n);return e.jsxs("div",{className:"border-t border-rule pt-4",children:[e.jsxs("div",{className:"font-display text-[clamp(2rem,5vw,3rem)] font-bold leading-none tracking-tightest text-ink tabular-nums",children:[t.prefix,r,e.jsx("span",{className:"text-flame",children:t.suffix})]}),e.jsx("p",{className:"mt-2 font-mono text-[12px] leading-snug text-faint",children:t.label})]})}function St(){const t=i.useRef(null),[n,r]=i.useState(!1);return i.useEffect(()=>{const s=t.current;if(!s)return;const a=new IntersectionObserver(([l])=>{l.isIntersecting&&(r(!0),a.disconnect())},{rootMargin:"-10% 0px -10% 0px"});return a.observe(s),()=>a.disconnect()},[]),e.jsx("div",{ref:t,className:"grid grid-cols-2 gap-x-8 gap-y-8 md:grid-cols-4",children:wt.map(s=>e.jsx(kt,{stat:s,run:n},s.label))})}const Ce="https://github.com/levelcodeai/levelcode",Ct=["read_codebase","edit_file","run_command","update_plan","ask_user","use_skill","verify_loop","checkpoint","background_exec"];function _e(){return e.jsxs("main",{id:"top",className:"relative overflow-hidden",children:[e.jsx(pt,{}),e.jsx(ut,{}),e.jsxs("section",{className:"relative flex min-h-[100svh] flex-col items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(xt,{className:"h-[min(92vw,740px)] w-[min(92vw,740px)] opacity-95"})}),e.jsxs("div",{className:"relative z-10 mx-auto max-w-4xl px-5 text-center",children:[e.jsx($,{children:e.jsxs("div",{className:"mb-6 inline-flex items-center gap-2 rounded-full border border-line bg-abyss/80 px-3 py-1 font-mono text-[12px] text-ghost backdrop-blur-sm",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-electric shadow-[0_0_10px_rgb(var(--accent-rgb)/0.9)]"}),"generation 3 · agentic · macOS · MIT"]})}),e.jsx($,{delay:.05,children:e.jsxs("h1",{className:"font-display text-[clamp(2.8rem,8vw,5.4rem)] font-bold leading-[0.98] tracking-tightest text-frost text-balance",children:["Level",e.jsx("span",{className:"pp",children:"Code"}),".ai"]})}),e.jsx($,{delay:.1,children:e.jsxs("p",{className:"mx-auto mt-6 max-w-xl text-[17px] leading-relaxed text-ghost pretty",children:["The AI-native editor that codes with you. Six agents in quiet orbit — they plan, edit, run, and verify. On ",e.jsx("em",{className:"text-frost",children:"your"})," key, on ",e.jsx("em",{className:"text-frost",children:"your"})," ","machine, no middleman."]})}),e.jsx($,{delay:.15,children:e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsx("a",{href:"#init",className:"btn-primary",children:"Download for macOS"}),e.jsx("a",{href:Ce,target:"_blank",rel:"noreferrer",className:"btn-ghost",children:"Star on GitHub"})]})}),e.jsx($,{delay:.2,children:e.jsx("p",{className:"mt-6 font-mono text-[12px] text-ghost/70",children:"no account · no telemetry · bring your own key"})})]}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 border-t border-line bg-abyss/60 backdrop-blur-sm",children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"flex w-max animate-marquee items-center gap-10 py-3 font-mono text-[12px] text-ghost/70",children:[0,1].map(t=>e.jsx("div",{"aria-hidden":t===1,className:"flex items-center gap-10",children:Ct.map(n=>e.jsxs("span",{className:"whitespace-nowrap",children:[e.jsx("span",{className:"text-electric/80",children:"◈"})," ",n]},n))},t))})})})]}),e.jsx("section",{id:"runtime",className:"scroll-mt-20 border-t border-line bg-abyss/50",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs($,{children:[e.jsx(J,{no:"01",children:"agent runtime"}),e.jsxs("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:["Autonomous where it earns it.",e.jsx("br",{}),"Gated where it matters."]}),e.jsx("p",{className:"mt-6 max-w-2xl text-[17px] leading-relaxed text-ghost pretty",children:"Every edit lands as a reviewable change. Every command waits for your approval. Before the agent says done, it diffs its own diagnostics and runs your tests — repairing what it broke, bounded and cancellable."})]}),e.jsx($,{delay:.08,children:e.jsx("div",{className:"mx-auto mt-12 max-w-4xl",children:e.jsx(at,{})})}),e.jsx("div",{className:"mt-14 grid gap-x-8 gap-y-10 md:grid-cols-2 lg:grid-cols-3",children:_t.map(t=>e.jsx($,{children:e.jsxs("div",{className:"border-t border-line pt-4",children:[e.jsx("span",{className:"font-mono text-[12px] text-electric",children:t.tag}),e.jsx("h3",{className:"mt-3 font-display text-lg font-semibold text-frost",children:t.title}),e.jsx("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:t.body})]})},t.title))})]})}),e.jsx("section",{id:"sketches",className:"scroll-mt-20 border-t border-line",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs($,{children:[e.jsx(J,{no:"02",children:"sketch builder"}),e.jsx("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:"Drag a whole system onto the canvas."}),e.jsxs("p",{className:"mt-6 max-w-2xl text-[17px] leading-relaxed text-ghost pretty",children:["Predefined agent topologies, ready to run — exactly as they appear on the real board. Drag the"," ",e.jsx("span",{className:"font-semibold text-frost",children:"Design a Key-Value Store"})," card onto the canvas and it lays down the eleven wired agents from the ByteByteGo chapter — requirements, architecture, storage engine, consistent hashing, replication + quorum, vector clocks, gossip + failover, integrate + server, tests, build + validate, and a review / run-guide. Or drop the"," ",e.jsx("span",{className:"font-semibold text-frost",children:"Real-time Gaming Leaderboard"})," card for a full Redis-sorted-set build. Set the goal at the top, hit Run, and watch the agents light up in order."]})]}),e.jsx($,{delay:.08,children:e.jsx("div",{className:"mt-12",children:e.jsx(jt,{})})})]})}),e.jsx("section",{id:"systems",className:"scroll-mt-20 border-t border-line bg-abyss/50",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs($,{children:[e.jsx(J,{no:"03",children:"core systems"}),e.jsx("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:"Four subsystems, one editor."})]}),e.jsx("div",{className:"mt-12 grid gap-x-8 gap-y-10 sm:grid-cols-2",children:Et.map(t=>e.jsx($,{children:e.jsxs("div",{className:"border-t border-line pt-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"font-mono text-[12px] text-electric",children:t.key}),e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.18em] text-ghost/60",children:t.sub})]}),e.jsx("h3",{className:"mt-3 font-display text-xl font-semibold text-frost",children:t.name}),e.jsx("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:t.body})]})},t.name))}),e.jsx("div",{className:"mt-14 grid gap-x-8 gap-y-10 md:grid-cols-3",children:Tt.map(t=>e.jsx($,{children:e.jsxs("div",{className:"border-t border-line pt-4",children:[e.jsx("span",{className:"font-mono text-[12px] text-leaf",children:t.tag}),e.jsx("h3",{className:"mt-3 font-display text-lg font-semibold text-frost",children:t.title}),e.jsx("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:t.body})]})},t.title))})]})}),e.jsx("section",{id:"models",className:"scroll-mt-20 border-t border-line",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs($,{children:[e.jsx(J,{no:"04",children:"any model · your key"}),e.jsx("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:"Fuse it to any intelligence — from your machine."}),e.jsx("p",{className:"mt-6 max-w-2xl text-[17px] leading-relaxed text-ghost pretty",children:"One registry, hundreds of models. Anthropic runs on a native adapter with prompt caching and full tool use; everything else flows through one OpenAI-compatible pipe. Requests travel from your machine to the provider — no relay, no logging, keys sealed in your keychain."})]}),e.jsx($,{delay:.08,children:e.jsx("div",{className:"mt-12",children:e.jsx(ht,{})})}),e.jsx($,{delay:.12,children:e.jsx("div",{className:"mt-16",children:e.jsx(St,{})})})]})}),e.jsx("section",{id:"init",className:"scroll-mt-20 border-t border-line bg-abyss/50",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24 text-center",children:[e.jsxs($,{children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(J,{no:"05",children:"download levelcode.ai"})}),e.jsx("h2",{className:"mx-auto max-w-3xl font-display text-[clamp(2.4rem,6vw,4.2rem)] font-semibold leading-[1] tracking-tightest text-frost text-balance",children:"Install the agent swarm."}),e.jsx("p",{className:"mx-auto mt-6 max-w-md text-[17px] leading-relaxed text-ghost pretty",children:"Free and open. Drag the .dmg to Applications, add a key — or run fully offline on local Ollama — and the agents come alive."})]}),e.jsx($,{delay:.08,children:e.jsx("div",{className:"mt-12 flex justify-center",children:e.jsx(it,{})})})]})}),e.jsx("footer",{className:"border-t border-line bg-void/50",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col gap-3 px-5 py-8 font-mono text-[12px] text-ghost/70 md:flex-row md:items-center md:justify-between",children:[e.jsxs("span",{className:"font-display text-sm font-bold tracking-tightest text-frost",children:["Level",e.jsx("span",{className:"pp",children:"Code"}),".ai"]}),e.jsx("span",{children:"Built on Code-OSS · MIT · open source"}),e.jsxs("span",{className:"flex items-center gap-4",children:[e.jsx("a",{href:Ce,target:"_blank",rel:"noreferrer",className:"transition-colors hover:text-frost",children:"GitHub"}),e.jsx("a",{href:"#init",className:"transition-colors hover:text-frost",children:"Download"}),e.jsxs("span",{children:["© ",new Date().getFullYear()]})]})]})})]})}const _t=[{tag:"apply-then-review",title:"Keep / Undo on every file",body:"Edits land instantly and await your verdict — per file or all at once, live +/− totals, state survives reloads."},{tag:"⛨ self-verification",title:"Proves itself before reporting",body:"Diffs diagnostics against a pre-run baseline and runs your verify command; new failures loop back for repair — bounded, never runaway."},{tag:"↩ checkpoints",title:"Rewind any turn",body:"Every agent turn is a checkpoint. One click rolls files, transcript, and pending reviews back to before it ran."},{tag:"▶ approval-gated",title:"A live terminal, on your terms",body:"Commands stream real stdout/stderr only after you approve; Stop kills the whole process tree — no orphaned servers."},{tag:"background",title:"Servers keep running",body:"Long commands detach and keep streaming while the agent works on; it polls output, sniffs the port, tests against the live process."},{tag:"transparent",title:"Real token accounting",body:"A live context meter with actual usage from the provider — click it for the full breakdown. Cost opacity is the enemy."}],Et=[{key:"⇥",sub:"reflex",name:"Autocomplete",body:"Debounced ghost text over every file, cancelled the instant you keep typing. Routed to a fast model per provider."},{key:"⌘⌥I",sub:"cognition",name:"Chat",body:"Streaming chat that knows your project — pin files or let ripgrep + workspace symbols pull context automatically."},{key:"⌘⌥E",sub:"revision",name:"Edit",body:"Select code, state the change, review a true side-by-side diff. Keep or discard — nothing applies behind your back."},{key:"default",sub:"autonomy",name:"Agent",body:"State the goal. It plans, edits across files, runs behind approval gates, and verifies before reporting."}],Tt=[{tag:"np++ toolkit",title:"Power-editing pack",body:"Keystroke macros, line ops, column mode with incrementing numbers, encoding/EOL controls, big-file mode, hot-exit."},{tag:"hack layer",title:"Init script + packages",body:"Code that runs at boot and hot-reloads on save; a package generator with a live dev loop; Atom / NPP / Sublime keymaps."},{tag:"continuity",title:"Sync + import",body:"Built-in Settings Sync, notify-only updates, and one-click import from VS Code, VSCodium, or Cursor."}],Ae="lc_attribution",Me=["linkedin","youtube","ref","utm_source","utm_medium","utm_campaign","utm_content"],$e=120,Lt=40,ne=300,At=40;function Mt(t){if(!t||typeof t!="object")return null;const n=t,r={},s=n.params;if(s&&typeof s=="object")for(const c of Me){const d=s[c];typeof d=="string"&&d&&(r[c]=d.slice(0,$e))}const a=typeof n.source=="string"?n.source.slice(0,Lt):"";if(Object.keys(r).length===0&&!a)return null;const l=(c,d)=>typeof c=="string"?c.slice(0,d):"";return{source:a||"other",params:r,landing:l(n.landing,ne),referrer:l(n.referrer,ne),ts:l(n.ts,At)}}function De(){try{const t=localStorage.getItem(Ae);return t?Mt(JSON.parse(t)):null}catch{return null}}function $t(){if(!(typeof window>"u"))try{if(De())return;const t=new URLSearchParams(window.location.search),n={};for(const a of Me){const l=t.get(a);l&&(n[a]=l.slice(0,$e))}if(Object.keys(n).length===0)return;const s={source:n.linkedin?"linkedin":n.youtube?"youtube":n.utm_source||n.ref||"other",params:n,landing:window.location.pathname.slice(0,ne),referrer:(document.referrer||"").slice(0,ne),ts:new Date().toISOString()};localStorage.setItem(Ae,JSON.stringify(s))}catch{}}function Dt(){return typeof window>"u"?null:De()}function Pt({redirectUri:t,codeChallenge:n}){const[r,s]=i.useState("email"),[a,l]=i.useState(""),[c,d]=i.useState(""),[N,h]=i.useState(!1),[k,o]=i.useState(null);async function g(b){b.preventDefault(),h(!0),o(null);try{await P("/ai/auth/email",{body:{email:a}}),s("code")}catch(S){o(S instanceof X?S.message:"Couldn't send a code. Try again.")}finally{h(!1)}}async function x(b){b.preventDefault(),h(!0),o(null);try{const S=await P("/ai/auth/verify",{body:{email:a,code:c,redirect_uri:t,code_challenge:n,attribution:Dt()}});if(!S.redirect)throw new X(422,"That code is invalid or has expired.");if(!S.redirect.startsWith("/")){const m=window.setTimeout(()=>{h(!1),o("Open LevelCode to finish signing in. If nothing happened, the editor may not be installed on this device.")},1500);window.addEventListener("pagehide",()=>window.clearTimeout(m),{once:!0}),Z(S.redirect);return}Z(S.redirect)}catch(S){o(S instanceof X?S.message:"That code is invalid or has expired."),h(!1)}}return r==="email"?e.jsxs("form",{onSubmit:g,className:"flex flex-col gap-3",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-widest text-faint",children:"Email"}),e.jsx("input",{type:"email",required:!0,autoFocus:!0,autoComplete:"email",value:a,onChange:b=>l(b.target.value),placeholder:"you@studio.dev",className:"rounded-lg border border-rule bg-card px-3 py-2.5 text-[15px] text-ink outline-none transition-colors focus:border-flame"})]}),k?e.jsx("p",{className:"text-[13px] text-red-600",children:k}):null,e.jsx("button",{type:"submit",disabled:N,className:"btn-primary w-full justify-center",children:N?"Sending…":"Email me a sign-in code"})]}):e.jsxs("form",{onSubmit:x,className:"flex flex-col gap-3",children:[e.jsxs("p",{className:"text-[13px] text-sub",children:["We sent a 6-digit code to ",e.jsx("span",{className:"font-medium text-ink",children:a}),". Enter it below."]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-widest text-faint",children:"Verification code"}),e.jsx("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]*",maxLength:6,required:!0,autoFocus:!0,value:c,onChange:b=>d(b.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"rounded-lg border border-rule bg-card px-3 py-2.5 text-center text-[22px] font-semibold tracking-[0.4em] text-ink outline-none transition-colors focus:border-flame"})]}),k?e.jsx("p",{className:"text-[13px] text-red-600",children:k}):null,e.jsx("button",{type:"submit",disabled:N||c.length<6,className:"btn-primary w-full justify-center",children:N?"Verifying…":"Verify & continue"}),e.jsxs("div",{className:"flex items-center justify-between font-mono text-[12px] text-faint",children:[e.jsx("button",{type:"button",onClick:g,disabled:N,className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"Resend code"}),e.jsx("button",{type:"button",onClick:()=>{s("email"),d(""),o(null)},className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"Use a different email"})]})]})}function Rt({redirectUri:t,codeChallenge:n}){return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Ee,{provider:"google",label:"Continue with Google",redirectUri:t,codeChallenge:n,children:e.jsx(Ot,{})}),e.jsx(Ee,{provider:"github",label:"Continue with GitHub",redirectUri:t,codeChallenge:n,children:e.jsx(Ft,{})})]})}function Ee({provider:t,label:n,redirectUri:r,codeChallenge:s,children:a}){return e.jsxs("a",{href:It(t,r,s),className:"flex w-full items-center justify-center gap-2.5 rounded-full border border-rule bg-card px-6 py-3 text-[15px] font-medium text-ink transition-colors hover:border-ink",children:[a,n]})}function It(t,n,r){const s=new URLSearchParams;n&&r&&(s.set("redirect_uri",n),s.set("code_challenge",r));const a=s.toString();return`${me}/ai/auth/oauth/${t}${a?`?${a}`:""}`}function Ot(){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 Ft(){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 qt={session_expired:"Your sign-in session expired. Please try again.",link_expired:"That sign-in link expired. Please try again from the editor."};function Bt(){const t=re(),[n]=Oe(),r=n.get("redirect_uri"),s=n.get("code_challenge"),a=n.get("error"),l=r&&s?{redirectUri:r,codeChallenge:s}:null,c=!!l,{loading:d,profile:N}=H(),[h,k]=i.useState("idle");return i.useEffect(()=>{if(!d){if(!N){k("form");return}if(r&&s){k("completing");let o=!0;return P("/ai/authorize_editor",{method:"POST",body:{redirect_uri:r,code_challenge:s}}).then(g=>{o&&(g.redirect?Z(g.redirect):k("form"))}).catch(()=>{o&&k("form")}),()=>{o=!1}}t("/account",{replace:!0})}},[d,N,r,s,t]),h==="completing"?e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto flex min-h-[100svh] max-w-6xl flex-col items-center justify-center px-5 py-28",children:e.jsxs("div",{className:"surface w-full max-w-md p-8 text-center",children:[e.jsx("div",{className:"lineno mb-3",children:"connecting"}),e.jsx("h1",{className:"font-display text-xl font-semibold tracking-tightest",children:"Opening LevelCode…"}),e.jsx("p",{className:"mt-3 text-[14px] text-sub pretty",children:"Signing the editor into your account. You can return to LevelCode — this tab can be closed."})]})})]}):h!=="form"?e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto flex min-h-[100svh] max-w-6xl flex-col items-center justify-center px-5 py-28"})]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto flex min-h-[100svh] max-w-6xl flex-col items-center justify-center px-5 py-28",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"lineno mb-4",children:"01 · sign in"}),e.jsxs("h1",{className:"font-display text-[clamp(2rem,4.5vw,2.8rem)] font-semibold leading-[1.04] tracking-tightest",children:["Welcome to ",e.jsx("span",{className:"pp",children:"LevelCode"})," Cloud"]}),e.jsx("p",{className:"mt-4 text-[15px] leading-relaxed text-sub pretty",children:c?"Sign in to connect the editor to your account. You’ll be sent back to LevelCode when you’re done.":"Sign in to manage your plan, keys, and usage."}),e.jsxs("div",{className:"surface mt-8 p-7",children:[a?e.jsx("div",{role:"alert",className:"mb-5 rounded-lg border border-red-500/40 bg-red-500/10 px-4 py-3 text-[13px] text-red-700",children:qt[a]??"Sign-in failed. Please try again."}):null,e.jsx(Rt,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-faint","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 border-t border-rule"}),e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-widest",children:"or"}),e.jsx("span",{className:"flex-1 border-t border-rule"})]}),e.jsx(Pt,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge})]}),e.jsxs("p",{className:"mt-5 font-mono text-[12px] text-faint",children:["By continuing you agree to the"," ",e.jsx(D,{to:"/terms",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"terms"})," ","and"," ",e.jsx(D,{to:"/privacy",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"privacy policy"}),". Bring your own key — we never resell provider access."]})]})})]})}function Yt({tiers:t,authed:n,currentPlan:r}){const s=re(),[a,l]=i.useState(null),[c,d]=i.useState(null),N=o=>(o??"").trim().toLowerCase(),h=o=>n&&!!r&&N(r)===N(o.name);async function k(o){if(d(null),!n){s("/login");return}l(o.key);try{const g=await P("/ai/checkout",{body:{lookup_key:o.key}});if(g.url){Z(g.url);return}if(g.status==="plan_changed"){s("/account?checkout=changed");return}d("Could not start checkout."),l(null)}catch(g){d(g instanceof X?g.message:"Could not start checkout."),l(null)}}return e.jsxs(e.Fragment,{children:[c?e.jsx("p",{className:"mt-6 font-mono text-[12px] text-flame",role:"alert",children:c}):null,e.jsx("div",{className:"mt-12 grid gap-5 sm:grid-cols-2 lg:grid-cols-4",children:t.map((o,g)=>{const x=g===1,b=h(o);return e.jsxs("div",{className:`surface flex flex-col p-6 ${b?"ring-2 ring-flame":x?"ring-1 ring-flame/40":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-display text-lg font-semibold",children:o.name}),b?e.jsx("span",{className:"rounded-full bg-flame px-2 py-0.5 font-mono text-[10px] uppercase tracking-widest text-white",children:"current"}):x?e.jsx("span",{className:"rounded-full bg-flame/10 px-2 py-0.5 font-mono text-[10px] uppercase tracking-widest text-flame",children:"popular"}):null]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-1",children:[e.jsx("span",{className:"font-display text-3xl font-bold tracking-tightest",children:Ut(o.price_cents)}),e.jsxs("span",{className:"text-sm text-faint",children:["/",o.interval||"mo"]})]}),e.jsxs("dl",{className:"mt-5 space-y-1.5 font-mono text-[12px] text-sub",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-faint",children:"input"}),e.jsx("dd",{className:"tabular-nums",children:Te(o.input_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-faint",children:"output"}),e.jsx("dd",{className:"tabular-nums",children:Te(o.output_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-faint",children:"turns"}),e.jsx("dd",{className:"tabular-nums",children:(o.turns??0).toLocaleString()})]})]}),e.jsx("ul",{className:"mt-5 flex-1 space-y-2 text-[13px] text-sub",children:(o.features??[]).map(S=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"mt-1.5 h-1 w-1 flex-none rounded-full bg-flame"}),e.jsx("span",{className:"pretty",children:S})]},S))}),b?e.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"mt-6 w-full cursor-default justify-center btn-ghost opacity-70",children:"✓ Current plan"}):e.jsx("button",{onClick:()=>k(o),disabled:a===o.key,className:`mt-6 w-full justify-center ${x?"btn-primary":"btn-ghost"}`,children:a===o.key?"Starting…":n?"Choose plan":"Sign in to start"})]},o.key)})})]})}function Ut(t){const n=t/100;return`$${n%1===0?n.toFixed(0):n.toFixed(2)}`}function Te(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString()}function zt(){const{profile:t}=H(),[n,r]=i.useState([]),[s,a]=i.useState(null);return i.useEffect(()=>{let l=!0;return P("/api/levelcode/v1/pricing").then(c=>{l&&r(c.tiers??[])}).catch(()=>{l&&a("Pricing is temporarily unavailable. Please try again shortly.")}),()=>{l=!1}},[]),e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-28",children:[e.jsx("div",{className:"lineno mb-4",children:"04 · pricing"}),e.jsx("h1",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-balance",children:"Plans that scale with your orbit"}),e.jsx("p",{className:"mt-5 max-w-xl text-[17px] leading-relaxed text-sub pretty",children:"Every plan is bring-your-own-key by default. Switch on the gateway and your monthly token cap is all you pay — we never mark up the provider."}),s?e.jsx("div",{className:"surface mt-12 p-8 text-[15px] text-sub",children:s}):e.jsx(Yt,{tiers:n,authed:!!t,currentPlan:(t==null?void 0:t.plan)??null})]})]})}function Pe({eyebrow:t,title:n,updated:r,intro:s,children:a}){return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-24",children:[e.jsx("div",{className:"lineno mb-4",children:t}),e.jsx("h1",{className:"font-display text-[clamp(2rem,5vw,3rem)] font-semibold leading-[1.05] tracking-tightest text-balance",children:n}),e.jsxs("p",{className:"mt-4 font-mono text-[12px] text-faint",children:["Last updated: ",r]}),e.jsx("p",{className:"mt-6 max-w-2xl text-[16px] leading-relaxed text-sub pretty",children:s}),e.jsx("div",{className:"mt-10 space-y-9",children:a}),e.jsxs("div",{className:"mt-16 border-t border-rule pt-6 font-mono text-[12px] text-faint",children:[e.jsx(D,{to:"/terms",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"Terms"}),e.jsx("span",{className:"px-2",children:"·"}),e.jsx(D,{to:"/privacy",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"Privacy"}),e.jsx("span",{className:"px-2",children:"·"}),e.jsx(D,{to:"/",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"levelcode.ai"})]})]})]})}function A({id:t,heading:n,children:r}){return e.jsxs("section",{id:t,className:"scroll-mt-24",children:[e.jsx("h2",{className:"font-display text-xl font-semibold tracking-tight text-ink",children:n}),e.jsx("div",{className:"mt-3 space-y-3 text-[15px] leading-relaxed text-sub pretty",children:r})]})}function Gt(){return e.jsxs(Pe,{eyebrow:"09 · legal",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(A,{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-ink",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-ink",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-ink",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-ink",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(A,{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(A,{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-ink",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-ink",children:"Payments"})," — Stripe, to process subscriptions and payments."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-ink",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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{id:"contact",heading:"11. Contact",children:e.jsxs("p",{children:["Privacy questions or requests? Email"," ",e.jsx("a",{href:"mailto:privacy@levelcode.ai",className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"privacy@levelcode.ai"}),"."]})})]})}function Wt(){return e.jsxs(Pe,{eyebrow:"09 · legal",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:"underline decoration-rule underline-offset-4 hover:text-ink",children:"Privacy Policy"}),"."]}),children:[e.jsx(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{heading:"13. Contact",children:e.jsxs("p",{children:["Questions about these Terms? Email"," ",e.jsx("a",{href:"mailto:legal@levelcode.ai",className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"legal@levelcode.ai"}),"."]})})]})}function Ht(){return e.jsxs(Fe,{children:[e.jsx(U,{path:"/",element:e.jsx(_e,{})}),e.jsx(U,{path:"/login",element:e.jsx(Bt,{})}),e.jsx(U,{path:"/pricing",element:e.jsx(zt,{})}),e.jsx(U,{path:"/account",element:e.jsx(Ze,{})}),e.jsx(U,{path:"/admin",element:e.jsx(tt,{})}),e.jsx(U,{path:"/terms",element:e.jsx(Wt,{})}),e.jsx(U,{path:"/privacy",element:e.jsx(Gt,{})}),e.jsx(U,{path:"/download",element:e.jsx(rt,{})}),e.jsx(U,{path:"*",element:e.jsx(_e,{})})]})}$t();qe(document.getElementById("root")).render(e.jsx(i.StrictMode,{children:e.jsx(Be,{basename:"/ai",children:e.jsx(Ht,{})})})); diff --git a/app/assets/interface/levelcode-TaNaT5-t.js b/app/assets/interface/levelcode-TaNaT5-t.js new file mode 100644 index 00000000..692fab5c --- /dev/null +++ b/app/assets/interface/levelcode-TaNaT5-t.js @@ -0,0 +1 @@ +var Ie=Object.defineProperty;var Oe=(t,n,r)=>n in t?Ie(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r;var ae=(t,n,r)=>Oe(t,typeof n!="symbol"?n+"":n,r);import{r as i,j as e,L as P,u as re,d as Fe,e as qe,f as U,g as Be,B as Ye}from"./chunk-7R3XDUXW-BMhzTiu5.js";const Ue=typeof window<"u"&&window.__ENV__||{},pe=String(Ue.API_BASE??"").replace(/\/+$/,"");let oe=null;async function ze(){const t=typeof document<"u"?document.querySelector('meta[name="csrf-token"]'):null,n=t==null?void 0:t.getAttribute("content");return n||(oe||(oe=fetch(`${pe}/ai/csrf`,{credentials:"include"}).then(r=>r.ok?r.json():{token:""}).then(r=>r.token??"").catch(()=>"")),oe)}class X extends Error{constructor(r,s,a){super(s);ae(this,"status");ae(this,"code");this.name="ApiError",this.status=r,this.code=a}}async function $(t,n={}){const r=n.method??(n.body!==void 0?"POST":"GET"),s={Accept:"application/json",...n.headers};n.body!==void 0&&(s["Content-Type"]="application/json"),r!=="GET"&&r!=="HEAD"&&(s["X-CSRF-Token"]=await ze());const a=await fetch(`${pe}${t}`,{method:r,headers:s,credentials:"include",body:n.body!==void 0?JSON.stringify(n.body):void 0}),l=await a.text();let c=null;if(l)try{c=JSON.parse(l)}catch{c=null}if(!a.ok){const d=c==null?void 0:c.error;throw new X(a.status,(d==null?void 0:d.message)??`Request failed (${a.status})`,d==null?void 0:d.code)}return c}function Z(t){window.location.href=t}function H(){const[t,n]=i.useState({loading:!0,profile:null});return i.useEffect(()=>{let r=!0;return $("/api/levelcode/v1/account/profile").then(s=>{r&&n({loading:!1,profile:s})}).catch(()=>{r&&n({loading:!1,profile:null})}),()=>{r=!1}},[]),t}function Ae(t,n){const r=(t||n||"").trim();if(!r)return"··";const s=r.split(/[\s@._-]+/).filter(Boolean);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():r.slice(0,2).toUpperCase()}const Ge="https://github.com/levelcodeai/levelcode",We="levelcode://levelcode.levelcode-ai/launch";function B(){const{profile:t}=H();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(P,{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(P,{to:"/pricing",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Pricing"}),e.jsx("a",{href:Ge,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(P,{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(P,{to:"/admin",className:"hidden text-sm text-sub transition-colors hover:text-flame sm:inline",children:"Admin"}):null,e.jsxs("a",{href:We,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(P,{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:Ae(t.name,t.email)})]}):e.jsx(P,{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 He=1e4,Q="en-US";function fe(t){return(t??0)/He}function Ve(t){const n=fe(t);return(n>0?Math.round(n):0).toLocaleString(Q)}function me(t){const n=fe(t);return n>0?n>=10?Math.round(n).toLocaleString(Q):n<.05?"<0.1":n.toFixed(1):"0"}function he(t){return(t??0).toLocaleString(Q)}const Ke=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],be=["bg-rule/50","bg-flame/25","bg-flame/50","bg-flame/75","bg-flame"];function Je(t){return`${t.getUTCFullYear()}-${String(t.getUTCMonth()+1).padStart(2,"0")}-${String(t.getUTCDate()).padStart(2,"0")}`}function Xe(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`:he(t)}function le(t){const[n,r,s]=t.split("-").map(Number);return new Date(Date.UTC(n,r-1,s)).toLocaleDateString(void 0,{weekday:"short",month:"short",day:"numeric",year:"numeric",timeZone:"UTC"})}function Ze({activity:t,year:n,years:r,onYear:s}){const[a,l]=i.useState(null),c=(t==null?void 0:t.days)??{},{weeks:d,monthCols:g}=i.useMemo(()=>{var C;const o=new Date(Date.UTC(n,0,1)),f=new Date(o);f.setUTCDate(o.getUTCDate()-o.getUTCDay());const b=new Date(Date.UTC(n,11,31)),T=new Date(b);T.setUTCDate(b.getUTCDate()+(6-b.getUTCDay()));const N=[],x=[],h=new Date(f);let y=-1;for(;h<=T;){const u=[];let p=null;for(let v=0;v<7;v++){const j=h.getUTCFullYear()===n;if(v===0&&(p=j?h.getUTCMonth():null),j){const R=Je(h);u.push({key:R,count:((C=c[R])==null?void 0:C.count)??0,date:new Date(h)})}else u.push({key:null,count:0,date:null});h.setUTCDate(h.getUTCDate()+1)}p!=null&&p!==y?(x.push(Ke[p]),y=p):x.push(null),N.push(u)}return{weeks:N,monthCols:x}},[n,c]),m=a?c[a]??null:null,_=(t==null?void 0:t.models)??[];return e.jsxs("div",{className:"surface 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:"lineno",children:"activity"}),e.jsxs("div",{className:"mt-1 font-display text-lg font-semibold tracking-tightest",children:[he((t==null?void 0:t.total)??0)," request",((t==null?void 0:t.total)??0)===1?"":"s"," in ",n]})]}),r.length>1?e.jsx("div",{className:"flex flex-wrap gap-1",children:r.map(o=>e.jsx("button",{type:"button",onClick:()=>{l(null),s(o)},className:`rounded-md px-2.5 py-1 font-mono text-[12px] transition-colors ${o===n?"bg-flame text-white":"text-sub hover:bg-rule/60"}`,children:o},o))}):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:g.map((o,f)=>e.jsx("div",{className:"w-[11px] font-mono text-[10px] text-faint",children:o?e.jsx("span",{className:"relative -left-[1px] whitespace-nowrap",children:o}):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((o,f)=>e.jsx("div",{className:"h-[11px] font-mono text-[9px] leading-[11px] text-faint",children:o},f))}),d.map((o,f)=>e.jsx("div",{className:"flex flex-col gap-[3px]",children:o.map((b,T)=>{var C,u;if(!b.key)return e.jsx("div",{className:"h-[11px] w-[11px]"},T);const N=Xe(b.count),x=a===b.key,h=(u=(C=c[b.key])==null?void 0:C.models)==null?void 0:u[0],y=b.count>0?`${le(b.key)} · ${b.count} request${b.count===1?"":"s"}${h?` · ${ie(h.model)} ${h.count}`:""}`:`${le(b.key)} · no activity`;return e.jsx("button",{type:"button",title:y,onClick:()=>l(x?null:b.key),className:`h-[11px] w-[11px] rounded-[2px] ${be[N]} ${x?"ring-1 ring-ink ring-offset-1":""} transition-colors hover:ring-1 hover:ring-ink/40`},T)})},f))]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 pl-8 font-mono text-[10px] text-faint",children:[e.jsx("span",{className:"mr-1",children:"Less"}),be.map((o,f)=>e.jsx("span",{className:`h-[11px] w-[11px] rounded-[2px] ${o}`},f)),e.jsx("span",{className:"ml-1",children:"More"})]})]})}),a&&m?e.jsxs("div",{className:"mt-6 rounded-lg border border-rule bg-card p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"font-mono text-[12px] text-sub",children:le(a)}),e.jsxs("div",{className:"font-mono text-[12px] text-faint",children:[m.count," req · ",V(m.input)," in · ",V(m.output)," out ·"," ",me(m.cost_micros)," credits"]})]}),e.jsx("ul",{className:"mt-3 space-y-1.5",children:m.models.map(o=>e.jsxs("li",{className:"flex items-center justify-between gap-3 font-mono text-[12px]",children:[e.jsx("span",{className:"truncate text-ink",children:ie(o.model)}),e.jsxs("span",{className:"whitespace-nowrap text-faint",children:[o.count," · ",V(o.input+o.output)," tok"]})]},o.model))})]}):e.jsx("p",{className:"mt-4 font-mono text-[11px] text-faint",children:"Click a day to see its per-model breakdown."}),_.length?e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{className:"lineno mb-3",children:["by model · ",n]}),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-faint",children:e.jsxs("tr",{className:"border-b border-rule",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:_.map(o=>e.jsxs("tr",{className:"border-b border-rule/60",children:[e.jsx("td",{className:"py-1.5 pr-3 text-ink",children:ie(o.model)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:he(o.count)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:V(o.input)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:V(o.output)}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:me(o.cost_micros)}),e.jsx("td",{className:"py-1.5 pl-3 text-right tabular-nums text-faint",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(Qe,{className:"text-sub"})," ",o.up]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(et,{className:"text-sub"})," ",o.down]})]})})]},o.model))})]})})]}):null]})}function ie(t){const n=t||"unknown",r=n.indexOf("/");return r>=0?n.slice(r+1):n}function Qe({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 et({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=re(),{loading:n,profile:r}=H(),[s,a]=i.useState(null),[l,c]=i.useState(null),[d,g]=i.useState(null),[m,_]=i.useState(new Date().getFullYear()),[o,f]=i.useState(null);i.useEffect(()=>{!n&&!r&&t("/login",{replace:!0})},[n,r,t]),i.useEffect(()=>{if(!r)return;let h=!0;return $("/api/levelcode/v1/account/usage").then(y=>{h&&a(y)}).catch(()=>{h&&f("We couldn’t load your usage right now. Please try again shortly.")}),()=>{h=!1}},[r]),i.useEffect(()=>{if(!r)return;let h=!0;return $("/api/levelcode/v1/account/models").then(y=>{h&&c(y)}).catch(()=>{}),()=>{h=!1}},[r]),i.useEffect(()=>{if(!r)return;let h=!0;return $(`/api/levelcode/v1/account/activity?year=${m}`).then(y=>{h&&g(y)}).catch(()=>{}),()=>{h=!1}},[r,m]);async function b(){try{const h=await $("/ai/billing",{method:"POST"});h.url&&Z(h.url)}catch{f("Could not open billing. Please try again.")}}async function T(){try{await $("/ai/signout",{method:"POST"})}catch{}t("/login",{replace:!0})}if(n||!r)return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto max-w-4xl px-5 py-28"})]});const N=s?ve(s.input_used,s.input_cap):0,x=s?ve(s.output_used,s.output_cap):0;return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-4xl px-5 py-28",children:[e.jsx("div",{className:"lineno mb-4",children:"05 · account"}),e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-[clamp(1.9rem,4vw,2.8rem)] font-semibold leading-[1.05] tracking-tightest",children:r.name?`Hi, ${r.name}`:"Your account"}),r.email?e.jsx("p",{className:"mt-2 font-mono text-[13px] text-faint",children:r.email}):null]}),e.jsxs("span",{className:"rounded-full border border-rule bg-card px-3 py-1 font-mono text-[12px] text-sub",children:["plan · ",(s==null?void 0:s.plan)??r.plan??"free"]})]}),o?e.jsx("div",{className:"surface mt-10 p-8 text-[15px] text-sub",children:o}):s?e.jsxs("div",{className:"mt-10 grid gap-5 sm:grid-cols-2",children:[e.jsx(ye,{label:"Input tokens",used:s.input_used,cap:s.input_cap,pct:N}),e.jsx(ye,{label:"Output tokens",used:s.output_used,cap:s.output_cap,pct:x}),e.jsx("div",{className:"surface 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:"lineno",children:"billing period resets"}),e.jsx("div",{className:"mt-1 font-display text-lg font-semibold",children:nt(s.period_end)}),e.jsxs("div",{className:"mt-1 font-mono text-[12px] text-faint",children:["overage policy · ",s.overage_policy]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx("button",{type:"button",onClick:b,className:"btn-ghost",children:"Manage billing"}),e.jsx(P,{to:"/pricing",className:"btn-primary",children:"Upgrade"})]})]})})]}):null,l&&l.models.length?e.jsx(st,{models:l}):null,e.jsx("div",{className:"mt-6",children:e.jsx(Ze,{activity:d,year:m,years:(d==null?void 0:d.years)??[m],onYear:_})}),e.jsx("button",{type:"button",onClick:T,className:"mt-10 font-mono text-[12px] text-faint underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"Sign out"})]})]})}function st({models:t}){const n=t.budget_micros||0,r=t.ceiling_micros??n,s=t.spent_micros||0,a=t.credits_remaining_micros||0,l=r0?Math.min(Math.round(s/r*100),100):0,g=Ve,m=o=>fe(o)>0?me(o):"—",_=o=>o.includes("/")?o.slice(o.indexOf("/")+1):o;return e.jsxs("div",{className:"surface mt-5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[e.jsx("div",{className:"lineno",children:l?"usage available now":"compute credits"}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-sub",children:[g(s)," / ",g(r)," · ",d,"%"]})]}),e.jsxs("div",{className:"mt-1 font-display text-2xl font-semibold tracking-tightest tabular-nums",children:[g(a),e.jsxs("span",{className:"text-sm font-normal text-faint",children:[" ","credits ",l?"available now":"left this period"]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-rule",children:e.jsx("div",{className:`h-full rounded-full ${d>=100?"bg-flamedeep":"bg-flame"}`,style:{width:`${d}%`}})}),l&&c?e.jsxs("div",{className:"mt-2 font-mono text-[11px] text-faint",children:["More unlocks ",c.toLocaleDateString(void 0,{month:"short",day:"numeric"})," · ",g(n)," ","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-faint",children:e.jsxs("tr",{className:"border-b border-rule",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(o=>e.jsxs("tr",{className:`border-b border-rule/60 ${o.live?"":"opacity-55"}`,children:[e.jsx("td",{className:"py-1.5 pr-3 text-ink",children:_(o.id)}),e.jsxs("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",title:`${o.multiplier}× the baseline model`,children:[m(o.per_turn_micros),e.jsxs("span",{className:"sr-only",children:[" credits per turn, ",o.multiplier,"× the baseline model"]})]}),e.jsx("td",{className:"py-1.5 px-3 text-right tabular-nums text-sub",children:o.live?(o.turns_left??0).toLocaleString(Q):"—"}),e.jsx("td",{className:"py-1.5 pl-3 text-right",children:o.live?e.jsx("span",{className:"text-[11px] text-flame",children:"live"}):e.jsx("span",{className:"rounded bg-rule/60 px-1.5 py-0.5 text-[10px] text-faint",children:"soon"})})]},o.id))})]})})]})}function ye({label:t,used:n,cap:r,pct:s}){const a=s>=100;return e.jsxs("div",{className:"surface p-6",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("div",{className:"lineno",children:t}),e.jsxs("div",{className:"font-mono text-[12px] tabular-nums text-sub",children:[s,"%"]})]}),e.jsxs("div",{className:"mt-3 font-display text-2xl font-semibold tracking-tightest tabular-nums",children:[je(n),e.jsxs("span",{className:"text-sm font-normal text-faint",children:[" / ",je(r)]})]}),e.jsx("div",{className:"mt-4 h-2 w-full overflow-hidden rounded-full bg-rule",children:e.jsx("div",{className:`h-full rounded-full ${a?"bg-flamedeep":"bg-flame"}`,style:{width:`${Math.min(s,100)}%`}})})]})}function ve(t,n){return!n||n<=0?0:Math.round(t/n*100)}function je(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString(Q)}function nt(t){if(!t)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?t:n.toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}function rt(){const t=re(),{loading:n,profile:r}=H(),[s,a]=i.useState(null),[l,c]=i.useState(null),[d,g]=i.useState("input"),[m,_]=i.useState("desc"),[o,f]=i.useState(""),[b,T]=i.useState(""),[N,x]=i.useState(null),h=(r==null?void 0:r.role)==="admin";i.useEffect(()=>{n||(r?h||t("/account",{replace:!0}):t("/login",{replace:!0}))},[n,r,h,t]),i.useEffect(()=>{if(!h)return;let u=!0;return $("/api/levelcode/v1/admin/summary").then(p=>u&&a(p)).catch(()=>u&&x("Couldn’t load the admin summary.")),()=>{u=!1}},[h]),i.useEffect(()=>{if(!h)return;let u=!0;const p=new URLSearchParams({sort:d,dir:m,limit:"200"});return o.trim()&&p.set("q",o.trim()),b&&p.set("plan",b),$(`/api/levelcode/v1/admin/users?${p.toString()}`).then(v=>u&&c(v)).catch(()=>u&&x("Couldn’t load users.")),()=>{u=!1}},[h,d,m,o,b]);const y=i.useMemo(()=>Object.keys((s==null?void 0:s.plans)??{}).sort(),[s]);function C(u){d===u?_(p=>p==="desc"?"asc":"desc"):(g(u),_(u==="email"||u==="plan"?"asc":"desc"))}return n||!h?e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto max-w-6xl px-5 py-28"})]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-28",children:[e.jsx("div",{className:"lineno mb-4",children:"06 · admin"}),e.jsx("h1",{className:"font-display text-[clamp(1.9rem,4vw,2.8rem)] font-semibold leading-[1.05] tracking-tightest",children:"System dashboard"}),e.jsx("p",{className:"mt-2 font-mono text-[13px] text-faint",children:"tokens burned · plans · geography · login health"}),N?e.jsx("div",{className:"surface mt-8 p-6 text-[14px] text-flame",children:N}):null,e.jsxs("div",{className:"mt-10 grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(K,{label:"users",value:G(s==null?void 0:s.users),sub:`${G(s==null?void 0:s.active_users)} active`}),e.jsx(K,{label:"requests",value:G(s==null?void 0:s.requests),sub:we(s==null?void 0:s.cost_micros)}),e.jsx(K,{label:"input tokens",value:ee(s==null?void 0:s.input)}),e.jsx(K,{label:"output tokens",value:ee(s==null?void 0:s.output)}),e.jsx(K,{label:"auth attempts",value:G(s==null?void 0:s.auth_attempts),sub:`${G(s==null?void 0:s.auth_failures)} failed`,alert:((s==null?void 0:s.auth_failures)??0)>0}),e.jsx(ce,{label:"plans",map:s==null?void 0:s.plans}),e.jsx(ce,{label:"countries",map:s==null?void 0:s.countries}),e.jsx(ce,{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:o,onChange:u=>f(u.target.value),placeholder:"Search email…",className:"w-full max-w-xs rounded-lg border border-rule bg-card px-3 py-2 font-mono text-[13px] text-ink outline-none focus:border-ink sm:w-auto"}),e.jsxs("select",{value:b,onChange:u=>T(u.target.value),className:"rounded-lg border border-rule bg-card px-3 py-2 font-mono text-[13px] text-sub outline-none focus:border-ink",children:[e.jsx("option",{value:"",children:"all plans"}),y.map(u=>e.jsx("option",{value:u,children:u},u))]}),e.jsxs("span",{className:"font-mono text-[12px] text-faint",children:[G(l==null?void 0:l.total)," users"]})]}),e.jsx("div",{className:"surface 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-faint",children:e.jsxs("tr",{className:"border-b border-rule",children:[e.jsx(z,{label:"email",col:"email",sort:d,dir:m,onClick:C,align:"left"}),e.jsx(z,{label:"plan",col:"plan",sort:d,dir:m,onClick:C,align:"left"}),e.jsx(z,{label:"input",col:"input",sort:d,dir:m,onClick:C}),e.jsx(z,{label:"output",col:"output",sort:d,dir:m,onClick:C}),e.jsx(z,{label:"requests",col:"requests",sort:d,dir:m,onClick:C}),e.jsx(z,{label:"cost",col:"cost",sort:d,dir:m,onClick:C}),e.jsx("th",{className:"px-3 py-2 text-left font-normal",children:"country"}),e.jsx(z,{label:"auth",col:"auth_attempts",sort:d,dir:m,onClick:C}),e.jsx(z,{label:"last seen",col:"last_seen",sort:d,dir:m,onClick:C}),e.jsx("th",{className:"px-3 py-2 text-right font-normal",children:"reach"})]})}),e.jsxs("tbody",{children:[((l==null?void 0:l.users)??[]).map(u=>e.jsxs("tr",{className:"border-b border-rule/60 hover:bg-rule/20",children:[e.jsxs("td",{className:"px-3 py-2 text-ink",children:[u.email,u.role==="admin"?e.jsx("span",{className:"ml-2 rounded bg-flame/15 px-1.5 py-0.5 text-[10px] text-flame",children:"admin"}):null]}),e.jsx("td",{className:"px-3 py-2 text-sub",children:u.plan}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:ee(u.input)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:ee(u.output)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:G(u.requests)}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums text-sub",children:we(u.cost_micros)}),e.jsx("td",{className:"px-3 py-2 text-sub",children:u.country??"—"}),e.jsx("td",{className:"px-3 py-2 text-right tabular-nums",children:e.jsxs("span",{className:u.auth_failures>0?"text-flame":"text-faint",children:[u.auth_attempts,u.auth_failures>0?` · ${u.auth_failures}✗`:""]})}),e.jsx("td",{className:"px-3 py-2 text-faint",children:at(u.last_seen_at)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("a",{className:"text-flame underline decoration-rule underline-offset-2 hover:decoration-flame",href:`mailto:${u.email}`,children:"email"})})]},u.id)),l&&l.users.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:"px-3 py-6 text-center text-faint",children:"No users match."})}):null]})]})})]})]})}function z({label:t,col:n,sort:r,dir:s,onClick:a,align:l="right"}){const c=r===n;return e.jsx("th",{className:`px-3 py-2 font-normal ${l==="right"?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>a(n),className:`inline-flex items-center gap-1 ${c?"text-ink":"hover:text-ink"}`,children:[t,e.jsx("span",{className:"text-[9px]",children:c?s==="desc"?"▼":"▲":"↕"})]})})}function K({label:t,value:n,sub:r,alert:s}){return e.jsxs("div",{className:"surface p-5",children:[e.jsx("div",{className:"lineno",children:t}),e.jsx("div",{className:"mt-1 font-display text-2xl font-semibold tracking-tightest tabular-nums",children:n}),r?e.jsx("div",{className:`mt-1 font-mono text-[11px] ${s?"text-flame":"text-faint"}`,children:r}):null]})}function ce({label:t,map:n,alert:r}){const s=Object.entries(n??{}).sort((a,l)=>l[1]-a[1]);return e.jsxs("div",{className:"surface p-5",children:[e.jsx("div",{className:"lineno",children:t}),s.length?e.jsx("ul",{className:"mt-2 space-y-1 font-mono text-[12px]",children:s.slice(0,5).map(([a,l])=>e.jsxs("li",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sub",children:a}),e.jsx("span",{className:`tabular-nums ${r?"text-flame":"text-faint"}`,children:l})]},a))}):e.jsx("div",{className:"mt-2 font-mono text-[12px] text-faint",children:"—"})]})}function G(t){return(t??0).toLocaleString()}function ee(t){const n=t??0;return n>=1e6?`${+(n/1e6).toFixed(1)}M`:n>=1e3?`${+(n/1e3).toFixed(0)}K`:n.toLocaleString()}function we(t){return`$${((t??0)/1e6).toFixed(2)}`}function at(t){if(!t)return"—";const n=new Date(t);return Number.isNaN(n.getTime())?"—":n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}const Ne="https://github.com/levelcodeai/levelcode/releases/latest",de={arm64:`${Ne}/download/LevelCode-arm64.dmg`,x64:`${Ne}/download/LevelCode-x64.dmg`};async function ot(){var a,l;const t=navigator,n=navigator.userAgent,r=/Mac/i.test(navigator.platform)||/Macintosh/.test(n),s=r&&(navigator.maxTouchPoints??0)>1;if(!r||s)return"not-mac";try{const c=await((l=(a=t.userAgentData)==null?void 0:a.getHighEntropyValues)==null?void 0:l.call(a,["architecture"]));if((c==null?void 0:c.architecture)==="arm")return"arm64";if((c==null?void 0:c.architecture)==="x86")return"x64"}catch{}try{const c=document.createElement("canvas"),d=c.getContext("webgl")||c.getContext("experimental-webgl"),g=d==null?void 0:d.getExtension("WEBGL_debug_renderer_info"),m=g&&d?String(d.getParameter(g.UNMASKED_RENDERER_WEBGL)):"";if(/apple/i.test(m))return"arm64";if(/intel|amd|radeon/i.test(m))return"x64"}catch{}return"unknown-mac"}function lt(){const[t,n]=i.useState("unknown-mac");i.useEffect(()=>{let l=!0;return ot().then(c=>{l&&n(c)}),()=>{l=!1}},[]);const r=t==="x64"?"x64":"arm64",s=r==="arm64"?"Apple Silicon":"Intel",a=t==="not-mac";return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),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."}),a?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:de[r],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:de.arm64,className:"btn-ghost text-[14px]",download:!0,children:"Apple Silicon (M1–M4)"}),e.jsx("a",{href:de.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 O=t=>({t,c:"text-[#c58aff]"}),ke=t=>({t,c:"text-[#7fd88f]"}),W=t=>({t,c:"text-[#9fb4ff]"}),ue=t=>({t,c:"text-[#5b6172]"}),xe=t=>({t,c:"text-[#e6a86b]"}),S=t=>({t}),F=[{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:[O("class"),S(" "),W("RefundService")]},{no:"13",toks:[S(" "),O("def"),S(" "),W("call"),S("(charge, key:)")]},{no:"14",toks:[S(" "),O("return"),S(" cached(key) "),O("if"),S(" seen?(key)")]},{no:"15",toks:[S(" result = gateway.refund(charge)")]},{no:"16",toks:[S(" remember(key, result, ttl: "),xe("24"),S(".hours)")]},{no:"17",toks:[S(" result")]},{no:"18",toks:[S(" "),O("end")]},{no:"19",toks:[O("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:[ue("# before: 62 lines in controller")]},{no:"41",toks:[O("def"),S(" "),W("create")]},{no:"42",toks:[S(" total = "),W("PricingCalculator")]},{no:"43",toks:[S(" .new(cart, coupon: params[:coupon])")]},{no:"44",toks:[S(" .total")]},{no:"45",toks:[S(" order = "),W("Order"),S(".create!(total:)")]},{no:"46",toks:[S(" render json: order")]},{no:"47",toks:[O("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:[O("if"),S(" plan_changed_mid_cycle?")]},{no:"89",toks:[S(" credit = unused_ratio * old_rate")]},{no:"90",toks:[S(" charge = remaining_ratio * new_rate")]},{no:"91",toks:[S(" invoice.adjust(credit:, charge:)")]},{no:"92",toks:[O("end")]},{no:"93",toks:[ue("# ← 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"),S(" "),ke('"refunds only once per key"'),S(" "),O("do")]},{no:"06",toks:[S(" "),xe("2"),S(".times { service.call(charge, key:) }")]},{no:"07",toks:[S(" expect(gateway.refunds.count).to eq("),xe("1"),S(")")]},{no:"08",toks:[O("end")]},{no:"09",toks:[S("")]},{no:"10",toks:[ke("✓ 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:[ue("# ⚠ 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]"},S(" .set(wait: backoff(attempt))")]},{no:"25",toks:[{t:"+ ",c:"text-[#7fd88f]"},S(" .perform_later(webhook.id,")]},{no:"26",toks:[{t:"+ ",c:"text-[#7fd88f]"},S(" lock: webhook.lock_token)")]}]}];function it(){const[t,n]=i.useState(!1),[r,s]=i.useState(0),[a,l]=i.useState(!0),[c,d]=i.useState(!0),[g,m]=i.useState(0),[_,o]=i.useState(0),[f,b]=i.useState(0),[T,N]=i.useState(!1),[x,h]=i.useState(0),y=i.useRef(null),C=i.useRef(null),u=i.useRef([]),p=i.useRef([]),v=i.useRef([]),j=F[r],R=j.duration??9;i.useEffect(()=>{window.matchMedia("(prefers-reduced-motion: reduce)").matches&&(n(!0),l(!1),o(F[r].code.length))},[]),i.useLayoutEffect(()=>{var E;const w=()=>{const k=u.current[r],L=C.current;if(!k||!L||!k.parentElement)return;const M=k.getBoundingClientRect(),q=k.parentElement.getBoundingClientRect();L.style.width=`${M.width}px`,L.style.transform=`translateX(${M.left-q.left}px)`};return w(),window.addEventListener("resize",w),(E=document.fonts)==null||E.ready.then(w).catch(()=>{}),()=>window.removeEventListener("resize",w)},[r,t]),i.useEffect(()=>{const w=y.current;if(!w)return;const E=new IntersectionObserver(([k])=>d(k.isIntersecting),{threshold:.25});return E.observe(w),()=>E.disconnect()},[]),i.useEffect(()=>{if(r===f)return;N(!0);const w=setTimeout(()=>{b(r),N(!1)},200);return()=>clearTimeout(w)},[r,f]),i.useEffect(()=>{if(t||(v.current.forEach(clearTimeout),v.current=[],!a||!c))return;const w=p.current[r],E=w?Array.from(w.querySelectorAll("[data-text]")):[];E.forEach(L=>L.textContent=""),o(0),h(L=>L+1);let k=300;return E.forEach(L=>{const M=L.dataset.text??"";for(let q=1;q<=M.length;q++)k+=14,v.current.push(setTimeout(()=>L.textContent=M.slice(0,q),k));k+=350}),F[r].code.forEach((L,M)=>{k+=320,v.current.push(setTimeout(()=>o(M+1),k))}),v.current.push(setTimeout(()=>s(L=>(L+1)%F.length),(F[r].duration??9)*1e3)),()=>{v.current.forEach(clearTimeout),v.current=[]}},[r,a,c,g,t]);const I=()=>{l(w=>{const E=!w;return E&&m(k=>k+1),E})},Y=w=>t?F[w].code.length:w===r?_:0;return e.jsxs("div",{ref:y,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:C,"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"}),F.map((w,E)=>e.jsx("button",{ref:k=>{u.current[E]=k},role:"tab",id:`sc-tab-${w.id}`,"aria-selected":E===r,"aria-controls":`sc-pane-${w.id}`,onClick:()=>{E===r?m(k=>k+1):s(E)},onKeyDown:k=>{var L,M;k.key==="ArrowRight"&&((L=u.current[(E+1)%F.length])==null||L.focus()),k.key==="ArrowLeft"&&((M=u.current[(E-1+F.length)%F.length])==null||M.focus())},className:`relative z-10 whitespace-nowrap rounded-full px-5 py-2 text-sm font-semibold transition-colors ${E===r?"text-paper":"text-sub hover:text-ink"}`,children:w.label},w.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 ${T?"opacity-0":"opacity-100"}`,children:F[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:j.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:[F.map((w,E)=>e.jsx("div",{ref:k=>{p.current[E]=k},role:"tabpanel",id:`sc-pane-${w.id}`,"aria-labelledby":`sc-tab-${w.id}`,className:`absolute inset-0 transition-opacity duration-300 ${E===r?"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:w.chat.map((k,L)=>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)]"}),k.who==="you"?"You":"LevelCode"]}),e.jsx("div",{"data-text":k.text,className:k.who==="you"?"text-[#c7cbe0]":"text-[#8b93ad]",children:t?k.text:""})]},L))}),e.jsx("div",{className:"overflow-hidden whitespace-pre p-5 font-mono text-[12px] leading-[1.9] text-[#c7cbe0] md:text-[13px]",children:w.code.slice(0,Y(E)).map((k,L)=>e.jsxs("div",{children:[e.jsx("span",{className:"inline-block w-[2.6em] select-none text-[#3b4157]",children:k.no}),k.toks.map((M,q)=>e.jsx("span",{className:M.c??"text-[#c7cbe0]",children:M.t},q)),L===Y(E)-1&&!t&&e.jsx("span",{className:"ml-px inline-block h-[1.05em] w-[2px] -translate-y-[1px] animate-caret bg-[#7d6bff] align-middle"})]},L))})]})},w.id)),!t&&e.jsx("button",{type:"button",onClick:I,"aria-label":a?"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:a?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:a&&c&&!t?{animation:`scfill ${R}s linear forwards`}:void 0},x)})]})]})]})}const ge="https://github.com/levelcodeai/levelcode/releases/latest",ct=`${ge}/download/LevelCode-arm64.dmg`,dt=`${ge}/download/LevelCode-x64.dmg`;function ut(){return e.jsx("div",{className:"w-full max-w-2xl text-left",children:e.jsxs("div",{className:"surface p-8",children:[e.jsx("h3",{className:"font-display text-xl font-semibold text-frost",children:"Install in one drag"}),e.jsxs("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:["Download the ",e.jsx("span",{className:"font-mono text-[13px]",children:".dmg"}),", open it, drag LevelCode to Applications. Add your API key — or point it at local Ollama — and the editor starts editing with you."]}),e.jsxs("div",{className:"mt-6 flex flex-wrap gap-3",children:[e.jsxs("a",{href:ct,className:"btn-primary",download:!0,children:[e.jsx(Se,{}),"Download for Apple Silicon"]}),e.jsxs("a",{href:dt,className:"btn-ghost",download:!0,children:[e.jsx(Se,{}),"Intel Mac"]})]}),e.jsxs("p",{className:"mt-4 font-mono text-[12px] text-ghost/70",children:["free · MIT · no account required ·"," ",e.jsx("a",{href:ge,target:"_blank",rel:"noreferrer",className:"underline decoration-line underline-offset-4 transition-colors hover:text-frost",children:"all releases →"})]})]})})}function Se(){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"})})}const xt="https://github.com/levelcodeai/levelcode",mt=[{href:"#runtime",label:"Runtime"},{href:"#sketches",label:"Sketches"},{href:"#systems",label:"Systems"},{href:"#models",label:"Models"}];function ht(){const{profile:t}=H(),[n,r]=i.useState(!1);return i.useEffect(()=>{const s=()=>r(window.scrollY>12);return s(),window.addEventListener("scroll",s,{passive:!0}),()=>window.removeEventListener("scroll",s)},[]),e.jsx("header",{className:`fixed inset-x-0 top-0 z-50 transition-colors duration-300 ${n?"border-b border-rule bg-paper/85 backdrop-blur-md":"border-b border-transparent"}`,children:e.jsxs("nav",{className:"mx-auto flex h-14 max-w-6xl items-center justify-between px-5",children:[e.jsxs("a",{href:"#top",className:"font-display text-[15px] font-bold tracking-tightest text-ink",children:["Level",e.jsx("span",{className:"pp",children:"Code"}),".ai"]}),e.jsx("div",{className:"hidden items-center gap-7 lg:flex",children:mt.map(s=>e.jsx("a",{href:s.href,className:"text-sm text-sub transition-colors hover:text-flame",children:s.label},s.href))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("a",{href:xt,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(P,{to:"/download",className:"rounded-full bg-flame px-4 py-1.5 text-sm font-semibold text-paper transition-colors hover:bg-flamedeep",children:"Download"}),t?e.jsx(P,{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:Ae(t.name,t.email)}):e.jsx(P,{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 te=[{tilt:-.52,rx:.46,ry:.16,speed:.5,viz:1,electrons:[{a:.3,label:"plan"},{a:Math.PI+.6,label:"verify"}]},{tilt:.55,rx:.42,ry:.15,speed:-.38,viz:2,electrons:[{a:1.4,label:"edit"},{a:4.2,label:"chat"}]},{tilt:1.38,rx:.44,ry:.17,speed:.3,viz:3,electrons:[{a:2.6,label:"run"},{a:5.6,label:"skill"}]}];function pt({className:t="",labels:n=!0}){const r=i.useRef(null);return i.useEffect(()=>{const s=r.current;if(!s)return;const a=s.getContext("2d");if(!a)return;const l=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let c=0,d=1;const g=te.map(p=>p.electrons.map(v=>v.a));let m=["#7d6bff","#5fb4ff","#a8ecff"],_="rgba(125, 107, 255, 0.05)";const o=()=>{const p=getComputedStyle(document.documentElement);m=[1,2,3].map(j=>p.getPropertyValue(`--viz-${j}`).trim()||m[j-1]);const v=p.getPropertyValue("--accent-rgb").trim();v&&(_=`rgba(${v.split(/\s+/).join(", ")}, 0.05)`)};o();const f=new MutationObserver(()=>{o(),l&&N()});f.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});const b=()=>{var v;const p=(v=s.parentElement)==null?void 0:v.getBoundingClientRect();c=Math.min(720,p?Math.min(p.width,p.height):640),d=Math.min(2,window.devicePixelRatio||1),s.width=c*d,s.height=c*d,s.style.width=`${c}px`,s.style.height=`${c}px`,a.setTransform(d,0,0,d,0,0)},T=(p,v)=>{const j=c/2,R=Math.cos(v)*p.rx*c,I=Math.sin(v)*p.ry*c,Y=Math.cos(p.tilt),w=Math.sin(p.tilt);return{x:j+R*Y-I*w,y:j+R*w+I*Y}},N=()=>{const p=c/2;a.clearRect(0,0,c,c),a.save(),a.translate(p,p),a.strokeStyle=_,a.lineWidth=1;const v=c/18;for(let j=-10;j<=10;j++)a.beginPath(),a.moveTo(j*v,-p),a.lineTo(j*v,p),a.stroke(),a.beginPath(),a.moveTo(-p,j*v),a.lineTo(p,j*v),a.stroke();a.restore(),te.forEach(j=>{a.save(),a.translate(p,p),a.rotate(j.tilt),a.strokeStyle=m[j.viz-1]+"4d",a.lineWidth=1,a.setLineDash([3,7]),a.beginPath(),a.ellipse(0,0,j.rx*c,j.ry*c,0,0,Math.PI*2),a.stroke(),a.restore()}),te.forEach((j,R)=>{const I=m[j.viz-1];j.electrons.forEach((Y,w)=>{const E=g[R][w],k=Math.sign(j.speed)||1;for(let M=14;M>=1;M--){const q=T(j,E-k*M*.045);a.globalAlpha=.45*(1-M/15),a.fillStyle=I,a.beginPath(),a.arc(q.x,q.y,2.4*(1-M/18),0,Math.PI*2),a.fill()}a.globalAlpha=1;const L=T(j,E);a.save(),a.shadowColor=I,a.shadowBlur=14,a.fillStyle=I,a.beginPath(),a.arc(L.x,L.y,5.4,0,Math.PI*2),a.fill(),a.fillStyle="#ffffff",a.beginPath(),a.arc(L.x,L.y,2.2,0,Math.PI*2),a.fill(),a.restore(),n&&(a.fillStyle=I,a.font="10px ui-monospace, monospace",a.textAlign="left",a.textBaseline="middle",a.fillText(Y.label,L.x+11,L.y-1))})})};if(b(),window.addEventListener("resize",b),l)return N(),()=>{f.disconnect(),window.removeEventListener("resize",b)};let x=0,h=performance.now(),y=window.scrollY,C=1;const u=p=>{x=requestAnimationFrame(u);const v=Math.min(.05,(p-h)/1e3);h=p;const j=Math.abs(window.scrollY-y);y=window.scrollY,C=Math.min(4,C+j*.012),C+=(1-C)*.03,te.forEach((I,Y)=>{I.electrons.forEach((w,E)=>{g[Y][E]+=I.speed*C*v*2})});const R=s.getBoundingClientRect();R.bottom<-100||R.top>window.innerHeight+100||N()};return x=requestAnimationFrame(u),()=>{cancelAnimationFrame(x),f.disconnect(),window.removeEventListener("resize",b)}},[n]),e.jsx("canvas",{ref:r,"aria-hidden":!0,className:`pointer-events-none ${t}`})}function J({no:t,children:n}){return e.jsxs("div",{className:"mb-5 flex items-baseline gap-3",children:[e.jsxs("span",{className:"lineno",children:["L",t]}),e.jsx("span",{className:"font-mono text-[12px] uppercase tracking-[0.18em] text-flame",children:n})]})}const ft=["Anthropic Claude","OpenAI","OpenRouter","Groq","Together","Fireworks","DeepSeek","xAI Grok","Mistral","Ollama — local","Any OpenAI-compatible"];function gt(){return e.jsxs("div",{className:"relative overflow-hidden py-2",children:[e.jsx("div",{className:"flex w-max animate-marquee items-center",style:{animationDuration:"42s"},children:[0,1].map(t=>e.jsx("div",{"aria-hidden":t===1,className:"flex items-center gap-4 pr-4",children:ft.map(n=>e.jsxs("span",{className:"flex items-center gap-2.5 whitespace-nowrap rounded-full border border-rule bg-card px-5 py-2.5 font-display text-[15px] font-semibold text-ink",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-flame"}),n]},n))},t))}),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 left-0 w-20 bg-gradient-to-r from-paper to-transparent"}),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-y-0 right-0 w-20 bg-gradient-to-l from-paper to-transparent"})]})}function D({children:t,delay:n=0,className:r=""}){const s=i.useRef(null),[a,l]=i.useState(!1);return i.useEffect(()=>{const c=s.current;if(!c)return;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){l(!0);return}const d=new IntersectionObserver(([g])=>{g.isIntersecting&&(l(!0),d.disconnect())},{rootMargin:"-12% 0px -8% 0px"});return d.observe(c),()=>d.disconnect()},[]),e.jsx("div",{ref:s,className:r,style:{opacity:a?1:0,transform:a?"none":"translateY(14px)",transition:`opacity 0.7s cubic-bezier(0.16,1,0.3,1) ${n}s, transform 0.7s cubic-bezier(0.16,1,0.3,1) ${n}s`},children:t})}function bt(){const[t,n]=i.useState(0);return i.useEffect(()=>{let r=0;const s=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{const a=document.documentElement.scrollHeight-window.innerHeight;n(a>0?Math.min(1,window.scrollY/a):0)})};return s(),window.addEventListener("scroll",s,{passive:!0}),window.addEventListener("resize",s),()=>{cancelAnimationFrame(r),window.removeEventListener("scroll",s),window.removeEventListener("resize",s)}},[]),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none fixed inset-x-0 top-0 z-[60] h-[2px]",children:e.jsx("div",{className:"h-full bg-flame/90 transition-[width] duration-150 ease-out",style:{width:`${t*100}%`}})})}const yt={amber:"#e2a43c",blue:"#57a2e8",green:"#7cb85c"},vt={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"}]},jt={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"}]},Ce=[vt,jt],wt={"Design a Key-Value Store":"KV","Real-time Gaming Leaderboard":"LB"},Nt=200,se=44;function kt(){const[t,n]=i.useState(null),[r,s]=i.useState(""),[a,l]=i.useState(!1),[c,d]=i.useState(!1),[g,m]=i.useState(new Set),_=i.useRef(null),o=i.useRef([]),f=i.useCallback(x=>{n(x),s(x.goal),m(new Set)},[]),b=i.useCallback(()=>{t&&(o.current.forEach(clearTimeout),o.current=[],m(new Set),t.nodes.forEach((x,h)=>{const y=setTimeout(()=>{m(u=>new Set(u).add(x.id))},h*900),C=setTimeout(()=>{m(u=>{const p=new Set(u);return p.delete(x.id),p})},h*900+1600);o.current.push(y,C)}))},[t]);i.useEffect(()=>()=>o.current.forEach(clearTimeout),[]);const T=x=>{x.preventDefault(),d(!1),l(!1);const h=x.dataTransfer.getData("text/levelcode-sketch"),y=Ce.find(C=>C.name===h);y&&f(y)},N=x=>t==null?void 0:t.nodes.find(h=>h.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:Ce.map(x=>e.jsxs("button",{type:"button",draggable:!0,onDragStart:h=>{h.dataTransfer.setData("text/levelcode-sketch",x.name),h.dataTransfer.effectAllowed="copy",l(!0)},onDragEnd:()=>l(!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:wt[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:_,onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy",d(!0)},onDragLeave:()=>d(!1),onDrop:T,className:`relative min-h-[440px] overflow-hidden rounded-xl border bg-[#f2f0ea] transition-colors ${c?"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:r,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:b,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 ${a||c?"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,h)=>{const y=N(x.from),C=N(x.to);if(!y||!C)return null;const u=y.x+Nt,p=y.y+se,v=C.x,j=C.y+se;return e.jsx("path",{d:`M${u},${p} C ${u+70},${p} ${v-70},${j} ${v},${j}`,fill:"none",stroke:"#b9b4a8",strokeWidth:1.5},h)})}),t.nodes.map(x=>{const h=yt[x.color],y=g.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)] ${y?"sb-node--running":""}`,style:{left:x.x,top:x.y,borderColor:y?"transparent":"#e2ddd2"},children:[y&&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] ${y?"sb-pulse":""}`,style:{background:y?"#65a34a":h}}),e.jsx("span",{className:"truncate text-[13px] font-semibold text-[#2a2822]",children:x.label}),y?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:se-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:se-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 St=[{value:0,suffix:" ",label:"telemetry events phoned home"},{value:0,suffix:" ",label:"servers between you and your model"},{value:10,suffix:"+",label:"providers · hundreds of models"},{value:100,suffix:"%",label:"of AI runs on your own key"}];function Ct(t,n,r=1100){const[s,a]=i.useState(0);return i.useEffect(()=>{if(!n)return;if(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches){a(t);return}let l=0;const c=performance.now(),d=g=>{const m=Math.min(1,(g-c)/r),_=1-Math.pow(1-m,3);a(Math.round(_*t)),m<1&&(l=requestAnimationFrame(d))};return l=requestAnimationFrame(d),()=>cancelAnimationFrame(l)},[t,n,r]),s}function _t({stat:t,run:n}){const r=Ct(t.value,n);return e.jsxs("div",{className:"border-t border-rule pt-4",children:[e.jsxs("div",{className:"font-display text-[clamp(2rem,5vw,3rem)] font-bold leading-none tracking-tightest text-ink tabular-nums",children:[t.prefix,r,e.jsx("span",{className:"text-flame",children:t.suffix})]}),e.jsx("p",{className:"mt-2 font-mono text-[12px] leading-snug text-faint",children:t.label})]})}function Et(){const t=i.useRef(null),[n,r]=i.useState(!1);return i.useEffect(()=>{const s=t.current;if(!s)return;const a=new IntersectionObserver(([l])=>{l.isIntersecting&&(r(!0),a.disconnect())},{rootMargin:"-10% 0px -10% 0px"});return a.observe(s),()=>a.disconnect()},[]),e.jsx("div",{ref:t,className:"grid grid-cols-2 gap-x-8 gap-y-8 md:grid-cols-4",children:St.map(s=>e.jsx(_t,{stat:s,run:n},s.label))})}const _e="https://github.com/levelcodeai/levelcode",Tt=["read_codebase","edit_file","run_command","update_plan","ask_user","use_skill","verify_loop","checkpoint","background_exec"];function Ee(){return e.jsxs("main",{id:"top",className:"relative overflow-hidden",children:[e.jsx(bt,{}),e.jsx(ht,{}),e.jsxs("section",{className:"relative flex min-h-[100svh] flex-col items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(pt,{className:"h-[min(92vw,740px)] w-[min(92vw,740px)] opacity-95"})}),e.jsxs("div",{className:"relative z-10 mx-auto max-w-4xl px-5 text-center",children:[e.jsx(D,{children:e.jsxs("div",{className:"mb-6 inline-flex items-center gap-2 rounded-full border border-line bg-abyss/80 px-3 py-1 font-mono text-[12px] text-ghost backdrop-blur-sm",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-electric shadow-[0_0_10px_rgb(var(--accent-rgb)/0.9)]"}),"generation 3 · agentic · macOS · MIT"]})}),e.jsx(D,{delay:.05,children:e.jsxs("h1",{className:"font-display text-[clamp(2.8rem,8vw,5.4rem)] font-bold leading-[0.98] tracking-tightest text-frost text-balance",children:["Level",e.jsx("span",{className:"pp",children:"Code"}),".ai"]})}),e.jsx(D,{delay:.1,children:e.jsxs("p",{className:"mx-auto mt-6 max-w-xl text-[17px] leading-relaxed text-ghost pretty",children:["The AI-native editor that codes with you. Six agents in quiet orbit — they plan, edit, run, and verify. On ",e.jsx("em",{className:"text-frost",children:"your"})," key, on ",e.jsx("em",{className:"text-frost",children:"your"})," ","machine, no middleman."]})}),e.jsx(D,{delay:.15,children:e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsx("a",{href:"#init",className:"btn-primary",children:"Download for macOS"}),e.jsx("a",{href:_e,target:"_blank",rel:"noreferrer",className:"btn-ghost",children:"Star on GitHub"})]})}),e.jsx(D,{delay:.2,children:e.jsx("p",{className:"mt-6 font-mono text-[12px] text-ghost/70",children:"no account · no telemetry · bring your own key"})})]}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 border-t border-line bg-abyss/60 backdrop-blur-sm",children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"flex w-max animate-marquee items-center gap-10 py-3 font-mono text-[12px] text-ghost/70",children:[0,1].map(t=>e.jsx("div",{"aria-hidden":t===1,className:"flex items-center gap-10",children:Tt.map(n=>e.jsxs("span",{className:"whitespace-nowrap",children:[e.jsx("span",{className:"text-electric/80",children:"◈"})," ",n]},n))},t))})})})]}),e.jsx("section",{id:"runtime",className:"scroll-mt-20 border-t border-line bg-abyss/50",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs(D,{children:[e.jsx(J,{no:"01",children:"agent runtime"}),e.jsxs("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:["Autonomous where it earns it.",e.jsx("br",{}),"Gated where it matters."]}),e.jsx("p",{className:"mt-6 max-w-2xl text-[17px] leading-relaxed text-ghost pretty",children:"Every edit lands as a reviewable change. Every command waits for your approval. Before the agent says done, it diffs its own diagnostics and runs your tests — repairing what it broke, bounded and cancellable."})]}),e.jsx(D,{delay:.08,children:e.jsx("div",{className:"mx-auto mt-12 max-w-4xl",children:e.jsx(it,{})})}),e.jsx("div",{className:"mt-14 grid gap-x-8 gap-y-10 md:grid-cols-2 lg:grid-cols-3",children:Lt.map(t=>e.jsx(D,{children:e.jsxs("div",{className:"border-t border-line pt-4",children:[e.jsx("span",{className:"font-mono text-[12px] text-electric",children:t.tag}),e.jsx("h3",{className:"mt-3 font-display text-lg font-semibold text-frost",children:t.title}),e.jsx("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:t.body})]})},t.title))})]})}),e.jsx("section",{id:"sketches",className:"scroll-mt-20 border-t border-line",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs(D,{children:[e.jsx(J,{no:"02",children:"sketch builder"}),e.jsx("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:"Drag a whole system onto the canvas."}),e.jsxs("p",{className:"mt-6 max-w-2xl text-[17px] leading-relaxed text-ghost pretty",children:["Predefined agent topologies, ready to run — exactly as they appear on the real board. Drag the"," ",e.jsx("span",{className:"font-semibold text-frost",children:"Design a Key-Value Store"})," card onto the canvas and it lays down the eleven wired agents from the ByteByteGo chapter — requirements, architecture, storage engine, consistent hashing, replication + quorum, vector clocks, gossip + failover, integrate + server, tests, build + validate, and a review / run-guide. Or drop the"," ",e.jsx("span",{className:"font-semibold text-frost",children:"Real-time Gaming Leaderboard"})," card for a full Redis-sorted-set build. Set the goal at the top, hit Run, and watch the agents light up in order."]})]}),e.jsx(D,{delay:.08,children:e.jsx("div",{className:"mt-12",children:e.jsx(kt,{})})})]})}),e.jsx("section",{id:"systems",className:"scroll-mt-20 border-t border-line bg-abyss/50",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs(D,{children:[e.jsx(J,{no:"03",children:"core systems"}),e.jsx("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:"Four subsystems, one editor."})]}),e.jsx("div",{className:"mt-12 grid gap-x-8 gap-y-10 sm:grid-cols-2",children:At.map(t=>e.jsx(D,{children:e.jsxs("div",{className:"border-t border-line pt-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"font-mono text-[12px] text-electric",children:t.key}),e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-[0.18em] text-ghost/60",children:t.sub})]}),e.jsx("h3",{className:"mt-3 font-display text-xl font-semibold text-frost",children:t.name}),e.jsx("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:t.body})]})},t.name))}),e.jsx("div",{className:"mt-14 grid gap-x-8 gap-y-10 md:grid-cols-3",children:Mt.map(t=>e.jsx(D,{children:e.jsxs("div",{className:"border-t border-line pt-4",children:[e.jsx("span",{className:"font-mono text-[12px] text-leaf",children:t.tag}),e.jsx("h3",{className:"mt-3 font-display text-lg font-semibold text-frost",children:t.title}),e.jsx("p",{className:"mt-2 text-[15px] leading-relaxed text-ghost pretty",children:t.body})]})},t.title))})]})}),e.jsx("section",{id:"models",className:"scroll-mt-20 border-t border-line",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24",children:[e.jsxs(D,{children:[e.jsx(J,{no:"04",children:"any model · your key"}),e.jsx("h2",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-frost text-balance",children:"Fuse it to any intelligence — from your machine."}),e.jsx("p",{className:"mt-6 max-w-2xl text-[17px] leading-relaxed text-ghost pretty",children:"One registry, hundreds of models. Anthropic runs on a native adapter with prompt caching and full tool use; everything else flows through one OpenAI-compatible pipe. Requests travel from your machine to the provider — no relay, no logging, keys sealed in your keychain."})]}),e.jsx(D,{delay:.08,children:e.jsx("div",{className:"mt-12",children:e.jsx(gt,{})})}),e.jsx(D,{delay:.12,children:e.jsx("div",{className:"mt-16",children:e.jsx(Et,{})})})]})}),e.jsx("section",{id:"init",className:"scroll-mt-20 border-t border-line bg-abyss/50",children:e.jsxs("div",{className:"mx-auto max-w-6xl px-5 py-24 text-center",children:[e.jsxs(D,{children:[e.jsx("div",{className:"flex justify-center",children:e.jsx(J,{no:"05",children:"download levelcode.ai"})}),e.jsx("h2",{className:"mx-auto max-w-3xl font-display text-[clamp(2.4rem,6vw,4.2rem)] font-semibold leading-[1] tracking-tightest text-frost text-balance",children:"Install the agent swarm."}),e.jsx("p",{className:"mx-auto mt-6 max-w-md text-[17px] leading-relaxed text-ghost pretty",children:"Free and open. Drag the .dmg to Applications, add a key — or run fully offline on local Ollama — and the agents come alive."})]}),e.jsx(D,{delay:.08,children:e.jsx("div",{className:"mt-12 flex justify-center",children:e.jsx(ut,{})})})]})}),e.jsx("footer",{className:"border-t border-line bg-void/50",children:e.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col gap-3 px-5 py-8 font-mono text-[12px] text-ghost/70 md:flex-row md:items-center md:justify-between",children:[e.jsxs("span",{className:"font-display text-sm font-bold tracking-tightest text-frost",children:["Level",e.jsx("span",{className:"pp",children:"Code"}),".ai"]}),e.jsx("span",{children:"Built on Code-OSS · MIT · open source"}),e.jsxs("span",{className:"flex items-center gap-4",children:[e.jsx("a",{href:_e,target:"_blank",rel:"noreferrer",className:"transition-colors hover:text-frost",children:"GitHub"}),e.jsx("a",{href:"#init",className:"transition-colors hover:text-frost",children:"Download"}),e.jsxs("span",{children:["© ",new Date().getFullYear()]})]})]})})]})}const Lt=[{tag:"apply-then-review",title:"Keep / Undo on every file",body:"Edits land instantly and await your verdict — per file or all at once, live +/− totals, state survives reloads."},{tag:"⛨ self-verification",title:"Proves itself before reporting",body:"Diffs diagnostics against a pre-run baseline and runs your verify command; new failures loop back for repair — bounded, never runaway."},{tag:"↩ checkpoints",title:"Rewind any turn",body:"Every agent turn is a checkpoint. One click rolls files, transcript, and pending reviews back to before it ran."},{tag:"▶ approval-gated",title:"A live terminal, on your terms",body:"Commands stream real stdout/stderr only after you approve; Stop kills the whole process tree — no orphaned servers."},{tag:"background",title:"Servers keep running",body:"Long commands detach and keep streaming while the agent works on; it polls output, sniffs the port, tests against the live process."},{tag:"transparent",title:"Real token accounting",body:"A live context meter with actual usage from the provider — click it for the full breakdown. Cost opacity is the enemy."}],At=[{key:"⇥",sub:"reflex",name:"Autocomplete",body:"Debounced ghost text over every file, cancelled the instant you keep typing. Routed to a fast model per provider."},{key:"⌘⌥I",sub:"cognition",name:"Chat",body:"Streaming chat that knows your project — pin files or let ripgrep + workspace symbols pull context automatically."},{key:"⌘⌥E",sub:"revision",name:"Edit",body:"Select code, state the change, review a true side-by-side diff. Keep or discard — nothing applies behind your back."},{key:"default",sub:"autonomy",name:"Agent",body:"State the goal. It plans, edits across files, runs behind approval gates, and verifies before reporting."}],Mt=[{tag:"np++ toolkit",title:"Power-editing pack",body:"Keystroke macros, line ops, column mode with incrementing numbers, encoding/EOL controls, big-file mode, hot-exit."},{tag:"hack layer",title:"Init script + packages",body:"Code that runs at boot and hot-reloads on save; a package generator with a live dev loop; Atom / NPP / Sublime keymaps."},{tag:"continuity",title:"Sync + import",body:"Built-in Settings Sync, notify-only updates, and one-click import from VS Code, VSCodium, or Cursor."}],Me="lc_attribution",De=["linkedin","youtube","ref","utm_source","utm_medium","utm_campaign","utm_content"],Pe=120,Dt=40,ne=300,Pt=40;function $t(t){if(!t||typeof t!="object")return null;const n=t,r={},s=n.params;if(s&&typeof s=="object")for(const c of De){const d=s[c];typeof d=="string"&&d&&(r[c]=d.slice(0,Pe))}const a=typeof n.source=="string"?n.source.slice(0,Dt):"";if(Object.keys(r).length===0&&!a)return null;const l=(c,d)=>typeof c=="string"?c.slice(0,d):"";return{source:a||"other",params:r,landing:l(n.landing,ne),referrer:l(n.referrer,ne),ts:l(n.ts,Pt)}}function $e(){try{const t=localStorage.getItem(Me);return t?$t(JSON.parse(t)):null}catch{return null}}function Rt(){if(!(typeof window>"u"))try{if($e())return;const t=new URLSearchParams(window.location.search),n={};for(const a of De){const l=t.get(a);l&&(n[a]=l.slice(0,Pe))}if(Object.keys(n).length===0)return;const s={source:n.linkedin?"linkedin":n.youtube?"youtube":n.utm_source||n.ref||"other",params:n,landing:window.location.pathname.slice(0,ne),referrer:(document.referrer||"").slice(0,ne),ts:new Date().toISOString()};localStorage.setItem(Me,JSON.stringify(s))}catch{}}function It(){return typeof window>"u"?null:$e()}function Ot({redirectUri:t,codeChallenge:n}){const[r,s]=i.useState("email"),[a,l]=i.useState(""),[c,d]=i.useState(""),[g,m]=i.useState(!1),[_,o]=i.useState(null);async function f(T){T.preventDefault(),m(!0),o(null);try{await $("/ai/auth/email",{body:{email:a}}),s("code")}catch(N){o(N instanceof X?N.message:"Couldn't send a code. Try again.")}finally{m(!1)}}async function b(T){T.preventDefault(),m(!0),o(null);try{const N=await $("/ai/auth/verify",{body:{email:a,code:c,redirect_uri:t,code_challenge:n,attribution:It()}});if(!N.redirect)throw new X(422,"That code is invalid or has expired.");if(!N.redirect.startsWith("/")){const x=window.setTimeout(()=>{m(!1),o("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}),Z(N.redirect);return}Z(N.redirect)}catch(N){o(N instanceof X?N.message:"That code is invalid or has expired."),m(!1)}}return r==="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:"font-mono text-[11px] uppercase tracking-widest text-faint",children:"Email"}),e.jsx("input",{type:"email",required:!0,autoFocus:!0,autoComplete:"email",value:a,onChange:T=>l(T.target.value),placeholder:"you@studio.dev",className:"rounded-lg border border-rule bg-card px-3 py-2.5 text-[15px] text-ink outline-none transition-colors focus:border-flame"})]}),_?e.jsx("p",{className:"text-[13px] text-red-600",children:_}):null,e.jsx("button",{type:"submit",disabled:g,className:"btn-primary w-full justify-center",children:g?"Sending…":"Email me a sign-in code"})]}):e.jsxs("form",{onSubmit:b,className:"flex flex-col gap-3",children:[e.jsxs("p",{className:"text-[13px] text-sub",children:["We sent a 6-digit code to ",e.jsx("span",{className:"font-medium text-ink",children:a}),". Enter it below."]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-widest text-faint",children:"Verification code"}),e.jsx("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]*",maxLength:6,required:!0,autoFocus:!0,value:c,onChange:T=>d(T.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"000000",className:"rounded-lg border border-rule bg-card px-3 py-2.5 text-center text-[22px] font-semibold tracking-[0.4em] text-ink outline-none transition-colors focus:border-flame"})]}),_?e.jsx("p",{className:"text-[13px] text-red-600",children:_}):null,e.jsx("button",{type:"submit",disabled:g||c.length<6,className:"btn-primary w-full justify-center",children:g?"Verifying…":"Verify & continue"}),e.jsxs("div",{className:"flex items-center justify-between font-mono text-[12px] text-faint",children:[e.jsx("button",{type:"button",onClick:f,disabled:g,className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"Resend code"}),e.jsx("button",{type:"button",onClick:()=>{s("email"),d(""),o(null)},className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"Use a different email"})]})]})}function Ft({redirectUri:t,codeChallenge:n}){return e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(Te,{provider:"google",label:"Continue with Google",redirectUri:t,codeChallenge:n,children:e.jsx(Bt,{})}),e.jsx(Te,{provider:"github",label:"Continue with GitHub",redirectUri:t,codeChallenge:n,children:e.jsx(Yt,{})})]})}function Te({provider:t,label:n,redirectUri:r,codeChallenge:s,children:a}){return e.jsxs("a",{href:qt(t,r,s),className:"flex w-full items-center justify-center gap-2.5 rounded-full border border-rule bg-card px-6 py-3 text-[15px] font-medium text-ink transition-colors hover:border-ink",children:[a,n]})}function qt(t,n,r){const s=new URLSearchParams;n&&r&&(s.set("redirect_uri",n),s.set("code_challenge",r));const a=s.toString();return`${pe}/ai/auth/oauth/${t}${a?`?${a}`:""}`}function Bt(){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 Yt(){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 Ut={session_expired:"Your sign-in session expired. Please try again.",link_expired:"That sign-in link expired. Please try again from the editor."};function zt(){const t=re(),[n]=Fe(),r=n.get("redirect_uri"),s=n.get("code_challenge"),a=n.get("error"),l=r&&s?{redirectUri:r,codeChallenge:s}:null,c=!!l,{loading:d,profile:g}=H(),[m,_]=i.useState("idle");return i.useEffect(()=>{if(!d){if(!g){_("form");return}if(r&&s){_("completing");let o=!0;return $("/ai/authorize_editor",{method:"POST",body:{redirect_uri:r,code_challenge:s}}).then(f=>{o&&(f.redirect?Z(f.redirect):_("form"))}).catch(()=>{o&&_("form")}),()=>{o=!1}}t("/account",{replace:!0})}},[d,g,r,s,t]),m==="completing"?e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto flex min-h-[100svh] max-w-6xl flex-col items-center justify-center px-5 py-28",children:e.jsxs("div",{className:"surface w-full max-w-md p-8 text-center",children:[e.jsx("div",{className:"lineno mb-3",children:"connecting"}),e.jsx("h1",{className:"font-display text-xl font-semibold tracking-tightest",children:"Opening LevelCode…"}),e.jsx("p",{className:"mt-3 text-[14px] text-sub pretty",children:"Signing the editor into your account. You can return to LevelCode — this tab can be closed."})]})})]}):m!=="form"?e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto flex min-h-[100svh] max-w-6xl flex-col items-center justify-center px-5 py-28"})]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsx("main",{className:"mx-auto flex min-h-[100svh] max-w-6xl flex-col items-center justify-center px-5 py-28",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsx("div",{className:"lineno mb-4",children:"01 · sign in"}),e.jsxs("h1",{className:"font-display text-[clamp(2rem,4.5vw,2.8rem)] font-semibold leading-[1.04] tracking-tightest",children:["Welcome to ",e.jsx("span",{className:"pp",children:"LevelCode"})," Cloud"]}),e.jsx("p",{className:"mt-4 text-[15px] leading-relaxed text-sub pretty",children:c?"Sign in to connect the editor to your account. You’ll be sent back to LevelCode when you’re done.":"Sign in to manage your plan, keys, and usage."}),e.jsxs("div",{className:"surface mt-8 p-7",children:[a?e.jsx("div",{role:"alert",className:"mb-5 rounded-lg border border-red-500/40 bg-red-500/10 px-4 py-3 text-[13px] text-red-700",children:Ut[a]??"Sign-in failed. Please try again."}):null,e.jsx(Ft,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge}),e.jsxs("div",{className:"my-5 flex items-center gap-3 text-faint","aria-hidden":"true",children:[e.jsx("span",{className:"flex-1 border-t border-rule"}),e.jsx("span",{className:"font-mono text-[11px] uppercase tracking-widest",children:"or"}),e.jsx("span",{className:"flex-1 border-t border-rule"})]}),e.jsx(Ot,{redirectUri:l==null?void 0:l.redirectUri,codeChallenge:l==null?void 0:l.codeChallenge})]}),e.jsxs("p",{className:"mt-5 font-mono text-[12px] text-faint",children:["By continuing you agree to the"," ",e.jsx(P,{to:"/terms",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"terms"})," ","and"," ",e.jsx(P,{to:"/privacy",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"privacy policy"}),". Bring your own key — we never resell provider access."]})]})})]})}function Gt({tiers:t,authed:n,currentPlan:r}){const s=re(),[a,l]=i.useState(null),[c,d]=i.useState(null),g=o=>(o??"").trim().toLowerCase(),m=o=>n&&!!r&&g(r)===g(o.name);async function _(o){if(d(null),!n){s("/login");return}l(o.key);try{const f=await $("/ai/checkout",{body:{lookup_key:o.key}});if(f.url){Z(f.url);return}if(f.status==="plan_changed"){s("/account?checkout=changed");return}d("Could not start checkout."),l(null)}catch(f){d(f instanceof X?f.message:"Could not start checkout."),l(null)}}return e.jsxs(e.Fragment,{children:[c?e.jsx("p",{className:"mt-6 font-mono text-[12px] text-flame",role:"alert",children:c}):null,e.jsx("div",{className:"mt-12 grid gap-5 sm:grid-cols-2 lg:grid-cols-4",children:t.map((o,f)=>{const b=f===1,T=m(o);return e.jsxs("div",{className:`surface flex flex-col p-6 ${T?"ring-2 ring-flame":b?"ring-1 ring-flame/40":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-display text-lg font-semibold",children:o.name}),T?e.jsx("span",{className:"rounded-full bg-flame px-2 py-0.5 font-mono text-[10px] uppercase tracking-widest text-white",children:"current"}):b?e.jsx("span",{className:"rounded-full bg-flame/10 px-2 py-0.5 font-mono text-[10px] uppercase tracking-widest text-flame",children:"popular"}):null]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-1",children:[e.jsx("span",{className:"font-display text-3xl font-bold tracking-tightest",children:Wt(o.price_cents)}),e.jsxs("span",{className:"text-sm text-faint",children:["/",o.interval||"mo"]})]}),e.jsxs("dl",{className:"mt-5 space-y-1.5 font-mono text-[12px] text-sub",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-faint",children:"input"}),e.jsx("dd",{className:"tabular-nums",children:Le(o.input_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-faint",children:"output"}),e.jsx("dd",{className:"tabular-nums",children:Le(o.output_cap)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-faint",children:"turns"}),e.jsx("dd",{className:"tabular-nums",children:(o.turns??0).toLocaleString()})]})]}),e.jsx("ul",{className:"mt-5 flex-1 space-y-2 text-[13px] text-sub",children:(o.features??[]).map(N=>e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{className:"mt-1.5 h-1 w-1 flex-none rounded-full bg-flame"}),e.jsx("span",{className:"pretty",children:N})]},N))}),T?e.jsx("button",{type:"button",disabled:!0,"aria-disabled":"true",className:"mt-6 w-full cursor-default justify-center btn-ghost opacity-70",children:"✓ Current plan"}):e.jsx("button",{onClick:()=>_(o),disabled:a===o.key,className:`mt-6 w-full justify-center ${b?"btn-primary":"btn-ghost"}`,children:a===o.key?"Starting…":n?"Choose plan":"Sign in to start"})]},o.key)})})]})}function Wt(t){const n=t/100;return`$${n%1===0?n.toFixed(0):n.toFixed(2)}`}function Le(t){return t>=1e6?`${+(t/1e6).toFixed(1)}M`:t>=1e3?`${+(t/1e3).toFixed(0)}K`:(t??0).toLocaleString()}function Ht(){const{profile:t}=H(),[n,r]=i.useState([]),[s,a]=i.useState(null);return i.useEffect(()=>{let l=!0;return $("/api/levelcode/v1/pricing").then(c=>{l&&r(c.tiers??[])}).catch(()=>{l&&a("Pricing is temporarily unavailable. Please try again shortly.")}),()=>{l=!1}},[]),e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-6xl px-5 py-28",children:[e.jsx("div",{className:"lineno mb-4",children:"04 · pricing"}),e.jsx("h1",{className:"max-w-3xl font-display text-[clamp(2rem,4.5vw,3.2rem)] font-semibold leading-[1.04] tracking-tightest text-balance",children:"Plans that scale with your orbit"}),e.jsx("p",{className:"mt-5 max-w-xl text-[17px] leading-relaxed text-sub pretty",children:"Every plan is bring-your-own-key by default. Switch on the gateway and your monthly token cap is all you pay — we never mark up the provider."}),s?e.jsx("div",{className:"surface mt-12 p-8 text-[15px] text-sub",children:s}):e.jsx(Gt,{tiers:n,authed:!!t,currentPlan:(t==null?void 0:t.plan)??null})]})]})}function Re({eyebrow:t,title:n,updated:r,intro:s,children:a}){return e.jsxs(e.Fragment,{children:[e.jsx(B,{}),e.jsxs("main",{className:"mx-auto max-w-3xl px-5 py-24",children:[e.jsx("div",{className:"lineno mb-4",children:t}),e.jsx("h1",{className:"font-display text-[clamp(2rem,5vw,3rem)] font-semibold leading-[1.05] tracking-tightest text-balance",children:n}),e.jsxs("p",{className:"mt-4 font-mono text-[12px] text-faint",children:["Last updated: ",r]}),e.jsx("p",{className:"mt-6 max-w-2xl text-[16px] leading-relaxed text-sub pretty",children:s}),e.jsx("div",{className:"mt-10 space-y-9",children:a}),e.jsxs("div",{className:"mt-16 border-t border-rule pt-6 font-mono text-[12px] text-faint",children:[e.jsx(P,{to:"/terms",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"Terms"}),e.jsx("span",{className:"px-2",children:"·"}),e.jsx(P,{to:"/privacy",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"Privacy"}),e.jsx("span",{className:"px-2",children:"·"}),e.jsx(P,{to:"/",className:"underline decoration-rule underline-offset-4 transition-colors hover:text-ink",children:"levelcode.ai"})]})]})]})}function A({id:t,heading:n,children:r}){return e.jsxs("section",{id:t,className:"scroll-mt-24",children:[e.jsx("h2",{className:"font-display text-xl font-semibold tracking-tight text-ink",children:n}),e.jsx("div",{className:"mt-3 space-y-3 text-[15px] leading-relaxed text-sub pretty",children:r})]})}function Vt(){return e.jsxs(Re,{eyebrow:"09 · legal",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(A,{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-ink",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-ink",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-ink",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-ink",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(A,{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(A,{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-ink",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-ink",children:"Payments"})," — Stripe, to process subscriptions and payments."]}),e.jsxs("li",{children:[e.jsx("strong",{className:"text-ink",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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{id:"contact",heading:"11. Contact",children:e.jsxs("p",{children:["Privacy questions or requests? Email"," ",e.jsx("a",{href:"mailto:privacy@levelcode.ai",className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"privacy@levelcode.ai"}),"."]})})]})}function Kt(){return e.jsxs(Re,{eyebrow:"09 · legal",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:"underline decoration-rule underline-offset-4 hover:text-ink",children:"Privacy Policy"}),"."]}),children:[e.jsx(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{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(A,{heading:"13. Contact",children:e.jsxs("p",{children:["Questions about these Terms? Email"," ",e.jsx("a",{href:"mailto:legal@levelcode.ai",className:"underline decoration-rule underline-offset-4 hover:text-ink",children:"legal@levelcode.ai"}),"."]})})]})}function Jt(){return e.jsxs(qe,{children:[e.jsx(U,{path:"/",element:e.jsx(Ee,{})}),e.jsx(U,{path:"/login",element:e.jsx(zt,{})}),e.jsx(U,{path:"/pricing",element:e.jsx(Ht,{})}),e.jsx(U,{path:"/account",element:e.jsx(tt,{})}),e.jsx(U,{path:"/admin",element:e.jsx(rt,{})}),e.jsx(U,{path:"/terms",element:e.jsx(Kt,{})}),e.jsx(U,{path:"/privacy",element:e.jsx(Vt,{})}),e.jsx(U,{path:"/download",element:e.jsx(lt,{})}),e.jsx(U,{path:"*",element:e.jsx(Ee,{})})]})}Rt();Be(document.getElementById("root")).render(e.jsx(i.StrictMode,{children:e.jsx(Ye,{basename:"/ai",children:e.jsx(Jt,{})})})); diff --git a/app/assets/interface/main-BZoV021O.js b/app/assets/interface/main-BVjw8FfB.js similarity index 96% rename from app/assets/interface/main-BZoV021O.js rename to app/assets/interface/main-BVjw8FfB.js index 3104a04f..129eabdd 100644 --- a/app/assets/interface/main-BZoV021O.js +++ b/app/assets/interface/main-BVjw8FfB.js @@ -3,18 +3,18 @@ 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 * Copyright(c) 2012-2014 Roman Shtylman * Copyright(c) 2015 Douglas Christopher Wilson * MIT Licensed - */var Kr;function wc(){if(Kr)return Xa;Kr=1,Xa.parse=o,Xa.serialize=u;var t=Object.prototype.toString,a=Object.prototype.hasOwnProperty,s=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,n=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,i=/^[\u0020-\u003A\u003D-\u007E]*$/;function o(p,y){if(typeof p!="string")throw new TypeError("argument str must be a string");var g={},f=p.length;if(f<2)return g;var b=y&&y.decode||m,j=0,w=0,v=0;do{if(w=p.indexOf("=",j),w===-1)break;if(v=p.indexOf(";",j),v===-1)v=f;else if(w>v){j=p.lastIndexOf(";",w-1)+1;continue}var k=d(p,j,w),N=c(p,w,k),z=p.slice(k,N);if(!a.call(g,z)){var L=d(p,w+1,v),T=c(p,v,L);p.charCodeAt(L)===34&&p.charCodeAt(T-1)===34&&(L++,T--);var S=p.slice(L,T);g[z]=x(S,b)}j=v+1}while(jg;){var f=p.charCodeAt(--y);if(f!==32&&f!==9)return y+1}return g}function u(p,y,g){var f=g&&g.encode||encodeURIComponent;if(typeof f!="function")throw new TypeError("option encode is invalid");if(!s.test(p))throw new TypeError("argument name is invalid");var b=f(y);if(!n.test(b))throw new TypeError("argument val is invalid");var j=p+"="+b;if(!g)return j;if(g.maxAge!=null){var w=Math.floor(g.maxAge);if(!isFinite(w))throw new TypeError("option maxAge is invalid");j+="; Max-Age="+w}if(g.domain){if(!r.test(g.domain))throw new TypeError("option domain is invalid");j+="; Domain="+g.domain}if(g.path){if(!i.test(g.path))throw new TypeError("option path is invalid");j+="; Path="+g.path}if(g.expires){var v=g.expires;if(!h(v)||isNaN(v.valueOf()))throw new TypeError("option expires is invalid");j+="; Expires="+v.toUTCString()}if(g.httpOnly&&(j+="; HttpOnly"),g.secure&&(j+="; Secure"),g.partitioned&&(j+="; Partitioned"),g.priority){var k=typeof g.priority=="string"?g.priority.toLowerCase():g.priority;switch(k){case"low":j+="; Priority=Low";break;case"medium":j+="; Priority=Medium";break;case"high":j+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(g.sameSite){var N=typeof g.sameSite=="string"?g.sameSite.toLowerCase():g.sameSite;switch(N){case!0:j+="; SameSite=Strict";break;case"lax":j+="; SameSite=Lax";break;case"strict":j+="; SameSite=Strict";break;case"none":j+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return j}function m(p){return p.indexOf("%")!==-1?decodeURIComponent(p):p}function h(p){return t.call(p)==="[object Date]"}function x(p,y){try{return y(p)}catch{return p}}return Xa}var us=wc();function Nc(){const t=typeof global>"u"?void 0:global.TEST_HAS_DOCUMENT_COOKIE;return typeof t=="boolean"?t:typeof document=="object"&&typeof document.cookie=="string"}function Cc(t){return typeof t=="string"?us.parse(t):typeof t=="object"&&t!==null?t:{}}function pn(t,a={}){const s=Sc(t);if(!a.doNotParse)try{return JSON.parse(s)}catch{}return t}function Sc(t){return t&&t[0]==="j"&&t[1]===":"?t.substr(2):t}class ll{constructor(a,s={}){this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.update=()=>{if(!this.HAS_DOCUMENT_COOKIE)return;const r=this.cookies;this.cookies=us.parse(document.cookie),this._checkChanges(r)};const n=typeof document>"u"?"":document.cookie;this.cookies=Cc(a||n),this.defaultSetOptions=s,this.HAS_DOCUMENT_COOKIE=Nc()}_emitChange(a){for(let s=0;s{a[n]!==this.cookies[n]&&this._emitChange({name:n,value:pn(this.cookies[n])})})}_startPolling(){this.pollingInterval=setInterval(this.update,300)}_stopPolling(){this.pollingInterval&&clearInterval(this.pollingInterval)}get(a,s={}){return s.doNotUpdate||this.update(),pn(this.cookies[a],s)}getAll(a={}){a.doNotUpdate||this.update();const s={};for(let n in this.cookies)s[n]=pn(this.cookies[n],a);return s}set(a,s,n){n?n=Object.assign(Object.assign({},this.defaultSetOptions),n):n=this.defaultSetOptions;const r=typeof s=="string"?s:JSON.stringify(s);this.cookies=Object.assign(Object.assign({},this.cookies),{[a]:r}),this.HAS_DOCUMENT_COOKIE&&(document.cookie=us.serialize(a,r,n)),this._emitChange({name:a,value:s,options:n})}remove(a,s){const n=s=Object.assign(Object.assign(Object.assign({},this.defaultSetOptions),s),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=Object.assign({},this.cookies),delete this.cookies[a],this.HAS_DOCUMENT_COOKIE&&(document.cookie=us.serialize(a,"",n)),this._emitChange({name:a,value:void 0,options:s})}addChangeListener(a){this.changeListeners.push(a),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===1&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.addEventListener("change",this.update):this._startPolling())}removeChangeListener(a){const s=this.changeListeners.indexOf(a);s>=0&&this.changeListeners.splice(s,1),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===0&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.removeEventListener("change",this.update):this._stopPolling())}}const ol=l.createContext(new ll),{Provider:Ec,Consumer:L5}=ol;class zc extends l.Component{constructor(a){super(a),a.cookies?this.cookies=a.cookies:this.cookies=new ll(void 0,a.defaultSetOptions)}render(){return l.createElement(Ec,{value:this.cookies},this.props.children)}}var xn={exports:{}},ye={};/** @license React v16.13.1 + */var Kr;function wc(){if(Kr)return Xa;Kr=1,Xa.parse=o,Xa.serialize=u;var t=Object.prototype.toString,a=Object.prototype.hasOwnProperty,s=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,n=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,i=/^[\u0020-\u003A\u003D-\u007E]*$/;function o(p,y){if(typeof p!="string")throw new TypeError("argument str must be a string");var g={},f=p.length;if(f<2)return g;var b=y&&y.decode||m,j=0,w=0,v=0;do{if(w=p.indexOf("=",j),w===-1)break;if(v=p.indexOf(";",j),v===-1)v=f;else if(w>v){j=p.lastIndexOf(";",w-1)+1;continue}var k=d(p,j,w),N=c(p,w,k),z=p.slice(k,N);if(!a.call(g,z)){var _=d(p,w+1,v),T=c(p,v,_);p.charCodeAt(_)===34&&p.charCodeAt(T-1)===34&&(_++,T--);var S=p.slice(_,T);g[z]=x(S,b)}j=v+1}while(jg;){var f=p.charCodeAt(--y);if(f!==32&&f!==9)return y+1}return g}function u(p,y,g){var f=g&&g.encode||encodeURIComponent;if(typeof f!="function")throw new TypeError("option encode is invalid");if(!s.test(p))throw new TypeError("argument name is invalid");var b=f(y);if(!n.test(b))throw new TypeError("argument val is invalid");var j=p+"="+b;if(!g)return j;if(g.maxAge!=null){var w=Math.floor(g.maxAge);if(!isFinite(w))throw new TypeError("option maxAge is invalid");j+="; Max-Age="+w}if(g.domain){if(!r.test(g.domain))throw new TypeError("option domain is invalid");j+="; Domain="+g.domain}if(g.path){if(!i.test(g.path))throw new TypeError("option path is invalid");j+="; Path="+g.path}if(g.expires){var v=g.expires;if(!h(v)||isNaN(v.valueOf()))throw new TypeError("option expires is invalid");j+="; Expires="+v.toUTCString()}if(g.httpOnly&&(j+="; HttpOnly"),g.secure&&(j+="; Secure"),g.partitioned&&(j+="; Partitioned"),g.priority){var k=typeof g.priority=="string"?g.priority.toLowerCase():g.priority;switch(k){case"low":j+="; Priority=Low";break;case"medium":j+="; Priority=Medium";break;case"high":j+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(g.sameSite){var N=typeof g.sameSite=="string"?g.sameSite.toLowerCase():g.sameSite;switch(N){case!0:j+="; SameSite=Strict";break;case"lax":j+="; SameSite=Lax";break;case"strict":j+="; SameSite=Strict";break;case"none":j+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return j}function m(p){return p.indexOf("%")!==-1?decodeURIComponent(p):p}function h(p){return t.call(p)==="[object Date]"}function x(p,y){try{return y(p)}catch{return p}}return Xa}var us=wc();function Nc(){const t=typeof global>"u"?void 0:global.TEST_HAS_DOCUMENT_COOKIE;return typeof t=="boolean"?t:typeof document=="object"&&typeof document.cookie=="string"}function Cc(t){return typeof t=="string"?us.parse(t):typeof t=="object"&&t!==null?t:{}}function pn(t,a={}){const s=Sc(t);if(!a.doNotParse)try{return JSON.parse(s)}catch{}return t}function Sc(t){return t&&t[0]==="j"&&t[1]===":"?t.substr(2):t}class ll{constructor(a,s={}){this.changeListeners=[],this.HAS_DOCUMENT_COOKIE=!1,this.update=()=>{if(!this.HAS_DOCUMENT_COOKIE)return;const r=this.cookies;this.cookies=us.parse(document.cookie),this._checkChanges(r)};const n=typeof document>"u"?"":document.cookie;this.cookies=Cc(a||n),this.defaultSetOptions=s,this.HAS_DOCUMENT_COOKIE=Nc()}_emitChange(a){for(let s=0;s{a[n]!==this.cookies[n]&&this._emitChange({name:n,value:pn(this.cookies[n])})})}_startPolling(){this.pollingInterval=setInterval(this.update,300)}_stopPolling(){this.pollingInterval&&clearInterval(this.pollingInterval)}get(a,s={}){return s.doNotUpdate||this.update(),pn(this.cookies[a],s)}getAll(a={}){a.doNotUpdate||this.update();const s={};for(let n in this.cookies)s[n]=pn(this.cookies[n],a);return s}set(a,s,n){n?n=Object.assign(Object.assign({},this.defaultSetOptions),n):n=this.defaultSetOptions;const r=typeof s=="string"?s:JSON.stringify(s);this.cookies=Object.assign(Object.assign({},this.cookies),{[a]:r}),this.HAS_DOCUMENT_COOKIE&&(document.cookie=us.serialize(a,r,n)),this._emitChange({name:a,value:s,options:n})}remove(a,s){const n=s=Object.assign(Object.assign(Object.assign({},this.defaultSetOptions),s),{expires:new Date(1970,1,1,0,0,1),maxAge:0});this.cookies=Object.assign({},this.cookies),delete this.cookies[a],this.HAS_DOCUMENT_COOKIE&&(document.cookie=us.serialize(a,"",n)),this._emitChange({name:a,value:void 0,options:s})}addChangeListener(a){this.changeListeners.push(a),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===1&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.addEventListener("change",this.update):this._startPolling())}removeChangeListener(a){const s=this.changeListeners.indexOf(a);s>=0&&this.changeListeners.splice(s,1),this.HAS_DOCUMENT_COOKIE&&this.changeListeners.length===0&&(typeof window=="object"&&"cookieStore"in window?window.cookieStore.removeEventListener("change",this.update):this._stopPolling())}}const ol=l.createContext(new ll),{Provider:Ec,Consumer:_5}=ol;class zc extends l.Component{constructor(a){super(a),a.cookies?this.cookies=a.cookies:this.cookies=new ll(void 0,a.defaultSetOptions)}render(){return l.createElement(Ec,{value:this.cookies},this.props.children)}}var xn={exports:{}},ye={};/** @license React v16.13.1 * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Xr;function _c(){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 Lc(){return Zr||(Zr=1,xn.exports=_c()),xn.exports}var gn,Jr;function Rc(){if(Jr)return gn;Jr=1;var t=Lc(),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));Tc()&&l.useLayoutEffect(()=>{function m(){const h=s.getAll(r);$c(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 $c(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",Pc=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}`]}},Mc=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}`]}},Ac=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}`]}},cl=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}`]}},dl=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}`]}},ul=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",Dc="/resources",gr="/about",hs="/contact_us",it="/register",Qe="/login",Tt="/",Ic="/branding",fr="/pages/create",ml="/settings/profile",Oc="/:handle",br=t=>`/@${t.replace(/^@/,"")}`,Vt="/pages",Fc="/analytics",dt="/plans",Bc="/settings",Uc="/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"})},hl=typeof document<"u"?q.useLayoutEffect:()=>{};function Hc(t){const a=l.useRef(null);return hl(()=>{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 pl(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 Vc(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 xl(t){let a=null;return()=>(a==null&&(a=t()),a)}const Gc=xl(function(){return Vc(/^Mac/i)}),qc=xl(function(){return Wc(/Android/i)});function Yc(t){return t.mozInputSource===0&&t.isTrusted?!0:qc()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}class Kc{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 gl(t){let a=l.useRef({isFocused:!1,observer:null});hl(()=>{const n=a.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]);let s=Hc(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 Kc("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 Xc(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=gl(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 Zc={Tab:!0,Escape:!0};function yr(t,a){for(let s of Wn)s(t,a)}function Jc(t){return!(t.metaKey||!Gc()&&t.altKey||t.ctrlKey||t.key==="Control"||t.key==="Shift"||t.key==="Meta")}function ps(t){At=!0,Jc(t)&&(Pa="keyboard",yr("keyboard",t))}function Xe(t){Pa="pointer",(t.type==="mousedown"||t.type==="pointerdown")&&(At=!0,yr("pointer",t))}function fl(t){Yc(t)&&(At=!0,Pa="virtual")}function bl(t){t.target===window||t.target===document||(!At&&!Vn&&(Pa="virtual",yr("virtual",t)),At=!1,Vn=!1)}function vl(){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",fl,!0),a.addEventListener("focus",bl,!0),a.addEventListener("blur",vl,!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",()=>{yl(t)},{once:!0}),ha.set(a,{focus:n})}const yl=(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",fl,!0),s.removeEventListener("focus",bl,!0),s.removeEventListener("blur",vl,!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 Qc(t){const a=$a(t);let s;return a.readyState!=="loading"?Gn(t):(s=()=>{Gn(t)},a.addEventListener("DOMContentLoaded",s)),()=>yl(t,s)}typeof document<"u"&&Qc();function kl(){return Pa!=="pointer"}const e0=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function t0(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&&!e0.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&&!Zc[s.key])}function a0(t,a,s){Gn(),l.useEffect(()=>{let n=(r,i)=>{t0(!!(s!=null&&s.isTextInput),r,i)&&t(kl())};return Wn.add(n),()=>{Wn.delete(n)}},a)}function s0(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=gl(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,fn=0;function qn(){xs=!0,setTimeout(()=>{xs=!1},50)}function Qr(t){t.pointerType==="touch"&&qn()}function n0(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Qr):document.addEventListener("touchend",qn),fn++,()=>{fn--,!(fn>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(n0,[]);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||kl()}),[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]);a0(p=>{r.current.isFocusVisible=p,u()},[],{isTextInput:s});let{focusProps:h}=Xc({isDisabled:n,onFocusChange:m}),{focusWithinProps:x}=s0({isDisabled:!n,onFocusWithinChange:m});return{isFocused:i,isFocusVisible:d,focusProps:n?x:h}}var r0=Object.defineProperty,i0=(t,a,s)=>a in t?r0(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,bn=(t,a,s)=>(i0(t,typeof a!="symbol"?a+"":a,s),s);let l0=class{constructor(){bn(this,"current",this.detect()),bn(this,"handoffState","pending"),bn(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 l0;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 o0(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 c0(t,a){return!(!t||!a||t.righta.right||t.bottoma.bottom)}function jl({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=o0(u);n(c0(m,a.current.getBoundingClientRect()))}},!1),r.addEventListener(c,"pointercancel",i,!1)}}});return{pressed:s,pressProps:t?{}:{onPointerDown:o,onPointerUp:i,onClick:i}}}let d0=l.createContext(void 0);function Aa(){return l.useContext(d0)}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=m0();return l.useCallback(a=>u0({mergeRefs:t,...a}),[t])}function u0({ourProps:t,theirProps:a,slot:s,defaultTag:n,features:r,visible:i=!0,name:o,mergeRefs:d}){d=d??h0;let c=wl(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}=vn(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(` + */var Xr;function Lc(){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,xn.exports=Lc()),xn.exports}var gn,Jr;function Rc(){if(Jr)return gn;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));Tc()&&l.useLayoutEffect(()=>{function m(){const h=s.getAll(r);$c(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 $c(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",Pc=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}`]}},Mc=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}`]}},Ac=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}`]}},cl=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}`]}},dl=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}`]}},ul=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",Dc="/resources",gr="/about",hs="/contact_us",it="/register",Qe="/login",Tt="/",Ic="/branding",fr="/pages/create",ml="/settings/profile",Oc="/:handle",br=t=>`/@${t.replace(/^@/,"")}`,Vt="/pages",Fc="/analytics",dt="/plans",Bc="/settings",Uc="/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"})},hl=typeof document<"u"?q.useLayoutEffect:()=>{};function Hc(t){const a=l.useRef(null);return hl(()=>{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},Lt=t=>t&&"window"in t&&t.window===t?t:$a(t).defaultView||window;function pl(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 Vc(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 xl(t){let a=null;return()=>(a==null&&(a=t()),a)}const Gc=xl(function(){return Vc(/^Mac/i)}),qc=xl(function(){return Wc(/Android/i)});function Yc(t){return t.mozInputSource===0&&t.isTrusted?!0:qc()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}class Kc{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 gl(t){let a=l.useRef({isFocused:!1,observer:null});hl(()=>{const n=a.current;return()=>{n.observer&&(n.observer.disconnect(),n.observer=null)}},[]);let s=Hc(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 Kc("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 Xc(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=gl(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 Zc={Tab:!0,Escape:!0};function yr(t,a){for(let s of Wn)s(t,a)}function Jc(t){return!(t.metaKey||!Gc()&&t.altKey||t.ctrlKey||t.key==="Control"||t.key==="Shift"||t.key==="Meta")}function ps(t){At=!0,Jc(t)&&(Pa="keyboard",yr("keyboard",t))}function Xe(t){Pa="pointer",(t.type==="mousedown"||t.type==="pointerdown")&&(At=!0,yr("pointer",t))}function fl(t){Yc(t)&&(At=!0,Pa="virtual")}function bl(t){t.target===window||t.target===document||(!At&&!Vn&&(Pa="virtual",yr("virtual",t)),At=!1,Vn=!1)}function vl(){At=!1,Vn=!0}function Gn(t){if(typeof window>"u"||ha.get(Lt(t)))return;const a=Lt(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",fl,!0),a.addEventListener("focus",bl,!0),a.addEventListener("blur",vl,!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",()=>{yl(t)},{once:!0}),ha.set(a,{focus:n})}const yl=(t,a)=>{const s=Lt(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",fl,!0),s.removeEventListener("focus",bl,!0),s.removeEventListener("blur",vl,!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 Qc(t){const a=$a(t);let s;return a.readyState!=="loading"?Gn(t):(s=()=>{Gn(t)},a.addEventListener("DOMContentLoaded",s)),()=>yl(t,s)}typeof document<"u"&&Qc();function kl(){return Pa!=="pointer"}const e0=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function t0(t,a,s){var n;const r=typeof window<"u"?Lt(s==null?void 0:s.target).HTMLInputElement:HTMLInputElement,i=typeof window<"u"?Lt(s==null?void 0:s.target).HTMLTextAreaElement:HTMLTextAreaElement,o=typeof window<"u"?Lt(s==null?void 0:s.target).HTMLElement:HTMLElement,d=typeof window<"u"?Lt(s==null?void 0:s.target).KeyboardEvent:KeyboardEvent;return t=t||(s==null?void 0:s.target)instanceof r&&!e0.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&&!Zc[s.key])}function a0(t,a,s){Gn(),l.useEffect(()=>{let n=(r,i)=>{t0(!!(s!=null&&s.isTextInput),r,i)&&t(kl())};return Wn.add(n),()=>{Wn.delete(n)}},a)}function s0(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=gl(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,fn=0;function qn(){xs=!0,setTimeout(()=>{xs=!1},50)}function Qr(t){t.pointerType==="touch"&&qn()}function n0(){if(!(typeof document>"u"))return typeof PointerEvent<"u"?document.addEventListener("pointerup",Qr):document.addEventListener("touchend",qn),fn++,()=>{fn--,!(fn>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(n0,[]);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||kl()}),[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]);a0(p=>{r.current.isFocusVisible=p,u()},[],{isTextInput:s});let{focusProps:h}=Xc({isDisabled:n,onFocusChange:m}),{focusWithinProps:x}=s0({isDisabled:!n,onFocusWithinChange:m});return{isFocused:i,isFocusVisible:d,focusProps:n?x:h}}var r0=Object.defineProperty,i0=(t,a,s)=>a in t?r0(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s,bn=(t,a,s)=>(i0(t,typeof a!="symbol"?a+"":a,s),s);let l0=class{constructor(){bn(this,"current",this.detect()),bn(this,"handoffState","pending"),bn(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 l0;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 o0(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 c0(t,a){return!(!t||!a||t.righta.right||t.bottoma.bottom)}function jl({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=o0(u);n(c0(m,a.current.getBoundingClientRect()))}},!1),r.addEventListener(c,"pointercancel",i,!1)}}});return{pressed:s,pressProps:t?{}:{onPointerDown:o,onPointerUp:i,onClick:i}}}let d0=l.createContext(void 0);function Aa(){return l.useContext(d0)}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=m0();return l.useCallback(a=>u0({mergeRefs:t,...a}),[t])}function u0({ourProps:t,theirProps:a,slot:s,defaultTag:n,features:r,visible:i=!0,name:o,mergeRefs:d}){d=d??h0;let c=wl(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}=vn(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=wl(m.props,gt(vn(c,["ref"])));for(let b in h)b in f&&delete h[b];return l.cloneElement(m,Object.assign({},f,h,u,{ref:r(p0(m),u.ref)},g))}return l.createElement(i,Object.assign({},vn(c,["ref"]),i!==l.Fragment&&u,i!==l.Fragment&&h),m)}function m0(){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 h0(...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 wl(...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 vn(t,a=[]){let s=Object.assign({},t);for(let n of a)n in s&&delete s[n];return s}function p0(t){return q.version.split(".")[0]>="19"?t.props.ref:t.ref}let x0="button";function g0(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}=jl({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:x0,name:"Button"})}let f0=ze(g0);function b0(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 v0(t){let[a]=l.useState(t);return a}function Nl(t={},a=null,s=[]){for(let[n,r]of Object.entries(t))Sl(s,Cl(a,n),r);return s}function Cl(t,a){return t?t+"["+a+"]":a}function Sl(t,a,s){if(Array.isArray(s))for(let[n,r]of s.entries())Sl(t,Cl(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,""]):Nl(s,a,t)}function y0(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 k0="span";var Gt=(t=>(t[t.None=1]="None",t[t.Focusable=2]="Focusable",t[t.Hidden=4]="Hidden",t))(Gt||{});function j0(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:k0,name:"Hidden"})}let ja=ze(j0),w0=l.createContext(null);function N0({children:t}){let a=l.useContext(w0);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 C0({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(N0,null,q.createElement(S0,{setForm:o,formId:a}),Nl(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 S0({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 E0=l.createContext(void 0);function El(){return l.useContext(E0)}function zl(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&&z0(s)?!1:n}function z0(t){if(!t)return!1;let a=t.previousElementSibling;for(;a!==null;){if(a instanceof HTMLLegendElement)return!1;a=a.previousElementSibling}return!0}let _l=Symbol();function _0(t,a=!0){return Object.assign(t,{[_l]: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[_l]))?void 0:s}let Os=l.createContext(null);Os.displayName="DescriptionContext";function Ll(){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,Ll),a}return t}function L0(){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 R0="p";function T0(t,a){let s=l.useId(),n=Aa(),{id:r=`headlessui-description-${s}`,...i}=t,o=Ll(),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:R0,name:o.name||"Description"})}let $0=ze(T0),Rl=Object.assign($0,{});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 Tl(){let t=l.useContext(Fs);if(t===null){let a=new Error("You used a