@soba-so/react 0.0.18 → 0.0.20
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/ConnectPill.d.ts +31 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +53 -15
- package/dist/styles.css +46 -8
- package/dist/types.d.ts +23 -0
- package/dist/useConnectButton.d.ts +10 -6
- package/dist/useMachineRuns.d.ts +24 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Machine } from "./types.js";
|
|
2
|
+
export interface ConnectPillProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
/** The machine the pill is about. `useConnectButton().machine` is the one to
|
|
4
|
+
* pass; `compute.machines[0]` is not, because that list is ordered by
|
|
5
|
+
* heartbeat and a laptop that slept a minute ago outranks a desktop that has
|
|
6
|
+
* been serving for an hour. */
|
|
7
|
+
machine: Machine | null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* WHAT IS CONNECTED AND WHETHER IT IS AWAKE, AS ONE CONTROL FOR A HEADER.
|
|
11
|
+
*
|
|
12
|
+
* ```jsx
|
|
13
|
+
* const { machine } = useConnectButton()
|
|
14
|
+
*
|
|
15
|
+
* <ConnectPill machine={machine} onClick={() => setOpen(true)} />
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The reporting half of `<ConnectButton />`, which is that pill plus our
|
|
19
|
+
* popover plus the pairing flow. Reach for this one when the app has its own
|
|
20
|
+
* idea of what pressing it does — its own panel, its own sheet, its own route —
|
|
21
|
+
* and for the usual case reach for `<ConnectButton />`, which wires all three.
|
|
22
|
+
*
|
|
23
|
+
* NOTHING IN IT IS THIS PACKAGE'S. The words, the dot's tone and the accessible
|
|
24
|
+
* name are `connectSays`, the same function the button and the dashboard's bar
|
|
25
|
+
* read, so three controls on three surfaces cannot end up disagreeing about one
|
|
26
|
+
* laptop. Pressing it is the only thing left for a host to decide.
|
|
27
|
+
*
|
|
28
|
+
* IT DRAWS NOTHING WITH NOTHING PAIRED. A pill reporting "no compute" is a
|
|
29
|
+
* readout of an absence; `<ConnectButton />` draws the door instead.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ConnectPill: import("react").ForwardRefExoticComponent<ConnectPillProps & import("react").RefAttributes<HTMLButtonElement>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { ConnectButton, type ConnectButtonProps } from "./ConnectButton.js";
|
|
|
3
3
|
export { ConnectCompute, type ConnectComputeProps } from "./ConnectCompute.js";
|
|
4
4
|
export { ConnectModal, type ConnectModalProps } from "./ConnectModal.js";
|
|
5
5
|
export { ConnectNudge, type ConnectNudgeProps } from "./ConnectNudge.js";
|
|
6
|
+
export { ConnectPill, type ConnectPillProps } from "./ConnectPill.js";
|
|
6
7
|
export { type ComputeState, type ConnectReason, type ConnectState, type PlanState, type RunRequest, type SobaContextValue, useSoba, } from "./context.js";
|
|
7
8
|
export { collectText, parseEvent, readEvents } from "./events.js";
|
|
8
9
|
export { ModelPicker, type ModelPickerProps } from "./ModelPicker.js";
|
|
@@ -15,12 +16,13 @@ export { SobaPlans, type SobaPlansProps } from "./SobaPlans.js";
|
|
|
15
16
|
export { SobaProvider, type SobaProviderProps } from "./SobaProvider.js";
|
|
16
17
|
export { injectStyles } from "./styles.js";
|
|
17
18
|
export { tierLabel } from "./tier.js";
|
|
18
|
-
export type { AgentEvent, AgentEventType, ConnectApi, ConnectContext, CostClass, CurrentPlan, Launch, Machine, MachineState, Message, ModelGroup, ModelOption, ModelOptionKind, PendingCode, Plan, Runtime, RunUsage, } from "./types.js";
|
|
19
|
+
export type { AgentEvent, AgentEventType, ConnectApi, ConnectContext, CostClass, CurrentPlan, Launch, Machine, MachineRun, MachineState, Message, ModelGroup, ModelOption, ModelOptionKind, PendingCode, Plan, Runtime, RunUsage, } from "./types.js";
|
|
19
20
|
export { type CheckoutView, type UseCheckoutOptions, useCheckout } from "./useCheckout.js";
|
|
20
21
|
export { type ComputeMachine, type ComputeRuntime, type ComputeView, useCompute, } from "./useCompute.js";
|
|
21
22
|
export { type ConnectButtonView, connectSays, useConnectButton } from "./useConnectButton.js";
|
|
22
23
|
export { type NudgeReason, type NudgeStalled, type NudgeStep, type NudgeView, type UseConnectNudgeOptions, useConnectNudge, } from "./useConnectNudge.js";
|
|
23
24
|
export { type AllowanceState, type CurrentPlanReward, type CurrentPlanView, useCurrentPlan, } from "./useCurrentPlan.js";
|
|
25
|
+
export { type MachineRunsOptions, type MachineRunsView, useMachineRuns } from "./useMachineRuns.js";
|
|
24
26
|
export { type ModelView, type UseModelOptions, useModel } from "./useModel.js";
|
|
25
27
|
export { useOpenSobaConnect } from "./useOpenSobaConnect.js";
|
|
26
28
|
export { type PlanCompute, type PlanConnect, type PlanCta, type PlanOffer, type PlanPrice, type PlansOptions, type PlansView, usePlans, } from "./usePlans.js";
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import{useRef as ls,useState as cs}from"react";var In=class extends Error{status;constructor(n,t){super(n),this.name="ConnectError",this.status=t}},ns=5*6e4,Tn=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 In&&s.status===401)throw s;this.gatewayBackUntil=Date.now()+ns}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:[]}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 In(a,o.status)}return s}};function Ln(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 $t(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=$t(e),o=$t(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 ln(e,n){if(!$t(e))return{};let t=Ln(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":Ln(r)}:{"--sc-accent":t,"--sc-accent-fg":e}}}function An(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 $n(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 cn(e){return e.find(n=>n.state==="offline")??null}function Dt(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 V(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 mt(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(mt)[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 Ht(e){return e.state==="online"||e.state==="busy"}function Dn(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 Xr,useRef as ts}from"react";import{Fragment as ss,jsx as Ne,jsxs as Ut}from"react/jsx-runtime";function Hn({anchor:e,label:n,options:t,current:r,onClose:o,onPick:s}){let a=ts(null);return Xr(()=>{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]),Xr(()=>{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]),Ne("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=>Ne(rs,{option:i,checked:r===i.id,onClose:o,onPick:s},i.id??""))})}function rs({option:e,checked:n,onClose:t,onPick:r}){return Ut(ss,{children:[e.heading?Ne("div",{className:"sc-menu-head",role:"presentation",children:e.heading}):e.rule?Ne("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:[Ne("span",{className:"sc-menu-label",children:e.label}),e.note&&Ne("span",{className:"sc-menu-note",children:e.note})]}),n&&Ne(os,{})]})]})}function os(){return Ne("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-menu-check",children:Ne("path",{d:"M5 12.5l4.5 4.5L19 7.5",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cn({open:e}){return Ne("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-chev sc-chev-open":"sc-chev",children:Ne("path",{d:"M9 6l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as we,jsxs as is}from"react/jsx-runtime";function j({className:e}){return is("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 eo({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 un({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 ft({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 as({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 Wt({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:eo,chatgpt:un,local:ft},no={shell:as};var ce=[{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"]}],to=["claude","chatgpt"];function Bt(){return ce.filter(e=>to.includes(e.id))}function qt(e){return ce.filter(n=>n.costClass===e)}function Ft(e){return ce.find(n=>n.expects.includes(e))??null}import{Fragment as oo,jsx as b,jsxs as O}from"react/jsx-runtime";function dn({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:P,machineNote:R,children:_}){let M=Ee(e),B=e.filter(N=>N.id!==M?.id),I=M&&p?ps(p,M):{};return!M&&n.length===0&&!s?b("p",{className:"sc-note",children:"Nothing connected yet."}):O("div",{className:"sc-tray",children:[M&&O(Nn,{title:"This machine",action:(a||P)&&O("span",{className:"sc-cap-acts",children:[a&&b("button",{type:"button",className:"sc-disc",onClick:a,disabled:c,"aria-label":"Refresh",title:"Refresh",children:b(Ms,{spinning:!!c})}),P]}),children:[b(us,{machine:M,...f?{onToggle:f,open:!!y}:{}}),R]}),M&&f&&y&&b(ms,{machine:M,runs:p??null,...m?{markOf:m}:{}}),M&&b(Nn,{title:"Agents on it",action:b(ks,{machine:M,appName:l,busy:i,...m?{markOf:m}:{},...r?{onPick:N=>r(M.id,N)}:{}}),children:w&&M.runtimes.length===0?b("p",{className:"sc-row-note",children:"Looking\u2026"}):M.runtimes.length>0?M.runtimes.map(N=>b(ws,{runtime:N,serving:I[N.id]??N.serving??0,...m?{mark:m(N)}:{},...t?{onApprove:()=>t(M.id,N.id)}:{}},N.id)):b("p",{className:"sc-row-note",children:"No agent advertised. Install Claude Code, Codex or Ollama on that machine."})}),n.length>0&&b(Nn,{title:n.length>1?"Connected plans":"Connected plan",children:n.map(N=>b(Ns,{credential:N,appName:l,busy:i,...o?{onDisconnect:()=>o(N.provider)}:{}},N.provider))}),(B.length>0||s)&&O(Nn,{title:B.length>0?"Your other machines":M?"Add a machine":"Your machines",children:[B.map(N=>b(ys,{machine:N},N.id)),s&&O("button",{type:"button",className:"sc-pair",onClick:s,children:[b("span",{className:"sc-otile","aria-hidden":"true",children:b(xs,{})}),b("span",{className:"sc-oname",children:e.length>0?"Pair another machine":"Connect a machine"})]})]}),_,u&&b("p",{className:"sc-error sc-tray-error",children:u})]})}function Nn({title:e,action:n,children:t}){return O("section",{className:"sc-group",children:[O("div",{className:"sc-group-cap",children:[b("p",{className:"sc-group-title",children:e}),n]}),b("div",{className:"sc-group-card",children:t})]})}function us({machine:e,onToggle:n,open:t}){let r=Ht(e),o=[r?null:e.pairing_lost?"No longer connected here":"Asleep or offline",$n(e),e.always_on?"always on":null,r&&e.capacity>0?`${e.active} of ${e.capacity} in flight`:Dn(e.last_seen_at)].filter(Boolean),s=O(oo,{children:[O("span",{className:"sc-mtile","aria-hidden":"true",children:[b(ro,{}),b("span",{className:`sc-mbadge sc-mbadge-${Ge(e).tone}`})]}),O("span",{className:"sc-mid",children:[b("span",{className:"sc-mname",children:V(e)}),b("span",{className:"sc-mmeta",children:o.map((a,c)=>O("span",{children:[c>0&&b("span",{className:"sc-mmeta-sep",children:"\xB7"}),a]},a))})]})]});return!n||!r?b("div",{className:"sc-mrow",children:s}):O("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,b(Cn,{open:!!t})]})}function ds(e,n){return e.filter(t=>t.machine_id===n.id||t.machine_id===null)}function ps(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 ms({machine:e,runs:n,markOf:t}){let r=n?ds(n,e):[],o=s=>{if(!s||!t)return null;let a=e.runtimes.find(c=>c.id===s);return a?t(a):null};return b(Nn,{title:"Running now",children:n===null?b("p",{className:"sc-row-note",children:"Looking\u2026"}):r.length===0?b("p",{className:"sc-row-note",children:"Nothing running."}):r.map(s=>{let a=o(s.runtime_id);return b(fs,{run:s,...a?{mark:a}:{}},s.id)})})}function fs({run:e,mark:n}){let t=e.runtime_id?ht(e.runtime_id):null;return O("div",{className:"sc-rrow",children:[b("span",{className:"sc-runtime-tile","aria-hidden":"true",children:n??(t&&b(t,{className:"sc-runtime-mark"}))}),O("span",{className:"sc-mid",children:[O("span",{className:"sc-rtop",children:[b("span",{className:"sc-aname",children:hs(e)}),b("span",{className:"sc-averdict",children:bs(e.started_at)})]}),b("span",{className:"sc-rstep",children:gs(e)})]})]})}function ht(e){let n=Ft(e);return(n?ze[n.id]:null)??no[e]??null}function hs(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 gs(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 bs(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 ys({machine:e}){let n=Ge(e);return O("div",{className:"sc-orow",children:[b("span",{className:"sc-otile","aria-hidden":"true",children:b(ro,{})}),b("span",{className:"sc-oname",children:V(e)}),b("span",{className:"sc-oword",children:n.word}),b("span",{className:`sc-dot sc-dot-${n.tone}`,"aria-hidden":"true"})]})}function ws({runtime:e,serving:n=0,mark:t,onApprove:r}){let o=An(e),s=O(oo,{children:[b(vs,{runtime:e,mark:t}),O("span",{className:e.absent?"sc-aname sc-aname-absent":"sc-aname",children:[e.display_name,e.version&&O("span",{className:"sc-aversion",children:[" ",e.version]})]}),n>0?O("span",{className:"sc-averdict",children:[b(Ss,{}),b("span",{className:"sc-aserving",children:n>1?`${n} running`:"running"})]}):e.absent?b("span",{className:"sc-averdict sc-tone-absent",children:"not offered"}):e.quarantined?r?b("button",{type:"button",className:"sc-row-act",onClick:r,children:"Let it serve"}):b("span",{className:"sc-averdict sc-tone-warn",children:"new, not serving yet"}):o.tone==="ok"?O("span",{className:"sc-averdict",children:[b("span",{className:"sc-dot sc-dot-ok","aria-hidden":"true"}),b("span",{className:"sc-sr",children:o.text})]}):b("span",{className:`sc-averdict sc-tone-${o.tone}`,children:o.text})]});return b("div",{className:"sc-arow",children:s})}function vs({runtime:e,mark:n}){if(n)return b("span",{className:"sc-runtime-tile","aria-hidden":"true",children:n});let t=ht(e.id);return b("span",{className:"sc-runtime-tile","aria-hidden":"true",children:t&&b(t,{className:"sc-runtime-mark"})})}function ks({machine:e,appName:n,busy:t,markOf:r,onPick:o}){let s=De(e),a=ye(e),[c,i]=cs(!1),l=ls(null);if(s.by!=="app"&&a.length===0)return null;let u=f=>{if(!f)return null;if(r)return r(f);let m=ht(f.id);return b("span",{className:"sc-runtime-tile","aria-hidden":"true",children:m&&b(m,{className:"sc-runtime-mark"})})},p=f=>{if(!f)return null;if(r)return b("span",{className:"sc-runs-mark",children:r(f)});let m=ht(f.id);return m?b(m,{className:"sc-runs-glyph"}):null},y;return s.by==="app"?y=O("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=O("span",{className:"sc-runs-fixed",children:[p(s.runtime),s.runtime?.display_name]}):y=O("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),b("span",{className:"sc-runs-label",children:s.runtime?.display_name}),b(Cn,{open:!0})]}),O("span",{className:"sc-runs-to",children:[b("span",{className:"sc-runs-cap",children:s.by==="app"?`${n??"App"} uses`:"Runs on"}),y,c&&o&&b(Cs,{anchor:l,machine:e,tile:u,onClose:()=>i(!1),onPick:f=>{i(!1),o(f)}})]})}function Cs({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 b(Hn,{anchor:e,label:"Which agent runs go to",options:i,current:c,onClose:r,onPick:o})}function Ns({credential:e,appName:n,busy:t,onDisconnect:r}){return O("div",{className:"sc-hrow",children:[O("div",{className:"sc-orow",children:[b("span",{className:"sc-otile","aria-hidden":"true",children:b(un,{className:"sc-omark"})}),O("span",{className:"sc-mid",children:[b("span",{className:"sc-oname",children:e.provider==="openai-chatgpt"?"ChatGPT plan":e.provider}),b("span",{className:"sc-mmeta",children:e.account_label??"signed in"})]}),r&&b("button",{type:"button",className:"sc-row-act",onClick:r,disabled:t,children:"Disconnect"})]}),r&&O("p",{className:"sc-row-note",children:[n??"This app"," stops using it. To withdraw the grant entirely, remove it in your OpenAI settings."]})]})}function ro(){return O("svg",{viewBox:"0 0 32 24","aria-hidden":"true",focusable:"false",className:"sc-mglyph",children:[b("rect",{x:"4",y:"1.5",width:"24",height:"15",rx:"2.5",fill:"var(--sc-sheet, #ffffff)",stroke:"currentColor",strokeWidth:"2"}),b("rect",{x:"1",y:"19.5",width:"30",height:"2.5",rx:"1.25",fill:"currentColor"})]})}function xs(){return b("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-oglyph",children:b("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function Ss(){return O("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-sglyph sc-spin",children:[b("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),b("path",{d:"M12 3a9 9 0 0 1 9 9",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Ms({spinning:e}){return b("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-dglyph sc-spin":"sc-dglyph",children:b("path",{d:"M21 12a9 9 0 1 1-2.64-6.36M21 3v6h-6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as Ps}from"react/jsx-runtime";function Un({machines:e,onApproveRuntime:n}){return Ps(dn,{machines:e,...n?{onApproveRuntime:n}:{}})}var Gt={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 zt="105 162 420 420",Kt="M407.1 308.9 A158 158 0 1 0 407.1 491.1 A116 116 0 0 1 407.1 308.9 Z",pn="M448.5 320 A110 110 0 0 1 448.5 480";import{Fragment as Bn,jsx as S,jsxs as Ke}from"react/jsx-runtime";function Vt({kind:e,size:n=44,className:t}){let r=Gt[e];return Ke("svg",{className:`bx${t?` ${t}`:""}`,"data-expression":e,viewBox:zt,overflow:"visible",width:n,height:n,"aria-hidden":"true",children:[S("path",{d:Kt,fill:"currentColor"}),S("path",{className:"bx-arc",d:pn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),r.slot==="stream"&&S(Rs,{}),r.slot==="zzz"&&S(_s,{}),r.slot==="dots"&&S(Es,{}),r.slot==="bang"&&S(Os,{}),r.slot==="orbit"&&S(Is,{}),r.slot==="cross"&&S(Ts,{}),r.slot==="snap"&&S(Ls,{}),r.slot==="bars"&&S(As,{}),r.slot==="ring"&&S($s,{}),r.slot==="sparks"&&S(Ds,{})]})}function Rs(){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 _s(){return Ke(Bn,{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 Es(){return Ke(Bn,{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 Os(){return Ke("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 Is(){return Ke("g",{className:"bx-ob",children:[S("path",{d:pn,fill:"none",stroke:"var(--tile-bg, transparent)",strokeWidth:41,strokeLinecap:"round"}),S("path",{d:pn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})]})}function Ts(){return Ke(Bn,{children:[S("path",{className:"bx-xa",d:pn,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 Ls(){return S("path",{className:"bx-snap",d:pn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})}function As(){return Ke("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 $s(){return S(Bn,{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 Ds(){return Ke(Bn,{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 oe,useEffect as ue,useId as zs,useMemo as Ve,useRef as xn,useState as W}from"react";var qn=[{slug:"mac-arm",label:"macOS, Apple silicon"},{slug:"mac-intel",label:"macOS, Intel"},{slug:"windows",label:"Windows"},{slug:"linux",label:"Linux"}];function Fn(e){if(!e)return"";try{return new URL(e).origin}catch{return""}}function io(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 Hs=3e3,Us=2*6e4,gt=Date.now(),bt=new Set,ao=!1;function Ws(){if(ao||typeof window>"u")return;ao=!0;let e=()=>{let t=gt;if(gt=Date.now(),gt-t>Us)for(let r of bt)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 bt)t()};window.addEventListener("focus",n),document.addEventListener("visibilitychange",n)}function Oe(e,n,t={}){Ws();let r,o=t.immediate===!1?Date.now():0,s=!1,a=!1,c=()=>{a||(r=setTimeout(i,t.idle===!1?n:io(n,Date.now()-gt)))},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,Hs)&&i()};return bt.add(l),t.immediate===!1?c():i(),()=>{a=!0,clearTimeout(r),bt.delete(l)}}var jt="soba";function lo(){return`${jt}://show`}function Gn(e,n,t){let r=`${jt}://connect?url=${encodeURIComponent(e)}`;return n&&(r+=`&nonce=${encodeURIComponent(n)}`),t&&(r+=`&want=${encodeURIComponent(t)}`),r}function zn(){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 Bs=1600;function Yt(e={}){return Qt(e)}async function Zt(e,n={}){if(typeof window>"u"||typeof document>"u")return"unknown";let t=Qt(n);try{window.location.href=Gn(e,n.nonce,n.want)}catch{return"absent"}return t}async function Jt(e={}){if(typeof window>"u"||typeof document>"u")return"unknown";let n=Qt(e);try{window.location.href=lo()}catch{return"absent"}return n}async function Qt(e){if(typeof window>"u"||typeof document>"u")return"unknown";let n=e.graceMs??Bs,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 co="soba.connect.choice",qs=180*24*60*60*1e3;function Xt(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 er(e,n){return e?n?`${co}.${e}.${Xt(n)}`:`${co}.${e}`:null}function nr(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)>qs)return null;let r=ce.find(o=>o.id===t.choice);return r?r.id:null}catch{return null}}function tr(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var uo="soba.connect.model",Fs=180*24*60*60*1e3;function rr(e,n){return e?n?`${uo}.${e}.${Xt(n)}`:`${uo}.${e}`:null}function yt(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)>Fs)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 or(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var po="soba.connect.dismissed",Gs=30*24*60*60*1e3;function sr(e,n){return e?n?`${po}.${e}.${Xt(n)}`:`${po}.${e}`:null}function ar(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)<Gs}catch{return!1}}function ir(e){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({at:new Date().toISOString()}))}catch{}}import{Fragment as kt,jsx as d,jsxs as x}from"react/jsx-runtime";var lr=2e3,Ks=1e4,Vs=9e4,js=6e4;function cr(e,n,t,r=[],o){return e?"code":n&&(t.length>0||r.length>0)?"manage":o?"launch":"choose"}function Ys(e){let n=Math.max(0,Math.round(e/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function pr({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]=W(y?cr(n,o,a??[],[],t):"loading"),[w,P]=W(s),[R,_]=W(a??[]),[M,B]=W(n??""),[I,N]=W(null),[F,T]=W(null),[se,X]=W(!1),[ve,K]=W(0),[ae,We]=W(()=>Date.now()),[Y,Me]=W(null),[Xe,de]=W(!1),[pe,ee]=W(!1),[gn,en]=W("browser"),[Le,nn]=W(null),[me,ne]=W([]),[Be,Pe]=W(0),[Ae,qe]=W(null),ie=xn(null),[E,bn]=W(t??null),[v,G]=W(null),te=Ve(()=>{let h=w?.accent?.trim(),C=w?.background?.trim();if(!(!h&&!C))return C?{...ln(C,h),background:C,borderRadius:"inherit"}:{"--sc-accent":h,"--sc-accent-fg":Ln(h)}},[w?.accent,w?.background]),fe=zs(),re=i??fe,Fe=xn(null);ue(()=>{if(!e||y)return;let h=!0;return Promise.all([e.context(),e.machines()]).then(([C,$])=>{h&&(P(C),_($),m(cr(n,o,$)))}).catch(C=>{h&&(T(C.message),m("choose"))}),()=>{h=!1}},[e,n,o,y]),ue(()=>{f!=="loading"||!y||m(cr(n,o,a??[]))},[f,y,n,o,a]),ue(()=>{a&&_(a)},[a]),ue(()=>{s&&P(s)},[s]);let yn=xn(!1),wn=xn(f);wn.current=f;let tn=xn(me);tn.current=me;let rn=!!w?.hosted_available;ue(()=>{!o&&wn.current==="manage"&&m("choose")},[o]),ue(()=>{if(!e||!p||f!=="manage")return;let h=!0,C=Oe(async()=>{try{let $=await e.machines();if(!h)return;_($);let U=!rn||yn.current;$.length===0&&tn.current.length===0&&U&&wn.current==="manage"&&m("choose")}catch{}},Ks,{immediate:!1});return()=>{h=!1,C()}},[f,e,rn,p]);let on=er(w?.publishable_key??null);ue(()=>{G(nr(on))},[on]),ue(()=>{if(!e||!rn)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,rn,o]),ue(()=>{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()=>{ie.current?.closed&&(ie.current=null,!await C()&&h&&m("choose"))},U=Oe(C,lr,{immediate:!1}),an=setInterval($,400),Ce=_e=>{let On=_e.data;On?.source==="soba"&&On.type==="hosted_result"&&C()};return window.addEventListener("message",Ce),()=>{h=!1,U(),clearInterval(an),window.removeEventListener("message",Ce),ie.current=null}},[e,f,p]);let It=oe(()=>{if(!e)return;let h=window.open("","soba-connect-plan","width=520,height=760,noopener=no");ie.current=h,m("hosted"),Pe(Date.now()),qe(null),T(null),e.startHosted().then(({url:C})=>{if(h&&!h.closed){h.location.href=C;return}qe(C)}).catch(C=>{h?.close(),ie.current=null,T(C.message),m("choose")})},[e]),it=oe(async h=>{if(e){X(!0);try{await e.disconnectHosted(h),ne((await e.hosted()).credentials)}catch(C){T(C.message)}finally{X(!1)}}},[e]);ue(()=>{if(!e||!p||f!=="waiting")return;let h=!0,C=Oe(async()=>{try{let $=await e.machines();if(!h)return;_($);let U=Fe.current;if(!U)return;let an=$.filter(_e=>!U.has(_e.id)),Ce=an.find(_e=>_e.state!=="offline")??an[0];if(Ce){nn(Ce.id),E&&tr(on,E);let _e=ce.find(At=>At.id===E)?.expects??[],On=ye(Ce).find(At=>_e.includes(At.id));On&&e.preferRuntime(Ce.id,On.id).catch(()=>{}),m("connected"),r?.($)}}catch{}},lr,{immediate:!1});return()=>{h=!1,C()}},[f,e,r,E,on,p]);let lt=oe(async()=>{if(e){T(null),X(!0);try{let h=await e.lookup(M);N(h),m("confirm")}catch(h){T(h.message)}finally{X(!1)}}},[e,M]),vn=oe(async()=>{if(e){T(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(M),m("waiting"),K(Date.now())}catch(h){T(h.message)}finally{X(!1)}}},[e,M,R]),ct=oe(async()=>{if(e){X(!0);try{await e.deny(M),en("browser"),m("denied")}catch(h){T(h.message)}finally{X(!1)}}},[e,M]),q=Ve(()=>w?.connect_url??null,[w]),[Re,he]=W(()=>zn()),sn=Ve(()=>q?Gn(q,Re??void 0,E??void 0):null,[q,Re,E]),ut=Ve(()=>Fn(q),[q]),Tt=oe(h=>{if(R.length===0)return null;let C=ce.find(U=>U.id===h);if(!C)return null;let $=R.flatMap(U=>U.runtimes??[]).filter(U=>C.expects.includes(U.id));return $.length===0?{tone:"dim",text:"not installed"}:$.some(U=>U.authenticated===!0)?{tone:"ok",text:"ready"}:$.every(U=>U.authenticated===!1)?{tone:"warn",text:"needs signing in"}:{tone:"dim",text:"installed"}},[R]),k=oe((h=null)=>{bn(h),T(null),Me(null),de(!1),ee(!1),z.current=!1,he(zn()),m("launch")},[]),z=xn(!!t);ue(()=>{f!=="launch"||!q||z.current||(z.current=!0,de(!0),Zt(q,{...Re?{nonce:Re}:{},...E?{want:E}:{}}).then(Me))},[f,q,Re,E]);let le=oe(()=>{de(!0),Yt().then(Me)},[]),dt=oe(h=>{if(pe){let C=zn();ee(!1),he(C),q&&(h.preventDefault(),window.location.href=Gn(q,C??void 0,E??void 0))}le()},[pe,le,q,E]),ge=Ve(()=>{let h=w?.runtimes;return h?ce.filter(C=>h.includes(C.id)):Bt()},[w?.runtimes]),ke=Ve(()=>{let h=ce.find(C=>C.id===E);return h?{choice:h,Mark:ze[h.id]??null}:null},[E]),$e=Ve(()=>R.find(h=>h.id===Le),[R,Le]);ue(()=>{let h=Re;if(!e||!p||f!=="launch"||!h)return;let C=!1,$=Date.now()+15e4,U=()=>{};return U=Oe(async()=>{if(Date.now()>$){U(),ee(!0);return}try{let an=await e.claim(h);if(C)return;if(an.declined){U(),Me(null),en("machine"),m("denied");return}if(!an.claimed)return;U();try{Fe.current=new Set((await e.machines()).map(Ce=>Ce.id))}catch{Fe.current=new Set(R.map(Ce=>Ce.id))}m("waiting"),K(Date.now())}catch{}},lr,{immediate:!1,idle:!1}),()=>{C=!0,U()}},[e,f,R,Re,p]);let be=Ve(()=>{if(!I)return null;if(I.approved||I.denied)return"answered";let h=I.expires_at?Date.parse(I.expires_at):Number.NaN;return Number.isFinite(h)&&h<=ae?"expired":"live"},[I,ae]);ue(()=>{if(!(f==="confirm"&&be==="live"||f==="waiting"||f==="hosted"))return;let C=setInterval(()=>We(Date.now()),1e3);return()=>clearInterval(C)},[f,be]);let pt=oe(async(h,C)=>{if(e)try{await e.approveRuntime(h,C),_(await e.machines())}catch($){T($.message)}},[e]),Lt=oe(async(h,C)=>{if(e)try{await e.preferRuntime(h,C),_(await e.machines())}catch($){T($.message)}},[e]);return f==="loading"?d("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:te,children:d("div",{className:"sc-card",children:d("p",{className:"sc-note",children:"Loading\u2026"})})}):x("div",{className:"soba-connect",...l?{"data-theme":l}:{},style:te,children:[c&&d("button",{type:"button",className:"sc-modal-close",onClick:c,"aria-label":"Close",children:"\xD7"}),f==="manage"&&x("div",{className:"sc-card",children:[d("h2",{className:"sc-title",id:re,children:"Your compute"}),x("p",{className:"sc-sub",children:[d(wt,{context:w})," ",R.length>0&&me.length>0?"runs on your connected plan, and on these machines while they are awake.":me.length>0?"runs on the plan you connected. Nothing here is charged to you.":"runs on these machines, while they are awake."]}),d(dn,{machines:R,hosted:me,onApproveRuntime:pt,onPreferRuntime:(h,C)=>void Lt(h,C),onDisconnectHosted:h=>void it(h),onPair:()=>m("choose"),busy:se,...w?.app.name?{appName:w.app.name}:{}}),F&&d("p",{className:"sc-error",children:F})]}),f==="choose"&&x("div",{className:"sc-card",children:[d(Js,{context:w}),d("h2",{className:"sc-h",id:re,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."}),q&&ge.length>0&&x(kt,{children:[d("div",{className:"sc-opts",children:ge.map(h=>{let C=ze[h.id];return x("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 $=Tt(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(ur,{className:"sc-opt-go"})})()]},h.id)})}),x("p",{className:"sc-opt-note",children:["Your accounts stay there. ",mo(w)," never sees them."]})]}),(!q||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."}),F&&d("p",{className:"sc-error",children:F}),q&&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"&&x("div",{className:"sc-card",children:[x("div",{className:"sc-head",children:[d(Sn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d(vt,{mark:ke?.Mark??j,still:pe||!Xe&&Y===null}),d("h2",{className:"sc-h",id:re,children:pe?"No answer from this machine":Y==="absent"?"Nothing opened":Y===null?"Opening Soba App\u2026":"Approve it on this machine"}),pe?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."}),ke&&x("p",{className:"sc-prereq",children:[ke.Mark&&d(ke.Mark,{className:"sc-rt-mark"}),"Needs ",ke.choice.prerequisite]}),x("div",{className:"sc-stack",style:{marginTop:18},children:[d("a",{className:Y==="absent"||pe?"sc-btn sc-btn-primary":"sc-btn",href:sn??"#",onClick:dt,children:pe?"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."}),ke&&Y==="absent"&&d("p",{className:"sc-note",children:d(Qs,{text:ke.choice.hint})}),x("div",{className:"sc-foot-strip",children:[d("span",{children:"Not installed on this machine?"}),x("button",{type:"button",className:"sc-foot-go",onClick:()=>m("get"),children:["Get it",d(ur,{})]})]})]})]}),f==="get"&&x("div",{className:"sc-card",children:[x("div",{className:"sc-head",children:[d(Sn,{onClick:()=>m("launch")}),d("p",{className:"sc-head-title",children:"Get Soba App"})]}),d("div",{className:"sc-opts",children:qn.map(h=>x("a",{className:"sc-opt",href:`${ut}/download/${h.slug}`,target:"_blank",rel:"noreferrer noopener",children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:d(Wt,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),d(ur,{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"&&x("div",{className:"sc-card",children:[x("div",{className:"sc-head",children:[d(Sn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-h",id:re,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."}),x("form",{className:"sc-stack",style:{marginTop:16},onSubmit:h=>{h.preventDefault(),lt()},children:[d("input",{className:"sc-input",value:M,onChange:h=>B(h.target.value),placeholder:"ACDE-F234",autoComplete:"off",autoFocus:!0,"aria-label":"Pairing code"}),F&&d("p",{className:"sc-error",children:F}),d("button",{type:"submit",className:"sc-btn sc-btn-primary",disabled:se||M.length<8,children:se?"Checking\u2026":"Continue"})]})]}),f==="confirm"&&I&&x("div",{className:"sc-card",children:[x("div",{className:"sc-head",children:[d(Sn,{onClick:()=>m("code")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-title",children:"Attach this machine to your account?"}),x("p",{className:"sc-sub",children:[d(wt,{context:w})," may send your runs to it once you approve. It can never see the account or the keys on it."]}),x("ul",{className:"sc-facts",children:[d(Kn,{k:"Code",v:I.user_code}),d(Kn,{k:"Machine",v:I.hostname??"not stated"}),d(Kn,{k:"System",v:[I.platform,I.arch].filter(Boolean).join(" / ")||"not stated"}),d(Kn,{k:"Asked by",v:I.client??"not stated"}),I.labels.length>0&&d(Kn,{k:"Labels",v:I.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."}),F&&d("p",{className:"sc-error",children:F}),x("div",{className:"sc-row",style:{marginTop:16},children:[d("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:()=>void vn(),disabled:se||be!=="live",children:"Approve"}),d("button",{type:"button",className:"sc-btn",onClick:()=>void ct(),disabled:se||be==="answered",children:"No, deny it"})]}),be==="live"&&I.expires_at&&x("p",{className:"sc-note",style:{marginTop:10},children:["This code expires in ",Ys(Date.parse(I.expires_at)-ae),"."]})]}),f==="waiting"&&x("div",{className:"sc-card",children:[x("div",{className:"sc-head",children:[d(Sn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:ke?.choice.short??"Soba App"})]}),d(vt,{mark:ke?.Mark??j}),d("h2",{className:"sc-h",id:re,children:"Approved. Waiting for it to connect"}),d("p",{className:"sc-p",children:"Nothing more to do here. This page changes when it arrives."}),ve>0&&ae-ve>Vs&&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"&&x("div",{className:"sc-card",children:[d(dr,{tone:"ok"}),d("h2",{className:"sc-h",id:re,children:$e?.label?`${$e.label} is connected`:"Connected"}),x("p",{className:"sc-p",children:[d(wt,{context:w})," will use ",$e?.label?"it":"this machine"," from now on, while it is awake."]}),o&&x(kt,{children:[d("div",{style:{marginTop:16},children:d(Un,{machines:R,onApproveRuntime:pt})}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:14},onClick:()=>m("manage"),children:"Done"})]})]}),f==="hosted"&&x("div",{className:"sc-card",children:[x("div",{className:"sc-head",children:[d(Sn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"ChatGPT"})]}),Ae?d(vt,{mark:un,still:!0}):d(vt,{mark:un}),d("h2",{className:"sc-h",id:re,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."}),x("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"}),F&&d("p",{className:"sc-error",children:F}),Be>0&&ae-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"&&x("div",{className:"sc-card",children:[d(dr,{tone:"ok"}),d("h2",{className:"sc-h",id:re,children:"ChatGPT is connected"}),x("p",{className:"sc-p",children:[d(wt,{context:w})," will run on your ChatGPT plan",me[0]?.account_label?` (${me[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&&x(kt,{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"&&x("div",{className:"sc-card",children:[d(dr,{tone:"off"}),d("h2",{className:"sc-h",id:re,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 mo(e){return e?.app.name??"this app"}function Zs(e){let n=e?.app.icon_urls;if(n?.length)return n;let t=e?.app.icon_url;return t?[t]:[]}function fo(e){let n=Zs(e),[t,r]=W([]),o=oe(c=>{c&&r(i=>i.includes(c)?i:[...i,c])},[]),s=oe(c=>o(c.currentTarget.getAttribute("src")),[o]),a=oe(c=>{c?.complete&&c.naturalWidth===0&&o(c.getAttribute("src"))},[o]);return{icon:n.find(c=>!t.includes(c)),onError:s,ref:a}}function Js({context:e}){let{icon:n,onError:t,ref:r}=fo(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 wt({context:e}){let{icon:n,onError:t,ref:r}=fo(e),o=e?.app.mark==="soba";return x("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}),mo(e)]})}function Sn({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 ur({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 vt({mark:e,still:n}){return x("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 dr({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 Qs({text:e}){return d(kt,{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 x("li",{className:"sc-fact",children:[d("span",{className:"sc-fact-key",children:e}),d("span",{children:n})]})}import{useEffect as Xs,useRef as fr}from"react";var Ct=0,mr=null;function ho(){if(typeof document>"u")return()=>{};Ct===0&&(mr=document.body.style.overflow,document.body.style.overflow="hidden"),Ct+=1;let e=!1;return()=>{e||(e=!0,Ct-=1,Ct===0&&(document.body.style.overflow=mr??"",mr=null))}}import{jsx as go}from"react/jsx-runtime";function Vn({open:e,onClose:n,labelledBy:t,theme:r,style:o,children:s}){let a=fr(null),c=fr(null),i=fr(null);return Xs(()=>{let l=a.current;if(l){if(!e){l.open&&l.close();return}return l.open||l.showModal(),document.activeElement===l&&c.current?.focus(),ho()}},[e]),go("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:go("div",{className:"sc-modal-sheet",ref:c,tabIndex:-1,children:s})})}import{useRef as ta,useState as ra}from"react";var ea={"claude-code":{small:"haiku",large:"opus"}};function bo(e){let n=ea[e];return!!(n?.small||n?.large)}var na={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus",fable:"Fable"};function yo(e){return na[e]??e}function hr(e){let n=[...e].sort(mt),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=>bo(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(V(u));continue}c.set(f,{option:{id:f,kind:"named",label:yo(y),model:y,runtime:p.id,runtimeName:p.display_name,costClass:p.cost_class},machines:new Set([V(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 jn(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 gr(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 br(e){return e.runtime?{model:e.model,runtime:e.runtime}:{model:e.model}}function Yn(e){return e.length>1}import{jsx as Nt,jsxs as wo}from"react/jsx-runtime";function yr({options:e,selected:n,onPick:t,caption:r,disabled:o,className:s}){let[a,c]=ra(!1),i=ta(null);if(!Yn(e))return null;let l=s?`sc-mp ${s}`:"sc-mp";return wo("span",{className:l,children:[r&&Nt("span",{className:"sc-mp-cap",children:r}),wo("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:[Nt("span",{className:"sc-mp-label",children:n.label}),Nt(Cn,{open:!0})]}),a&&Nt(Hn,{anchor:i,label:"Which model answers",options:oa(e),current:n.id,onClose:()=>c(!1),onPick:u=>{c(!1),u&&t(u)}})]})}function oa(e){let n=[];for(let t of jn(e))t.options.forEach((r,o)=>{let s=sa(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 sa(e){return e.kind!=="named"?e.note:e.machine?`on ${e.machine}`:void 0}import{useEffect as wr,useRef as aa}from"react";import{jsx as ia}from"react/jsx-runtime";var mn=8;function vr({open:e,onClose:n,anchor:t,label:r,theme:o,style:s,children:a}){let c=aa(null);return wr(()=>{let i=c.current;if(!(!i||!(typeof i.showPopover=="function")))try{e?i.showPopover():i.hidePopover()}catch{}},[e]),wr(()=>{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-mn,P=Math.max(mn,Math.min(y.right-f,Math.max(mn,w))),R=y.bottom+mn,_=y.top-mn-m,M=R+m>window.innerHeight-mn&&_>mn?_:R;u.style.left=`${Math.round(P)}px`,u.style.top=`${Math.round(M)}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]),wr(()=>{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]),ia("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 Zn=new Map,Mn=new Map,vo=!1;function la(){vo||typeof window>"u"||(vo=!0,window.addEventListener("storage",e=>{!e.key||!Zn.has(e.key)||(Mn.set(e.key,yt(e.key)),kr(e.key))}))}function kr(e){for(let n of Zn.get(e)??[])n()}function Jn(e){return e??""}function Cr(e,n){let t=Jn(e);la();let r=Zn.get(t)??new Set;return r.add(n),Zn.set(t,r),()=>{r.delete(n),r.size===0&&Zn.delete(t)}}function xt(e){let n=Jn(e),t=Mn.get(n);if(t!==void 0)return t;let r=e?yt(e):null;return Mn.set(n,r),r}function Nr(){return null}function xr(e,n){xt(e)===null&&(Mn.set(Jn(e),n),kr(Jn(e)))}function Sr(e,n){let t=Jn(e);Mn.get(t)!==n&&(Mn.set(t,n),or(e,n),kr(t))}function He(e){let n=`${e.unit}s`;return e.reward==="unlimited"?`Unlimited ${n} on your own AI`:e.reward==="included"&&e.includedUnits!==null?`${ua(e.includedUnits)} ${n} a month once you connect`:e.reward==="credit"&&e.creditMicros>0?`${ca(e.creditMicros)} back each month you stay connected`:null}function Ue(e){return e==="unlimited"||e==="included"}var Co=new Set(["user-hardware","user-subscription"]),ko=new Set(["open-weights","frontier"]);function xe(e){return e===null||e.length===0?!1:e.every(n=>Co.has(n))}var ca=e=>(e/1e6).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),ua=e=>e.toLocaleString("en-US");function Mr(e,n){if(!(n===null||n.some(s=>ko.has(s))))return!1;let r=e.findIndex(s=>Co.has(s));if(r===-1)return!1;let o=e.findIndex(s=>ko.has(s));return o===-1||r<o}import{createContext as No,useContext as xo}from"react";var Pr=No(null);function St(){return xo(Pr)}var Rr=No({context:null,machines:void 0,theme:"light"});function H(){return xo(Rr)}import{useMemo as ma}from"react";import{createContext as da,useContext as pa}from"react";var _r=da(null);function D(){let e=pa(_r);if(!e)throw new Error("useSoba() must be used inside a <SobaProvider>.");return e}function Qn(){let{compute:e}=D();return ma(()=>{let n=e.machines,t=[...n].sort((s,a)=>Ee([s,a])===s?-1:1).map(fa),r=Ee([...n]),o=cn(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 fa(e){let n=De(e);return{machine:e,name:V(e),state:Ge(e),status:Dt(e),hardware:$n(e),lastSeen:e.state==="offline"?Dn(e.last_seen_at):null,runtimes:ye(e).map(t=>({runtime:t,name:t.display_name,auth:An(t),quarantined:!!t.quarantined})),runsOn:{by:n.by,name:n.runtime?.display_name??null}}}import{jsx as Xn}from"react/jsx-runtime";function ha({className:e}){let{theme:n}=H(),t=e?`soba-connect ${e}`:"soba-connect";return Xn("div",{className:t,"data-theme":n,children:Xn(Er,{})})}function Er(){let e=Qn();return e.view==="loading"?Xn("p",{className:"sc-note",children:"Loading\u2026"}):e.view==="error"?Xn("p",{className:"sc-error",children:e.error?.message}):Xn(Un,{machines:e.machines.map(n=>n.machine)})}import{useCallback as nt,useEffect as Rt,useMemo as wa,useRef as Or,useState as je}from"react";import{useId as ga}from"react";import{jsx as Pn,jsxs as Mt}from"react/jsx-runtime";function et({open:e,onOpenChange:n,initialCode:t,onConnected:r,showStatus:o,reason:s}){let{error:a}=D(),c=St(),i=H(),l=()=>n(!1),u=ga(),p=i.context?.background?.trim(),y=p?ln(p,i.context?.accent):void 0;return Mt(Vn,{open:e,onClose:l,labelledBy:u,theme:i.theme,style:y,children:[a?Mt("div",{className:"sc-card",children:[Pn("h2",{className:"sc-title",id:u,children:"Could not start"}),Pn("p",{className:"sc-error",children:a.message})]}):!c&&!i.context?Mt("div",{className:"sc-card",children:[Pn("h2",{className:"sc-title",id:u,children:"One moment"}),Pn("p",{className:"sc-note",children:"Getting your compute\u2026"})]}):Pn(pr,{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:[Pn(j,{className:"sc-foot-mark"}),"Secured by Soba"]})]})}import{useCallback as ba}from"react";function ya(){let{connect:e}=D(),n=Qn(),t=ba(()=>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 ${V(e)}`:"Connect compute",connected:e!==null,state:n}}import{Fragment as Ir,jsx as Ye,jsxs as tt}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=St(),[m,w]=je(s??!!r),P=Or(null),R=a!==void 0,_=!R&&!s&&!r&&u.hasModal,M=R?a:_?u.isOpen:m,B=v=>{_?v?u.open("manual"):u.close():R||w(v),c?.(v)},I=Or(M);Rt(()=>{I.current&&!M&&P.current?.focus(),I.current=M},[M]);let[N,F]=je(null),[T,se]=je(!1),X=wa(()=>T&&N?va(l.machines,N):l.machines,[l.machines,T,N]),ve=Ee(X),K=Pt(ve),ae=i&&K.connected,We=K.state,Y=nt(()=>se(!1),[]),[Me,Xe]=je(!1),de=nt(async()=>{Xe(!0);try{await l.refresh()}finally{Xe(!1)}},[l]),pe=Or(de);pe.current=de,Rt(()=>{T&&pe.current()},[T]);let[ee,gn]=je(!1),[en,Le]=je([]),nn=!!p.context?.hosted_available;Rt(()=>{if(!T||!f||!nn)return;let v=!0;return f.hosted().then(G=>{v&&Le(G.credentials)}).catch(()=>{}),()=>{v=!1}},[T,f,nn]);let[me,ne]=je(!1);Rt(()=>{if(!T||!f)return;let v=!0,G=Oe(async()=>{let te=await f.runs();v&&F(te)},3e3);return()=>{v=!1,G()}},[T,f]);let[Be,Pe]=je(null),Ae=nt(async(v,G)=>{if(f){Pe(null);try{await f.approveRuntime(v,G),await l.refresh()}catch(te){Pe(te.message)}}},[f,l]),qe=nt(async(v,G)=>{if(f){Pe(null);try{await f.preferRuntime(v,G),await l.refresh()}catch(te){Pe(te.message)}}},[f,l]),ie=nt(async v=>{if(f){Pe(null);try{await f.disconnectHosted(v),Le((await f.hosted()).credentials)}catch(G){Pe(G.message)}}},[f]),E=p.context?.background?.trim(),bn=E?ln(E,p.context?.accent):void 0;return tt(Ir,{children:[Ye("button",{ref:P,type:"button","data-theme":y,className:["sc-btn",ae?"sc-btn-connected":"sc-btn-icon",!ae&&n==="primary"?"sc-btn-primary":"",t].filter(Boolean).join(" "),...ae&&!e?{"aria-haspopup":"dialog","aria-expanded":T,"aria-label":K.ariaLabel}:{},onClick:()=>{if(ae&&!e&&!R&&!s&&!r){se(v=>!v);return}B(!0)},children:e??(ae?tt(Ir,{children:[Ye("span",{className:"sc-pill-tile","aria-hidden":"true",children:Ye(j,{className:We.tone==="busy"?"sc-pill-mark sc-pill-mark-busy":"sc-pill-mark"})}),tt("span",{className:"sc-btn-connected-text",children:[We.word,ve&&tt("span",{className:"sc-btn-connected-where",children:[" on ",V(ve)]})]}),Ye("i",{className:`sc-dot sc-dot-${We.tone}`,"aria-hidden":"true"})]}):tt(Ir,{children:[Ye(j,{className:"sc-btn-mark"}),"Connect compute"]}))}),Ye(vr,{open:T,onClose:Y,anchor:P,label:"Your compute",theme:y,...bn?{style:bn}:{},children:Ye(dn,{machines:X,hosted:en,onApproveRuntime:(v,G)=>void Ae(v,G),onPreferRuntime:(v,G)=>void qe(v,G),onDisconnectHosted:v=>void ie(v),onRefresh:()=>void de(),refreshing:Me,error:Be,runs:N,runsOpen:me,onToggleRuns:()=>ne(v=>!v),onPair:()=>{se(!1),_?u.open("pair"):(gn(!0),B(!0))},...p.context?.app.name?{appName:p.context.app.name}:{}})}),!_&&Ye(et,{open:M,onOpenChange:v=>{v||gn(!1),B(v)},...ee?{showStatus:!1}:{},...r?{initialCode:r}:{},...o?{onConnected:o}:{}})]})}function va(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 Tr,jsxs as Ca}from"react/jsx-runtime";function ka({initialCode:e,onConnected:n,className:t,showStatus:r=!0}){let{theme:o}=H();return Ca("div",{className:t?`soba-connect ${t}`:"soba-connect","data-theme":o,children:[r&&Tr(Er,{}),Tr("div",{className:"sc-compute-act",children:Tr(fn,{...e?{initialCode:e}:{},...n?{onConnected:n}:{}})})]})}import{useId as La,useState as Aa}from"react";import{useCallback as Ar,useEffect as _o,useState as Eo}from"react";import{useCallback as Na,useState as xa}from"react";function rt(){let[e,n]=xa(null);return{open:Na(()=>{n(null),Jt().then(n)},[]),launch:e,note:e==="absent"?"Nothing opened here. That machine may be a different computer, or asleep.":null}}import{useCallback as So,useMemo as Mo}from"react";function hn(e){if(!e)return null;if(typeof e=="string")return e;if(typeof Response<"u"&&e instanceof Response)return Po(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"?Po(n.status):n.cause&&n.cause!==e?hn(n.cause):null}function Po(e){return e===402?"payment_required":e===409?"no_compute":null}function Lr(...e){let[n,t]=e,{plan:r,compute:o,connect:s}=D(),a=t?.predict??e.length===0,c=Ma(Sa(n),o)??(a?Pa(r,o):null),i=r.plan,l=r.plans,u=Mo(()=>{if(c!=="payment_required")return null;let m=i?.price??0,w=i?.included_units??0;return l.find(P=>P.id!==i?.id&&P.price>m&&(P.included_units===null||P.included_units>w))??null},[c,l,i]),p=So(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=So(()=>{c&&y(c)},[y,c]);return Mo(()=>{if(!c)return null;let m=i?He({unit:i.unit,reward:i.connected_reward,includedUnits:i.connected_included_units,creditMicros:i.connected_credit*1e6}):null,w=i&&Ue(i.connected_reward)?m:null;return{reason:c,...Ra(c,{connectOffer:w,connected:o.connected,online:o.online,machine:cn(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 Sa(e){let n=hn(e);return n==="payment_required"||n==="no_compute"?n:null}function Ma(e,n){return e==="no_compute"&&n.connected&&n.online?null:e}function Pa(e,n){let t=e.plan;return!t||n.loading?null:xe(t.route_allow)&&!n.online?"no_compute":e.remaining===0&&t.overage==="stop"?"payment_required":null}function Ra(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 ${Ro(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 ${Ro(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 Ro(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}function _a(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=xe(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&&Mr(n.route_prefer,u);if(!c&&!y&&!f)return null;let m=xe(u)?Ea(n.unit,xe(n.route_allow)):Ue(n.connected_reward)?Ia(t,n,i):f?Oa(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 $r(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=sr(c.publishableKey),[l,u]=Eo(!1);_o(()=>{u(ar(i))},[i]);let p=Ar(()=>{u(!0),ir(i)},[i]),y=Ar(()=>c.open("manual"),[c]),f=Ar(()=>c.open("no_compute"),[c]),m=rt(),[w,P]=Eo(!1),{refresh:R}=a,{launch:_}=m;_o(()=>{if(_===null||_==="absent")return;P(!1);let F=setInterval(()=>void R(),3e3),T=setTimeout(()=>{clearInterval(F),P(!0)},2e4);return()=>{clearInterval(F),clearTimeout(T)}},[_,R]);let M=Ta(c.app?.name,Fn(c.connectUrl)),B=s.loading||a.loading,I=cn(a.machines),N=B?null:_a({plan:s.plan,allowance:{remaining:s.remaining,included:s.included},connected:a.connected,online:a.online,quiet:I?V(I):null,error:t,predict:o,...r!==void 0?{allow:r}:{},at:n,waved:l});return{reason:N?.reason??null,visible:N!==null,title:N?.title??null,detail:N?.detail??null,meter:N?.meter??null,dismissible:N?.dismissible??!1,dismissed:l,dismiss:p,open:y,atTheWall:N?.atTheWall??!1,steps:M,stalled:N?.reason==="stalled"?{machine:I?V(I):null,ownCompute:N.ownCompute,wake:m.open,launch:m.launch,note:m.note,stuck:w,connectAnother:f}:null,loading:B}}function Ea(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 Oa(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 Ia(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=He({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 Ta(e,n){return[{lead:"Download Soba App",detail:"",...n?{linksLead:"Get it for"}:{},links:n?qn.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:ce.map(t=>({label:t.short,href:t.install}))}]}import{Fragment as Io,jsx as L,jsxs as Ze}from"react/jsx-runtime";function $a(e){let{className:n,fallback:t=null}=e,r=$r({...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]=Aa(null),i=La(),l=L(Io,{children:t});if(!r.visible)return l;if(r.stalled)return L(Oo,{className:n,theme:s,stalled:!0,children:L(Da,{title:r.title??"",detail:r.detail??"",stalled:r.stalled})});let u=a??r.atTheWall;return Ze(Oo,{className:n,theme:s,children:[Ze("div",{className:"sc-nudge-top",children:[Ze("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:r.title}),L("p",{className:"sc-nudge-detail",children:r.detail}),Ze("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(Ua,{})]})]}),r.dismissible?L("button",{type:"button",className:"sc-nudge-dismiss","aria-label":"Dismiss",title:"Dismiss",onClick:r.dismiss,children:L(Ha,{})}):null]}),u?L("ol",{className:"sc-nudge-steps",id:i,children:r.steps.map(p=>Ze("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?Ze("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 Oo({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 Da({title:e,detail:n,stalled:t}){return Ze(Io,{children:[L("div",{className:"sc-nudge-top",children:Ze("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 Ha(){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 Ua(){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 Wa=new Set(["delta","thinking","status","done","error"]);function Rn(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"||!Wa.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*Dr(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(
|
|
4
|
-
`);if(a=[],p==="[DONE]")return;let
|
|
5
|
-
`);if(
|
|
2
|
+
import{useEffect as Ns,useRef as xs,useState as At}from"react";var yn=class extends Error{status;constructor(n,t){super(n),this.name="ConnectError",this.status=t}},hs=5*6e4,Tn=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 yn&&s.status===401)throw s;this.gatewayBackUntil=Date.now()+hs}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 yn("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 yn(a,o.status)}return s}};function Bn(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 Tt(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 bn(e,n,t){let r=Tt(e),o=Tt(n);return!r||!o?e:`#${r.map((a,l)=>Math.round(a+(o[l]-a)*t)).map(a=>a.toString(16).padStart(2,"0")).join("")}`}function rn(e,n){if(!Tt(e))return{};let t=Bn(e),r=n?.trim();return{"--sc-ground":e,"--sc-shell":e,"--sc-sheet":bn(e,t,.07),"--sc-raised":bn(e,t,.13),"--sc-line":bn(e,t,.18),"--sc-line-2":bn(e,t,.28),"--sc-text":t,"--sc-text-2":bn(t,e,.15),"--sc-muted":bn(t,e,.38),...r?{"--sc-accent":r,"--sc-accent-fg":Bn(r)}:{"--sc-accent":t,"--sc-accent-fg":e}}}function Gn(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 Wn(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 on(e){return e.find(n=>n.state==="offline")??null}function Bt(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 mt(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 Ie(e){return[...e].sort(mt)[0]??null}function sn(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 wn(e){let n=sn(e);return{label:e?n.word:"Connect compute",ariaLabel:e?`${n.word} on ${_(e)}`:"Connect compute",connected:e!==null,state:n}}function Gt(e){return e.state==="online"||e.state==="busy"}function Hn(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 Wt(e,n){let t=r=>r.absent?2:r.quarantined?1:0;return t(e)-t(n)||e.display_name.localeCompare(n.display_name)}function Ht(e){return e.runtimes.filter(n=>n.id!=="shell")}function ye(e){return e.runtimes.filter(n=>n.id!=="shell"&&!n.quarantined&&!n.absent)}function Ge(e){let n=a=>a?e.runtimes.find(l=>l.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,l)=>o(a)-o(l))[0]??null;return{by:"default",runtimeId:s?.id??null,runtime:s}}var Dt={"claude-code":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LdmMDFUGiPQm85+OMP6Ul+i323zeItTiodoFLQBcWTXwGzxn0BijiYgzGcTQWguIgdoz8sWQSMR3A0hMCPb5owh4whw+YR7MJ6ktMo+EciiobYAFJqDE4zPhtDRKVwF5DSuQcnOKR2AP8Cui93e4Bz9uMXV0/FBGGZ/BaqmGMFGWMFNw7QyOZML4XaHNc3OnIDZkE7cOUzf5QfCGN8C6GkgqwSeXP8HIxHP4MmOI/a321n07gV9IjNBy7QnyZrED37ivv4/PQyO8w10e8KcphEWKSNuIPY8QfKrR4Ye+yCnB3kPeGZiJkLwBzq+EZK2GxGe7nRW12PSGeADM/EmtjG4qej4OQ90YuRN/rYcWzMU8ZPuWbyCHPgbYT3vQ4Pp0/OM7QYx6VGXgMbdGN/AVNIT3cAadkl50K7+QtmgFGBskwuuGBL+EfnaxNQFH3ihDqM12j6lTyyVn4H4E6hAx4NkYwy1G0DlAmsUN8ESX6/+H/GpiUBv4FSyLhydRRp0cAAAAASUVORK5CYII="};import{useEffect as io,useRef as gs}from"react";import{Fragment as bs,jsx as Ne,jsxs as Ut}from"react/jsx-runtime";function Dn({anchor:e,label:n,options:t,current:r,onClose:o,onPick:s}){let a=gs(null);return io(()=>{let i=a.current,c=e.current;if(!i||!c)return;try{typeof i.showPopover=="function"&&i.showPopover()}catch{}let u=c.getBoundingClientRect(),p=i.offsetWidth,f=i.offsetHeight,g=Math.max(8,Math.min(u.right-p,window.innerWidth-p-8)),m=u.bottom+6,y=m+f>window.innerHeight-8&&u.top-6-f>8?u.top-6-f:m;i.style.left=`${Math.round(g)}px`,i.style.top=`${Math.round(y)}px`,i.querySelector('[aria-checked="true"]')?.focus()},[e]),io(()=>{let i=c=>{let u=c.target;!u||a.current?.contains(u)||e.current?.contains(u)||o()};return document.addEventListener("pointerdown",i,!0),()=>document.removeEventListener("pointerdown",i,!0)},[e,o]),Ne("div",{ref:a,role:"menu","aria-label":n,className:"sc-menu",popover:"manual",onKeyDown:i=>{let c=[...a.current?.querySelectorAll("[role=menuitemradio]")??[]],u=c.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;c[(u+p+c.length)%c.length]?.focus()}else i.key==="Tab"&&o()},children:t.map(i=>Ne(fs,{option:i,checked:r===i.id,onClose:o,onPick:s},i.id??""))})}function fs({option:e,checked:n,onClose:t,onPick:r}){return Ut(bs,{children:[e.heading?Ne("div",{className:"sc-menu-head",role:"presentation",children:e.heading}):e.rule?Ne("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:[Ne("span",{className:"sc-menu-label",children:e.label}),e.note&&Ne("span",{className:"sc-menu-note",children:e.note})]}),n&&Ne(As,{})]})]})}function As(){return Ne("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-menu-check",children:Ne("path",{d:"M5 12.5l4.5 4.5L19 7.5",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Cn({open:e}){return Ne("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-chev sc-chev-open":"sc-chev",children:Ne("path",{d:"M9 6l6 6-6 6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}import{jsx as we,jsxs as ws}from"react/jsx-runtime";function X({className:e}){return ws("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 lo({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 an({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 ys({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 Ft({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 Ye={claude:lo,chatgpt:an,local:ht},co={shell:ys};function po(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 Cs=3e3,vs=2*6e4,gt=Date.now(),ft=new Set,uo=!1;function ks(){if(uo||typeof window>"u")return;uo=!0;let e=()=>{let t=gt;if(gt=Date.now(),gt-t>vs)for(let r of ft)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 ft)t()};window.addEventListener("focus",n),document.addEventListener("visibilitychange",n)}function Ce(e,n,t={}){ks();let r,o=t.immediate===!1?Date.now():0,s=!1,a=!1,l=()=>{a||(r=setTimeout(i,t.idle===!1?n:po(n,Date.now()-gt)))},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}}l()}},c=()=>{Date.now()-o>Math.min(n,Cs)&&i()};return ft.add(c),t.immediate===!1?l():i(),()=>{a=!0,clearTimeout(r),ft.delete(c)}}var ce=[{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"]}],mo=["claude","chatgpt"];function Qt(){return ce.filter(e=>mo.includes(e.id))}function Jt(e){return ce.filter(n=>n.costClass===e)}function Vt(e){return ce.find(n=>n.expects.includes(e))??null}import{Fragment as Ao,jsx as A,jsxs as I}from"react/jsx-runtime";function ln({machines:e,hosted:n=[],onApproveRuntime:t,onPreferRuntime:r,onDisconnectHosted:o,onPair:s,onRefresh:a,refreshing:l,busy:i,appName:c,error:u,runs:p,loadRuns:f,loading:g,machineMenu:m,machineNote:y,children:R,onStopRun:S}){let k=Ie(e),W=e.filter(M=>M.id!==k?.id),[F,O]=At(!1),[P,Q]=At(null),T=p===void 0&&!!f,K=T?P:p??null,q=p!==void 0||!!f;Ns(()=>{if(!T||!F||!f)return;let M=!0,De=Ce(async()=>{let Y=await f();M&&Q(Y)},3e3);return()=>{M=!1,De()}},[T,F,f]);let de=k&&K?Ps(K,k):{},V=k?Ht(k):[];return!k&&n.length===0&&!s?A("p",{className:"sc-note",children:"Nothing connected yet."}):I("div",{className:"sc-tray",children:[k&&I(vn,{title:"This machine",action:(a||m)&&I("span",{className:"sc-cap-acts",children:[a&&A("button",{type:"button",className:"sc-disc",onClick:a,disabled:l,"aria-label":"Refresh",title:"Refresh",children:A(Fs,{spinning:!!l})}),m]}),children:[A(Rs,{machine:k,...q?{onToggle:()=>O(M=>!M),open:F}:{}}),y]}),k&&q&&F&&A(Ms,{machine:k,runs:K,...S?{onStop:S}:{}}),k&&A(vn,{title:"Agents on it",action:A(Gs,{machine:k,appName:c,busy:i,...r?{onPick:M=>r(k.id,M)}:{}}),children:g&&V.length===0?A("p",{className:"sc-row-note",children:"Looking\u2026"}):V.length>0?[...V].sort(Wt).map(M=>A(Ts,{runtime:M,serving:de[M.id]??M.serving??0,...t?{onApprove:()=>t(k.id,M.id)}:{}},M.id)):A("p",{className:"sc-row-note",children:"No agent advertised. Install Claude Code, Codex or Ollama on that machine."})}),n.length>0&&A(vn,{title:n.length>1?"Connected plans":"Connected plan",children:n.map(M=>A(Hs,{credential:M,appName:c,busy:i,...o?{onDisconnect:()=>o(M.provider)}:{}},M.provider))}),(W.length>0||s)&&I(vn,{title:W.length>0?"Your other machines":k?"Add a machine":"Your machines",children:[W.map(M=>A(Ls,{machine:M},M.id)),s&&I("button",{type:"button",className:"sc-pair",onClick:s,children:[A("span",{className:"sc-otile","aria-hidden":"true",children:A(Ds,{})}),A("span",{className:"sc-oname",children:e.length>0?"Pair another machine":"Connect a machine"})]})]}),R,u&&A("p",{className:"sc-error sc-tray-error",children:u})]})}function vn({title:e,action:n,children:t}){return I("section",{className:"sc-group",children:[I("div",{className:"sc-group-cap",children:[A("p",{className:"sc-group-title",children:e}),n]}),A("div",{className:"sc-group-card",children:t})]})}function Rs({machine:e,onToggle:n,open:t}){let r=Gt(e),o=[r?null:e.pairing_lost?"No longer connected here":"Asleep or offline",Wn(e),e.always_on?"always on":null,r&&e.capacity>0?`${e.active} of ${e.capacity} in flight`:Hn(e.last_seen_at)].filter(Boolean),s=I(Ao,{children:[I("span",{className:"sc-mtile","aria-hidden":"true",children:[A(fo,{}),A("span",{className:`sc-mbadge sc-mbadge-${sn(e).tone}`})]}),I("span",{className:"sc-mid",children:[A("span",{className:"sc-mname",children:_(e)}),A("span",{className:"sc-mmeta",children:o.map((a,l)=>I("span",{children:[l>0&&A("span",{className:"sc-mmeta-sep",children:"\xB7"}),a]},a))})]})]});return!n||!r?A("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,A(Cn,{open:!!t})]})}function Ss(e,n){return e.filter(t=>t.machine_id===n.id||t.machine_id===null)}function Ps(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 Ms({machine:e,runs:n,onStop:t}){let r=n?Ss(n,e):[],[o,s]=At(new Set),a=async l=>{s(i=>new Set(i).add(l));try{await t?.(l)}catch{s(i=>{let c=new Set(i);return c.delete(l),c})}};return A(vn,{title:"Running now",children:n===null?A("p",{className:"sc-row-note",children:"Looking\u2026"}):r.length===0?A("p",{className:"sc-row-note",children:"Nothing running."}):r.map(l=>A(Es,{run:l,stopping:o.has(l.id),...t?{onStop:()=>void a(l.id)}:{}},l.id))})}function Es({run:e,stopping:n,onStop:t}){return I("div",{className:"sc-rrow",children:[A(Yt,{id:e.runtime_id}),I("span",{className:"sc-mid",children:[I("span",{className:"sc-rtop",children:[A("span",{className:"sc-aname",children:ho(e)}),A("span",{className:"sc-averdict",children:Os(e.started_at)})]}),A("span",{className:"sc-rstep",children:n?"Stopping\u2026":Is(e)})]}),t&&A("button",{type:"button",className:"sc-disc sc-rstop",onClick:t,disabled:n,"aria-label":`Stop ${ho(e)}`,title:"Stop",children:A(Qs,{})})]})}function go(e){let n=Vt(e);return(n?Ye[n.id]:null)??co[e]??null}function ho(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 Is(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 Os(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 Ls({machine:e}){let n=sn(e);return I("div",{className:"sc-orow",children:[A("span",{className:"sc-otile","aria-hidden":"true",children:A(fo,{})}),A("span",{className:"sc-oname",children:_(e)}),A("span",{className:"sc-oword",children:n.word}),A("span",{className:`sc-dot sc-dot-${n.tone}`,"aria-hidden":"true"})]})}function Ts({runtime:e,serving:n=0,onApprove:t}){let r=Gn(e),o=I(Ao,{children:[A(Yt,{id:e.id,name:e.display_name}),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:[A(Us,{}),A("span",{className:"sc-aserving",children:n>1?`${n} running`:"running"})]}):e.absent?A("span",{className:"sc-averdict sc-tone-absent",children:"not offered"}):e.quarantined?t?A("button",{type:"button",className:"sc-row-act",onClick:t,children:"Let it serve"}):A("span",{className:"sc-averdict sc-tone-warn",children:"new, not serving yet"}):r.tone==="ok"?I("span",{className:"sc-averdict",children:[A("span",{className:"sc-dot sc-dot-ok","aria-hidden":"true"}),A("span",{className:"sc-sr",children:r.text})]}):A("span",{className:`sc-averdict sc-tone-${r.tone}`,children:r.text})]});return A("div",{className:"sc-arow",children:o})}function Yt({id:e,name:n}){return A("span",{className:"sc-runtime-tile","aria-hidden":"true",children:A(Bs,{id:e,...n?{name:n}:{}})})}function Bs({id:e,name:n}){if(!e)return null;let t=Dt[e];if(t)return A("img",{src:t,alt:"",className:"sc-runtime-logo"});let r=go(e);return r?A(r,{className:"sc-runtime-mark"}):n?A("span",{className:"sc-runtime-letter",children:n.slice(0,1).toUpperCase()}):null}function Gs({machine:e,appName:n,busy:t,onPick:r}){let o=Ge(e),s=ye(e),[a,l]=At(!1),i=xs(null);if(o.by!=="app"&&s.length===0)return null;let c=f=>f?A(Yt,{id:f.id,name:f.display_name}):null,u=f=>{if(!f)return null;let g=Dt[f.id];if(g)return A("img",{src:g,alt:"",className:"sc-runs-logo"});let m=go(f.id);return m?A(m,{className:"sc-runs-glyph"}):null},p;return o.by==="app"?p=I("span",{className:"sc-runs-fixed",title:`Set by ${n??"the app"}`,children:[u(o.runtime),o.runtime?.display_name??o.runtimeId]}):!r||s.length<2?p=I("span",{className:"sc-runs-fixed",children:[u(o.runtime),o.runtime?.display_name]}):p=I("button",{ref:i,type:"button",className:"sc-runs-btn","aria-haspopup":"menu","aria-expanded":a,"aria-label":`Runs go to ${o.runtime?.display_name??"the default"}. Change`,disabled:t,onClick:()=>l(f=>!f),children:[u(o.runtime),A("span",{className:"sc-runs-label",children:o.runtime?.display_name}),A(Cn,{open:!0})]}),I("span",{className:"sc-runs-to",children:[A("span",{className:"sc-runs-cap",children:o.by==="app"?`${n??"App"} uses`:"Runs on"}),p,a&&r&&A(Ws,{anchor:i,machine:e,tile:c,onClose:()=>l(!1),onPick:f=>{l(!1),r(f)}})]})}function Ws({anchor:e,machine:n,tile:t,onClose:r,onPick:o}){let s=Ge(n),a=Ge({...n,preferred_runtime:null}).runtime,l=s.by==="you"?s.runtimeId:null,i=[{id:null,label:"Automatic",...a?{note:`Uses ${a.display_name}`}:{},glyph:t(a)},...ye(n).map((c,u)=>({id:c.id,label:c.display_name,glyph:t(c),...u===0?{rule:!0}:{}}))];return A(Dn,{anchor:e,label:"Which agent runs go to",options:i,current:l,onClose:r,onPick:o})}function Hs({credential:e,appName:n,busy:t,onDisconnect:r}){return I("div",{className:"sc-hrow",children:[I("div",{className:"sc-orow",children:[A("span",{className:"sc-otile","aria-hidden":"true",children:A(an,{className:"sc-omark"})}),I("span",{className:"sc-mid",children:[A("span",{className:"sc-oname",children:e.provider==="openai-chatgpt"?"ChatGPT plan":e.provider}),A("span",{className:"sc-mmeta",children:e.account_label??"signed in"})]}),r&&A("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 fo(){return I("svg",{viewBox:"0 0 32 24","aria-hidden":"true",focusable:"false",className:"sc-mglyph",children:[A("rect",{x:"4",y:"1.5",width:"24",height:"15",rx:"2.5",fill:"var(--sc-sheet, #ffffff)",stroke:"currentColor",strokeWidth:"2"}),A("rect",{x:"1",y:"19.5",width:"30",height:"2.5",rx:"1.25",fill:"currentColor"})]})}function Ds(){return A("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-oglyph",children:A("path",{d:"M12 5v14M5 12h14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}function Us(){return I("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:"sc-sglyph sc-spin",children:[A("circle",{cx:"12",cy:"12",r:"9",fill:"none",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),A("path",{d:"M12 3a9 9 0 0 1 9 9",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Fs({spinning:e}){return A("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",className:e?"sc-dglyph sc-spin":"sc-dglyph",children:A("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 Qs(){return A("svg",{className:"sc-dglyph",viewBox:"0 0 16 16","aria-hidden":"true",children:A("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1.5",fill:"currentColor"})})}import{jsx as Js}from"react/jsx-runtime";function Un({machines:e,onApproveRuntime:n}){return Js(ln,{machines:e,...n?{onApproveRuntime:n}:{}})}var jt={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 zt="105 162 420 420",qt="M407.1 308.9 A158 158 0 1 0 407.1 491.1 A116 116 0 0 1 407.1 308.9 Z",cn="M448.5 320 A110 110 0 0 1 448.5 480";import{Fragment as Qn,jsx as x,jsxs as je}from"react/jsx-runtime";function Zt({kind:e,size:n=44,className:t}){let r=jt[e];return je("svg",{className:`bx${t?` ${t}`:""}`,"data-expression":e,viewBox:zt,overflow:"visible",width:n,height:n,"aria-hidden":"true",children:[x("path",{d:qt,fill:"currentColor"}),x("path",{className:"bx-arc",d:cn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"}),r.slot==="stream"&&x(Vs,{}),r.slot==="zzz"&&x(Ys,{}),r.slot==="dots"&&x(js,{}),r.slot==="bang"&&x(zs,{}),r.slot==="orbit"&&x(qs,{}),r.slot==="cross"&&x(Zs,{}),r.slot==="snap"&&x(Xs,{}),r.slot==="bars"&&x(Ks,{}),r.slot==="ring"&&x(_s,{}),r.slot==="sparks"&&x($s,{})]})}function Vs(){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 Ys(){return je(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 js(){return je(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 zs(){return je("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 qs(){return je("g",{className:"bx-ob",children:[x("path",{d:cn,fill:"none",stroke:"var(--tile-bg, transparent)",strokeWidth:41,strokeLinecap:"round"}),x("path",{d:cn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})]})}function Zs(){return je(Qn,{children:[x("path",{className:"bx-xa",d:cn,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 Xs(){return x("path",{className:"bx-snap",d:cn,fill:"none",stroke:"currentColor",strokeWidth:17,strokeLinecap:"round"})}function Ks(){return je("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 _s(){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 $s(){return je(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 ae,useEffect as ue,useId as oa,useMemo as ze,useRef as kn,useState as J}from"react";var Jn=[{slug:"mac-arm",label:"macOS, Apple silicon"},{slug:"mac-intel",label:"macOS, Intel"},{slug:"windows",label:"Windows"},{slug:"linux",label:"Linux"}];function Vn(e){if(!e)return"";try{return new URL(e).origin}catch{return""}}var Xt="soba";function yo(){return`${Xt}://show`}function Yn(e,n,t){let r=`${Xt}://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 ea=1600;function Kt(e={}){return er(e)}async function _t(e,n={}){if(typeof window>"u"||typeof document>"u")return"unknown";let t=er(n);try{window.location.href=Yn(e,n.nonce,n.want)}catch{return"absent"}return t}async function $t(e={}){if(typeof window>"u"||typeof document>"u")return"unknown";let n=er(e);try{window.location.href=yo()}catch{return"absent"}return n}async function er(e){if(typeof window>"u"||typeof document>"u")return"unknown";let n=e.graceMs??ea,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 wo="soba.connect.choice",na=180*24*60*60*1e3;function nr(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 tr(e,n){return e?n?`${wo}.${e}.${nr(n)}`:`${wo}.${e}`:null}function rr(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)>na)return null;let r=ce.find(o=>o.id===t.choice);return r?r.id:null}catch{return null}}function or(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var Co="soba.connect.model",ta=180*24*60*60*1e3;function sr(e,n){return e?n?`${Co}.${e}.${nr(n)}`:`${Co}.${e}`:null}function bt(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)>ta)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 ar(e,n){if(!(!e||typeof localStorage>"u"))try{localStorage.setItem(e,JSON.stringify({choice:n,at:new Date().toISOString()}))}catch{}}var vo="soba.connect.dismissed",ra=30*24*60*60*1e3;function ir(e,n){return e?n?`${vo}.${e}.${nr(n)}`:`${vo}.${e}`:null}function lr(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)<ra}catch{return!1}}function cr(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 ur=2e3,sa=1e4,aa=9e4,ia=6e4;function dr(e,n,t,r=[],o){return e?"code":n&&(t.length>0||r.length>0)?"manage":o?"launch":"choose"}function la(e){let n=Math.max(0,Math.round(e/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function hr({client:e,initialCode:n,initialChoice:t,onConnected:r,showStatus:o=!0,initialContext:s=null,initialMachines:a,onClose:l,headingId:i,theme:c,reason:u,active:p=!0}){let f=!!s&&a!==void 0,[g,m]=J(f?dr(n,o,a??[],[],t):"loading"),[y,R]=J(s),[S,k]=J(a??[]),[W,F]=J(n??""),[O,P]=J(null),[Q,T]=J(null),[K,q]=J(!1),[de,V]=J(0),[M,De]=J(()=>Date.now()),[Y,pe]=J(null),[Ke,Se]=J(!1),[me,te]=J(!1),[mn,Ue]=J("browser"),[Fe,ie]=J(null),[he,re]=J([]),[Qe,hn]=J(0),[Pe,Te]=J(null),oe=kn(null),[w,j]=J(t??null),[E,Mt]=J(null),Je=ze(()=>{let h=y?.accent?.trim(),v=y?.background?.trim();if(!(!h&&!v))return v?{...rn(v,h),background:v,borderRadius:"inherit"}:{"--sc-accent":h,"--sc-accent-fg":Bn(h)}},[y?.accent,y?.background]),ge=oa(),se=i??ge,Ve=kn(null);ue(()=>{if(!e||f)return;let h=!0;return Promise.all([e.context(),e.machines()]).then(([v,H])=>{h&&(R(v),k(H),m(dr(n,o,H)))}).catch(v=>{h&&(T(v.message),m("choose"))}),()=>{h=!1}},[e,n,o,f]),ue(()=>{g!=="loading"||!f||m(dr(n,o,a??[]))},[g,f,n,o,a]),ue(()=>{a&&k(a)},[a]),ue(()=>{s&&R(s)},[s]);let gn=kn(!1),fn=kn(g);fn.current=g;let _e=kn(he);_e.current=he;let $e=!!y?.hosted_available;ue(()=>{!o&&fn.current==="manage"&&m("choose")},[o]),ue(()=>{if(!e||!p||g!=="manage")return;let h=!0,v=Ce(async()=>{try{let H=await e.machines();if(!h)return;k(H);let U=!$e||gn.current;H.length===0&&_e.current.length===0&&U&&fn.current==="manage"&&m("choose")}catch{}},sa,{immediate:!1});return()=>{h=!1,v()}},[g,e,$e,p]);let en=tr(y?.publishable_key??null);ue(()=>{Mt(rr(en))},[en]),ue(()=>{if(!e||!$e)return;let h=!0;return e.hosted().then(v=>{h&&(re(v.credentials),!gn.current&&(gn.current=!0,v.credentials.length>0&&o&&fn.current==="choose"&&m("manage")))}).catch(()=>{}),()=>{h=!1}},[e,$e,o]),ue(()=>{if(!e||!p||g!=="hosted")return;let h=!0,v=async()=>{try{let Ee=await e.hosted();if(!h)return!1;if(re(Ee.credentials),Ee.credentials.length>0)return m("hosted_connected"),Te(null),!0}catch{}return!1},H=async()=>{oe.current?.closed&&(oe.current=null,!await v()&&h&&m("choose"))},U=Ce(v,ur,{immediate:!1}),tn=setInterval(H,400),ke=Ee=>{let Ln=Ee.data;Ln?.source==="soba"&&Ln.type==="hosted_result"&&v()};return window.addEventListener("message",ke),()=>{h=!1,U(),clearInterval(tn),window.removeEventListener("message",ke),oe.current=null}},[e,g,p]);let Et=ae(()=>{if(!e)return;let h=window.open("","soba-connect-plan","width=520,height=760,noopener=no");oe.current=h,m("hosted"),hn(Date.now()),Te(null),T(null),e.startHosted().then(({url:v})=>{if(h&&!h.closed){h.location.href=v;return}Te(v)}).catch(v=>{h?.close(),oe.current=null,T(v.message),m("choose")})},[e]),it=ae(async h=>{if(e){q(!0);try{await e.disconnectHosted(h),re((await e.hosted()).credentials)}catch(v){T(v.message)}finally{q(!1)}}},[e]);ue(()=>{if(!e||!p||g!=="waiting")return;let h=!0,v=Ce(async()=>{try{let H=await e.machines();if(!h)return;k(H);let U=Ve.current;if(!U)return;let tn=H.filter(Ee=>!U.has(Ee.id)),ke=tn.find(Ee=>Ee.state!=="offline")??tn[0];if(ke){ie(ke.id),w&&or(en,w);let Ee=ce.find(Lt=>Lt.id===w)?.expects??[],Ln=ye(ke).find(Lt=>Ee.includes(Lt.id));Ln&&e.preferRuntime(ke.id,Ln.id).catch(()=>{}),m("connected"),r?.(H)}}catch{}},ur,{immediate:!1});return()=>{h=!1,v()}},[g,e,r,w,en,p]);let lt=ae(async()=>{if(e){T(null),q(!0);try{let h=await e.lookup(W);P(h),m("confirm")}catch(h){T(h.message)}finally{q(!1)}}},[e,W]),An=ae(async()=>{if(e){T(null),q(!0);try{try{Ve.current=new Set((await e.machines()).map(h=>h.id))}catch{Ve.current=new Set(S.map(h=>h.id))}await e.approve(W),m("waiting"),V(Date.now())}catch(h){T(h.message)}finally{q(!1)}}},[e,W,S]),ct=ae(async()=>{if(e){q(!0);try{await e.deny(W),Ue("browser"),m("denied")}catch(h){T(h.message)}finally{q(!1)}}},[e,W]),z=ze(()=>y?.connect_url??null,[y]),[Me,fe]=J(()=>jn()),nn=ze(()=>z?Yn(z,Me??void 0,w??void 0):null,[z,Me,w]),ut=ze(()=>Vn(z),[z]),It=ae(h=>{if(S.length===0)return null;let v=ce.find(U=>U.id===h);if(!v)return null;let H=S.flatMap(U=>U.runtimes??[]).filter(U=>v.expects.includes(U.id));return H.length===0?{tone:"dim",text:"not installed"}:H.some(U=>U.authenticated===!0)?{tone:"ok",text:"ready"}:H.every(U=>U.authenticated===!1)?{tone:"warn",text:"needs signing in"}:{tone:"dim",text:"installed"}},[S]),C=ae((h=null)=>{j(h),T(null),pe(null),Se(!1),te(!1),Z.current=!1,fe(jn()),m("launch")},[]),Z=kn(!!t);ue(()=>{g!=="launch"||!z||Z.current||(Z.current=!0,Se(!0),_t(z,{...Me?{nonce:Me}:{},...w?{want:w}:{}}).then(pe))},[g,z,Me,w]);let le=ae(()=>{Se(!0),Kt().then(pe)},[]),dt=ae(h=>{if(me){let v=jn();te(!1),fe(v),z&&(h.preventDefault(),window.location.href=Yn(z,v??void 0,w??void 0))}le()},[me,le,z,w]),Ae=ze(()=>{let h=y?.runtimes;return h?ce.filter(v=>h.includes(v.id)):Qt()},[y?.runtimes]),ve=ze(()=>{let h=ce.find(v=>v.id===w);return h?{choice:h,Mark:Ye[h.id]??null}:null},[w]),Be=ze(()=>S.find(h=>h.id===Fe),[S,Fe]);ue(()=>{let h=Me;if(!e||!p||g!=="launch"||!h)return;let v=!1,H=Date.now()+15e4,U=()=>{};return U=Ce(async()=>{if(Date.now()>H){U(),te(!0);return}try{let tn=await e.claim(h);if(v)return;if(tn.declined){U(),pe(null),Ue("machine"),m("denied");return}if(!tn.claimed)return;U();try{Ve.current=new Set((await e.machines()).map(ke=>ke.id))}catch{Ve.current=new Set(S.map(ke=>ke.id))}m("waiting"),V(Date.now())}catch{}},ur,{immediate:!1,idle:!1}),()=>{v=!0,U()}},[e,g,S,Me,p]);let be=ze(()=>{if(!O)return null;if(O.approved||O.denied)return"answered";let h=O.expires_at?Date.parse(O.expires_at):Number.NaN;return Number.isFinite(h)&&h<=M?"expired":"live"},[O,M]);ue(()=>{if(!(g==="confirm"&&be==="live"||g==="waiting"||g==="hosted"))return;let v=setInterval(()=>De(Date.now()),1e3);return()=>clearInterval(v)},[g,be]);let pt=ae(async(h,v)=>{if(e)try{await e.approveRuntime(h,v),k(await e.machines())}catch(H){T(H.message)}},[e]),Ot=ae(async(h,v)=>{if(e)try{await e.preferRuntime(h,v),k(await e.machines())}catch(H){T(H.message)}},[e]);return g==="loading"?d("div",{className:"soba-connect",...c?{"data-theme":c}:{},style:Je,children:d("div",{className:"sc-card",children:d("p",{className:"sc-note",children:"Loading\u2026"})})}):N("div",{className:"soba-connect",...c?{"data-theme":c}:{},style:Je,children:[l&&d("button",{type:"button",className:"sc-modal-close",onClick:l,"aria-label":"Close",children:"\xD7"}),g==="manage"&&N("div",{className:"sc-card",children:[d("h2",{className:"sc-title",id:se,children:"Your compute"}),N("p",{className:"sc-sub",children:[d(yt,{context:y})," ",S.length>0&&he.length>0?"runs on your connected plan, and on these machines while they are awake.":he.length>0?"runs on the plan you connected. Nothing here is charged to you.":"runs on these machines, while they are awake."]}),d(ln,{machines:S,hosted:he,onApproveRuntime:pt,onPreferRuntime:(h,v)=>void Ot(h,v),onDisconnectHosted:h=>void it(h),onPair:()=>m("choose"),busy:K,...y?.app.name?{appName:y.app.name}:{}}),Q&&d("p",{className:"sc-error",children:Q})]}),g==="choose"&&N("div",{className:"sc-card",children:[d(ua,{context:y}),d("h2",{className:"sc-h",id:se,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."}),z&&Ae.length>0&&N(Ct,{children:[d("div",{className:"sc-opts",children:Ae.map(h=>{let v=Ye[h.id];return N("button",{type:"button",className:"sc-opt",onClick:()=>C(h.id),children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:v&&d(v,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),(()=>{let H=It(h.id);return H?d("span",{className:`sc-opt-has sc-opt-has-${H.tone}`,children:H.text}):E===h.id?d("span",{className:"sc-opt-last",children:"last used"}):d(pr,{className:"sc-opt-go"})})()]},h.id)})}),N("p",{className:"sc-opt-note",children:["Your accounts stay there. ",ko(y)," never sees them."]})]}),(!z||Ae.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."}),Q&&d("p",{className:"sc-error",children:Q}),z&&y?.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"})})]}),g==="launch"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d(wt,{mark:ve?.Mark??X,still:me||!Ke&&Y===null}),d("h2",{className:"sc-h",id:se,children:me?"No answer from this machine":Y==="absent"?"Nothing opened":Y===null?"Opening Soba App\u2026":"Approve it on this machine"}),me?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."}),ve&&N("p",{className:"sc-prereq",children:[ve.Mark&&d(ve.Mark,{className:"sc-rt-mark"}),"Needs ",ve.choice.prerequisite]}),N("div",{className:"sc-stack",style:{marginTop:18},children:[d("a",{className:Y==="absent"||me?"sc-btn sc-btn-primary":"sc-btn",href:nn??"#",onClick:dt,children:me?"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."}),ve&&Y==="absent"&&d("p",{className:"sc-note",children:d(da,{text:ve.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(pr,{})]})]})]})]}),g==="get"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("launch")}),d("p",{className:"sc-head-title",children:"Get Soba App"})]}),d("div",{className:"sc-opts",children:Jn.map(h=>N("a",{className:"sc-opt",href:`${ut}/download/${h.slug}`,target:"_blank",rel:"noreferrer noopener",children:[d("span",{className:"sc-opt-tile","aria-hidden":"true",children:d(Ft,{className:"sc-opt-mark"})}),d("span",{className:"sc-opt-text",children:d("span",{className:"sc-opt-label",children:h.label})}),d(pr,{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."})]}),g==="code"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"Soba App"})]}),d("h2",{className:"sc-h",id:se,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(),lt()},children:[d("input",{className:"sc-input",value:W,onChange:h=>F(h.target.value),placeholder:"ACDE-F234",autoComplete:"off",autoFocus:!0,"aria-label":"Pairing code"}),Q&&d("p",{className:"sc-error",children:Q}),d("button",{type:"submit",className:"sc-btn sc-btn-primary",disabled:K||W.length<8,children:K?"Checking\u2026":"Continue"})]})]}),g==="confirm"&&O&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{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(yt,{context:y})," 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(zn,{k:"Code",v:O.user_code}),d(zn,{k:"Machine",v:O.hostname??"not stated"}),d(zn,{k:"System",v:[O.platform,O.arch].filter(Boolean).join(" / ")||"not stated"}),d(zn,{k:"Asked by",v:O.client??"not stated"}),O.labels.length>0&&d(zn,{k:"Labels",v:O.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."}),Q&&d("p",{className:"sc-error",children:Q}),N("div",{className:"sc-row",style:{marginTop:16},children:[d("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:()=>void An(),disabled:K||be!=="live",children:"Approve"}),d("button",{type:"button",className:"sc-btn",onClick:()=>void ct(),disabled:K||be==="answered",children:"No, deny it"})]}),be==="live"&&O.expires_at&&N("p",{className:"sc-note",style:{marginTop:10},children:["This code expires in ",la(Date.parse(O.expires_at)-M),"."]})]}),g==="waiting"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:ve?.choice.short??"Soba App"})]}),d(wt,{mark:ve?.Mark??X}),d("h2",{className:"sc-h",id:se,children:"Approved. Waiting for it to connect"}),d("p",{className:"sc-p",children:"Nothing more to do here. This page changes when it arrives."}),de>0&&M-de>aa&&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."})]}),g==="connected"&&N("div",{className:"sc-card",children:[d(mr,{tone:"ok"}),d("h2",{className:"sc-h",id:se,children:Be?.label?`${Be.label} is connected`:"Connected"}),N("p",{className:"sc-p",children:[d(yt,{context:y})," will use ",Be?.label?"it":"this machine"," from now on, while it is awake."]}),o&&N(Ct,{children:[d("div",{style:{marginTop:16},children:d(Un,{machines:S,onApproveRuntime:pt})}),d("button",{type:"button",className:"sc-btn sc-btn-wide",style:{marginTop:14},onClick:()=>m("manage"),children:"Done"})]})]}),g==="hosted"&&N("div",{className:"sc-card",children:[N("div",{className:"sc-head",children:[d(Nn,{onClick:()=>m("choose")}),d("p",{className:"sc-head-title",children:"ChatGPT"})]}),Pe?d(wt,{mark:an,still:!0}):d(wt,{mark:an}),d("h2",{className:"sc-h",id:se,children:Pe?"Your browser blocked the window":"Finish signing in to ChatGPT"}),d("p",{className:"sc-p",children:Pe?"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:[Pe&&d("a",{className:"sc-btn sc-btn-primary",href:Pe,target:"soba-connect-plan",rel:"noreferrer",children:"Open the ChatGPT sign-in"}),Q&&d("p",{className:"sc-error",children:Q}),Qe>0&&M-Qe>ia&&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."})]})]}),g==="hosted_connected"&&N("div",{className:"sc-card",children:[d(mr,{tone:"ok"}),d("h2",{className:"sc-h",id:se,children:"ChatGPT is connected"}),N("p",{className:"sc-p",children:[d(yt,{context:y})," will run on your ChatGPT plan",he[0]?.account_label?` (${he[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"})})]})]}),g==="denied"&&N("div",{className:"sc-card",children:[d(mr,{tone:"off"}),d("h2",{className:"sc-h",id:se,children:"Declined"}),d("p",{className:"sc-p",children:mn==="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 ko(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 No(e){let n=ca(e),[t,r]=J([]),o=ae(l=>{l&&r(i=>i.includes(l)?i:[...i,l])},[]),s=ae(l=>o(l.currentTarget.getAttribute("src")),[o]),a=ae(l=>{l?.complete&&l.naturalWidth===0&&o(l.getAttribute("src"))},[o]);return{icon:n.find(l=>!t.includes(l)),onError:s,ref:a}}function ua({context:e}){let{icon:n,onError:t,ref:r}=No(e);return e?.app.mark==="soba"?d(X,{className:"sc-app-mark"}):n?d("img",{className:"sc-app-mark",src:n,alt:"","aria-hidden":"true",ref:r,onError:t}):null}function yt({context:e}){let{icon:n,onError:t,ref:r}=No(e),o=e?.app.mark==="soba";return N("span",{className:"sc-app",children:[o&&d(X,{className:"sc-app-icon"}),!o&&n&&d("img",{className:"sc-app-icon",src:n,alt:"",ref:r,onError:t}),ko(e)]})}function Nn({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 pr({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 wt({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 mr({tone:e}){return d("span",{className:`sc-result sc-result-${e}`,"aria-hidden":"true",children:d(Zt,{kind:e==="ok"?"snap":"gone",size:84})})}function da({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 zn({k:e,v:n}){return N("li",{className:"sc-fact",children:[d("span",{className:"sc-fact-key",children:e}),d("span",{children:n})]})}import{forwardRef as pa}from"react";import{jsx as gr,jsxs as fr}from"react/jsx-runtime";var Ar=pa(function({machine:n,className:t,...r},o){if(!n)return null;let{ariaLabel:s,state:a}=wn(n);return fr("button",{ref:o,type:"button","aria-label":s,className:["sc-btn","sc-btn-connected",t].filter(Boolean).join(" "),...r,children:[gr("span",{className:"sc-pill-tile","aria-hidden":"true",children:gr(X,{className:a.tone==="busy"?"sc-pill-mark sc-pill-mark-busy":"sc-pill-mark"})}),fr("span",{className:"sc-btn-connected-text",children:[a.word,fr("span",{className:"sc-btn-connected-where",children:[" on ",_(n)]})]}),gr("i",{className:`sc-dot sc-dot-${a.tone}`,"aria-hidden":"true"})]})});import{useEffect as ma,useRef as yr}from"react";var vt=0,br=null;function xo(){if(typeof document>"u")return()=>{};vt===0&&(br=document.body.style.overflow,document.body.style.overflow="hidden"),vt+=1;let e=!1;return()=>{e||(e=!0,vt-=1,vt===0&&(document.body.style.overflow=br??"",br=null))}}import{jsx as Ro}from"react/jsx-runtime";function qn({open:e,onClose:n,labelledBy:t,theme:r,style:o,children:s}){let a=yr(null),l=yr(null),i=yr(null);return ma(()=>{let c=a.current;if(c){if(!e){c.open&&c.close();return}return c.open||c.showModal(),document.activeElement===c&&l.current?.focus(),xo()}},[e]),Ro("dialog",{ref:a,className:"soba-connect sc-modal","aria-labelledby":t,...r?{"data-theme":r}:{},style:o,onCancel:c=>{c.preventDefault(),n()},onPointerDown:c=>{i.current=c.target},onClick:c=>{c.target===c.currentTarget&&i.current===c.currentTarget&&n()},children:Ro("div",{className:"sc-modal-sheet",ref:l,tabIndex:-1,children:s})})}import{useRef as fa,useState as Aa}from"react";var ha={"claude-code":{small:"haiku",large:"opus"}};function So(e){let n=ha[e];return!!(n?.small||n?.large)}var ga={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus",fable:"Fable"};function Po(e){return ga[e]??e}function wr(e){let n=[...e].sort(mt),t=Ie([...e]),r=t?Ge(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=>So(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 l=new Map;for(let u of n)for(let p of ye(u))for(let f of p.models){if(!f)continue;let g=`${p.id}/${f}`,m=l.get(g);if(m){m.machines.add(_(u));continue}l.set(g,{option:{id:g,kind:"named",label:Po(f),model:f,runtime:p.id,runtimeName:p.display_name,costClass:p.cost_class},machines:new Set([_(u)])})}let i=new Set;for(let{machines:u}of l.values())for(let p of u)i.add(p);let c=i.size>1;for(let{option:u,machines:p}of l.values()){let f=c&&p.size===1?[...p][0]:void 0;s.push(f?{...u,machine:f}:u)}return s}function Zn(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 Cr(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 vr(e){return e.runtime?{model:e.model,runtime:e.runtime}:{model:e.model}}function Xn(e){return e.length>1}import{jsx as kt,jsxs as Mo}from"react/jsx-runtime";function kr({options:e,selected:n,onPick:t,caption:r,disabled:o,className:s}){let[a,l]=Aa(!1),i=fa(null);if(!Xn(e))return null;let c=s?`sc-mp ${s}`:"sc-mp";return Mo("span",{className:c,children:[r&&kt("span",{className:"sc-mp-cap",children:r}),Mo("button",{ref:i,type:"button",className:"sc-mp-btn","aria-haspopup":"menu","aria-expanded":a,"aria-label":`Model: ${n.label}. Change`,disabled:o,onClick:()=>l(u=>!u),children:[kt("span",{className:"sc-mp-label",children:n.label}),kt(Cn,{open:!0})]}),a&&kt(Dn,{anchor:i,label:"Which model answers",options:ba(e),current:n.id,onClose:()=>l(!1),onPick:u=>{l(!1),u&&t(u)}})]})}function ba(e){let n=[];for(let t of Zn(e))t.options.forEach((r,o)=>{let s=ya(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 ya(e){return e.kind!=="named"?e.note:e.machine?`on ${e.machine}`:void 0}import{useEffect as Nr,useRef as wa}from"react";import{jsx as Ca}from"react/jsx-runtime";var un=8;function xr({open:e,onClose:n,anchor:t,label:r,theme:o,style:s,children:a}){let l=wa(null);return Nr(()=>{let i=l.current;if(!(!i||!(typeof i.showPopover=="function")))try{e?i.showPopover():i.hidePopover()}catch{}},[e]),Nr(()=>{if(!e)return;let i=()=>{let u=l.current,p=t.current;if(!u||!p)return;let f=p.getBoundingClientRect(),g=u.offsetWidth,m=u.offsetHeight,y=window.innerWidth-g-un,R=Math.max(un,Math.min(f.right-g,Math.max(un,y))),S=f.bottom+un,k=f.top-un-m,W=S+m>window.innerHeight-un&&k>un?k:S;u.style.left=`${Math.round(R)}px`,u.style.top=`${Math.round(W)}px`};i();let c=requestAnimationFrame(i);return window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),()=>{cancelAnimationFrame(c),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)}},[e,t]),Nr(()=>{if(!e)return;let i=u=>{u.key==="Escape"&&n()},c=u=>{let p=u.target;p&&(l.current?.contains(p)||t.current?.contains(p)||n())};return document.addEventListener("keydown",i),document.addEventListener("pointerdown",c,!0),()=>{document.removeEventListener("keydown",i),document.removeEventListener("pointerdown",c,!0)}},[e,n,t]),Ca("div",{ref:l,role:"dialog","aria-label":r,className:"soba-connect sc-pop",...o?{"data-theme":o}:{},popover:"manual",hidden:!e,style:s,children:a})}var Kn=new Map,xn=new Map,Eo=!1;function va(){Eo||typeof window>"u"||(Eo=!0,window.addEventListener("storage",e=>{!e.key||!Kn.has(e.key)||(xn.set(e.key,bt(e.key)),Rr(e.key))}))}function Rr(e){for(let n of Kn.get(e)??[])n()}function _n(e){return e??""}function Sr(e,n){let t=_n(e);va();let r=Kn.get(t)??new Set;return r.add(n),Kn.set(t,r),()=>{r.delete(n),r.size===0&&Kn.delete(t)}}function Nt(e){let n=_n(e),t=xn.get(n);if(t!==void 0)return t;let r=e?bt(e):null;return xn.set(n,r),r}function Pr(){return null}function Mr(e,n){Nt(e)===null&&(xn.set(_n(e),n),Rr(_n(e)))}function Er(e,n){let t=_n(e);xn.get(t)!==n&&(xn.set(t,n),ar(e,n),Rr(t))}function We(e){let n=`${e.unit}s`;return e.reward==="unlimited"?`Unlimited ${n} on your own AI`:e.reward==="included"&&e.includedUnits!==null?`${Na(e.includedUnits)} ${n} a month once you connect`:e.reward==="credit"&&e.creditMicros>0?`${ka(e.creditMicros)} back each month you stay connected`:null}function He(e){return e==="unlimited"||e==="included"}var Oo=new Set(["user-hardware","user-subscription"]),Io=new Set(["open-weights","frontier"]);function xe(e){return e===null||e.length===0?!1:e.every(n=>Oo.has(n))}var ka=e=>(e/1e6).toLocaleString("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),Na=e=>e.toLocaleString("en-US");function Ir(e,n){if(!(n===null||n.some(s=>Io.has(s))))return!1;let r=e.findIndex(s=>Oo.has(s));if(r===-1)return!1;let o=e.findIndex(s=>Io.has(s));return o===-1||r<o}import{createContext as Lo,useContext as To}from"react";var Or=Lo(null);function Rn(){return To(Or)}var Lr=Lo({context:null,machines:void 0,theme:"light"});function B(){return To(Lr)}import{useMemo as Sa}from"react";import{createContext as xa,useContext as Ra}from"react";var Tr=xa(null);function D(){let e=Ra(Tr);if(!e)throw new Error("useSoba() must be used inside a <SobaProvider>.");return e}function $n(){let{compute:e}=D();return Sa(()=>{let n=e.machines,t=[...n].sort((s,a)=>Ie([s,a])===s?-1:1).map(Pa),r=Ie([...n]),o=on(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 Pa(e){let n=Ge(e);return{machine:e,name:_(e),state:sn(e),status:Bt(e),hardware:Wn(e),lastSeen:e.state==="offline"?Hn(e.last_seen_at):null,runtimes:ye(e).map(t=>({runtime:t,name:t.display_name,auth:Gn(t),quarantined:!!t.quarantined})),runsOn:{by:n.by,name:n.runtime?.display_name??null}}}import{jsx as et}from"react/jsx-runtime";function Ma({className:e}){let{theme:n}=B(),t=e?`soba-connect ${e}`:"soba-connect";return et("div",{className:t,"data-theme":n,children:et(Br,{})})}function Br(){let e=$n();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(Un,{machines:e.machines.map(n=>n.machine)})}import{useCallback as tt,useEffect as Dr,useMemo as Wa,useRef as Ur,useState as Pn}from"react";import{useId as Ea}from"react";import{jsx as Sn,jsxs as xt}from"react/jsx-runtime";function nt({open:e,onOpenChange:n,initialCode:t,onConnected:r,showStatus:o,reason:s}){let{error:a}=D(),l=Rn(),i=B(),c=()=>n(!1),u=Ea(),p=i.context?.background?.trim(),f=p?rn(p,i.context?.accent):void 0;return xt(qn,{open:e,onClose:c,labelledBy:u,theme:i.theme,style:f,children:[a?xt("div",{className:"sc-card",children:[Sn("h2",{className:"sc-title",id:u,children:"Could not start"}),Sn("p",{className:"sc-error",children:a.message})]}):!l&&!i.context?xt("div",{className:"sc-card",children:[Sn("h2",{className:"sc-title",id:u,children:"One moment"}),Sn("p",{className:"sc-note",children:"Getting your compute\u2026"})]}):Sn(hr,{client:l,active:e,onClose:c,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}:{}}),xt("p",{className:"sc-modal-foot",children:[Sn(X,{className:"sc-foot-mark"}),"Secured by Soba"]})]})}import{forwardRef as Ia}from"react";import{jsx as Oa}from"react/jsx-runtime";var Gr=Ia(function(n,t){let{theme:r}=B();return Oa(Ar,{ref:t,"data-theme":r,...n})});import{useCallback as La}from"react";function Ta(){let{connect:e}=D(),n=$n(),t=La(()=>e.open("manual"),[e]);return{...wn(n.primary?.machine??null),machine:n.primary,open:t,canOpen:e.hasModal,loading:n.view==="loading"}}function Wr(e){return wn(e)}import{useCallback as Bo,useEffect as Ba,useState as Ga}from"react";function Hr({enabled:e=!0,intervalMs:n=3e3}={}){let t=Rn(),[r,o]=Ga(null),s=Bo(async()=>{t&&o(await t.runs())},[t]);Ba(()=>{if(!e||!t)return;let l=!0,i=Ce(async()=>{let c=await t.runs();l&&o(c)},n);return()=>{l=!1,i()}},[e,t,n]);let a=Bo(async l=>{if(!t)throw new Error("Stopping a run needs <SobaProvider>.");await t.stopRun(l),await s().catch(()=>{})},[t,s]);return{runs:r,refresh:s,stop:a}}import{Fragment as Go,jsx as Mn,jsxs as Wo}from"react/jsx-runtime";function dn({children:e,variant:n,className:t,initialCode:r,onConnected:o,defaultOpen:s,open:a,onOpenChange:l,showConnected:i=!0}){let{compute:c,connect:u}=D(),p=B(),{theme:f}=p,g=Rn(),[m,y]=Pn(s??!!r),R=Ur(null),S=a!==void 0,k=!S&&!s&&!r&&u.hasModal,W=S?a:k?u.isOpen:m,F=w=>{k?w?u.open("manual"):u.close():S||y(w),l?.(w)},O=Ur(W);Dr(()=>{O.current&&!W&&R.current?.focus(),O.current=W},[W]);let[P,Q]=Pn(!1),{runs:T,stop:K}=Hr({enabled:P}),q=Wa(()=>P&&T?Ha(c.machines,T):c.machines,[c.machines,P,T]),de=Ie(q),V=i&&Wr(de).connected,M=tt(()=>Q(!1),[]),[De,Y]=Pn(!1),pe=tt(async()=>{Y(!0);try{await c.refresh()}finally{Y(!1)}},[c]),Ke=Ur(pe);Ke.current=pe,Dr(()=>{P&&Ke.current()},[P]);let[Se,me]=Pn(!1),[te,mn]=Pn([]),Ue=!!p.context?.hosted_available;Dr(()=>{if(!P||!g||!Ue)return;let w=!0;return g.hosted().then(j=>{w&&mn(j.credentials)}).catch(()=>{}),()=>{w=!1}},[P,g,Ue]);let[Fe,ie]=Pn(null),he=tt(async(w,j)=>{if(g){ie(null);try{await g.approveRuntime(w,j),await c.refresh()}catch(E){ie(E.message)}}},[g,c]),re=tt(async(w,j)=>{if(g){ie(null);try{await g.preferRuntime(w,j),await c.refresh()}catch(E){ie(E.message)}}},[g,c]),Qe=tt(async w=>{if(g){ie(null);try{await g.disconnectHosted(w),mn((await g.hosted()).credentials)}catch(j){ie(j.message)}}},[g]),hn=p.context?.background?.trim(),Pe=hn?rn(hn,p.context?.accent):void 0,Te=V&&!e,oe=()=>{if(Te&&!S&&!s&&!r){Q(w=>!w);return}F(!0)};return Wo(Go,{children:[Te?Mn(Gr,{ref:R,machine:de,"aria-haspopup":"dialog","aria-expanded":P,onClick:oe,...t?{className:t}:{}}):Mn("button",{ref:R,type:"button","data-theme":f,className:["sc-btn","sc-btn-icon",n==="primary"?"sc-btn-primary":"",t].filter(Boolean).join(" "),onClick:oe,children:e??Wo(Go,{children:[Mn(X,{className:"sc-btn-mark"}),"Connect compute"]})}),Mn(xr,{open:P,onClose:M,anchor:R,label:"Your compute",theme:f,...Pe?{style:Pe}:{},children:Mn(ln,{machines:q,hosted:te,onApproveRuntime:(w,j)=>void he(w,j),onPreferRuntime:(w,j)=>void re(w,j),onDisconnectHosted:w=>void Qe(w),onRefresh:()=>void pe(),refreshing:De,error:Fe,runs:T,onStopRun:async w=>{ie(null);try{await K(w)}catch(j){throw ie(j.message),j}},onPair:()=>{Q(!1),k?u.open("pair"):(me(!0),F(!0))},...p.context?.app.name?{appName:p.context.app.name}:{}})}),!k&&Mn(nt,{open:W,onOpenChange:w=>{w||me(!1),F(w)},...Se?{showStatus:!1}:{},...r?{initialCode:r}:{},...o?{onConnected:o}:{}})]})}function Ha(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 Fr,jsxs as Ua}from"react/jsx-runtime";function Da({initialCode:e,onConnected:n,className:t,showStatus:r=!0}){let{theme:o}=B();return Ua("div",{className:t?`soba-connect ${t}`:"soba-connect","data-theme":o,children:[r&&Fr(Br,{}),Fr("div",{className:"sc-compute-act",children:Fr(dn,{...e?{initialCode:e}:{},...n?{onConnected:n}:{}})})]})}import{useId as _a,useState as $a}from"react";import{useCallback as Jr,useEffect as Qo,useState as Jo}from"react";import{useCallback as Fa,useState as Qa}from"react";function rt(){let[e,n]=Qa(null);return{open:Fa(()=>{n(null),$t().then(n)},[]),launch:e,note:e==="absent"?"Nothing opened here. That machine may be a different computer, or asleep.":null}}import{useCallback as Ho,useMemo as Do}from"react";function pn(e){if(!e)return null;if(typeof e=="string")return e;if(typeof Response<"u"&&e instanceof Response)return Uo(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"?Uo(n.status):n.cause&&n.cause!==e?pn(n.cause):null}function Uo(e){return e===402?"payment_required":e===409?"no_compute":null}function Qr(...e){let[n,t]=e,{plan:r,compute:o,connect:s}=D(),a=t?.predict??e.length===0,l=Va(Ja(n),o)??(a?Ya(r,o):null),i=r.plan,c=r.plans,u=Do(()=>{if(l!=="payment_required")return null;let m=i?.price??0,y=i?.included_units??0;return c.find(R=>R.id!==i?.id&&R.price>m&&(R.included_units===null||R.included_units>y))??null},[l,c,i]),p=Ho(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]),f=s.open,g=Ho(()=>{l&&f(l)},[f,l]);return Do(()=>{if(!l)return null;let m=i?We({unit:i.unit,reward:i.connected_reward,includedUnits:i.connected_included_units,creditMicros:i.connected_credit*1e6}):null,y=i&&He(i.connected_reward)?m:null;return{reason:l,...ja(l,{connectOffer:y,connected:o.connected,online:o.online,machine:on(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:p}},[l,i,o,u,g,p,r.current?.period_end])}function Ja(e){let n=pn(e);return n==="payment_required"||n==="no_compute"?n:null}function Va(e,n){return e==="no_compute"&&n.connected&&n.online?null:e}function Ya(e,n){let t=e.plan;return!t||n.loading?null:xe(t.route_allow)&&!n.online?"no_compute":e.remaining===0&&t.overage==="stop"?"payment_required":null}function ja(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 ${Fo(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 ${Fo(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 Fo(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}function za(e){let{plan:n,allowance:t,connected:r,online:o,quiet:s,error:a,predict:l,at:i,waved:c}=e;if(!n)return null;let u=e.allow!==void 0?e.allow:n.route_allow;if(r){if(o)return null;let y=xe(u);return{reason:"stalled",title:`${s??"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 p=pn(a),f=p==="payment_required"||p==="no_compute",g=n.ask_to_connect!==!1&&Ir(n.route_prefer,u);if(!l&&!f&&!g)return null;let m=xe(u)?qa(n.unit,xe(n.route_allow)):He(n.connected_reward)?Xa(t,n,i):g?Za(n.unit):null;return!m||m.dismissible&&c?null:{...m,dismissible:!!m.dismissible,ownCompute:!1,atTheWall:!m.dismissible&&(!l||m.meter!==null&&m.meter.left===0)}}function Vr(e={}){let{at:n=.25,error:t,allow:r}=e,o=e.predict??!(e.errorGiven??t!==void 0),{plan:s,compute:a,connect:l}=D(),i=ir(l.publishableKey),[c,u]=Jo(!1);Qo(()=>{u(lr(i))},[i]);let p=Jr(()=>{u(!0),cr(i)},[i]),f=Jr(()=>l.open("manual"),[l]),g=Jr(()=>l.open("no_compute"),[l]),m=rt(),[y,R]=Jo(!1),{refresh:S}=a,{launch:k}=m;Qo(()=>{if(k===null||k==="absent")return;R(!1);let Q=setInterval(()=>void S(),3e3),T=setTimeout(()=>{clearInterval(Q),R(!0)},2e4);return()=>{clearInterval(Q),clearTimeout(T)}},[k,S]);let W=Ka(l.app?.name,Vn(l.connectUrl)),F=s.loading||a.loading,O=on(a.machines),P=F?null:za({plan:s.plan,allowance:{remaining:s.remaining,included:s.included},connected:a.connected,online:a.online,quiet:O?_(O):null,error:t,predict:o,...r!==void 0?{allow:r}:{},at:n,waved:c});return{reason:P?.reason??null,visible:P!==null,title:P?.title??null,detail:P?.detail??null,meter:P?.meter??null,dismissible:P?.dismissible??!1,dismissed:c,dismiss:p,open:f,atTheWall:P?.atTheWall??!1,steps:W,stalled:P?.reason==="stalled"?{machine:O?_(O):null,ownCompute:P.ownCompute,wake:m.open,launch:m.launch,note:m.note,stuck:y,connectAnother:g}:null,loading:F}}function qa(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 Za(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 Xa(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=We({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 Ka(e,n){return[{lead:"Download Soba App",detail:"",...n?{linksLead:"Get it for"}:{},links:n?Jn.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:ce.map(t=>({label:t.short,href:t.install}))}]}import{Fragment as Yo,jsx as L,jsxs as qe}from"react/jsx-runtime";function ei(e){let{className:n,fallback:t=null}=e,r=Vr({...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}=B(),[a,l]=$a(null),i=_a(),c=L(Yo,{children:t});if(!r.visible)return c;if(r.stalled)return L(Vo,{className:n,theme:s,stalled:!0,children:L(ni,{title:r.title??"",detail:r.detail??"",stalled:r.stalled})});let u=a??r.atTheWall;return qe(Vo,{className:n,theme:s,children:[qe("div",{className:"sc-nudge-top",children:[qe("div",{className:"sc-nudge-say",children:[L("p",{className:"sc-nudge-title",children:r.title}),L("p",{className:"sc-nudge-detail",children:r.detail}),qe("button",{type:"button",className:"sc-btn sc-btn-quiet sc-nudge-more","aria-expanded":u,"aria-controls":i,onClick:()=>l(!u),children:[u?"Hide the details":"How it works",L(ri,{})]})]}),r.dismissible?L("button",{type:"button",className:"sc-nudge-dismiss","aria-label":"Dismiss",title:"Dismiss",onClick:r.dismiss,children:L(ti,{})}):null]}),u?L("ol",{className:"sc-nudge-steps",id:i,children:r.steps.map(p=>qe("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?qe("span",{className:"sc-step-links",children:[p.linksLead,p.links.map(f=>L("a",{href:f.href,target:"_blank",rel:"noreferrer noopener",children:f.label},f.href))]}):null]},p.lead))}):null,L(dn,{variant:"primary"})]})}function Vo({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 ni({title:e,detail:n,stalled:t}){return qe(Yo,{children:[L("div",{className:"sc-nudge-top",children:qe("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 ti(){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 ri(){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 oi=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"||!oi.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*Yr(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 c=s.indexOf(`
|
|
3
|
+
`);if(c===-1)break;let u=zo(s.slice(0,c));if(s=s.slice(c+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 f=p?En(p):null;f&&(yield f);continue}jo(u,a)}}!t&&s&&jo(zo(s),a);let l=t?s.trim():a.join(`
|
|
5
|
+
`);if(l&&l!=="[DONE]"){let i=En(l);i&&(yield i)}}finally{r.cancel().catch(()=>{})}}function jo(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 zo(e){return e.endsWith("\r")?e.slice(0,-1):e}async function si(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 jr,useEffect as ai,useMemo as zr,useSyncExternalStore as ii}from"react";function qr(e={}){let{compute:n,connect:t}=D(),{value:r,onChange:o,defaultValue:s,remember:a=!0,user:l}=e,i=r!==void 0,c=a&&!i?sr(t.publishableKey,l):null,u=jr(k=>Sr(c,k),[c]),p=ii(u,jr(()=>Nt(c),[c]),Pr),f=zr(()=>wr(n.machines),[n.machines]),g=zr(()=>Zn(f),[f]);ai(()=>{i||!s||Mr(c,s)},[i,s,c]);let m=i?r:p??s??null,{selected:y,unavailable:R}=zr(()=>Cr(f,m??null),[f,m]),S=jr(k=>{i||Er(c,k),o?.(k)},[i,c,o]);return{options:f,groups:g,selected:y,select:S,run:vr(y),unavailable:R,pickable:Xn(f),loading:n.loading&&!n.machines.length}}import{jsx as qo}from"react/jsx-runtime";function li({caption:e,disabled:n,className:t,...r}){let{theme:o}=B(),{options:s,selected:a,select:l,pickable:i}=qr(r);return i?qo("span",{className:"soba-connect sc-inline","data-theme":o,children:qo(kr,{options:s,selected:a,onPick:l,...e?{caption:e}:{},...n?{disabled:n}:{},...t?{className:t}:{}})}):null}import{useEffect as ci}from"react";var Zo="data-soba-react",Xo=!1;function ot(){if(Xo||typeof document>"u"||(Xo=!0,document.querySelector(`style[${Zo}]`)))return;let e=document.createElement("style");e.setAttribute(Zo,""),e.textContent=`.soba-connect {
|
|
6
6
|
--sc-ground: #ffffff;
|
|
7
7
|
--sc-sheet: #ffffff;
|
|
8
8
|
--sc-raised: #f6f6f7;
|
|
@@ -48,9 +48,6 @@ import{useRef as ls,useState as cs}from"react";var In=class extends Error{status
|
|
|
48
48
|
|
|
49
49
|
box-sizing: border-box;
|
|
50
50
|
|
|
51
|
-
width: 100%;
|
|
52
|
-
max-width: 560px;
|
|
53
|
-
margin: 0 auto;
|
|
54
51
|
color: var(--sc-text, #1a1a1c);
|
|
55
52
|
font-family: var(
|
|
56
53
|
--sc-font,
|
|
@@ -66,6 +63,12 @@ import{useRef as ls,useState as cs}from"react";var In=class extends Error{status
|
|
|
66
63
|
line-height: 1.5;
|
|
67
64
|
letter-spacing: -0.005em;
|
|
68
65
|
}
|
|
66
|
+
|
|
67
|
+
:where(.soba-connect) {
|
|
68
|
+
width: 100%;
|
|
69
|
+
max-width: 560px;
|
|
70
|
+
margin: 0 auto;
|
|
71
|
+
}
|
|
69
72
|
.soba-connect *,
|
|
70
73
|
.soba-connect *::before,
|
|
71
74
|
.soba-connect *::after {
|
|
@@ -472,6 +475,12 @@ a.sc-btn {
|
|
|
472
475
|
font-variant-numeric: tabular-nums;
|
|
473
476
|
}
|
|
474
477
|
|
|
478
|
+
.sc-rstop {
|
|
479
|
+
align-self: center;
|
|
480
|
+
width: 24px;
|
|
481
|
+
height: 24px;
|
|
482
|
+
}
|
|
483
|
+
|
|
475
484
|
.sc-rstep {
|
|
476
485
|
display: -webkit-box;
|
|
477
486
|
overflow: hidden;
|
|
@@ -501,6 +510,28 @@ a.sc-btn {
|
|
|
501
510
|
background: var(--sc-tray-sunk, #f6f6f7);
|
|
502
511
|
}
|
|
503
512
|
|
|
513
|
+
.sc-runtime-logo {
|
|
514
|
+
width: 15px;
|
|
515
|
+
height: 15px;
|
|
516
|
+
border-radius: 3px;
|
|
517
|
+
object-fit: contain;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.sc-runtime-letter {
|
|
521
|
+
font-size: 10px;
|
|
522
|
+
font-weight: 600;
|
|
523
|
+
line-height: 1;
|
|
524
|
+
color: var(--sc-muted, #6b6b73);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.sc-runs-logo {
|
|
528
|
+
flex: none;
|
|
529
|
+
width: 14px;
|
|
530
|
+
height: 14px;
|
|
531
|
+
border-radius: 3px;
|
|
532
|
+
object-fit: contain;
|
|
533
|
+
}
|
|
534
|
+
|
|
504
535
|
.sc-runtime-mark {
|
|
505
536
|
width: 13px;
|
|
506
537
|
height: 13px;
|
|
@@ -666,7 +697,9 @@ a.sc-btn {
|
|
|
666
697
|
background: transparent;
|
|
667
698
|
font-family: inherit;
|
|
668
699
|
cursor: pointer;
|
|
669
|
-
transition:
|
|
700
|
+
transition:
|
|
701
|
+
background-color 120ms ease,
|
|
702
|
+
color 120ms ease;
|
|
670
703
|
}
|
|
671
704
|
|
|
672
705
|
.sc-runs-btn:hover:not(:disabled),
|
|
@@ -722,7 +755,9 @@ a.sc-btn {
|
|
|
722
755
|
border: 1px solid var(--sc-line, #e9e9eb);
|
|
723
756
|
border-radius: 12px;
|
|
724
757
|
background: var(--sc-tray-card, #ffffff);
|
|
725
|
-
box-shadow:
|
|
758
|
+
box-shadow:
|
|
759
|
+
0 10px 30px rgba(0, 0, 0, 0.12),
|
|
760
|
+
0 2px 6px rgba(0, 0, 0, 0.06);
|
|
726
761
|
color: var(--sc-text, #1a1a1c);
|
|
727
762
|
|
|
728
763
|
max-height: 60vh;
|
|
@@ -830,7 +865,9 @@ a.sc-btn {
|
|
|
830
865
|
font-weight: 500;
|
|
831
866
|
color: var(--sc-text-2, #3f3f46);
|
|
832
867
|
cursor: pointer;
|
|
833
|
-
transition:
|
|
868
|
+
transition:
|
|
869
|
+
background-color 120ms ease,
|
|
870
|
+
color 120ms ease;
|
|
834
871
|
}
|
|
835
872
|
|
|
836
873
|
.sc-mp-btn:hover:not(:disabled),
|
|
@@ -1932,8 +1969,9 @@ a.sc-btn {
|
|
|
1932
1969
|
border-radius: var(--sc-r-pill, 999px);
|
|
1933
1970
|
border-color: var(--sc-line, #e9e9eb);
|
|
1934
1971
|
|
|
1935
|
-
|
|
1936
|
-
|
|
1972
|
+
|
|
1973
|
+
box-shadow: var(--sc-shadow-1, 0 1px 2px rgb(0 0 0 / 5%));
|
|
1974
|
+
font-size: var(--sc-fs-small, 12.5px);
|
|
1937
1975
|
font-weight: 500;
|
|
1938
1976
|
|
|
1939
1977
|
letter-spacing: -0.005em;
|
|
@@ -3007,7 +3045,7 @@ li.sc-plan-row.sc-plan-current {
|
|
|
3007
3045
|
.sc-opt-has-warn {
|
|
3008
3046
|
color: var(--sc-warn, #b06f14);
|
|
3009
3047
|
}
|
|
3010
|
-
`,document.head.appendChild(e)}import{jsx as Ie,jsxs as st}from"react/jsx-runtime";function Ho(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 Ka(){return st("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 Va({error:e,onRetry:n,onDismiss:t,title:r,className:o}){let s=Ho(e),a=H();return za(()=>ot(),[]),s?Ie("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":a.theme,role:"alert",children:st("div",{className:"sc-card sc-limit sc-run-error",children:[st("div",{className:"sc-limit-head",children:[Ie("span",{className:"sc-limit-mark sc-run-error-mark","aria-hidden":"true",children:Ie(Ka,{})}),st("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)&&st("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 ja,useState as Uo}from"react";import{jsx as Z,jsxs as _t}from"react/jsx-runtime";function Ya({reason:e}){return Z("span",{className:"sc-limit-mark","aria-hidden":"true",children:e==="no_compute"?Z(ft,{}):Z(j,{})})}function Za(e){let{error:n,variant:t="card",onDismiss:r,className:o}=e,s=Lr(n,{predict:e.predict??!("error"in e)}),a=ja(),c=H();if(!s)return null;let i=Z(Ja,{offer:s,headingId:a,onDismiss:r});return t==="dialog"?Z(Vn,{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 Ja({offer:e,headingId:n,onDismiss:t}){let{compute:r}=D(),[o,s]=Uo(!1),[a,c]=Uo(null),i=e.reason==="no_compute"&&r.connected&&!r.online,l=i||e.connectOffer!==null||!r.connected,u=rt();async function p(){s(!0),c(null);try{await e.upgrade()}catch(y){c(y.message)}finally{s(!1)}}return _t("div",{className:"sc-card sc-limit",children:[_t("div",{className:"sc-limit-head",children:[Z(Ya,{reason:e.reason}),_t("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}),_t("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 Qa}from"react";function at(){let{plan:e,compute:n,connect:t}=D();return Qa(()=>{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=ni(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:Xa(r,c||l,n.connected,()=>t.open("manual")),summary:ei({plan:r,assignment:o,used:p,ceiling:i,trialDaysLeft:a,raised:c,uncounted:l,state:w})}},[e,n.connected,t])}function Xa(e,n,t,r){let o=He({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:Ue(e.connected_reward)&&!t,open:r}:xe(e.route_allow)&&!t?{line:"Nothing connected yet, so nothing can run.",inForce:!1,required:!0,connected:t,actionable:!0,open:r}:null}function ei(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 ${Wo(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 ${Wo(t.period_end)}.`:"";return`${p.toLocaleString()} of ${(o??0).toLocaleString()} ${n.unit}s left.${y}${u}`}function ni(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 Wo(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}import{Fragment as ri,jsx as J,jsxs as Se}from"react/jsx-runtime";function Br({heading:e="Current plan",showUsage:n=!0,showName:t=!0,className:r}){let o=at(),{theme:s}=H(),a=y=>J("section",{className:r?`soba-connect sc-fill ${r}`:"soba-connect sc-fill","data-theme":s,children:Se("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(Se("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(Se(ri,{children:[Se("div",{className:"sc-current-grid",children:[(t||i!==null)&&Se("div",{className:"sc-current-main",children:[t?Se("p",{className:"sc-current-name",children:[c.name,i!==null&&Se("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})]}):i!==null&&J("p",{className:"sc-current-trial",children:Se("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})}),t&&c.description&&J("p",{className:"sc-sub",children:c.description})]}),n&&Se("div",{className:"sc-usage",children:[Se("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&&Se("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: ${ti(p.line)}.`:p.line}),(p.actionable||p.connected)&&J(fn,{})]})]}))}var ti=e=>e.charAt(0).toLowerCase()+e.slice(1);import{useCallback as oi,useMemo as si,useState as Bo}from"react";var ai={"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 qr(e={}){let{plan:n,compute:t,connect:r}=D(),[o,s]=Bo(null),[a,c]=Bo(null),{featured:i,onSelect:l,successUrl:u,cancelUrl:p}=e,y=oi(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=si(()=>n.plans.map(m=>{let w=n.current?.plan_id===m.id;return{plan:m,current:w,featured:i===m.id&&!w,price:li(m),allowance:m.included_units===null?`Unlimited ${m.unit}s`:`${m.included_units.toLocaleString()} ${m.unit}${m.included_units===1?"":"s"}`,allowanceNote:ci(m),computeLabel:m.route_allow===null?"any compute":m.route_allow.length===0?"no compute":null,compute:(m.route_allow??[]).map(P=>({costClass:P,label:ai[P]??P,owned:ii.has(P),runtimes:qt(P).map(R=>R.id)})),connect:ui(m,w,t.connected,()=>r.open("manual")),cta:{label:di(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 li(e){return e.price===0?{amount:"Free",interval:null,free:!0}:{amount:`$${e.price.toLocaleString()}`,interval:e.interval,free:!1}}function ci(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 ui(e,n,t,r){let o=He({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6}),s=xe(e.route_allow)&&!t;if(!o&&!s)return null;let a=Ue(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 di(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 g,jsxs as A}from"react/jsx-runtime";function Et(e){return e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill"}function Fr({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}=qr({...a?{featured:a}:{},...e?{onSelect:e}:{},...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),{theme:y}=H();if(u)return g("div",{className:Et(c),"data-theme":y,children:g("div",{className:"sc-card",children:g("p",{className:"sc-error",children:u.message})})});if(l)return g("div",{className:Et(c),"data-theme":y,children:g("div",{className:"sc-card",children:g("p",{className:"sc-note",children:"Loading plans\u2026"})})});if(i.length===0)return g("div",{className:Et(c),"data-theme":y,children:g("div",{className:"sc-card",children:g("p",{className:"sc-note",children:"This app has no plans yet."})})});let f={showCompute:r,showConnect:o};return A("div",{className:Et(c),"data-theme":y,"data-variant":s,children:[s==="rows"?g(mi,{offers:i,shelf:f}):s==="table"?g(fi,{offers:i,shelf:f}):g(pi,{offers:i,shelf:f}),p&&g("p",{className:"sc-error",children:p})]})}function pi({offers:e,shelf:n}){return g("div",{className:"sc-plans",children:e.map(t=>A("div",{className:qo("sc-plan",t),children:[A("div",{className:"sc-row-between",children:[g("span",{className:"sc-title",children:t.plan.name}),g(Gr,{offer:t})]}),g("p",{className:"sc-sub",children:t.plan.description}),g(zr,{price:t.price,free:"forever"}),g(jr,{offer:t,shelf:n}),g(Fo,{offer:t}),g("div",{className:"sc-plan-band",children:n.showCompute&&g(Vr,{offer:t})}),g("div",{className:"sc-plan-band",children:g(Kr,{offer:t})})]},t.plan.id))})}function mi({offers:e,shelf:n}){return g("ul",{className:"sc-plan-rows",children:e.map(t=>A("li",{className:qo("sc-plan-row",t),children:[A("div",{className:"sc-row-main",children:[A("span",{className:"sc-row-name",children:[g("span",{className:"sc-title",children:t.plan.name}),g(Gr,{offer:t})]}),t.plan.description&&g("p",{className:"sc-sub",children:t.plan.description}),g(Fo,{offer:t}),n.showCompute&&g(Vr,{offer:t,inline:!0}),g(Kr,{offer:t,inline:!0})]}),A("div",{className:"sc-row-side",children:[g(zr,{price:t.price,free:"forever",small:!0}),g(jr,{offer:t,shelf:n})]})]},t.plan.id))})}function fi({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 g("div",{className:"sc-table-scroll",children:A("table",{className:"sc-plan-table",children:[g("thead",{children:A("tr",{children:[g("td",{}),e.map(a=>A("th",{scope:"col",className:s(a),children:[A("span",{className:"sc-row-name",children:[g("span",{className:"sc-title",children:a.plan.name}),g(Gr,{offer:a})]}),g(zr,{price:a.price,small:!0})]},a.plan.id))]})}),A("tbody",{children:[A("tr",{children:[g("th",{scope:"row",children:"Included"}),e.map(a=>g("td",{className:s(a),children:a.allowance},a.plan.id))]}),t&&A("tr",{children:[g("th",{scope:"row",children:"Then"}),e.map(a=>g("td",{className:s(a),children:a.plan.overage_per_unit>0?`$${a.plan.overage_per_unit} / ${a.plan.unit}`:g("span",{className:"sc-muted-cell",children:"Stops"})},a.plan.id))]}),r&&A("tr",{children:[g("th",{scope:"row",children:"Trial"}),e.map(a=>g("td",{className:s(a),children:a.plan.trial_days>0?`${a.plan.trial_days} days`:g("span",{className:"sc-muted-cell",children:"None"})},a.plan.id))]}),n.showCompute&&A("tr",{children:[g("th",{scope:"row",children:"Runs on"}),e.map(a=>g("td",{className:s(a),children:g(Vr,{offer:a,bare:!0})},a.plan.id))]}),o&&A("tr",{children:[g("th",{scope:"row",children:"Connect your own"}),e.map(a=>g("td",{className:s(a),children:g(Kr,{offer:a,bare:!0})},a.plan.id))]}),A("tr",{className:"sc-table-buy",children:[g("td",{}),e.map(a=>g("td",{className:s(a),children:g(jr,{offer:a,shelf:n})},a.plan.id))]})]})]})})}function qo(e,n){return[e,n.current?"sc-plan-current":"",n.featured?"sc-plan-featured":""].filter(Boolean).join(" ")}function Gr({offer:e}){return e.current?g("span",{className:"sc-plan-badge",children:"Current"}):e.featured?g("span",{className:"sc-plan-badge-soft",children:"Recommended"}):null}function zr({price:e,small:n,free:t}){return A("p",{className:n?"sc-plan-price sc-plan-price-sm":"sc-plan-price",children:[g("span",{className:"sc-plan-amount",children:e.amount}),e.interval?A("span",{className:"sc-plan-interval",children:["/",e.interval]}):t&&g("span",{className:"sc-plan-interval sc-plan-after",children:t})]})}function Fo({offer:e}){return A("p",{className:"sc-plan-allowance",children:[g("span",{className:"sc-plan-figure",children:e.allowance}),g("span",{className:"sc-plan-qualifier",children:e.allowanceNote})]})}function Kr({offer:e,inline:n,bare:t}){let r=e.connect;if(!r)return t?g("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:[g("span",{className:"sc-reward-said",children:r.line}),A("span",{className:"sc-reward-do","aria-hidden":!0,children:[g(j,{className:"sc-reward-mark"}),"Connect compute"]})]}):g("p",{className:o,children:r.line});return t?s:g("div",{className:n?"sc-plan-reward sc-plan-reward-inline":"sc-plan-reward",children:s})}function Vr({offer:e,inline:n,bare:t}){let r=e.computeLabel?g("ul",{className:n?"sc-compute sc-compute-inline":"sc-compute",children:g("li",{children:e.computeLabel})}):g("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,g(hi,{runtimes:o.runtimes})]},o.costClass))});return t?r:A("div",{className:n?"sc-plan-compute sc-plan-compute-inline":"sc-plan-compute",children:[g("span",{className:"sc-fact-key",children:"Runs on"}),r]})}function jr({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:[g(j,{className:"sc-btn-mark"}),"Connect compute"]}):g("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 hi({runtimes:e}){return e.length===0?null:g("span",{className:"sc-compute-marks",children:e.map(n=>{let t=ze[n];return t?g(t,{className:"sc-rt-mark"},n):null})})}import{jsx as Yr,jsxs as Go}from"react/jsx-runtime";function gi({heading:e,plansHeading:n,showUsage:t=!0,showName:r=!0,className:o,...s}){let{plan:a,loading:c}=at(),{theme:i}=H(),l=n??(c?"Plans":a?"Change plan":"Choose a plan");return Go("div",{className:o?`soba-connect sc-fill sc-billing ${o}`:"soba-connect sc-fill sc-billing","data-theme":i,children:[Yr(Br,{...e===void 0?{}:{heading:e},showUsage:t,showName:r}),Go("section",{className:"sc-billing-plans",children:[l&&Yr("h2",{className:"sc-section-title",children:l}),Yr(Fr,{...s})]})]})}import{useCallback as zo,useState as Ko}from"react";function Zr({plan:e,successUrl:n,cancelUrl:t,label:r}){let{plan:o}=D(),[s,a]=Ko(!1),[c,i]=Ko(null),l=zo(()=>o.checkout(e.id,{...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),[o,e.id,n,t]),u=zo(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 Vo,jsxs as yi}from"react/jsx-runtime";function bi({plan:e,successUrl:n,cancelUrl:t,label:r,className:o}){let{theme:s}=H(),a=Zr({plan:e,...n?{successUrl:n}:{},...t?{cancelUrl:t}:{},...r?{label:r}:{}});return yi("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":s,children:[Vo("button",{type:"button",className:"sc-btn sc-btn-primary",disabled:a.busy,onClick:()=>void a.buy(),children:a.label}),a.error&&Vo("p",{className:"sc-error",children:a.error})]})}import{useCallback as Te,useEffect as Je,useMemo as En,useRef as Qe,useState as Q}from"react";var wi="soba.session:";function jo(e){return!e.cacheKey||!e.endpoint?null:wi+JSON.stringify([e.endpoint,e.user??null,e.cacheKey])}function vi(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 ki(e,n){try{n?globalThis.localStorage?.setItem(e,JSON.stringify(n)):globalThis.localStorage?.removeItem(e)}catch{}}var Yo=6e4,Ci=1e4,Ot=class{#e;#n=null;#r=null;#t;#o=new Set;constructor(n){this.#t=n,this.#e=n.token??null;let t=jo(n),r=t&&!this.#e?vi(t):null;r&&r.expiresAt-Yo>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()+Ci,this.#n-Yo)}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=jo(this.#t);c&&ki(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}}},_n=new Map,Zo=new WeakMap,Ni=1;function xi(e){if(e.token||!e.endpoint)return null;let n=0;return e.fetchImpl&&(n=Zo.get(e.fetchImpl)??Ni++,Zo.set(e.fetchImpl,n)),JSON.stringify([e.endpoint,e.user??null,n,e.cacheKey??null])}function Jo(e){let n=xi(e);if(!n)return new Ot(e);let t=_n.get(n)??{holder:new Ot(e),users:0};return _n.set(n,t),t.holder}function Qo(e){for(let n of _n.values())n.holder===e&&n.users++}function Xo(e){for(let[n,t]of _n)if(t.holder===e){setTimeout(()=>{--t.users<=0&&_n.get(n)===t&&_n.delete(n)},0);return}}function es(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,Si(r,s))}}function Si(e,n){let t=new Headers(e?.headers);return t.set("authorization",`Bearer ${n}`),{...e,headers:t}}import{jsx as Jr,jsxs as _i}from"react/jsx-runtime";var Mi="https://www.soba.so",Pi=3e4;function Ri(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=Mi,pollMs:f=Pi,injectStyles:m=!0,modal:w=!0,fetchImpl:P,onError:R}=e,[_,M]=Q(t??null),[B,I]=Q(null),[N,F]=Q(l),[T,se]=Q(null),[X,ve]=Q(l===null),[K,ae]=Q(i??[]),[We,Y]=Q(null),[Me,Xe]=Q(i===void 0),[de,pe]=Q(u??[]),[ee,gn]=Q(p),[en,Le]=Q(null),[nn,me]=Q(u===void 0),[ne,Be]=Q(null),[Pe,Ae]=Q(!1),qe=Qe(R);qe.current=R;let ie=Te(k=>{I(k),qe.current?.(k)},[]);Je(()=>{m&&ot()},[m]);let E=En(()=>Jo({...t?{token:t}:{},...r?{endpoint:r}:{},...o?{user:o}:{},...P?{fetchImpl:P}:{},...s?{cacheKey:s}:{}}),[t,r,o,P,s]);Je(()=>{let k=!0;Qo(E);let z=E.subscribe(()=>{k&&M(E.token)});return!E.token&&!E.canRefresh?ie(new Error("<SobaProvider> needs a `session` or a `sessionEndpoint`. A browser cannot mint one: that takes your secret key.")):E.ensure().then(()=>k&&M(E.token),le=>k&&ie(le)),()=>{k=!1,z(),Xo(E)}},[E,ie]),Je(()=>{B&&(ve(!1),Xe(!1),me(!1),se(k=>k??B),Y(k=>k??B),Le(k=>k??B))},[B]),Je(()=>{let k=E.refreshAt;if(k===null)return;let z=()=>{E.refresh().catch(ge=>ie(ge))},le=()=>{document.hidden||(document.removeEventListener("visibilitychange",le),z())},dt=setTimeout(()=>{typeof document<"u"&&document.hidden?document.addEventListener("visibilitychange",le):z()},Math.max(0,k-Date.now()));return()=>{clearTimeout(dt),typeof document<"u"&&document.removeEventListener("visibilitychange",le)}},[E,ie,_]);let bn=Qe(l?.machines_url??null),v=En(()=>{if(!_)return null;let k=new Tn({session:_,baseUrl:y,fetchImpl:es(E,P??fetch.bind(globalThis))});return k.setMachinesUrl(bn.current),k},[_,y,E,P]),G=Qe(l!==null);Je(()=>{if(!v||G.current)return;let k=!0;return ve(!0),v.context().then(z=>{k&&(F(z),se(null),ve(!1))},z=>{k&&(se(z),ve(!1))}),()=>{k=!1}},[v]);let te=Te(async()=>{if(v)try{let k=await v.machines();ae(Array.isArray(k)?k:[]),Y(null)}catch(k){Y(k)}finally{Xe(!1)}},[v]),fe=Te(async()=>{if(v)try{let k=await v.plans();pe(k.plans),gn(k.current),Le(null)}catch(k){Le(k)}finally{me(!1)}},[v]),re=Qe(!1),[Fe,yn]=Q(!1),wn=Qe(u!==void 0),tn=Qe(!1),rn=Te(()=>{re.current||(re.current=!0,tn.current&&queueMicrotask(()=>{tn.current&&yn(!0)}))},[]);Je(()=>(tn.current=!0,re.current&&yn(!0),()=>{tn.current=!1}),[]),Je(()=>{!v||!Fe||wn.current||fe()},[v,Fe,fe]);let on=Te(async k=>{if(!v)throw new Error("No session yet.");await v.selectPlan(k),await fe()},[v,fe]),It=Te(async(k,z)=>{if(!v)throw new Error("No session yet.");let le=await v.checkoutPlan(k,z);if(!le.url)throw new Error("Checkout could not be started.");return le.url},[v]),it=Te(async()=>{if(!v)throw new Error("No session yet.");await v.leavePlan(),await fe()},[v,fe]),lt=Qe(i!==void 0);Je(()=>{if(!v)return;let k=Oe(te,f,{immediate:!lt.current});return lt.current=!1,k},[v,te,f]);let vn=Te((k="manual")=>{w&&(Ae(!0),Be(k))},[w]),ct=Te(()=>Be(null),[]),q=Qe(K);q.current=K;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,...le}=k,ge=await(P??fetch.bind(globalThis))(a,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream"},credentials:"same-origin",body:JSON.stringify(le),...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 pt=q.current.length>0&&!q.current.some(Lt=>Lt.state!=="offline");throw ge.status===409&&pt&&vn("no_compute"),be}let ke=Dr(ge);return async function*(){try{yield*ke}finally{re.current&&fe()}}()},[a,P,fe,vn]),he=En(()=>ee?de.find(k=>k.id===ee.plan_id)??null:null,[de,ee]),sn=En(()=>he?he.connected_reward==="included"&&K.length>0&&he.connected_included_units!==null?he.connected_included_units:he.included_units:null,[he,K]),ut=En(()=>({plans:de,current:ee,plan:he,used:ee?.units_used??null,included:sn,remaining:sn!==null&&ee?Math.max(0,sn-ee.units_used):null,unlimited:he!==null&&sn===null,loading:nn,error:en,select:on,checkout:It,leave:it,refresh:fe}),[de,ee,he,sn,nn,en,on,It,it,fe]),Tt=En(()=>({session:_,client:v,error:B,get plan(){return rn(),ut},compute:{machines:K,connected:K.length>0,online:K.some(k=>k.state!=="offline"),loading:Me,error:We,refresh:te},connect:{app:N?.app??null,command:N?.command??null,connectUrl:N?.connect_url??null,publishableKey:N?.publishable_key??null,loading:X,error:T,open:vn,close:ct,isOpen:ne!==null,hasModal:w},run:Re}),[_,v,B,ut,rn,ne,vn,ct,w,K,Me,We,te,N,X,T,Re]);return Jr(Pr.Provider,{value:v,children:Jr(Rr.Provider,{value:{context:N,machines:Me?void 0:K,theme:c??N?.theme??"light"},children:_i(_r.Provider,{value:Tt,children:[n,w&&Pe&&Jr(et,{open:ne!==null,onOpenChange:k=>Be(k?ne??"manual":null),onConnected:()=>{te()},...ne==="payment_required"||ne==="no_compute"?{reason:ne}:{},...ne==="pair"?{showStatus:!1}:{}})]})})})}function Ei(e){return e?Oi[e]??e:null}var Oi={"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 Ii(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*Ti(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(`
|
|
3048
|
+
`,document.head.appendChild(e)}import{jsx as Oe,jsxs as st}from"react/jsx-runtime";function Ko(e){if(!e)return null;let n=pn(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 ui(){return st("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[Oe("path",{d:"M8 5v4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),Oe("circle",{cx:"8",cy:"11.6",r:"0.9",fill:"currentColor"}),Oe("circle",{cx:"8",cy:"8",r:"6.4",stroke:"currentColor",strokeWidth:"1.3"})]})}function di({error:e,onRetry:n,onDismiss:t,title:r,className:o}){let s=Ko(e),a=B();return ci(()=>ot(),[]),s?Oe("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":a.theme,role:"alert",children:st("div",{className:"sc-card sc-limit sc-run-error",children:[st("div",{className:"sc-limit-head",children:[Oe("span",{className:"sc-limit-mark sc-run-error-mark","aria-hidden":"true",children:Oe(ui,{})}),st("div",{children:[Oe("h2",{className:"sc-limit-title",children:r??"That run did not finish"}),Oe("p",{className:"sc-limit-body sc-run-error-message",children:s})]})]}),(t||n)&&st("div",{className:"sc-limit-actions",children:[t&&Oe("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,children:"Dismiss"}),n&&Oe("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:n,children:"Try again"})]})]})}):null}import{useId as pi,useState as _o}from"react";import{jsx as $,jsxs as Rt}from"react/jsx-runtime";function mi({reason:e}){return $("span",{className:"sc-limit-mark","aria-hidden":"true",children:e==="no_compute"?$(ht,{}):$(X,{})})}function hi(e){let{error:n,variant:t="card",onDismiss:r,className:o}=e,s=Qr(n,{predict:e.predict??!("error"in e)}),a=pi(),l=B();if(!s)return null;let i=$(gi,{offer:s,headingId:a,onDismiss:r});return t==="dialog"?$(qn,{open:!0,onClose:()=>r?.(),labelledBy:a,theme:l.theme,children:i}):$("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":l.theme,children:i})}function gi({offer:e,headingId:n,onDismiss:t}){let{compute:r}=D(),[o,s]=_o(!1),[a,l]=_o(null),i=e.reason==="no_compute"&&r.connected&&!r.online,c=i||e.connectOffer!==null||!r.connected,u=rt();async function p(){s(!0),l(null);try{await e.upgrade()}catch(f){l(f.message)}finally{s(!1)}}return Rt("div",{className:"sc-card sc-limit",children:[Rt("div",{className:"sc-limit-head",children:[$(mi,{reason:e.reason}),Rt("div",{children:[$("h2",{className:"sc-limit-title",id:n,children:e.title}),$("p",{className:"sc-limit-body",children:e.body})]})]}),a&&$("p",{className:"sc-error",children:a}),i&&u.note&&$("p",{className:"sc-limit-note",children:u.note}),Rt("div",{className:"sc-limit-actions",children:[t&&$("button",{type:"button",className:"sc-btn sc-btn-quiet",onClick:t,disabled:o,children:"Not now"}),e.upgradeTo&&$("button",{type:"button",className:c?"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}`}),c&&$("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&&$("button",{type:"button",className:"sc-btn sc-btn-primary",onClick:u.open,disabled:o,children:"Open Soba App"})]})]})}import{useMemo as fi}from"react";function at(){let{plan:e,compute:n,connect:t}=D();return fi(()=>{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=yi(o?.trial_ends_at??null),l=r.connected_reward==="included"&&n.connected&&r.connected_included_units!==null,i=l?r.connected_included_units:r.included_units,c=r.connected_reward==="unlimited"&&n.connected,u=i===null,p=e.used??0,f=i===null?null:Math.max(0,i-p),g=i&&i>0?Math.min(100,Math.round(p/i*100)):null,m=i!==null&&p>=i,y=a!==null?"trial":u?"unlimited":m?r.overage==="meter"?"metered":"spent":"within";return{...s,state:y,trialDaysLeft:a,ceiling:i,raised:l,uncounted:c,used:p,remaining:f,percent:g,unlimited:u,reward:Ai(r,l||c,n.connected,()=>t.open("manual")),summary:bi({plan:r,assignment:o,used:p,ceiling:i,trialDaysLeft:a,raised:l,uncounted:c,state:y})}},[e,n.connected,t])}function Ai(e,n,t,r){let o=We({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}:xe(e.route_allow)&&!t?{line:"Nothing connected yet, so nothing can run.",inForce:!1,required:!0,connected:t,actionable:!0,open:r}:null}function bi(e){let{plan:n,assignment:t,used:r,ceiling:o,trialDaysLeft:s,raised:a,uncounted:l,state:i}=e,c=`${n.unit}${r===1?"":"s"}`,u=l?" Runs your own AI serves do not count toward it.":"";if(i==="trial"&&s!==null){let g=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 ${g}.`}if(i==="unlimited")return`${r.toLocaleString()} ${c} 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 ${$o(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),f=a?` Raised from ${(n.included_units??0).toLocaleString()} while your own AI is connected.`:t?.period_end?` Resets ${$o(t.period_end)}.`:"";return`${p.toLocaleString()} of ${(o??0).toLocaleString()} ${n.unit}s left.${f}${u}`}function yi(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 $o(e){let n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:"numeric",month:"long"})}import{Fragment as Ci,jsx as ee,jsxs as Re}from"react/jsx-runtime";function Zr({heading:e="Current plan",showUsage:n=!0,showName:t=!0,className:r}){let o=at(),{theme:s}=B(),a=f=>ee("section",{className:r?`soba-connect sc-fill ${r}`:"soba-connect sc-fill","data-theme":s,children:Re("div",{className:"sc-card sc-current",children:[e&&ee("h2",{className:"sc-section-title",children:e}),f]})});if(o.error)return a(ee("p",{className:"sc-error",children:o.error.message}));if(o.loading)return a(ee("p",{className:"sc-note",children:"Loading\u2026"}));if(!o.plan)return a(Re("div",{className:"sc-current-main",children:[ee("p",{className:"sc-current-name",children:"No plan"}),ee("p",{className:"sc-sub",children:o.summary})]}));let{plan:l,trialDaysLeft:i,percent:c,unlimited:u,reward:p}=o;return a(Re(Ci,{children:[Re("div",{className:"sc-current-grid",children:[(t||i!==null)&&Re("div",{className:"sc-current-main",children:[t?Re("p",{className:"sc-current-name",children:[l.name,i!==null&&Re("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})]}):i!==null&&ee("p",{className:"sc-current-trial",children:Re("span",{className:"sc-trial-badge",children:[i," ",i===1?"day":"days"," left"]})}),t&&l.description&&ee("p",{className:"sc-sub",children:l.description})]}),n&&Re("div",{className:"sc-usage",children:[Re("div",{className:"sc-row-between",children:[ee("span",{className:"sc-fact-key",children:"Usage"}),ee("span",{className:c!==null&&c>=100?"sc-usage-figure sc-usage-over":"sc-usage-figure",children:u?"Unlimited":c===null?"Metered":`${c}% used`})]}),c!==null&&ee("div",{className:"sc-meter",role:"presentation",children:c>0&&ee("span",{className:c>=100?"sc-meter-fill sc-meter-full":"sc-meter-fill",style:{width:`${c}%`}})}),ee("p",{className:"sc-usage-line",children:o.summary})]})]}),p&&Re("div",{className:"sc-current-foot",children:[ee("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: ${wi(p.line)}.`:p.line}),(p.actionable||p.connected)&&ee(dn,{})]})]}))}var wi=e=>e.charAt(0).toLowerCase()+e.slice(1);import{useCallback as vi,useMemo as ki,useState as es}from"react";var Ni={"user-hardware":"your own machine","user-subscription":"your own AI subscription","open-weights":"open models we host",frontier:"frontier models"},xi=new Set(["user-hardware","user-subscription"]);function Xr(e={}){let{plan:n,compute:t,connect:r}=D(),[o,s]=es(null),[a,l]=es(null),{featured:i,onSelect:c,successUrl:u,cancelUrl:p}=e,f=vi(async m=>{s(m.id),l(null);try{if(m.selectable)await n.select(m.id);else if(c)c(m);else{let y=await n.checkout(m.id,{...u?{successUrl:u}:{},...p?{cancelUrl:p}:{}});window.location.assign(y);return}}catch(y){throw l(y.message),y}finally{(m.selectable||c)&&s(null)}},[n,c,u,p]),g=ki(()=>n.plans.map(m=>{let y=n.current?.plan_id===m.id;return{plan:m,current:y,featured:i===m.id&&!y,price:Ri(m),allowance:m.included_units===null?`Unlimited ${m.unit}s`:`${m.included_units.toLocaleString()} ${m.unit}${m.included_units===1?"":"s"}`,allowanceNote:Si(m),computeLabel:m.route_allow===null?"any compute":m.route_allow.length===0?"no compute":null,compute:(m.route_allow??[]).map(R=>({costClass:R,label:Ni[R]??R,owned:xi.has(R),runtimes:Jt(R).map(S=>S.id)})),connect:Pi(m,y,t.connected,()=>r.open("manual")),cta:{label:Mi(m,y,o===m.id),disabled:y||o!==null,busy:o===m.id,take:()=>f(m)}}}),[n.plans,n.current,i,t.connected,r,o,f]);return{offers:g,current:g.find(m=>m.current)??null,loading:n.loading,error:n.error,failed:a}}function Ri(e){return e.price===0?{amount:"Free",interval:null,free:!0}:{amount:`$${e.price.toLocaleString()}`,interval:e.interval,free:!1}}function Si(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 Pi(e,n,t,r){let o=We({unit:e.unit,reward:e.connected_reward,includedUnits:e.connected_included_units,creditMicros:e.connected_credit*1e6}),s=xe(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 Mi(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 G}from"react/jsx-runtime";function St(e){return e?`soba-connect sc-fill ${e}`:"soba-connect sc-fill"}function Kr({onSelect:e,successUrl:n,cancelUrl:t,showCompute:r=!0,showConnect:o=!1,variant:s="cards",featured:a,className:l}){let{offers:i,loading:c,error:u,failed:p}=Xr({...a?{featured:a}:{},...e?{onSelect:e}:{},...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),{theme:f}=B();if(u)return b("div",{className:St(l),"data-theme":f,children:b("div",{className:"sc-card",children:b("p",{className:"sc-error",children:u.message})})});if(c)return b("div",{className:St(l),"data-theme":f,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"Loading plans\u2026"})})});if(i.length===0)return b("div",{className:St(l),"data-theme":f,children:b("div",{className:"sc-card",children:b("p",{className:"sc-note",children:"This app has no plans yet."})})});let g={showCompute:r,showConnect:o};return G("div",{className:St(l),"data-theme":f,"data-variant":s,children:[s==="rows"?b(Ii,{offers:i,shelf:g}):s==="table"?b(Oi,{offers:i,shelf:g}):b(Ei,{offers:i,shelf:g}),p&&b("p",{className:"sc-error",children:p})]})}function Ei({offers:e,shelf:n}){return b("div",{className:"sc-plans",children:e.map(t=>G("div",{className:ns("sc-plan",t),children:[G("div",{className:"sc-row-between",children:[b("span",{className:"sc-title",children:t.plan.name}),b(_r,{offer:t})]}),b("p",{className:"sc-sub",children:t.plan.description}),b($r,{price:t.price,free:"forever"}),b(to,{offer:t,shelf:n}),b(ts,{offer:t}),b("div",{className:"sc-plan-band",children:n.showCompute&&b(no,{offer:t})}),b("div",{className:"sc-plan-band",children:b(eo,{offer:t})})]},t.plan.id))})}function Ii({offers:e,shelf:n}){return b("ul",{className:"sc-plan-rows",children:e.map(t=>G("li",{className:ns("sc-plan-row",t),children:[G("div",{className:"sc-row-main",children:[G("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:t.plan.name}),b(_r,{offer:t})]}),t.plan.description&&b("p",{className:"sc-sub",children:t.plan.description}),b(ts,{offer:t}),n.showCompute&&b(no,{offer:t,inline:!0}),b(eo,{offer:t,inline:!0})]}),G("div",{className:"sc-row-side",children:[b($r,{price:t.price,free:"forever",small:!0}),b(to,{offer:t,shelf:n})]})]},t.plan.id))})}function Oi({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:G("table",{className:"sc-plan-table",children:[b("thead",{children:G("tr",{children:[b("td",{}),e.map(a=>G("th",{scope:"col",className:s(a),children:[G("span",{className:"sc-row-name",children:[b("span",{className:"sc-title",children:a.plan.name}),b(_r,{offer:a})]}),b($r,{price:a.price,small:!0})]},a.plan.id))]})}),G("tbody",{children:[G("tr",{children:[b("th",{scope:"row",children:"Included"}),e.map(a=>b("td",{className:s(a),children:a.allowance},a.plan.id))]}),t&&G("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&&G("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&&G("tr",{children:[b("th",{scope:"row",children:"Runs on"}),e.map(a=>b("td",{className:s(a),children:b(no,{offer:a,bare:!0})},a.plan.id))]}),o&&G("tr",{children:[b("th",{scope:"row",children:"Connect your own"}),e.map(a=>b("td",{className:s(a),children:b(eo,{offer:a,bare:!0})},a.plan.id))]}),G("tr",{className:"sc-table-buy",children:[b("td",{}),e.map(a=>b("td",{className:s(a),children:b(to,{offer:a,shelf:n})},a.plan.id))]})]})]})})}function ns(e,n){return[e,n.current?"sc-plan-current":"",n.featured?"sc-plan-featured":""].filter(Boolean).join(" ")}function _r({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 $r({price:e,small:n,free:t}){return G("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?G("span",{className:"sc-plan-interval",children:["/",e.interval]}):t&&b("span",{className:"sc-plan-interval sc-plan-after",children:t})]})}function ts({offer:e}){return G("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 eo({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?G("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}),G("span",{className:"sc-reward-do","aria-hidden":!0,children:[b(X,{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 no({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=>G("li",{className:o.owned?"sc-compute-own":void 0,children:[o.label,b(Li,{runtimes:o.runtimes})]},o.costClass))});return t?r:G("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 to({offer:e,shelf:n}){let t=e.connect;return n.showConnect&&t?.actionable?G("button",{type:"button",className:"sc-btn sc-btn-primary sc-btn-icon",onClick:t.open,children:[b(X,{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 Li({runtimes:e}){return e.length===0?null:b("span",{className:"sc-compute-marks",children:e.map(n=>{let t=Ye[n];return t?b(t,{className:"sc-rt-mark"},n):null})})}import{jsx as ro,jsxs as rs}from"react/jsx-runtime";function Ti({heading:e,plansHeading:n,showUsage:t=!0,showName:r=!0,className:o,...s}){let{plan:a,loading:l}=at(),{theme:i}=B(),c=n??(l?"Plans":a?"Change plan":"Choose a plan");return rs("div",{className:o?`soba-connect sc-fill sc-billing ${o}`:"soba-connect sc-fill sc-billing","data-theme":i,children:[ro(Zr,{...e===void 0?{}:{heading:e},showUsage:t,showName:r}),rs("section",{className:"sc-billing-plans",children:[c&&ro("h2",{className:"sc-section-title",children:c}),ro(Kr,{...s})]})]})}import{useCallback as os,useState as ss}from"react";function oo({plan:e,successUrl:n,cancelUrl:t,label:r}){let{plan:o}=D(),[s,a]=ss(!1),[l,i]=ss(null),c=os(()=>o.checkout(e.id,{...n?{successUrl:n}:{},...t?{cancelUrl:t}:{}}),[o,e.id,n,t]),u=os(async()=>{a(!0),i(null);try{window.location.assign(await c())}catch(p){i(p.message),a(!1)}},[c]);return{label:s?"Opening\u2026":r??`Subscribe for $${e.price.toLocaleString()}/${e.interval}`,busy:s,error:l,buy:u,session:c}}import{jsx as as,jsxs as Gi}from"react/jsx-runtime";function Bi({plan:e,successUrl:n,cancelUrl:t,label:r,className:o}){let{theme:s}=B(),a=oo({plan:e,...n?{successUrl:n}:{},...t?{cancelUrl:t}:{},...r?{label:r}:{}});return Gi("div",{className:o?`soba-connect ${o}`:"soba-connect","data-theme":s,children:[as("button",{type:"button",className:"sc-btn sc-btn-primary",disabled:a.busy,onClick:()=>void a.buy(),children:a.label}),a.error&&as("p",{className:"sc-error",children:a.error})]})}import{useCallback as Le,useEffect as Ze,useMemo as On,useRef as Xe,useState as ne}from"react";var Wi="soba.session:";function is(e){return!e.cacheKey||!e.endpoint?null:Wi+JSON.stringify([e.endpoint,e.user??null,e.cacheKey])}function Hi(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 Di(e,n){try{n?globalThis.localStorage?.setItem(e,JSON.stringify(n)):globalThis.localStorage?.removeItem(e)}catch{}}var ls=6e4,Ui=1e4,Pt=class{#e;#n=null;#r=null;#t;#o=new Set;constructor(n){this.#t=n,this.#e=n.token??null;let t=is(n),r=t&&!this.#e?Hi(t):null;r&&r.expiresAt-ls>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()+Ui,this.#n-ls)}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 l=is(this.#t);l&&Di(l,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}}},In=new Map,cs=new WeakMap,Fi=1;function Qi(e){if(e.token||!e.endpoint)return null;let n=0;return e.fetchImpl&&(n=cs.get(e.fetchImpl)??Fi++,cs.set(e.fetchImpl,n)),JSON.stringify([e.endpoint,e.user??null,n,e.cacheKey??null])}function us(e){let n=Qi(e);if(!n)return new Pt(e);let t=In.get(n)??{holder:new Pt(e),users:0};return In.set(n,t),t.holder}function ds(e){for(let n of In.values())n.holder===e&&n.users++}function ps(e){for(let[n,t]of In)if(t.holder===e){setTimeout(()=>{--t.users<=0&&In.get(n)===t&&In.delete(n)},0);return}}function ms(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,Ji(r,s))}}function Ji(e,n){let t=new Headers(e?.headers);return t.set("authorization",`Bearer ${n}`),{...e,headers:t}}import{jsx as so,jsxs as zi}from"react/jsx-runtime";var Vi="https://www.soba.so",Yi=3e4;function ji(e){let{children:n,session:t,sessionEndpoint:r,user:o,sessionCacheKey:s,runEndpoint:a,theme:l,initialMachines:i,initialConnect:c=null,initialPlans:u,initialCurrentPlan:p=null,baseUrl:f=Vi,pollMs:g=Yi,injectStyles:m=!0,modal:y=!0,fetchImpl:R,onError:S}=e,[k,W]=ne(t??null),[F,O]=ne(null),[P,Q]=ne(c),[T,K]=ne(null),[q,de]=ne(c===null),[V,M]=ne(i??[]),[De,Y]=ne(null),[pe,Ke]=ne(i===void 0),[Se,me]=ne(u??[]),[te,mn]=ne(p),[Ue,Fe]=ne(null),[ie,he]=ne(u===void 0),[re,Qe]=ne(null),[hn,Pe]=ne(!1),Te=Xe(S);Te.current=S;let oe=Le(C=>{O(C),Te.current?.(C)},[]);Ze(()=>{m&&ot()},[m]);let w=On(()=>us({...t?{token:t}:{},...r?{endpoint:r}:{},...o?{user:o}:{},...R?{fetchImpl:R}:{},...s?{cacheKey:s}:{}}),[t,r,o,R,s]);Ze(()=>{let C=!0;ds(w);let Z=w.subscribe(()=>{C&&W(w.token)});return!w.token&&!w.canRefresh?oe(new Error("<SobaProvider> needs a `session` or a `sessionEndpoint`. A browser cannot mint one: that takes your secret key.")):w.ensure().then(()=>C&&W(w.token),le=>C&&oe(le)),()=>{C=!1,Z(),ps(w)}},[w,oe]),Ze(()=>{F&&(de(!1),Ke(!1),he(!1),K(C=>C??F),Y(C=>C??F),Fe(C=>C??F))},[F]),Ze(()=>{let C=w.refreshAt;if(C===null)return;let Z=()=>{w.refresh().catch(Ae=>oe(Ae))},le=()=>{document.hidden||(document.removeEventListener("visibilitychange",le),Z())},dt=setTimeout(()=>{typeof document<"u"&&document.hidden?document.addEventListener("visibilitychange",le):Z()},Math.max(0,C-Date.now()));return()=>{clearTimeout(dt),typeof document<"u"&&document.removeEventListener("visibilitychange",le)}},[w,oe,k]);let j=Xe(c?.machines_url??null),E=On(()=>{if(!k)return null;let C=new Tn({session:k,baseUrl:f,fetchImpl:ms(w,R??fetch.bind(globalThis))});return C.setMachinesUrl(j.current),C},[k,f,w,R]),Mt=Xe(c!==null);Ze(()=>{if(!E||Mt.current)return;let C=!0;return de(!0),E.context().then(Z=>{C&&(Q(Z),K(null),de(!1))},Z=>{C&&(K(Z),de(!1))}),()=>{C=!1}},[E]);let Je=Le(async()=>{if(E)try{let C=await E.machines();M(Array.isArray(C)?C:[]),Y(null)}catch(C){Y(C)}finally{Ke(!1)}},[E]),ge=Le(async()=>{if(E)try{let C=await E.plans();me(C.plans),mn(C.current),Fe(null)}catch(C){Fe(C)}finally{he(!1)}},[E]),se=Xe(!1),[Ve,gn]=ne(!1),fn=Xe(u!==void 0),_e=Xe(!1),$e=Le(()=>{se.current||(se.current=!0,_e.current&&queueMicrotask(()=>{_e.current&&gn(!0)}))},[]);Ze(()=>(_e.current=!0,se.current&&gn(!0),()=>{_e.current=!1}),[]),Ze(()=>{!E||!Ve||fn.current||ge()},[E,Ve,ge]);let en=Le(async C=>{if(!E)throw new Error("No session yet.");await E.selectPlan(C),await ge()},[E,ge]),Et=Le(async(C,Z)=>{if(!E)throw new Error("No session yet.");let le=await E.checkoutPlan(C,Z);if(!le.url)throw new Error("Checkout could not be started.");return le.url},[E]),it=Le(async()=>{if(!E)throw new Error("No session yet.");await E.leavePlan(),await ge()},[E,ge]),lt=Xe(i!==void 0);Ze(()=>{if(!E)return;let C=Ce(Je,g,{immediate:!lt.current});return lt.current=!1,C},[E,Je,g]);let An=Le((C="manual")=>{y&&(Pe(!0),Qe(C))},[y]),ct=Le(()=>Qe(null),[]),z=Xe(V);z.current=V;let Me=Le(async C=>{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,...le}=C,Ae=await(R??fetch.bind(globalThis))(a,{method:"POST",headers:{"content-type":"application/json",accept:"text/event-stream"},credentials:"same-origin",body:JSON.stringify(le),...Z?{signal:Z}:{}});if(!Ae.ok){let Be=await Ae.json().catch(()=>null),be=new Error(Be?.error?.message??`${a} answered ${Ae.status}.`);be.status=Ae.status,Be?.error?.code&&(be.code=Be.error.code),Be?.error&&(be.error=Be.error);let pt=z.current.length>0&&!z.current.some(Ot=>Ot.state!=="offline");throw Ae.status===409&&pt&&An("no_compute"),be}let ve=Yr(Ae);return async function*(){try{yield*ve}finally{se.current&&ge()}}()},[a,R,ge,An]),fe=On(()=>te?Se.find(C=>C.id===te.plan_id)??null:null,[Se,te]),nn=On(()=>fe?fe.connected_reward==="included"&&V.length>0&&fe.connected_included_units!==null?fe.connected_included_units:fe.included_units:null,[fe,V]),ut=On(()=>({plans:Se,current:te,plan:fe,used:te?.units_used??null,included:nn,remaining:nn!==null&&te?Math.max(0,nn-te.units_used):null,unlimited:fe!==null&&nn===null,loading:ie,error:Ue,select:en,checkout:Et,leave:it,refresh:ge}),[Se,te,fe,nn,ie,Ue,en,Et,it,ge]),It=On(()=>({session:k,client:E,error:F,get plan(){return $e(),ut},compute:{machines:V,connected:V.length>0,online:V.some(C=>C.state!=="offline"),loading:pe,error:De,refresh:Je},connect:{app:P?.app??null,command:P?.command??null,connectUrl:P?.connect_url??null,publishableKey:P?.publishable_key??null,loading:q,error:T,open:An,close:ct,isOpen:re!==null,hasModal:y},run:Me}),[k,E,F,ut,$e,re,An,ct,y,V,pe,De,Je,P,q,T,Me]);return so(Or.Provider,{value:E,children:so(Lr.Provider,{value:{context:P,machines:pe?void 0:V,theme:l??P?.theme??"light"},children:zi(Tr.Provider,{value:It,children:[n,y&&hn&&so(nt,{open:re!==null,onOpenChange:C=>Qe(C?re??"manual":null),onConnected:()=>{Je()},...re==="payment_required"||re==="no_compute"?{reason:re}:{},...re==="pair"?{showStatus:!1}:{}})]})})})}function qi(e){return e?Zi[e]??e:null}var Zi={"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 Xi(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,l=()=>a.abort();n.signal?.addEventListener("abort",l);let i=setTimeout(()=>a.abort(),r.timeoutMs??3e3);try{let c=await t(s,{headers:{authorization:`Bearer ${r.session}`,accept:"text/event-stream"},signal:a.signal});return c.ok?{url:s,bearer:r.session,open:c}:null}catch{return null}finally{clearTimeout(i),n.signal?.removeEventListener("abort",l)}}async function*Ki(e){let n=e.body;if(!n)return;let t=n.getReader(),r=new TextDecoder,o="",s=null,a=[];try{for(;;){let l=await t.read();if(l.done)return;o+=r.decode(l.value,{stream:!0});for(let i=o.indexOf(`
|
|
3011
3049
|
`);i!==-1;i=o.indexOf(`
|
|
3012
|
-
`)){let
|
|
3013
|
-
`)}),s=null,a=[];else if(
|
|
3050
|
+
`)){let c=o.slice(0,i).replace(/\r$/,"");if(o=o.slice(i+1),c==="")a.length&&(yield{id:s,data:a.join(`
|
|
3051
|
+
`)}),s=null,a=[];else if(c.startsWith("id:")){let u=Number(c.slice(3).trim());s=Number.isFinite(u)?u:null}else if(c.startsWith("data:")){let u=c.slice(5);a.push(u.startsWith(" ")?u.slice(1):u)}}}}finally{t.cancel().catch(()=>{})}}var ao=(e,n)=>new Promise(t=>{let r=setTimeout(t,e);n?.addEventListener("abort",()=>{clearTimeout(r),t()})});async function*_i(e,n={}){let t=n.fetchImpl??fetch.bind(globalThis),r=await Xi(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 l;try{l=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 ao(1e3*a,n.signal);continue}if(l.status===503&&a<o){a++,await ao(Number(l.headers.get("retry-after")??3)*1e3,n.signal);continue}if(!l.ok){let i=`Could not read this run (${l.status}).`;try{let c=await l.json();c.error?.message&&(i=c.error.message)}catch{}throw new Error(i)}for await(let i of Ki(l)){i.id!==null&&(s=i.id),a=0;let c=En(i.data);if(c&&(yield c,c.type==="done"||c.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 ao(1e3*a,n.signal)}}export{Ma as ComputeStatus,dn as ConnectButton,Da as ConnectCompute,nt as ConnectModal,ei as ConnectNudge,Gr as ConnectPill,li as ModelPicker,di as RunError,hi as RunLimit,Ti as SobaBilling,Bi as SobaCheckout,Zr as SobaCurrentPlan,Kr as SobaPlans,ji as SobaProvider,si as collectText,Wr as connectSays,ot as injectStyles,En as parseEvent,Yr as readEvents,Ko as runErrorMessage,pn as sobaErrorCode,qi as tierLabel,oo as useCheckout,$n as useCompute,Ta as useConnectButton,Vr as useConnectNudge,at as useCurrentPlan,Hr as useMachineRuns,qr as useModel,rt as useOpenSobaConnect,Xr as usePlans,Qr as useRunLimit,D as useSoba,_i as watchRun};
|
package/dist/styles.css
CHANGED
|
@@ -44,9 +44,6 @@
|
|
|
44
44
|
|
|
45
45
|
box-sizing: border-box;
|
|
46
46
|
|
|
47
|
-
width: 100%;
|
|
48
|
-
max-width: 560px;
|
|
49
|
-
margin: 0 auto;
|
|
50
47
|
color: var(--sc-text, #1a1a1c);
|
|
51
48
|
font-family: var(
|
|
52
49
|
--sc-font,
|
|
@@ -62,6 +59,12 @@
|
|
|
62
59
|
line-height: 1.5;
|
|
63
60
|
letter-spacing: -0.005em;
|
|
64
61
|
}
|
|
62
|
+
|
|
63
|
+
:where(.soba-connect) {
|
|
64
|
+
width: 100%;
|
|
65
|
+
max-width: 560px;
|
|
66
|
+
margin: 0 auto;
|
|
67
|
+
}
|
|
65
68
|
.soba-connect *,
|
|
66
69
|
.soba-connect *::before,
|
|
67
70
|
.soba-connect *::after {
|
|
@@ -468,6 +471,12 @@ a.sc-btn {
|
|
|
468
471
|
font-variant-numeric: tabular-nums;
|
|
469
472
|
}
|
|
470
473
|
|
|
474
|
+
.sc-rstop {
|
|
475
|
+
align-self: center;
|
|
476
|
+
width: 24px;
|
|
477
|
+
height: 24px;
|
|
478
|
+
}
|
|
479
|
+
|
|
471
480
|
.sc-rstep {
|
|
472
481
|
display: -webkit-box;
|
|
473
482
|
overflow: hidden;
|
|
@@ -497,6 +506,28 @@ a.sc-btn {
|
|
|
497
506
|
background: var(--sc-tray-sunk, #f6f6f7);
|
|
498
507
|
}
|
|
499
508
|
|
|
509
|
+
.sc-runtime-logo {
|
|
510
|
+
width: 15px;
|
|
511
|
+
height: 15px;
|
|
512
|
+
border-radius: 3px;
|
|
513
|
+
object-fit: contain;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.sc-runtime-letter {
|
|
517
|
+
font-size: 10px;
|
|
518
|
+
font-weight: 600;
|
|
519
|
+
line-height: 1;
|
|
520
|
+
color: var(--sc-muted, #6b6b73);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.sc-runs-logo {
|
|
524
|
+
flex: none;
|
|
525
|
+
width: 14px;
|
|
526
|
+
height: 14px;
|
|
527
|
+
border-radius: 3px;
|
|
528
|
+
object-fit: contain;
|
|
529
|
+
}
|
|
530
|
+
|
|
500
531
|
.sc-runtime-mark {
|
|
501
532
|
width: 13px;
|
|
502
533
|
height: 13px;
|
|
@@ -662,7 +693,9 @@ a.sc-btn {
|
|
|
662
693
|
background: transparent;
|
|
663
694
|
font-family: inherit;
|
|
664
695
|
cursor: pointer;
|
|
665
|
-
transition:
|
|
696
|
+
transition:
|
|
697
|
+
background-color 120ms ease,
|
|
698
|
+
color 120ms ease;
|
|
666
699
|
}
|
|
667
700
|
|
|
668
701
|
.sc-runs-btn:hover:not(:disabled),
|
|
@@ -718,7 +751,9 @@ a.sc-btn {
|
|
|
718
751
|
border: 1px solid var(--sc-line, #e9e9eb);
|
|
719
752
|
border-radius: 12px;
|
|
720
753
|
background: var(--sc-tray-card, #ffffff);
|
|
721
|
-
box-shadow:
|
|
754
|
+
box-shadow:
|
|
755
|
+
0 10px 30px rgba(0, 0, 0, 0.12),
|
|
756
|
+
0 2px 6px rgba(0, 0, 0, 0.06);
|
|
722
757
|
color: var(--sc-text, #1a1a1c);
|
|
723
758
|
|
|
724
759
|
max-height: 60vh;
|
|
@@ -826,7 +861,9 @@ a.sc-btn {
|
|
|
826
861
|
font-weight: 500;
|
|
827
862
|
color: var(--sc-text-2, #3f3f46);
|
|
828
863
|
cursor: pointer;
|
|
829
|
-
transition:
|
|
864
|
+
transition:
|
|
865
|
+
background-color 120ms ease,
|
|
866
|
+
color 120ms ease;
|
|
830
867
|
}
|
|
831
868
|
|
|
832
869
|
.sc-mp-btn:hover:not(:disabled),
|
|
@@ -1928,8 +1965,9 @@ a.sc-btn {
|
|
|
1928
1965
|
border-radius: var(--sc-r-pill, 999px);
|
|
1929
1966
|
border-color: var(--sc-line, #e9e9eb);
|
|
1930
1967
|
|
|
1931
|
-
|
|
1932
|
-
|
|
1968
|
+
|
|
1969
|
+
box-shadow: var(--sc-shadow-1, 0 1px 2px rgb(0 0 0 / 5%));
|
|
1970
|
+
font-size: var(--sc-fs-small, 12.5px);
|
|
1933
1971
|
font-weight: 500;
|
|
1934
1972
|
|
|
1935
1973
|
letter-spacing: -0.005em;
|
package/dist/types.d.ts
CHANGED
|
@@ -35,6 +35,29 @@ export interface Runtime {
|
|
|
35
35
|
quarantined?: boolean;
|
|
36
36
|
first_seen_at?: string;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* ONE RUN ON ONE OF THIS PERSON'S MACHINES, for this app — a row of "Running
|
|
40
|
+
* now". `label` is the app's own name for it (`metadata.label`), `task` its
|
|
41
|
+
* category; `step` the last thing it said it was doing, `phase` what its latest
|
|
42
|
+
* frame was. `machine_id` is null while it waits for a free slot.
|
|
43
|
+
*/
|
|
44
|
+
export interface MachineRun {
|
|
45
|
+
id: string;
|
|
46
|
+
machine_id: string | null;
|
|
47
|
+
status: "queued" | "running";
|
|
48
|
+
label: string | null;
|
|
49
|
+
task: string | null;
|
|
50
|
+
runtime_id: string | null;
|
|
51
|
+
model: string | null;
|
|
52
|
+
cost_class: string | null;
|
|
53
|
+
started_at: string;
|
|
54
|
+
first_output_at: string | null;
|
|
55
|
+
step: string | null;
|
|
56
|
+
phase: {
|
|
57
|
+
kind: "thinking" | "writing" | "tool" | "approval" | "starting";
|
|
58
|
+
tool?: string;
|
|
59
|
+
} | null;
|
|
60
|
+
}
|
|
38
61
|
export interface Machine {
|
|
39
62
|
id: string;
|
|
40
63
|
label: string | null;
|
|
@@ -52,17 +52,21 @@ export interface ConnectButtonView {
|
|
|
52
52
|
}
|
|
53
53
|
export declare function useConnectButton(): ConnectButtonView;
|
|
54
54
|
/**
|
|
55
|
-
* WHAT
|
|
56
|
-
*
|
|
55
|
+
* WHAT A CONTROL SAYS ABOUT ONE MACHINE — the rule itself, with no hooks in it,
|
|
56
|
+
* because `<ConnectPill />` cannot read it off the hook above.
|
|
57
57
|
*
|
|
58
58
|
* While its panel is open the pill's state is THIS APP'S RUNS rather than the
|
|
59
59
|
* machine's own counters: the run list is read every three seconds and is
|
|
60
60
|
* exactly this app's, where `state` and `active` arrive by heartbeat and count
|
|
61
|
-
* every app on that laptop. So
|
|
62
|
-
* for those few seconds, and a hook reading the provider cannot.
|
|
61
|
+
* every app on that laptop. So `<ConnectButton />` substitutes its own machine
|
|
62
|
+
* list for those few seconds, and a hook reading the provider cannot.
|
|
63
63
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
64
|
+
* THE BODY IS THE KIT'S NOW. It was defined here, which put it one package
|
|
65
|
+
* above the only two functions it is made of and out of reach of the other
|
|
66
|
+
* surface that draws this pill — the dashboard's bar, which spelled the same
|
|
67
|
+
* four lines out by hand. It moved down beside `stateWord` and `machineName`;
|
|
68
|
+
* this stays as the published face of it, so the declaration a customer
|
|
69
|
+
* installs names types from this package rather than from a private one.
|
|
66
70
|
*/
|
|
67
71
|
export declare function connectSays(machine: Machine | null): {
|
|
68
72
|
label: string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MachineRun } from "./types.js";
|
|
2
|
+
export interface MachineRunsOptions {
|
|
3
|
+
/** Read only while true — a list somebody has open. Default true. */
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
/** How often to read it again. Default 3s: a run's step changes on nearly every read. */
|
|
6
|
+
intervalMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface MachineRunsView {
|
|
9
|
+
/** This app's runs on this person's machines. `null` until the first read. */
|
|
10
|
+
runs: MachineRun[] | null;
|
|
11
|
+
refresh: () => Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Stop one, as the person whose machine it is on — no app server involved.
|
|
14
|
+
* The app reading that run sees it end with `reason: "stopped_by_user"`.
|
|
15
|
+
* Rejects with the gateway's message when it could not be stopped.
|
|
16
|
+
*/
|
|
17
|
+
stop: (runId: string) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* WHAT THIS PERSON'S MACHINES ARE RUNNING FOR THIS APP, and a way to stop it:
|
|
21
|
+
* the "Running now" list in `<ConnectButton />`'s panel, without the panel.
|
|
22
|
+
* Needs `<SobaProvider>`; outside one, `runs` stays null and `stop` rejects.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useMachineRuns({ enabled, intervalMs }?: MachineRunsOptions): MachineRunsView;
|
package/package.json
CHANGED