@soba-so/react 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use client"
2
- import{useRef as ps,useState as so}from"react";var Cn=class extends Error{status;constructor(n,t){super(n),this.name="ConnectError",this.status=t}},ss=5*6e4,Ln=class{session;baseUrl;doFetch;lastMachines=null;machinesUrl=null;gatewayBackUntil=0;constructor(n){this.session=n.session,this.baseUrl=(n.baseUrl??"").replace(/\/+$/,""),this.doFetch=n.fetchImpl??fetch.bind(globalThis)}async context(){let n=await this.request("GET","/v1/connect");return this.setMachinesUrl(n.machines_url),n}setMachinesUrl(n){typeof n=="string"&&/^https?:\/\//.test(n)&&(this.machinesUrl=n)}async machines(){let n=this.lastMachines,t=n?`?v=${encodeURIComponent(n.version)}`:"",r;if(this.machinesUrl&&Date.now()>=this.gatewayBackUntil)try{r=await this.request("GET",`${this.machinesUrl}${t}`)}catch(s){if(s instanceof Cn&&s.status===401)throw s;this.gatewayBackUntil=Date.now()+ss}if(r??=await this.request("GET",`/v1/machines${t}`),r.unchanged&&n)return n.machines;let o=Array.isArray(r.machines)?r.machines:[];return this.lastMachines=typeof r.version=="string"?{version:r.version,machines:o}:null,o}async runs(){let n=await this.request("GET","/v1/machines/runs");return Array.isArray(n.runs)?n.runs:[]}async stopRun(n){let t=this.machinesUrl?.replace(/\/v1\/machines$/,"");if(!t)throw new Cn("This page can't stop runs yet: it hasn't been told where Soba's gateway is.",501);await this.request("POST",`${t}/v1/runs/${encodeURIComponent(n)}/stop`,{})}lookup(n){return this.request("GET",`/v1/device/lookup?code=${encodeURIComponent(n)}`)}approve(n){return this.request("POST","/v1/device/approve",{user_code:n})}claim(n){return this.request("POST","/v1/device/claim",{pairing_nonce:n})}deny(n){return this.request("POST","/v1/device/deny",{user_code:n})}plans(){return this.request("GET","/v1/plans")}selectPlan(n){return this.request("POST","/v1/plans/select",{plan:n})}checkoutPlan(n,t){return this.request("POST","/v1/plans/checkout",{plan:n,...t?.successUrl?{success_url:t.successUrl}:{},...t?.cancelUrl?{cancel_url:t.cancelUrl}:{}})}leavePlan(){return this.request("DELETE","/v1/plans/select")}hosted(){return this.request("GET","/v1/hosted")}startHosted(){return this.request("POST","/v1/hosted/start")}disconnectHosted(n){return this.request("DELETE",n?`/v1/hosted?provider=${encodeURIComponent(n)}`:"/v1/hosted")}approveRuntime(n,t){return this.request("POST","/v1/runtimes/approve",{machine_id:n,runtime_id:t})}preferRuntime(n,t){return this.request("POST","/v1/runtimes/prefer",{machine_id:n,runtime_id:t})}async request(n,t,r){let o=await this.doFetch(/^https?:\/\//.test(t)?t:`${this.baseUrl}${t}`,{method:n,headers:{authorization:`Bearer ${this.session}`,...r?{"content-type":"application/json"}:{}},...r?{body:JSON.stringify(r)}:{}}),s={};try{s=await o.json()}catch{}if(!o.ok){let a=typeof s.error=="string"?s.error:`Request failed (${o.status})`;throw new Cn(a,o.status)}return s}};function An(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return"#ffffff";let t=n[1].length===3?[...n[1]].map(s=>s+s).join(""):n[1],r=s=>{let a=Number.parseInt(t.slice(s*2,s*2+2),16)/255;return a<=.04045?a/12.92:((a+.055)/1.055)**2.4};return .2126*r(0)+.7152*r(1)+.0722*r(2)>.45?"#101012":"#ffffff"}function At(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return null;let t=n[1].length===3?[...n[1]].map(r=>r+r).join(""):n[1];return[0,1,2].map(r=>Number.parseInt(t.slice(r*2,r*2+2),16))}function kn(e,n,t){let r=At(e),o=At(n);return!r||!o?e:`#${r.map((a,c)=>Math.round(a+(o[c]-a)*t)).map(a=>a.toString(16).padStart(2,"0")).join("")}`}function an(e,n){if(!At(e))return{};let t=An(e),r=n?.trim();return{"--sc-ground":e,"--sc-shell":e,"--sc-sheet":kn(e,t,.07),"--sc-raised":kn(e,t,.13),"--sc-line":kn(e,t,.18),"--sc-line-2":kn(e,t,.28),"--sc-text":t,"--sc-text-2":kn(t,e,.15),"--sc-muted":kn(t,e,.38),...r?{"--sc-accent":r,"--sc-accent-fg":An(r)}:{"--sc-accent":t,"--sc-accent-fg":e}}}function $n(e){return e.authenticated===!0?{tone:"ok",text:"signed in"}:e.authenticated===!1?{tone:"warn",text:e.auth_hint??"signed out on that machine"}:{tone:"unknown",text:"could not tell"}}function Dn(e){let{platform:n,arch:t}=e;if(!n)return null;let r=n==="darwin"||n==="macos",o=r?"Mac":n==="win32"||n==="windows"?"Windows PC":"Linux machine";return r?`${t==="aarch64"||t==="arm64"?"Apple silicon ":""}${o}`:o}function ln(e){return e.find(n=>n.state==="offline")??null}function $t(e){return e.state==="busy"?{tone:"busy",text:`serving ${e.active} of ${e.capacity}`}:e.state==="online"?{tone:"ok",text:"connected"}:{tone:"off",text:"asleep or offline"}}function K(e){let n=e.label?.trim(),t=e.name?.trim();return n&&(!t||n!==t)?n:(t??n??"").replace(/\.(local|lan|home|internal)$/i,"").replace(/[-_]+/g," ").trim()||n||"This machine"}function ft(e,n){let t=o=>o.state==="busy"?0:o.state==="online"?1:2,r=o=>o.last_seen_at?Date.parse(o.last_seen_at):0;return t(e)-t(n)||r(n)-r(e)}function Ee(e){return[...e].sort(ft)[0]??null}function Ge(e){return e?e.state==="busy"?{tone:"busy",word:"Serving"}:e.state==="online"?{tone:"ok",word:"Connected"}:{tone:"off",word:"Asleep"}:{tone:"off",word:"No compute"}}function Dt(e){return e.state==="online"||e.state==="busy"}function Un(e){if(!e)return"never seen";let n=Date.parse(e);if(Number.isNaN(n))return"never seen";let t=Date.now()-n,r=6e4;return t<2*r?"just now":t<60*r?`${Math.floor(t/r)} min ago`:t<24*60*r?`${Math.floor(t/(60*r))} hr ago`:`${Math.floor(t/(24*60*r))} days ago`}function ye(e){return e.runtimes.filter(n=>n.id!=="shell"&&!n.quarantined&&!n.absent)}function De(e){let n=a=>a?e.runtimes.find(c=>c.id===a)??null:null;if(e.requested_runtime)return{by:"app",runtimeId:e.requested_runtime,runtime:n(e.requested_runtime)};let t=ye(e),r=t.find(a=>a.id===e.preferred_runtime);if(r)return{by:"you",runtimeId:r.id,runtime:r};let o=a=>a.id==="claude-code"?0:a.id==="codex"?1:2,s=[...t].sort((a,c)=>o(a)-o(c))[0]??null;return{by:"default",runtimeId:s?.id??null,runtime:s}}import{useEffect as eo,useRef as as}from"react";import{Fragment as cs,jsx as xe,jsxs as Ut}from"react/jsx-runtime";function Hn({anchor:e,label:n,options:t,current:r,onClose:o,onPick:s}){let a=as(null);return eo(()=>{let i=a.current,l=e.current;if(!i||!l)return;try{typeof i.showPopover=="function"&&i.showPopover()}catch{}let u=l.getBoundingClientRect(),p=i.offsetWidth,y=i.offsetHeight,f=Math.max(8,Math.min(u.right-p,window.innerWidth-p-8)),m=u.bottom+6,w=m+y>window.innerHeight-8&&u.top-6-y>8?u.top-6-y:m;i.style.left=`${Math.round(f)}px`,i.style.top=`${Math.round(w)}px`,i.querySelector('[aria-checked="true"]')?.focus()},[e]),eo(()=>{let i=l=>{let u=l.target;!u||a.current?.contains(u)||e.current?.contains(u)||o()};return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[e,o]),xe("div",{ref:a,role:"menu","aria-label":n,className:"sc-menu",popover:"manual",onKeyDown:i=>{let l=[...a.current?.querySelectorAll("[role=menuitemradio]")??[]],u=l.indexOf(document.activeElement);if(i.key==="Escape")i.stopPropagation(),i.nativeEvent.stopImmediatePropagation(),o(),e.current?.focus();else if(i.key==="ArrowDown"||i.key==="ArrowUp"){i.preventDefault();let p=i.key==="ArrowDown"?1:-1;l[(u+p+l.length)%l.length]?.focus()}else i.key==="Tab"&&o()},children:t.map(i=>xe(is,{option:i,checked:r===i.id,onClose:o,onPick:s},i.id??""))})}function is({option:e,checked:n,onClose:t,onPick:r}){return Ut(cs,{children:[e.heading?xe("div",{className:"sc-menu-head",role:"presentation",children:e.heading}):e.rule?xe("div",{className:"sc-menu-sep"}):null,Ut("button",{type:"button",role:"menuitemradio","aria-checked":n,className:"sc-menu-item",onClick:()=>n?t():r(e.id),children:[e.glyph,Ut("span",{className:"sc-menu-text",children:[xe("span",{className:"sc-menu-label",children:e.label}),e.note&&xe("span",{className:"sc-menu-note",children:e.note})]}),n&&xe(ls,{})]})]})}function ls(){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-menu-check",children:xe("path",{d:"M5 12.5l4.5 4.5L19 7.5",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Nn({open:e}){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-chev sc-chev-open":"sc-chev",children:xe("path",{d:"M9 6l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as we,jsxs as ds}from"react/jsx-runtime";function j({className:e}){return ds("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:[we("path",{d:"M18.125 7.039A8.6 8.6 0 1 0 18.125 16.961A6 6 0 0 1 18.125 7.039Z",fill:"currentColor"}),we("path",{d:"M19.925 7.039A8.6 8.6 0 0 1 19.925 16.961A6 6 0 0 0 19.925 7.039Z",fill:"currentColor"})]})}function no({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{fill:"currentColor",d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})})}function cn({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{fill:"currentColor",d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})})}function ht({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M4 5h16v11H4zM9 20h6M12 16v4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function us({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M5 7l5 5-5 5M12 18h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ht({className:e}){return we("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:we("path",{d:"M5 6h14v10H5zM2.5 19.5h19",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var ze={claude:no,chatgpt:cn,local:ht},to={shell:us};var ie=[{id:"claude",costClass:"user-subscription",short:"Claude Code",label:"Continue with Claude",title:"The Claude plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Claude Code installed and signed in",hint:"Install it from claude.ai/code, then run `claude` once and sign in.",install:"https://claude.com/product/claude-code",expects:["claude-code"]},{id:"chatgpt",costClass:"user-subscription",short:"Codex",label:"Continue with ChatGPT",title:"The ChatGPT plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Codex installed and signed in",hint:"Install Codex, then run `codex` once and sign in.",install:"https://learn.chatgpt.com/codex/cli",expects:["codex"]},{id:"local",costClass:"user-hardware",short:"Local models",label:"Use a model on this machine",title:"A model on your own machine",cost:"Free. You bought the hardware",prerequisite:"Ollama running, with a model pulled",hint:"Install Ollama, then `ollama pull` a model before pairing.",install:"https://ollama.com",expects:["ollama","openai-api"]}],ro=["claude","chatgpt"];function Wt(){return ie.filter(e=>ro.includes(e.id))}function Bt(e){return ie.filter(n=>n.costClass===e)}function qt(e){return ie.find(n=>n.expects.includes(e))??null}import{Fragment as io,jsx as g,jsxs as I}from"react/jsx-runtime";function un({machines:e,hosted:n=[],onApproveRuntime:t,onPreferRuntime:r,onDisconnectHosted:o,onPair:s,onRefresh:a,refreshing:c,busy:i,appName:l,error:u,runs:p,runsOpen:y,onToggleRuns:f,markOf:m,loading:w,machineMenu:M,machineNote:R,children:_,onStopRun:U}){let P=Ee(e),T=e.filter(S=>S.id!==P?.id),E=P&&p?hs(p,P):{};return!P&&n.length===0&&!s?g("p",{className:"sc-note",children:"Nothing connected yet."}):I("div",{className:"sc-tray",children:[P&&I(xn,{title:"This machine",action:(a||M)&&I("span",{className:"sc-cap-acts",children:[a&&g("button",{type:"button",className:"sc-disc",onClick:a,disabled:c,"aria-label":"Refresh",title:"Refresh",children:g(Rs,{spinning:!!c})}),M]}),children:[g(ms,{machine:P,...f?{onToggle:f,open:!!y}:{}}),R]}),P&&f&&y&&g(gs,{machine:P,runs:p??null,...m?{markOf:m}:{},...U?{onStop:U}:{}}),P&&g(xn,{title:"Agents on it",action:g(Ns,{machine:P,appName:l,busy:i,...m?{markOf:m}:{},...r?{onPick:S=>r(P.id,S)}:{}}),children:w&&P.runtimes.length===0?g("p",{className:"sc-row-note",children:"Looking\u2026"}):P.runtimes.length>0?P.runtimes.map(S=>g(ks,{runtime:S,serving:E[S.id]??S.serving??0,...m?{mark:m(S)}:{},...t?{onApprove:()=>t(P.id,S.id)}:{}},S.id)):g("p",{className:"sc-row-note",children:"No agent advertised. Install Claude Code, Codex or Ollama on that machine."})}),n.length>0&&g(xn,{title:n.length>1?"Connected plans":"Connected plan",children:n.map(S=>g(Ss,{credential:S,appName:l,busy:i,...o?{onDisconnect:()=>o(S.provider)}:{}},S.provider))}),(T.length>0||s)&&I(xn,{title:T.length>0?"Your other machines":P?"Add a machine":"Your machines",children:[T.map(S=>g(vs,{machine:S},S.id)),s&&I("button",{type:"button",className:"sc-pair",onClick:s,children:[g("span",{className:"sc-otile","aria-hidden":"true",children:g(Ms,{})}),g("span",{className:"sc-oname",children:e.length>0?"Pair another machine":"Connect a machine"})]})]}),_,u&&g("p",{className:"sc-error sc-tray-error",children:u})]})}function xn({title:e,action:n,children:t}){return I("section",{className:"sc-group",children:[I("div",{className:"sc-group-cap",children:[g("p",{className:"sc-group-title",children:e}),n]}),g("div",{className:"sc-group-card",children:t})]})}function ms({machine:e,onToggle:n,open:t}){let r=Dt(e),o=[r?null:e.pairing_lost?"No longer connected here":"Asleep or offline",Dn(e),e.always_on?"always on":null,r&&e.capacity>0?`${e.active} of ${e.capacity} in flight`:Un(e.last_seen_at)].filter(Boolean),s=I(io,{children:[I("span",{className:"sc-mtile","aria-hidden":"true",children:[g(ao,{}),g("span",{className:`sc-mbadge sc-mbadge-${Ge(e).tone}`})]}),I("span",{className:"sc-mid",children:[g("span",{className:"sc-mname",children:K(e)}),g("span",{className:"sc-mmeta",children:o.map((a,c)=>I("span",{children:[c>0&&g("span",{className:"sc-mmeta-sep",children:"\xB7"}),a]},a))})]})]});return!n||!r?g("div",{className:"sc-mrow",children:s}):I("button",{type:"button",className:"sc-mrow sc-mrow-btn",onClick:n,"aria-expanded":!!t,title:t?"Hide what it is running":"See what it is running",children:[s,g(Nn,{open:!!t})]})}function fs(e,n){return e.filter(t=>t.machine_id===n.id||t.machine_id===null)}function hs(e,n){let t={};for(let r of e)r.machine_id!==n.id||r.status!=="running"||!r.runtime_id||(t[r.runtime_id]=(t[r.runtime_id]??0)+1);return t}function gs({machine:e,runs:n,markOf:t,onStop:r}){let o=n?fs(n,e):[],s=l=>{if(!l||!t)return null;let u=e.runtimes.find(p=>p.id===l);return u?t(u):null},[a,c]=so(new Set),i=async l=>{c(u=>new Set(u).add(l));try{await r?.(l)}catch{c(u=>{let p=new Set(u);return p.delete(l),p})}};return g(xn,{title:"Running now",children:n===null?g("p",{className:"sc-row-note",children:"Looking\u2026"}):o.length===0?g("p",{className:"sc-row-note",children:"Nothing running."}):o.map(l=>{let u=s(l.runtime_id);return g(bs,{run:l,...u?{mark:u}:{},stopping:a.has(l.id),...r?{onStop:()=>void i(l.id)}:{}},l.id)})})}function bs({run:e,mark:n,stopping:t,onStop:r}){let o=e.runtime_id?gt(e.runtime_id):null;return I("div",{className:"sc-rrow",children:[g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:n??(o&&g(o,{className:"sc-runtime-mark"}))}),I("span",{className:"sc-mid",children:[I("span",{className:"sc-rtop",children:[g("span",{className:"sc-aname",children:oo(e)}),g("span",{className:"sc-averdict",children:ws(e.started_at)})]}),g("span",{className:"sc-rstep",children:t?"Stopping\u2026":ys(e)})]}),r&&g("button",{type:"button",className:"sc-disc sc-rstop",onClick:r,disabled:t,"aria-label":`Stop ${oo(e)}`,title:"Stop",children:g(_s,{})})]})}function gt(e){let n=qt(e);return(n?ze[n.id]:null)??to[e]??null}function oo(e){if(e.label)return e.label;if(e.task){let n=e.task.replace(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}return"A run"}function ys(e){if(e.status==="queued")return"Waiting for a free slot";if(e.step)return e.step;switch(e.phase?.kind){case"thinking":return"Thinking";case"writing":return"Writing";case"tool":return e.phase.tool?`Using ${e.phase.tool}`:"Using a tool";case"approval":return e.phase.tool?`Waiting for you to allow ${e.phase.tool}`:"Waiting for your approval";default:return e.first_output_at?"Working":"Starting"}}function ws(e){let n=Math.max(0,Math.round((Date.now()-new Date(e).getTime())/1e3));if(n<60)return`${n}s`;let t=Math.floor(n/60);return t<60?`${t}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function vs({machine:e}){let n=Ge(e);return I("div",{className:"sc-orow",children:[g("span",{className:"sc-otile","aria-hidden":"true",children:g(ao,{})}),g("span",{className:"sc-oname",children:K(e)}),g("span",{className:"sc-oword",children:n.word}),g("span",{className:`sc-dot sc-dot-${n.tone}`,"aria-hidden":"true"})]})}function ks({runtime:e,serving:n=0,mark:t,onApprove:r}){let o=$n(e),s=I(io,{children:[g(Cs,{runtime:e,mark:t}),I("span",{className:e.absent?"sc-aname sc-aname-absent":"sc-aname",children:[e.display_name,e.version&&I("span",{className:"sc-aversion",children:[" ",e.version]})]}),n>0?I("span",{className:"sc-averdict",children:[g(Ps,{}),g("span",{className:"sc-aserving",children:n>1?`${n} running`:"running"})]}):e.absent?g("span",{className:"sc-averdict sc-tone-absent",children:"not offered"}):e.quarantined?r?g("button",{type:"button",className:"sc-row-act",onClick:r,children:"Let it serve"}):g("span",{className:"sc-averdict sc-tone-warn",children:"new, not serving yet"}):o.tone==="ok"?I("span",{className:"sc-averdict",children:[g("span",{className:"sc-dot sc-dot-ok","aria-hidden":"true"}),g("span",{className:"sc-sr",children:o.text})]}):g("span",{className:`sc-averdict sc-tone-${o.tone}`,children:o.text})]});return g("div",{className:"sc-arow",children:s})}function Cs({runtime:e,mark:n}){if(n)return g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:n});let t=gt(e.id);return g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:t&&g(t,{className:"sc-runtime-mark"})})}function Ns({machine:e,appName:n,busy:t,markOf:r,onPick:o}){let s=De(e),a=ye(e),[c,i]=so(!1),l=ps(null);if(s.by!=="app"&&a.length===0)return null;let u=f=>{if(!f)return null;if(r)return r(f);let m=gt(f.id);return g("span",{className:"sc-runtime-tile","aria-hidden":"true",children:m&&g(m,{className:"sc-runtime-mark"})})},p=f=>{if(!f)return null;if(r)return g("span",{className:"sc-runs-mark",children:r(f)});let m=gt(f.id);return m?g(m,{className:"sc-runs-glyph"}):null},y;return s.by==="app"?y=I("span",{className:"sc-runs-fixed",title:`Set by ${n??"the app"}`,children:[p(s.runtime),s.runtime?.display_name??s.runtimeId]}):!o||a.length<2?y=I("span",{className:"sc-runs-fixed",children:[p(s.runtime),s.runtime?.display_name]}):y=I("button",{ref:l,type:"button",className:"sc-runs-btn","aria-haspopup":"menu","aria-expanded":c,"aria-label":`Runs go to ${s.runtime?.display_name??"the default"}. Change`,disabled:t,onClick:()=>i(f=>!f),children:[p(s.runtime),g("span",{className:"sc-runs-label",children:s.runtime?.display_name}),g(Nn,{open:!0})]}),I("span",{className:"sc-runs-to",children:[g("span",{className:"sc-runs-cap",children:s.by==="app"?`${n??"App"} uses`:"Runs on"}),y,c&&o&&g(xs,{anchor:l,machine:e,tile:u,onClose:()=>i(!1),onPick:f=>{i(!1),o(f)}})]})}function xs({anchor:e,machine:n,tile:t,onClose:r,onPick:o}){let s=De(n),a=De({...n,preferred_runtime:null}).runtime,c=s.by==="you"?s.runtimeId:null,i=[{id:null,label:"Automatic",...a?{note:`Uses ${a.display_name}`}:{},glyph:t(a)},...ye(n).map((l,u)=>({id:l.id,label:l.display_name,glyph:t(l),...u===0?{rule:!0}:{}}))];return g(Hn,{anchor:e,label:"Which agent runs go to",options:i,current:c,onClose:r,onPick:o})}function Ss({credential:e,appName:n,busy:t,onDisconnect:r}){return I("div",{className:"sc-hrow",children:[I("div",{className:"sc-orow",children:[g("span",{className:"sc-otile","aria-hidden":"true",children:g(cn,{className:"sc-omark"})}),I("span",{className:"sc-mid",children:[g("span",{className:"sc-oname",children:e.provider==="openai-chatgpt"?"ChatGPT plan":e.provider}),g("span",{className:"sc-mmeta",children:e.account_label??"signed in"})]}),r&&g("button",{type:"button",className:"sc-row-act",onClick:r,disabled:t,children:"Disconnect"})]}),r&&I("p",{className:"sc-row-note",children:[n??"This app"," stops using it. To withdraw the grant entirely, remove it in your OpenAI settings."]})]})}function ao(){return I("svg",{viewBox:"0 0 32 24","aria-hidden":"true",focusable:"false",className:"sc-mglyph",children:[g("rect",{x:"4",y:"1.5",width:"24",height:"15",rx:"2.5",fill:"var(--sc-sheet, #ffffff)",stroke:"currentColor",strokeWidth:"2"}),g("rect",{x:"1",y:"19.5",width:"30",height:"2.5",rx:"1.25",fill:"currentColor"})]})}function Ms(){return g("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-oglyph",children:g("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function Ps(){return I("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-sglyph sc-spin",children:[g("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),g("path",{d:"M12 3a9 9 0 0 1 9 9",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Rs({spinning:e}){return g("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-dglyph sc-spin":"sc-dglyph",children:g("path",{d:"M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function _s(){return g("svg",{className:"sc-dglyph",viewBox:"0 0 16 16","aria-hidden":"true",children:g("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5",fill:"currentColor"})})}import{jsx as Es}from"react/jsx-runtime";function Wn({machines:e,onApproveRuntime:n}){return Es(un,{machines:e,...n?{onApproveRuntime:n}:{}})}var Ft={ready:{arc:!0},serving:{arc:!0,slot:"stream"},paused:{arc:!1,slot:"zzz"},thinking:{arc:!1,slot:"dots"},connecting:{arc:!1,slot:"orbit"},attention:{arc:!1,slot:"bang"},gone:{arc:!1,slot:"cross"},snap:{arc:!1,slot:"snap"},listening:{arc:!1,slot:"bars"},permission:{arc:!1,slot:"ring"},ai:{arc:!1,slot:"sparks"}};var Gt="105 162 420 420",zt="M407.1 308.9 A158 158 0 1 0 407.1 491.1 A116 116 0 0 1 407.1 308.9 Z",dn="M448.5 320 A110 110 0 0 1 448.5 480";import{Fragment as qn,jsx as x,jsxs as Ve}from"react/jsx-runtime";function Vt({kind:e,size:n=44,className:t}){let r=Ft[e];return Ve("svg",{className:`bx${t?` ${t}`:""}`,"data-expression":e,viewBox:Gt,overflow:"visible",width:n,height:n,"aria-hidden":"true",children:[x("path",{d:zt,fill:"currentColor"}),x("path",{className:"bx-arc",d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),r.slot==="stream"&&x(Os,{}),r.slot==="zzz"&&x(Is,{}),r.slot==="dots"&&x(Ts,{}),r.slot==="bang"&&x(Ls,{}),r.slot==="orbit"&&x(As,{}),r.slot==="cross"&&x($s,{}),r.slot==="snap"&&x(Ds,{}),r.slot==="bars"&&x(Us,{}),r.slot==="ring"&&x(Hs,{}),r.slot==="sparks"&&x(Ws,{})]})}function Os(){return x("path",{className:"bx-st",d:"M475.3 290.3 A150 150 0 0 1 475.3 509.7",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeDasharray:"0.1 31"})}function Is(){return Ve(qn,{children:[x("g",{className:"bx-z1",children:x("path",{d:"M444 372 H496 L444 436 H496",fill:"none",stroke:"currentColor",strokeWidth:"20",strokeLinecap:"round",strokeLinejoin:"round"})}),x("g",{className:"bx-z2",children:x("path",{d:"M492 300 H522 L492 338 H522",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeLinejoin:"round"})})]})}function Ts(){return Ve(qn,{children:[x("circle",{className:"bx-th",cx:"463.1",cy:"336.9",r:"21",fill:"currentColor"}),x("circle",{className:"bx-th bx-th2",cx:"483",cy:"400",r:"21",fill:"currentColor"}),x("circle",{className:"bx-th bx-th3",cx:"463.1",cy:"463.1",r:"21",fill:"currentColor"})]})}function Ls(){return Ve("g",{className:"bx-at",children:[x("line",{x1:"490",y1:"312",x2:"490",y2:"414",stroke:"currentColor",strokeWidth:"46",strokeLinecap:"round"}),x("circle",{cx:"490",cy:"484",r:"28",fill:"currentColor"})]})}function As(){return Ve("g",{className:"bx-ob",children:[x("path",{d:dn,fill:"none",stroke:"var(--tile-bg, transparent)",strokeWidth:41,strokeLinecap:"round"}),x("path",{d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})]})}function $s(){return Ve(qn,{children:[x("path",{className:"bx-xa",d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),x("g",{className:"bx-xx",children:x("path",{d:"M442 364 L514 436 M514 364 L442 436",fill:"none",stroke:"currentColor",strokeWidth:"24",strokeLinecap:"round"})})]})}function Ds(){return x("path",{className:"bx-snap",d:dn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})}function Us(){return Ve("g",{stroke:"currentColor",strokeWidth:"17",strokeLinecap:"round",children:[x("line",{className:"bx-vb",x1:"452",y1:"370",x2:"452",y2:"430"}),x("line",{className:"bx-vb bx-vb2",x1:"482",y1:"330",x2:"482",y2:"470"}),x("line",{className:"bx-vb bx-vb3",x1:"512",y1:"355",x2:"512",y2:"445"})]})}function Hs(){return x(qn,{children:[[450,366],[474,376],[484,400],[474,424],[450,434],[426,424],[416,400],[426,376]].map(([n,t],r)=>x("circle",{className:"bx-w",cx:n,cy:t,r:"11",fill:"currentColor",style:{animationDelay:`${-1.2+r*.15}s`}},r))})}function Ws(){return Ve(qn,{children:[x("g",{className:"bx-sp",children:x("path",{d:"M460 300 Q465.4 324.6 490 330 Q465.4 335.4 460 360 Q454.6 335.4 430 330 Q454.6 324.6 460 300 Z",fill:"currentColor"})}),x("g",{className:"bx-sp bx-sp2",children:x("path",{d:"M486 356 Q493.92 392.08 530 400 Q493.92 407.92 486 444 Q478.08 407.92 442 400 Q478.08 392.08 486 356 Z",fill:"currentColor"})}),x("g",{className:"bx-sp bx-sp3",children:x("path",{d:"M460 440 Q465.4 464.6 490 470 Q465.4 475.4 460 500 Q454.6 475.4 430 470 Q454.6 464.6 460 440 Z",fill:"currentColor"})})]})}import{useCallback as re,useEffect as le,useId as js,useMemo as Ke,useRef as Sn,useState as q}from"react";var Fn=[{slug:"mac-arm",label:"macOS, Apple silicon"},{slug:"mac-intel",label:"macOS, Intel"},{slug:"windows",label:"Windows"},{slug:"linux",label:"Linux"}];function Gn(e){if(!e)return"";try{return new URL(e).origin}catch{return""}}function uo(e,n){return n<2*6e4?e:n<10*6e4?Math.max(e,6e4):n<30*6e4?Math.max(e,3*6e4):Math.max(e,10*6e4)}var Bs=3e3,qs=2*6e4,bt=Date.now(),yt=new Set,co=!1;function Fs(){if(co||typeof window>"u")return;co=!0;let e=()=>{let t=bt;if(bt=Date.now(),bt-t>qs)for(let r of yt)r()};for(let t of["pointerdown","keydown","wheel","touchstart"])window.addEventListener(t,e,{capture:!0,passive:!0});let n=()=>{if(!document.hidden)for(let t of yt)t()};window.addEventListener("focus",n),document.addEventListener("visibilitychange",n)}function Oe(e,n,t={}){Fs();let r,o=t.immediate===!1?Date.now():0,s=!1,a=!1,c=()=>{a||(r=setTimeout(i,t.idle===!1?n:uo(n,Date.now()-bt)))},i=async()=>{if(clearTimeout(r),!(a||s)){if(typeof document>"u"||!document.hidden){s=!0,o=Date.now();try{await e()}catch{}finally{s=!1}}c()}},l=()=>{Date.now()-o>Math.min(n,Bs)&&i()};return yt.add(l),t.immediate===!1?c():i(),()=>{a=!0,clearTimeout(r),yt.delete(l)}}var Kt="soba";function po(){return`${Kt}://show`}function zn(e,n,t){let r=`${Kt}://connect?url=${encodeURIComponent(e)}`;return n&&(r+=`&nonce=${encodeURIComponent(n)}`),t&&(r+=`&want=${encodeURIComponent(t)}`),r}function Vn(){let e=globalThis.crypto;if(!e?.getRandomValues)return null;let n=e.getRandomValues(new Uint8Array(32)),t="";for(let r of n)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var Gs=1600;function jt(e={}){return Jt(e)}async function Yt(e,n={}){if(typeof window>"u"||typeof document>"u")return"unknown";let t=Jt(n);try{window.location.href=zn(e,n.nonce,n.want)}catch{return"absent"}return t}async function Zt(e={}){if(typeof window>"u"||typeof document>"u")return"unknown";let n=Jt(e);try{window.location.href=po()}catch{return"absent"}return n}async function Jt(e){if(typeof window>"u"||typeof document>"u")return"unknown";let n=e.graceMs??Gs,t=document.visibilityState==="visible"&&document.hasFocus(),r=!1,o=()=>{r=!0},s=()=>{document.visibilityState==="hidden"&&(r=!0)};return window.addEventListener("blur",o),window.addEventListener("pagehide",o),document.addEventListener("visibilitychange",s),await new Promise(a=>setTimeout(a,n)),window.removeEventListener("blur",o),window.removeEventListener("pagehide",o),document.removeEventListener("visibilitychange",s),t?r?"opened":"absent":"unknown"}var mo="soba.connect.choice",zs=180*24*60*60*1e3;function Qt(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function Xt(e,n){return e?n?`${mo}.${e}.${Qt(n)}`:`${mo}.${e}`:null}function er(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>zs)return null;let r=ie.find(o=>o.id===t.choice);return r?r.id:null}catch{return null}}function nr(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var fo="soba.connect.model",Vs=180*24*60*60*1e3;function tr(e,n){return e?n?`${fo}.${e}.${Qt(n)}`:`${fo}.${e}`:null}function wt(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>Vs)return null;let r=t.choice;return typeof r!="string"||!r||r.length>120?null:/^[\w.:@+-]+(\/[\w.:@+-]+)?$/.test(r)?r:null}catch{return null}}function rr(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var ho="soba.connect.dismissed",Ks=30*24*60*60*1e3;function or(e,n){return e?n?`${ho}.${e}.${Qt(n)}`:`${ho}.${e}`:null}function sr(e){if(!e||typeof localStorage>"u")return!1;try{let n=localStorage.getItem(e);if(!n)return!1;let t=JSON.parse(n);return Date.now()-Date.parse(t.at)<Ks}catch{return!1}}function ar(e){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({at:new Date().toISOString()}))}catch{}}import{Fragment as Ct,jsx as d,jsxs as N}from"react/jsx-runtime";var ir=2e3,Ys=1e4,Zs=9e4,Js=6e4;function lr(e,n,t,r=[],o){return e?"code":n&&(t.length>0||r.length>0)?"manage":o?"launch":"choose"}function Qs(e){let n=Math.max(0,Math.round(e/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function dr({client:e,initialCode:n,initialChoice:t,onConnected:r,showStatus:o=!0,initialContext:s=null,initialMachines:a,onClose:c,headingId:i,theme:l,reason:u,active:p=!0}){let y=!!s&&a!==void 0,[f,m]=q(y?lr(n,o,a??[],[],t):"loading"),[w,M]=q(s),[R,_]=q(a??[]),[U,P]=q(n??""),[T,E]=q(null),[S,W]=q(null),[ve,X]=q(!1),[ke,V]=q(0),[oe,We]=q(()=>Date.now()),[Y,Pe]=q(null),[Qe,ce]=q(!1),[ue,ee]=q(!1),[gn,Xe]=q("browser"),[Le,en]=q(null),[de,ne]=q([]),[Be,pe]=q(0),[Ae,qe]=q(null),se=Sn(null),[O,bn]=q(t??null),[v,F]=q(null),me=Ke(()=>{let h=w?.accent?.trim(),C=w?.background?.trim();if(!(!h&&!C))return C?{...an(C,h),background:C,borderRadius:"inherit"}:{"--sc-accent":h,"--sc-accent-fg":An(h)}},[w?.accent,w?.background]),fe=js(),te=i??fe,Fe=Sn(null);le(()=>{if(!e||y)return;let h=!0;return Promise.all([e.context(),e.machines()]).then(([C,$])=>{h&&(M(C),_($),m(lr(n,o,$)))}).catch(C=>{h&&(W(C.message),m("choose"))}),()=>{h=!1}},[e,n,o,y]),le(()=>{f!=="loading"||!y||m(lr(n,o,a??[]))},[f,y,n,o,a]),le(()=>{a&&_(a)},[a]),le(()=>{s&&M(s)},[s]);let yn=Sn(!1),wn=Sn(f);wn.current=f;let nn=Sn(de);nn.current=de;let tn=!!w?.hosted_available;le(()=>{!o&&wn.current==="manage"&&m("choose")},[o]),le(()=>{if(!e||!p||f!=="manage")return;let h=!0,C=Oe(async()=>{try{let $=await e.machines();if(!h)return;_($);let B=!tn||yn.current;$.length===0&&nn.current.length===0&&B&&wn.current==="manage"&&m("choose")}catch{}},Ys,{immediate:!1});return()=>{h=!1,C()}},[f,e,tn,p]);let rn=Xt(w?.publishable_key??null);le(()=>{F(er(rn))},[rn]),le(()=>{if(!e||!tn)return;let h=!0;return e.hosted().then(C=>{h&&(ne(C.credentials),!yn.current&&(yn.current=!0,C.credentials.length>0&&o&&wn.current==="choose"&&m("manage")))}).catch(()=>{}),()=>{h=!1}},[e,tn,o]),le(()=>{if(!e||!p||f!=="hosted")return;let h=!0,C=async()=>{try{let _e=await e.hosted();if(!h)return!1;if(ne(_e.credentials),_e.credentials.length>0)return m("hosted_connected"),qe(null),!0}catch{}return!1},$=async()=>{se.current?.closed&&(se.current=null,!await C()&&h&&m("choose"))},B=Oe(C,ir,{immediate:!1}),sn=setInterval($,400),Ne=_e=>{let Tn=_e.data;Tn?.source==="soba"&&Tn.type==="hosted_result"&&C()};return window.addEventListener("message",Ne),()=>{h=!1,B(),clearInterval(sn),window.removeEventListener("message",Ne),se.current=null}},[e,f,p]);let Ot=re(()=>{if(!e)return;let h=window.open("","soba-connect-plan","width=520,height=760,noopener=no");se.current=h,m("hosted"),pe(Date.now()),qe(null),W(null),e.startHosted().then(({url:C})=>{if(h&&!h.closed){h.location.href=C;return}qe(C)}).catch(C=>{h?.close(),se.current=null,W(C.message),m("choose")})},[e]),lt=re(async h=>{if(e){X(!0);try{await e.disconnectHosted(h),ne((await e.hosted()).credentials)}catch(C){W(C.message)}finally{X(!1)}}},[e]);le(()=>{if(!e||!p||f!=="waiting")return;let h=!0,C=Oe(async()=>{try{let $=await e.machines();if(!h)return;_($);let B=Fe.current;if(!B)return;let sn=$.filter(_e=>!B.has(_e.id)),Ne=sn.find(_e=>_e.state!=="offline")??sn[0];if(Ne){en(Ne.id),O&&nr(rn,O);let _e=ie.find(Lt=>Lt.id===O)?.expects??[],Tn=ye(Ne).find(Lt=>_e.includes(Lt.id));Tn&&e.preferRuntime(Ne.id,Tn.id).catch(()=>{}),m("connected"),r?.($)}}catch{}},ir,{immediate:!1});return()=>{h=!1,C()}},[f,e,r,O,rn,p]);let ct=re(async()=>{if(e){W(null),X(!0);try{let h=await e.lookup(U);E(h),m("confirm")}catch(h){W(h.message)}finally{X(!1)}}},[e,U]),vn=re(async()=>{if(e){W(null),X(!0);try{try{Fe.current=new Set((await e.machines()).map(h=>h.id))}catch{Fe.current=new Set(R.map(h=>h.id))}await e.approve(U),m("waiting"),V(Date.now())}catch(h){W(h.message)}finally{X(!1)}}},[e,U,R]),ut=re(async()=>{if(e){X(!0);try{await e.deny(U),Xe("browser"),m("denied")}catch(h){W(h.message)}finally{X(!1)}}},[e,U]),G=Ke(()=>w?.connect_url??null,[w]),[Re,he]=q(()=>Vn()),on=Ke(()=>G?zn(G,Re??void 0,O??void 0):null,[G,Re,O]),dt=Ke(()=>Gn(G),[G]),It=re(h=>{if(R.length===0)return null;let C=ie.find(B=>B.id===h);if(!C)return null;let $=R.flatMap(B=>B.runtimes??[]).filter(B=>C.expects.includes(B.id));return $.length===0?{tone:"dim",text:"not installed"}:$.some(B=>B.authenticated===!0)?{tone:"ok",text:"ready"}:$.every(B=>B.authenticated===!1)?{tone:"warn",text:"needs signing in"}:{tone:"dim",text:"installed"}},[R]),k=re((h=null)=>{bn(h),W(null),Pe(null),ce(!1),ee(!1),z.current=!1,he(Vn()),m("launch")},[]),z=Sn(!!t);le(()=>{f!=="launch"||!G||z.current||(z.current=!0,ce(!0),Yt(G,{...Re?{nonce:Re}:{},...O?{want:O}:{}}).then(Pe))},[f,G,Re,O]);let ae=re(()=>{ce(!0),jt().then(Pe)},[]),pt=re(h=>{if(ue){let C=Vn();ee(!1),he(C),G&&(h.preventDefault(),window.location.href=zn(G,C??void 0,O??void 0))}ae()},[ue,ae,G,O]),ge=Ke(()=>{let h=w?.runtimes;return h?ie.filter(C=>h.includes(C.id)):Wt()},[w?.runtimes]),Ce=Ke(()=>{let h=ie.find(C=>C.id===O);return h?{choice:h,Mark:ze[h.id]??null}:null},[O]),$e=Ke(()=>R.find(h=>h.id===Le),[R,Le]);le(()=>{let h=Re;if(!e||!p||f!=="launch"||!h)return;let C=!1,$=Date.now()+15e4,B=()=>{};return B=Oe(async()=>{if(Date.now()>$){B(),ee(!0);return}try{let sn=await e.claim(h);if(C)return;if(sn.declined){B(),Pe(null),Xe("machine"),m("denied");return}if(!sn.claimed)return;B();try{Fe.current=new Set((await e.machines()).map(Ne=>Ne.id))}catch{Fe.current=new Set(R.map(Ne=>Ne.id))}m("waiting"),V(Date.now())}catch{}},ir,{immediate:!1,idle:!1}),()=>{C=!0,B()}},[e,f,R,Re,p]);let be=Ke(()=>{if(!T)return null;if(T.approved||T.denied)return"answered";let h=T.expires_at?Date.parse(T.expires_at):Number.NaN;return Number.isFinite(h)&&h<=oe?"expired":"live"},[T,oe]);le(()=>{if(!(f==="confirm"&&be==="live"||f==="waiting"||f==="hosted"))return;let C=setInterval(()=>We(Date.now()),1e3);return()=>clearInterval(C)},[f,be]);let mt=re(async(h,C)=>{if(e)try{await e.approveRuntime(h,C),_(await e.machines())}catch($){W($.message)}},[e]),Tt=re(async(h,C)=>{if(e)try{await e.preferRuntime(h,C),_(await e.machines())}catch($){W($.message)}},[e]);return f==="loading"?d("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:me,children:d("div",{className:"sc-card",children:d("p",{className:"sc-note",children:"Loading\u2026"})})}):N("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:me,children:[c&&d("button",{type:"button",className:"sc-modal-close",onClick:c,"aria-label":"Close",children:"\xD7"}),f==="manage"&&N("div",{className:"sc-card",children:[d("h2",{className:"sc-title",id:te,children:"Your compute"}),N("p",{className:"sc-sub",children:[d(vt,{context:w})," ",R.length>0&&de.length>0?"runs on your connected plan, and on these machines while they are awake.":de.length>0?"runs on the plan you connected. Nothing here is charged to you.":"runs on these machines, while they are awake."]}),d(un,{machines:R,hosted:de,onApproveRuntime:mt,onPreferRuntime:(h,C)=>void Tt(h,C),onDisconnectHosted:h=>void lt(h),onPair:()=>m("choose"),busy:ve,...w?.app.name?{appName:w.app.name}:{}}),S&&d("p",{className:"sc-error",children:S})]}),f==="choose"&&N("div",{className:"sc-card",children:[d(ea,{context:w}),d("h2",{className:"sc-h",id:te,children:u==="payment_required"?"Carry on with your own AI":u==="no_compute"?"This run needs a machine":"Connect your AI"}),d("p",{className:"sc-p",children:"Use compute you already have."}),G&&ge.length>0&&N(Ct,{children:[d("div",{className:"sc-opts",children:ge.map(h=>{let C=ze[h.id];return N("button",{type:"button",className:"sc-opt",onClick:()=>k(h.id),children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:C&&d(C,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),(()=>{let $=It(h.id);return $?d("span",{className:`sc-opt-has sc-opt-has-${$.tone}`,children:$.text}):v===h.id?d("span",{className:"sc-opt-last",children:"last used"}):d(cr,{className:"sc-opt-go"})})()]},h.id)})}),N("p",{className:"sc-opt-note",children:["Your accounts stay there. ",go(w)," never sees them."]})]}),(!G||ge.length===0)&&d("p",{className:"sc-error",style:{marginTop:16},children:"This app has no publishable key yet, so there is nothing to pair against."}),S&&d("p",{className:"sc-error",children:S}),G&&w?.show_code===!0&&d("div",{className:"sc-opt-alt",children:d("button",{type:"button",className:"sc-alt-link",onClick:()=>m("code"),children:"I have a code"})})]}),f==="launch"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d(kt,{mark:Ce?.Mark??j,still:ue||!Qe&&Y===null}),d("h2",{className:"sc-h",id:te,children:ue?"No answer from this machine":Y==="absent"?"Nothing opened":Y===null?"Opening Soba App\u2026":"Approve it on this machine"}),ue?d("p",{className:"sc-p",children:"The Soba app did not answer. It may not be open, or nobody was there. Try again when you are ready."}):Y==="absent"?d("p",{className:"sc-p",children:"Nothing opened on this machine. Open it yourself below, or install it if it is not here yet."}):d("p",{className:"sc-p",children:Y===null?"Approve it there and this page does the rest.":"This page finishes on its own."}),Ce&&N("p",{className:"sc-prereq",children:[Ce.Mark&&d(Ce.Mark,{className:"sc-rt-mark"}),"Needs ",Ce.choice.prerequisite]}),N("div",{className:"sc-stack",style:{marginTop:18},children:[d("a",{className:Y==="absent"||ue?"sc-btn sc-btn-primary":"sc-btn",href:on??"#",onClick:pt,children:ue?"Try again":Y==="absent"?"Open Soba App":"Open it again"}),d("p",{className:"sc-note",children:Y===null?"Your browser will ask permission first.":"Your browser asks permission the first time."}),Ce&&Y==="absent"&&d("p",{className:"sc-note",children:d(na,{text:Ce.choice.hint})}),N("div",{className:"sc-foot-strip",children:[d("span",{children:"Not installed on this machine?"}),N("button",{type:"button",className:"sc-foot-go",onClick:()=>m("get"),children:["Get it",d(cr,{})]})]})]})]}),f==="get"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("launch")}),d("p",{className:"sc-head-title",children:"Get Soba App"})]}),d("div",{className:"sc-opts",children:Fn.map(h=>N("a",{className:"sc-opt",href:`${dt}/download/${h.slug}`,target:"_blank",rel:"noreferrer noopener",children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:d(Ht,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),d(cr,{className:"sc-opt-go"})]},h.slug))}),d("p",{className:"sc-opt-note",children:"Install it, then come back here and press the row you started with."})]}),f==="code"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-h",id:te,children:"Enter the code from that machine"}),d("p",{className:"sc-p",children:"Eight characters, shown by the Soba app once you paste the link."}),N("form",{className:"sc-stack",style:{marginTop:16},onSubmit:h=>{h.preventDefault(),ct()},children:[d("input",{className:"sc-input",value:U,onChange:h=>P(h.target.value),placeholder:"ACDE-F234",autoComplete:"off",autoFocus:!0,"aria-label":"Pairing code"}),S&&d("p",{className:"sc-error",children:S}),d("button",{type:"submit",className:"sc-btn sc-btn-primary",disabled:ve||U.length<8,children:ve?"Checking\u2026":"Continue"})]})]}),f==="confirm"&&T&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("code")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-title",children:"Attach this machine to your account?"}),N("p",{className:"sc-sub",children:[d(vt,{context:w})," may send your runs to it once you approve. It can never see the account or the keys on it."]}),N("ul",{className:"sc-facts",children:[d(Kn,{k:"Code",v:T.user_code}),d(Kn,{k:"Machine",v:T.hostname??"not stated"}),d(Kn,{k:"System",v:[T.platform,T.arch].filter(Boolean).join(" / ")||"not stated"}),d(Kn,{k:"Asked by",v:T.client??"not stated"}),T.labels.length>0&&d(Kn,{k:"Labels",v:T.labels.join(", ")})]}),d("p",{className:"sc-note",style:{marginTop:12},children:"Every line above is what that machine said about itself. If none of it looks like a computer of yours, say no."}),be==="expired"&&d("p",{className:"sc-error",children:"That code has expired. Ask the machine for a new one. It prints a fresh code each time it starts."}),be==="answered"&&d("p",{className:"sc-error",children:"That code has already been answered. If it was not you, deny the next one."}),S&&d("p",{className:"sc-error",children:S}),N("div",{className:"sc-row",style:{marginTop:16},children:[d("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:()=>void vn(),disabled:ve||be!=="live",children:"Approve"}),d("button",{type:"button",className:"sc-btn",onClick:()=>void ut(),disabled:ve||be==="answered",children:"No, deny it"})]}),be==="live"&&T.expires_at&&N("p",{className:"sc-note",style:{marginTop:10},children:["This code expires in ",Qs(Date.parse(T.expires_at)-oe),"."]})]}),f==="waiting"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:Ce?.choice.short??"Soba App"})]}),d(kt,{mark:Ce?.Mark??j}),d("h2",{className:"sc-h",id:te,children:"Approved. Waiting for it to connect"}),d("p",{className:"sc-p",children:"Nothing more to do here. This page changes when it arrives."}),ke>0&&oe-ke>Zs&&d("p",{className:"sc-note sc-tone-warn",style:{marginTop:14,textAlign:"center"},children:"Still nothing. Look at the Soba app on that machine: it says what it is doing. This keeps watching either way."})]}),f==="connected"&&N("div",{className:"sc-card",children:[d(ur,{tone:"ok"}),d("h2",{className:"sc-h",id:te,children:$e?.label?`${$e.label} is connected`:"Connected"}),N("p",{className:"sc-p",children:[d(vt,{context:w})," will use ",$e?.label?"it":"this machine"," from now on, while it is awake."]}),o&&N(Ct,{children:[d("div",{style:{marginTop:16},children:d(Wn,{machines:R,onApproveRuntime:mt})}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:14},onClick:()=>m("manage"),children:"Done"})]})]}),f==="hosted"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Mn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"ChatGPT"})]}),Ae?d(kt,{mark:cn,still:!0}):d(kt,{mark:cn}),d("h2",{className:"sc-h",id:te,children:Ae?"Your browser blocked the window":"Finish signing in to ChatGPT"}),d("p",{className:"sc-p",children:Ae?"Nothing opened. Open the sign-in yourself below. A link you click is allowed where a window we open is not.":"Approve it in the window that opened."}),N("div",{className:"sc-stack",style:{marginTop:18},children:[Ae&&d("a",{className:"sc-btn sc-btn-primary",href:Ae,target:"soba-connect-plan",rel:"noreferrer",children:"Open the ChatGPT sign-in"}),S&&d("p",{className:"sc-error",children:S}),Be>0&&oe-Be>Js&&d("p",{className:"sc-note sc-tone-warn",children:"Still nothing. The window may have been closed before it finished, or the sign-in may have been declined. This keeps watching either way."})]})]}),f==="hosted_connected"&&N("div",{className:"sc-card",children:[d(ur,{tone:"ok"}),d("h2",{className:"sc-h",id:te,children:"ChatGPT is connected"}),N("p",{className:"sc-p",children:[d(vt,{context:w})," will run on your ChatGPT plan",de[0]?.account_label?` (${de[0].account_label})`:"",". Nothing more to pay, nothing to install."]}),d("p",{className:"sc-opt-note",style:{textAlign:"center"},children:"It runs on our side, so it has no access to your files or your terminal."}),o&&N(Ct,{children:[d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>m("manage"),children:"Done"}),d("div",{className:"sc-opt-alt",children:d("button",{type:"button",className:"sc-alt-link",onClick:()=>m("choose"),children:"Connect a machine too"})})]})]}),f==="denied"&&N("div",{className:"sc-card",children:[d(ur,{tone:"off"}),d("h2",{className:"sc-h",id:te,children:"Declined"}),d("p",{className:"sc-p",children:gn==="machine"?"Nothing was connected. You can ask again whenever you like.":"That machine was not attached to your account, and the terminal has been told so."}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>m("choose"),children:"Back to the start"})]})]})}function go(e){return e?.app.name??"this app"}function Xs(e){let n=e?.app.icon_urls;if(n?.length)return n;let t=e?.app.icon_url;return t?[t]:[]}function bo(e){let n=Xs(e),[t,r]=q([]),o=re(c=>{c&&r(i=>i.includes(c)?i:[...i,c])},[]),s=re(c=>o(c.currentTarget.getAttribute("src")),[o]),a=re(c=>{c?.complete&&c.naturalWidth===0&&o(c.getAttribute("src"))},[o]);return{icon:n.find(c=>!t.includes(c)),onError:s,ref:a}}function ea({context:e}){let{icon:n,onError:t,ref:r}=bo(e);return e?.app.mark==="soba"?d(j,{className:"sc-app-mark"}):n?d("img",{className:"sc-app-mark",src:n,alt:"","aria-hidden":"true",ref:r,onError:t}):null}function vt({context:e}){let{icon:n,onError:t,ref:r}=bo(e),o=e?.app.mark==="soba";return N("span",{className:"sc-app",children:[o&&d(j,{className:"sc-app-icon"}),!o&&n&&d("img",{className:"sc-app-icon",src:n,alt:"",ref:r,onError:t}),go(e)]})}function Mn({onClick:e}){return d("button",{type:"button",className:"sc-head-back",onClick:e,"aria-label":"Back",children:d("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:d("path",{d:"M15 5 8 12l7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function cr({className:e}){return d("svg",{className:e,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:d("path",{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function kt({mark:e,still:n}){return N("span",{className:"sc-waiting","aria-hidden":"true",children:[!n&&d("svg",{className:"sc-waiting-orbit",viewBox:"0 0 100 100","aria-hidden":"true",focusable:"false",children:d("circle",{className:"sc-waiting-arc",cx:"50",cy:"50",r:"46"})}),d(e,{className:"sc-waiting-mark"})]})}function ur({tone:e}){return d("span",{className:`sc-result sc-result-${e}`,"aria-hidden":"true",children:d(Vt,{kind:e==="ok"?"snap":"gone",size:84})})}function na({text:e}){return d(Ct,{children:e.split("`").map((n,t)=>t%2===1?d("code",{className:"sc-inline-code",children:n},t):n)})}function Kn({k:e,v:n}){return N("li",{className:"sc-fact",children:[d("span",{className:"sc-fact-key",children:e}),d("span",{children:n})]})}import{useEffect as ta,useRef as mr}from"react";var Nt=0,pr=null;function yo(){if(typeof document>"u")return()=>{};Nt===0&&(pr=document.body.style.overflow,document.body.style.overflow="hidden"),Nt+=1;let e=!1;return()=>{e||(e=!0,Nt-=1,Nt===0&&(document.body.style.overflow=pr??"",pr=null))}}import{jsx as wo}from"react/jsx-runtime";function jn({open:e,onClose:n,labelledBy:t,theme:r,style:o,children:s}){let a=mr(null),c=mr(null),i=mr(null);return ta(()=>{let l=a.current;if(l){if(!e){l.open&&l.close();return}return l.open||l.showModal(),document.activeElement===l&&c.current?.focus(),yo()}},[e]),wo("dialog",{ref:a,className:"soba-connect sc-modal","aria-labelledby":t,...r?{"data-theme":r}:{},style:o,onCancel:l=>{l.preventDefault(),n()},onPointerDown:l=>{i.current=l.target},onClick:l=>{l.target===l.currentTarget&&i.current===l.currentTarget&&n()},children:wo("div",{className:"sc-modal-sheet",ref:c,tabIndex:-1,children:s})})}import{useRef as sa,useState as aa}from"react";var ra={"claude-code":{small:"haiku",large:"opus"}};function vo(e){let n=ra[e];return!!(n?.small||n?.large)}var oa={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus",fable:"Fable"};function ko(e){return oa[e]??e}function fr(e){let n=[...e].sort(ft),t=Ee([...e]),r=t?De(t):null,s=[{id:"auto",kind:"auto",label:"Automatic",model:"auto",...r?.runtime?{note:`Uses ${r.runtime.display_name}`}:{}}];n.some(u=>ye(u).some(p=>vo(p.id)))&&s.push({id:"small",kind:"size",label:"Fast",note:"quick and cheap",model:"small"},{id:"large",kind:"size",label:"Best",note:"the most capable",model:"large"});let c=new Map;for(let u of n)for(let p of ye(u))for(let y of p.models){if(!y)continue;let f=`${p.id}/${y}`,m=c.get(f);if(m){m.machines.add(K(u));continue}c.set(f,{option:{id:f,kind:"named",label:ko(y),model:y,runtime:p.id,runtimeName:p.display_name,costClass:p.cost_class},machines:new Set([K(u)])})}let i=new Set;for(let{machines:u}of c.values())for(let p of u)i.add(p);let l=i.size>1;for(let{option:u,machines:p}of c.values()){let y=l&&p.size===1?[...p][0]:void 0;s.push(y?{...u,machine:y}:u)}return s}function Yn(e){let n=[],t=[];for(let r of e){if(r.kind!=="named"){n.push(r);continue}let o=r.runtimeName??r.runtime??"",s=t.find(a=>a.heading===o);s?s.options.push(r):t.push({heading:o,options:[r]})}return n.length?[{heading:null,options:n},...t]:t}function hr(e,n){let t=e.find(o=>o.kind==="auto")??{id:"auto",kind:"auto",label:"Automatic",model:"auto"};if(!n||n==="auto")return{selected:t,unavailable:null};let r=e.find(o=>o.id===n);return r?{selected:r,unavailable:null}:{selected:t,unavailable:n}}function gr(e){return e.runtime?{model:e.model,runtime:e.runtime}:{model:e.model}}function Zn(e){return e.length>1}import{jsx as xt,jsxs as Co}from"react/jsx-runtime";function br({options:e,selected:n,onPick:t,caption:r,disabled:o,className:s}){let[a,c]=aa(!1),i=sa(null);if(!Zn(e))return null;let l=s?`sc-mp ${s}`:"sc-mp";return Co("span",{className:l,children:[r&&xt("span",{className:"sc-mp-cap",children:r}),Co("button",{ref:i,type:"button",className:"sc-mp-btn","aria-haspopup":"menu","aria-expanded":a,"aria-label":`Model: ${n.label}. Change`,disabled:o,onClick:()=>c(u=>!u),children:[xt("span",{className:"sc-mp-label",children:n.label}),xt(Nn,{open:!0})]}),a&&xt(Hn,{anchor:i,label:"Which model answers",options:ia(e),current:n.id,onClose:()=>c(!1),onPick:u=>{c(!1),u&&t(u)}})]})}function ia(e){let n=[];for(let t of Yn(e))t.options.forEach((r,o)=>{let s=la(r);n.push({id:r.id,label:r.label,...s?{note:s}:{},...t.heading&&o===0?{heading:t.heading}:{},...!t.heading&&r.kind==="size"&&o===1?{rule:!0}:{}})});return n}function la(e){return e.kind!=="named"?e.note:e.machine?`on ${e.machine}`:void 0}import{useEffect as yr,useRef as ca}from"react";import{jsx as ua}from"react/jsx-runtime";var pn=8;function wr({open:e,onClose:n,anchor:t,label:r,theme:o,style:s,children:a}){let c=ca(null);return yr(()=>{let i=c.current;if(!(!i||!(typeof i.showPopover=="function")))try{e?i.showPopover():i.hidePopover()}catch{}},[e]),yr(()=>{if(!e)return;let i=()=>{let u=c.current,p=t.current;if(!u||!p)return;let y=p.getBoundingClientRect(),f=u.offsetWidth,m=u.offsetHeight,w=window.innerWidth-f-pn,M=Math.max(pn,Math.min(y.right-f,Math.max(pn,w))),R=y.bottom+pn,_=y.top-pn-m,U=R+m>window.innerHeight-pn&&_>pn?_:R;u.style.left=`${Math.round(M)}px`,u.style.top=`${Math.round(U)}px`};i();let l=requestAnimationFrame(i);return window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{cancelAnimationFrame(l),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e,t]),yr(()=>{if(!e)return;let i=u=>{u.key==="Escape"&&n()},l=u=>{let p=u.target;p&&(c.current?.contains(p)||t.current?.contains(p)||n())};return document.addEventListener("keydown",i),document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("keydown",i),document.removeEventListener("pointerdown",l,!0)}},[e,n,t]),ua("div",{ref:c,role:"dialog","aria-label":r,className:"soba-connect sc-pop",...o?{"data-theme":o}:{},popover:"manual",hidden:!e,style:s,children:a})}var Jn=new Map,Pn=new Map,No=!1;function da(){No||typeof window>"u"||(No=!0,window.addEventListener("storage",e=>{!e.key||!Jn.has(e.key)||(Pn.set(e.key,wt(e.key)),vr(e.key))}))}function vr(e){for(let n of Jn.get(e)??[])n()}function Qn(e){return e??""}function kr(e,n){let t=Qn(e);da();let r=Jn.get(t)??new Set;return r.add(n),Jn.set(t,r),()=>{r.delete(n),r.size===0&&Jn.delete(t)}}function St(e){let n=Qn(e),t=Pn.get(n);if(t!==void 0)return t;let r=e?wt(e):null;return Pn.set(n,r),r}function Cr(){return null}function Nr(e,n){St(e)===null&&(Pn.set(Qn(e),n),vr(Qn(e)))}function xr(e,n){let t=Qn(e);Pn.get(t)!==n&&(Pn.set(t,n),rr(e,n),vr(t))}function Ue(e){let n=`${e.unit}s`;return e.reward==="unlimited"?`Unlimited ${n} on your own AI`:e.reward==="included"&&e.includedUnits!==null?`${ma(e.includedUnits)} ${n} a month once you connect`:e.reward==="credit"&&e.creditMicros>0?`${pa(e.creditMicros)} back each month you stay connected`:null}function He(e){return e==="unlimited"||e==="included"}var So=new Set(["user-hardware","user-subscription"]),xo=new Set(["open-weights","frontier"]);function Se(e){return e===null||e.length===0?!1:e.every(n=>So.has(n))}var pa=e=>(e/1e6).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),ma=e=>e.toLocaleString("en-US");function Sr(e,n){if(!(n===null||n.some(s=>xo.has(s))))return!1;let r=e.findIndex(s=>So.has(s));if(r===-1)return!1;let o=e.findIndex(s=>xo.has(s));return o===-1||r<o}import{createContext as Mo,useContext as Po}from"react";var Mr=Mo(null);function Rn(){return Po(Mr)}var Pr=Mo({context:null,machines:void 0,theme:"light"});function H(){return Po(Pr)}import{useMemo as ga}from"react";import{createContext as fa,useContext as ha}from"react";var Rr=fa(null);function D(){let e=ha(Rr);if(!e)throw new Error("useSoba() must be used inside a <SobaProvider>.");return e}function Xn(){let{compute:e}=D();return ga(()=>{let n=e.machines,t=[...n].sort((s,a)=>Ee([s,a])===s?-1:1).map(ba),r=Ee([...n]),o=ln(n);return{view:t.length?"machines":e.loading?"loading":e.error?"error":"empty",machines:t,primary:r?t.find(s=>s.machine.id===r.id)??null:null,connected:e.connected,online:e.online,stalled:e.connected&&!e.online&&o?t.find(s=>s.machine.id===o.id)??null:null,loading:e.loading,error:e.error,refresh:e.refresh}},[e])}function ba(e){let n=De(e);return{machine:e,name:K(e),state:Ge(e),status:$t(e),hardware:Dn(e),lastSeen:e.state==="offline"?Un(e.last_seen_at):null,runtimes:ye(e).map(t=>({runtime:t,name:t.display_name,auth:$n(t),quarantined:!!t.quarantined})),runsOn:{by:n.by,name:n.runtime?.display_name??null}}}import{jsx as et}from"react/jsx-runtime";function ya({className:e}){let{theme:n}=H(),t=e?`soba-connect ${e}`:"soba-connect";return et("div",{className:t,"data-theme":n,children:et(_r,{})})}function _r(){let e=Xn();return e.view==="loading"?et("p",{className:"sc-note",children:"Loading\u2026"}):e.view==="error"?et("p",{className:"sc-error",children:e.error?.message}):et(Wn,{machines:e.machines.map(n=>n.machine)})}import{useCallback as tt,useEffect as Or,useMemo as xa,useRef as Ir,useState as mn}from"react";import{useId as wa}from"react";import{jsx as _n,jsxs as Mt}from"react/jsx-runtime";function nt({open:e,onOpenChange:n,initialCode:t,onConnected:r,showStatus:o,reason:s}){let{error:a}=D(),c=Rn(),i=H(),l=()=>n(!1),u=wa(),p=i.context?.background?.trim(),y=p?an(p,i.context?.accent):void 0;return Mt(jn,{open:e,onClose:l,labelledBy:u,theme:i.theme,style:y,children:[a?Mt("div",{className:"sc-card",children:[_n("h2",{className:"sc-title",id:u,children:"Could not start"}),_n("p",{className:"sc-error",children:a.message})]}):!c&&!i.context?Mt("div",{className:"sc-card",children:[_n("h2",{className:"sc-title",id:u,children:"One moment"}),_n("p",{className:"sc-note",children:"Getting your compute\u2026"})]}):_n(dr,{client:c,active:e,onClose:l,headingId:u,theme:i.theme,initialContext:i.context,...i.machines!==void 0?{initialMachines:i.machines}:{},...t?{initialCode:t}:{},...r?{onConnected:r}:{},...o===void 0?{}:{showStatus:o},...s?{reason:s}:{}}),Mt("p",{className:"sc-modal-foot",children:[_n(j,{className:"sc-foot-mark"}),"Secured by Soba"]})]})}import{useCallback as va}from"react";function ka(){let{connect:e}=D(),n=Xn(),t=va(()=>e.open("manual"),[e]);return{...Pt(n.primary?.machine??null),machine:n.primary,open:t,canOpen:e.hasModal,loading:n.view==="loading"}}function Pt(e){let n=Ge(e);return{label:e?n.word:"Connect compute",ariaLabel:e?`${n.word} on ${K(e)}`:"Connect compute",connected:e!==null,state:n}}import{useCallback as Ro,useEffect as Ca,useState as Na}from"react";function Er({enabled:e=!0,intervalMs:n=3e3}={}){let t=Rn(),[r,o]=Na(null),s=Ro(async()=>{t&&o(await t.runs())},[t]);Ca(()=>{if(!e||!t)return;let c=!0,i=Oe(async()=>{let l=await t.runs();c&&o(l)},n);return()=>{c=!1,i()}},[e,t,n]);let a=Ro(async c=>{if(!t)throw new Error("Stopping a run needs <SobaProvider>.");await t.stopRun(c),await s().catch(()=>{})},[t,s]);return{runs:r,refresh:s,stop:a}}import{Fragment as Tr,jsx as je,jsxs as rt}from"react/jsx-runtime";function fn({children:e,variant:n,className:t,initialCode:r,onConnected:o,defaultOpen:s,open:a,onOpenChange:c,showConnected:i=!0}){let{compute:l,connect:u}=D(),p=H(),{theme:y}=p,f=Rn(),[m,w]=mn(s??!!r),M=Ir(null),R=a!==void 0,_=!R&&!s&&!r&&u.hasModal,U=R?a:_?u.isOpen:m,P=v=>{_?v?u.open("manual"):u.close():R||w(v),c?.(v)},T=Ir(U);Or(()=>{T.current&&!U&&M.current?.focus(),T.current=U},[U]);let[E,S]=mn(!1),{runs:W,stop:ve}=Er({enabled:E}),X=xa(()=>E&&W?Sa(l.machines,W):l.machines,[l.machines,E,W]),ke=Ee(X),V=Pt(ke),oe=i&&V.connected,We=V.state,Y=tt(()=>S(!1),[]),[Pe,Qe]=mn(!1),ce=tt(async()=>{Qe(!0);try{await l.refresh()}finally{Qe(!1)}},[l]),ue=Ir(ce);ue.current=ce,Or(()=>{E&&ue.current()},[E]);let[ee,gn]=mn(!1),[Xe,Le]=mn([]),en=!!p.context?.hosted_available;Or(()=>{if(!E||!f||!en)return;let v=!0;return f.hosted().then(F=>{v&&Le(F.credentials)}).catch(()=>{}),()=>{v=!1}},[E,f,en]);let[de,ne]=mn(!1),[Be,pe]=mn(null),Ae=tt(async(v,F)=>{if(f){pe(null);try{await f.approveRuntime(v,F),await l.refresh()}catch(me){pe(me.message)}}},[f,l]),qe=tt(async(v,F)=>{if(f){pe(null);try{await f.preferRuntime(v,F),await l.refresh()}catch(me){pe(me.message)}}},[f,l]),se=tt(async v=>{if(f){pe(null);try{await f.disconnectHosted(v),Le((await f.hosted()).credentials)}catch(F){pe(F.message)}}},[f]),O=p.context?.background?.trim(),bn=O?an(O,p.context?.accent):void 0;return rt(Tr,{children:[je("button",{ref:M,type:"button","data-theme":y,className:["sc-btn",oe?"sc-btn-connected":"sc-btn-icon",!oe&&n==="primary"?"sc-btn-primary":"",t].filter(Boolean).join(" "),...oe&&!e?{"aria-haspopup":"dialog","aria-expanded":E,"aria-label":V.ariaLabel}:{},onClick:()=>{if(oe&&!e&&!R&&!s&&!r){S(v=>!v);return}P(!0)},children:e??(oe?rt(Tr,{children:[je("span",{className:"sc-pill-tile","aria-hidden":"true",children:je(j,{className:We.tone==="busy"?"sc-pill-mark sc-pill-mark-busy":"sc-pill-mark"})}),rt("span",{className:"sc-btn-connected-text",children:[We.word,ke&&rt("span",{className:"sc-btn-connected-where",children:[" on ",K(ke)]})]}),je("i",{className:`sc-dot sc-dot-${We.tone}`,"aria-hidden":"true"})]}):rt(Tr,{children:[je(j,{className:"sc-btn-mark"}),"Connect compute"]}))}),je(wr,{open:E,onClose:Y,anchor:M,label:"Your compute",theme:y,...bn?{style:bn}:{},children:je(un,{machines:X,hosted:Xe,onApproveRuntime:(v,F)=>void Ae(v,F),onPreferRuntime:(v,F)=>void qe(v,F),onDisconnectHosted:v=>void se(v),onRefresh:()=>void ce(),refreshing:Pe,error:Be,runs:W,runsOpen:de,onToggleRuns:()=>ne(v=>!v),onStopRun:async v=>{pe(null);try{await ve(v)}catch(F){throw pe(F.message),F}},onPair:()=>{S(!1),_?u.open("pair"):(gn(!0),P(!0))},...p.context?.app.name?{appName:p.context.app.name}:{}})}),!_&&je(nt,{open:U,onOpenChange:v=>{v||gn(!1),P(v)},...ee?{showStatus:!1}:{},...r?{initialCode:r}:{},...o?{onConnected:o}:{}})]})}function Sa(e,n){return e.map(t=>{if(t.state==="offline")return t;let r=n.filter(o=>o.machine_id===t.id).length;return{...t,active:r,state:r>0?"busy":"online"}})}import{jsx as Lr,jsxs as Pa}from"react/jsx-runtime";function Ma({initialCode:e,onConnected:n,className:t,showStatus:r=!0}){let{theme:o}=H();return Pa("div",{className:t?`soba-connect ${t}`:"soba-connect","data-theme":o,children:[r&&Lr(_r,{}),Lr("div",{className:"sc-compute-act",children:Lr(fn,{...e?{initialCode:e}:{},...n?{onConnected:n}:{}})})]})}import{useId as Ha,useState as Wa}from"react";import{useCallback as $r,useEffect as To,useState as Lo}from"react";import{useCallback as Ra,useState as _a}from"react";function ot(){let[e,n]=_a(null);return{open:Ra(()=>{n(null),Zt().then(n)},[]),launch:e,note:e==="absent"?"Nothing opened here. That machine may be a different computer, or asleep.":null}}import{useCallback as _o,useMemo as Eo}from"react";function hn(e){if(!e)return null;if(typeof e=="string")return e;if(typeof Response<"u"&&e instanceof Response)return Oo(e.status);let n=e,t=n.error;return typeof t?.code=="string"?t.code:typeof t?.type=="string"?t.type:typeof n.code=="string"?n.code:typeof n.status=="number"?Oo(n.status):n.cause&&n.cause!==e?hn(n.cause):null}function Oo(e){return e===402?"payment_required":e===409?"no_compute":null}function Ar(...e){let[n,t]=e,{plan:r,compute:o,connect:s}=D(),a=t?.predict??e.length===0,c=Oa(Ea(n),o)??(a?Ia(r,o):null),i=r.plan,l=r.plans,u=Eo(()=>{if(c!=="payment_required")return null;let m=i?.price??0,w=i?.included_units??0;return l.find(M=>M.id!==i?.id&&M.price>m&&(M.included_units===null||M.included_units>w))??null},[c,l,i]),p=_o(async()=>{if(!u)return;if(u.selectable){await r.select(u.id);return}let m=await r.checkout(u.id);window.location.assign(m)},[u,r]),y=s.open,f=_o(()=>{c&&y(c)},[y,c]);return Eo(()=>{if(!c)return null;let m=i?Ue({unit:i.unit,reward:i.connected_reward,includedUnits:i.connected_included_units,creditMicros:i.connected_credit*1e6}):null,w=i&&He(i.connected_reward)?m:null;return{reason:c,...Ta(c,{connectOffer:w,connected:o.connected,online:o.online,machine:ln(o.machines)?.label??null,unit:i?.unit??"message",interval:i?.interval??"month",upgrade:u!==null,resets:r.current?.period_end??null}),connectOffer:w,upgradeTo:u,connect:f,upgrade:p}},[c,i,o,u,f,p,r.current?.period_end])}function Ea(e){let n=hn(e);return n==="payment_required"||n==="no_compute"?n:null}function Oa(e,n){return e==="no_compute"&&n.connected&&n.online?null:e}function Ia(e,n){let t=e.plan;return!t||n.loading?null:Se(t.route_allow)&&!n.online?"no_compute":e.remaining===0&&t.overage==="stop"?"payment_required":null}function Ta(e,n){if(e==="payment_required"){let t=`No ${n.unit}s left this ${n.interval}`;return n.connectOffer&&!n.connected?{title:t,body:`${n.connectOffer}. Connecting takes a minute and costs nothing.`}:n.connectOffer&&!n.online?{title:t,body:`${n.connectOffer}. Waking ${n.machine??"your machine"} is enough.`}:n.upgrade?{title:t,body:n.resets?`A larger plan carries on now. This one comes back on ${Io(n.resets)}.`:"A larger plan carries on now, or wait for this one to renew."}:{title:t,body:n.resets?`Your allowance comes back on ${Io(n.resets)}.`:"Your allowance comes back at the start of the next period."}}return n.connected&&!n.online?{title:`${n.machine??"Your machine"} can't be reached`,body:"This run needs it awake and connected. Open Soba App on that machine, or connect another one."}:{title:"Nothing connected yet",body:"This app runs on AI you already pay for, on a machine of your own. Connect one and this run has somewhere to go."}}function Io(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}function La(e){let{plan:n,allowance:t,connected:r,online:o,quiet:s,error:a,predict:c,at:i,waved:l}=e;if(!n)return null;let u=e.allow!==void 0?e.allow:n.route_allow;if(r){if(o)return null;let w=Se(u);return{reason:"stalled",title:`${s??"Your machine"} can\u2019t be reached`,detail:w?"The Soba app there has stopped reporting in, so runs have nowhere to go until it is back.":"The Soba app there has stopped reporting in, so nothing will run on your own AI until it is back.",meter:null,dismissible:!1,atTheWall:!1,ownCompute:w}}let p=hn(a),y=p==="payment_required"||p==="no_compute",f=n.ask_to_connect!==!1&&Sr(n.route_prefer,u);if(!c&&!y&&!f)return null;let m=Se(u)?Aa(n.unit,Se(n.route_allow)):He(n.connected_reward)?Da(t,n,i):f?$a(n.unit):null;return!m||m.dismissible&&l?null:{...m,dismissible:!!m.dismissible,ownCompute:!1,atTheWall:!m.dismissible&&(!c||m.meter!==null&&m.meter.left===0)}}function Dr(e={}){let{at:n=.25,error:t,allow:r}=e,o=e.predict??!(e.errorGiven??t!==void 0),{plan:s,compute:a,connect:c}=D(),i=or(c.publishableKey),[l,u]=Lo(!1);To(()=>{u(sr(i))},[i]);let p=$r(()=>{u(!0),ar(i)},[i]),y=$r(()=>c.open("manual"),[c]),f=$r(()=>c.open("no_compute"),[c]),m=ot(),[w,M]=Lo(!1),{refresh:R}=a,{launch:_}=m;To(()=>{if(_===null||_==="absent")return;M(!1);let S=setInterval(()=>void R(),3e3),W=setTimeout(()=>{clearInterval(S),M(!0)},2e4);return()=>{clearInterval(S),clearTimeout(W)}},[_,R]);let U=Ua(c.app?.name,Gn(c.connectUrl)),P=s.loading||a.loading,T=ln(a.machines),E=P?null:La({plan:s.plan,allowance:{remaining:s.remaining,included:s.included},connected:a.connected,online:a.online,quiet:T?K(T):null,error:t,predict:o,...r!==void 0?{allow:r}:{},at:n,waved:l});return{reason:E?.reason??null,visible:E!==null,title:E?.title??null,detail:E?.detail??null,meter:E?.meter??null,dismissible:E?.dismissible??!1,dismissed:l,dismiss:p,open:y,atTheWall:E?.atTheWall??!1,steps:U,stalled:E?.reason==="stalled"?{machine:T?K(T):null,ownCompute:E.ownCompute,wake:m.open,launch:m.launch,note:m.note,stuck:w,connectAnother:f}:null,loading:P}}function Aa(e,n){return{reason:"needed",title:n?"This plan runs on your own AI.":`These ${e}s run on your own AI.`,detail:`Connect a machine and your ${e}s run there, free, on access you already have.`,meter:null}}function $a(e){return{reason:"preferred",title:"This plan prefers your own AI.",detail:`Connect a machine and your ${e}s run there instead, on access you already have.`,meter:null,dismissible:!0}}function Da(e,n,t){let{remaining:r,included:o}=e;if(r===null||o===null||o===0||r>Math.ceil(o*t))return null;let s=Ue({unit:n.unit,reward:n.connected_reward,includedUnits:n.connected_included_units,creditMicros:n.connected_credit*1e6});return s?{reason:"running",title:r===0?`No ${n.unit}s left this month.`:`${r} ${n.unit}${r===1?"":"s"} left this month.`,detail:`${s}.`,meter:{left:r,of:o}}:null}function Ua(e,n){return[{lead:"Download Soba App",detail:"",...n?{linksLead:"Get it for"}:{},links:n?Fn.map(t=>({label:t.label,href:`${n}/download/${t.slug}`})):[]},{lead:"Connect compute",detail:"Press this, then approve the pairing when the app asks.",opens:!0,links:[]},{lead:"Let your AIs serve",detail:`It finds what is installed on that machine. Allow one, and ${e??"this app"} sends every run there.`,linksLead:"Nothing on it yet?",links:ie.map(t=>({label:t.short,href:t.install}))}]}import{Fragment as $o,jsx as L,jsxs as Ye}from"react/jsx-runtime";function Ba(e){let{className:n,fallback:t=null}=e,r=Dr({...e.at===void 0?{}:{at:e.at},...e.predict===void 0?{}:{predict:e.predict},...e.allow===void 0?{}:{allow:e.allow},error:e.error,errorGiven:"error"in e}),{connect:o}=D(),{theme:s}=H(),[a,c]=Wa(null),i=Ha(),l=L($o,{children:t});if(!r.visible)return l;if(r.stalled)return L(Ao,{className:n,theme:s,stalled:!0,children:L(qa,{title:r.title??"",detail:r.detail??"",stalled:r.stalled})});let u=a??r.atTheWall;return Ye(Ao,{className:n,theme:s,children:[Ye("div",{className:"sc-nudge-top",children:[Ye("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:r.title}),L("p",{className:"sc-nudge-detail",children:r.detail}),Ye("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more","aria-expanded":u,"aria-controls":i,onClick:()=>c(!u),children:[u?"Hide the details":"How it works",L(Ga,{})]})]}),r.dismissible?L("button",{type:"button",className:"sc-nudge-dismiss","aria-label":"Dismiss",title:"Dismiss",onClick:r.dismiss,children:L(Fa,{})}):null]}),u?L("ol",{className:"sc-nudge-steps",id:i,children:r.steps.map(p=>Ye("li",{children:[p.opens?L("button",{type:"button",className:"sc-step-lead",onClick:()=>o.open("manual"),children:p.lead}):L("strong",{children:p.lead}),p.detail?L("span",{children:p.detail}):null,p.links.length>0?Ye("span",{className:"sc-step-links",children:[p.linksLead,p.links.map(y=>L("a",{href:y.href,target:"_blank",rel:"noreferrer noopener",children:y.label},y.href))]}):null]},p.lead))}):null,L(fn,{variant:"primary"})]})}function Ao({className:e,theme:n,stalled:t,children:r}){return L("div",{className:e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill","data-theme":n,children:L("div",{className:t?"sc-nudge sc-nudge-stalled":"sc-nudge",children:r})})}function qa({title:e,detail:n,stalled:t}){return Ye($o,{children:[L("div",{className:"sc-nudge-top",children:Ye("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:e}),L("p",{className:"sc-nudge-detail",children:n}),t.note&&L("p",{className:"sc-nudge-note",children:t.note}),t.stuck&&L("p",{className:"sc-nudge-note",children:"The Soba app is open, but this machine still isn\u2019t reporting in. It may no longer be connected to this app."}),(t.launch==="absent"||t.stuck)&&L("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more",onClick:t.connectAnother,children:t.stuck?"Connect it again":"Connect another machine"})]})}),L("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:t.wake,children:"Open Soba App"})]})}function Fa(){return L("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-x",children:L("path",{d:"m4.8 4.8 6.4 6.4M11.2 4.8l-6.4 6.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function Ga(){return L("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-chev",children:L("path",{d:"M4.5 6.5 8 10l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}var za=new Set(["delta","thinking","status","done","error"]);function En(e){let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!="object")return null;let t=n,r=t.type==="event"?t.event:t;if(!r||typeof r!="object")return null;let o=r;if(typeof o.type!="string"||!za.has(o.type))return null;let s={type:o.type};return typeof o.text=="string"&&(s.text=o.text),typeof o.message=="string"&&(s.message=o.message),typeof o.tool=="string"&&(s.tool=o.tool),typeof o.tier=="string"&&(s.tier=o.tier),o.usage&&typeof o.usage=="object"&&(s.usage=o.usage),typeof o.session=="string"&&(s.session=o.session),typeof o.toolInput=="string"&&(s.toolInput=o.toolInput),o.git&&typeof o.git=="object"&&(s.git=o.git),o.turn&&typeof o.turn=="object"&&typeof o.turn.text=="string"&&(s.turn={text:o.turn.text}),typeof o.reason=="string"&&(s.reason=o.reason),typeof o.retryable=="boolean"&&(s.retryable=o.retryable),(o.state==="interrupted"||o.state==="resumed")&&(s.state=o.state),s}async function*Ur(e){let n=e.body;if(!n)throw new Error("That run response had no body to stream.");let t=(e.headers.get("content-type")??"").includes("ndjson"),r=n.getReader(),o=new TextDecoder,s="",a=[];try{for(;;){let i=await r.read();if(i.done)break;for(s+=o.decode(i.value,{stream:!0});;){let l=s.indexOf(`
3
- `);if(l===-1)break;let u=Uo(s.slice(0,l));if(s=s.slice(l+1),t){let p=u.trim()?En(u):null;p&&(yield p);continue}if(u===""){let p=a.join(`
4
- `);if(a=[],p==="[DONE]")return;let y=p?En(p):null;y&&(yield y);continue}Do(u,a)}}!t&&s&&Do(Uo(s),a);let c=t?s.trim():a.join(`
5
- `);if(c&&c!=="[DONE]"){let i=En(c);i&&(yield i)}}finally{r.cancel().catch(()=>{})}}function Do(e,n){if(!e||e.startsWith(":"))return;let t=e.indexOf(":");if(t===-1||e.slice(0,t)!=="data")return;let r=e.slice(t+1);n.push(r.startsWith(" ")?r.slice(1):r)}function Uo(e){return e.endsWith("\r")?e.slice(0,-1):e}async function Va(e){let n="";for await(let t of e)if(t.type==="delta"&&t.text&&(n+=t.text),t.type==="error")throw new Error(t.message??"The run ended with an error.");return n}import{useCallback as Hr,useEffect as Ka,useMemo as Wr,useSyncExternalStore as ja}from"react";function Br(e={}){let{compute:n,connect:t}=D(),{value:r,onChange:o,defaultValue:s,remember:a=!0,user:c}=e,i=r!==void 0,l=a&&!i?tr(t.publishableKey,c):null,u=Hr(_=>kr(l,_),[l]),p=ja(u,Hr(()=>St(l),[l]),Cr),y=Wr(()=>fr(n.machines),[n.machines]),f=Wr(()=>Yn(y),[y]);Ka(()=>{i||!s||Nr(l,s)},[i,s,l]);let m=i?r:p??s??null,{selected:w,unavailable:M}=Wr(()=>hr(y,m??null),[y,m]),R=Hr(_=>{i||xr(l,_),o?.(_)},[i,l,o]);return{options:y,groups:f,selected:w,select:R,run:gr(w),unavailable:M,pickable:Zn(y),loading:n.loading&&!n.machines.length}}import{jsx as Ho}from"react/jsx-runtime";function Ya({caption:e,disabled:n,className:t,...r}){let{theme:o}=H(),{options:s,selected:a,select:c,pickable:i}=Br(r);return i?Ho("span",{className:"soba-connect sc-inline","data-theme":o,children:Ho(br,{options:s,selected:a,onPick:c,...e?{caption:e}:{},...n?{disabled:n}:{},...t?{className:t}:{}})}):null}import{useEffect as Za}from"react";var Wo="data-soba-react",Bo=!1;function st(){if(Bo||typeof document>"u"||(Bo=!0,document.querySelector(`style[${Wo}]`)))return;let e=document.createElement("style");e.setAttribute(Wo,""),e.textContent=`.soba-connect {
2
+ var fs={"claude-code":{small:"haiku",large:"opus"}};function vt(e){let n=fs[e];return!!(n?.small||n?.large)}import{useEffect as Os,useRef as Ls,useState as Pt}from"react";var xn=class extends Error{status;constructor(n,t){super(n),this.name="ConnectError",this.status=t}},gs=5*6e4,Dn=class{session;baseUrl;doFetch;lastMachines=null;machinesUrl=null;gatewayBackUntil=0;constructor(n){this.session=n.session,this.baseUrl=(n.baseUrl??"").replace(/\/+$/,""),this.doFetch=n.fetchImpl??fetch.bind(globalThis)}async context(){let n=await this.request("GET","/v1/connect");return this.setMachinesUrl(n.machines_url),n}setMachinesUrl(n){typeof n=="string"&&/^https?:\/\//.test(n)&&(this.machinesUrl=n)}async machines(){let n=this.lastMachines,t=n?`?v=${encodeURIComponent(n.version)}`:"",r;if(this.machinesUrl&&Date.now()>=this.gatewayBackUntil)try{r=await this.request("GET",`${this.machinesUrl}${t}`)}catch(a){if(a instanceof xn&&a.status===401)throw a;this.gatewayBackUntil=Date.now()+gs}if(r??=await this.request("GET",`/v1/machines${t}`),r.unchanged&&n)return n.machines;let o=Array.isArray(r.machines)?r.machines:[];return this.lastMachines=typeof r.version=="string"?{version:r.version,machines:o}:null,o}async runs(){let n=await this.request("GET","/v1/machines/runs");return Array.isArray(n.runs)?n.runs:[]}async stopRun(n){let t=this.machinesUrl?.replace(/\/v1\/machines$/,"");if(!t)throw new xn("This page can't stop runs yet: it hasn't been told where Soba's gateway is.",501);await this.request("POST",`${t}/v1/runs/${encodeURIComponent(n)}/stop`,{})}lookup(n){return this.request("GET",`/v1/device/lookup?code=${encodeURIComponent(n)}`)}approve(n){return this.request("POST","/v1/device/approve",{user_code:n})}claim(n){return this.request("POST","/v1/device/claim",{pairing_nonce:n})}deny(n){return this.request("POST","/v1/device/deny",{user_code:n})}plans(){return this.request("GET","/v1/plans")}selectPlan(n){return this.request("POST","/v1/plans/select",{plan:n})}checkoutPlan(n,t){return this.request("POST","/v1/plans/checkout",{plan:n,...t?.successUrl?{success_url:t.successUrl}:{},...t?.cancelUrl?{cancel_url:t.cancelUrl}:{}})}leavePlan(){return this.request("DELETE","/v1/plans/select")}hosted(){return this.request("GET","/v1/hosted")}startHosted(){return this.request("POST","/v1/hosted/start")}disconnectHosted(n){return this.request("DELETE",n?`/v1/hosted?provider=${encodeURIComponent(n)}`:"/v1/hosted")}approveRuntime(n,t){return this.request("POST","/v1/runtimes/approve",{machine_id:n,runtime_id:t})}preferRuntime(n,t){return this.request("POST","/v1/runtimes/prefer",{machine_id:n,runtime_id:t})}async request(n,t,r){let o=await this.doFetch(/^https?:\/\//.test(t)?t:`${this.baseUrl}${t}`,{method:n,headers:{authorization:`Bearer ${this.session}`,...r?{"content-type":"application/json"}:{}},...r?{body:JSON.stringify(r)}:{}}),a={};try{a=await o.json()}catch{}if(!o.ok){let s=typeof a.error=="string"?a.error:`Request failed (${o.status})`;throw new xn(s,o.status)}return a}};function Un(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return"#ffffff";let t=n[1].length===3?[...n[1]].map(a=>a+a).join(""):n[1],r=a=>{let s=Number.parseInt(t.slice(a*2,a*2+2),16)/255;return s<=.04045?s/12.92:((s+.055)/1.055)**2.4};return .2126*r(0)+.7152*r(1)+.0722*r(2)>.45?"#101012":"#ffffff"}function Jt(e){let n=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!n?.[1])return null;let t=n[1].length===3?[...n[1]].map(r=>r+r).join(""):n[1];return[0,1,2].map(r=>Number.parseInt(t.slice(r*2,r*2+2),16))}function Nn(e,n,t){let r=Jt(e),o=Jt(n);return!r||!o?e:`#${r.map((s,c)=>Math.round(s+(o[c]-s)*t)).map(s=>s.toString(16).padStart(2,"0")).join("")}`}function cn(e,n){if(!Jt(e))return{};let t=Un(e),r=n?.trim();return{"--sc-ground":e,"--sc-shell":e,"--sc-sheet":Nn(e,t,.07),"--sc-raised":Nn(e,t,.13),"--sc-line":Nn(e,t,.18),"--sc-line-2":Nn(e,t,.28),"--sc-text":t,"--sc-text-2":Nn(t,e,.15),"--sc-muted":Nn(t,e,.38),...r?{"--sc-accent":r,"--sc-accent-fg":Un(r)}:{"--sc-accent":t,"--sc-accent-fg":e}}}function qe(e){return e.authenticated===!0?{tone:"ok",text:"signed in"}:e.authenticated===!1?{tone:"warn",text:e.auth_hint??"signed out on that machine"}:{tone:"unknown",text:"could not tell"}}function Fn(e){let{platform:n,arch:t}=e;if(!n)return null;let r=n==="darwin"||n==="macos",o=r?"Mac":n==="win32"||n==="windows"?"Windows PC":"Linux machine";return r?`${t==="aarch64"||t==="arm64"?"Apple silicon ":""}${o}`:o}function un(e){return e.find(n=>n.state==="offline")??null}function Yt(e){return e.state==="busy"?{tone:"busy",text:`serving ${e.active} of ${e.capacity}`}:e.state==="online"?{tone:"ok",text:"connected"}:{tone:"off",text:"asleep or offline"}}function _(e){let n=e.label?.trim(),t=e.name?.trim();return n&&(!t||n!==t)?n:(t??n??"").replace(/\.(local|lan|home|internal)$/i,"").replace(/[-_]+/g," ").trim()||n||"This machine"}function kt(e,n){let t=o=>o.state==="busy"?0:o.state==="online"?1:2,r=o=>o.last_seen_at?Date.parse(o.last_seen_at):0;return t(e)-t(n)||r(n)-r(e)}function We(e){return[...e].sort(kt)[0]??null}function dn(e){return e?e.state==="busy"?{tone:"busy",word:"Serving"}:e.state==="online"?{tone:"ok",word:"Connected"}:{tone:"off",word:"Asleep"}:{tone:"off",word:"No compute"}}function Mn(e){let n=dn(e);return{label:e?n.word:"Connect compute",ariaLabel:e?`${n.word} on ${_(e)}`:"Connect compute",connected:e!==null,state:n}}function Qn(e){return e.state==="online"||e.state==="busy"}function Vn(e){if(!e)return"never seen";let n=Date.parse(e);if(Number.isNaN(n))return"never seen";let t=Date.now()-n,r=6e4;return t<2*r?"just now":t<60*r?`${Math.floor(t/r)} min ago`:t<24*60*r?`${Math.floor(t/(60*r))} hr ago`:`${Math.floor(t/(24*60*r))} days ago`}function jt(e){return e.runtimes.filter(n=>n.id!=="shell")}function Ne(e){return e.runtimes.filter(n=>n.id!=="shell"&&!n.quarantined&&!n.absent)}function He(e){let n=s=>s?e.runtimes.find(c=>c.id===s)??null:null;if(e.requested_runtime)return{by:"app",runtimeId:e.requested_runtime,runtime:n(e.requested_runtime)};let t=Ne(e),r=t.find(s=>s.id===e.preferred_runtime);if(r)return{by:"you",runtimeId:r.id,runtime:r};let o=s=>s.id==="claude-code"?0:s.id==="codex"?1:2,a=[...t].sort((s,c)=>o(s)-o(c))[0]??null;return{by:"default",runtimeId:a?.id??null,runtime:a}}var zt="soba";function Jn(){return`${zt}://show`}function Yn(e,n,t){let r=`${zt}://connect?url=${encodeURIComponent(e)}`;return n&&(r+=`&nonce=${encodeURIComponent(n)}`),t&&(r+=`&want=${encodeURIComponent(t)}`),r}function jn(){let e=globalThis.crypto;if(!e?.getRandomValues)return null;let n=e.getRandomValues(new Uint8Array(32)),t="";for(let r of n)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var As=1600;function qt(e={}){return Xt(e)}async function Zt(e,n={}){if(typeof window>"u"||typeof document>"u")return"unknown";let t=Xt(n);try{window.location.href=Yn(e,n.nonce,n.want)}catch{return"absent"}return t}async function zn(e={}){if(typeof window>"u"||typeof document>"u")return"unknown";let n=Xt(e);try{window.location.href=Jn()}catch{return"absent"}return n}async function Xt(e){if(typeof window>"u"||typeof document>"u")return"unknown";let n=e.graceMs??As,t=document.visibilityState==="visible"&&document.hasFocus(),r=!1,o=()=>{r=!0},a=()=>{document.visibilityState==="hidden"&&(r=!0)};return window.addEventListener("blur",o),window.addEventListener("pagehide",o),document.addEventListener("visibilitychange",a),await new Promise(s=>setTimeout(s,n)),window.removeEventListener("blur",o),window.removeEventListener("pagehide",o),document.removeEventListener("visibilitychange",a),t?r?"opened":"absent":"unknown"}var co={"claude-code":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXH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YgzGcTQWguIgdoz8sWQSMR3A0hMCPb5owh4whw+YR7MJ6ktMo+EciiobYAFJqDE4zPhtDRKVwF5DSuQcnOKR2AP8Cui93e4Bz9uMXV0/FBGGZ/BaqmGMFGWMFNw7QyOZML4XaHNc3OnIDZkE7cOUzf5QfCGN8C6GkgqwSeXP8HIxHP4MmOI/a321n07gV9IjNBy7QnyZrED37ivv4/PQyO8w10e8KcphEWKSNuIPY8QfKrR4Ye+yCnB3kPeGZiJkLwBzq+EZK2GxGe7nRW12PSGeADM/EmtjG4qej4OQ90YuRN/rYcWzMU8ZPuWbyCHPgbYT3vQ4Pp0/OM7QYx6VGXgMbdGN/AVNIT3cAadkl50K7+QtmgFGBskwuuGBL+EfnaxNQFH3ihDqM12j6lTyyVn4H4E6hAx4NkYwy1G0DlAmsUN8ESX6/+H/GpiUBv4FSyLhydRRp0cAAAAASUVORK5CYII="};import{useEffect as uo,useRef as bs}from"react";import{Fragment as Cs,jsx as Oe,jsxs as Kt}from"react/jsx-runtime";function qn({anchor:e,label:n,options:t,current:r,onClose:o,onPick:a}){let s=bs(null);return uo(()=>{let i=s.current,l=e.current;if(!i||!l)return;try{typeof i.showPopover=="function"&&i.showPopover()}catch{}let u=l.getBoundingClientRect();u.width>i.offsetWidth&&(i.style.width=`${Math.round(u.width)}px`);let m=i.offsetWidth,b=i.offsetHeight,g=u.width>248?u.left:u.right-m,h=Math.max(8,Math.min(g,window.innerWidth-m-8)),y=u.bottom+6,N=y+b>window.innerHeight-8&&u.top-6-b>8?u.top-6-b:y;i.style.left=`${Math.round(h)}px`,i.style.top=`${Math.round(N)}px`,i.querySelector('[aria-checked="true"]')?.focus()},[e]),uo(()=>{let i=l=>{let u=l.target;!u||s.current?.contains(u)||e.current?.contains(u)||o()};return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[e,o]),Oe("div",{ref:s,role:"menu","aria-label":n,className:"sc-menu",popover:"manual",onKeyDown:i=>{let l=[...s.current?.querySelectorAll("[role=menuitemradio]")??[]],u=l.indexOf(document.activeElement);if(i.key==="Escape")i.stopPropagation(),i.nativeEvent.stopImmediatePropagation(),o(),e.current?.focus();else if(i.key==="ArrowDown"||i.key==="ArrowUp"){i.preventDefault();let m=i.key==="ArrowDown"?1:-1;l[(u+m+l.length)%l.length]?.focus()}else i.key==="Tab"&&o()},children:t.map(i=>Oe(ys,{option:i,checked:r===i.id,onClose:o,onPick:a},i.id??""))})}function ys({option:e,checked:n,onClose:t,onPick:r}){return Kt(Cs,{children:[e.heading?Oe("div",{className:"sc-menu-head",role:"presentation",children:e.heading}):e.rule?Oe("div",{className:"sc-menu-sep"}):null,Kt("button",{type:"button",role:"menuitemradio","aria-checked":n,className:"sc-menu-item",onClick:()=>n?t():r(e.id),children:[e.glyph,Kt("span",{className:"sc-menu-text",children:[Oe("span",{className:"sc-menu-label",children:e.label}),e.note&&Oe("span",{className:"sc-menu-note",children:e.note})]}),n&&Oe(ws,{})]})]})}function ws(){return Oe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-menu-check",children:Oe("path",{d:"M5 12.5l4.5 4.5L19 7.5",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Sn({open:e}){return Oe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-chev sc-chev-open":"sc-chev",children:Oe("path",{d:"M9 6l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{useRef as ks,useState as Ns}from"react";var vs={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus",fable:"Fable"};function pn(e){return vs[e]??e}function Zn(e){let n=[...e].sort(kt),t=We([...e]),r=t?He(t):null,a=[{id:"auto",kind:"auto",label:"Automatic",model:"auto",...r?.runtime?{note:r.runtime.default_model?`Uses ${pn(r.runtime.default_model)}`:`Uses ${r.runtime.display_name}`}:{}}];n.some(u=>Ne(u).some(m=>vt(m.id)))&&a.push({id:"small",kind:"size",label:"Fast",note:"quick and cheap",model:"small"},{id:"large",kind:"size",label:"Best",note:"the most capable",model:"large"});let c=new Map;for(let u of n)for(let m of Ne(u))for(let b of m.models){if(!b)continue;let g=`${m.id}/${b}`,h=c.get(g);if(h){h.machines.add(_(u));continue}c.set(g,{option:{id:g,kind:"named",label:pn(b),model:b,runtime:m.id,runtimeName:m.display_name,costClass:m.cost_class},machines:new Set([_(u)])})}let i=new Set;for(let{machines:u}of c.values())for(let m of u)i.add(m);let l=i.size>1;for(let{option:u,machines:m}of c.values()){let b=l&&m.size===1?[...m][0]:void 0;a.push(b?{...u,machine:b}:u)}return a}function Xn(e){let n=[],t=[];for(let r of e){if(r.kind!=="named"){n.push(r);continue}let o=r.runtimeName??r.runtime??"",a=t.find(s=>s.heading===o);a?a.options.push(r):t.push({heading:o,options:[r]})}return n.length?[{heading:null,options:n},...t]:t}function _t(e,n){let t=e.find(o=>o.kind==="auto")??{id:"auto",kind:"auto",label:"Automatic",model:"auto"};if(!n||n==="auto")return{selected:t,unavailable:null};let r=e.find(o=>o.id===n);return r?{selected:r,unavailable:null}:{selected:t,unavailable:n}}function $t(e){return e.runtime?{model:e.model,runtime:e.runtime}:{model:e.model}}function mn(e){return e.length>1}import{jsx as Nt,jsxs as po}from"react/jsx-runtime";function Kn({options:e,selected:n,onPick:t,caption:r,disabled:o,className:a}){let[s,c]=Ns(!1),i=ks(null);if(!mn(e))return null;let l=a?`sc-mp ${a}`:"sc-mp";return po("span",{className:l,children:[r&&Nt("span",{className:"sc-mp-cap",children:r}),po("button",{ref:i,type:"button",className:"sc-mp-btn","aria-haspopup":"menu","aria-expanded":s,"aria-label":`Model: ${n.label}. Change`,disabled:o,onClick:()=>c(u=>!u),children:[Nt("span",{className:"sc-mp-label",children:n.label}),Nt(Sn,{open:!0})]}),s&&Nt(qn,{anchor:i,label:"Which model answers",options:xs(e),current:n.id,onClose:()=>c(!1),onPick:u=>{c(!1),u&&t(u)}})]})}function xs(e){let n=[];for(let t of Xn(e))t.options.forEach((r,o)=>{let a=Ms(r);n.push({id:r.id,label:r.label,...a?{note:a}:{},...t.heading&&o===0?{heading:t.heading}:{},...!t.heading&&r.kind==="size"&&o===1?{rule:!0}:{}})});return n}function Ms(e){return e.kind!=="named"?e.note:e.machine?`on ${e.machine}`:void 0}import{jsx as xe,jsxs as Ps}from"react/jsx-runtime";function q({className:e}){return Ps("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:[xe("path",{d:"M18.125 7.039A8.6 8.6 0 1 0 18.125 16.961A6 6 0 0 1 18.125 7.039Z",fill:"currentColor"}),xe("path",{d:"M19.925 7.039A8.6 8.6 0 0 1 19.925 16.961A6 6 0 0 0 19.925 7.039Z",fill:"currentColor"})]})}function mo({className:e}){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:xe("path",{fill:"currentColor",d:"M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"})})}function hn({className:e}){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:xe("path",{fill:"currentColor",d:"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"})})}function xt({className:e}){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:xe("path",{d:"M4 5h16v11H4zM9 20h6M12 16v4",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ss({className:e}){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:xe("path",{d:"M5 7l5 5-5 5M12 18h7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function er({className:e}){return xe("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e,children:xe("path",{d:"M5 6h14v10H5zM2.5 19.5h19",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}var Ze={claude:mo,chatgpt:hn,local:xt},ho={shell:Ss};function go(e,n){return n<2*6e4?e:n<10*6e4?Math.max(e,6e4):n<30*6e4?Math.max(e,3*6e4):Math.max(e,10*6e4)}var Rs=3e3,Es=2*6e4,Mt=Date.now(),St=new Set,fo=!1;function Is(){if(fo||typeof window>"u")return;fo=!0;let e=()=>{let t=Mt;if(Mt=Date.now(),Mt-t>Es)for(let r of St)r()};for(let t of["pointerdown","keydown","wheel","touchstart"])window.addEventListener(t,e,{capture:!0,passive:!0});let n=()=>{if(!document.hidden)for(let t of St)t()};window.addEventListener("focus",n),document.addEventListener("visibilitychange",n)}function Me(e,n,t={}){Is();let r,o=t.immediate===!1?Date.now():0,a=!1,s=!1,c=()=>{s||(r=setTimeout(i,t.idle===!1?n:go(n,Date.now()-Mt)))},i=async()=>{if(clearTimeout(r),!(s||a)){if(typeof document>"u"||!document.hidden){a=!0,o=Date.now();try{await e()}catch{}finally{a=!1}}c()}},l=()=>{Date.now()-o>Math.min(n,Rs)&&i()};return St.add(l),t.immediate===!1?c():i(),()=>{s=!0,clearTimeout(r),St.delete(l)}}var Ae=[{id:"claude",costClass:"user-subscription",short:"Claude Code",label:"Continue with Claude",title:"The Claude plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Claude Code installed and signed in",hint:"Install it from claude.ai/code, then run `claude` once and sign in.",install:"https://claude.com/product/claude-code",expects:["claude-code"]},{id:"chatgpt",costClass:"user-subscription",short:"Codex",label:"Continue with ChatGPT",title:"The ChatGPT plan you already pay for",cost:"Nothing beyond the plan",prerequisite:"Codex installed and signed in",hint:"Install Codex, then run `codex` once and sign in.",install:"https://learn.chatgpt.com/codex/cli",expects:["codex"]},{id:"local",costClass:"user-hardware",short:"Local models",label:"Use a model on this machine",title:"A model on your own machine",cost:"Free. You bought the hardware",prerequisite:"Ollama running, with a model pulled",hint:"Install Ollama, then `ollama pull` a model before pairing.",install:"https://ollama.com",expects:["ollama","openai-api"]}],Ao=["claude","chatgpt"];function nr(){return Ae.filter(e=>Ao.includes(e.id))}function tr(e){return Ae.filter(n=>n.costClass===e)}function rr(e){return Ae.find(n=>n.expects.includes(e))??null}import{Fragment as _n,jsx as d,jsxs as C}from"react/jsx-runtime";function fn({machines:e,hosted:n=[],onApproveRuntime:t,onPreferRuntime:r,onDisconnectHosted:o,onPair:a,onWake:s,onOpenApp:c,onRefresh:i,refreshing:l,busy:u,appName:m,model:b,onPickModel:g,error:h,runs:y,loadRuns:N,loading:P,machineMenu:R,machineNote:W,openApp:E=!0,children:I,onStopRun:O}){let k=We(e),U=e.filter(T=>T.id!==k?.id),[pe,ne]=Pt(null),[ae,Z]=Pt("no"),me=y===void 0&&!!N,Ye=me?pe:y??null,$=y!==void 0||!!N;Os(()=>{if(!me||!N)return;let T=!0,le=Me(async()=>{let Re=await N();T&&ne(Re)},3e3);return()=>{T=!1,le()}},[me,N]);let Se=(k?jt(k):[]).filter(T=>T.quarantined&&!T.absent),X=k?He(k).runtime:null,ie=X?.cost_class==="user-hardware"?X:null,z=ie?Xs(ie.default_model):null,Pe=!!k&&!Qn(k),he=(()=>{if(!k||Pe||!X||qe(X).tone!=="warn")return null;let le=_(k);return{title:`${X.display_name} is signed out`,detail:`Sign in on ${le} so Soba can start runs.`}})(),fe=!k||!Pe?null:k.pairing_lost?{title:"Not connected to Soba",detail:`Connect ${_(k)} to start receiving runs from your apps.`}:{title:"Soba is asleep",detail:"It is not taking new runs. Wake it to start receiving runs from your apps again."},V={label:ae==="going"?"Opening Soba\u2026":"Open Soba",onPress:()=>{c?.(),Z("going"),zn().then(T=>Z(T==="absent"?"absent":"no"))},spin:ae==="going"},J=k?Pe&&s?{label:"Wake Soba",onPress:s}:V:a?{label:"Connect to Soba",onPress:a}:null,te=k&&Pe&&s?V:null;return!k&&n.length===0&&!a?d("p",{className:"sc-note",children:"Nothing connected yet."}):C("div",{className:"sc-tray",children:[k&&C(De,{title:"This machine",action:(i||E||R)&&C("span",{className:"sc-cap-acts",children:[i&&d("button",{type:"button",className:"sc-disc",onClick:i,disabled:l,"aria-label":"Refresh",title:"Refresh",children:d(ea,{spinning:!!l})}),E&&d(Vs,{}),R]}),children:[d(Ts,{machine:k}),W]}),k&&d(De,{title:"Runs on",children:X?d(zs,{machine:k,appName:m,busy:u,...b?{model:b}:{},...g?{onPickModel:g}:{},...r?{onPick:T=>r(k.id,T)}:{}}):C("div",{className:"sc-blank",children:[d("span",{className:"sc-blank-mark","aria-hidden":"true",children:d(Ws,{})}),C("span",{className:"sc-blank-say",children:[d("span",{className:"sc-blank-title",children:P?"Looking\u2026":"No agent on this machine"}),d("span",{className:"sc-blank-body",children:P?"Reading what it can run.":"Install Claude Code, Codex or Ollama there and it will appear here."})]}),!P&&E&&C("a",{className:"sc-blank-act",href:Jn(),children:[d("span",{children:"Add agents"}),d(Co,{})]})]})}),k&&(he||z)&&C(De,{title:"Needs attention",children:[he&&C("div",{className:"sc-alarm",children:[d("span",{className:"sc-alarm-mark","aria-hidden":"true",children:d(yo,{})}),C("span",{className:"sc-alarm-say",children:[d("span",{className:"sc-alarm-title",children:he.title}),d("span",{className:"sc-alarm-body",children:he.detail})]})]}),z&&C("div",{className:"sc-alarm sc-alarm-warn",children:[d("span",{className:"sc-alarm-mark","aria-hidden":"true",children:d(yo,{})}),C("span",{className:"sc-alarm-say",children:[d("span",{className:"sc-alarm-title",children:"A large model on this computer"}),C("span",{className:"sc-alarm-body",children:["Your ",z," model can take all this computer's memory while it answers."]})]})]})]}),k&&fe&&d(De,{title:"Soba",children:C("div",{className:"sc-blank",children:[d("span",{className:"sc-blank-soba","aria-hidden":"true",children:d(q,{className:"sc-blank-soba-mark"})}),C("span",{className:"sc-blank-say",children:[d("span",{className:"sc-blank-title",children:fe.title}),d("span",{className:"sc-blank-body",children:fe.detail})]})]})}),k&&$&&!Pe&&d(Gs,{machine:k,runs:Ye,...O?{onStop:O}:{}}),k&&d(_n,{children:Se.length>0&&d(De,{title:"New on this machine",children:Se.map(T=>d(Ys,{runtime:T,...t?{onApprove:()=>t(k.id,T.id)}:{}},T.id))})}),n.length>0&&d(De,{title:n.length>1?"Connected plans":"Connected plan",children:n.map(T=>d(_s,{credential:T,appName:m,busy:u,...o?{onDisconnect:()=>o(T.provider)}:{}},T.provider))}),U.length>0&&d(De,{title:"Your other machines",children:U.map(T=>d(Js,{machine:T},T.id))}),!k&&a&&d(De,{title:"Your machines",children:C("button",{type:"button",className:"sc-pair",onClick:a,children:[d("span",{className:"sc-otile","aria-hidden":"true",children:d($s,{})}),d("span",{className:"sc-oname",children:"Connect a machine"})]})}),(J||te)&&C("div",{className:"sc-acts",children:[J&&C("button",{type:"button",className:"sc-act-go",onClick:J.onPress,disabled:u||J.spin,"data-spin":J.spin?"true":void 0,children:[J.spin&&d(wo,{}),J.label]}),te&&C("button",{type:"button",className:"sc-act-quiet",onClick:te.onPress,disabled:u||te.spin,"data-spin":te.spin?"true":void 0,children:[te.spin&&d(wo,{}),te.label]}),ae==="absent"&&C("p",{className:"sc-act-miss",children:["Nothing opened here. ",k?_(k):"That machine"," may be a different computer, or the Soba app is not installed on this one."]})]}),I,h&&d("p",{className:"sc-error sc-tray-error",children:h})]})}function De({title:e,action:n,children:t}){return C("section",{className:"sc-group",children:[C("div",{className:"sc-group-cap",children:[d("p",{className:"sc-group-title",children:e}),n]}),d("div",{className:"sc-group-card",children:t})]})}function Ts({machine:e,onToggle:n,open:t}){let r=Qn(e),o=[r?null:e.pairing_lost?"Not connected to Soba":"Soba is asleep",r?Fn(e):null,e.always_on?"always on":null].filter(Boolean),a=r&&e.capacity>0?e.active>0?`${e.active} of ${e.capacity} running`:null:Vn(e.last_seen_at),s=C(_n,{children:[C("span",{className:"sc-mtile","aria-hidden":"true",children:[d(vo,{}),d("span",{className:`sc-mbadge sc-mbadge-${r?dn(e).tone:e.pairing_lost?"off":"away"}`})]}),C("span",{className:"sc-mid",children:[d("span",{className:"sc-mname",children:_(e)}),C("span",{className:"sc-mmeta",children:[d("span",{className:"sc-mmeta-is",children:o.map((c,i)=>C("span",{children:[i>0&&d("span",{className:"sc-mmeta-sep",children:"\xB7"}),c]},c))}),a&&d("span",{className:"sc-mmeta-now",children:a})]})]})]});return!n||!r?d("div",{className:"sc-mrow",children:s}):C("button",{type:"button",className:"sc-mrow sc-mrow-btn",onClick:n,"aria-expanded":!!t,title:t?"Hide what it is running":"See what it is running",children:[s,d(Sn,{open:!!t})]})}function Bs(e,n){return e.filter(t=>t.machine_id===n.id||t.machine_id===null)}function Gs({machine:e,runs:n,onStop:t}){let r=n?Bs(n,e):[],[o,a]=Pt(new Set),s=async i=>{a(l=>new Set(l).add(i));try{await t?.(i)}catch{a(l=>{let u=new Set(l);return u.delete(i),u})}},c=()=>{for(let i of r)s(i.id)};return d(De,{title:"Active runs",...t&&r.length>1?{action:d("button",{type:"button",className:"sc-cap-link",onClick:c,children:"Stop all"})}:{},children:n===null?d("p",{className:"sc-row-note",children:"Looking\u2026"}):r.length===0?C("p",{className:"sc-nilrow",children:[d("span",{className:"sc-nilrow-mark","aria-hidden":"true",children:d(Hs,{})}),"Nothing running"]}):r.map(i=>d(Ds,{run:i,stopping:o.has(i.id),...t?{onStop:()=>void s(i.id)}:{}},i.id))})}function Ws(){return C("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-blank-glyph",children:[d("rect",{x:"3",y:"4.5",width:"18",height:"15",rx:"2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.8"}),d("path",{d:"M7.5 10l2.5 2.2-2.5 2.2M12.5 14.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Hs(){return C("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-blank-glyph",children:[d("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"1.8"}),d("path",{d:"M9 12.5l2.2 2.2L15.5 9.8",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ds({run:e,stopping:n,onStop:t}){return C("div",{className:"sc-rrow",children:[d("span",{className:n?"sc-rdot":"sc-rdot sc-rdot-live","aria-hidden":"true"}),C("span",{className:"sc-mid",children:[d("span",{className:"sc-rtitle",children:bo(e)}),d("span",{className:"sc-rstep",children:n?"Stopping\u2026":`${Fs(e)} \xB7 ${Qs(e.started_at)}`})]}),t&&d("button",{type:"button",className:"sc-rstop",onClick:t,disabled:n,"aria-label":`Stop ${bo(e)}`,children:d("span",{className:"sc-rstop-ring",children:d(na,{})})})]})}function Us(e){let n=rr(e);return(n?Ze[n.id]:null)??ho[e]??null}function bo(e){if(e.label)return e.label;if(e.task){let n=e.task.replace(/[_-]+/g," ").trim();return n.charAt(0).toUpperCase()+n.slice(1)}return"A run"}function Fs(e){if(e.status==="queued")return"Waiting for a free slot";if(e.step)return e.step;switch(e.phase?.kind){case"thinking":return"Thinking";case"writing":return"Writing";case"tool":return e.phase.tool?`Using ${e.phase.tool}`:"Using a tool";case"approval":return e.phase.tool?`Waiting for you to allow ${e.phase.tool}`:"Waiting for your approval";default:return e.first_output_at?"Working":"Starting"}}function Qs(e){let n=Math.max(0,Math.round((Date.now()-new Date(e).getTime())/1e3));if(n<60)return`${n}s`;let t=Math.floor(n/60);return t<60?`${t}m ${String(n%60).padStart(2,"0")}s`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function Vs(){return d("a",{className:"sc-disc sc-open-app",href:Jn(),"aria-label":"Open Soba App",title:"Open Soba App",children:d(Co,{})})}function Co(){return d("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-dglyph",children:d("path",{d:"M14 4h6v6M20 4l-8.5 8.5M18 14.5V19a1 1 0 01-1 1H5a1 1 0 01-1-1V7a1 1 0 011-1h4.5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Js({machine:e}){let n=dn(e);return C("div",{className:"sc-orow",children:[d("span",{className:"sc-otile","aria-hidden":"true",children:d(vo,{})}),d("span",{className:"sc-oname",children:_(e)}),d("span",{className:"sc-oword",children:n.word}),d("span",{className:`sc-dot sc-dot-${n.tone}`,"aria-hidden":"true"})]})}function Ys({runtime:e,onApprove:n}){return C("div",{className:"sc-mrow",children:[d("span",{className:"sc-mtile sc-atile","aria-hidden":"true",children:d(Rt,{id:e.id,name:e.display_name})}),C("span",{className:"sc-mid",children:[d("span",{className:"sc-mname",children:e.display_name}),d("span",{className:"sc-mmeta",children:e.version??"waiting to be let in"})]}),n?d("button",{type:"button",className:"sc-row-act",onClick:n,children:"Let it serve"}):d("span",{className:"sc-averdict sc-tone-warn",children:"not serving yet"})]})}function js({id:e,name:n}){return d("span",{className:"sc-runtime-tile","aria-hidden":"true",children:d(Rt,{id:e,...n?{name:n}:{}})})}function Rt({id:e,name:n}){if(!e)return null;let t=co[e];if(t)return d("img",{src:t,alt:"",className:"sc-runtime-logo"});let r=Us(e);return r?d(r,{className:"sc-runtime-mark"}):n?d("span",{className:"sc-runtime-letter",children:n.slice(0,1).toUpperCase()}):null}function zs({machine:e,appName:n,busy:t,onPick:r,model:o,onPickModel:a}){let s=He(e),c=Ne(e),[i,l]=Pt(!1),u=Ls(null);if(s.by!=="app"&&c.length===0)return null;let m=E=>E?d(js,{id:E.id,name:E.display_name}):null,b=s.runtime?.display_name??s.runtimeId??"\u2014",g=s.by!=="app"&&!!r&&c.length>=2,h=s.runtime?.id??s.runtimeId,y=!Qn(e),N=s.runtime&&qe(s.runtime).tone==="warn"?"Signed out":null,P=o?Zn([e]).filter(E=>E.kind==="named"?E.runtime===h:E.kind==="size"?!!h&&vt(h):!0):[],R=(()=>{if(!o)return;if(o.kind!=="auto")return o;let E=s.runtime?.default_model;if(!E)return o;let I=pn(E);return{...o,label:I.length>16?I:`${o.label} \xB7 ${I}`}})(),W=s.by==="app"?`Set by ${n??"the app"}`:s.runtime?Zs(s.runtime):null;return C(_n,{children:[g?C("button",{ref:u,type:"button",className:y?"sc-runs-agent sc-runs-dim":"sc-runs-agent","aria-haspopup":"menu","aria-expanded":i,"aria-label":`Runs go to ${b}. Change`,disabled:t,onClick:()=>l(E=>!E),children:[d("span",{className:"sc-runs-tile","aria-hidden":"true",children:d(Rt,{id:h??null,name:b})}),C("span",{className:"sc-runs-said-name",children:[d("span",{className:"sc-runs-name",children:b}),N&&d("span",{className:"sc-runs-ill",children:N})]}),d(Sn,{open:!1})]}):C("span",{className:y?"sc-runs-agent sc-runs-fixed sc-runs-dim":"sc-runs-agent sc-runs-fixed",children:[d("span",{className:"sc-runs-tile","aria-hidden":"true",children:d(Rt,{id:h??null,name:b})}),C("span",{className:"sc-runs-said-name",children:[d("span",{className:"sc-runs-name",children:b}),N&&d("span",{className:"sc-runs-ill",children:N})]}),s.by==="app"&&C("span",{className:"sc-runs-told",children:["set by ",n??"the app"]})]}),R&&a&&mn(P)?C(_n,{children:[d("span",{className:"sc-runs-rule","aria-hidden":"true"}),d(Kn,{options:P,selected:R,onPick:a,caption:"Model",className:y?"sc-runs-model sc-runs-dim":"sc-runs-model",...t?{disabled:t}:{}})]}):W&&C(_n,{children:[d("span",{className:"sc-runs-rule","aria-hidden":"true"}),C("span",{className:"sc-runs-said",children:[d("span",{className:"sc-runs-key",children:"Model"}),d("span",{className:"sc-runs-val",children:W})]})]}),i&&r&&d(qs,{anchor:u,machine:e,tile:m,onClose:()=>l(!1),onPick:E=>{l(!1),r(E)}})]})}function qs({anchor:e,machine:n,tile:t,onClose:r,onPick:o}){let a=He(n),s=He({...n,preferred_runtime:null}).runtime,c=a.by==="you"?a.runtimeId:null,i=[{id:null,label:"Automatic",...s?{note:`Uses ${s.display_name}`}:{},glyph:t(s)},...Ne(n).map((l,u)=>{let m=Ks(l);return{id:l.id,label:l.display_name,glyph:t(l),...m?{note:m}:{},...u===0?{rule:!0}:{}}})];return d(qn,{anchor:e,label:"Which agent runs go to",options:i,current:c,onClose:r,onPick:o})}function Zs(e){let n=qe(e);return n.tone==="warn"?n.text:e.default_model?pn(e.default_model):e.version??void 0}function Xs(e){if(!e)return null;let n=/(\d+(?:\.\d+)?)\s*b\b/i.exec(e),t=n?.[1]?Number(n[1]):Number.NaN;return!Number.isFinite(t)||t<20?null:`${n?.[1]}B`}function Ks(e){let n=qe(e);return n.tone==="warn"?n.text:e.default_model?pn(e.default_model):e.cost_class==="user-hardware"?"In this machine's memory":n.tone!=="ok"?n.text:e.version??void 0}function _s({credential:e,appName:n,busy:t,onDisconnect:r}){return C("div",{className:"sc-hrow",children:[C("div",{className:"sc-orow",children:[d("span",{className:"sc-otile","aria-hidden":"true",children:d(hn,{className:"sc-omark"})}),C("span",{className:"sc-mid",children:[d("span",{className:"sc-oname",children:e.provider==="openai-chatgpt"?"ChatGPT plan":e.provider}),d("span",{className:"sc-mmeta",children:e.account_label??"signed in"})]}),r&&d("button",{type:"button",className:"sc-row-act",onClick:r,disabled:t,children:"Disconnect"})]}),r&&C("p",{className:"sc-row-note",children:[n??"This app"," stops using it. To withdraw the grant entirely, remove it in your OpenAI settings."]})]})}function vo(){return C("svg",{viewBox:"0 0 32 24","aria-hidden":"true",focusable:"false",className:"sc-mglyph",children:[d("rect",{x:"4",y:"1.5",width:"24",height:"15",rx:"2.5",fill:"var(--sc-sheet, #ffffff)",stroke:"currentColor",strokeWidth:"2"}),d("rect",{x:"1",y:"19.5",width:"30",height:"2.5",rx:"1.25",fill:"currentColor"})]})}function $s(){return d("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-oglyph",children:d("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function yo(){return C("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-hglyph",children:[d("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"2"}),d("path",{d:"M12 7.5v5.5",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),d("circle",{cx:"12",cy:"16.5",r:"1.15",fill:"currentColor"})]})}function wo(){return C("svg",{className:"sc-act-glyph sc-spin",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",children:[d("circle",{cx:"8",cy:"8",r:"6.2",fill:"none",stroke:"currentColor",strokeWidth:"2",opacity:"0.3"}),d("path",{d:"M8 1.8a6.2 6.2 0 0 1 6.2 6.2",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function ea({spinning:e}){return d("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-dglyph sc-spin":"sc-dglyph",children:d("path",{d:"M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function na(){return d("svg",{className:"sc-dglyph",viewBox:"0 0 14 14","aria-hidden":"true",children:d("rect",{x:"2",y:"2",width:"10",height:"10",rx:"2",fill:"currentColor"})})}import{jsx as ta}from"react/jsx-runtime";function $n({machines:e,onApproveRuntime:n,model:t,onPickModel:r}){return ta(fn,{machines:e,...n?{onApproveRuntime:n}:{},...t?{model:t}:{},...r?{onPickModel:r}:{}})}var or={ready:{arc:!0},serving:{arc:!0,slot:"stream"},paused:{arc:!1,slot:"zzz"},thinking:{arc:!1,slot:"dots"},connecting:{arc:!1,slot:"orbit"},attention:{arc:!1,slot:"bang"},gone:{arc:!1,slot:"cross"},snap:{arc:!1,slot:"snap"},listening:{arc:!1,slot:"bars"},permission:{arc:!1,slot:"ring"},ai:{arc:!1,slot:"sparks"}};var sr="105 162 420 420",ar="M407.1 308.9 A158 158 0 1 0 407.1 491.1 A116 116 0 0 1 407.1 308.9 Z",gn="M448.5 320 A110 110 0 0 1 448.5 480";import{Fragment as nt,jsx as S,jsxs as Xe}from"react/jsx-runtime";function ir({kind:e,size:n=44,className:t}){let r=or[e];return Xe("svg",{className:`bx${t?` ${t}`:""}`,"data-expression":e,viewBox:sr,overflow:"visible",width:n,height:n,"aria-hidden":"true",children:[S("path",{d:ar,fill:"currentColor"}),S("path",{className:"bx-arc",d:gn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),r.slot==="stream"&&S(ra,{}),r.slot==="zzz"&&S(oa,{}),r.slot==="dots"&&S(sa,{}),r.slot==="bang"&&S(aa,{}),r.slot==="orbit"&&S(ia,{}),r.slot==="cross"&&S(la,{}),r.slot==="snap"&&S(ca,{}),r.slot==="bars"&&S(ua,{}),r.slot==="ring"&&S(da,{}),r.slot==="sparks"&&S(pa,{})]})}function ra(){return S("path",{className:"bx-st",d:"M475.3 290.3 A150 150 0 0 1 475.3 509.7",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeDasharray:"0.1 31"})}function oa(){return Xe(nt,{children:[S("g",{className:"bx-z1",children:S("path",{d:"M444 372 H496 L444 436 H496",fill:"none",stroke:"currentColor",strokeWidth:"20",strokeLinecap:"round",strokeLinejoin:"round"})}),S("g",{className:"bx-z2",children:S("path",{d:"M492 300 H522 L492 338 H522",fill:"none",stroke:"currentColor",strokeWidth:"15",strokeLinecap:"round",strokeLinejoin:"round"})})]})}function sa(){return Xe(nt,{children:[S("circle",{className:"bx-th",cx:"463.1",cy:"336.9",r:"21",fill:"currentColor"}),S("circle",{className:"bx-th bx-th2",cx:"483",cy:"400",r:"21",fill:"currentColor"}),S("circle",{className:"bx-th bx-th3",cx:"463.1",cy:"463.1",r:"21",fill:"currentColor"})]})}function aa(){return Xe("g",{className:"bx-at",children:[S("line",{x1:"490",y1:"312",x2:"490",y2:"414",stroke:"currentColor",strokeWidth:"46",strokeLinecap:"round"}),S("circle",{cx:"490",cy:"484",r:"28",fill:"currentColor"})]})}function ia(){return Xe("g",{className:"bx-ob",children:[S("path",{d:gn,fill:"none",stroke:"var(--tile-bg, transparent)",strokeWidth:41,strokeLinecap:"round"}),S("path",{d:gn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})]})}function la(){return Xe(nt,{children:[S("path",{className:"bx-xa",d:gn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),S("g",{className:"bx-xx",children:S("path",{d:"M442 364 L514 436 M514 364 L442 436",fill:"none",stroke:"currentColor",strokeWidth:"24",strokeLinecap:"round"})})]})}function ca(){return S("path",{className:"bx-snap",d:gn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})}function ua(){return Xe("g",{stroke:"currentColor",strokeWidth:"17",strokeLinecap:"round",children:[S("line",{className:"bx-vb",x1:"452",y1:"370",x2:"452",y2:"430"}),S("line",{className:"bx-vb bx-vb2",x1:"482",y1:"330",x2:"482",y2:"470"}),S("line",{className:"bx-vb bx-vb3",x1:"512",y1:"355",x2:"512",y2:"445"})]})}function da(){return S(nt,{children:[[450,366],[474,376],[484,400],[474,424],[450,434],[426,424],[416,400],[426,376]].map(([n,t],r)=>S("circle",{className:"bx-w",cx:n,cy:t,r:"11",fill:"currentColor",style:{animationDelay:`${-1.2+r*.15}s`}},r))})}function pa(){return Xe(nt,{children:[S("g",{className:"bx-sp",children:S("path",{d:"M460 300 Q465.4 324.6 490 330 Q465.4 335.4 460 360 Q454.6 335.4 430 330 Q454.6 324.6 460 300 Z",fill:"currentColor"})}),S("g",{className:"bx-sp bx-sp2",children:S("path",{d:"M486 356 Q493.92 392.08 530 400 Q493.92 407.92 486 444 Q478.08 407.92 442 400 Q478.08 392.08 486 356 Z",fill:"currentColor"})}),S("g",{className:"bx-sp bx-sp3",children:S("path",{d:"M460 440 Q465.4 464.6 490 470 Q465.4 475.4 460 500 Q454.6 475.4 430 470 Q454.6 464.6 460 440 Z",fill:"currentColor"})})]})}import{useCallback as de,useEffect as be,useId as ga,useMemo as Ke,useRef as Pn,useState as j}from"react";var tt=[{slug:"mac-arm",label:"macOS, Apple silicon"},{slug:"mac-intel",label:"macOS, Intel"},{slug:"windows",label:"Windows"},{slug:"linux",label:"Linux"}];function rt(e){if(!e)return"";try{return new URL(e).origin}catch{return""}}var No="soba.connect.choice",ma=180*24*60*60*1e3;function lr(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function cr(e,n){return e?n?`${No}.${e}.${lr(n)}`:`${No}.${e}`:null}function ur(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>ma)return null;let r=Ae.find(o=>o.id===t.choice);return r?r.id:null}catch{return null}}function dr(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var xo="soba.connect.model",ha=180*24*60*60*1e3;function pr(e,n){return e?n?`${xo}.${e}.${lr(n)}`:`${xo}.${e}`:null}function Et(e){if(!e||typeof localStorage>"u")return null;try{let n=localStorage.getItem(e);if(!n)return null;let t=JSON.parse(n);if(Date.now()-Date.parse(t.at)>ha)return null;let r=t.choice;return typeof r!="string"||!r||r.length>120?null:/^[\w.:@+-]+(\/[\w.:@+-]+)?$/.test(r)?r:null}catch{return null}}function mr(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var Mo="soba.connect.dismissed",fa=30*24*60*60*1e3;function hr(e,n){return e?n?`${Mo}.${e}.${lr(n)}`:`${Mo}.${e}`:null}function fr(e){if(!e||typeof localStorage>"u")return!1;try{let n=localStorage.getItem(e);if(!n)return!1;let t=JSON.parse(n);return Date.now()-Date.parse(t.at)<fa}catch{return!1}}function gr(e){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({at:new Date().toISOString()}))}catch{}}import{Fragment as Lt,jsx as p,jsxs as M}from"react/jsx-runtime";var Ar=2e3,Aa=1e4,ba=9e4,ya=6e4;function br(e,n,t,r=[],o){return e?"code":n&&(t.length>0||r.length>0)?"manage":o?"launch":"choose"}function wa(e){let n=Math.max(0,Math.round(e/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Cr({client:e,initialCode:n,initialChoice:t,onConnected:r,showStatus:o=!0,initialContext:a=null,initialMachines:s,onClose:c,headingId:i,theme:l,reason:u,active:m=!0}){let b=!!a&&s!==void 0,[g,h]=j(b?br(n,o,s??[],[],t):"loading"),[y,N]=j(a),[P,R]=j(s??[]),[W,E]=j(n??""),[I,O]=j(null),[k,U]=j(null),[pe,ne]=j(!1),[ae,Z]=j(0),[me,Ye]=j(()=>Date.now()),[$,ye]=j(null),[Se,X]=j(!1),[ie,z]=j(!1),[Pe,he]=j("browser"),[fe,nn]=j(null),[V,J]=j([]),[te,T]=j(0),[le,Re]=j(null),ce=Pn(null),[L,B]=j(t??null),[x,tn]=j(null),je=Ke(()=>{let f=y?.accent?.trim(),v=y?.background?.trim();if(!(!f&&!v))return v?{...cn(v,f),background:v,borderRadius:"inherit"}:{"--sc-accent":f,"--sc-accent-fg":Un(f)}},[y?.accent,y?.background]),we=ga(),ue=i??we,ze=Pn(null);be(()=>{if(!e||b)return;let f=!0;return Promise.all([e.context(),e.machines()]).then(([v,F])=>{f&&(N(v),R(F),h(br(n,o,F)))}).catch(v=>{f&&(U(v.message),h("choose"))}),()=>{f=!1}},[e,n,o,b]),be(()=>{g!=="loading"||!b||h(br(n,o,s??[]))},[g,b,n,o,s]),be(()=>{s&&R(s)},[s]),be(()=>{a&&N(a)},[a]);let Cn=Pn(!1),vn=Pn(g);vn.current=g;let rn=Pn(V);rn.current=V;let on=!!y?.hosted_available;be(()=>{!o&&vn.current==="manage"&&h("choose")},[o]),be(()=>{if(!e||!m||g!=="manage")return;let f=!0,v=Me(async()=>{try{let F=await e.machines();if(!f)return;R(F);let Y=!on||Cn.current;F.length===0&&rn.current.length===0&&Y&&vn.current==="manage"&&h("choose")}catch{}},Aa,{immediate:!1});return()=>{f=!1,v()}},[g,e,on,m]);let sn=cr(y?.publishable_key??null);be(()=>{tn(ur(sn))},[sn]),be(()=>{if(!e||!on)return;let f=!0;return e.hosted().then(v=>{f&&(J(v.credentials),!Cn.current&&(Cn.current=!0,v.credentials.length>0&&o&&vn.current==="choose"&&h("manage")))}).catch(()=>{}),()=>{f=!1}},[e,on,o]),be(()=>{if(!e||!m||g!=="hosted")return;let f=!0,v=async()=>{try{let Ge=await e.hosted();if(!f)return!1;if(J(Ge.credentials),Ge.credentials.length>0)return h("hosted_connected"),Re(null),!0}catch{}return!1},F=async()=>{ce.current?.closed&&(ce.current=null,!await v()&&f&&h("choose"))},Y=Me(v,Ar,{immediate:!1}),ln=setInterval(F,400),Ie=Ge=>{let Hn=Ge.data;Hn?.source==="soba"&&Hn.type==="hosted_result"&&v()};return window.addEventListener("message",Ie),()=>{f=!1,Y(),clearInterval(ln),window.removeEventListener("message",Ie),ce.current=null}},[e,g,m]);let Ut=de(()=>{if(!e)return;let f=window.open("","soba-connect-plan","width=520,height=760,noopener=no");ce.current=f,h("hosted"),T(Date.now()),Re(null),U(null),e.startHosted().then(({url:v})=>{if(f&&!f.closed){f.location.href=v;return}Re(v)}).catch(v=>{f?.close(),ce.current=null,U(v.message),h("choose")})},[e]),gt=de(async f=>{if(e){ne(!0);try{await e.disconnectHosted(f),J((await e.hosted()).credentials)}catch(v){U(v.message)}finally{ne(!1)}}},[e]);be(()=>{if(!e||!m||g!=="waiting")return;let f=!0,v=Me(async()=>{try{let F=await e.machines();if(!f)return;R(F);let Y=ze.current;if(!Y)return;let ln=F.filter(Ge=>!Y.has(Ge.id)),Ie=ln.find(Ge=>Ge.state!=="offline")??ln[0];if(Ie){nn(Ie.id),L&&dr(sn,L);let Ge=Ae.find(Vt=>Vt.id===L)?.expects??[],Hn=Ne(Ie).find(Vt=>Ge.includes(Vt.id));Hn&&e.preferRuntime(Ie.id,Hn.id).catch(()=>{}),h("connected"),r?.(F)}}catch{}},Ar,{immediate:!1});return()=>{f=!1,v()}},[g,e,r,L,sn,m]);let At=de(async()=>{if(e){U(null),ne(!0);try{let f=await e.lookup(W);O(f),h("confirm")}catch(f){U(f.message)}finally{ne(!1)}}},[e,W]),kn=de(async()=>{if(e){U(null),ne(!0);try{try{ze.current=new Set((await e.machines()).map(f=>f.id))}catch{ze.current=new Set(P.map(f=>f.id))}await e.approve(W),h("waiting"),Z(Date.now())}catch(f){U(f.message)}finally{ne(!1)}}},[e,W,P]),bt=de(async()=>{if(e){ne(!0);try{await e.deny(W),he("browser"),h("denied")}catch(f){U(f.message)}finally{ne(!1)}}},[e,W]),K=Ke(()=>y?.connect_url??null,[y]),[Be,Ce]=j(()=>jn()),an=Ke(()=>K?Yn(K,Be??void 0,L??void 0):null,[K,Be,L]),yt=Ke(()=>rt(K),[K]),Ft=de(f=>{if(P.length===0)return null;let v=Ae.find(Y=>Y.id===f);if(!v)return null;let F=P.flatMap(Y=>Y.runtimes??[]).filter(Y=>v.expects.includes(Y.id));return F.length===0?{tone:"dim",text:"not installed"}:F.some(Y=>Y.authenticated===!0)?{tone:"ok",text:"ready"}:F.every(Y=>Y.authenticated===!1)?{tone:"warn",text:"needs signing in"}:{tone:"dim",text:"installed"}},[P]),w=de((f=null)=>{B(f),U(null),ye(null),X(!1),z(!1),ee.current=!1,Ce(jn()),h("launch")},[]),ee=Pn(!!t);be(()=>{g!=="launch"||!K||ee.current||(ee.current=!0,X(!0),Zt(K,{...Be?{nonce:Be}:{},...L?{want:L}:{}}).then(ye))},[g,K,Be,L]);let ge=de(()=>{X(!0),qt().then(ye)},[]),wt=de(f=>{if(ie){let v=jn();z(!1),Ce(v),K&&(f.preventDefault(),window.location.href=Yn(K,v??void 0,L??void 0))}ge()},[ie,ge,K,L]),ve=Ke(()=>{let f=y?.runtimes;return f?Ae.filter(v=>f.includes(v.id)):nr()},[y?.runtimes]),Ee=Ke(()=>{let f=Ae.find(v=>v.id===L);return f?{choice:f,Mark:Ze[f.id]??null}:null},[L]),Qe=Ke(()=>P.find(f=>f.id===fe),[P,fe]);be(()=>{let f=Be;if(!e||!m||g!=="launch"||!f)return;let v=!1,F=Date.now()+15e4,Y=()=>{};return Y=Me(async()=>{if(Date.now()>F){Y(),z(!0);return}try{let ln=await e.claim(f);if(v)return;if(ln.declined){Y(),ye(null),he("machine"),h("denied");return}if(!ln.claimed)return;Y();try{ze.current=new Set((await e.machines()).map(Ie=>Ie.id))}catch{ze.current=new Set(P.map(Ie=>Ie.id))}h("waiting"),Z(Date.now())}catch{}},Ar,{immediate:!1,idle:!1}),()=>{v=!0,Y()}},[e,g,P,Be,m]);let ke=Ke(()=>{if(!I)return null;if(I.approved||I.denied)return"answered";let f=I.expires_at?Date.parse(I.expires_at):Number.NaN;return Number.isFinite(f)&&f<=me?"expired":"live"},[I,me]);be(()=>{if(!(g==="confirm"&&ke==="live"||g==="waiting"||g==="hosted"))return;let v=setInterval(()=>Ye(Date.now()),1e3);return()=>clearInterval(v)},[g,ke]);let Ct=de(async(f,v)=>{if(e)try{await e.approveRuntime(f,v),R(await e.machines())}catch(F){U(F.message)}},[e]),Qt=de(async(f,v)=>{if(e)try{await e.preferRuntime(f,v),R(await e.machines())}catch(F){U(F.message)}},[e]);return g==="loading"?p("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:je,children:p("div",{className:"sc-card",children:p("p",{className:"sc-note",children:"Loading\u2026"})})}):M("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:je,children:[c&&p("button",{type:"button",className:"sc-modal-close",onClick:c,"aria-label":"Close",children:"\xD7"}),g==="manage"&&M("div",{className:"sc-card",children:[p("h2",{className:"sc-title",id:ue,children:"Your compute"}),M("p",{className:"sc-sub",children:[p(It,{context:y})," ",P.length>0&&V.length>0?"runs on your connected plan, and on these machines while they are awake.":V.length>0?"runs on the plan you connected. Nothing here is charged to you.":"runs on these machines, while they are awake."]}),p(fn,{machines:P,hosted:V,onApproveRuntime:Ct,onPreferRuntime:(f,v)=>void Qt(f,v),onDisconnectHosted:f=>void gt(f),onPair:()=>h("choose"),busy:pe,...y?.app.name?{appName:y.app.name}:{}}),k&&p("p",{className:"sc-error",children:k})]}),g==="choose"&&M("div",{className:"sc-card",children:[p(va,{context:y}),p("h2",{className:"sc-h",id:ue,children:u==="payment_required"?"Carry on with your own AI":u==="no_compute"?"This run needs a machine":"Connect your AI"}),p("p",{className:"sc-p",children:"Use compute you already have."}),K&&ve.length>0&&M(Lt,{children:[p("div",{className:"sc-opts",children:ve.map(f=>{let v=Ze[f.id];return M("button",{type:"button",className:"sc-opt",onClick:()=>w(f.id),children:[p("span",{className:"sc-opt-tile","aria-hidden":"true",children:v&&p(v,{className:"sc-opt-mark"})}),p("span",{className:"sc-opt-text",children:p("span",{className:"sc-opt-label",children:f.label})}),(()=>{let F=Ft(f.id);return F?p("span",{className:`sc-opt-has sc-opt-has-${F.tone}`,children:F.text}):x===f.id?p("span",{className:"sc-opt-last",children:"last used"}):p(yr,{className:"sc-opt-go"})})()]},f.id)})}),M("p",{className:"sc-opt-note",children:["Your accounts stay there. ",So(y)," never sees them."]})]}),(!K||ve.length===0)&&p("p",{className:"sc-error",style:{marginTop:16},children:"This app has no publishable key yet, so there is nothing to pair against."}),k&&p("p",{className:"sc-error",children:k}),K&&y?.show_code===!0&&p("div",{className:"sc-opt-alt",children:p("button",{type:"button",className:"sc-alt-link",onClick:()=>h("code"),children:"I have a code"})})]}),g==="launch"&&M("div",{className:"sc-card",children:[M("div",{className:"sc-head",children:[p(Rn,{onClick:()=>h("choose")}),p("p",{className:"sc-head-title",children:"Soba App"})]}),p(Ot,{mark:Ee?.Mark??q,still:ie||!Se&&$===null}),p("h2",{className:"sc-h",id:ue,children:ie?"No answer from this machine":$==="absent"?"Nothing opened":$===null?"Opening Soba App\u2026":"Approve it on this machine"}),ie?p("p",{className:"sc-p",children:"The Soba app did not answer. It may not be open, or nobody was there. Try again when you are ready."}):$==="absent"?p("p",{className:"sc-p",children:"Nothing opened on this machine. Open it yourself below, or install it if it is not here yet."}):p("p",{className:"sc-p",children:$===null?"Approve it there and this page does the rest.":"This page finishes on its own."}),Ee&&M("p",{className:"sc-prereq",children:[Ee.Mark&&p(Ee.Mark,{className:"sc-rt-mark"}),"Needs ",Ee.choice.prerequisite]}),M("div",{className:"sc-stack",style:{marginTop:18},children:[p("a",{className:$==="absent"||ie?"sc-btn sc-btn-primary":"sc-btn",href:an??"#",onClick:wt,children:ie?"Try again":$==="absent"?"Open Soba App":"Open it again"}),p("p",{className:"sc-note",children:$===null?"Your browser will ask permission first.":"Your browser asks permission the first time."}),Ee&&$==="absent"&&p("p",{className:"sc-note",children:p(ka,{text:Ee.choice.hint})}),M("div",{className:"sc-foot-strip",children:[p("span",{children:"Not installed on this machine?"}),M("button",{type:"button",className:"sc-foot-go",onClick:()=>h("get"),children:["Get it",p(yr,{})]})]})]})]}),g==="get"&&M("div",{className:"sc-card",children:[M("div",{className:"sc-head",children:[p(Rn,{onClick:()=>h("launch")}),p("p",{className:"sc-head-title",children:"Get Soba App"})]}),p("div",{className:"sc-opts",children:tt.map(f=>M("a",{className:"sc-opt",href:`${yt}/download/${f.slug}`,target:"_blank",rel:"noreferrer noopener",children:[p("span",{className:"sc-opt-tile","aria-hidden":"true",children:p(er,{className:"sc-opt-mark"})}),p("span",{className:"sc-opt-text",children:p("span",{className:"sc-opt-label",children:f.label})}),p(yr,{className:"sc-opt-go"})]},f.slug))}),p("p",{className:"sc-opt-note",children:"Install it, then come back here and press the row you started with."})]}),g==="code"&&M("div",{className:"sc-card",children:[M("div",{className:"sc-head",children:[p(Rn,{onClick:()=>h("choose")}),p("p",{className:"sc-head-title",children:"Soba App"})]}),p("h2",{className:"sc-h",id:ue,children:"Enter the code from that machine"}),p("p",{className:"sc-p",children:"Eight characters, shown by the Soba app once you paste the link."}),M("form",{className:"sc-stack",style:{marginTop:16},onSubmit:f=>{f.preventDefault(),At()},children:[p("input",{className:"sc-input",value:W,onChange:f=>E(f.target.value),placeholder:"ACDE-F234",autoComplete:"off",autoFocus:!0,"aria-label":"Pairing code"}),k&&p("p",{className:"sc-error",children:k}),p("button",{type:"submit",className:"sc-btn sc-btn-primary",disabled:pe||W.length<8,children:pe?"Checking\u2026":"Continue"})]})]}),g==="confirm"&&I&&M("div",{className:"sc-card",children:[M("div",{className:"sc-head",children:[p(Rn,{onClick:()=>h("code")}),p("p",{className:"sc-head-title",children:"Soba App"})]}),p("h2",{className:"sc-title",children:"Attach this machine to your account?"}),M("p",{className:"sc-sub",children:[p(It,{context:y})," may send your runs to it once you approve. It can never see the account or the keys on it."]}),M("ul",{className:"sc-facts",children:[p(ot,{k:"Code",v:I.user_code}),p(ot,{k:"Machine",v:I.hostname??"not stated"}),p(ot,{k:"System",v:[I.platform,I.arch].filter(Boolean).join(" / ")||"not stated"}),p(ot,{k:"Asked by",v:I.client??"not stated"}),I.labels.length>0&&p(ot,{k:"Labels",v:I.labels.join(", ")})]}),p("p",{className:"sc-note",style:{marginTop:12},children:"Every line above is what that machine said about itself. If none of it looks like a computer of yours, say no."}),ke==="expired"&&p("p",{className:"sc-error",children:"That code has expired. Ask the machine for a new one. It prints a fresh code each time it starts."}),ke==="answered"&&p("p",{className:"sc-error",children:"That code has already been answered. If it was not you, deny the next one."}),k&&p("p",{className:"sc-error",children:k}),M("div",{className:"sc-row",style:{marginTop:16},children:[p("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:()=>void kn(),disabled:pe||ke!=="live",children:"Approve"}),p("button",{type:"button",className:"sc-btn",onClick:()=>void bt(),disabled:pe||ke==="answered",children:"No, deny it"})]}),ke==="live"&&I.expires_at&&M("p",{className:"sc-note",style:{marginTop:10},children:["This code expires in ",wa(Date.parse(I.expires_at)-me),"."]})]}),g==="waiting"&&M("div",{className:"sc-card",children:[M("div",{className:"sc-head",children:[p(Rn,{onClick:()=>h("choose")}),p("p",{className:"sc-head-title",children:Ee?.choice.short??"Soba App"})]}),p(Ot,{mark:Ee?.Mark??q}),p("h2",{className:"sc-h",id:ue,children:"Approved. Waiting for it to connect"}),p("p",{className:"sc-p",children:"Nothing more to do here. This page changes when it arrives."}),ae>0&&me-ae>ba&&p("p",{className:"sc-note sc-tone-warn",style:{marginTop:14,textAlign:"center"},children:"Still nothing. Look at the Soba app on that machine: it says what it is doing. This keeps watching either way."})]}),g==="connected"&&M("div",{className:"sc-card",children:[p(wr,{tone:"ok"}),p("h2",{className:"sc-h",id:ue,children:Qe?.label?`${Qe.label} is connected`:"Connected"}),M("p",{className:"sc-p",children:[p(It,{context:y})," will use ",Qe?.label?"it":"this machine"," from now on, while it is awake."]}),o&&M(Lt,{children:[p("div",{style:{marginTop:16},children:p($n,{machines:P,onApproveRuntime:Ct})}),p("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:14},onClick:()=>h("manage"),children:"Done"})]})]}),g==="hosted"&&M("div",{className:"sc-card",children:[M("div",{className:"sc-head",children:[p(Rn,{onClick:()=>h("choose")}),p("p",{className:"sc-head-title",children:"ChatGPT"})]}),le?p(Ot,{mark:hn,still:!0}):p(Ot,{mark:hn}),p("h2",{className:"sc-h",id:ue,children:le?"Your browser blocked the window":"Finish signing in to ChatGPT"}),p("p",{className:"sc-p",children:le?"Nothing opened. Open the sign-in yourself below. A link you click is allowed where a window we open is not.":"Approve it in the window that opened."}),M("div",{className:"sc-stack",style:{marginTop:18},children:[le&&p("a",{className:"sc-btn sc-btn-primary",href:le,target:"soba-connect-plan",rel:"noreferrer",children:"Open the ChatGPT sign-in"}),k&&p("p",{className:"sc-error",children:k}),te>0&&me-te>ya&&p("p",{className:"sc-note sc-tone-warn",children:"Still nothing. The window may have been closed before it finished, or the sign-in may have been declined. This keeps watching either way."})]})]}),g==="hosted_connected"&&M("div",{className:"sc-card",children:[p(wr,{tone:"ok"}),p("h2",{className:"sc-h",id:ue,children:"ChatGPT is connected"}),M("p",{className:"sc-p",children:[p(It,{context:y})," will run on your ChatGPT plan",V[0]?.account_label?` (${V[0].account_label})`:"",". Nothing more to pay, nothing to install."]}),p("p",{className:"sc-opt-note",style:{textAlign:"center"},children:"It runs on our side, so it has no access to your files or your terminal."}),o&&M(Lt,{children:[p("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>h("manage"),children:"Done"}),p("div",{className:"sc-opt-alt",children:p("button",{type:"button",className:"sc-alt-link",onClick:()=>h("choose"),children:"Connect a machine too"})})]})]}),g==="denied"&&M("div",{className:"sc-card",children:[p(wr,{tone:"off"}),p("h2",{className:"sc-h",id:ue,children:"Declined"}),p("p",{className:"sc-p",children:Pe==="machine"?"Nothing was connected. You can ask again whenever you like.":"That machine was not attached to your account, and the terminal has been told so."}),p("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:16},onClick:()=>h("choose"),children:"Back to the start"})]})]})}function So(e){return e?.app.name??"this app"}function Ca(e){let n=e?.app.icon_urls;if(n?.length)return n;let t=e?.app.icon_url;return t?[t]:[]}function Po(e){let n=Ca(e),[t,r]=j([]),o=de(c=>{c&&r(i=>i.includes(c)?i:[...i,c])},[]),a=de(c=>o(c.currentTarget.getAttribute("src")),[o]),s=de(c=>{c?.complete&&c.naturalWidth===0&&o(c.getAttribute("src"))},[o]);return{icon:n.find(c=>!t.includes(c)),onError:a,ref:s}}function va({context:e}){let{icon:n,onError:t,ref:r}=Po(e);return e?.app.mark==="soba"?p(q,{className:"sc-app-mark"}):n?p("img",{className:"sc-app-mark",src:n,alt:"","aria-hidden":"true",ref:r,onError:t}):null}function It({context:e}){let{icon:n,onError:t,ref:r}=Po(e),o=e?.app.mark==="soba";return M("span",{className:"sc-app",children:[o&&p(q,{className:"sc-app-icon"}),!o&&n&&p("img",{className:"sc-app-icon",src:n,alt:"",ref:r,onError:t}),So(e)]})}function Rn({onClick:e}){return p("button",{type:"button",className:"sc-head-back",onClick:e,"aria-label":"Back",children:p("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:p("path",{d:"M15 5 8 12l7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}function yr({className:e}){return p("svg",{className:e,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:p("path",{d:"M9 5l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ot({mark:e,still:n}){return M("span",{className:"sc-waiting","aria-hidden":"true",children:[!n&&p("svg",{className:"sc-waiting-orbit",viewBox:"0 0 100 100","aria-hidden":"true",focusable:"false",children:p("circle",{className:"sc-waiting-arc",cx:"50",cy:"50",r:"46"})}),p(e,{className:"sc-waiting-mark"})]})}function wr({tone:e}){return p("span",{className:`sc-result sc-result-${e}`,"aria-hidden":"true",children:p(ir,{kind:e==="ok"?"snap":"gone",size:84})})}function ka({text:e}){return p(Lt,{children:e.split("`").map((n,t)=>t%2===1?p("code",{className:"sc-inline-code",children:n},t):n)})}function ot({k:e,v:n}){return M("li",{className:"sc-fact",children:[p("span",{className:"sc-fact-key",children:e}),p("span",{children:n})]})}import{forwardRef as Na}from"react";import{jsx as vr,jsxs as kr}from"react/jsx-runtime";var Nr=Na(function({machine:n,className:t,...r},o){if(!n)return null;let{ariaLabel:a,state:s}=Mn(n);return kr("button",{ref:o,type:"button","aria-label":a,className:["sc-btn","sc-btn-connected",t].filter(Boolean).join(" "),...r,children:[vr("span",{className:"sc-pill-tile","aria-hidden":"true",children:vr(q,{className:s.tone==="busy"?"sc-pill-mark sc-pill-mark-busy":"sc-pill-mark"})}),kr("span",{className:"sc-btn-connected-text",children:[s.word,kr("span",{className:"sc-btn-connected-where",children:[" on ",_(n)]})]}),vr("i",{className:`sc-dot sc-dot-${s.tone}`,"aria-hidden":"true"})]})});import{useEffect as xa,useRef as Mr}from"react";var Tt=0,xr=null;function Ro(){if(typeof document>"u")return()=>{};Tt===0&&(xr=document.body.style.overflow,document.body.style.overflow="hidden"),Tt+=1;let e=!1;return()=>{e||(e=!0,Tt-=1,Tt===0&&(document.body.style.overflow=xr??"",xr=null))}}import{jsx as Eo}from"react/jsx-runtime";function st({open:e,onClose:n,labelledBy:t,theme:r,style:o,children:a}){let s=Mr(null),c=Mr(null),i=Mr(null);return xa(()=>{let l=s.current;if(l){if(!e){l.open&&l.close();return}return l.open||l.showModal(),document.activeElement===l&&c.current?.focus(),Ro()}},[e]),Eo("dialog",{ref:s,className:"soba-connect sc-modal","aria-labelledby":t,...r?{"data-theme":r}:{},style:o,onCancel:l=>{l.preventDefault(),n()},onPointerDown:l=>{i.current=l.target},onClick:l=>{l.target===l.currentTarget&&i.current===l.currentTarget&&n()},children:Eo("div",{className:"sc-modal-sheet",ref:c,tabIndex:-1,children:a})})}import{useEffect as Sr,useRef as Ma}from"react";import{jsx as Sa}from"react/jsx-runtime";var An=8;function Pr({open:e,onClose:n,anchor:t,label:r,theme:o,style:a,children:s}){let c=Ma(null);return Sr(()=>{let i=c.current;if(!(!i||!(typeof i.showPopover=="function")))try{e?i.showPopover():i.hidePopover()}catch{}},[e]),Sr(()=>{if(!e)return;let i=()=>{let u=c.current,m=t.current;if(!u||!m)return;let b=m.getBoundingClientRect(),g=u.offsetWidth,h=u.offsetHeight,y=window.innerWidth-g-An,N=Math.max(An,Math.min(b.right-g,Math.max(An,y))),P=b.bottom+An,R=b.top-An-h,W=P+h>window.innerHeight-An&&R>An?R:P;u.style.left=`${Math.round(N)}px`,u.style.top=`${Math.round(W)}px`};i();let l=requestAnimationFrame(i);return window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{cancelAnimationFrame(l),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e,t]),Sr(()=>{if(!e)return;let i=u=>{u.key==="Escape"&&n()},l=u=>{let m=u.target;m&&(c.current?.contains(m)||t.current?.contains(m)||n())};return document.addEventListener("keydown",i),document.addEventListener("pointerdown",l,!0),()=>{document.removeEventListener("keydown",i),document.removeEventListener("pointerdown",l,!0)}},[e,n,t]),Sa("div",{ref:c,role:"dialog","aria-label":r,className:"soba-connect sc-pop",...o?{"data-theme":o}:{},popover:"manual",hidden:!e,style:a,children:s})}var at=new Map,En=new Map,Io=!1;function Pa(){Io||typeof window>"u"||(Io=!0,window.addEventListener("storage",e=>{!e.key||!at.has(e.key)||(En.set(e.key,Et(e.key)),Rr(e.key))}))}function Rr(e){for(let n of at.get(e)??[])n()}function it(e){return e??""}function Er(e,n){let t=it(e);Pa();let r=at.get(t)??new Set;return r.add(n),at.set(t,r),()=>{r.delete(n),r.size===0&&at.delete(t)}}function Bt(e){let n=it(e),t=En.get(n);if(t!==void 0)return t;let r=e?Et(e):null;return En.set(n,r),r}function Ir(){return null}function Or(e,n){Bt(e)===null&&(En.set(it(e),n),Rr(it(e)))}function Lr(e,n){let t=it(e);En.get(t)!==n&&(En.set(t,n),mr(e,n),Rr(t))}function Ve(e){let n=`${e.unit}s`;return e.reward==="unlimited"?`Unlimited ${n} on your own AI`:e.reward==="included"&&e.includedUnits!==null?`${Ea(e.includedUnits)} ${n} a month once you connect`:e.reward==="credit"&&e.creditMicros>0?`${Ra(e.creditMicros)} back each month you stay connected`:null}function Je(e){return e==="unlimited"||e==="included"}var Lo=new Set(["user-hardware","user-subscription"]),Oo=new Set(["open-weights","frontier"]);function Le(e){return e===null||e.length===0?!1:e.every(n=>Lo.has(n))}var Ra=e=>(e/1e6).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),Ea=e=>e.toLocaleString("en-US");function Tr(e,n){if(!(n===null||n.some(a=>Oo.has(a))))return!1;let r=e.findIndex(a=>Lo.has(a));if(r===-1)return!1;let o=e.findIndex(a=>Oo.has(a));return o===-1||r<o}import{createContext as To,useContext as Bo}from"react";var Br=To(null);function In(){return Bo(Br)}var Gr=To({context:null,machines:void 0,theme:"light"});function H(){return Bo(Gr)}import{useMemo as La}from"react";import{createContext as Ia,useContext as Oa}from"react";var Wr=Ia(null);function Q(){let e=Oa(Wr);if(!e)throw new Error("useSoba() must be used inside a <SobaProvider>.");return e}function lt(){let{compute:e}=Q();return La(()=>{let n=e.machines,t=[...n].sort((a,s)=>We([a,s])===a?-1:1).map(Ta),r=We([...n]),o=un(n);return{view:t.length?"machines":e.loading?"loading":e.error?"error":"empty",machines:t,primary:r?t.find(a=>a.machine.id===r.id)??null:null,connected:e.connected,online:e.online,stalled:e.connected&&!e.online&&o?t.find(a=>a.machine.id===o.id)??null:null,loading:e.loading,error:e.error,refresh:e.refresh}},[e])}function Ta(e){let n=He(e);return{machine:e,name:_(e),state:dn(e),status:Yt(e),hardware:Fn(e),lastSeen:e.state==="offline"?Vn(e.last_seen_at):null,runtimes:Ne(e).map(t=>({runtime:t,name:t.display_name,auth:qe(t),quarantined:!!t.quarantined})),runsOn:{by:n.by,name:n.runtime?.display_name??null}}}import{useCallback as Hr,useEffect as Ba,useMemo as Dr,useSyncExternalStore as Ga}from"react";function bn(e={}){let{compute:n,connect:t}=Q(),{value:r,onChange:o,defaultValue:a,remember:s=!0,user:c}=e,i=r!==void 0,l=s&&!i?pr(t.publishableKey,c):null,u=Hr(R=>Er(l,R),[l]),m=Ga(u,Hr(()=>Bt(l),[l]),Ir),b=Dr(()=>Zn(n.machines),[n.machines]),g=Dr(()=>Xn(b),[b]);Ba(()=>{i||!a||Or(l,a)},[i,a,l]);let h=i?r:m??a??null,{selected:y,unavailable:N}=Dr(()=>_t(b,h??null),[b,h]),P=Hr(R=>{i||Lr(l,R),o?.(R)},[i,l,o]);return{options:b,groups:g,selected:y,select:P,run:$t(y),unavailable:N,pickable:mn(b),loading:n.loading&&!n.machines.length}}import{jsx as ct}from"react/jsx-runtime";function Wa({className:e}){let{theme:n}=H(),t=e?`soba-connect ${e}`:"soba-connect";return ct("div",{className:t,"data-theme":n,children:ct(Ur,{})})}function Ur(){let e=lt(),n=bn();return e.view==="loading"?ct("p",{className:"sc-note",children:"Loading\u2026"}):e.view==="error"?ct("p",{className:"sc-error",children:e.error?.message}):ct($n,{machines:e.machines.map(t=>t.machine),model:n.selected,onPickModel:n.select})}import{useCallback as dt,useEffect as Jr,useMemo as Ya,useRef as Yr,useState as Ln}from"react";import{useId as Ha}from"react";import{jsx as On,jsxs as Gt}from"react/jsx-runtime";function ut({open:e,onOpenChange:n,initialCode:t,onConnected:r,showStatus:o,reason:a}){let{error:s}=Q(),c=In(),i=H(),l=()=>n(!1),u=Ha(),m=i.context?.background?.trim(),b=m?cn(m,i.context?.accent):void 0;return Gt(st,{open:e,onClose:l,labelledBy:u,theme:i.theme,style:b,children:[s?Gt("div",{className:"sc-card",children:[On("h2",{className:"sc-title",id:u,children:"Could not start"}),On("p",{className:"sc-error",children:s.message})]}):!c&&!i.context?Gt("div",{className:"sc-card",children:[On("h2",{className:"sc-title",id:u,children:"One moment"}),On("p",{className:"sc-note",children:"Getting your compute\u2026"})]}):On(Cr,{client:c,active:e,onClose:l,headingId:u,theme:i.theme,initialContext:i.context,...i.machines!==void 0?{initialMachines:i.machines}:{},...t?{initialCode:t}:{},...r?{onConnected:r}:{},...o===void 0?{}:{showStatus:o},...a?{reason:a}:{}}),Gt("p",{className:"sc-modal-foot",children:[On(q,{className:"sc-foot-mark"}),"Secured by Soba"]})]})}import{forwardRef as Da}from"react";import{jsx as Ua}from"react/jsx-runtime";var Fr=Da(function(n,t){let{theme:r}=H();return Ua(Nr,{ref:t,"data-theme":r,...n})});import{useCallback as Fa}from"react";function Qa(){let{connect:e}=Q(),n=lt(),t=Fa(()=>e.open("manual"),[e]);return{...Mn(n.primary?.machine??null),machine:n.primary,open:t,canOpen:e.hasModal,loading:n.view==="loading"}}function Qr(e){return Mn(e)}import{useCallback as Go,useEffect as Va,useState as Ja}from"react";function Vr({enabled:e=!0,intervalMs:n=3e3}={}){let t=In(),[r,o]=Ja(null),a=Go(async()=>{t&&o(await t.runs())},[t]);Va(()=>{if(!e||!t)return;let c=!0,i=Me(async()=>{let l=await t.runs();c&&o(l)},n);return()=>{c=!1,i()}},[e,t,n]);let s=Go(async c=>{if(!t)throw new Error("Stopping a run needs <SobaProvider>.");await t.stopRun(c),await a().catch(()=>{})},[t,a]);return{runs:r,refresh:a,stop:s}}import{Fragment as Wo,jsx as Tn,jsxs as Ho}from"react/jsx-runtime";function yn({children:e,variant:n,className:t,initialCode:r,onConnected:o,defaultOpen:a,open:s,onOpenChange:c,showConnected:i=!0}){let{compute:l,connect:u}=Q(),m=H(),{theme:b}=m,g=In(),[h,y]=Ln(a??!!r),N=Yr(null),P=s!==void 0,R=!P&&!a&&!r&&u.hasModal,W=P?s:R?u.isOpen:h,E=B=>{R?B?u.open("manual"):u.close():P||y(B),c?.(B)},I=Yr(W);Jr(()=>{I.current&&!W&&N.current?.focus(),I.current=W},[W]);let[O,k]=Ln(!1),{runs:U,stop:pe}=Vr({enabled:O}),ne=bn(),ae=Ya(()=>O&&U?ja(l.machines,U):l.machines,[l.machines,O,U]),Z=We(ae),me=i&&Qr(Z).connected,Ye=dt(()=>k(!1),[]),[$,ye]=Ln(!1),Se=dt(async()=>{ye(!0);try{await l.refresh()}finally{ye(!1)}},[l]),X=Yr(Se);X.current=Se,Jr(()=>{O&&X.current()},[O]);let[ie,z]=Ln(!1),[Pe,he]=Ln([]),fe=!!m.context?.hosted_available;Jr(()=>{if(!O||!g||!fe)return;let B=!0;return g.hosted().then(x=>{B&&he(x.credentials)}).catch(()=>{}),()=>{B=!1}},[O,g,fe]);let[nn,V]=Ln(null),J=dt(async(B,x)=>{if(g){V(null);try{await g.approveRuntime(B,x),await l.refresh()}catch(tn){V(tn.message)}}},[g,l]),te=dt(async(B,x)=>{if(g){V(null);try{await g.preferRuntime(B,x),await l.refresh()}catch(tn){V(tn.message)}}},[g,l]),T=dt(async B=>{if(g){V(null);try{await g.disconnectHosted(B),he((await g.hosted()).credentials)}catch(x){V(x.message)}}},[g]),le=m.context?.background?.trim(),Re=le?cn(le,m.context?.accent):void 0,ce=me&&!e,L=()=>{if(ce&&!P&&!a&&!r){k(B=>!B);return}E(!0)};return Ho(Wo,{children:[ce?Tn(Fr,{ref:N,machine:Z,"aria-haspopup":"dialog","aria-expanded":O,onClick:L,...t?{className:t}:{}}):Tn("button",{ref:N,type:"button","data-theme":b,className:["sc-btn","sc-btn-icon",n==="primary"?"sc-btn-primary":"",t].filter(Boolean).join(" "),onClick:L,children:e??Ho(Wo,{children:[Tn(q,{className:"sc-btn-mark"}),"Connect compute"]})}),Tn(Pr,{open:O,onClose:Ye,anchor:N,label:"Your compute",theme:b,...Re?{style:Re}:{},children:Tn(fn,{machines:ae,hosted:Pe,onApproveRuntime:(B,x)=>void J(B,x),onPreferRuntime:(B,x)=>void te(B,x),onDisconnectHosted:B=>void T(B),onRefresh:()=>void Se(),refreshing:$,model:ne.selected,onPickModel:ne.select,error:nn,runs:U,onStopRun:async B=>{V(null);try{await pe(B)}catch(x){throw V(x.message),x}},onPair:()=>{k(!1),R?u.open("pair"):(z(!0),E(!0))},...m.context?.app.name?{appName:m.context.app.name}:{}})}),!R&&Tn(ut,{open:W,onOpenChange:B=>{B||z(!1),E(B)},...ie?{showStatus:!1}:{},...r?{initialCode:r}:{},...o?{onConnected:o}:{}})]})}function ja(e,n){return e.map(t=>{if(t.state==="offline")return t;let r=n.filter(o=>o.machine_id===t.id).length;return{...t,active:r,state:r>0?"busy":"online"}})}import{jsx as jr,jsxs as qa}from"react/jsx-runtime";function za({initialCode:e,onConnected:n,className:t,showStatus:r=!0}){let{theme:o}=H();return qa("div",{className:t?`soba-connect ${t}`:"soba-connect","data-theme":o,children:[r&&jr(Ur,{}),jr("div",{className:"sc-compute-act",children:jr(yn,{...e?{initialCode:e}:{},...n?{onConnected:n}:{}})})]})}import{useId as ai,useState as ii}from"react";import{useCallback as qr,useEffect as Vo,useState as Jo}from"react";import{useCallback as Za,useState as Xa}from"react";function pt(){let[e,n]=Xa(null);return{open:Za(()=>{n(null),zn().then(n)},[]),launch:e,note:e==="absent"?"Nothing opened here. That machine may be a different computer, or asleep.":null}}import{useCallback as Do,useMemo as Uo}from"react";function wn(e){if(!e)return null;if(typeof e=="string")return e;if(typeof Response<"u"&&e instanceof Response)return Fo(e.status);let n=e,t=n.error;return typeof t?.code=="string"?t.code:typeof t?.type=="string"?t.type:typeof n.code=="string"?n.code:typeof n.status=="number"?Fo(n.status):n.cause&&n.cause!==e?wn(n.cause):null}function Fo(e){return e===402?"payment_required":e===409?"no_compute":null}function zr(...e){let[n,t]=e,{plan:r,compute:o,connect:a}=Q(),s=t?.predict??e.length===0,c=_a(Ka(n),o)??(s?$a(r,o):null),i=r.plan,l=r.plans,u=Uo(()=>{if(c!=="payment_required")return null;let h=i?.price??0,y=i?.included_units??0;return l.find(N=>N.id!==i?.id&&N.price>h&&(N.included_units===null||N.included_units>y))??null},[c,l,i]),m=Do(async()=>{if(!u)return;if(u.selectable){await r.select(u.id);return}let h=await r.checkout(u.id);window.location.assign(h)},[u,r]),b=a.open,g=Do(()=>{c&&b(c)},[b,c]);return Uo(()=>{if(!c)return null;let h=i?Ve({unit:i.unit,reward:i.connected_reward,includedUnits:i.connected_included_units,creditMicros:i.connected_credit*1e6}):null,y=i&&Je(i.connected_reward)?h:null;return{reason:c,...ei(c,{connectOffer:y,connected:o.connected,online:o.online,machine:un(o.machines)?.label??null,unit:i?.unit??"message",interval:i?.interval??"month",upgrade:u!==null,resets:r.current?.period_end??null}),connectOffer:y,upgradeTo:u,connect:g,upgrade:m}},[c,i,o,u,g,m,r.current?.period_end])}function Ka(e){let n=wn(e);return n==="payment_required"||n==="no_compute"?n:null}function _a(e,n){return e==="no_compute"&&n.connected&&n.online?null:e}function $a(e,n){let t=e.plan;return!t||n.loading?null:Le(t.route_allow)&&!n.online?"no_compute":e.remaining===0&&t.overage==="stop"?"payment_required":null}function ei(e,n){if(e==="payment_required"){let t=`No ${n.unit}s left this ${n.interval}`;return n.connectOffer&&!n.connected?{title:t,body:`${n.connectOffer}. Connecting takes a minute and costs nothing.`}:n.connectOffer&&!n.online?{title:t,body:`${n.connectOffer}. Waking ${n.machine??"your machine"} is enough.`}:n.upgrade?{title:t,body:n.resets?`A larger plan carries on now. This one comes back on ${Qo(n.resets)}.`:"A larger plan carries on now, or wait for this one to renew."}:{title:t,body:n.resets?`Your allowance comes back on ${Qo(n.resets)}.`:"Your allowance comes back at the start of the next period."}}return n.connected&&!n.online?{title:`${n.machine??"Your machine"} can't be reached`,body:"This run needs it awake and connected. Open Soba App on that machine, or connect another one."}:{title:"Nothing connected yet",body:"This app runs on AI you already pay for, on a machine of your own. Connect one and this run has somewhere to go."}}function Qo(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}function ni(e){let{plan:n,allowance:t,connected:r,online:o,quiet:a,error:s,predict:c,at:i,waved:l}=e;if(!n)return null;let u=e.allow!==void 0?e.allow:n.route_allow;if(r){if(o)return null;let y=Le(u);return{reason:"stalled",title:`${a??"Your machine"} can\u2019t be reached`,detail:y?"The Soba app there has stopped reporting in, so runs have nowhere to go until it is back.":"The Soba app there has stopped reporting in, so nothing will run on your own AI until it is back.",meter:null,dismissible:!1,atTheWall:!1,ownCompute:y}}let m=wn(s),b=m==="payment_required"||m==="no_compute",g=n.ask_to_connect!==!1&&Tr(n.route_prefer,u);if(!c&&!b&&!g)return null;let h=Le(u)?ti(n.unit,Le(n.route_allow)):Je(n.connected_reward)?oi(t,n,i):g?ri(n.unit):null;return!h||h.dismissible&&l?null:{...h,dismissible:!!h.dismissible,ownCompute:!1,atTheWall:!h.dismissible&&(!c||h.meter!==null&&h.meter.left===0)}}function Zr(e={}){let{at:n=.25,error:t,allow:r}=e,o=e.predict??!(e.errorGiven??t!==void 0),{plan:a,compute:s,connect:c}=Q(),i=hr(c.publishableKey),[l,u]=Jo(!1);Vo(()=>{u(fr(i))},[i]);let m=qr(()=>{u(!0),gr(i)},[i]),b=qr(()=>c.open("manual"),[c]),g=qr(()=>c.open("no_compute"),[c]),h=pt(),[y,N]=Jo(!1),{refresh:P}=s,{launch:R}=h;Vo(()=>{if(R===null||R==="absent")return;N(!1);let k=setInterval(()=>void P(),3e3),U=setTimeout(()=>{clearInterval(k),N(!0)},2e4);return()=>{clearInterval(k),clearTimeout(U)}},[R,P]);let W=si(c.app?.name,rt(c.connectUrl)),E=a.loading||s.loading,I=un(s.machines),O=E?null:ni({plan:a.plan,allowance:{remaining:a.remaining,included:a.included},connected:s.connected,online:s.online,quiet:I?_(I):null,error:t,predict:o,...r!==void 0?{allow:r}:{},at:n,waved:l});return{reason:O?.reason??null,visible:O!==null,title:O?.title??null,detail:O?.detail??null,meter:O?.meter??null,dismissible:O?.dismissible??!1,dismissed:l,dismiss:m,open:b,atTheWall:O?.atTheWall??!1,steps:W,stalled:O?.reason==="stalled"?{machine:I?_(I):null,ownCompute:O.ownCompute,wake:h.open,launch:h.launch,note:h.note,stuck:y,connectAnother:g}:null,loading:E}}function ti(e,n){return{reason:"needed",title:n?"This plan runs on your own AI.":`These ${e}s run on your own AI.`,detail:`Connect a machine and your ${e}s run there, free, on access you already have.`,meter:null}}function ri(e){return{reason:"preferred",title:"This plan prefers your own AI.",detail:`Connect a machine and your ${e}s run there instead, on access you already have.`,meter:null,dismissible:!0}}function oi(e,n,t){let{remaining:r,included:o}=e;if(r===null||o===null||o===0||r>Math.ceil(o*t))return null;let a=Ve({unit:n.unit,reward:n.connected_reward,includedUnits:n.connected_included_units,creditMicros:n.connected_credit*1e6});return a?{reason:"running",title:r===0?`No ${n.unit}s left this month.`:`${r} ${n.unit}${r===1?"":"s"} left this month.`,detail:`${a}.`,meter:{left:r,of:o}}:null}function si(e,n){return[{lead:"Download Soba App",detail:"",...n?{linksLead:"Get it for"}:{},links:n?tt.map(t=>({label:t.label,href:`${n}/download/${t.slug}`})):[]},{lead:"Connect compute",detail:"Press this, then approve the pairing when the app asks.",opens:!0,links:[]},{lead:"Let your AIs serve",detail:`It finds what is installed on that machine. Allow one, and ${e??"this app"} sends every run there.`,linksLead:"Nothing on it yet?",links:Ae.map(t=>({label:t.short,href:t.install}))}]}import{Fragment as jo,jsx as G,jsxs as _e}from"react/jsx-runtime";function li(e){let{className:n,fallback:t=null}=e,r=Zr({...e.at===void 0?{}:{at:e.at},...e.predict===void 0?{}:{predict:e.predict},...e.allow===void 0?{}:{allow:e.allow},error:e.error,errorGiven:"error"in e}),{connect:o}=Q(),{theme:a}=H(),[s,c]=ii(null),i=ai(),l=G(jo,{children:t});if(!r.visible)return l;if(r.stalled)return G(Yo,{className:n,theme:a,stalled:!0,children:G(ci,{title:r.title??"",detail:r.detail??"",stalled:r.stalled})});let u=s??r.atTheWall;return _e(Yo,{className:n,theme:a,children:[_e("div",{className:"sc-nudge-top",children:[_e("div",{className:"sc-nudge-say",children:[G("p",{className:"sc-nudge-title",children:r.title}),G("p",{className:"sc-nudge-detail",children:r.detail}),_e("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more","aria-expanded":u,"aria-controls":i,onClick:()=>c(!u),children:[u?"Hide the details":"How it works",G(di,{})]})]}),r.dismissible?G("button",{type:"button",className:"sc-nudge-dismiss","aria-label":"Dismiss",title:"Dismiss",onClick:r.dismiss,children:G(ui,{})}):null]}),u?G("ol",{className:"sc-nudge-steps",id:i,children:r.steps.map(m=>_e("li",{children:[m.opens?G("button",{type:"button",className:"sc-step-lead",onClick:()=>o.open("manual"),children:m.lead}):G("strong",{children:m.lead}),m.detail?G("span",{children:m.detail}):null,m.links.length>0?_e("span",{className:"sc-step-links",children:[m.linksLead,m.links.map(b=>G("a",{href:b.href,target:"_blank",rel:"noreferrer noopener",children:b.label},b.href))]}):null]},m.lead))}):null,G(yn,{variant:"primary"})]})}function Yo({className:e,theme:n,stalled:t,children:r}){return G("div",{className:e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill","data-theme":n,children:G("div",{className:t?"sc-nudge sc-nudge-stalled":"sc-nudge",children:r})})}function ci({title:e,detail:n,stalled:t}){return _e(jo,{children:[G("div",{className:"sc-nudge-top",children:_e("div",{className:"sc-nudge-say",children:[G("p",{className:"sc-nudge-title",children:e}),G("p",{className:"sc-nudge-detail",children:n}),t.note&&G("p",{className:"sc-nudge-note",children:t.note}),t.stuck&&G("p",{className:"sc-nudge-note",children:"The Soba app is open, but this machine still isn\u2019t reporting in. It may no longer be connected to this app."}),(t.launch==="absent"||t.stuck)&&G("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more",onClick:t.connectAnother,children:t.stuck?"Connect it again":"Connect another machine"})]})}),G("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:t.wake,children:"Open Soba App"})]})}function ui(){return G("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-x",children:G("path",{d:"m4.8 4.8 6.4 6.4M11.2 4.8l-6.4 6.4",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function di(){return G("svg",{viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",className:"sc-nudge-chev",children:G("path",{d:"M4.5 6.5 8 10l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}var pi=new Set(["delta","thinking","status","done","error"]);function Bn(e){let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!="object")return null;let t=n,r=t.type==="event"?t.event:t;if(!r||typeof r!="object")return null;let o=r;if(typeof o.type!="string"||!pi.has(o.type))return null;let a={type:o.type};return typeof o.text=="string"&&(a.text=o.text),typeof o.message=="string"&&(a.message=o.message),typeof o.tool=="string"&&(a.tool=o.tool),typeof o.tier=="string"&&(a.tier=o.tier),o.usage&&typeof o.usage=="object"&&(a.usage=o.usage),typeof o.session=="string"&&(a.session=o.session),typeof o.toolInput=="string"&&(a.toolInput=o.toolInput),o.git&&typeof o.git=="object"&&(a.git=o.git),o.turn&&typeof o.turn=="object"&&typeof o.turn.text=="string"&&(a.turn={text:o.turn.text}),typeof o.reason=="string"&&(a.reason=o.reason),typeof o.retryable=="boolean"&&(a.retryable=o.retryable),(o.state==="interrupted"||o.state==="resumed")&&(a.state=o.state),a}async function*Xr(e){let n=e.body;if(!n)throw new Error("That run response had no body to stream.");let t=(e.headers.get("content-type")??"").includes("ndjson"),r=n.getReader(),o=new TextDecoder,a="",s=[];try{for(;;){let i=await r.read();if(i.done)break;for(a+=o.decode(i.value,{stream:!0});;){let l=a.indexOf(`
3
+ `);if(l===-1)break;let u=qo(a.slice(0,l));if(a=a.slice(l+1),t){let m=u.trim()?Bn(u):null;m&&(yield m);continue}if(u===""){let m=s.join(`
4
+ `);if(s=[],m==="[DONE]")return;let b=m?Bn(m):null;b&&(yield b);continue}zo(u,s)}}!t&&a&&zo(qo(a),s);let c=t?a.trim():s.join(`
5
+ `);if(c&&c!=="[DONE]"){let i=Bn(c);i&&(yield i)}}finally{r.cancel().catch(()=>{})}}function zo(e,n){if(!e||e.startsWith(":"))return;let t=e.indexOf(":");if(t===-1||e.slice(0,t)!=="data")return;let r=e.slice(t+1);n.push(r.startsWith(" ")?r.slice(1):r)}function qo(e){return e.endsWith("\r")?e.slice(0,-1):e}async function mi(e){let n="";for await(let t of e)if(t.type==="delta"&&t.text&&(n+=t.text),t.type==="error")throw new Error(t.message??"The run ended with an error.");return n}import{jsx as Zo}from"react/jsx-runtime";function hi({caption:e,disabled:n,className:t,...r}){let{theme:o}=H(),{options:a,selected:s,select:c,pickable:i}=bn(r);return i?Zo("span",{className:"soba-connect sc-inline","data-theme":o,children:Zo(Kn,{options:a,selected:s,onPick:c,...e?{caption:e}:{},...n?{disabled:n}:{},...t?{className:t}:{}})}):null}import{useEffect as fi}from"react";var Xo="data-soba-react",Ko=!1;function mt(){if(Ko||typeof document>"u"||(Ko=!0,document.querySelector(`style[${Xo}]`)))return;let e=document.createElement("style");e.setAttribute(Xo,""),e.textContent=`.soba-connect {
6
6
  --sc-ground: #ffffff;
7
7
  --sc-sheet: #ffffff;
8
8
  --sc-raised: #f6f6f7;
@@ -16,9 +16,14 @@ import{useRef as ps,useState as so}from"react";var Cn=class extends Error{status
16
16
  --sc-ok: #22a06b;
17
17
  --sc-warn: #b06f14;
18
18
 
19
- --sc-tray: var(--sc-raised, #f6f6f7);
19
+ --sc-danger: #c2452d;
20
+
21
+ --sc-warn-dot: #d9a21b;
22
+
23
+
24
+ --sc-tray: #f3f3f2;
20
25
  --sc-tray-card: var(--sc-sheet, #ffffff);
21
- --sc-tray-sunk: var(--sc-raised, #f6f6f7);
26
+ --sc-tray-sunk: #efefed;
22
27
 
23
28
  --sc-font-size: 15px;
24
29
  --sc-fs-label: max(11px, calc(var(--sc-font-size) * 0.77));
@@ -48,9 +53,6 @@ import{useRef as ps,useState as so}from"react";var Cn=class extends Error{status
48
53
 
49
54
  box-sizing: border-box;
50
55
 
51
- width: 100%;
52
- max-width: 560px;
53
- margin: 0 auto;
54
56
  color: var(--sc-text, #1a1a1c);
55
57
  font-family: var(
56
58
  --sc-font,
@@ -66,6 +68,12 @@ import{useRef as ps,useState as so}from"react";var Cn=class extends Error{status
66
68
  line-height: 1.5;
67
69
  letter-spacing: -0.005em;
68
70
  }
71
+
72
+ :where(.soba-connect) {
73
+ width: 100%;
74
+ max-width: 560px;
75
+ margin: 0 auto;
76
+ }
69
77
  .soba-connect *,
70
78
  .soba-connect *::before,
71
79
  .soba-connect *::after {
@@ -201,10 +209,6 @@ a.sc-btn {
201
209
  color: var(--sc-muted, #6b6b73);
202
210
  }
203
211
 
204
- .sc-tone-absent {
205
- color: var(--sc-faint, #a1a1aa);
206
- }
207
-
208
212
  .sc-error {
209
213
  color: var(--sc-warn, #b06f14);
210
214
  font-size: var(--sc-fs-body);
@@ -253,10 +257,11 @@ a.sc-btn {
253
257
 
254
258
  .sc-tray {
255
259
  display: grid;
256
- gap: 8px;
257
- padding: 6px;
258
- border-radius: 18px;
259
- background: var(--sc-tray, #f6f6f7);
260
+
261
+ gap: 20px;
262
+ padding: 20px;
263
+ border-radius: 24px;
264
+ background: var(--sc-tray, #f3f3f2);
260
265
  }
261
266
 
262
267
  .sc-group {
@@ -267,8 +272,9 @@ a.sc-btn {
267
272
  display: flex;
268
273
  align-items: center;
269
274
  gap: 4px;
270
- min-height: 24px;
271
- padding: 0 2px 3px 12px;
275
+ min-height: 22px;
276
+
277
+ padding: 0 0 8px 4px;
272
278
  }
273
279
 
274
280
  .sc-cap-acts {
@@ -285,24 +291,27 @@ a.sc-btn {
285
291
  overflow: hidden;
286
292
  text-overflow: ellipsis;
287
293
  white-space: nowrap;
288
- font-size: var(--sc-fs-label);
294
+ font-size: 14px;
289
295
  letter-spacing: 0;
290
296
  color: var(--sc-muted, #6b6b73);
291
297
  }
292
298
 
293
299
  .sc-group-card {
294
- padding: 6px 0 6px 12px;
295
- border-radius: var(--sc-r-lg, 14px);
300
+ padding: 7px 0 7px 12px;
301
+ border-radius: 18px;
296
302
  background: var(--sc-tray-card, #ffffff);
297
- box-shadow: var(--sc-shadow-1);
303
+ box-shadow:
304
+ var(--sc-shadow-1),
305
+ inset 0 0 0 1px color-mix(in srgb, var(--sc-line, #e9e9eb) 70%, transparent);
298
306
  }
299
307
 
300
308
  .sc-disc {
301
309
  flex: none;
302
310
  display: grid;
303
311
  place-items: center;
304
- width: 26px;
305
- height: 26px;
312
+
313
+ width: 36px;
314
+ height: 36px;
306
315
  padding: 0;
307
316
  border: 0;
308
317
  border-radius: 50%;
@@ -340,9 +349,9 @@ a.sc-btn {
340
349
  .sc-mrow {
341
350
  display: flex;
342
351
  align-items: center;
343
- gap: 10px;
352
+ gap: 14px;
344
353
  min-height: 52px;
345
- padding: 4px 12px 4px 0;
354
+ padding: 7px 16px 7px 4px;
346
355
  }
347
356
 
348
357
  .sc-mtile {
@@ -350,27 +359,29 @@ a.sc-btn {
350
359
  flex: none;
351
360
  display: grid;
352
361
  place-items: center;
353
- width: 38px;
354
- height: 38px;
362
+ width: 44px;
363
+ height: 44px;
364
+
355
365
  border-radius: 12px;
356
- background: var(--sc-tray-sunk, #f6f6f7);
357
- box-shadow: inset 0 0 0 1px var(--sc-line, #e9e9eb);
358
- color: var(--sc-text, #1a1a1c);
366
+
367
+ background: var(--sc-tray-sunk, #efefed);
368
+ color: var(--sc-text, #1b1b1a);
359
369
  }
360
370
 
361
371
  .sc-mglyph {
362
372
  width: 24px;
363
- height: 18px;
373
+ height: 19px;
364
374
  }
365
375
 
366
376
  .sc-mbadge {
367
377
  position: absolute;
368
- right: 0;
369
- bottom: 0;
370
- width: 10px;
371
- height: 10px;
378
+ left: auto;
379
+ bottom: -3px;
380
+ right: -3px;
381
+ width: 14px;
382
+ height: 14px;
372
383
  border-radius: 50%;
373
- transform: translate(30%, 30%);
384
+ transform: none;
374
385
  box-shadow: 0 0 0 2.5px var(--sc-tray-card, #ffffff);
375
386
  }
376
387
 
@@ -386,34 +397,51 @@ a.sc-btn {
386
397
  background: var(--sc-line-2, #dcdce0);
387
398
  }
388
399
 
400
+ .sc-mbadge-away {
401
+ background: var(--sc-warn-dot, #d9a21b);
402
+ }
403
+
389
404
  .sc-mid {
390
405
  display: flex;
391
406
  flex: 1;
392
407
  min-width: 0;
393
408
  flex-direction: column;
394
- gap: 1px;
409
+ gap: 2px;
395
410
  }
396
411
 
397
412
  .sc-mname {
398
413
  overflow: hidden;
399
414
  text-overflow: ellipsis;
400
415
  white-space: nowrap;
401
- font-size: var(--sc-fs-small);
402
- font-weight: 550;
416
+ font-size: 16px;
417
+ font-weight: 600;
403
418
  }
404
419
 
405
420
  .sc-mmeta {
406
421
  display: flex;
407
- flex-wrap: wrap;
408
- align-items: center;
409
- gap: 1px 6px;
410
- font-size: var(--sc-fs-label);
422
+ align-items: baseline;
423
+ gap: 10px;
424
+ font-size: 14px;
411
425
  line-height: 1.35;
412
426
  color: var(--sc-muted, #6b6b73);
413
427
  }
414
428
 
429
+ .sc-mmeta-is {
430
+ min-width: 0;
431
+ overflow: hidden;
432
+ text-overflow: ellipsis;
433
+ white-space: nowrap;
434
+ }
435
+
436
+ .sc-mmeta-now {
437
+ flex: none;
438
+ margin-left: auto;
439
+ color: var(--sc-text-2, #3f3f46);
440
+ font-variant-numeric: tabular-nums;
441
+ }
442
+
415
443
  .sc-mmeta-sep {
416
- padding-right: 6px;
444
+ padding: 0 6px;
417
445
  color: var(--sc-line-2, #dcdce0);
418
446
  }
419
447
 
@@ -451,41 +479,295 @@ a.sc-btn {
451
479
  transform: rotate(90deg);
452
480
  }
453
481
 
482
+ .sc-group-card:has(> .sc-rrow) {
483
+ padding: 0 16px;
484
+ }
454
485
  .sc-rrow {
455
486
  display: flex;
456
- align-items: flex-start;
457
- gap: 10px;
458
- padding: 6px 12px 6px 0;
487
+ align-items: center;
488
+ gap: 14px;
489
+ padding: 14px 0;
459
490
  }
460
-
461
- .sc-rrow .sc-runtime-tile {
462
- margin-top: 1px;
491
+ .sc-rrow + .sc-rrow {
492
+ box-shadow: inset 0 1px 0 var(--sc-line, #e9e9e7);
463
493
  }
464
-
465
- .sc-rtop {
466
- display: flex;
467
- align-items: baseline;
468
- gap: 8px;
494
+ .sc-rdot {
495
+ flex: none;
496
+ width: 10px;
497
+ height: 10px;
498
+ border-radius: 50%;
499
+ background: var(--sc-line-2, #dcdce0);
469
500
  }
470
-
471
- .sc-rtop .sc-averdict {
472
- font-variant-numeric: tabular-nums;
501
+ .sc-rdot-live {
502
+ background: var(--sc-ok, #1e8e5a);
503
+ }
504
+ @media (prefers-reduced-motion: no-preference) {
505
+ .sc-rdot-live {
506
+ animation: sc-breathe 1.6s ease-in-out infinite;
507
+ }
508
+ }
509
+ @keyframes sc-breathe {
510
+ 0%,
511
+ 100% {
512
+ opacity: 1;
513
+ }
514
+ 50% {
515
+ opacity: 0.35;
516
+ }
517
+ }
518
+ .sc-rtitle {
519
+ overflow: hidden;
520
+ text-overflow: ellipsis;
521
+ white-space: nowrap;
522
+ font-size: 15px;
523
+ font-weight: 500;
473
524
  }
474
525
 
475
526
  .sc-rstop {
476
- align-self: center;
477
- width: 24px;
478
- height: 24px;
527
+ flex: none;
528
+ display: grid;
529
+ place-items: center;
530
+ width: 44px;
531
+ height: 44px;
532
+ margin: -8px -10px -8px 0;
533
+ padding: 0;
534
+ border: 0;
535
+ border-radius: 50%;
536
+ background: transparent;
537
+ color: var(--sc-muted, #6b6b69);
538
+ cursor: pointer;
479
539
  }
480
540
 
541
+ .sc-rstop-ring {
542
+ display: grid;
543
+ place-items: center;
544
+ width: 28px;
545
+ height: 28px;
546
+ border-radius: 50%;
547
+ box-shadow: inset 0 0 0 1px var(--sc-line, #e9e9e7);
548
+ transition:
549
+ background-color 120ms ease,
550
+ box-shadow 120ms ease,
551
+ color 120ms ease;
552
+ }
553
+ .sc-rstop:hover:not(:disabled) {
554
+ color: var(--sc-text, #1b1b1a);
555
+ }
556
+ .sc-rstop:hover:not(:disabled) .sc-rstop-ring {
557
+ background: var(--sc-tray-sunk, #efefed);
558
+ box-shadow: inset 0 0 0 1px transparent;
559
+ }
560
+ .sc-rstop .sc-dglyph {
561
+ width: 10px;
562
+ height: 10px;
563
+ }
564
+ .sc-rstop:disabled {
565
+ cursor: default;
566
+ opacity: 0.5;
567
+ }
481
568
  .sc-rstep {
482
569
  display: -webkit-box;
483
570
  overflow: hidden;
484
571
  -webkit-box-orient: vertical;
485
572
  -webkit-line-clamp: 2;
486
- font-size: var(--sc-fs-label);
573
+ line-clamp: 2;
574
+ font-size: 13px;
487
575
  line-height: 1.4;
488
- color: var(--sc-muted, #6b6b73);
576
+ color: var(--sc-muted, #6b6b69);
577
+ font-variant-numeric: tabular-nums;
578
+ }
579
+
580
+ .sc-blank {
581
+ display: flex;
582
+ flex-direction: column;
583
+ align-items: center;
584
+ gap: 12px;
585
+ padding: 24px 24px 26px;
586
+ text-align: center;
587
+ }
588
+ .sc-blank-mark {
589
+ display: grid;
590
+ place-items: center;
591
+ width: 44px;
592
+ height: 44px;
593
+ border-radius: 50%;
594
+ background: var(--sc-tray-sunk, #efefed);
595
+ color: var(--sc-faint, #8c8c89);
596
+ }
597
+ .sc-blank-glyph {
598
+ width: 20px;
599
+ height: 20px;
600
+ }
601
+ .sc-blank-say {
602
+ display: flex;
603
+ flex-direction: column;
604
+ gap: 4px;
605
+ }
606
+ .sc-blank-title {
607
+ font-size: 16px;
608
+ font-weight: 600;
609
+ }
610
+ .sc-blank-body {
611
+ font-size: 14px;
612
+ line-height: 20px;
613
+ color: var(--sc-muted, #6b6b69);
614
+ }
615
+
616
+ .sc-blank-act {
617
+ display: inline-flex;
618
+ align-items: center;
619
+ gap: 7px;
620
+ height: 36px;
621
+ padding: 0 14px;
622
+ border: 1px solid var(--sc-line, #e6e6e3);
623
+ border-radius: 11px;
624
+ color: var(--sc-text, #1b1b1a);
625
+ font-size: 14px;
626
+ font-weight: 600;
627
+ text-decoration: none;
628
+ transition: background 120ms ease;
629
+ }
630
+ .sc-blank-act:hover {
631
+ background: var(--sc-tray-sunk, #efefed);
632
+ }
633
+
634
+ .sc-alarm {
635
+ display: flex;
636
+ align-items: flex-start;
637
+ gap: 14px;
638
+ margin: -7px -0 -7px -12px;
639
+ padding: 16px;
640
+ border-radius: 18px;
641
+ background: color-mix(in srgb, var(--sc-danger, #c2452d) 9%, var(--sc-tray-card, #ffffff));
642
+ }
643
+
644
+ .sc-alarm-mark {
645
+ flex: none;
646
+ display: grid;
647
+ place-items: center;
648
+ width: 30px;
649
+ margin-top: 1px;
650
+ color: var(--sc-danger, #c2452d);
651
+ }
652
+ .sc-alarm-mark .sc-hglyph {
653
+ width: 22px;
654
+ height: 22px;
655
+ }
656
+
657
+ .sc-alarm-warn {
658
+ background: color-mix(in srgb, var(--sc-warn, #b06f14) 10%, var(--sc-tray-card, #ffffff));
659
+ }
660
+ .sc-alarm-warn .sc-alarm-mark {
661
+ color: var(--sc-warn, #b06f14);
662
+ }
663
+ .sc-alarm + .sc-alarm {
664
+ margin-top: 8px;
665
+ }
666
+ .sc-alarm-say {
667
+ display: flex;
668
+ flex-direction: column;
669
+ gap: 4px;
670
+ min-width: 0;
671
+ }
672
+ .sc-alarm-title {
673
+ font-size: 16px;
674
+ font-weight: 600;
675
+ }
676
+ .sc-alarm-body {
677
+ font-size: 14px;
678
+ line-height: 20px;
679
+ color: var(--sc-text-2, #5a4a46);
680
+ }
681
+
682
+ .sc-blank-soba {
683
+ display: grid;
684
+ place-items: center;
685
+ color: var(--sc-text, #1b1b1a);
686
+ }
687
+ .sc-blank-soba-mark {
688
+ width: 48px;
689
+ height: 48px;
690
+ }
691
+
692
+ .sc-cap-link {
693
+ flex: none;
694
+ margin: -8px -4px -8px 0;
695
+ padding: 8px 4px;
696
+ border: 0;
697
+ background: transparent;
698
+ font: inherit;
699
+ font-size: 13px;
700
+ color: var(--sc-text-2, #3f3f46);
701
+ text-decoration: underline;
702
+ text-underline-offset: 2px;
703
+ cursor: pointer;
704
+ }
705
+ .sc-cap-link:hover {
706
+ color: var(--sc-text, #1b1b1a);
707
+ }
708
+
709
+ .sc-acts {
710
+ display: flex;
711
+ flex-direction: column;
712
+ gap: 4px;
713
+ }
714
+ .sc-act-go {
715
+ display: flex;
716
+ align-items: center;
717
+ justify-content: center;
718
+ gap: 9px;
719
+ height: 48px;
720
+ border: 0;
721
+ border-radius: 14px;
722
+ background: var(--sc-accent, #1b1b1a);
723
+ color: var(--sc-accent-fg, #ffffff);
724
+ font: inherit;
725
+ font-size: 15px;
726
+ font-weight: 600;
727
+ cursor: pointer;
728
+ transition: opacity 120ms ease;
729
+ }
730
+ .sc-act-go:hover:not(:disabled) {
731
+ opacity: 0.88;
732
+ }
733
+ .sc-act-quiet {
734
+ display: flex;
735
+ align-items: center;
736
+ justify-content: center;
737
+ gap: 8px;
738
+ height: 44px;
739
+ border: 0;
740
+ border-radius: 12px;
741
+ background: transparent;
742
+ font: inherit;
743
+ font-size: 14px;
744
+ color: var(--sc-muted, #6b6b69);
745
+ cursor: pointer;
746
+ }
747
+ .sc-act-quiet:hover:not(:disabled) {
748
+ color: var(--sc-text, #1b1b1a);
749
+ }
750
+ .sc-act-go:disabled,
751
+ .sc-act-quiet:disabled {
752
+ cursor: default;
753
+ opacity: 0.5;
754
+ }
755
+ .sc-act-go[data-spin],
756
+ .sc-act-quiet[data-spin] {
757
+ opacity: 1;
758
+ }
759
+ .sc-act-glyph {
760
+ flex: none;
761
+ width: 15px;
762
+ height: 15px;
763
+ }
764
+
765
+ .sc-act-miss {
766
+ margin: 4px 2px 0;
767
+ font-size: 13px;
768
+ line-height: 1.5;
769
+ color: var(--sc-muted, #6b6b69);
770
+ text-align: center;
489
771
  }
490
772
 
491
773
  .sc-arow {
@@ -500,13 +782,27 @@ a.sc-btn {
500
782
  flex: none;
501
783
  display: grid;
502
784
  place-items: center;
503
- width: 22px;
504
- height: 22px;
785
+ width: 30px;
786
+ height: 30px;
505
787
  border-radius: var(--sc-r-sm, 6px);
506
788
  border: 1px solid var(--sc-line, #e9e9eb);
507
789
  background: var(--sc-tray-sunk, #f6f6f7);
508
790
  }
509
791
 
792
+ .sc-runtime-logo {
793
+ width: 15px;
794
+ height: 15px;
795
+ border-radius: 3px;
796
+ object-fit: contain;
797
+ }
798
+
799
+ .sc-runtime-letter {
800
+ font-size: 10px;
801
+ font-weight: 600;
802
+ line-height: 1;
803
+ color: var(--sc-muted, #6b6b73);
804
+ }
805
+
510
806
  .sc-runtime-mark {
511
807
  width: 13px;
512
808
  height: 13px;
@@ -522,10 +818,6 @@ a.sc-btn {
522
818
  font-size: var(--sc-fs-small);
523
819
  }
524
820
 
525
- .sc-aname-absent {
526
- color: var(--sc-muted, #6b6b73);
527
- }
528
-
529
821
  .sc-aversion {
530
822
  color: var(--sc-muted, #6b6b73);
531
823
  }
@@ -539,22 +831,10 @@ a.sc-btn {
539
831
  color: var(--sc-muted, #6b6b73);
540
832
  }
541
833
 
542
- .sc-sglyph {
543
- flex: none;
544
- width: 11px;
545
- height: 11px;
546
- color: var(--sc-ok, #22a06b);
547
- }
548
-
549
- .sc-aserving {
550
- margin-left: 5px;
551
- font-variant-numeric: tabular-nums;
552
- }
553
-
554
834
  .sc-orow {
555
835
  display: flex;
556
836
  align-items: center;
557
- gap: 10px;
837
+ gap: 18px;
558
838
  min-height: 34px;
559
839
  padding-right: 12px;
560
840
  }
@@ -600,7 +880,7 @@ a.sc-btn {
600
880
  .sc-pair {
601
881
  display: flex;
602
882
  align-items: center;
603
- gap: 10px;
883
+ gap: 18px;
604
884
  width: calc(100% + 4px);
605
885
  min-height: 34px;
606
886
  margin-left: -4px;
@@ -620,7 +900,8 @@ a.sc-btn {
620
900
  }
621
901
 
622
902
  .sc-open-app {
623
- color: inherit;
903
+
904
+ color: var(--sc-muted, #6b6b73);
624
905
  text-decoration: none;
625
906
  }
626
907
 
@@ -636,99 +917,76 @@ a.sc-btn {
636
917
  color: var(--sc-muted, #6b6b73);
637
918
  }
638
919
 
639
- .sc-runs-to {
640
- display: inline-flex;
641
- flex: none;
642
- align-items: center;
643
- gap: 2px;
644
- min-width: 0;
645
- max-width: 62%;
646
- font-size: var(--sc-fs-label);
647
- color: var(--sc-muted, #6b6b73);
648
- }
649
-
650
- .sc-runs-cap {
651
- flex: none;
652
- white-space: nowrap;
653
- }
654
-
655
- .sc-runs-fixed,
656
- .sc-runs-btn {
657
- display: inline-flex;
920
+ .sc-nilrow {
921
+ display: flex;
658
922
  align-items: center;
659
- gap: 5px;
660
- min-width: 0;
661
- height: 24px;
662
- padding: 0 6px;
663
- font-size: var(--sc-fs-label);
664
- font-weight: 500;
665
- color: var(--sc-text-2, #3f3f46);
923
+ gap: 10px;
924
+ margin: 0;
925
+ padding: 9px 0;
926
+ font-size: 14px;
927
+ color: var(--sc-muted, #6b6b69);
666
928
  }
667
929
 
668
- .sc-runs-btn {
669
- padding-right: 4px;
670
- border: 0;
671
- border-radius: var(--sc-r-pill, 999px);
672
- background: transparent;
673
- font-family: inherit;
674
- cursor: pointer;
675
- transition: background-color 120ms ease, color 120ms ease;
930
+ .sc-group-card:has(> .sc-nilrow) {
931
+ padding: 7px 16px;
676
932
  }
677
-
678
- .sc-runs-btn:hover:not(:disabled),
679
- .sc-runs-btn[aria-expanded="true"] {
680
- background: var(--sc-tray-card, #ffffff);
681
- color: var(--sc-text, #1a1a1c);
933
+ .sc-nilrow-mark {
934
+ display: grid;
935
+ place-items: center;
936
+ flex: none;
937
+ width: 28px;
938
+ height: 28px;
939
+ border-radius: 50%;
940
+ background: var(--sc-tray-sunk, #efefed);
941
+ color: var(--sc-faint, #8c8c89);
682
942
  }
683
-
684
- .sc-runs-btn:disabled {
685
- opacity: 0.5;
686
- cursor: default;
943
+ .sc-nilrow-mark .sc-blank-glyph {
944
+ width: 15px;
945
+ height: 15px;
687
946
  }
688
947
 
689
- .sc-runs-glyph {
690
- flex: none;
691
- width: 12px;
692
- height: 12px;
948
+ .sc-heads {
949
+ display: flex;
950
+ align-items: flex-start;
951
+ gap: 8px;
952
+ margin: 2px 12px 3px 0;
953
+ padding: 8px 10px;
954
+ border-radius: var(--sc-r, 10px);
955
+ background: color-mix(in srgb, var(--sc-warn, #b06f14) 9%, var(--sc-tray-card, #ffffff));
693
956
  }
694
-
695
- .sc-runs-mark {
696
- display: inline-grid;
957
+ .sc-heads-mark {
697
958
  flex: none;
959
+ display: grid;
698
960
  place-items: center;
699
- width: 14px;
700
- height: 14px;
701
- }
702
-
703
- .sc-runs-mark > * {
704
- max-width: 14px;
705
- max-height: 14px;
961
+
962
+ margin-top: 1px;
963
+ color: var(--sc-warn, #b06f14);
706
964
  }
707
-
708
- .sc-runs-label {
709
- min-width: 0;
710
- overflow: hidden;
711
- text-overflow: ellipsis;
712
- white-space: nowrap;
965
+ .sc-hglyph {
966
+ width: 13px;
967
+ height: 13px;
713
968
  }
714
-
715
- .sc-runs-btn .sc-chev {
716
- width: 11px;
717
- height: 11px;
718
- color: var(--sc-faint, #a1a1aa);
969
+ .sc-heads-say {
970
+ margin: 0;
971
+ font-size: var(--sc-fs-label);
972
+ line-height: 1.45;
973
+ color: var(--sc-text-2, #3f3f46);
719
974
  }
720
975
 
721
976
  .sc-menu {
722
977
  position: fixed;
723
978
  inset: auto;
724
979
  z-index: 2147483647;
725
- width: 248px;
980
+
981
+ width: 320px;
726
982
  margin: 0;
727
983
  padding: 4px;
728
984
  border: 1px solid var(--sc-line, #e9e9eb);
729
985
  border-radius: 12px;
730
986
  background: var(--sc-tray-card, #ffffff);
731
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
987
+ box-shadow:
988
+ 0 10px 30px rgba(0, 0, 0, 0.12),
989
+ 0 2px 6px rgba(0, 0, 0, 0.06);
732
990
  color: var(--sc-text, #1a1a1c);
733
991
 
734
992
  max-height: 60vh;
@@ -739,15 +997,16 @@ a.sc-btn {
739
997
  .sc-menu-item {
740
998
  display: flex;
741
999
  align-items: center;
742
- gap: 10px;
1000
+ gap: 14px;
743
1001
  width: 100%;
744
- min-height: 34px;
745
- padding: 5px 8px;
1002
+
1003
+ min-height: 44px;
1004
+ padding: 7px 12px;
746
1005
  border: 0;
747
- border-radius: 8px;
1006
+ border-radius: 12px;
748
1007
  background: transparent;
749
1008
  font: inherit;
750
- font-size: var(--sc-fs-small);
1009
+ font-size: 15px;
751
1010
  color: inherit;
752
1011
  text-align: left;
753
1012
  cursor: pointer;
@@ -773,9 +1032,9 @@ a.sc-btn {
773
1032
  }
774
1033
 
775
1034
  .sc-menu-note {
776
- font-size: var(--sc-fs-label);
1035
+ font-size: 13.5px;
777
1036
  line-height: 1.4;
778
- color: var(--sc-muted, #6b6b73);
1037
+ color: var(--sc-muted, #6b6b69);
779
1038
  }
780
1039
 
781
1040
  .sc-menu-check {
@@ -806,6 +1065,11 @@ a.sc-btn {
806
1065
  border-top: 0;
807
1066
  }
808
1067
 
1068
+ .sc-tray-error {
1069
+ margin: 0;
1070
+ padding: 0 12px 2px;
1071
+ }
1072
+
809
1073
  .sc-mp {
810
1074
  display: inline-flex;
811
1075
  align-items: center;
@@ -836,7 +1100,9 @@ a.sc-btn {
836
1100
  font-weight: 500;
837
1101
  color: var(--sc-text-2, #3f3f46);
838
1102
  cursor: pointer;
839
- transition: background-color 120ms ease, color 120ms ease;
1103
+ transition:
1104
+ background-color 120ms ease,
1105
+ color 120ms ease;
840
1106
  }
841
1107
 
842
1108
  .sc-mp-btn:hover:not(:disabled),
@@ -876,32 +1142,166 @@ a.sc-btn {
876
1142
  color: var(--sc-faint, #a1a1aa);
877
1143
  }
878
1144
 
879
- .sc-row-act {
880
- flex: none;
881
- padding: 3px 9px;
882
- border: 1px solid transparent;
883
- border-radius: var(--sc-r-pill, 999px);
884
- background: var(--sc-tray-sunk, #f6f6f7);
1145
+ .sc-atile .sc-runtime-logo {
1146
+ width: 25px;
1147
+ height: 25px;
1148
+ border-radius: 7px;
1149
+ }
1150
+ .sc-atile .sc-runtime-mark {
1151
+ width: 22px;
1152
+ height: 22px;
1153
+ }
1154
+ .sc-atile .sc-runtime-letter {
1155
+ font-size: 15px;
1156
+ }
1157
+
1158
+ .sc-group-card:has(> .sc-runs-agent) {
1159
+ padding: 0 16px;
1160
+ }
1161
+ .sc-runs-agent {
1162
+ display: flex;
1163
+ align-items: center;
1164
+ gap: 14px;
1165
+ width: 100%;
1166
+ min-width: 0;
1167
+ margin: 0;
1168
+ padding: 14px 0;
1169
+ border: 0;
1170
+ background: transparent;
885
1171
  font: inherit;
886
- font-size: var(--sc-fs-label);
887
- font-weight: 500;
888
- color: var(--sc-text-2, #3f3f46);
1172
+ color: inherit;
1173
+ text-align: left;
889
1174
  cursor: pointer;
1175
+ }
1176
+
1177
+ .sc-runs-dim {
1178
+ opacity: 0.55;
1179
+ }
1180
+ .sc-runs-agent:disabled,
1181
+ .sc-runs-fixed {
1182
+ cursor: default;
1183
+ }
1184
+ .sc-runs-agent:focus-visible {
1185
+ outline: 2px solid var(--sc-accent, #18181b);
1186
+ outline-offset: -2px;
1187
+ border-radius: var(--sc-r-sm, 6px);
1188
+ }
1189
+
1190
+ .sc-runs-tile {
1191
+ flex: none;
1192
+ display: grid;
1193
+ place-items: center;
1194
+ width: 44px;
1195
+ height: 44px;
1196
+ border-radius: 12px;
1197
+ background: var(--sc-tray-sunk, #efefed);
1198
+ }
1199
+
1200
+ .sc-runs-tile .sc-runtime-logo {
1201
+ width: 34px;
1202
+ height: 34px;
1203
+ border-radius: 9px;
1204
+ }
1205
+ .sc-runs-tile .sc-runtime-mark {
1206
+ width: 30px;
1207
+ height: 30px;
1208
+ }
1209
+ .sc-runs-tile .sc-runtime-letter {
1210
+ font-size: 19px;
1211
+ }
1212
+ .sc-runs-name {
1213
+ flex: 1;
1214
+ min-width: 0;
1215
+ overflow: hidden;
1216
+ text-overflow: ellipsis;
890
1217
  white-space: nowrap;
1218
+ font-size: 16px;
1219
+ font-weight: 600;
1220
+ }
1221
+ .sc-runs-agent .sc-chev {
1222
+ flex: none;
1223
+ width: 16px;
1224
+ height: 16px;
1225
+ color: var(--sc-faint, #a1a1aa);
891
1226
  }
892
1227
 
893
- .sc-row-act:hover:not(:disabled) {
894
- color: var(--sc-text, #1a1a1c);
1228
+ .sc-runs-told {
1229
+ flex: none;
1230
+ font-size: 14px;
1231
+ color: var(--sc-muted, #6b6b69);
895
1232
  }
896
1233
 
897
- .sc-row-act:disabled {
898
- opacity: 0.5;
899
- cursor: default;
1234
+ .sc-runs-rule {
1235
+ display: block;
1236
+ height: 1px;
1237
+ background: var(--sc-line, #e9e9e7);
900
1238
  }
901
1239
 
902
- .sc-tray-error {
903
- margin: 0;
904
- padding: 0 12px 2px;
1240
+ .sc-runs-model {
1241
+ display: flex;
1242
+ align-items: center;
1243
+ gap: 0;
1244
+ width: 100%;
1245
+ max-width: none;
1246
+ min-width: 0;
1247
+ }
1248
+ .sc-runs-model .sc-mp-cap,
1249
+ .sc-runs-key {
1250
+ flex: none;
1251
+ width: 58px;
1252
+ font-size: 15px;
1253
+ color: var(--sc-muted, #6b6b69);
1254
+ }
1255
+ .sc-runs-model .sc-mp-btn {
1256
+ flex: 1;
1257
+ justify-content: flex-start;
1258
+ gap: 14px;
1259
+ min-width: 0;
1260
+ height: auto;
1261
+ min-height: 44px;
1262
+ padding: 0;
1263
+ border-radius: 0;
1264
+ background: transparent;
1265
+ font-size: 15px;
1266
+ font-weight: 400;
1267
+ color: var(--sc-text, #1b1b1a);
1268
+ }
1269
+ .sc-runs-model .sc-mp-btn:hover:not(:disabled),
1270
+ .sc-runs-model .sc-mp-btn[aria-expanded="true"] {
1271
+ background: transparent;
1272
+ color: var(--sc-text, #1b1b1a);
1273
+ }
1274
+ .sc-runs-model .sc-mp-label {
1275
+ flex: 1;
1276
+ min-width: 0;
1277
+ overflow: hidden;
1278
+ text-overflow: ellipsis;
1279
+ white-space: nowrap;
1280
+ text-align: left;
1281
+ }
1282
+ .sc-runs-model .sc-mp-btn .sc-chev {
1283
+ flex: none;
1284
+ width: 16px;
1285
+ height: 16px;
1286
+ color: var(--sc-faint, #a1a1aa);
1287
+ }
1288
+ .sc-runs-model .sc-mp-btn .sc-chev-open {
1289
+ transform: none;
1290
+ }
1291
+
1292
+ .sc-runs-said {
1293
+ display: flex;
1294
+ align-items: center;
1295
+ gap: 0;
1296
+ min-height: 44px;
1297
+ font-size: 15px;
1298
+ }
1299
+ .sc-runs-val {
1300
+ flex: 1;
1301
+ min-width: 0;
1302
+ overflow: hidden;
1303
+ text-overflow: ellipsis;
1304
+ white-space: nowrap;
905
1305
  }
906
1306
 
907
1307
  .sc-pop {
@@ -911,8 +1311,9 @@ a.sc-btn {
911
1311
  right: auto;
912
1312
  bottom: auto;
913
1313
  z-index: 2147483000;
914
- width: min(92vw, 320px);
915
- max-width: min(92vw, 320px);
1314
+
1315
+ width: min(92vw, 420px);
1316
+ max-width: min(92vw, 420px);
916
1317
 
917
1318
  max-height: calc(100vh - 24px);
918
1319
  overflow-y: auto;
@@ -928,11 +1329,6 @@ a.sc-btn {
928
1329
  var(--sc-shadow-2);
929
1330
  }
930
1331
 
931
- .sc-pop > .sc-tray {
932
- background: transparent;
933
- border-radius: inherit;
934
- }
935
-
936
1332
  @keyframes sc-pop-in {
937
1333
  from {
938
1334
  opacity: 0;
@@ -995,6 +1391,8 @@ a.sc-btn {
995
1391
 
996
1392
  --sc-ok: #4cb782;
997
1393
  --sc-warn: #f2994a;
1394
+ --sc-danger: #e4705a;
1395
+ --sc-warn-dot: #e0ad33;
998
1396
 
999
1397
  --sc-tray: var(--sc-ground, #0f0f11);
1000
1398
  --sc-tray-card: var(--sc-raised, #1d1d20);
@@ -1020,6 +1418,7 @@ a.sc-btn {
1020
1418
 
1021
1419
  --sc-ok: #4cb782;
1022
1420
  --sc-warn: #f2994a;
1421
+ --sc-danger: #e4705a;
1023
1422
 
1024
1423
  --sc-tray: var(--sc-ground, #0f0f11);
1025
1424
  --sc-tray-card: var(--sc-raised, #1d1d20);
@@ -1878,7 +2277,7 @@ a.sc-btn {
1878
2277
  .sc-step-lead:focus-visible,
1879
2278
  .sc-step-links a:focus-visible,
1880
2279
  .sc-alt-link:focus-visible,
1881
- .sc-runs-btn:focus-visible,
2280
+ .sc-runs-agent:focus-visible,
1882
2281
  .sc-mp-btn:focus-visible,
1883
2282
  .sc-row-act:focus-visible,
1884
2283
  .sc-disc:focus-visible,
@@ -1938,8 +2337,9 @@ a.sc-btn {
1938
2337
  border-radius: var(--sc-r-pill, 999px);
1939
2338
  border-color: var(--sc-line, #e9e9eb);
1940
2339
 
1941
- box-shadow: var(--sc-shadow-1);
1942
- font-size: var(--sc-fs-small);
2340
+
2341
+ box-shadow: var(--sc-shadow-1, 0 1px 2px rgb(0 0 0 / 5%));
2342
+ font-size: var(--sc-fs-small, 12.5px);
1943
2343
  font-weight: 500;
1944
2344
 
1945
2345
  letter-spacing: -0.005em;
@@ -3013,7 +3413,7 @@ li.sc-plan-row.sc-plan-current {
3013
3413
  .sc-opt-has-warn {
3014
3414
  color: var(--sc-warn, #b06f14);
3015
3415
  }
3016
- `,document.head.appendChild(e)}import{jsx as Ie,jsxs as at}from"react/jsx-runtime";function qo(e){if(!e)return null;let n=hn(e);if(n==="payment_required"||n==="no_compute")return null;if(typeof e=="string")return e||null;let t=e,r=t.error?.message;return typeof r=="string"&&r?r:typeof t.message=="string"&&t.message?t.message:"The run ended with an error."}function Ja(){return at("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Ie("path",{d:"M8 5v4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),Ie("circle",{cx:"8",cy:"11.6",r:"0.9",fill:"currentColor"}),Ie("circle",{cx:"8",cy:"8",r:"6.4",stroke:"currentColor",strokeWidth:"1.3"})]})}function Qa({error:e,onRetry:n,onDismiss:t,title:r,className:o}){let s=qo(e),a=H();return Za(()=>st(),[]),s?Ie("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":a.theme,role:"alert",children:at("div",{className:"sc-card sc-limit sc-run-error",children:[at("div",{className:"sc-limit-head",children:[Ie("span",{className:"sc-limit-mark sc-run-error-mark","aria-hidden":"true",children:Ie(Ja,{})}),at("div",{children:[Ie("h2",{className:"sc-limit-title",children:r??"That run did not finish"}),Ie("p",{className:"sc-limit-body sc-run-error-message",children:s})]})]}),(t||n)&&at("div",{className:"sc-limit-actions",children:[t&&Ie("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,children:"Dismiss"}),n&&Ie("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:n,children:"Try again"})]})]})}):null}import{useId as Xa,useState as Fo}from"react";import{jsx as Z,jsxs as Rt}from"react/jsx-runtime";function ei({reason:e}){return Z("span",{className:"sc-limit-mark","aria-hidden":"true",children:e==="no_compute"?Z(ht,{}):Z(j,{})})}function ni(e){let{error:n,variant:t="card",onDismiss:r,className:o}=e,s=Ar(n,{predict:e.predict??!("error"in e)}),a=Xa(),c=H();if(!s)return null;let i=Z(ti,{offer:s,headingId:a,onDismiss:r});return t==="dialog"?Z(jn,{open:!0,onClose:()=>r?.(),labelledBy:a,theme:c.theme,children:i}):Z("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":c.theme,children:i})}function ti({offer:e,headingId:n,onDismiss:t}){let{compute:r}=D(),[o,s]=Fo(!1),[a,c]=Fo(null),i=e.reason==="no_compute"&&r.connected&&!r.online,l=i||e.connectOffer!==null||!r.connected,u=ot();async function p(){s(!0),c(null);try{await e.upgrade()}catch(y){c(y.message)}finally{s(!1)}}return Rt("div",{className:"sc-card sc-limit",children:[Rt("div",{className:"sc-limit-head",children:[Z(ei,{reason:e.reason}),Rt("div",{children:[Z("h2",{className:"sc-limit-title",id:n,children:e.title}),Z("p",{className:"sc-limit-body",children:e.body})]})]}),a&&Z("p",{className:"sc-error",children:a}),i&&u.note&&Z("p",{className:"sc-limit-note",children:u.note}),Rt("div",{className:"sc-limit-actions",children:[t&&Z("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,disabled:o,children:"Not now"}),e.upgradeTo&&Z("button",{type:"button",className:l?"sc-btn":"sc-btn sc-btn-primary",onClick:()=>void p(),disabled:o,children:o?"Opening\u2026":e.upgradeTo.selectable?`Switch to ${e.upgradeTo.name}`:`${e.upgradeTo.name} for $${e.upgradeTo.price.toLocaleString()}/${e.upgradeTo.interval}`}),l&&Z("button",{type:"button",className:i?"sc-btn":"sc-btn sc-btn-primary",onClick:e.connect,disabled:o,children:i?"Connect another machine":"Connect compute"}),i&&Z("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:u.open,disabled:o,children:"Open Soba App"})]})]})}import{useMemo as ri}from"react";function it(){let{plan:e,compute:n,connect:t}=D();return ri(()=>{let r=e.plan,o=e.current,s={plan:r,assignment:o,loading:e.loading,error:e.error,periodEnd:o?.period_end?new Date(o.period_end):null};if(!r)return{...s,state:"none",trialDaysLeft:null,ceiling:null,raised:!1,uncounted:!1,used:0,remaining:null,percent:null,unlimited:!1,reward:null,summary:"Nothing is assigned to this account, so runs are bounded by whatever the app allows."};let a=ai(o?.trial_ends_at??null),c=r.connected_reward==="included"&&n.connected&&r.connected_included_units!==null,i=c?r.connected_included_units:r.included_units,l=r.connected_reward==="unlimited"&&n.connected,u=i===null,p=e.used??0,y=i===null?null:Math.max(0,i-p),f=i&&i>0?Math.min(100,Math.round(p/i*100)):null,m=i!==null&&p>=i,w=a!==null?"trial":u?"unlimited":m?r.overage==="meter"?"metered":"spent":"within";return{...s,state:w,trialDaysLeft:a,ceiling:i,raised:c,uncounted:l,used:p,remaining:y,percent:f,unlimited:u,reward:oi(r,c||l,n.connected,()=>t.open("manual")),summary:si({plan:r,assignment:o,used:p,ceiling:i,trialDaysLeft:a,raised:c,uncounted:l,state:w})}},[e,n.connected,t])}function oi(e,n,t,r){let o=Ue({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6});return o?{line:o,inForce:n,required:!1,connected:t,actionable:He(e.connected_reward)&&!t,open:r}:Se(e.route_allow)&&!t?{line:"Nothing connected yet, so nothing can run.",inForce:!1,required:!0,connected:t,actionable:!0,open:r}:null}function si(e){let{plan:n,assignment:t,used:r,ceiling:o,trialDaysLeft:s,raised:a,uncounted:c,state:i}=e,l=`${n.unit}${r===1?"":"s"}`,u=c?" Runs your own AI serves do not count toward it.":"";if(i==="trial"&&s!==null){let f=n.price===0?"it continues free":`it is $${n.price.toLocaleString()} a ${n.interval}`;return`${s} ${s===1?"day":"days"} left of your trial, then ${f}.`}if(i==="unlimited")return`${r.toLocaleString()} ${l} this period. No ceiling on this plan.`;if(i==="metered"){let f=r-(o??0);return n.overage_per_unit>0?`${f.toLocaleString()} past the allowance, billed at $${n.overage_per_unit} a ${n.unit}.${u}`:`${f.toLocaleString()} past the allowance.${u}`}if(i==="spent")return t?.period_end?`Allowance spent. It comes back on ${Go(t.period_end)}.${u}`:`Allowance spent. It comes back at the start of the next period.${u}`;let p=Math.max(0,(o??0)-r),y=a?` Raised from ${(n.included_units??0).toLocaleString()} while your own AI is connected.`:t?.period_end?` Resets ${Go(t.period_end)}.`:"";return`${p.toLocaleString()} of ${(o??0).toLocaleString()} ${n.unit}s left.${y}${u}`}function ai(e){if(!e)return null;let n=new Date(e).getTime()-Date.now();return Number.isNaN(n)||n<=0?null:Math.max(1,Math.ceil(n/864e5))}function Go(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}import{Fragment as li,jsx as J,jsxs as Me}from"react/jsx-runtime";function qr({heading:e="Current plan",showUsage:n=!0,showName:t=!0,className:r}){let o=it(),{theme:s}=H(),a=y=>J("section",{className:r?`soba-connect sc-fill ${r}`:"soba-connect sc-fill","data-theme":s,children:Me("div",{className:"sc-card sc-current",children:[e&&J("h2",{className:"sc-section-title",children:e}),y]})});if(o.error)return a(J("p",{className:"sc-error",children:o.error.message}));if(o.loading)return a(J("p",{className:"sc-note",children:"Loading\u2026"}));if(!o.plan)return a(Me("div",{className:"sc-current-main",children:[J("p",{className:"sc-current-name",children:"No plan"}),J("p",{className:"sc-sub",children:o.summary})]}));let{plan:c,trialDaysLeft:i,percent:l,unlimited:u,reward:p}=o;return a(Me(li,{children:[Me("div",{className:"sc-current-grid",children:[(t||i!==null)&&Me("div",{className:"sc-current-main",children:[t?Me("p",{className:"sc-current-name",children:[c.name,i!==null&&Me("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})]}):i!==null&&J("p",{className:"sc-current-trial",children:Me("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})}),t&&c.description&&J("p",{className:"sc-sub",children:c.description})]}),n&&Me("div",{className:"sc-usage",children:[Me("div",{className:"sc-row-between",children:[J("span",{className:"sc-fact-key",children:"Usage"}),J("span",{className:l!==null&&l>=100?"sc-usage-figure sc-usage-over":"sc-usage-figure",children:u?"Unlimited":l===null?"Metered":`${l}% used`})]}),l!==null&&J("div",{className:"sc-meter",role:"presentation",children:l>0&&J("span",{className:l>=100?"sc-meter-fill sc-meter-full":"sc-meter-fill",style:{width:`${l}%`}})}),J("p",{className:"sc-usage-line",children:o.summary})]})]}),p&&Me("div",{className:"sc-current-foot",children:[J("p",{className:p.required?"sc-plan-reward-line sc-plan-reward-need":p.inForce?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-open",children:p.required?p.line:p.inForce?`In force: ${ii(p.line)}.`:p.line}),(p.actionable||p.connected)&&J(fn,{})]})]}))}var ii=e=>e.charAt(0).toLowerCase()+e.slice(1);import{useCallback as ci,useMemo as ui,useState as zo}from"react";var di={"user-hardware":"your own machine","user-subscription":"your own AI subscription","open-weights":"open models we host",frontier:"frontier models"},pi=new Set(["user-hardware","user-subscription"]);function Fr(e={}){let{plan:n,compute:t,connect:r}=D(),[o,s]=zo(null),[a,c]=zo(null),{featured:i,onSelect:l,successUrl:u,cancelUrl:p}=e,y=ci(async m=>{s(m.id),c(null);try{if(m.selectable)await n.select(m.id);else if(l)l(m);else{let w=await n.checkout(m.id,{...u?{successUrl:u}:{},...p?{cancelUrl:p}:{}});window.location.assign(w);return}}catch(w){throw c(w.message),w}finally{(m.selectable||l)&&s(null)}},[n,l,u,p]),f=ui(()=>n.plans.map(m=>{let w=n.current?.plan_id===m.id;return{plan:m,current:w,featured:i===m.id&&!w,price:mi(m),allowance:m.included_units===null?`Unlimited ${m.unit}s`:`${m.included_units.toLocaleString()} ${m.unit}${m.included_units===1?"":"s"}`,allowanceNote:fi(m),computeLabel:m.route_allow===null?"any compute":m.route_allow.length===0?"no compute":null,compute:(m.route_allow??[]).map(M=>({costClass:M,label:di[M]??M,owned:pi.has(M),runtimes:Bt(M).map(R=>R.id)})),connect:hi(m,w,t.connected,()=>r.open("manual")),cta:{label:gi(m,w,o===m.id),disabled:w||o!==null,busy:o===m.id,take:()=>y(m)}}}),[n.plans,n.current,i,t.connected,r,o,y]);return{offers:f,current:f.find(m=>m.current)??null,loading:n.loading,error:n.error,failed:a}}function mi(e){return e.price===0?{amount:"Free",interval:null,free:!0}:{amount:`$${e.price.toLocaleString()}`,interval:e.interval,free:!1}}function fi(e){let n=[];return e.included_units===null?n.push("No ceiling on this plan"):(n.push(`Included each ${e.interval}`),e.overage==="meter"&&e.overage_per_unit>0?n.push(`then $${e.overage_per_unit} a ${e.unit}`):e.included_units>0&&n.push(`then ${e.unit}s stop`)),e.trial_days>0&&n.push(`${e.trial_days}-day trial`),n.join(" \xB7 ")}function hi(e,n,t,r){let o=Ue({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6}),s=Se(e.route_allow)&&!t;if(!o&&!s)return null;let a=He(e.connected_reward);return{key:o?"Connect your own":"To use this",line:o??(n?"Nothing connected yet, so nothing can run.":"Runs only on compute you connect."),reward:o!==null,actionable:n&&(a||s)&&!t,open:r}}function gi(e,n,t){return n?"Your plan":t?e.selectable?"Switching\u2026":"Opening\u2026":e.selectable?"Choose":`Subscribe for $${e.price.toLocaleString()}/${e.interval}`}import{jsx as b,jsxs as A}from"react/jsx-runtime";function _t(e){return e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill"}function Gr({onSelect:e,successUrl:n,cancelUrl:t,showCompute:r=!0,showConnect:o=!1,variant:s="cards",featured:a,className:c}){let{offers:i,loading:l,error:u,failed:p}=Fr({...a?{featured:a}:{},...e?{onSelect:e}:{},...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),{theme:y}=H();if(u)return b("div",{className:_t(c),"data-theme":y,children:b("div",{className:"sc-card",children:b("p",{className:"sc-error",children:u.message})})});if(l)return b("div",{className:_t(c),"data-theme":y,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"Loading plans\u2026"})})});if(i.length===0)return b("div",{className:_t(c),"data-theme":y,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"This app has no plans yet."})})});let f={showCompute:r,showConnect:o};return A("div",{className:_t(c),"data-theme":y,"data-variant":s,children:[s==="rows"?b(yi,{offers:i,shelf:f}):s==="table"?b(wi,{offers:i,shelf:f}):b(bi,{offers:i,shelf:f}),p&&b("p",{className:"sc-error",children:p})]})}function bi({offers:e,shelf:n}){return b("div",{className:"sc-plans",children:e.map(t=>A("div",{className:Vo("sc-plan",t),children:[A("div",{className:"sc-row-between",children:[b("span",{className:"sc-title",children:t.plan.name}),b(zr,{offer:t})]}),b("p",{className:"sc-sub",children:t.plan.description}),b(Vr,{price:t.price,free:"forever"}),b(Yr,{offer:t,shelf:n}),b(Ko,{offer:t}),b("div",{className:"sc-plan-band",children:n.showCompute&&b(jr,{offer:t})}),b("div",{className:"sc-plan-band",children:b(Kr,{offer:t})})]},t.plan.id))})}function yi({offers:e,shelf:n}){return b("ul",{className:"sc-plan-rows",children:e.map(t=>A("li",{className:Vo("sc-plan-row",t),children:[A("div",{className:"sc-row-main",children:[A("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:t.plan.name}),b(zr,{offer:t})]}),t.plan.description&&b("p",{className:"sc-sub",children:t.plan.description}),b(Ko,{offer:t}),n.showCompute&&b(jr,{offer:t,inline:!0}),b(Kr,{offer:t,inline:!0})]}),A("div",{className:"sc-row-side",children:[b(Vr,{price:t.price,free:"forever",small:!0}),b(Yr,{offer:t,shelf:n})]})]},t.plan.id))})}function wi({offers:e,shelf:n}){let t=e.some(a=>a.plan.overage_per_unit>0),r=e.some(a=>a.plan.trial_days>0),o=e.some(a=>a.connect!==null),s=a=>[a.current?"sc-col-current":"",a.featured?"sc-col-featured":""].filter(Boolean).join(" ")||void 0;return b("div",{className:"sc-table-scroll",children:A("table",{className:"sc-plan-table",children:[b("thead",{children:A("tr",{children:[b("td",{}),e.map(a=>A("th",{scope:"col",className:s(a),children:[A("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:a.plan.name}),b(zr,{offer:a})]}),b(Vr,{price:a.price,small:!0})]},a.plan.id))]})}),A("tbody",{children:[A("tr",{children:[b("th",{scope:"row",children:"Included"}),e.map(a=>b("td",{className:s(a),children:a.allowance},a.plan.id))]}),t&&A("tr",{children:[b("th",{scope:"row",children:"Then"}),e.map(a=>b("td",{className:s(a),children:a.plan.overage_per_unit>0?`$${a.plan.overage_per_unit} / ${a.plan.unit}`:b("span",{className:"sc-muted-cell",children:"Stops"})},a.plan.id))]}),r&&A("tr",{children:[b("th",{scope:"row",children:"Trial"}),e.map(a=>b("td",{className:s(a),children:a.plan.trial_days>0?`${a.plan.trial_days} days`:b("span",{className:"sc-muted-cell",children:"None"})},a.plan.id))]}),n.showCompute&&A("tr",{children:[b("th",{scope:"row",children:"Runs on"}),e.map(a=>b("td",{className:s(a),children:b(jr,{offer:a,bare:!0})},a.plan.id))]}),o&&A("tr",{children:[b("th",{scope:"row",children:"Connect your own"}),e.map(a=>b("td",{className:s(a),children:b(Kr,{offer:a,bare:!0})},a.plan.id))]}),A("tr",{className:"sc-table-buy",children:[b("td",{}),e.map(a=>b("td",{className:s(a),children:b(Yr,{offer:a,shelf:n})},a.plan.id))]})]})]})})}function Vo(e,n){return[e,n.current?"sc-plan-current":"",n.featured?"sc-plan-featured":""].filter(Boolean).join(" ")}function zr({offer:e}){return e.current?b("span",{className:"sc-plan-badge",children:"Current"}):e.featured?b("span",{className:"sc-plan-badge-soft",children:"Recommended"}):null}function Vr({price:e,small:n,free:t}){return A("p",{className:n?"sc-plan-price sc-plan-price-sm":"sc-plan-price",children:[b("span",{className:"sc-plan-amount",children:e.amount}),e.interval?A("span",{className:"sc-plan-interval",children:["/",e.interval]}):t&&b("span",{className:"sc-plan-interval sc-plan-after",children:t})]})}function Ko({offer:e}){return A("p",{className:"sc-plan-allowance",children:[b("span",{className:"sc-plan-figure",children:e.allowance}),b("span",{className:"sc-plan-qualifier",children:e.allowanceNote})]})}function Kr({offer:e,inline:n,bare:t}){let r=e.connect;if(!r)return t?b("span",{className:"sc-muted-cell",children:"None"}):null;let o=r.reward?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-need",s=r.actionable?A("button",{type:"button",className:`${o} sc-plan-reward-act`,"aria-label":"Connect compute",onClick:r.open,children:[b("span",{className:"sc-reward-said",children:r.line}),A("span",{className:"sc-reward-do","aria-hidden":!0,children:[b(j,{className:"sc-reward-mark"}),"Connect compute"]})]}):b("p",{className:o,children:r.line});return t?s:b("div",{className:n?"sc-plan-reward sc-plan-reward-inline":"sc-plan-reward",children:s})}function jr({offer:e,inline:n,bare:t}){let r=e.computeLabel?b("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:b("li",{children:e.computeLabel})}):b("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:e.compute.map(o=>A("li",{className:o.owned?"sc-compute-own":void 0,children:[o.label,b(vi,{runtimes:o.runtimes})]},o.costClass))});return t?r:A("div",{className:n?"sc-plan-compute sc-plan-compute-inline":"sc-plan-compute",children:[b("span",{className:"sc-fact-key",children:"Runs on"}),r]})}function Yr({offer:e,shelf:n}){let t=e.connect;return n.showConnect&&t?.actionable?A("button",{type:"button",className:"sc-btn sc-btn-primary sc-btn-icon",onClick:t.open,children:[b(j,{className:"sc-btn-mark"}),"Connect compute"]}):b("button",{type:"button",className:e.current?"sc-btn":"sc-btn sc-btn-primary",disabled:e.cta.disabled,onClick:()=>void e.cta.take().catch(()=>{}),children:e.cta.label})}function vi({runtimes:e}){return e.length===0?null:b("span",{className:"sc-compute-marks",children:e.map(n=>{let t=ze[n];return t?b(t,{className:"sc-rt-mark"},n):null})})}import{jsx as Zr,jsxs as jo}from"react/jsx-runtime";function ki({heading:e,plansHeading:n,showUsage:t=!0,showName:r=!0,className:o,...s}){let{plan:a,loading:c}=it(),{theme:i}=H(),l=n??(c?"Plans":a?"Change plan":"Choose a plan");return jo("div",{className:o?`soba-connect sc-fill sc-billing ${o}`:"soba-connect sc-fill sc-billing","data-theme":i,children:[Zr(qr,{...e===void 0?{}:{heading:e},showUsage:t,showName:r}),jo("section",{className:"sc-billing-plans",children:[l&&Zr("h2",{className:"sc-section-title",children:l}),Zr(Gr,{...s})]})]})}import{useCallback as Yo,useState as Zo}from"react";function Jr({plan:e,successUrl:n,cancelUrl:t,label:r}){let{plan:o}=D(),[s,a]=Zo(!1),[c,i]=Zo(null),l=Yo(()=>o.checkout(e.id,{...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),[o,e.id,n,t]),u=Yo(async()=>{a(!0),i(null);try{window.location.assign(await l())}catch(p){i(p.message),a(!1)}},[l]);return{label:s?"Opening\u2026":r??`Subscribe for $${e.price.toLocaleString()}/${e.interval}`,busy:s,error:c,buy:u,session:l}}import{jsx as Jo,jsxs as Ni}from"react/jsx-runtime";function Ci({plan:e,successUrl:n,cancelUrl:t,label:r,className:o}){let{theme:s}=H(),a=Jr({plan:e,...n?{successUrl:n}:{},...t?{cancelUrl:t}:{},...r?{label:r}:{}});return Ni("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":s,children:[Jo("button",{type:"button",className:"sc-btn sc-btn-primary",disabled:a.busy,onClick:()=>void a.buy(),children:a.label}),a.error&&Jo("p",{className:"sc-error",children:a.error})]})}import{useCallback as Te,useEffect as Ze,useMemo as In,useRef as Je,useState as Q}from"react";var xi="soba.session:";function Qo(e){return!e.cacheKey||!e.endpoint?null:xi+JSON.stringify([e.endpoint,e.user??null,e.cacheKey])}function Si(e){try{let n=globalThis.localStorage?.getItem(e);if(!n)return null;let t=JSON.parse(n);return typeof t.token!="string"||typeof t.expiresAt!="number"?null:{token:t.token,expiresAt:t.expiresAt}}catch{return null}}function Mi(e,n){try{n?globalThis.localStorage?.setItem(e,JSON.stringify(n)):globalThis.localStorage?.removeItem(e)}catch{}}var Xo=6e4,Pi=1e4,Et=class{#e;#n=null;#r=null;#t;#o=new Set;constructor(n){this.#t=n,this.#e=n.token??null;let t=Qo(n),r=t&&!this.#e?Si(t):null;r&&r.expiresAt-Xo>Date.now()&&(this.#e=r.token,this.#n=r.expiresAt)}get token(){return this.#e}get expiresAt(){return this.#n}get canRefresh(){return!!this.#t.endpoint}get refreshAt(){return!this.canRefresh||this.#n===null?null:Math.max(Date.now()+Pi,this.#n-Xo)}subscribe(n){return this.#o.add(n),()=>this.#o.delete(n)}async ensure(){return this.#e?this.#e:this.refresh()}async refresh(){if(this.#r)return this.#r;let n=this.#t.endpoint;if(!n)throw new Error("This Soba session cannot be refreshed. Pass `sessionEndpoint` so the provider can mint a new one.");let t=this.#t.fetchImpl??fetch.bind(globalThis);this.#r=(async()=>{let r=await t(n,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(this.#t.user?{user:this.#t.user}:{})});if(!r.ok)throw new Error(`Could not start a Soba session (${r.status} from ${n}).`);let o=await r.json(),s=o.session??o.token;if(!s)throw new Error(`${n} answered without a \`session\`. See @soba-so/react's README.`);let a=o.expires_in??o.expiresIn;this.#e=s,this.#n=typeof a=="number"?Date.now()+a*1e3:null;let c=Qo(this.#t);c&&Mi(c,this.#n===null?null:{token:s,expiresAt:this.#n});for(let i of this.#o)i();return s})();try{return await this.#r}finally{this.#r=null}}},On=new Map,es=new WeakMap,Ri=1;function _i(e){if(e.token||!e.endpoint)return null;let n=0;return e.fetchImpl&&(n=es.get(e.fetchImpl)??Ri++,es.set(e.fetchImpl,n)),JSON.stringify([e.endpoint,e.user??null,n,e.cacheKey??null])}function ns(e){let n=_i(e);if(!n)return new Et(e);let t=On.get(n)??{holder:new Et(e),users:0};return On.set(n,t),t.holder}function ts(e){for(let n of On.values())n.holder===e&&n.users++}function rs(e){for(let[n,t]of On)if(t.holder===e){setTimeout(()=>{--t.users<=0&&On.get(n)===t&&On.delete(n)},0);return}}function os(e,n=fetch.bind(globalThis)){return async(t,r)=>{let o=await n(t,r);if(o.status!==401||!e.canRefresh)return o;let s;try{s=await e.refresh()}catch{return o}return n(t,Ei(r,s))}}function Ei(e,n){let t=new Headers(e?.headers);return t.set("authorization",`Bearer ${n}`),{...e,headers:t}}import{jsx as Qr,jsxs as Li}from"react/jsx-runtime";var Oi="https://www.soba.so",Ii=3e4;function Ti(e){let{children:n,session:t,sessionEndpoint:r,user:o,sessionCacheKey:s,runEndpoint:a,theme:c,initialMachines:i,initialConnect:l=null,initialPlans:u,initialCurrentPlan:p=null,baseUrl:y=Oi,pollMs:f=Ii,injectStyles:m=!0,modal:w=!0,fetchImpl:M,onError:R}=e,[_,U]=Q(t??null),[P,T]=Q(null),[E,S]=Q(l),[W,ve]=Q(null),[X,ke]=Q(l===null),[V,oe]=Q(i??[]),[We,Y]=Q(null),[Pe,Qe]=Q(i===void 0),[ce,ue]=Q(u??[]),[ee,gn]=Q(p),[Xe,Le]=Q(null),[en,de]=Q(u===void 0),[ne,Be]=Q(null),[pe,Ae]=Q(!1),qe=Je(R);qe.current=R;let se=Te(k=>{T(k),qe.current?.(k)},[]);Ze(()=>{m&&st()},[m]);let O=In(()=>ns({...t?{token:t}:{},...r?{endpoint:r}:{},...o?{user:o}:{},...M?{fetchImpl:M}:{},...s?{cacheKey:s}:{}}),[t,r,o,M,s]);Ze(()=>{let k=!0;ts(O);let z=O.subscribe(()=>{k&&U(O.token)});return!O.token&&!O.canRefresh?se(new Error("<SobaProvider> needs a `session` or a `sessionEndpoint`. A browser cannot mint one: that takes your secret key.")):O.ensure().then(()=>k&&U(O.token),ae=>k&&se(ae)),()=>{k=!1,z(),rs(O)}},[O,se]),Ze(()=>{P&&(ke(!1),Qe(!1),de(!1),ve(k=>k??P),Y(k=>k??P),Le(k=>k??P))},[P]),Ze(()=>{let k=O.refreshAt;if(k===null)return;let z=()=>{O.refresh().catch(ge=>se(ge))},ae=()=>{document.hidden||(document.removeEventListener("visibilitychange",ae),z())},pt=setTimeout(()=>{typeof document<"u"&&document.hidden?document.addEventListener("visibilitychange",ae):z()},Math.max(0,k-Date.now()));return()=>{clearTimeout(pt),typeof document<"u"&&document.removeEventListener("visibilitychange",ae)}},[O,se,_]);let bn=Je(l?.machines_url??null),v=In(()=>{if(!_)return null;let k=new Ln({session:_,baseUrl:y,fetchImpl:os(O,M??fetch.bind(globalThis))});return k.setMachinesUrl(bn.current),k},[_,y,O,M]),F=Je(l!==null);Ze(()=>{if(!v||F.current)return;let k=!0;return ke(!0),v.context().then(z=>{k&&(S(z),ve(null),ke(!1))},z=>{k&&(ve(z),ke(!1))}),()=>{k=!1}},[v]);let me=Te(async()=>{if(v)try{let k=await v.machines();oe(Array.isArray(k)?k:[]),Y(null)}catch(k){Y(k)}finally{Qe(!1)}},[v]),fe=Te(async()=>{if(v)try{let k=await v.plans();ue(k.plans),gn(k.current),Le(null)}catch(k){Le(k)}finally{de(!1)}},[v]),te=Je(!1),[Fe,yn]=Q(!1),wn=Je(u!==void 0),nn=Je(!1),tn=Te(()=>{te.current||(te.current=!0,nn.current&&queueMicrotask(()=>{nn.current&&yn(!0)}))},[]);Ze(()=>(nn.current=!0,te.current&&yn(!0),()=>{nn.current=!1}),[]),Ze(()=>{!v||!Fe||wn.current||fe()},[v,Fe,fe]);let rn=Te(async k=>{if(!v)throw new Error("No session yet.");await v.selectPlan(k),await fe()},[v,fe]),Ot=Te(async(k,z)=>{if(!v)throw new Error("No session yet.");let ae=await v.checkoutPlan(k,z);if(!ae.url)throw new Error("Checkout could not be started.");return ae.url},[v]),lt=Te(async()=>{if(!v)throw new Error("No session yet.");await v.leavePlan(),await fe()},[v,fe]),ct=Je(i!==void 0);Ze(()=>{if(!v)return;let k=Oe(me,f,{immediate:!ct.current});return ct.current=!1,k},[v,me,f]);let vn=Te((k="manual")=>{w&&(Ae(!0),Be(k))},[w]),ut=Te(()=>Be(null),[]),G=Je(V);G.current=V;let Re=Te(async k=>{if(!a)throw new Error("Pass `runEndpoint` to <SobaProvider> to start runs from the browser. It is your own route: it holds your secret key, calls soba.run(), and forwards the stream.");let{signal:z,...ae}=k,ge=await(M??fetch.bind(globalThis))(a,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream"},credentials:"same-origin",body:JSON.stringify(ae),...z?{signal:z}:{}});if(!ge.ok){let $e=await ge.json().catch(()=>null),be=new Error($e?.error?.message??`${a} answered ${ge.status}.`);be.status=ge.status,$e?.error?.code&&(be.code=$e.error.code),$e?.error&&(be.error=$e.error);let mt=G.current.length>0&&!G.current.some(Tt=>Tt.state!=="offline");throw ge.status===409&&mt&&vn("no_compute"),be}let Ce=Ur(ge);return async function*(){try{yield*Ce}finally{te.current&&fe()}}()},[a,M,fe,vn]),he=In(()=>ee?ce.find(k=>k.id===ee.plan_id)??null:null,[ce,ee]),on=In(()=>he?he.connected_reward==="included"&&V.length>0&&he.connected_included_units!==null?he.connected_included_units:he.included_units:null,[he,V]),dt=In(()=>({plans:ce,current:ee,plan:he,used:ee?.units_used??null,included:on,remaining:on!==null&&ee?Math.max(0,on-ee.units_used):null,unlimited:he!==null&&on===null,loading:en,error:Xe,select:rn,checkout:Ot,leave:lt,refresh:fe}),[ce,ee,he,on,en,Xe,rn,Ot,lt,fe]),It=In(()=>({session:_,client:v,error:P,get plan(){return tn(),dt},compute:{machines:V,connected:V.length>0,online:V.some(k=>k.state!=="offline"),loading:Pe,error:We,refresh:me},connect:{app:E?.app??null,command:E?.command??null,connectUrl:E?.connect_url??null,publishableKey:E?.publishable_key??null,loading:X,error:W,open:vn,close:ut,isOpen:ne!==null,hasModal:w},run:Re}),[_,v,P,dt,tn,ne,vn,ut,w,V,Pe,We,me,E,X,W,Re]);return Qr(Mr.Provider,{value:v,children:Qr(Pr.Provider,{value:{context:E,machines:Pe?void 0:V,theme:c??E?.theme??"light"},children:Li(Rr.Provider,{value:It,children:[n,w&&pe&&Qr(nt,{open:ne!==null,onOpenChange:k=>Be(k?ne??"manual":null),onConnected:()=>{me()},...ne==="payment_required"||ne==="no_compute"?{reason:ne}:{},...ne==="pair"?{showStatus:!1}:{}})]})})})}function Ai(e){return e?$i[e]??e:null}var $i={"user-hardware":"your own computer","user-subscription":"your own AI plan","user-api-key":"your own API key","open-weights":"open models we host",frontier:"a frontier model we pay for"};async function Di(e,n,t){let r=n.local;if(!r?.session||n.after)return null;let o=/\/v1\/runs\/([^/]+)\/events/.exec(e.url)?.[1];if(!o)return null;let s=`http://127.0.0.1:${r.port??47321}/v1/runs/${o}/events`,a=new AbortController,c=()=>a.abort();n.signal?.addEventListener("abort",c);let i=setTimeout(()=>a.abort(),r.timeoutMs??3e3);try{let l=await t(s,{headers:{authorization:`Bearer ${r.session}`,accept:"text/event-stream"},signal:a.signal});return l.ok?{url:s,bearer:r.session,open:l}:null}catch{return null}finally{clearTimeout(i),n.signal?.removeEventListener("abort",c)}}async function*Ui(e){let n=e.body;if(!n)return;let t=n.getReader(),r=new TextDecoder,o="",s=null,a=[];try{for(;;){let c=await t.read();if(c.done)return;o+=r.decode(c.value,{stream:!0});for(let i=o.indexOf(`
3416
+ `,document.head.appendChild(e)}import{jsx as Ue,jsxs as ht}from"react/jsx-runtime";function _o(e){if(!e)return null;let n=wn(e);if(n==="payment_required"||n==="no_compute")return null;if(typeof e=="string")return e||null;let t=e,r=t.error?.message;return typeof r=="string"&&r?r:typeof t.message=="string"&&t.message?t.message:"The run ended with an error."}function gi(){return ht("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Ue("path",{d:"M8 5v4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),Ue("circle",{cx:"8",cy:"11.6",r:"0.9",fill:"currentColor"}),Ue("circle",{cx:"8",cy:"8",r:"6.4",stroke:"currentColor",strokeWidth:"1.3"})]})}function Ai({error:e,onRetry:n,onDismiss:t,title:r,className:o}){let a=_o(e),s=H();return fi(()=>mt(),[]),a?Ue("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":s.theme,role:"alert",children:ht("div",{className:"sc-card sc-limit sc-run-error",children:[ht("div",{className:"sc-limit-head",children:[Ue("span",{className:"sc-limit-mark sc-run-error-mark","aria-hidden":"true",children:Ue(gi,{})}),ht("div",{children:[Ue("h2",{className:"sc-limit-title",children:r??"That run did not finish"}),Ue("p",{className:"sc-limit-body sc-run-error-message",children:a})]})]}),(t||n)&&ht("div",{className:"sc-limit-actions",children:[t&&Ue("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,children:"Dismiss"}),n&&Ue("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:n,children:"Try again"})]})]})}):null}import{useId as bi,useState as $o}from"react";import{jsx as re,jsxs as Wt}from"react/jsx-runtime";function yi({reason:e}){return re("span",{className:"sc-limit-mark","aria-hidden":"true",children:e==="no_compute"?re(xt,{}):re(q,{})})}function wi(e){let{error:n,variant:t="card",onDismiss:r,className:o}=e,a=zr(n,{predict:e.predict??!("error"in e)}),s=bi(),c=H();if(!a)return null;let i=re(Ci,{offer:a,headingId:s,onDismiss:r});return t==="dialog"?re(st,{open:!0,onClose:()=>r?.(),labelledBy:s,theme:c.theme,children:i}):re("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":c.theme,children:i})}function Ci({offer:e,headingId:n,onDismiss:t}){let{compute:r}=Q(),[o,a]=$o(!1),[s,c]=$o(null),i=e.reason==="no_compute"&&r.connected&&!r.online,l=i||e.connectOffer!==null||!r.connected,u=pt();async function m(){a(!0),c(null);try{await e.upgrade()}catch(b){c(b.message)}finally{a(!1)}}return Wt("div",{className:"sc-card sc-limit",children:[Wt("div",{className:"sc-limit-head",children:[re(yi,{reason:e.reason}),Wt("div",{children:[re("h2",{className:"sc-limit-title",id:n,children:e.title}),re("p",{className:"sc-limit-body",children:e.body})]})]}),s&&re("p",{className:"sc-error",children:s}),i&&u.note&&re("p",{className:"sc-limit-note",children:u.note}),Wt("div",{className:"sc-limit-actions",children:[t&&re("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,disabled:o,children:"Not now"}),e.upgradeTo&&re("button",{type:"button",className:l?"sc-btn":"sc-btn sc-btn-primary",onClick:()=>void m(),disabled:o,children:o?"Opening\u2026":e.upgradeTo.selectable?`Switch to ${e.upgradeTo.name}`:`${e.upgradeTo.name} for $${e.upgradeTo.price.toLocaleString()}/${e.upgradeTo.interval}`}),l&&re("button",{type:"button",className:i?"sc-btn":"sc-btn sc-btn-primary",onClick:e.connect,disabled:o,children:i?"Connect another machine":"Connect compute"}),i&&re("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:u.open,disabled:o,children:"Open Soba App"})]})]})}import{useMemo as vi}from"react";function ft(){let{plan:e,compute:n,connect:t}=Q();return vi(()=>{let r=e.plan,o=e.current,a={plan:r,assignment:o,loading:e.loading,error:e.error,periodEnd:o?.period_end?new Date(o.period_end):null};if(!r)return{...a,state:"none",trialDaysLeft:null,ceiling:null,raised:!1,uncounted:!1,used:0,remaining:null,percent:null,unlimited:!1,reward:null,summary:"Nothing is assigned to this account, so runs are bounded by whatever the app allows."};let s=xi(o?.trial_ends_at??null),c=r.connected_reward==="included"&&n.connected&&r.connected_included_units!==null,i=c?r.connected_included_units:r.included_units,l=r.connected_reward==="unlimited"&&n.connected,u=i===null,m=e.used??0,b=i===null?null:Math.max(0,i-m),g=i&&i>0?Math.min(100,Math.round(m/i*100)):null,h=i!==null&&m>=i,y=s!==null?"trial":u?"unlimited":h?r.overage==="meter"?"metered":"spent":"within";return{...a,state:y,trialDaysLeft:s,ceiling:i,raised:c,uncounted:l,used:m,remaining:b,percent:g,unlimited:u,reward:ki(r,c||l,n.connected,()=>t.open("manual")),summary:Ni({plan:r,assignment:o,used:m,ceiling:i,trialDaysLeft:s,raised:c,uncounted:l,state:y})}},[e,n.connected,t])}function ki(e,n,t,r){let o=Ve({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6});return o?{line:o,inForce:n,required:!1,connected:t,actionable:Je(e.connected_reward)&&!t,open:r}:Le(e.route_allow)&&!t?{line:"Nothing connected yet, so nothing can run.",inForce:!1,required:!0,connected:t,actionable:!0,open:r}:null}function Ni(e){let{plan:n,assignment:t,used:r,ceiling:o,trialDaysLeft:a,raised:s,uncounted:c,state:i}=e,l=`${n.unit}${r===1?"":"s"}`,u=c?" Runs your own AI serves do not count toward it.":"";if(i==="trial"&&a!==null){let g=n.price===0?"it continues free":`it is $${n.price.toLocaleString()} a ${n.interval}`;return`${a} ${a===1?"day":"days"} left of your trial, then ${g}.`}if(i==="unlimited")return`${r.toLocaleString()} ${l} this period. No ceiling on this plan.`;if(i==="metered"){let g=r-(o??0);return n.overage_per_unit>0?`${g.toLocaleString()} past the allowance, billed at $${n.overage_per_unit} a ${n.unit}.${u}`:`${g.toLocaleString()} past the allowance.${u}`}if(i==="spent")return t?.period_end?`Allowance spent. It comes back on ${es(t.period_end)}.${u}`:`Allowance spent. It comes back at the start of the next period.${u}`;let m=Math.max(0,(o??0)-r),b=s?` Raised from ${(n.included_units??0).toLocaleString()} while your own AI is connected.`:t?.period_end?` Resets ${es(t.period_end)}.`:"";return`${m.toLocaleString()} of ${(o??0).toLocaleString()} ${n.unit}s left.${b}${u}`}function xi(e){if(!e)return null;let n=new Date(e).getTime()-Date.now();return Number.isNaN(n)||n<=0?null:Math.max(1,Math.ceil(n/864e5))}function es(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}import{Fragment as Si,jsx as oe,jsxs as Te}from"react/jsx-runtime";function Kr({heading:e="Current plan",showUsage:n=!0,showName:t=!0,className:r}){let o=ft(),{theme:a}=H(),s=b=>oe("section",{className:r?`soba-connect sc-fill ${r}`:"soba-connect sc-fill","data-theme":a,children:Te("div",{className:"sc-card sc-current",children:[e&&oe("h2",{className:"sc-section-title",children:e}),b]})});if(o.error)return s(oe("p",{className:"sc-error",children:o.error.message}));if(o.loading)return s(oe("p",{className:"sc-note",children:"Loading\u2026"}));if(!o.plan)return s(Te("div",{className:"sc-current-main",children:[oe("p",{className:"sc-current-name",children:"No plan"}),oe("p",{className:"sc-sub",children:o.summary})]}));let{plan:c,trialDaysLeft:i,percent:l,unlimited:u,reward:m}=o;return s(Te(Si,{children:[Te("div",{className:"sc-current-grid",children:[(t||i!==null)&&Te("div",{className:"sc-current-main",children:[t?Te("p",{className:"sc-current-name",children:[c.name,i!==null&&Te("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})]}):i!==null&&oe("p",{className:"sc-current-trial",children:Te("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})}),t&&c.description&&oe("p",{className:"sc-sub",children:c.description})]}),n&&Te("div",{className:"sc-usage",children:[Te("div",{className:"sc-row-between",children:[oe("span",{className:"sc-fact-key",children:"Usage"}),oe("span",{className:l!==null&&l>=100?"sc-usage-figure sc-usage-over":"sc-usage-figure",children:u?"Unlimited":l===null?"Metered":`${l}% used`})]}),l!==null&&oe("div",{className:"sc-meter",role:"presentation",children:l>0&&oe("span",{className:l>=100?"sc-meter-fill sc-meter-full":"sc-meter-fill",style:{width:`${l}%`}})}),oe("p",{className:"sc-usage-line",children:o.summary})]})]}),m&&Te("div",{className:"sc-current-foot",children:[oe("p",{className:m.required?"sc-plan-reward-line sc-plan-reward-need":m.inForce?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-open",children:m.required?m.line:m.inForce?`In force: ${Mi(m.line)}.`:m.line}),(m.actionable||m.connected)&&oe(yn,{})]})]}))}var Mi=e=>e.charAt(0).toLowerCase()+e.slice(1);import{useCallback as Pi,useMemo as Ri,useState as ns}from"react";var Ei={"user-hardware":"your own machine","user-subscription":"your own AI subscription","open-weights":"open models we host",frontier:"frontier models"},Ii=new Set(["user-hardware","user-subscription"]);function _r(e={}){let{plan:n,compute:t,connect:r}=Q(),[o,a]=ns(null),[s,c]=ns(null),{featured:i,onSelect:l,successUrl:u,cancelUrl:m}=e,b=Pi(async h=>{a(h.id),c(null);try{if(h.selectable)await n.select(h.id);else if(l)l(h);else{let y=await n.checkout(h.id,{...u?{successUrl:u}:{},...m?{cancelUrl:m}:{}});window.location.assign(y);return}}catch(y){throw c(y.message),y}finally{(h.selectable||l)&&a(null)}},[n,l,u,m]),g=Ri(()=>n.plans.map(h=>{let y=n.current?.plan_id===h.id;return{plan:h,current:y,featured:i===h.id&&!y,price:Oi(h),allowance:h.included_units===null?`Unlimited ${h.unit}s`:`${h.included_units.toLocaleString()} ${h.unit}${h.included_units===1?"":"s"}`,allowanceNote:Li(h),computeLabel:h.route_allow===null?"any compute":h.route_allow.length===0?"no compute":null,compute:(h.route_allow??[]).map(N=>({costClass:N,label:Ei[N]??N,owned:Ii.has(N),runtimes:tr(N).map(P=>P.id)})),connect:Ti(h,y,t.connected,()=>r.open("manual")),cta:{label:Bi(h,y,o===h.id),disabled:y||o!==null,busy:o===h.id,take:()=>b(h)}}}),[n.plans,n.current,i,t.connected,r,o,b]);return{offers:g,current:g.find(h=>h.current)??null,loading:n.loading,error:n.error,failed:s}}function Oi(e){return e.price===0?{amount:"Free",interval:null,free:!0}:{amount:`$${e.price.toLocaleString()}`,interval:e.interval,free:!1}}function Li(e){let n=[];return e.included_units===null?n.push("No ceiling on this plan"):(n.push(`Included each ${e.interval}`),e.overage==="meter"&&e.overage_per_unit>0?n.push(`then $${e.overage_per_unit} a ${e.unit}`):e.included_units>0&&n.push(`then ${e.unit}s stop`)),e.trial_days>0&&n.push(`${e.trial_days}-day trial`),n.join(" \xB7 ")}function Ti(e,n,t,r){let o=Ve({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6}),a=Le(e.route_allow)&&!t;if(!o&&!a)return null;let s=Je(e.connected_reward);return{key:o?"Connect your own":"To use this",line:o??(n?"Nothing connected yet, so nothing can run.":"Runs only on compute you connect."),reward:o!==null,actionable:n&&(s||a)&&!t,open:r}}function Bi(e,n,t){return n?"Your plan":t?e.selectable?"Switching\u2026":"Opening\u2026":e.selectable?"Choose":`Subscribe for $${e.price.toLocaleString()}/${e.interval}`}import{jsx as A,jsxs as D}from"react/jsx-runtime";function Ht(e){return e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill"}function $r({onSelect:e,successUrl:n,cancelUrl:t,showCompute:r=!0,showConnect:o=!1,variant:a="cards",featured:s,className:c}){let{offers:i,loading:l,error:u,failed:m}=_r({...s?{featured:s}:{},...e?{onSelect:e}:{},...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),{theme:b}=H();if(u)return A("div",{className:Ht(c),"data-theme":b,children:A("div",{className:"sc-card",children:A("p",{className:"sc-error",children:u.message})})});if(l)return A("div",{className:Ht(c),"data-theme":b,children:A("div",{className:"sc-card",children:A("p",{className:"sc-note",children:"Loading plans\u2026"})})});if(i.length===0)return A("div",{className:Ht(c),"data-theme":b,children:A("div",{className:"sc-card",children:A("p",{className:"sc-note",children:"This app has no plans yet."})})});let g={showCompute:r,showConnect:o};return D("div",{className:Ht(c),"data-theme":b,"data-variant":a,children:[a==="rows"?A(Wi,{offers:i,shelf:g}):a==="table"?A(Hi,{offers:i,shelf:g}):A(Gi,{offers:i,shelf:g}),m&&A("p",{className:"sc-error",children:m})]})}function Gi({offers:e,shelf:n}){return A("div",{className:"sc-plans",children:e.map(t=>D("div",{className:ts("sc-plan",t),children:[D("div",{className:"sc-row-between",children:[A("span",{className:"sc-title",children:t.plan.name}),A(eo,{offer:t})]}),A("p",{className:"sc-sub",children:t.plan.description}),A(no,{price:t.price,free:"forever"}),A(oo,{offer:t,shelf:n}),A(rs,{offer:t}),A("div",{className:"sc-plan-band",children:n.showCompute&&A(ro,{offer:t})}),A("div",{className:"sc-plan-band",children:A(to,{offer:t})})]},t.plan.id))})}function Wi({offers:e,shelf:n}){return A("ul",{className:"sc-plan-rows",children:e.map(t=>D("li",{className:ts("sc-plan-row",t),children:[D("div",{className:"sc-row-main",children:[D("span",{className:"sc-row-name",children:[A("span",{className:"sc-title",children:t.plan.name}),A(eo,{offer:t})]}),t.plan.description&&A("p",{className:"sc-sub",children:t.plan.description}),A(rs,{offer:t}),n.showCompute&&A(ro,{offer:t,inline:!0}),A(to,{offer:t,inline:!0})]}),D("div",{className:"sc-row-side",children:[A(no,{price:t.price,free:"forever",small:!0}),A(oo,{offer:t,shelf:n})]})]},t.plan.id))})}function Hi({offers:e,shelf:n}){let t=e.some(s=>s.plan.overage_per_unit>0),r=e.some(s=>s.plan.trial_days>0),o=e.some(s=>s.connect!==null),a=s=>[s.current?"sc-col-current":"",s.featured?"sc-col-featured":""].filter(Boolean).join(" ")||void 0;return A("div",{className:"sc-table-scroll",children:D("table",{className:"sc-plan-table",children:[A("thead",{children:D("tr",{children:[A("td",{}),e.map(s=>D("th",{scope:"col",className:a(s),children:[D("span",{className:"sc-row-name",children:[A("span",{className:"sc-title",children:s.plan.name}),A(eo,{offer:s})]}),A(no,{price:s.price,small:!0})]},s.plan.id))]})}),D("tbody",{children:[D("tr",{children:[A("th",{scope:"row",children:"Included"}),e.map(s=>A("td",{className:a(s),children:s.allowance},s.plan.id))]}),t&&D("tr",{children:[A("th",{scope:"row",children:"Then"}),e.map(s=>A("td",{className:a(s),children:s.plan.overage_per_unit>0?`$${s.plan.overage_per_unit} / ${s.plan.unit}`:A("span",{className:"sc-muted-cell",children:"Stops"})},s.plan.id))]}),r&&D("tr",{children:[A("th",{scope:"row",children:"Trial"}),e.map(s=>A("td",{className:a(s),children:s.plan.trial_days>0?`${s.plan.trial_days} days`:A("span",{className:"sc-muted-cell",children:"None"})},s.plan.id))]}),n.showCompute&&D("tr",{children:[A("th",{scope:"row",children:"Runs on"}),e.map(s=>A("td",{className:a(s),children:A(ro,{offer:s,bare:!0})},s.plan.id))]}),o&&D("tr",{children:[A("th",{scope:"row",children:"Connect your own"}),e.map(s=>A("td",{className:a(s),children:A(to,{offer:s,bare:!0})},s.plan.id))]}),D("tr",{className:"sc-table-buy",children:[A("td",{}),e.map(s=>A("td",{className:a(s),children:A(oo,{offer:s,shelf:n})},s.plan.id))]})]})]})})}function ts(e,n){return[e,n.current?"sc-plan-current":"",n.featured?"sc-plan-featured":""].filter(Boolean).join(" ")}function eo({offer:e}){return e.current?A("span",{className:"sc-plan-badge",children:"Current"}):e.featured?A("span",{className:"sc-plan-badge-soft",children:"Recommended"}):null}function no({price:e,small:n,free:t}){return D("p",{className:n?"sc-plan-price sc-plan-price-sm":"sc-plan-price",children:[A("span",{className:"sc-plan-amount",children:e.amount}),e.interval?D("span",{className:"sc-plan-interval",children:["/",e.interval]}):t&&A("span",{className:"sc-plan-interval sc-plan-after",children:t})]})}function rs({offer:e}){return D("p",{className:"sc-plan-allowance",children:[A("span",{className:"sc-plan-figure",children:e.allowance}),A("span",{className:"sc-plan-qualifier",children:e.allowanceNote})]})}function to({offer:e,inline:n,bare:t}){let r=e.connect;if(!r)return t?A("span",{className:"sc-muted-cell",children:"None"}):null;let o=r.reward?"sc-plan-reward-line":"sc-plan-reward-line sc-plan-reward-need",a=r.actionable?D("button",{type:"button",className:`${o} sc-plan-reward-act`,"aria-label":"Connect compute",onClick:r.open,children:[A("span",{className:"sc-reward-said",children:r.line}),D("span",{className:"sc-reward-do","aria-hidden":!0,children:[A(q,{className:"sc-reward-mark"}),"Connect compute"]})]}):A("p",{className:o,children:r.line});return t?a:A("div",{className:n?"sc-plan-reward sc-plan-reward-inline":"sc-plan-reward",children:a})}function ro({offer:e,inline:n,bare:t}){let r=e.computeLabel?A("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:A("li",{children:e.computeLabel})}):A("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:e.compute.map(o=>D("li",{className:o.owned?"sc-compute-own":void 0,children:[o.label,A(Di,{runtimes:o.runtimes})]},o.costClass))});return t?r:D("div",{className:n?"sc-plan-compute sc-plan-compute-inline":"sc-plan-compute",children:[A("span",{className:"sc-fact-key",children:"Runs on"}),r]})}function oo({offer:e,shelf:n}){let t=e.connect;return n.showConnect&&t?.actionable?D("button",{type:"button",className:"sc-btn sc-btn-primary sc-btn-icon",onClick:t.open,children:[A(q,{className:"sc-btn-mark"}),"Connect compute"]}):A("button",{type:"button",className:e.current?"sc-btn":"sc-btn sc-btn-primary",disabled:e.cta.disabled,onClick:()=>void e.cta.take().catch(()=>{}),children:e.cta.label})}function Di({runtimes:e}){return e.length===0?null:A("span",{className:"sc-compute-marks",children:e.map(n=>{let t=Ze[n];return t?A(t,{className:"sc-rt-mark"},n):null})})}import{jsx as so,jsxs as os}from"react/jsx-runtime";function Ui({heading:e,plansHeading:n,showUsage:t=!0,showName:r=!0,className:o,...a}){let{plan:s,loading:c}=ft(),{theme:i}=H(),l=n??(c?"Plans":s?"Change plan":"Choose a plan");return os("div",{className:o?`soba-connect sc-fill sc-billing ${o}`:"soba-connect sc-fill sc-billing","data-theme":i,children:[so(Kr,{...e===void 0?{}:{heading:e},showUsage:t,showName:r}),os("section",{className:"sc-billing-plans",children:[l&&so("h2",{className:"sc-section-title",children:l}),so($r,{...a})]})]})}import{useCallback as ss,useState as as}from"react";function ao({plan:e,successUrl:n,cancelUrl:t,label:r}){let{plan:o}=Q(),[a,s]=as(!1),[c,i]=as(null),l=ss(()=>o.checkout(e.id,{...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),[o,e.id,n,t]),u=ss(async()=>{s(!0),i(null);try{window.location.assign(await l())}catch(m){i(m.message),s(!1)}},[l]);return{label:a?"Opening\u2026":r??`Subscribe for $${e.price.toLocaleString()}/${e.interval}`,busy:a,error:c,buy:u,session:l}}import{jsx as is,jsxs as Qi}from"react/jsx-runtime";function Fi({plan:e,successUrl:n,cancelUrl:t,label:r,className:o}){let{theme:a}=H(),s=ao({plan:e,...n?{successUrl:n}:{},...t?{cancelUrl:t}:{},...r?{label:r}:{}});return Qi("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":a,children:[is("button",{type:"button",className:"sc-btn sc-btn-primary",disabled:s.busy,onClick:()=>void s.buy(),children:s.label}),s.error&&is("p",{className:"sc-error",children:s.error})]})}import{useCallback as Fe,useEffect as $e,useMemo as Wn,useRef as en,useState as se}from"react";var Vi="soba.session:";function ls(e){return!e.cacheKey||!e.endpoint?null:Vi+JSON.stringify([e.endpoint,e.user??null,e.cacheKey])}function Ji(e){try{let n=globalThis.localStorage?.getItem(e);if(!n)return null;let t=JSON.parse(n);return typeof t.token!="string"||typeof t.expiresAt!="number"?null:{token:t.token,expiresAt:t.expiresAt}}catch{return null}}function Yi(e,n){try{n?globalThis.localStorage?.setItem(e,JSON.stringify(n)):globalThis.localStorage?.removeItem(e)}catch{}}var cs=6e4,ji=1e4,Dt=class{#e;#n=null;#r=null;#t;#o=new Set;constructor(n){this.#t=n,this.#e=n.token??null;let t=ls(n),r=t&&!this.#e?Ji(t):null;r&&r.expiresAt-cs>Date.now()&&(this.#e=r.token,this.#n=r.expiresAt)}get token(){return this.#e}get expiresAt(){return this.#n}get canRefresh(){return!!this.#t.endpoint}get refreshAt(){return!this.canRefresh||this.#n===null?null:Math.max(Date.now()+ji,this.#n-cs)}subscribe(n){return this.#o.add(n),()=>this.#o.delete(n)}async ensure(){return this.#e?this.#e:this.refresh()}async refresh(){if(this.#r)return this.#r;let n=this.#t.endpoint;if(!n)throw new Error("This Soba session cannot be refreshed. Pass `sessionEndpoint` so the provider can mint a new one.");let t=this.#t.fetchImpl??fetch.bind(globalThis);this.#r=(async()=>{let r=await t(n,{method:"POST",headers:{"content-type":"application/json"},credentials:"same-origin",body:JSON.stringify(this.#t.user?{user:this.#t.user}:{})});if(!r.ok)throw new Error(`Could not start a Soba session (${r.status} from ${n}).`);let o=await r.json(),a=o.session??o.token;if(!a)throw new Error(`${n} answered without a \`session\`. See @soba-so/react's README.`);let s=o.expires_in??o.expiresIn;this.#e=a,this.#n=typeof s=="number"?Date.now()+s*1e3:null;let c=ls(this.#t);c&&Yi(c,this.#n===null?null:{token:a,expiresAt:this.#n});for(let i of this.#o)i();return a})();try{return await this.#r}finally{this.#r=null}}},Gn=new Map,us=new WeakMap,zi=1;function qi(e){if(e.token||!e.endpoint)return null;let n=0;return e.fetchImpl&&(n=us.get(e.fetchImpl)??zi++,us.set(e.fetchImpl,n)),JSON.stringify([e.endpoint,e.user??null,n,e.cacheKey??null])}function ds(e){let n=qi(e);if(!n)return new Dt(e);let t=Gn.get(n)??{holder:new Dt(e),users:0};return Gn.set(n,t),t.holder}function ps(e){for(let n of Gn.values())n.holder===e&&n.users++}function ms(e){for(let[n,t]of Gn)if(t.holder===e){setTimeout(()=>{--t.users<=0&&Gn.get(n)===t&&Gn.delete(n)},0);return}}function hs(e,n=fetch.bind(globalThis)){return async(t,r)=>{let o=await n(t,r);if(o.status!==401||!e.canRefresh)return o;let a;try{a=await e.refresh()}catch{return o}return n(t,Zi(r,a))}}function Zi(e,n){let t=new Headers(e?.headers);return t.set("authorization",`Bearer ${n}`),{...e,headers:t}}import{jsx as io,jsxs as $i}from"react/jsx-runtime";var Xi="https://soba.so",Ki=3e4;function _i(e){let{children:n,session:t,sessionEndpoint:r,user:o,sessionCacheKey:a,runEndpoint:s,theme:c,initialMachines:i,initialConnect:l=null,initialPlans:u,initialCurrentPlan:m=null,baseUrl:b=Xi,pollMs:g=Ki,injectStyles:h=!0,modal:y=!0,fetchImpl:N,onError:P}=e,[R,W]=se(t??null),[E,I]=se(null),[O,k]=se(l),[U,pe]=se(null),[ne,ae]=se(l===null),[Z,me]=se(i??[]),[Ye,$]=se(null),[ye,Se]=se(i===void 0),[X,ie]=se(u??[]),[z,Pe]=se(m),[he,fe]=se(null),[nn,V]=se(u===void 0),[J,te]=se(null),[T,le]=se(!1),Re=en(P);Re.current=P;let ce=Fe(w=>{I(w),Re.current?.(w)},[]);$e(()=>{h&&mt()},[h]);let L=Wn(()=>ds({...t?{token:t}:{},...r?{endpoint:r}:{},...o?{user:o}:{},...N?{fetchImpl:N}:{},...a?{cacheKey:a}:{}}),[t,r,o,N,a]);$e(()=>{let w=!0;ps(L);let ee=L.subscribe(()=>{w&&W(L.token)});return!L.token&&!L.canRefresh?ce(new Error("<SobaProvider> needs a `session` or a `sessionEndpoint`. A browser cannot mint one: that takes your secret key.")):L.ensure().then(()=>w&&W(L.token),ge=>w&&ce(ge)),()=>{w=!1,ee(),ms(L)}},[L,ce]),$e(()=>{E&&(ae(!1),Se(!1),V(!1),pe(w=>w??E),$(w=>w??E),fe(w=>w??E))},[E]),$e(()=>{let w=L.refreshAt;if(w===null)return;let ee=()=>{L.refresh().catch(ve=>ce(ve))},ge=()=>{document.hidden||(document.removeEventListener("visibilitychange",ge),ee())},wt=setTimeout(()=>{typeof document<"u"&&document.hidden?document.addEventListener("visibilitychange",ge):ee()},Math.max(0,w-Date.now()));return()=>{clearTimeout(wt),typeof document<"u"&&document.removeEventListener("visibilitychange",ge)}},[L,ce,R]);let B=en(l?.machines_url??null),x=Wn(()=>{if(!R)return null;let w=new Dn({session:R,baseUrl:b,fetchImpl:hs(L,N??fetch.bind(globalThis))});return w.setMachinesUrl(B.current),w},[R,b,L,N]),tn=en(l!==null);$e(()=>{if(!x||tn.current)return;let w=!0;return ae(!0),x.context().then(ee=>{w&&(k(ee),pe(null),ae(!1))},ee=>{w&&(pe(ee),ae(!1))}),()=>{w=!1}},[x]);let je=Fe(async()=>{if(x)try{let w=await x.machines();me(Array.isArray(w)?w:[]),$(null)}catch(w){$(w)}finally{Se(!1)}},[x]),we=Fe(async()=>{if(x)try{let w=await x.plans();ie(w.plans),Pe(w.current),fe(null)}catch(w){fe(w)}finally{V(!1)}},[x]),ue=en(!1),[ze,Cn]=se(!1),vn=en(u!==void 0),rn=en(!1),on=Fe(()=>{ue.current||(ue.current=!0,rn.current&&queueMicrotask(()=>{rn.current&&Cn(!0)}))},[]);$e(()=>(rn.current=!0,ue.current&&Cn(!0),()=>{rn.current=!1}),[]),$e(()=>{!x||!ze||vn.current||we()},[x,ze,we]);let sn=Fe(async w=>{if(!x)throw new Error("No session yet.");await x.selectPlan(w),await we()},[x,we]),Ut=Fe(async(w,ee)=>{if(!x)throw new Error("No session yet.");let ge=await x.checkoutPlan(w,ee);if(!ge.url)throw new Error("Checkout could not be started.");return ge.url},[x]),gt=Fe(async()=>{if(!x)throw new Error("No session yet.");await x.leavePlan(),await we()},[x,we]),At=en(i!==void 0);$e(()=>{if(!x)return;let w=Me(je,g,{immediate:!At.current});return At.current=!1,w},[x,je,g]);let kn=Fe((w="manual")=>{y&&(le(!0),te(w))},[y]),bt=Fe(()=>te(null),[]),K=en(Z);K.current=Z;let Be=Fe(async w=>{if(!s)throw new Error("Pass `runEndpoint` to <SobaProvider> to start runs from the browser. It is your own route: it holds your secret key, calls soba.run(), and forwards the stream.");let{signal:ee,...ge}=w,ve=await(N??fetch.bind(globalThis))(s,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream"},credentials:"same-origin",body:JSON.stringify(ge),...ee?{signal:ee}:{}});if(!ve.ok){let Qe=await ve.json().catch(()=>null),ke=new Error(Qe?.error?.message??`${s} answered ${ve.status}.`);ke.status=ve.status,Qe?.error?.code&&(ke.code=Qe.error.code),Qe?.error&&(ke.error=Qe.error);let Ct=K.current.length>0&&!K.current.some(Qt=>Qt.state!=="offline");throw ve.status===409&&Ct&&kn("no_compute"),ke}let Ee=Xr(ve);return async function*(){try{yield*Ee}finally{ue.current&&we()}}()},[s,N,we,kn]),Ce=Wn(()=>z?X.find(w=>w.id===z.plan_id)??null:null,[X,z]),an=Wn(()=>Ce?Ce.connected_reward==="included"&&Z.length>0&&Ce.connected_included_units!==null?Ce.connected_included_units:Ce.included_units:null,[Ce,Z]),yt=Wn(()=>({plans:X,current:z,plan:Ce,used:z?.units_used??null,included:an,remaining:an!==null&&z?Math.max(0,an-z.units_used):null,unlimited:Ce!==null&&an===null,loading:nn,error:he,select:sn,checkout:Ut,leave:gt,refresh:we}),[X,z,Ce,an,nn,he,sn,Ut,gt,we]),Ft=Wn(()=>({session:R,client:x,error:E,get plan(){return on(),yt},compute:{machines:Z,connected:Z.length>0,online:Z.some(w=>w.state!=="offline"),loading:ye,error:Ye,refresh:je},connect:{app:O?.app??null,command:O?.command??null,connectUrl:O?.connect_url??null,publishableKey:O?.publishable_key??null,loading:ne,error:U,open:kn,close:bt,isOpen:J!==null,hasModal:y},run:Be}),[R,x,E,yt,on,J,kn,bt,y,Z,ye,Ye,je,O,ne,U,Be]);return io(Br.Provider,{value:x,children:io(Gr.Provider,{value:{context:O,machines:ye?void 0:Z,theme:c??O?.theme??"light"},children:$i(Wr.Provider,{value:Ft,children:[n,y&&T&&io(ut,{open:J!==null,onOpenChange:w=>te(w?J??"manual":null),onConnected:()=>{je()},...J==="payment_required"||J==="no_compute"?{reason:J}:{},...J==="pair"?{showStatus:!1}:{}})]})})})}function el(e){return e?nl[e]??e:null}var nl={"user-hardware":"your own computer","user-subscription":"your own AI plan","user-api-key":"your own API key","open-weights":"open models we host",frontier:"a frontier model we pay for"};async function tl(e,n,t){let r=n.local;if(!r?.session||n.after)return null;let o=/\/v1\/runs\/([^/]+)\/events/.exec(e.url)?.[1];if(!o)return null;let a=`http://127.0.0.1:${r.port??47321}/v1/runs/${o}/events`,s=new AbortController,c=()=>s.abort();n.signal?.addEventListener("abort",c);let i=setTimeout(()=>s.abort(),r.timeoutMs??3e3);try{let l=await t(a,{headers:{authorization:`Bearer ${r.session}`,accept:"text/event-stream"},signal:s.signal});return l.ok?{url:a,bearer:r.session,open:l}:null}catch{return null}finally{clearTimeout(i),n.signal?.removeEventListener("abort",c)}}async function*rl(e){let n=e.body;if(!n)return;let t=n.getReader(),r=new TextDecoder,o="",a=null,s=[];try{for(;;){let c=await t.read();if(c.done)return;o+=r.decode(c.value,{stream:!0});for(let i=o.indexOf(`
3017
3417
  `);i!==-1;i=o.indexOf(`
3018
- `)){let l=o.slice(0,i).replace(/\r$/,"");if(o=o.slice(i+1),l==="")a.length&&(yield{id:s,data:a.join(`
3019
- `)}),s=null,a=[];else if(l.startsWith("id:")){let u=Number(l.slice(3).trim());s=Number.isFinite(u)?u:null}else if(l.startsWith("data:")){let u=l.slice(5);a.push(u.startsWith(" ")?u.slice(1):u)}}}}finally{t.cancel().catch(()=>{})}}var Xr=(e,n)=>new Promise(t=>{let r=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(r),t()})});async function*Hi(e,n={}){let t=n.fetchImpl??fetch.bind(globalThis),r=await Di(e,n,t)??{url:e.url,bearer:e.token,open:null},o=n.maxRetries??6,s=n.after??0,a=0;for(;;){if(n.signal?.aborted)return;let c;try{c=r.open??await t(r.url,{headers:{authorization:`Bearer ${r.bearer}`,accept:"text/event-stream",...s?{"last-event-id":String(s)}:{}},...n.signal?{signal:n.signal}:{}}),r.open=null}catch(i){if(n.signal?.aborted)return;if(++a>o)throw i;await Xr(1e3*a,n.signal);continue}if(c.status===503&&a<o){a++,await Xr(Number(c.headers.get("retry-after")??3)*1e3,n.signal);continue}if(!c.ok){let i=`Could not read this run (${c.status}).`;try{let l=await c.json();l.error?.message&&(i=l.error.message)}catch{}throw new Error(i)}for await(let i of Ui(c)){i.id!==null&&(s=i.id),a=0;let l=En(i.data);if(l&&(yield l,l.type==="done"||l.type==="error"))return}if(n.signal?.aborted)return;if(++a>o)throw new Error("Lost this run's stream and could not get it back.");await Xr(1e3*a,n.signal)}}export{ya as ComputeStatus,fn as ConnectButton,Ma as ConnectCompute,nt as ConnectModal,Ba as ConnectNudge,Ya as ModelPicker,Qa as RunError,ni as RunLimit,ki as SobaBilling,Ci as SobaCheckout,qr as SobaCurrentPlan,Gr as SobaPlans,Ti as SobaProvider,Va as collectText,Pt as connectSays,st as injectStyles,En as parseEvent,Ur as readEvents,qo as runErrorMessage,hn as sobaErrorCode,Ai as tierLabel,Jr as useCheckout,Xn as useCompute,ka as useConnectButton,Dr as useConnectNudge,it as useCurrentPlan,Er as useMachineRuns,Br as useModel,ot as useOpenSobaConnect,Fr as usePlans,Ar as useRunLimit,D as useSoba,Hi as watchRun};
3418
+ `)){let l=o.slice(0,i).replace(/\r$/,"");if(o=o.slice(i+1),l==="")s.length&&(yield{id:a,data:s.join(`
3419
+ `)}),a=null,s=[];else if(l.startsWith("id:")){let u=Number(l.slice(3).trim());a=Number.isFinite(u)?u:null}else if(l.startsWith("data:")){let u=l.slice(5);s.push(u.startsWith(" ")?u.slice(1):u)}}}}finally{t.cancel().catch(()=>{})}}var lo=(e,n)=>new Promise(t=>{let r=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(r),t()})});async function*ol(e,n={}){let t=n.fetchImpl??fetch.bind(globalThis),r=await tl(e,n,t)??{url:e.url,bearer:e.token,open:null},o=n.maxRetries??6,a=n.after??0,s=0;for(;;){if(n.signal?.aborted)return;let c;try{c=r.open??await t(r.url,{headers:{authorization:`Bearer ${r.bearer}`,accept:"text/event-stream",...a?{"last-event-id":String(a)}:{}},...n.signal?{signal:n.signal}:{}}),r.open=null}catch(i){if(n.signal?.aborted)return;if(++s>o)throw i;await lo(1e3*s,n.signal);continue}if(c.status===503&&s<o){s++,await lo(Number(c.headers.get("retry-after")??3)*1e3,n.signal);continue}if(!c.ok){let i=`Could not read this run (${c.status}).`;try{let l=await c.json();l.error?.message&&(i=l.error.message)}catch{}throw new Error(i)}for await(let i of rl(c)){i.id!==null&&(a=i.id),s=0;let l=Bn(i.data);if(l&&(yield l,l.type==="done"||l.type==="error"))return}if(n.signal?.aborted)return;if(++s>o)throw new Error("Lost this run's stream and could not get it back.");await lo(1e3*s,n.signal)}}export{Wa as ComputeStatus,yn as ConnectButton,za as ConnectCompute,ut as ConnectModal,li as ConnectNudge,Fr as ConnectPill,hi as ModelPicker,Ai as RunError,wi as RunLimit,Ui as SobaBilling,Fi as SobaCheckout,Kr as SobaCurrentPlan,$r as SobaPlans,_i as SobaProvider,mi as collectText,Qr as connectSays,mt as injectStyles,Bn as parseEvent,Xr as readEvents,_o as runErrorMessage,wn as sobaErrorCode,el as tierLabel,ao as useCheckout,lt as useCompute,Qa as useConnectButton,Zr as useConnectNudge,ft as useCurrentPlan,Vr as useMachineRuns,bn as useModel,pt as useOpenSobaConnect,_r as usePlans,zr as useRunLimit,Q as useSoba,ol as watchRun};