PageSourceSearch

https://www.clawmax.ai/assets/ClientConsolePreview-FPs8riFN.js

js clawmax.ai collected 2026-10-05 01:01:22 UTC 233,252 bytes, 24 lines download raw bytes

1import{r as d,j as e}from"./query-vendor-D9HxUwVw.js";import{h as Nn,g as Mn,k as yl,i as bl,o as Si,A as pn,d as hn,T as Oi,j as Sa,b as Oa,p as Et,n as Mi,q as Ma,r as Ko,l as Bo,s as Wo,t as zo}from"./alert-DmCPZtFv.js";import{c as In,j as Ho,W as Vo,Y as Yo,k as Go,o as O,w as x,p as He,C as Ii,i as J,H as Pi,q as Lt,M as vl,U as Ei,r as Jo,F as Ri,E as Oe,a8 as Zo,X as Ai,a4 as Ia,$ as jl,a0 as wl,a1 as kl,a2 as Nl,a5 as Xo}from"./main-Beet4ICb.js";import{N as Qo,D as ft,a as us,b as _t,c as Qe,d as et,e as tt,m as st,S as ed,g as td,h as sd,i as nd,k as ht,l as ad,C as Cl}from"./Navbar-BqJTjusa.js";import{C as rd}from"./ClientAiSupport-DRzyoBNl.js";import{B as Ti,R as Di}from"./preview-ops-CQ8vvmdY.js";import{A as ms,a as ps,b as hs,c as xs,d as gs,e as fs,f as _s,g as ys}from"./alert-dialog-CZA9pin1.js";import{B as M}from"./badge-CfqqaGGs.js";import{B as b}from"./button-LbntbU2-.js";import{C as K,a as te,b as se,c as ne,d as B}from"./card-Dr1ffPuS.js";import{C as bs,E as id}from"./checkbox-eagU0jAt.js";import{I}from"./input-CwhkcFhu.js";import{L as $i}from"./label-8pqAgZUs.js";import{S as Ve,a as Ye,b as Ge,c as Je,d as Ce,T as ld}from"./textarea-L4dhNIYf.js";import{T as Li,a as Ui,b as xt,c as fe,d as qi,e as G}from"./table-2srWrW1w.js";import{T as od,c as xn,a as dd,b as Fi}from"./tabs-Cjn84vbU.js";import{f as pe,h as _e,o as Sl,p as cd,q as Wa,g as Ol,l as Ki,d as Bi,e as gn,c as Rt,E as ud,j as Pa,a as Ea,k as Ra}from"./internal-pricing-6Dif-1j4.js";import{T as ls}from"./triangle-alert-BNQirVJZ.js";import{P as Wi}from"./plus-DVPltgQD.js";import{D as ye}from"./download-C06b31re.js";import{S as At}from"./smartphone-BAfBBgxe.js";import{T as Ml}from"./trash-2-B866bM7g.js";import{C as Il}from"./copy-CClSMULm.js";import"./TermsOfServiceContent-81UKey7L.js";import"./supabase-vendor-oIW8hzbJ.js";import"./send-j9uKDMUv.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const md=In("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ut=In("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const zi=In("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Hi=In("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]),pd=[5,10,15,20,25,30,35,40,45,50],hd=[1,2,3,5],sr=5,nr=50,xd=1,gd=30,Vi=12,Yi=12,Gi=500,fd=24;function Os(s,a,i,u){const p=typeof s=="number"?s:Number(s);if(!Number.isInteger(p)||p<i||p>u)throw new Error(`${a} must be a whole number from ${i} to ${u}`);return p}function _d(s){const a=Os(s,"max_instances",sr,nr);return a<=5?1:a<=10?2:3}function yd(s,a){const i=Os(s,"max_instances",sr,nr),u=Os(a,"cluster_count",1,3),p=Math.floor(i/u),h=i%u;return Array.from({length:u},(v,z)=>p+(z<h?1:0))}function bd(s){const a=Os(s.maxInstances,"max_instances",sr,nr),i=Os(s.usageDays,"usage_days",xd,gd);if(typeof s.accessStartsAt!="string"||!s.accessStartsAt.trim())throw new Error("access_starts_at is required");const u=new Date(s.accessStartsAt);if(Number.isNaN(u.getTime()))throw new Error("access_starts_at must be a valid timestamp");const p=s.now||new Date;if(u.getTime()<p.getTime()+fd*60*60*1e3)throw new Error("access_starts_at must provide at least 24 hours of preparation time");const h=i+1,v=new Date(u.getTime()-Vi*60*60*1e3),z=new Date(u.getTime()+i*24*60*60*1e3),X=new Date(z.getTime()+Yi*60*60*1e3),he=_d(a);return{max_instances:a,usage_days:i,prep_hours:Vi,capacity_days:h,cleanup_hours:Yi,rate_cents_per_instance_day:Gi,amount_cents:a*h*Gi,requested_cluster_count:he,cluster_slot_targets:yd(a,he),access_starts_at:u.toISOString(),capacity_starts_at:v.toISOString(),access_ends_at:z.toISOString(),cleanup_ends_at:X.toISOString()}}const vd=[{value:"nyc1",label:"New York (NYC1)"},{value:"lon1",label:"London (LON1)"}],jd=3e4,wd=5e3,gt=10,Ji="bg-primary/28 hover:bg-primary/28 dark:bg-primary/32 dark:hover:bg-primary/32",Zi="border-l-4 border-primary pl-3",Xi="gap-2 data-[state=active]:border data-[state=active]:border-primary/20 data-[state=active]:bg-primary/10 data-[state=active]:text-primary data-[state=active]:shadow-none",kd="https://chat.whatsapp.com/K0rV9AlHQBHBklJFE6alvM?mode=gi_t",Nd="https://chat.whatsapp.com/ESmtehW8fsz7dykdtOFVgX?mode=gi_t",Qi="https://chat.whatsapp.com/Ixud2R2mR1cGZ4w7S6Ozlk?mode=gi_t",el=[1500,2500,4e3];function Cd(){const s=new Date(Date.now()+1728e5);s.setMinutes(0,0,0);const a=s.getTimezoneOffset()*60*1e3;return new Date(s.getTime()-a).toISOString().slice(0,16)}function tl({backups:s,selected:a,onChange:i}){return s.length===0?null:e.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Restore saved workspaces (optional)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose up to five encrypted backups, or leave everything unchecked to start fresh. Multiple backups restore into separate source-labeled folders."}),e.jsx("div",{className:"space-y-2",children:s.map(u=>{const p=a.includes(u.id);return e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/70 bg-background px-3 py-2",children:[e.jsx(bs,{checked:p,onCheckedChange:h=>{h===!0&&!p&&a.length<5&&i([...a,u.id]),h!==!0&&p&&i(a.filter(v=>v!==u.id))},className:"mt-0.5"}),e.jsxs("span",{className:"min-w-0 text-sm",children:[e.jsx("span",{className:"block font-medium text-foreground",children:u.source_instance_name||u.source_instance_key}),e.jsxs("span",{className:"block text-xs text-muted-foreground",children:[u.source_target_type==="cloud_instance"?"Cloud":"On-Prem",u.captured_at?` · saved ${new Date(u.captured_at).toLocaleDateString()}`:"",u.workspace_count!=null?` · ${u.workspace_count} workspace${u.workspace_count===1?"":"s"}`:""]})]})]},u.id)})})]})}const ar="clawmax.client.cloudCreateDraft",rr="clawmax.client.onpremCreateDraft",ir="clawmax.client.enterpriseUpgradeDraft",sl="clawmax.client.selectedCloudId",nl="clawmax.client.selectedCloudPage",al="clawmax.client.selectedCloudDetailOpen",rl="clawmax.client.selectedOnPremId",il="clawmax.client.selectedOnPremDetailOpen",ll="clawmax.client.onPremInstallGuideOpen",ol="clawmax.client.selectedCustomerId";function Pl(s,a,i,u){var p,h;return!s||!a?null:s==="cloud_instance"?((p=i.find(v=>v.id===a||v.instance_key===a))==null?void 0:p.customer_id)||null:((h=u.find(v=>v.id===a||v.instance_key===a))==null?void 0:h.customer_id)||null}function j(s){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(s)}function El(s,a="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:a.toUpperCase(),maximumFractionDigits:2}).format((s||0)/100)}function Sd(){if(typeof window>"u")return null;try{const s=window.sessionStorage.getItem(ar);if(!s)return null;const a=JSON.parse(s);return!a||typeof a!="object"?null:a}catch{return null}}function Od(s,a){typeof window>"u"||window.sessionStorage.setItem(ar,JSON.stringify({...s,requestId:a}))}function os(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`request-${Date.now()}-${Math.random().toString(36).slice(2)}`}function dl(){typeof window>"u"||window.sessionStorage.removeItem(ar)}function Aa(s){if(typeof window>"u")return"";try{return window.localStorage.getItem(s)||""}catch{return""}}function Ta(s,a){if(!(typeof window>"u"))try{a?window.localStorage.setItem(s,a):window.localStorage.removeItem(s)}catch{}}function Md(s){if(typeof window>"u")return 1;try{const a=window.localStorage.getItem(s),i=a?Number.parseInt(a,10):NaN;return Number.isFinite(i)&&i>0?i:1}catch{return 1}}function Id(s,a){if(!(typeof window>"u"))try{a>1?window.localStorage.setItem(s,String(a)):window.localStorage.removeItem(s)}catch{}}function Da(s,a=!1){if(typeof window>"u")return a;try{const i=window.localStorage.getItem(s);return i==="true"?!0:i==="false"?!1:a}catch{return a}}function $a(s,a){if(!(typeof window>"u"))try{window.localStorage.setItem(s,a?"true":"false")}catch{}}function Pd(){if(typeof window>"u")return null;try{const s=window.sessionStorage.getItem(ir);if(!s)return null;const a=JSON.parse(s);return typeof(a==null?void 0:a.includedInstances)=="number"?a:null}catch{return null}}function Ed(s,a,i,u){typeof window>"u"||window.sessionStorage.setItem(ir,JSON.stringify({includedInstances:s,promotionCode:a,enterpriseName:i,enterpriseWebsiteUrl:u}))}function cl(){typeof window>"u"||window.sessionStorage.removeItem(ir)}function L(s,a){if(!a)return s;const i=new URL(s,"https://clawmax.local");return i.searchParams.set("customerId",a),`${i.pathname}${i.search}`}function Rd(){if(typeof window>"u")return null;try{const s=window.sessionStorage.getItem(rr);if(!s)return null;const a=JSON.parse(s);return!a||typeof a!="object"?null:a}catch{return null}}function Ad(s,a){typeof window>"u"||window.sessionStorage.setItem(rr,JSON.stringify({...s,requestId:a}))}function ul(){typeof window>"u"||window.sessionStorage.removeItem(rr)}function Rl(s){const a=new URLSearchParams(s),i=Number.parseInt(a.get("onprem_support_months")||"",10);return Wa(i)?i:Ol()}function Al(s){const a=new URLSearchParams(s),i=Number.parseInt(a.get("enterprise_included_instances")||"",10);return cd(i)?i:Sl}function Ze(s){try{window.location.assign(s)}catch(a){if(a instanceof Error&&/Not implemented: navigation/.test(a.message))return;throw a}}
21function Tl(s,a=Date.now()){if(!s)return"just now";const i=new Date(s).getTime();if(!Number.isFinite(i))return"just now";const u=Math.round((i-a)/6e4),p=Math.abs(u);if(p<1)return"less than a minute ago";if(p<60)return u<0?`${p} minute${p===1?"":"s"} ago`:`in ${p} minute${p===1?"":"s"}`;const h=Math.round(p/60);if(h<24)return u<0?`${h} hour${h===1?"":"s"} ago`:`in ${h} hour${h===1?"":"s"}`;const v=Math.round(h/24);return u<0?`${v} day${v===1?"":"s"} ago`:`in ${v} day${v===1?"":"s"}`}function qt(s){return s.maintenance_window_starts_at||s.started_at||s.completed_at||s.failed_at||s.queued_at||""}function za(s){var u,p;if(typeof s.scheduled_retry_label=="string"&&s.scheduled_retry_label.trim())return s.scheduled_retry_label.trim();const a=typeof s.scheduled_retry_count=="number"?s.scheduled_retry_count:typeof((u=s.request_payload)==null?void 0:u.scheduled_retry_count)=="number"?s.request_payload.scheduled_retry_count:0;if(a<=0)return null;const i=typeof s.scheduled_retry_max=="number"?s.scheduled_retry_max:typeof((p=s.request_payload)==null?void 0:p.scheduled_retry_max)=="number"?s.request_payload.scheduled_retry_max:3;return`Rescheduled ${a} of ${i}`}function vs(s){return!s||s.status!=="scheduled"?null:typeof s.request_note=="string"&&s.request_note.trim()?s.request_note.trim():null}function fn(s,a,i,u){const p=e.jsx(M,{variant:a,className:i,children:s});return u?e.jsx(jl,{children:e.jsxs(wl,{children:[e.jsx(kl,{asChild:!0,children:e.jsx("div",{className:"w-fit cursor-help",title:u,children:p})}),e.jsx(Nl,{className:"max-w-sm whitespace-pre-wrap text-sm",children:u})]})}):p}function be(s){if(!s)return"Unknown time";const a=new Date(s);return Number.isNaN(a.getTime())?s:new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short"}).format(a)}function Cn(s){if(!s)return"maintenance status needs billing setup";const a=Date.parse(s);if(!Number.isFinite(a))return"maintenance status needs billing setup";const i=Math.max(0,Math.floor((Date.now()-a)/(24*60*60*1e3)));if(i<=0)return"maintenance expires today";if(i<30)return`${i} day${i===1?"":"s"} behind`;const u=Math.floor(i/30),p=i%30;return p?`${u} month${u===1?"":"s"} ${p} day${p===1?"":"s"} behind`:`${u} month${u===1?"":"s"} behind`}function Dl(s){const a=s.trim().toLowerCase();return a==="paid"||a==="succeeded"?"default":a==="failed"||a==="past_due"||a==="unpaid"?"destructive":"outline"}function ml(s,a){return e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsx(se,{children:"Billing history"}),e.jsx(ne,{children:"Recent Stripe charges and billing attempts for this deployment."})]}),e.jsx(B,{children:a?e.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-3 text-sm text-muted-foreground",children:"Loading billing events…"}):s.length?e.jsx("div",{className:"space-y-2",children:s.map(i=>e.jsx("div",{className:"rounded-md border border-border px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"font-medium text-foreground",children:El(i.amount_cents,i.currency||"USD")}),e.jsx(M,{variant:Dl(i.status),children:i.status})]}),e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:i.description||i.billing_reason||i.event_type}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:be(i.occurred_at)})]}),e.jsxs("div",{className:"flex flex-wrap justify-start gap-2 sm:justify-end",children:[i.invoice_url?e.jsx("a",{href:i.invoice_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-primary underline-offset-4 hover:underline",children:"Invoice"}):null,i.receipt_url?e.jsx("a",{href:i.receipt_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-primary underline-offset-4 hover:underline",children:"PDF"}):null]})]})},i.id))}):e.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-3 text-sm text-muted-foreground",children:"No recorded billing events for this deployment yet."})})]})}function ks(s,a,i){const u=s.filter(p=>p.target_type===a).filter(p=>p.target_id===i||p.target_key===i).filter(p=>p.status==="scheduled").filter(p=>p.action_type==="queue_update"&&p.action_type_label==="Maintenance redeploy").sort((p,h)=>qt(h).localeCompare(qt(p)))[0];return u||s.filter(p=>p.target_type===a).filter(p=>p.target_id===i||p.target_key===i).filter(p=>p.status==="scheduled"||p.status==="queued"||p.status==="started").sort((p,h)=>qt(h).localeCompare(qt(p)))[0]}function $l(s){return!s||s.target_type!=="onprem_instance"?!1:s.action_type==="queue_update"&&s.action_type_label==="Update Opik settings"&&(s.status==="queued"||s.status==="started")}function vn(s,a,i){const u=ks(s,a,i);
21return $l(u)?null:u}function Ll(s){return s.target_type==="cloud_instance"&&s.action_type==="queue_update"?"Redeploy":s.action_type_label}function js(s,a){if(!a)return{label:s,variant:Sn(s),className:"",detail:null};const i=Ll(a);return a.status==="scheduled"?{label:"Maintenance scheduled",variant:"outline",className:"border-amber-500/40 bg-amber-500/10 text-amber-900 dark:text-amber-200",detail:a.maintenance_window_starts_at?`Scheduled for ${be(a.maintenance_window_starts_at)}${za(a)?` · ${za(a)}`:""}`:"Scheduled maintenance window pending"}:{label:a.status==="started"?`${i} in progress`:`${i} queued`,variant:"outline",className:"border-primary/40 bg-primary/10 text-primary shadow-[0_0_18px_hsl(var(--primary)/0.22)] animate-pulse",detail:`${a.status==="started"?"Started":"Queued"} ${Tl(qt(a))}`}}function Ul(s){return!s||s==="Never"||s==="Unknown"}function Ms(s){return!!s.dashboard_url&&Nn(s.runtime_health)&&/running/i.test(s.runtime_status)}function jn(s){return Ul(s.last_seen_at)?{label:"Connecting this Mac",variant:"secondary",detail:"Waiting for first agent writeback",seenLabel:"Awaiting first writeback"}:/running/i.test(s.runtime_status)&&Nn(s.runtime_health)||!(/running/i.test(s.desired_state)&&!Ms(s))?null:{label:"Starting dashboard",variant:"secondary",detail:"ClawMax is installing and starting the local runtime",seenLabel:s.last_seen_at||"Awaiting dashboard startup"}}function Ha(s){return s.model_provider==="Ollama"?"Ollama":s.credential_mode==="BYOK"?"BYOK models":s.model_provider}function ql(s){const{selectedRecord:a,selectedAlreadyConnected:i,hasConflictingActiveDeployment:u}=s,p=[];return(i||u)&&p.push("This Mac is already connected to another instance. On that Mac, open the ClawMax tray menu and choose Disconnect This Mac, then retry."),a&&!Ms(a)&&(/running/i.test(a.desired_state)||/running/i.test(a.runtime_status))&&(p.push("On the connected Mac, open the ClawMax tray menu and choose Restart > Dashboard."),p.push("If ClawMax looks stuck on the connected Mac, open the tray menu and choose Restart > ClawMax.")),p}function Sn(s){return/(not loaded|not installed|needs attention)/i.test(s)?"destructive":/(healthy|running|connected|active|ready)/i.test(s)?"default":/(watch|lagging|paused|trial|limited)/i.test(s)?"secondary":/(critical|offline|suspended|degraded|needs setup)/i.test(s)?"destructive":"outline"}function Ns(s){return!!s.service_url&&s.public_url_ready!==!1}function Fl(s,a,i){if(!s)return"";let u=s.trim();const p=(i==null?void 0:i.trim().toLowerCase())||"";return u=u.replace(/\bnamespace\s+([A-Za-z0-9._:-]+)\b/gi,(h,v)=>{const z=String(v).toLowerCase();return p&&(z.includes(p)||z.endsWith(`-${p}`))?`namespace for ${i}`:"namespace"}),u=u.replace(/\bshared cluster\s+[A-Za-z0-9._:-]+\b/gi,"shared cluster"),u=u.replace(/\bcluster\s+[A-Za-z0-9._:-]+\b/gi,"cluster"),u=u.replace(/\s+/g," ").trim(),/shared cluster/i.test(u)&&a&&(u=u.replace(/shared cluster/gi,`${a} shared cluster`)),u}function Kl(s){return{id:s.instance_key||s.id,billing_target_id:s.id,customer_id:s.customer_id,customer:s.customer_name||"Unknown",provider:s.cloud_provider_label||"Civo",billing_mode:s.billing_mode_label||"ClawMax cloud",model_provider:s.model_provider_label||"OpenAI",credential_mode:s.credential_mode_label||"BYOK",model_name:s.default_model||"Customer-managed in dashboard",region:s.region||"unknown",plan:s.plan_name||"Starter",version:s.version||"",status:s.runtime_status_label||"Degraded",cpu_load:s.cpu_load_percent!=null?`${s.cpu_load_percent}%`:"",memory_load:s.memory_load_percent!=null?`${s.memory_load_percent}%`:"",cpu_limit:s.cpu_limit||"",memory_limit:s.memory_limit||"",workspace_pvc_name:s.workspace_pvc_name||void 0,workspace_storage:s.workspace_storage||void 0,last_status_summary:s.last_status_summary||void 0,recent_log_excerpt:s.recent_log_excerpt||void 0,monthly_cost:s.monthly_infra_cost||0,model_monthly_cost:s.monthly_model_cost||0,setup_fee:s.setup_fee||0,recurring_support_enabled:s.recurring_support_enabled,recurring_support_fee:s.recurring_support_fee||0,uptime:"n/a",last_restart_at:s.last_restart_at||"Not yet",last_deploy_at:s.last_deploy_at||"Not yet",service_url:s.service_url||"",public_url_ready:s.public_url_ready??void 0,cluster_id:s.cluster_id||void 0,cluster_display_name:s.cluster_display_name||void 0,cluster_region:s.cluster_region||void 0,placement_reason:s.placement_reason||void 0,ready_at:s.ready_at||"",ready_email_sent_at:s.ready_email_sent_at||"",promotion_code:s.promotion_code||void 0,effective_free_install:s.effective_free_install??void 0,effective_support_free_until:s.effective_support_free_until||void 0,promotion_ends_at:s.promotion_ends_at||void 0,stripe_subscription_id:s.stripe_subscription_id||void 0,support_expiry_warning_sent_at:s.support_expiry_warning_sent_at||void 0,support_expiry_final_warning_sent_at:s.support_expiry_final_warning_sent_at||void 0,support_expiry_delete_after:s.support_expiry_delete_after||void 0,support_expiry_delete_queued_at:s.support_expiry_delete_queued_at||void 0}}function lr(s){const a=typeof s=="string"?s.trim().toLowerCase():"";return a==="pkg"||a==="homebrew"||a==="manual"||a==="unknown"?a:"unknown"}function or(s){const a=[s.last_status_summary,s.last_error,s.last_reconcile_result,s.recent_log_excerpt].filter(
21Boolean).join(" ");return/\breconnect[_ -]?required\b|missing\/invalid refresh token|invalid refresh token|rejected worker binding|re-establish(?:ment)? of trust/i.test(a)}function Pn(s){const a=lr(s==null?void 0:s.install_method);return a!=="unknown"?{installMethod:a,installMethodDetail:(s==null?void 0:s.install_method_detail)??null}:s!=null&&s.instance_key&&s.instance_key!=="onp-praveen-mpahqxz7"?{installMethod:"pkg",installMethodDetail:"pkg:clawmax-app"}:{installMethod:"unknown",installMethodDetail:(s==null?void 0:s.install_method_detail)??null}}function Va(s){const{installMethod:a}=Pn(s);return a==="homebrew"?"homebrew":a==="manual"?"manual":"installer"}function Bl(s){const{installMethod:a,installMethodDetail:i}=Pn(s);return a==="unknown"?{title:"Default path for most Macs",description:"Use the installer above. Keep Homebrew or Manual for machines that were originally set up that way or need a terminal-first flow."}:a==="pkg"?{title:"Installed with the signed app",description:"This Mac looks like a PKG/app install. Use the installer path above for updates or repairs."}:a==="homebrew"?{title:"Installed with Homebrew",description:i==="homebrew:cask"?"This Mac looks like a Homebrew app cask install. Use the Homebrew path first for updates.":"This Mac looks like a Homebrew install. Use the Homebrew path first for updates."}:{title:"Installed with the CLI",description:"This Mac looks like a manual CLI install. Use the Manual path first for updates."}}function Wl(s){const{installMethod:a}=Pn(s);return{installMethod:a,showHomebrew:a==="unknown"||a==="homebrew",showManual:a==="unknown"||a==="manual"}}function On(s,a){const i=s.last_dashboard_url||s.dashboard_url||"";return{id:s.instance_key||s.id,billing_target_id:s.id,instance_key:s.instance_key||s.id,customer_id:s.customer_id??null,customer:a||s.customer_name||"Unknown",site:s.site_name||"Unknown",model_provider:s.model_provider_label||"Ollama",credential_mode:s.credential_mode_label||"ClawMax-managed",model_name:s.default_model||"",agent_status:s.agent_status_label||"Offline",agent_install_status:s.agent_install_status_label||"Not installed",service_load_status:s.service_load_status_label||"Not loaded",desired_state:s.desired_state_label||"Stopped",runtime_health:s.runtime_health_label||"Needs attention",runtime_status:s.runtime_status_label||"Paused",connectivity:s.connectivity_mode_label||"Direct",remote_access:s.remote_access_status_label||"Needs Setup",version:s.version||"",last_seen_at:s.last_seen_at||"Never",last_reconcile_at:s.last_reconcile_at||"Never",last_reconcile_result:s.last_reconcile_result||void 0,last_status_summary:s.last_status_summary||void 0,recent_log_excerpt:s.recent_log_excerpt||"Awaiting agent install",update_channel:s.update_channel_label||"Stable",cpu_class:s.cpu_class||"",model_monthly_cost:s.monthly_model_cost??0,setup_fee:s.setup_fee??0,recurring_support_enabled:s.recurring_support_enabled,recurring_support_fee:s.recurring_support_fee??0,stripe_subscription_id:s.stripe_subscription_id??null,...Object.prototype.hasOwnProperty.call(s,"effective_support_free_until")?{effective_support_free_until:s.effective_support_free_until??null}:{},...Object.prototype.hasOwnProperty.call(s,"support_expiry_warning_sent_at")?{support_expiry_warning_sent_at:s.support_expiry_warning_sent_at??null}:{},...Object.prototype.hasOwnProperty.call(s,"support_expiry_final_warning_sent_at")?{support_expiry_final_warning_sent_at:s.support_expiry_final_warning_sent_at??null}:{},...Object.prototype.hasOwnProperty.call(s,"support_expiry_delete_after")?{support_expiry_delete_after:s.support_expiry_delete_after??null}:{},...Object.prototype.hasOwnProperty.call(s,"support_expiry_delete_queued_at")?{support_expiry_delete_queued_at:s.support_expiry_delete_queued_at??null}:{},support_bundle_status:s.support_bundle_status||"No support bundle recorded",runtime_target:s.runtime_target_label||"kubernetes",dashboard_url:i,workspace_path:s.last_workspace_path||"",last_error:s.last_error||"None",target_release:s.target_release||"",installer_release:s.installer_release||"",deployment_worker_key:s.deployment_worker_key||"",install_method:lr(s.install_method),install_method_detail:s.install_method_detail??null,latest_available_version:s.latest_available_version??null,update_available:s.update_available??null,last_update_checked_at:s.last_update_checked_at??null,last_update_error:s.last_update_error??null,installer_release_current:s.installer_release_current??null,installer_release_target:s.installer_release_target??null,installer_update_state:s.installer_update_state??null,installer_update_detail:s.installer_update_detail??null,installer_update_available:s.installer_update_available??null,installer_update_can_install:s.installer_update_can_install??null,installer_update_last_checked_at:s.installer_update_last_checked_at??null,installer_update_requested_at:s.installer_update_requested_at??null,installer_update_prepared_at:s.installer_update_prepared_at??null,installer_update_applied_at:s.installer_update_applied_at??null,installer_update_error:s.installer_update_error??null,reconnect_required:s.reconnect_required??or(s),reconnect_url:s.reconnect_url??null,reconnect_deep_link:s.reconnect_deep_link??null,reconnect_expires_at:s.reconnect_expires_at??null}}function pl(s){var a;return On(s.onprem_instance,((a=s.preview)==null?void 0:a.customer)||s.onprem_instance.customer_name||"Unknown")}function Ft(s){return bl(s)&&!Mn(s)}function zl(s){return s.dashboard_url?Mn(s.dashboard_url)?Ms(s)?yl(s.instance_key):null:Ft(s.dashboard_url)?s.dashboard_url:null:null}function ds(s,a="inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline"){return s.dashboard_url?Mn(s.dashboard_url)?Ms(s)?e.jsxs("a",{href:yl(s.instance_key),className:a,children:["Open on connected Mac",e.
21jsx(Oe,{className:"h-4 w-4"})]}):"Dashboard is starting on the connected Mac":Ft(s.dashboard_url)?e.jsxs("a",{href:s.dashboard_url,target:"_blank",rel:"noopener noreferrer",className:a,children:["Open dashboard",e.jsx(Oe,{className:"h-4 w-4"})]}):s.dashboard_url:"Not reported yet"}function hl(s,a="font-medium text-foreground"){const i=zl(s);if(!i)return e.jsx("div",{className:a,children:s.id});const u=!!(s.dashboard_url&&Ft(s.dashboard_url));return e.jsxs("a",{href:i,target:u?"_blank":void 0,rel:u?"noopener noreferrer":void 0,className:J(a,"inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline"),children:[s.id,e.jsx(Oe,{className:"h-3.5 w-3.5"})]})}function Hl(s,a="text-xs text-muted-foreground break-all"){return s?bl(s)?e.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:J(a,"text-primary underline-offset-4 hover:underline"),children:s}):e.jsx("span",{className:a,children:s}):e.jsx("span",{className:a,children:"Not available"})}function Td(s,a="text-xs text-muted-foreground break-all"){return Hl(s.dashboard_url,a)}function Dd(s,a="text-xs text-muted-foreground break-all"){return Hl(s.service_url,a)}function $d(s){return Ns(s)?s.service_url:null}function La(s,a="font-medium text-foreground"){const i=$d(s);return i?e.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:J(a,"inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline"),children:[s.id,e.jsx(Oe,{className:"h-3.5 w-3.5"})]}):e.jsx("div",{className:a,children:s.id})}function Tt(s){return!!(s.dashboard_url&&Mn(s.dashboard_url))}function Vl(s,a){return s.last_seen_at!==a.last_seen_at?!0:s.agent_status!==a.agent_status||s.agent_install_status!==a.agent_install_status||s.service_load_status!==a.service_load_status||s.desired_state!==a.desired_state||s.runtime_health!==a.runtime_health||s.runtime_status!==a.runtime_status||s.connectivity!==a.connectivity||s.remote_access!==a.remote_access}function Yl(s,a,i){return a&&a.id!==i&&(a=null),s?a?{...s,last_seen_at:a.last_seen_at||s.last_seen_at,last_reconcile_at:a.last_reconcile_at||s.last_reconcile_at,last_reconcile_result:a.last_reconcile_result||s.last_reconcile_result,last_status_summary:a.last_status_summary||s.last_status_summary,recent_log_excerpt:a.recent_log_excerpt||s.recent_log_excerpt,support_bundle_status:a.support_bundle_status||s.support_bundle_status,runtime_target:a.runtime_target||s.runtime_target,dashboard_url:a.dashboard_url||s.dashboard_url,workspace_path:a.workspace_path||s.workspace_path,last_error:a.last_error||s.last_error,target_release:a.target_release||s.target_release,installer_release:a.installer_release||s.installer_release,deployment_worker_key:a.deployment_worker_key||s.deployment_worker_key,reconnect_required:a.reconnect_required??s.reconnect_required,reconnect_url:a.reconnect_url||s.reconnect_url,reconnect_deep_link:a.reconnect_deep_link||s.reconnect_deep_link,reconnect_expires_at:a.reconnect_expires_at||s.reconnect_expires_at}:s:a}function Ya(s,a){return!a||a.id!==s.id?s:{...s,dashboard_url:a.dashboard_url||s.dashboard_url,reconnect_required:a.reconnect_required??s.reconnect_required,reconnect_url:a.reconnect_url||s.reconnect_url,reconnect_deep_link:a.reconnect_deep_link||s.reconnect_deep_link,reconnect_expires_at:a.reconnect_expires_at||s.reconnect_expires_at}}function Kt(s){if(!s)return!1;const a=new Date(s).getTime();return Number.isFinite(a)&&a>Date.now()}function Dt(s){return s.stripe_subscription_id?`${j(s.recurring_support_fee)}/mo`:Kt(s.effective_support_free_until)?`Included until ${new Date(s.effective_support_free_until).toLocaleDateString()}`:s.recurring_support_enabled?`${j(s.recurring_support_fee)}/mo`:"Self-supported"}function Gl(s){return s.stripe_subscription_id?`${j(s.recurring_support_fee)}/mo`:Kt(s.effective_support_free_until)?`Included until ${new Date(s.effective_support_free_until).toLocaleDateString()}`:s.recurring_support_enabled?`${j(s.recurring_support_fee)}/mo`:"Self-supported"}function ws(s){return(s.stripe_subscription_id||s.recurring_support_enabled)&&(!Kt(s.effective_support_free_until)||s.stripe_subscription_id)?s.recurring_support_fee:0}function Jl(s){return s.recurring_support_enabled?s.recurring_support_fee>=_e({useManagedOpik:!0})?"Metering included":"Bring your own Opik":"No managed metering"}function Ga(s){return s.credential_mode==="BYOK"?"Customer-managed":s.model_monthly_cost?`${j(s.model_monthly_cost)}/mo`:"Included"}function wn(s){return!s.promotion_code||s.stripe_subscription_id?null:Kt(s.effective_support_free_until)?{label:"Promo coverage",variant:"outline",className:"border-primary/40 text-primary"}:s.setup_fee===0?{label:"Promo setup",variant:"outline",className:"border-primary/40 text-primary"}:null}function dr(s,a=24){if(!s)return null;const i=new Date(s).getTime();return Number.isFinite(i)?new Date(i+a*60*60*1e3).toISOString():null}function bt(s,a=0){if(!s)return null;const i=new Date(s).getTime();return Number.isFinite(i)?new Date(i-a*24*60*60*1e3).toISOString():null}function Ja(s){if(s.stripe_subscription_id)return null;const a=s.support_expiry_delete_after||dr(s.effective_support_free_until,24),i=a?Date.parse(a):Number.NaN,u=bt(s.effective_support_free_until,3),p=u?Date.parse(u):Number.NaN,h=bt(s.effective_support_free_until,5),v=h?Date.parse(h):Number.NaN;return s.support_expiry_delete_queued_at?{label:"Delete queued",variant:"destructive",className:""}:Number.isFinite(i)&&Date.now()>=i?{label:"Delete due",variant:"destructive",className:""}:s.support_expiry_final_warning_sent_at?{label:"T-3 notice sent",variant:"destructive",className:""}:Number.isFinite(p)&&Date.now()>=p?{label:"T-3 warning",variant:"destructive",className:""}:s.support_expiry_warning_sent_at?{label:"T-5 notice sent",variant:"outline",className:"border-amber-500/40 text-amber-800 dark:text-amber-200"}:Number.isFinite(v)&&Date.now()>=v?{label:"T-5 warning",variant:"outline",className:"border-amber-500/40 text-amber-800 dark:text-amber-200"}:null}function Zl(s){if(!s.effective_support_free_until||s.stripe_subscription_id||s.status==="Pending Cleanup")return null;const a=bt(s.effective_support_free_until,5);if(!a||Date.now()<new Date(a).getTime())return null;const i=s.support_expiry_delete_after||dr(s.effective_support_free_until,24);if(!i)return null;const u=bt(s.effective_support_free_until,3),p=Date.parse(i);return{stage:s.support_expiry_delete_queued_at?"delete_queued":Number.isFinite(p)&&Date.now()>=p?"delete_due":u&&Date.now()>=new Date(u).getTime()?"final_warning":"warning",deleteAfter:i,supportFreeUntil:s.effective_support_free_until}}function yt(s){if(s.stripe_subscription_id||!Object.prototype.hasOwnProperty.call(s,"effective_support_free_until"))return null;const a=s.effective_support_free_until?Date.parse(s.effective_support_free_until):Number.NaN;if(!Number.isFinite(a)||Date.now()>=a)return{stage:"lapsed",firstWarningAt:null,finalWarningAt:null,supportFreeUntil:s.effective_support_free_until||null};const i=bt(s.effective_support_free_until,5);if(!i)return null;const u=bt(s.effective_support_free_until,3);return{stage:u&&Kt(u)?"warning":"final_warning",firstWarningAt:i,finalWarningAt:u,supportFreeUntil:s.effective_support_free_until}}function Za(s){return s.recurring_support_enabled?s.recurring_support_fee>=pe({useManagedOpik:!0})?"Metering included":"Bring your own Opik":"No managed metering"}function kn(s){const a=yt(s);return(a==null?void 0:a.stage)==="lapsed"?`Maintenance expired · ${Cn(a.supportFreeUntil)}`:s.recurring_support_enabled?`${j(s.recurring_support_fee)}/mo`:"Self-supported"}function Xa(s){const a=yt(s);return a?a.stage==="lapsed"?{label:"Maintenance expired",variant:"destructive",className:""}:a.stage==="final_warning"?{label:s.support_expiry_final_warning_sent_at?"T-3 notice sent":"T-3 warning",variant:"destructive",className:""}:{label:s.support_expiry_warning_sent_at?"T-5 notice sent":"T-5 warning",variant:"outline",className:"border-amber-500/40 text-amber-800 dark:text-amber-200"}:null}function Ua(s){return s.version||"Unknown"}function Xl(s){return s.installer_release_current||s.installer_release||""}function qa(s){return Xl(s)||"Unknown"}function Cs(s){return s.reconnect_required===!0||or(s)}function Qa(s){return Cs(s)?!0:s.agent_install_status==="Installed"&&s.agent_status==="Connected"}function er(s){const a=!!s.dashboard_url||!!(s.last_seen_at&&!/^(Never|Awaiting first writeback)$/i.test(s.last_seen_at)),i=/running/i.test(s.runtime_status)&&Nn(s.runtime_health),u=/loaded/i.test(s.service_load_status)&&Nn(s.runtime_health);return a&&(i||u)}function xl(){return e.jsx(jl,{children:e.jsxs(wl,{children:[e.jsx(kl,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex text-muted-foreground transition-colors hover:text-foreground","aria-label":"What is Email OTP?",children:e.jsx(md,{className:"h-4 w-4"})})}),e.jsx(Nl,{className:"max-w-xs text-sm",children:"Email OTP means email one-time password. Users receive a one-time login code by email when they sign in."})]})})}const gl={clawmax:"1.4.5",clawmaxCli:"1.4.5"},Ld="<ONPREM_INSTANCE_KEY>",Ud="<DEPLOYMENT_ACTIONS_WORKER_KEY>",cs="https://www.clawmax.ai";function qd(s){return s?"Active":"Pending"}function Fd(s,a){return s>0||a>
210?"Active":"Not started"}function tr(s){if(!s)return"";const a=s.toLowerCase().replace(/^v/,"").trim();if(!a||a==="unknown"||a==="n/a"||a==="not yet")return"";const i=a.match(/(\d+\.\d+\.\d+)/);return(i==null?void 0:i[1])||a}function Ql(s,a){const i=tr(s),u=tr(a);return!i||!u?!1:i!==u}function eo(s){return s?s==="podman-compose"?"the requested Podman runtime":s==="kubernetes"?"the requested Kubernetes runtime":`the requested ${s} runtime`:"the requested runtime target"}function fl(s){return(s==null?void 0:s.instance_key)||(s==null?void 0:s.id)||""}function _l(s){return s==="homebrew"||s==="manual"}async function Ss(s,a){if(!s){x.error("Sign in to manage payment methods");return}try{const i=await O("/api/client/stripe/billing-portal",{accessToken:s,method:"POST",body:JSON.stringify({customer_id:(a==null?void 0:a.customerId)||null,mode:(a==null?void 0:a.mode)||(a!=null&&a.paymentMethodReady?"payment_method_update":"payment_method_setup"),return_path:(a==null?void 0:a.returnPath)||"/client/profile",target_type:(a==null?void 0:a.targetType)||null,target_id:(a==null?void 0:a.targetId)||null})});typeof window<"u"&&window.location.assign(i.url)}catch(i){x.error("Failed to open Stripe billing",{description:i instanceof Error?i.message:"Unexpected error"})}}async function Fa(s,a){if(!s||!(a!=null&&a.targetId))throw new Error("Sign in to manage recurring maintenance");return O("/api/client/maintenance-subscription",{accessToken:s,method:"POST",body:JSON.stringify({action:a.action,customer_id:a.customerId||null,target_type:a.targetType,target_id:a.targetId})})}async function Kd(s,a){if(!s)throw new Error("Sign in to confirm billing");return O("/api/client/stripe/confirm-payment-method",{accessToken:s,method:"POST",body:JSON.stringify({customer_id:(a==null?void 0:a.customerId)||null,target_type:(a==null?void 0:a.targetType)||null,target_id:(a==null?void 0:a.targetId)||null,session_id:(a==null?void 0:a.sessionId)||null})})}function cr(s,a){return s==="link"?"Stripe Link":s&&a?`${s.toUpperCase()} •••• ${a}`:s?s.toUpperCase():a?`Card •••• ${a}`:"Saved billing method"}function $t({accessToken:s,customerId:a,customer:i,triggerLabel:u,triggerVariant:p="outline",triggerSize:h="default",returnPath:v="/client/profile",targetType:z,targetId:X}){const[he,De]=d.useState(!1),[$e,H]=d.useState(!1),[Le,Re]=d.useState(!1),ie=!!(i!=null&&i.stripe_payment_method_ready),P=u||(ie?"View billing":"Set up billing"),ve=ie?cr(i==null?void 0:i.stripe_default_payment_method_brand,i==null?void 0:i.stripe_default_payment_method_last4):"No saved payment method yet.",nt=async()=>{H(!0);try{await Ss(s,{customerId:a,paymentMethodReady:ie,returnPath:v,targetType:z,targetId:X})}finally{H(!1)}},Ue=async()=>{H(!0);try{await Ss(s,{mode:"subscription_cancel",customerId:a,paymentMethodReady:!0,returnPath:v,targetType:z,targetId:X}),Re(!1)}finally{H(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(ft,{open:he,onOpenChange:De,children:[e.jsx(us,{asChild:!0,children:e.jsxs(b,{type:"button",variant:p,size:h,children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),P]})}),e.jsxs(_t,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-xl",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:ie?"Billing":"Set up billing"}),e.jsx(tt,{children:ie?"Review the saved billing method for this account and open Stripe when you need to update billing or manage subscriptions.":"Add a saved billing method in Stripe so setup charges and recurring maintenance can be handled from this account."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-border px-3 py-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Primary billing method"}),e.jsx(M,{variant:ie?"default":"outline",children:ie?"Billing method on file":"Billing not set up"})]}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:ve}),e.jsx("div",{className:"mt-2 text-muted-foreground",children:ie?"This saved Stripe billing method will be used for setup charges and recurring maintenance when those charges apply.":"Set up billing now so you are ready when you need setup charges or recurring maintenance."})]}),e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground",children:"ClawMax keeps the billing summary here. Stripe handles secure card entry and subscription changes when you choose to continue there."})]}),e.jsxs(st,{className:"flex-col-reverse gap-2 sm:flex-row sm:justify-between",children:[e.jsxs("div",{className:"flex w-full flex-col-reverse gap-2 sm:w-auto 
21sm:flex-row",children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>De(!1),children:"Close"}),ie?e.jsx(b,{type:"button",variant:"destructive",onClick:()=>Re(!0),children:"Cancel billing"}):null]}),e.jsx(b,{type:"button",onClick:()=>void nt(),disabled:$e,children:$e?"Opening…":ie?"Open Stripe billing":"Set up billing in Stripe"})]})]})]}),e.jsx(ms,{open:Le,onOpenChange:Re,children:e.jsxs(ps,{children:[e.jsxs(hs,{children:[e.jsx(xs,{children:"Cancel billing in Stripe?"}),e.jsx(gs,{children:"If you cancel recurring billing in Stripe, covered cloud or on-prem deployments can lose ClawMax maintenance after their paid-through period ends. Continue only if you want to manage that cancellation in Stripe now."})]}),e.jsxs(fs,{children:[e.jsx(_s,{disabled:$e,children:"Keep billing"}),e.jsx(ys,{onClick:()=>void Ue(),disabled:$e,children:$e?"Opening…":"Open Stripe to cancel"})]})]})})]})}function Ka({accessToken:s,customerId:a,customer:i,compact:u=!1}){const p=!!(i!=null&&i.stripe_payment_method_ready);return e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("div",{className:"font-medium text-foreground",children:p?"Need to review billing?":"Need to set up billing?"}),e.jsx("div",{className:"mt-1",children:p?"Open billing to review the saved card or continue into Stripe if you need to change billing details.":"Open billing now to add a saved card before you continue."}),e.jsx("div",{className:u?"mt-2":"mt-3",children:e.jsx($t,{accessToken:s,customerId:a,customer:i||null,triggerLabel:p?"View billing":"Set up billing",triggerVariant:"outline",triggerSize:u?"sm":"default",returnPath:"/client/profile"})})]})}function _n({kind:s,onAction:a,onDelete:i,onOpenCloudOpikSettings:u,onOpenOnPremOpikSettings:p,maintenanceLocked:h=!1}){return e.jsxs(td,{children:[e.jsx(sd,{asChild:!0,children:e.jsxs(b,{variant:"outline",size:"sm",className:"h-8 w-8 p-0",children:[e.jsx(id,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Open actions"})]})}),e.jsxs(nd,{align:"end",children:[s==="cloud"?e.jsxs(e.Fragment,{children:[e.jsxs(ht,{onSelect:()=>a==null?void 0:a("restart_instance"),children:[e.jsx(Di,{className:"mr-2 h-4 w-4"}),"Restart"]}),u?e.jsxs(ht,{onSelect:u,children:[e.jsx(Lt,{className:"mr-2 h-4 w-4"}),"Opik settings"]}):null]}):e.jsx(e.Fragment,{children:h?e.jsxs(ht,{disabled:!0,children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),"Restart maintenance first"]}):e.jsxs(e.Fragment,{children:[e.jsxs(ht,{onSelect:()=>a==null?void 0:a("restart_agent"),children:[e.jsx(Di,{className:"mr-2 h-4 w-4"}),"Restart agent"]}),e.jsxs(ht,{onSelect:()=>a==null?void 0:a("request_support_bundle"),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Submit support bundle"]}),p?e.jsxs(ht,{onSelect:p,children:[e.jsx(Lt,{className:"mr-2 h-4 w-4"}),"Opik settings"]}):null]})}),i?e.jsxs(e.Fragment,{children:[e.jsx(ad,{}),e.jsxs(ht,{onSelect:i,className:"text-destructive focus:text-destructive",children:[e.jsx(Ml,{className:"mr-2 h-4 w-4"}),"Delete deployment"]})]}):null]})]})}function yn(s,a,i){const p={restart_instance:{title:`Restart requested for ${i}`,description:"The request is acknowledged. Live restart wiring may still take time when enabled."},restart_agent:{title:`Agent restart requested for ${i}`,description:"This maps to the queued `clawmax agent restart` lifecycle action."},request_support_bundle:{title:`Support bundle submission started for ${i}`,description:"ClawMax will collect the local support bundle on the connected Mac and submit the result back here."},update_opik_settings:{title:`Opik settings update requested for ${i}`,description:`The request is acknowledged and will be applied through the next ${s==="cloud"?"cloud":"on-prem"} reconcile.`}}[a];p&&x.success(p.title,{description:p.description})}const Xe=({title:s,value:a,subtitle:i})=>e.jsxs(K,{className:"h-full",children:[e.jsxs(te,{className:"pb-1 pt-5",children:[e.jsx(ne,{children:s}),e.jsx(se,{className:"text-2xl sm:text-3xl",children:a})]}),e.jsx(B,{className:"pt-0 pb-5",children:e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:i})})]}),bn=({productLabel:s,inviteUrl:a,unlocked:i,extraNote:u,className:p})=>e.jsxs(K,{className:J("flex h-full flex-col",p),children:[e.jsxs(te,{children:[e.jsx(se,{children:"WhatsApp support"}),e.jsxs(ne,{children:[s," customers can join the dedicated support group for faster help and rollout updates."]})]}),e.jsx(B,{className:"flex flex-1 flex-col gap-3",children:i?a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-950 dark:text-emerald-100",children:["Your ",s.toLowerCase()," support group is ready."]}),u?e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:u}):null]}),e.jsx(b,{asChild:!0,className:"mt-auto w-full justify-start",children:e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(vl,{className:"mr-2 h-4 w-4"}),"Join WhatsApp support group"]})})]}):e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:"WhatsApp support is included. Add the invite URL for this product and the join button will appear here automatically."}):e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:["This invite appears after your first active ",s.toLowerCase()," deployment or package is on your account."]})})]});function Se({text:s,label:a}){const[i,u]=d.useState(!1),p=()=>{navigator.clipboard.writeText(s).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)})};return e.jsx("button",{type:"button",onClick:p,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-slate-700 bg-slate-800 px-1.5 py-1 text-slate-400 transition-colors hover:bg-slate-700 hover:text-slate-200","aria-label":a||"Copy",children:i?e.jsx(Cl,{className:"h-3 w-3 text-green-400"}):e.jsx(Il,{className:"h-3 w-3"})})}function Ba({title:s,description:a,commands:i,notes:u,downloadUrl:p}){const[h,v]=d.useState(!1),z=()=>{const X=i.filter(he=>he.trim()&&!he.trim().startsWith("#")).join(`
22`);navigator.clipboard.writeText(X).then(()=>{v(!0),setTimeout(()=>v(!1),2e3)})};return e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsx(se,{children:s}),e.jsx(ne,{children:a})]}),e.jsxs(B,{className:"space-y-4",children:[p?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 rounded-md border border-primary/30 bg-primary/5 px-4 py-2.5 text-sm font-medium text-primary transition-colors hover:bg-primary/10",children:[e.jsx(ye,{className:"h-4 w-4"}),"Download latest agent CLI from GitHub",e.jsx(Oe,{className:"h-3.5 w-3.5 opacity-60"})]}):null,e.jsxs("div",{className:"relative rounded-md border border-border bg-slate-950 p-4 font-mono text-xs text-slate-100",children:[e.jsx("button",{type:"button",onClick:z,className:"absolute right-3 top-3 rounded-md border border-slate-700 bg-slate-800 p-1.5 text-slate-400 transition-colors hover:bg-slate-700 hover:text-slate-200","aria-label":"Copy all commands",children:h?e.jsx(Cl,{className:"h-3.5 w-3.5 text-green-400"}):e.jsx(Il,{className:"h-3.5 w-3.5"})}),e.jsx("pre",{className:"whitespace-pre-wrap pr-10",children:i.join(`
23`)})]}),e.jsx("div",{className:"space-y-2",children:u.map(X=>e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{children:X.text}),X.command?e.jsx("code",{className:"ml-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:X.command}):null]}),X.command?e.jsx(Se,{text:X.command,label:`Copy: ${X.command}`}):null]},X.text))})]})]})}const gc={resolveTargetCustomerIdForBilling:Pl,currency:j,currencyFromCents:El,getOnPremSupportPackageMonthsFromSearch:Rl,getEnterpriseIncludedInstancesFromSearch:Al,formatRelativeTime:Tl,getActionTimestamp:qt,getScheduledRetryLabel:za,get
23ScheduledMaintenanceNote:vs,formatDateTime:be,formatMaintenanceBehind:Cn,getBillingEventStatusVariant:Dl,getLatestPendingAction:ks,isNonBlockingOnPremPendingAction:$l,getLatestDisplayPendingAction:vn,getActionDisplayLabel:Ll,getClientInstanceActionPresentation:js,hasOnPremPendingFirstWriteback:Ul,isOnPremDashboardReady:Ms,getOnPremFirstConnectPresentation:jn,getOnPremModelHeadline:Ha,getOnPremTrayRecoveryGuidance:ql,statusBadgeVariant:Sn,isCloudPublicUrlReady:Ns,sanitizeClientPlacementReason:Fl,normalizeCloudFromApi:Kl,normalizeOnPremInstallMethod:lr,inferOnPremReconnectRequired:or,resolveOnPremInstallMethod:Pn,getPreferredOnPremInstallTab:Va,getOnPremInstallMethodSummary:Bl,getOnPremAlternateInstallTabs:Wl,normalizeOnPremFromApi:On,isExternalDashboardUrl:Ft,getOnPremDashboardHref:zl,canSyncOnPremStatus:Tt,didOnPremStatusAdvance:Vl,mergeSelectedOnPremRecord:Yl,mergeOnPremRowAccessFields:Ya,isFutureDate:Kt,getCloudRecurringSupportLabel:Dt,getOnPremRecurringSupportLabel:Gl,getCloudRecurringSupportCharge:ws,getCloudMeteringLabel:Jl,getCloudModelBillingLabel:Ga,getCloudPromotionPill:wn,addHours:dr,subtractDays:bt,getSupportExpiryPill:Ja,getCloudSupportExpiryNotice:Zl,getOnPremSupportExpiryNotice:yt,getOnPremMeteringLabel:Za,getOnPremMaintenanceLabel:kn,getOnPremSupportExpiryPill:Xa,getOnPremAgentVersionSource:Xl,isOnPremReconnectRequired:Cs,shouldShowOnPremReconnectRowCta:Qa,isLikelyActiveOnPremRecord:er,getClientPlanLabel:qd,getClientHealthLabel:Fd,normalizeReleaseVersion:tr,hasRuntimeReleaseMismatch:Ql,describeRuntimeTarget:eo,formatClientPaymentMethodLabel:cr},fc=()=>{var ki,Ni;const{session:s,profile:a}=Ho(),i=Vo(),u=((ki=s==null?void 0:s.user)==null?void 0:ki.email)||(a==null?void 0:a.email)||"",p=Yo(),h=Go(),v=h.pathname==="/client/profile"||h.pathname==="/terms"?"profile":h.pathname==="/client/enterprise"?"enterprise":h.pathname==="/client/feedback"?"feedback":h.pathname==="/client/onprem"||h.pathname==="/client/actions"?"onprem":"cloud",z=Rl(h.search),X=Al(h.search),he=((Ni=new URLSearchParams(h.search).get("promotion_code"))==null?void 0:Ni.trim().toUpperCase())||"",De=(a==null?void 0:a.full_name)||"Customer",$e=a!=null&&a.terms_accepted_at?new Date(a.terms_accepted_at).toLocaleString():"Not yet accepted",[H,Le]=d.useState(()=>Aa(sl)),[Re,ie]=d.useState(""),[P,ve]=d.useState(()=>Aa(rl)),[nt,Ue]=d.useState(""),[to,Bt]=d.useState(null),[U,ur]=d.useState(null),[Me,mr]=d.useState(!1),[so,En]=d.useState(!1),[k,ae]=d.useState({siteName:"",supportPackageMonths:z,modelProvider:"BYOK",promotionCode:"",dashboardAuthMode:"bypass",otpAllowedEmails:u,useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:"",workspaceBackupIds:[]}),[no,Rn]=d.useState(!1),[pr,An]=d.useState(!1),Is=d.useRef(!1),vt=d.useRef(null),Ps=d.useRef(!1),Es=d.useRef(null),[hr,Rs]=d.useState(!1),[Tn,Wt]=d.useState(!1),[Ie,je]=d.useState("installer"),[at,jt]=d.useState(()=>Da(il,!1)),[zt,rt]=d.useState(()=>Da(ll,!1)),[ao,As]=d.useState(!1),[ro,io]=d.useState(!1),[lo,Ts]=d.useState(!1),[xr,Ds]=d.useState(!1),Ht=d.useRef(!1),wt=d.useRef(null),Dn=d.useRef(!1),$s=d.useRef(null),[gr,$n]=d.useState(!1),[Ln,kt]=d.useState(!1),[oo,Ls]=d.useState(!1),[we,Un]=d.useState(Sl),[fr,_r]=d.useState(!1),[yr,br]=d.useState(!1),qn=d.useRef(!1),[q,Pe]=d.useState({promotionCode:"",enterpriseName:"",enterpriseWebsiteUrl:""}),[co,Fn]=d.useState(!1),[vr,jr]=d.useState(!1),[qe,it]=d.useState([]),[Kn,Bn]=d.useState(null),[Wn,wr]=d.useState(!1),[kr,zn]=d.useState(null),[Nr,Vt]=d.useState([]),[lt,Us]=d.useState([]),[Hn,Cr]=d.useState({}),[Yt,Nt]=d.useState(null),[me,qs]=d.useState({maxInstances:5,usageDays:1,accessStartsAt:Cd(),promotionCode:""}),[C,re]=d.useState({displayName:"",region:"nyc1",promotionCode:"",dashboardAuthMode:"email_otp",otpAllowedEmails:u,useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:"",workspaceBackupIds:[]}),[Sr,Vn]=d.useState([]),[ot,Yn]=d.useState(!1),[Gn,Jn]=d.useState([]),[dt,Zn]=d.useState([]),[c,Fs]=d.useState(null),[Xn,Ks]=d.useState([]),[g,Bs]=d.useState(()=>{var t;if(typeof window<"u"){const n=(t=new URLSearchParams(window.location.search).get("customerId"))==null?void 0:t.trim();if(n)return n}return Aa(ol)}),[Or,Qn]=d.useState([]),[ea,Mr]=d.useState(""),[Ir,Pr]=d.useState(!1),[Er,Rr]=d.useState(!1),[Ar,Tr]=d.useState(null),[Ae,ta]=d.useState([]),[Dr,sa]=d.use
23State([]),[$r,na]=d.useState(!1),[aa,ct]=d.useState(0),[Lr,Fe]=d.useState(0),[Te,Ee]=d.useState(0),Ur=d.useRef(null),[ra,qr]=d.useState(""),[ia,Gt]=d.useState(()=>Md(nl)),[ut,Ws]=d.useState(()=>Da(al,!1)),Fr=d.useRef(!1),la=d.useRef(!1),[Ct,oa]=d.useState(!1),[Kr,da]=d.useState(!1),[Jt,Br]=d.useState(""),[A,St]=d.useState(null),[Wr,ca]=d.useState(""),[ua,zr]=d.useState(!1),[S,zs]=d.useState(null),[Ot,Hs]=d.useState(null),[ke,Hr]=d.useState(null),[xe,Vs]=d.useState(null),[Q,Ke]=d.useState({useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""}),[Ys,Vr]=d.useState(!1),[ge,Gs]=d.useState(null),[ee,Be]=d.useState({useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""}),[Js,Yr]=d.useState(!1),[uo,Zt]=d.useState(!1),Gr=d.useRef(null),[ma,Jr]=d.useState([]),Zr=new Set(ma.filter(t=>!dt.some(n=>n.id===t.id)).map(t=>t.id)),F=d.useMemo(()=>[...dt,...ma.filter(t=>!dt.some(n=>n.id===t.id))],[dt,ma]),w=dt.find(t=>t.id===H)??null,Xr=Gn.find(t=>t.id===P)??null,f=Yl(Xr,to,P),E=Xr??f,oe=E?jn(E):null,Zs=(f==null?void 0:f.instance_key)||Ld,Xs=(f==null?void 0:f.deployment_worker_key)||Ud,Qr=(U==null?void 0:U.tray_command_token)||`/Applications/ClawMax.app/Contents/MacOS/ClawMax --bootstrap-token "<BOOTSTRAP_TOKEN>" --bootstrap-api-url "${cs}"`,ei=(U==null?void 0:U.tray_command_url)||'/Applications/ClawMax.app/Contents/MacOS/ClawMax --bootstrap-url "<SIGNED_BOOTSTRAP_URL>"',Qs=U!=null&&U.bootstrap_token?`clawmax://bootstrap?token=${encodeURIComponent(U.bootstrap_token)}`:"clawmax://bootstrap?token=<BOOTSTRAP_TOKEN>",mo=t=>`clawmax://disconnect?instance_key=${encodeURIComponent(t)}`,ti=f?Ql(f.version,f.target_release):!1,Xt=Va(f),si=Bl(f),Mt=Wl(f),mt=f?Cs(f):!1,po=Mt.showHomebrew||Mt.showManual,en=Mt.showHomebrew,tn=Mt.showManual,ho=Mt.installMethod==="homebrew"?"Homebrew install path":Mt.installMethod==="manual"?"Manual install path":"Other install methods",sn=Xn.find(t=>t.id===g)||c,y=sn||c,pa=v==="onprem"&&f?"onprem_instance":v==="cloud"&&w?"cloud_instance":null,ha=v==="onprem"&&f?f.billing_target_id||f.id:v==="cloud"&&w?w.billing_target_id||w.id:null,de=((c==null?void 0:c.access_role)||(sn==null?void 0:sn.access_role))==="owner";let le=null,ni="";try{le=bd({maxInstances:me.maxInstances,usageDays:me.usageDays,accessStartsAt:me.accessStartsAt?new Date(me.accessStartsAt).toISOString():""})}catch(t){ni=t instanceof Error?t.message:"Invalid reservation"}const ai=d.useRef(null);d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t){Zn([]),ta([]),oa(!1);return}let n=!1;return(async()=>{try{const[l,m]=await Promise.all([O(L("/api/client/cloud-instances?pageSize=100",g),{accessToken:t}),O(L("/api/client/deployment-actions?pageSize=100",g),{accessToken:t})]);n||(Zn((Array.isArray(l.cloud_instances)?l.cloud_instances:[]).map(Kl)),ta(Array.isArray(m.deployment_actions)?m.deployment_actions:[]),oa(!0))}catch{n||(Zn([]),ta([]),oa(!0))}})(),()=>{n=!0}},[aa,Te,g,s==null?void 0:s.access_token]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t){Vn([]),Yn(!1);return}let n=!1;return O(L("/api/client/workspace-backups",g),{accessToken:t}).then(r=>{n||(Yn(r.enabled===!0),Vn(Array.isArray(r.workspace_backups)?r.workspace_backups:[]))}).catch(()=>{n||(Yn(!1),Vn([]))}),()=>{n=!0}},[aa,Lr,g,s==null?void 0:s.access_token]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t||!pa||!ha){sa([]),na(!1);return}let n=!1;return(async()=>{na(!0);try{const l=new URLSearchParams({targetType:pa,targetId:ha}),m=await O(L(`/api/client/billing-events?${l.toString()}`,g),{accessToken:t});n||sa(Array.isArray(m.billing_events)?m.billing_events:[])}catch{n||sa([])}finally{n||na(!1)}})(),()=>{n=!0}},[Te,aa,ha,pa,g,s==null?void 0:s.access_token]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t||!P){Bt(null);return}let n=!1;return(async()=>{try{const l=await O(L(`/api/client/onprem-instances/${encodeURIComponent(P)}`,g),{accessToken:t});n||Bt(pl(l))}catch{n||Bt(null)}})(),()=>{n=!0}},[g,P,s==null?void 0:s.access_token,Te]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t){Fs(null),Ks([]);return}let n=!1;return(async()=>{try{const l=await O(L("/api/client/account",g),{accessToken:t});n||(Fs(l.customer||null),Ks(Array.isArray(l.accessible_customers)?l.accessible_customers:[]),l.active_customer_id&&l.active_customer_id!==g&&Bs(l.active_customer_id))}catch{n||(Fs(null),Ks([]))}})(),()=>{n=!0}},[h.search,g,s==null?void 0:s.access_token,Te]),d.useEffect(()=>{var n;const t=((n=new URLSearchParams(h.search).get("customerId"))==null?void 0:n.trim())||null;t&&t!==g&&Bs(t)},[h.search,g]),d.useEffect(()=>{g&&Ta(ol,g)},[g]),d.useEffect(()=>{var o,_,N,$;const t=new URLSearchParams(h.search),n=((o=t.get("reconnect_token"))==null?void 0:o.trim())||null,r=((_=t.get("instanceId"))==null?void 0:_.trim())||null,l=((N=t.get("customerId"))==null?void 0:N.trim())||null;if(!(s!=null&&s.access_token)||!n||ai.current===n||l&&g&&l!==g)return;ai.current=n,r&&r!==P&&ve(r),r&&(Ue(""),jt(!0),rt(!0),je("installer")),t.delete("reconnect_token");const m=t.toString();typeof window<"u"&&typeof(($=window.history)==null?void 0:$.replaceState)=="function"&&window.history.replaceState({},"",`${h.pathname}${m?`?${m}`:""}${h.hash}`),Ze(`clawmax://bootstrap?token=${encodeURIComponent(n)}`),x.success("Opening ClawMax reconnect flow",{description:"If ClawMax is installed, the reconnect deep link should open the app automatically."})},[h.hash,h.pathname,h.search,g,P,s==null?void 0:s.access_token]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t||!g){Qn([]);return}let n=!1;return(async()=>{try{const l=await O(L("/api/client/customer-members",g),{accessToken:t});n||Qn(Array.isArray(l.customer_members)?l.customer_members:[])}catch{n||Qn([])}})(),()=>{n=!0}},[g,s==null?void 0:s.access_token,Te]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t||!g||!["enterprise","cloud"].includes(v)){it([]);return}let n=!1;return(async()=>{const l=new URLSearchParams(h.search),m=l.get("reservation_id");return l.get("event_checkout")==="cancelled"&&m&&(x.success("Request saved",{description:"You can complete payment later or cancel the request below."}),n||(l.delete("event_checkout"),l.delete("reservation_id"),l.delete("customerId"),p({pathname:h.pathname,search:l.toString()},{replace:!0}))),O(L("/api/client/enterprise-burst-reservations",g),{accessToken:t})})().then(l=>{n||it(Array.isArray(l.reservations)?l.reservations:[])}).catch(()=>{n||it([])}),()=>{n=!0}},[Te,v,g,s==null?void 0:s.access_token,h.search,h.pathname,p]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t||!["enterprise","cloud"].includes(v)){Vt([]),Us([]);return}let n=!1;return O("/api/client/enterprise-burst-invitations?scope=mine",{accessToken:t}).then(r=>{n||Us(Array.isArray(r.invitations)?r.invitations:[])}).catch(()=>{n||Us([])}),g&&de?O(L("/api/client/enterprise-burst-invitations",g),{accessToken:t}).then(r=>{n||Vt(Array.isArray(r.invitations)?r.invitations:[])}).catch(()=>{n||Vt([])}):Vt([]),()=>{n=!0}},[de,Te,v,g,s==null?void 0:s.access_token]),d.useEffect(()=>{let t=!1;Jr([]);const n=s==null?void 0:s.access_token;if(!n||!["cloud","enterprise"].includes(v))return;const r=[...new Set(lt.filter(l=>{var m;return l.status==="accepted"&&l.access_delivery!=="pending_update"&&l.access_delivery!=="revoked"&&["ready","active"].includes(((m=l.reservation)==null?void 0:m.status)||"")}).map(l=>l.reservation_id))];return Promise.all(r.map(async l=>{try{return((await O(`/api/client/enterprise-event-instances?reservation_id=${encodeURIComponent(l)}`,{accessToken:n})).instances||[]).filter(o=>{try{const _=new URL(o.public_origin);return _.protocol==="https:"&&_.origin===o.public_origin&&!_.port&&_.hostname.endsWith(".cloud.clawmax.ai")}catch{return!1}}).map(o=>({id:o.instance_key||o.cloud_instance_id,billing_target_id:o.cloud_instance_id,customer:"Enterprise event",provider:"Civo",billing_mode:"ClawMax cloud",model_provider:"OpenAI",credential_mode:"BYOK",model_name:"",region:"",plan:"Enterprise",version:o.dashboard_release||"",status:"Running",cpu_load:"",memory_load:"",monthly_cost:0,model_monthly_cost:0,setup_fee:0,recurring_support_enabled:!1,recurring_support_fee:0,uptime:"",last_restart_at:"",last_deploy_at:"",service_url:o.public_origin,public_url_ready:!0,tags:["enterprise","event"]}))}catch{return[]}})).then(l=>{t||Jr([...new Map(l.flat().map(m=>[m.id,m])).values()])}),()=>{t=!0}},[lt,s==null?void 0:s.access_token,v,Te]),d.useEffect(()=>{const t=s==null?void 0:s.access_token;if(!t){da(!1);return}let n=!1;return(async()=>{try{const l=await O(L("/api/client/onprem-instances?pageSize=100",g),{accessToken:t});n||(Jn((Array.isArray(l.onprem_instances)?l.onprem_instances:[]).map(m=>On(m,m.customer_name||De))),da(!0))}catch{n||(Jn([]),da(!0))}})(),()=>{n=!0}},[De,g,s==null?void 0:s.access_token,Lr,Te]);const D=Gn,pt=D.length>0,V=E?er(E):!1,ri=f?f.agent_install_status==="Installed"||V:!1,It=E?D.filter(t=>t.id!==E.id&&er(t)):[],We=It[0]??null,xa=It.length,ii=dt.filter(t=>t.plan==="Enterprise"),xo=(c==null?void 0:c.plan_label)==="Enterprise"&&c.managed_instance_limit>0?Ki(c.managed_instance_limit):0,li=ii.length?Ki(Math.max(ii.length,we)):xo,ze=li>0,Qt=ze?li:we,ga=ze?dt.length+D.length:0,nn=ze?Math.max(0,Qt-ga):0,go=!!(c!=null&&c.enterprise_support_free_until&&!Number.isNaN(Date.parse(c.enterprise_support_free_until))&&Date.parse(c.enterprise_support_free_until)>Date.now()),Pt=ze&&nn>0&&go,oi=Bi(Qt),an=Bi(we),fa=(c==null?void 0:c.cloud_replacement_slots_available)||0,_a=(c==null?void 0:c.onprem_replacement_slots_available)||0,ya=fa>0,ba=_a>0,rn=!Ln&&!ya&&(!Pt||!!C.promotionCode.trim()),ln=!Tn&&!ba&&(!Pt||!!k.promotionCode.trim()),fo=F.length>0,_o=D.length>0,va=ra.trim().toLowerCase(),Ne=va?F.filter(t=>[t.id,t.region,t.provider,t.billing_mode,t.model_provider,t.credential_mode,t.model_name,t.status,...t.tags||[]].some(n=>n==null?void 0:n.toLowerCase().includes(va))):F,on=Math.max(1,Math.ceil(Ne.length/gt)),ce=Math.min(ia,on),dn=Ne.slice((ce-1)*gt,ce*gt),es=F.length+D.length,yo=F.reduce((t,n)=>t+n.setup_fee,0)+D.reduce((t,n)=>t+n.setup_fee,0),di=F.reduce((t,n)=>{const r=ws(n);return t+n.monthly_cost+n.model_monthly_cost+r},0)+D.reduce((t,n)=>{const r=n.recurring_support_enabled?n.recurring_support_fee:0;return t+n.model_monthly_cost+r},0),ci=F.filter(t=>!!wn(t)).length,bo=v==="onprem"?D.length:v==="cloud"?F.length:es,ja=F.filter(t=>/degraded/i.test(t.status)).length+D.filter(t=>/degraded/i.test(t.runtime_status)).length,vo=v==="onprem"?"On-prem instances":v==="cloud"?"Cloud instances":"Instances",jo=ja>0?`${ja} degraded · ${F.length} cloud · ${D.length} on-prem · ${es} total`:v==="onprem"?`${es} total including ${F.length} cloud`:v==="cloud"?`${es} total including ${D.length} on-prem`:`${F.length} cloud · ${D.length} on-prem · ${es} total`,ui=Ae.some(t=>t.status==="scheduled"||t.status==="queued"||t.status==="started")||F.some(t=>/restarting|pending cleanup/i.test(t.status))||D.some(t=>/restarting|pending cleanup/i.test(t.runtime_status))||v==="onprem"||["enterprise","cloud"].includes(v)&&lt.some(t=>{var n;return t.status==="accepted"&&["ready","active"].includes(((n=t.reservation)==null?void 0:n.status)||"")})||["enterprise","cloud"].includes(v)&&[...lt,...Nr].some(t=>t.status==="accepted"&&t.access_delivery==="pending_update")||["enterprise","cloud"].includes(v)&&qe.some(t=>["paid_preparing","deleting"].includes(t.status)),wa=(t,n)=>{const r=Sa(t.billing_target_id,qe);if(r&&!(/running/i.test(t.status)&&t.public_url_ready===!0)){const l=qe.flatMap(m=>m.runtime_observations||[]).find(m=>m.instance_id===t.billing_target_id);return{label:r,variant:"outline",className:"border-primary/40 bg-primary/10 text-primary",detail
23:r.startsWith("Runtime verified")&&l?`Worker verified runtime ${be(l.verified_at)} · OTP access is separate`:"Event batch status · individual runtime readiness is not yet verified"}}return js(t.status,n)};d.useEffect(()=>{if(!(s!=null&&s.access_token)||!ui)return;const t=v==="onprem"?wd:jd,n=window.setInterval(()=>{document.visibilityState!=="hidden"&&Ee(r=>r+1)},t);return()=>{window.clearInterval(n)}},[v,s==null?void 0:s.access_token,ui]),d.useEffect(()=>{if(!Fr.current){Fr.current=!0;return}Gt(1)},[va]),d.useEffect(()=>{Ct&&ia!==ce&&Gt(ce)},[ia,ce,Ct]),d.useEffect(()=>{Ta(sl,H)},[H]),d.useEffect(()=>{Ct&&Id(nl,ce)},[ce,Ct]),d.useEffect(()=>{$a(al,ut)},[ut]),d.useEffect(()=>{Ta(rl,P)},[P]),d.useEffect(()=>{$a(il,at)},[at]),d.useEffect(()=>{$a(ll,zt)},[zt]),d.useEffect(()=>{f&&je(Va(f))},[f]),d.useEffect(()=>{var t;if(Re){Ne.some(n=>n.id===Re)?ie(""):H!==Re&&Le(Re);return}if(Ct){if(!la.current&&H){const n=Ne.findIndex(r=>r.id===H);if(n>=0){const r=Math.floor(n/gt)+1;if(r!==ce){Gt(r);return}la.current=!0}else la.current=!0}H||Le(((t=dn[0])==null?void 0:t.id)??"")}},[ce,Ne,Ct,dn,Re,H]),d.useEffect(()=>{var t;if(nt){D.some(n=>n.id===nt)?Ue(""):P!==nt&&ve(nt);return}Kr&&(D.some(n=>n.id===P)||ve(((t=D[0])==null?void 0:t.id)??""))},[D,Kr,nt,P]),d.useEffect(()=>{ur(t=>(t==null?void 0:t.instance_id)===P||(t==null?void 0:t.instance_key)===P?t:null)},[P]);const ts=Jt.trim().toLowerCase(),ss=ts?D.filter(t=>[t.id,t.site,t.model_provider,t.agent_status,t.runtime_status,t.connectivity,t.remote_access].some(n=>n==null?void 0:n.toLowerCase().includes(ts))):D,cn=async t=>{var l,m;const n=s==null?void 0:s.access_token;if(!n){x.error("Sign in to manage recurring maintenance");return}const r=t.kind==="cloud"?((l=F.find(o=>o.id===t.id))==null?void 0:l.customer_id)||g||(c==null?void 0:c.id)||null:((m=D.find(o=>o.id===t.id))==null?void 0:m.customer_id)||g||(c==null?void 0:c.id)||null;zs({...t,action:"activate"});try{await Fa(n,{action:"activate",customerId:r,targetType:t.kind==="cloud"?"cloud_instance":"onprem_instance",targetId:t.id}),x.success("Recurring maintenance is active",{description:t.kind==="cloud"?"The selected cloud instance is now covered and charged monthly.":"The selected on-prem deployment is now covered and charged monthly."}),ct(o=>o+1),Fe(o=>o+1),Ee(o=>o+1)}catch(o){x.error("Failed to activate recurring maintenance",{description:o instanceof Error?o.message:"Unexpected error"})}finally{zs(null)}},wo=async t=>{var l,m;const n=s==null?void 0:s.access_token;if(!n){x.error("Sign in to manage recurring maintenance");return}const r=t.kind==="cloud"?((l=F.find(o=>o.id===t.id))==null?void 0:l.customer_id)||g||(c==null?void 0:c.id)||null:((m=D.find(o=>o.id===t.id))==null?void 0:m.customer_id)||g||(c==null?void 0:c.id)||null;zs({kind:t.kind,id:t.id,action:"cancel"});try{const o=await Fa(n,{action:"cancel",customerId:r,targetType:t.kind==="cloud"?"cloud_instance":"onprem_instance",targetId:t.id});x.success("Recurring maintenance will not renew",{description:o.covered_until?`${t.label} stays covered until ${be(o.covered_until)}.`:`${t.label} is back on its standard expiry schedule.`}),ct(_=>_+1),Fe(_=>_+1),Ee(_=>_+1)}catch(o){x.error("Failed to cancel recurring maintenance",{description:o instanceof Error?o.message:"Unexpected error"})}finally{zs(null),Hs(null)}},ko=async()=>{var n;const t=s==null?void 0:s.access_token;if(!(!t||!A)){zr(!0);try{A.kind==="cloud"?(await O(L(`/api/client/cloud-instance-actions?instanceId=${encodeURIComponent(A.id)}`,g),{accessToken:t,method:"POST",body:JSON.stringify({action:"delete_instance",customer_id:g||(c==null?void 0:c.id)||null,preserve_workspace:ot})}),x.success(`Delete requested for ${A.label}`,{description:ot?"The worker will verify an encrypted workspace backup before cleanup.":"The instance will disappear after the worker completes cleanup."}),ct(r=>r+1),H===A.id&&Le("")):(await O(L(`/api/client/onprem-instance-actions?instanceId=${encodeURIComponent(A.id)}`,g),{accessToken:t,method:"POST",body:JSON.stringify({action:"delete_instance",customer_id:g||(c==null?void 0:c.id)||null,preserve_workspace:ot})}),x.success(`Delete requested for ${A.label}`,{description:ot?"The local agent must verify an encrypted workspace backup before removing the deployment.":A.detail}),Fe(r=>r+1),P===A.id&&ve(((n=D[0])==null?void 0:n.id)??""))}catch(r){x.success(r instanceof Error?r.message:"Failed to delete instance")}finally{zr(!1),St(null),ca("")}}},mi=async(t,n)=>{var l;const r=s==null?void 0:s.access_token;if(!r){yn("cloud",t,n);return}try{const m=await O(L(`/api/client/cloud-instance-actions?instanceId=${encodeURIComponent(n)}`,g),{accessToken:r,method:"POST",body:JSON.stringify({action:t,customer_id:g||(c==null?void 0:c.id)||null})});x.success(m.message||`${n} ${t.replace(/_/g," ")} queued`,{description:((l=m.deployment_action)==null?void 0:l.action_description)||"The request was queued for the cloud worker."}),Fe(o=>o+1)}catch(m){x.error(`Failed to queue ${t.replace(/_/g," ")}`,{description:m instanceof Error?m.message:"Unexpected error"})}},pi=async(t,n)=>{var l;const r=s==null?void 0:s.access_token;if(!r){yn("onprem",t,n);return}try{const m=await O(L(`/api/client/onprem-instance-actions?instanceId=${encodeURIComponent(n)}`,g),{accessToken:r,method:"POST",body:JSON.stringify({action:t,customer_id:g||(c==null?void 0:c.id)||null})});x.success(m.message||`${n} ${t.replace(/_/g," ")} queued`,{description:((l=m.deployment_action)==null?void 0:l.action_description)||(t==="request_support_bundle"?"The connected Mac will collect a support bundle on the next reconcile and the result will appear in the console.":"The request was queued for the connected Mac.")}),Fe(o=>o+1),Ee(o=>o+1)}catch(m){x.error(`Failed to queue ${t.replace(/_/g," ")}`,{description:m instanceof Error?m.message:"Unexpected error"})}},hi=t=>{const n=t.recurring_support_fee>=_e({useManagedOpik:!0});Vs(t),Ke({useManagedOpik:n,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""})},No=async()=>{var n;const t=s==null?void 0:s.access_token;if(!t||!xe){yn("cloud","update_opik_settings",(xe==null?void 0:xe.id)||"cloud instance");return}if(!Q.useManagedOpik&&!Q.opikApiKey.trim()){x.error("Opik API key is required to use your own Opik");return}Vr(!0);try{const r=await O(L(`/api/client/cloud-instance-actions?instanceId=${encodeURIComponent(xe.id)}`,g),{accessToken:t,method:"POST",body:JSON.stringify({action:"queue_update",customer_id:g||(c==null?void 0:c.id)||null,request_variant:"update_opik_settings",use_managed_opik:Q.useManagedOpik,opik_api_key:Q.useManagedOpik?void 0:Q.opikApiKey||void 0,opik_workspace:Q.useManagedOpik?void 0:Q.opikWorkspace||void 0,opik_project:Q.useManagedOpik?void 0:Q.opikProject||void 0,resend_api_key:Q.useManagedOpik?void 0:Q.resendApiKey||void 0})});x.success(r.message||`${xe.id} Opik settings update queued`,{description:((n=r.deployment_action)==null?void 0:n.action_description)||"The request was queued for the cloud worker."}),ct(l=>l+1),Vs(null),Ke({useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""})}catch(r){x.error("Failed to queue Opik settings update",{description:r instanceof Error?r.message:"Unexpected error"})}finally{Vr(!1)}},xi=t=>{const n=t.recurring_support_fee>=pe({useManagedOpik:!0});Gs(t),Be({useManagedOpik:n,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""})},Co=async()=>{var n;const t=s==null?void 0:s.access_token;if(!t||!ge){yn("onprem","update_opik_settings",(ge==null?void 0:ge.id)||"on-prem instance");return}if(!ee.useManagedOpik&&!ee.opikApiKey.trim()){x.error("Opik API key is required to use your own Opik");return}Yr(!0);try{const r=await O(L(`/api/client/onprem-instance-actions?instanceId=${encodeURIComponent(ge.id)}`,g),{accessToken:t,method:"POST",body:JSON.stringify({action:"queue_update",customer_id:g||(c==null?void 0:c.id)||null,request_variant:"update_opik_settings",use_managed_opik:ee.useManagedOpik,opik_api_key:ee.useManagedOpik?void 0:ee.opikApiKey||void 0,opik_workspace:ee.useManagedOpik?void 0:ee.opikWorkspace||void 0,opik_project:ee.useManagedOpik?void 0:ee.opikProject||void 0,resend_api_key:ee.useManagedOpik?void 0:ee.resendApiKey||void 0})});x.success(r.message||`${ge.id} Opik settings update queued`,{description:r.next_step||((n=r.deployment_action)==null?void 0:n.action_description)||"Reconnect the connected Mac to apply the updated Opik settings."}),ct(l=>l+1),Gs(null),Be({useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""})}catch(r){x.error("Failed to queue Opik settings update",{description:r instanceof Error?r.message:"Unexpected error"})}finally{Yr(!1)}},gi=async(t={})=>{var r,l,m;if(Is.current)return;if(!k.siteName.trim()){x.error("Please provide a site name");return}if(k.dashboardAuthMode==="email_otp"&&!k.otpAllowedEmails.trim()){x.error("Please provide at least one allowed email");return}if(!k.useManagedOpik&&!k.opikApiKey.trim()){x.error("Add your Opik API key to get the $10/month discount");return}const n=s==null?void 0:s.access_token;if(!n){Rn(!0);return}Is.current=!0,An(!0);try{if(ln&&!t.skipCheckout){const N=vt.current||os();vt.current=N,Ad(k,N);const $=await O("/api/client/stripe/checkout",{accessToken:n,method:"POST",body:JSON.stringify({customer_id:g||(c==null?void 0:c.id)||null,target_type:"onprem_instance",request_id:N,request_display_name:k.siteName.trim(),onprem_support_months:k.supportPackageMonths,promotion_code:k.promotionCode.trim()||void 0,success_path:`/client/onprem?checkout=success&request_id=${encodeURIComponent(N)}&session_id={CHECKOUT_SESSION_ID}`,cancel_path:"/client/onprem?checkout=cancelled"})});if($.payment_required)if($.checkout_url){x.success("Redirecting to payment",{description:`Setup fee payment is required before registering ${k.siteName.trim()||"this deployment"}.`}),Ze($.checkout_url);return}else throw new Error("Stripe checkout session did not return a checkout URL")}const o=await O(L("/api/client/onprem-instances",g),{accessToken:n,method:"POST",body:JSON.stringify({customer_id:g||(c==null?void 0:c.id)||null,idempotency_key:vt.current||void 0,checkout_session_id:((r=new URLSearchParams(h.search).get("session_id"))==null?void 0:r.trim())||void 0,site_name:k.siteName.trim(),onprem_support_months:k.supportPackageMonths,model_provider:k.modelProvider,promotion_code:k.promotionCode.trim()||void 0,dashboard_auth_mode:k.dashboardAuthMode,otp_allowed_emails:k.otpAllowedEmails,use_managed_opik:k.useManagedOpik,opik_api_key:k.useManagedOpik?void 0:k.opikApiKey||void 0,opik_workspace:k.useManagedOpik?void 0:k.opikWorkspace||void 0,opik_project:k.useManagedOpik?void 0:k.opikProject||void 0,resend_api_key:k.useManagedOpik?void 0:k.resendApiKey||void 0,workspace_backup_ids:k.workspaceBackupIds})}),_=fl(o.onprem_instance);Bt(On(o.onprem_instance,o.onprem_instance.customer_name||De)),Ue(_),Fe(N=>N+1),ve(_),rt(!0),jt(!0),Rn(!0),Wt(!1),Rs(!1),Ps.current=!1,vt.current=null,ul()}catch(o){if(o instanceof Ia&&((l=o.data)==null?void 0:l.code)==="billing_configuration_unavailable"){x.error(o.message,{duration:1/0,action:{label:"Get billing help",onClick:()=>p("/request-demo")}});return}const _=o instanceof Ia&&((m=o.data)==null?void 0:m.code)==="billing_profile_missing";x.error(o instanceof Error?o.message:"Failed to create on-prem instance",_?{duration:1/0,action:{label:"Set up billing",onClick:()=>{Ss(n,{mode:"payment_method_setup",customerId:g||(c==null?void 0:c.id)||null,returnPath:"/client/onprem"})}}}:void 0)}finally{Is.current=!1,An(!1)}},un=t=>{En(t),t||(Rn(!1),Is.current=!1,An(!1),Wt(!1),Rs(!1),Ps.current=!1,vt.current=null,ae({siteName:"",supportPackageMonths:z,modelProvider:"BYOK",promotionCode:"",dashboardAuthMode:"bypass",otpAllowedEmails:u,useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:"",workspaceBackupIds:[]}),ul())},ns=t=>{rt(!0),je(t),t!=="installer"&&As(!0),un(!1),typeof window<"u"&&window.setTimeout(()=>{const n=document.getElementById("install-guide");n&&typeof n.scrollIntoView=="function"&&n.scrollIntoView({behavior:"smooth",block:"start"})},0)},fi=(t,n)=>e.jsxs("div",{className:"mt-3 rounded-md border border-border/60 bg-background/70 px-3 py-3 text-sm",children:[e.jsx("p",{className:"text-muted-foreground",children:t}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(b,{type:"button",size:"sm",variant:"outline",onClick:()=>ns("installer"),children:[e.jsx(zi,{className:"mr-2 h-4 w-4"}),"Open .pkg guide"]}),e.jsxs(b,{type:"button",size:"sm",variant:"outline",onClick:()=>ns("homebrew"),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Open Homebrew guide"]}),n!=null&&n.includeReconnect?e.jsxs(b,{type:"button",size:"sm",onClick:mn,disabled:!P||Me,children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),Me?"Opening ClawMax…":V?"Reconnect this Mac":"Open ClawMax and connect this Mac"]}):null]})]}),ka=async(t=P)=>{if(!(!(s!=null&&s.access_token)||!t)){mr(!0);try{const n=await O(L(`/api/client/onprem-bootstrap?instanceId=${encodeURIComponent(t)}`,g),{method:"POST",accessToken:s.access_token});ur(n),n.bootstrap_token&&Ze(`clawmax://bootstrap?token=${encodeURIComponent(n.bootstrap_token)}`),x.success("Generated macOS bootstrap handoff",{description:"If ClawMax is installed, the bootstrap deep link should open the app automatically. Use the app-launch fallback if the deep link does not open."})}catch(n){x.error(n instanceof Error?n.message:"Failed to generate bootstrap handoff")}finally{mr(!1)}}},mn=()=>
23{if(!mt&&(V||It.length>0)){Zt(!0);return}ka()},_i=t=>{Ue(""),ve(t.id),jt(!0),rt(!0),ka(t.id)},Na=t=>{t!=null&&t.instance_key&&(Ze(mo(t.instance_key)),x.success("Asked ClawMax to disconnect this Mac",{description:`If ClawMax is installed, it should clear the local binding for ${t.id}${t.site?` (${t.site})`:""} and keep the installed scaffold intact.`}))},as=async t=>{if(!(t!=null&&t.instance_key)||!(s!=null&&s.access_token)||ke)return;Hr(t.id),Ze(zo(t.instance_key));const n=x.loading("Syncing local agent status...",{description:`Waiting for ClawMax on this Mac to write back fresh status for ${t.id}.`}),r={...t},l=Date.now()+3e4;try{for(;Date.now()<l;){await new Promise(_=>window.setTimeout(_,1500));const m=await O(L(`/api/client/onprem-instances/${encodeURIComponent(t.id)}`,g),{accessToken:s.access_token}),o=pl(m);if(Jn(_=>_.map(N=>N.id===o.id?{...N,...o}:N)),Bt(_=>(_==null?void 0:_.id)===o.id?o:_),Fe(_=>_+1),Vl(r,o)){x.dismiss(n),x.success("Local status sync completed",{description:`${o.id} wrote back fresh local agent status.`});return}}x.dismiss(n),x.error("Local app did not respond or status writeback failed",{description:`ClawMax on this Mac did not advance ${t.id} status within 30 seconds. This only works on the Mac currently connected to this instance. If nothing writes back, the local tray likely rejected the request or local status sync failed.`})}catch(m){x.dismiss(n),x.error("Local app did not respond or status writeback failed",{description:m instanceof Error?`${m.message} This only works on the Mac currently connected to this instance.`:"This only works on the Mac currently connected to this instance. The local tray likely rejected the request or local status sync failed."})}finally{Hr(m=>m===t.id?null:m)}};d.useEffect(()=>{!k.otpAllowedEmails&&u&&ae(t=>({...t,otpAllowedEmails:u}))},[k.otpAllowedEmails,u]),d.useEffect(()=>{!pt&&_l(Ie)&&je("installer")},[pt,Ie]),d.useEffect(()=>{const t=Rd();if(!t)return;const n=h.pathname.startsWith("/client/onprem")&&new URLSearchParams(h.search).get("checkout")==="success";vt.current=t.requestId||os(),ae(r=>({...r,siteName:t.siteName||r.siteName,supportPackageMonths:t.supportPackageMonths&&Wa(t.supportPackageMonths)?t.supportPackageMonths:r.supportPackageMonths,modelProvider:t.modelProvider||r.modelProvider,promotionCode:t.promotionCode||r.promotionCode,dashboardAuthMode:t.dashboardAuthMode||r.dashboardAuthMode,otpAllowedEmails:t.otpAllowedEmails||r.otpAllowedEmails,useManagedOpik:t.useManagedOpik??r.useManagedOpik,opikApiKey:t.opikApiKey||r.opikApiKey,opikWorkspace:t.opikWorkspace||r.opikWorkspace,opikProject:t.opikProject||r.opikProject,resendApiKey:t.resendApiKey||r.resendApiKey,workspaceBackupIds:Array.isArray(t.workspaceBackupIds)?t.workspaceBackupIds:r.workspaceBackupIds})),En(!0),Wt(n),Rs(n)},[h.pathname,h.search]),d.useEffect(()=>{ae(t=>t.siteName||t.promotionCode||t.opikApiKey||t.opikWorkspace||t.opikProject||t.resendApiKey?t:{...t,supportPackageMonths:z})},[z]),d.useEffect(()=>{const t=new URLSearchParams(h.search);if(t.get("new_request")!=="1")return;const n=`${h.pathname}?${t.toString()}`;if(Gr.current===n)return;if(Gr.current=n,h.pathname.startsWith("/client/cloud"))re(l=>({...l,promotionCode:he||l.promotionCode})),Ts(!0);else if(h.pathname.startsWith("/client/onprem"))ae(l=>({...l,supportPackageMonths:z,promotionCode:he||l.promotionCode})),En(!0);else if(h.pathname==="/client/enterprise")Un(X),Pe(l=>({...l,promotionCode:he||l.promotionCode})),Ls(!0);else return;t.delete("new_request"),t.delete("promotion_code");const r=t.toString();p(`${h.pathname}${r?`?${r}`:""}${h.hash}`,{replace:!0})},[h.hash,h.pathname,h.search,p,X,z,he]),d.useEffect(()=>{!C.otpAllowedEmails&&u&&re(t=>({...t,otpAllowedEmails:u}))},[C.otpAllowedEmails,u]),d.useEffect(()=>{const t=Sd();if(!t)return;const n=h.pathname.startsWith("/client/cloud")&&new URLSearchParams(h.search).get("checkout")==="success";wt.current=t.requestId||os(),re(r=>({...r,displayName:t.displayName||r.displayName,region:t.region||r.region,promotionCode:t.promotionCode||r.promotionCode,dashboardAuthMode:t.dashboardAuthMode||r.dashboardAuthMode,otpAllowedEmails:t.otpAllowedEmails||r.otpAllowedEmails,useManagedOpik:t.useManagedOpik??r.useManagedOpik,opikApiKey:t.opikApiKey||r.opikApiKey,opikWorkspace:t.opikWorkspace||r.opikWorkspace,opikProject:t.opikProject||r.opikProject,resendApiKey:t.resendApiKey||r.resendApiKey,workspaceBackupIds:Array.isArray(t.workspaceBackupIds)?t.workspaceBackupIds:r.workspaceBackupIds})),Ts(!0),kt(n),$n(n)},[h.pathname,h.search]),d.useEffect(()=>{const t=Pd();t!=null&&t.includedInstances&&(Un(t.includedInstances),Pe(n=>({...n,promotionCode:t.promotionCode||n.promotionCode,enterpriseName:t.enterpriseName||n.enterpriseName,enterpriseWebsiteUrl:t.enterpriseWebsiteUrl||n.enterpriseWebsiteUrl})),Ls(!0),cl())},[]),d.useEffect(()=>{Pe(t=>({...t,enterpriseName:(c==null?void 0:c.enterprise_name)||t.enterpriseName,enterpriseWebsiteUrl:(c==null?void 0:c.enterprise_website_url)||t.enterpriseWebsiteUrl}))},[c==null?void 0:c.enterprise_name,c==null?void 0:c.enterprise_website_url]),d.useEffect(()=>{const n=new URLSearchParams(h.search).get("checkout");n==="success"&&h.pathname.startsWith("/client/cloud")?(kt(!0),x.success("Payment received",{description:"ClawMax is automatically submitting your saved cloud request."})):n==="cancelled"&&h.pathname.startsWith("/client/cloud")?(kt(!1),x.success("Payment cancelled",{description:"Your cloud request draft is still here if you want to try again."})):n==="success"&&h.pathname.startsWith("/client/onprem")?(Wt(!0),x.success("Payment received",{description:"ClawMax is automatically submitting your saved on-prem request."})):n==="cancelled"&&h.pathname.startsWith("/client/onprem")?(Wt(!1),x.success("Payment cancelled",{description:"Your on-prem deployment draft is still here if you want to try again."})):n==="success"&&h.pathname==="/client/enterprise"?x.success("Enterprise payment received",{description:"Your enterprise package is now active for new cloud and on-prem requests."}):n==="cancelled"&&h.pathname==="/client/enterprise"&&x.success("Enterprise payment cancelled",{description:"Your selected package is still here if you want to try again."})},[h.pathname,h.search]),d.useEffect(()=>{var rs,Z;const t=s==null?void 0:s.access_token,n=new URLSearchParams(h.search),r=n.get("billing"),l=((rs=n.get("customerId"))==null?void 0:rs.trim())||null,m=((Z=n.get("session_id"))==null?void 0:Z.trim())||null;if(!t||r!=="success")return;const o=n.get("target_type"),_=n.get("target_id"),N=o==="cloud_instance"||o==="onprem_instance"?o:h.pathname.startsWith("/client/onprem")?"onprem_instance":h.pathname.startsWith("/client/cloud")?"cloud_instance":void 0,$=_||(N==="cloud_instance"?H:N==="onprem_instance"?P:""),Y=Pl(N,$||"",F,D);if(N&&$&&l&&!Y)return;const T=`${h.pathname}?${n.toString()}`;if(Ur.current===T)return;Ur.current=T;const ue=Y||l||g||(c==null?void 0:c.id)||null;(async()=>{try{const R=await Kd(t,{customerId:ue,targetType:N,targetId:$||void 0,sessionId:m});ue&&ue!==g&&Bs(ue),R.payment_method_ready&&(Fs(W=>W&&{...W,stripe_customer_id:R.stripe_customer_id||W.stripe_customer_id||null,stripe_payment_method_ready:!0,stripe_default_payment_method_brand:R.stripe_default_payment_method_brand||W.stripe_default_payment_method_brand||null,stripe_default_payment_method_last4:R.str
23ipe_default_payment_method_last4||W.stripe_default_payment_method_last4||null}),Ks(W=>W.map(is=>is.id===(ue||"")?{...is,stripe_payment_method_ready:!0,stripe_default_payment_method_brand:R.stripe_default_payment_method_brand||is.stripe_default_payment_method_brand||null,stripe_default_payment_method_last4:R.stripe_default_payment_method_last4||is.stripe_default_payment_method_last4||null}:is)));let Ca=!!R.activated,Ci=null;if(!Ca&&R.payment_method_ready&&N&&$)try{await Fa(t,{action:"activate",customerId:ue,targetType:N,targetId:$}),Ca=!0}catch(W){Ci=W instanceof Error?W.message:"Recurring maintenance still needs a manual retry."}if(ct(W=>W+1),Fe(W=>W+1),Ee(W=>W+1),Ca)x.success("Recurring maintenance is active",{description:"Your saved card is active and recurring maintenance is now enabled for this instance."});else if(R.payment_method_ready)x.error("Payment method saved, but recurring maintenance is not active",{description:Ci||(R.activation_skipped_reason==="target_not_found"?"The target deployment could not be resolved for maintenance activation.":R.activation_skipped_reason==="missing_payment_method"?"A saved payment method is still not available for recurring maintenance.":"Recurring maintenance still needs a manual retry.")});else{const W=Array.isArray(R.payment_method_recovery_debug)&&R.payment_method_recovery_debug.length?` Recovery trace: ${R.payment_method_recovery_debug.slice(-12).join(" | ")}`:"";x.error("Saved payment method was not detected",{description:R.activation_skipped_reason==="missing_payment_method"?`Stripe returned successfully, but no reusable default payment method was detected for this account.${W}`:`Stripe returned successfully, but the saved payment method could not be confirmed.${W}`})}}catch(R){x.error("Failed to confirm saved payment method",{description:R instanceof Error?R.message:"Unexpected error"})}finally{if(typeof window<"u"){const R=new URL(window.location.href);R.searchParams.delete("billing"),R.searchParams.delete("customerId"),R.searchParams.delete("session_id"),R.searchParams.delete("target_type"),R.searchParams.delete("target_id"),window.history.replaceState({},"",`${R.pathname}${R.search}${R.hash}`)}}})()},[D,c==null?void 0:c.id,F,h.pathname,h.search,H,g,P,s==null?void 0:s.access_token]);const yi=t=>{Ts(t),t||(Ht.current=!1,Ds(!1),kt(!1),dl(),re({displayName:"",region:"nyc1",promotionCode:"",dashboardAuthMode:"email_otp",otpAllowedEmails:u,useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:"",workspaceBackupIds:[]}))},So=()=>{Xo.flushSync(()=>{Ts(!1)}),Ht.current=!1,Ds(!1),kt(!1),$n(!1),Dn.current=!1,wt.current=null,dl(),re({displayName:"",region:"nyc1",promotionCode:"",dashboardAuthMode:"email_otp",otpAllowedEmails:u,useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:"",workspaceBackupIds:[]})},Oo=async()=>{var r;const t=wt.current||os();wt.current=t;const n=((r=new URLSearchParams(h.search).get("session_id"))==null?void 0:r.trim())||null;return O(L("/api/client/cloud-instances",g),{accessToken:s==null?void 0:s.access_token,method:"POST",body:JSON.stringify({customer_id:g||(c==null?void 0:c.id)||null,idempotency_key:t,checkout_session_id:n,display_name:C.displayName.trim(),region:C.region,promotion_code:C.promotionCode.trim()||void 0,dashboard_auth_mode:C.dashboardAuthMode,otp_allowed_emails:C.otpAllowedEmails,use_managed_opik:C.useManagedOpik,opik_api_key:C.useManagedOpik?void 0:C.opikApiKey||void 0,opik_workspace:C.useManagedOpik?void 0:C.opikWorkspace||void 0,opik_project:C.useManagedOpik?void 0:C.opikProject||void 0,resend_api_key:C.useManagedOpik?void 0:C.resendApiKey||void 0,workspace_backup_ids:C.workspaceBackupIds})})},bi=async(t={})=>{if(Ht.current)return;if(!C.displayName.trim()){x.error("Please provide an instance name");return}if(C.dashboardAuthMode==="email_otp"&&!C.otpAllowedEmails.trim()){x.error("Please provide at least one allowed email");return}if(!C.useManagedOpik&&!C.opikApiKey.trim()){x.error("Add your Opik API key to get the $10/month discount");return}const n=s==null?void 0:s.access_token;if(!n){x.error("Please sign in before requesting a cloud instance");return}Ht.current=!0,Ds(!0);let r;try{if(rn&&!t.skipCheckout){const _=wt.current||os();wt.current=_,Od(C,_);const N=await O("/api/client/stripe/checkout",{accessToken:n,method:"POST",body:JSON.stringify({customer_id:g||(c==null?void 0:c.id)||null,target_type:"cloud_instance",request_id:_,request_display_name:C.displayName.trim(),request_region:C.region,promotion_code:C.promotionCode.trim()||void 0,success_path:`/client/cloud?checkout=success&request_id=${encodeURIComponent(_)}&session_id={CHECKOUT_SESSION_ID}`,cancel_path:"/client/cloud?checkout=cancelled"})});if(N.payment_required)if(N.checkout_url){x.success("Redirecting to payment",{description:`Setup fee payment is required before provisioning ${C.displayName.trim()||"this cloud instance"}.`}),Ze(N.checkout_url);return}else throw new Error("Stripe checkout session did not return a checkout URL")}let l=null,m=null;for(let _=0;_<=el.length;_+=1)try{l=await Oo();break}catch(N){if(!(N instanceof Ia))throw N;const $=N.data||{};if(!(($.code==="shared_capacity_not_verified"||$.code==="shared_capacity_stale")&&($.capacity_refresh_queued||$.capacity_refresh_action_id||$.existing_capacity_refresh_action_id)))throw N;m=N,r==null&&(r=x.loading("Verifying shared-cloud capacity...",{description:"ClawMax queued a fresh capacity refresh and will retry automatically."}));const T=el[_];if(T==null)break;await new Promise(ue=>window.setTimeout(ue,T))}if(!l){if(r!=null&&x.dismiss(r),m){x.error("Shared-cloud capacity is still being verified",{description:"ClawMax queued a capacity refresh for this region. Please try again in a few seconds."});return}throw new Error("Failed to request cloud instance")}r!=null&&x.dismiss(r);const o=fl(l.cloud_instance);ie(o),ct(_=>_+1),Le(o),Ws(!0),kt(!1),So(),x.success(`Requested ${C.displayName.trim()}`,{description:"Provisioning has been queued."})}catch(l){r!=null&&x.dismiss(r),x.error(l instanceof Error?l.message:"Failed to request cloud instance")}finally{Ht.current=!1,Ds(!1)}};$s.current=()=>{bi({skipCheckout:!0})},d.useEffect(()=>{var t;!gr||!Ln||!(s!=null&&s.access_token)||Dn.current||(Dn.current=!0,$n(!1),(t=$s.current)==null||t.call($s))},[gr,Ln,s==null?void 0:s.access_token,C]),Es.current=()=>{gi({skipCheckout:!0})},d.useEffect(()=>{var t;!hr||!Tn||!(s!=null&&s.access_token)||Ps.current||(Ps.current=!0,Rs(!1),(t=Es.current)==null||t.call(Es))},[hr,Tn,s==null?void 0:s.access_token,k]);const Mo=async()=>
23{if(qn.current)return;const t=s==null?void 0:s.access_token;if(!t){x.success("Please sign in before upgrading to enterprise");return}if(!q.enterpriseName.trim()){x.error("Please provide an enterprise name");return}qn.current=!0,_r(!0);try{Ed(we,q.promotionCode.trim(),q.enterpriseName.trim(),q.enterpriseWebsiteUrl.trim());const n=await O("/api/client/stripe/checkout",{accessToken:t,method:"POST",body:JSON.stringify({customer_id:g||(c==null?void 0:c.id)||null,target_type:"enterprise_package",target_id:`enterprise-${we}`,enterprise_included_instances:we,enterprise_name:q.enterpriseName.trim(),enterprise_website_url:q.enterpriseWebsiteUrl.trim()||void 0,promotion_code:q.promotionCode.trim()||void 0,success_path:"/client/enterprise?checkout=success",cancel_path:"/client/enterprise?checkout=cancelled"})});if(!n.checkout_url)throw new Error("Stripe checkout session did not return a checkout URL");x.success("Redirecting to payment",{description:`Enterprise payment is required before ${we} mixed instances are activated.`}),Ze(n.checkout_url)}catch(n){x.error(n instanceof Error?n.message:"Failed to start enterprise checkout"),cl(),qn.current=!1,_r(!1)}},Io=async()=>{const t=s==null?void 0:s.access_token,n=g||(c==null?void 0:c.id);if(!t||!n){x.error("Please sign in before requesting Enterprise event capacity");return}const r=q.enterpriseName.trim()||(c==null?void 0:c.enterprise_name)||(c==null?void 0:c.name);if(!r){x.error("Please add an enterprise name first");return}jr(!0);try{const l=await O("/api/client/enterprise-burst-reservations",{accessToken:t,method:"POST",body:JSON.stringify({customer_id:n,enterprise_name:r,max_instances:me.maxInstances,usage_days:me.usageDays,access_starts_at:new Date(me.accessStartsAt).toISOString(),time_zone:Intl.DateTimeFormat().resolvedOptions().timeZone||"America/New_York"})});it(m=>[l.reservation,...m.filter(o=>o.id!==l.reservation.id)]),Fn(!1),await vi(l.reservation,me.promotionCode)}catch(l){x.error("Failed to save capacity request",{description:l instanceof Error?l.message:"Unexpected error"})}finally{jr(!1)}},Po=async()=>{const t=s==null?void 0:s.access_token,n=g||(c==null?void 0:c.id);if(!(!t||!n||!Kn)){wr(!0);try{const r=await O("/api/client/enterprise-burst-reservations",{accessToken:t,method:"PATCH",body:JSON.stringify({customer_id:n,reservation_id:Kn.id,action:"cancel"})});it(l=>l.filter(m=>m.id!==r.reservation.id)),Bn(null),x.success("Capacity request cancelled",{description:r.refunded?"Provisioning had not started, so the payment was refunded.":"Provisioning had not started. No charge remains for this request."})}catch(r){x.error("Failed to cancel capacity request",{description:r instanceof Error?r.message:"Unexpected error"})}finally{wr(!1)}}},vi=async(t,n=q.promotionCode)=>{const r=s==null?void 0:s.access_token,l=g||(c==null?void 0:c.id);if(!(!r||!l)){zn(t.id);try{const m=await O("/api/client/enterprise-burst-checkout",{accessToken:r,method:"POST",body:JSON.stringify({customer_id:l,reservation_id:t.id,promotion_code:n.trim()||void 0})});if(m.reservation)it(o=>o.map(_=>_.id===t.id?{..._,...m.reservation}:_)),x.success("Payment requirement satisfied",{description:"ClawMax will now verify capacity before Management can approve the request."});else if(m.checkout_url)it(o=>o.map(_=>_.id===t.id?{..._,status:"checkout_pending"}:_)),zn(null),Ze(m.checkout_url);else throw new Error("Checkout did not return a payment destination")}catch(m){x.error("Unable to start event capacity payment",{description:m instanceof Error?m.message:"Unexpected error"}),zn(null)}}},Eo=async t=>{var m;const n=s==null?void 0:s.access_token,r=g||(c==null?void 0:c.id),l=(m=Hn[t.id])==null?void 0:m.trim();if(!(!n||!r||!l)){Nt(t.id);try{const o=await O("/api/client/enterprise-burst-invitations",{accessToken:n,method:"POST",body:JSON.stringify({customer_id:r,reservation_id:t.id,emails:l.split(/[\n,;]+/)})});Cr(N=>({...N,[t.id]:""})),Ee(N=>N+1);const _=o.created_count+(o.reactivated_count||0);x.success(_?`${_} event ${_===1?"user":"users"} invited`:"No new invitations needed",{description:o.message||(o.skipped_count>0?`${o.skipped_count} existing or owner ${o.skipped_count===1?"invitation was":"invitations were"} skipped.`:"The first users to accept receive the available instance slots.")})}catch(o){x.error("Failed to add event invitation",{description:o instanceof Error?o.message:"Unexpected error"})}finally{Nt(null)}}},Ro=async t=>{const n=s==null?void 0:s.access_token,r=g||(c==null?void 0:c.id);if(!(!n||!r)){Nt(t.id);try{await O("/api/client/enterprise-burst-invitations",{accessToken:n,method:"DELETE",body:JSON.stringify({customer_id:r,invitation_id:t.
23id})}),Vt(l=>l.filter(m=>m.id!==t.id)),x.success("Event invitation revoked")}catch(l){x.error("Failed to revoke event invitation",{description:l instanceof Error?l.message:"Unexpected error"})}finally{Nt(null)}}},Ao=async t=>{const n=s==null?void 0:s.access_token;if(n){Nt(t.id);try{const r=await O("/api/client/enterprise-burst-invitation-accept",{accessToken:n,method:"POST",body:JSON.stringify({invitation_id:t.id})});Us(l=>l.map(m=>m.id===t.id?{...m,...r.invitation}:m)),Ee(l=>l+1),r.outcome==="accepted"?x.success("Enterprise invitation accepted",{description:r.message}):x.error("Event capacity is full",{description:r.message})}catch(r){x.error("Failed to accept event invitation",{description:r instanceof Error?r.message:"Unexpected error"})}finally{Nt(null)}}},To=async()=>{const t=s==null?void 0:s.access_token,n=g||(c==null?void 0:c.id);if(!t||!n){x.error("Please sign in before opening the Enterprise workspace");return}br(!0);try{const r=await O("/api/client/enterprise-session",{accessToken:t,method:"POST",body:JSON.stringify({customer_id:n})}),l=new URL(r.entry_origin);if(l.protocol!=="https:"||l.origin!==r.entry_origin)throw new Error("Enterprise entry is unavailable");window.location.assign(l.origin)}catch(r){x.error("Failed to open the Enterprise workspace",{description:r instanceof Error?r.message:"Unexpected error"}),br(!1)}},Do=async()=>{const t=s==null?void 0:s.access_token;if(!t||!g){x.error("Please sign in before updating enterprise settings");return}if(!q.enterpriseName.trim()){x.error("Please provide an enterprise name");return}Pr(!0);try{await O(L("/api/client/account",g),{accessToken:t,method:"PATCH",body:JSON.stringify({customer_id:g,enterprise_name:q.enterpriseName.trim(),enterprise_website_url:q.enterpriseWebsiteUrl.trim()||void 0})}),x.success("Enterprise settings updated"),Ee(n=>n+1)}catch(n){x.error("Failed to update enterprise settings",{description:n instanceof Error?n.message:"Unexpected error"})}finally{Pr(!1)}},$o=async()=>{const t=s==null?void 0:s.access_token;if(!t||!g){x.error("Please sign in before inviting members");return}if(!ea.trim()){x.error("Please provide a member email");return}Rr(!0);try{await O(L("/api/client/customer-members",g),{accessToken:t,method:"POST",body:JSON.stringify({customer_id:g,email:ea.trim()})}),Mr(""),Ee(n=>n+1),x.success("Enterprise member added",{description:"They can now sign in and access this enterprise."})}catch(n){x.error("Failed to add enterprise member",{description:n instanceof Error?n.message:"Unexpected error"})}finally{Rr(!1)}},Lo=async t=>{const n=s==null?void 0:s.access_token;if(!n||!g){x.error("Please sign in before removing members");return}Tr(t);try{await O(L("/api/client/customer-members",g),{accessToken:n,method:"DELETE",body:JSON.stringify({customer_id:g,member_id:t})}),Ee(r=>r+1),x.success("Enterprise member removed")}catch(r){x.error("Failed to remove enterprise member",{description:r instanceof Error?r.message:"Unexpected error"})}finally{Tr(null)}},Uo=v==="onprem"?"On-Prem":v==="enterprise"?"Enterprise":v==="profile"?"Profile":"Cloud",qo=v==="cloud"?`${F.length} cloud deployment(s); ${ja} degraded; ${Ae.length} recent action(s).`:v==="onprem"?`${D.length} on-prem deployment(s); ${Ae.length} recent action(s).`:v==="enterprise"?`${ga} of ${Qt} included deployment slot(s) currently represented.`:`Signed-in account profile for ${De}; terms status: ${$e}.`,Fo=v==="cloud"&&w?{title:w.id,subtitle:`${w.status} · ${w.region}`}:v==="onprem"&&f?{title:f.id,subtitle:`${f.runtime_health||f.runtime_status||"Status unavailable"} · ${f.version||"Version unavailable"}`}:null,ji=(t,n)=>{const r=e.jsxs("div",{className:"min-w-0 space-y-2 break-all",children:[La(t),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(M,{variant:"outline",children:"Enterprise"}),e.jsx(M,{variant:"outline",children:"Event"})]})]}),l=e.jsx("a",{href:t.service_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline",children:"Open dashboard"});return n?e.jsxs("div",{className:"space-y-3 rounded-lg border border-border p-4",children:[r,e.jsx(M,{variant:"outline",children:"Running"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Included in event · Email OTP access"}
23),e.jsx("p",{className:"text-sm",children:t.version}),l]},t.id):e.jsxs(xt,{children:[e.jsx(G,{children:r}),e.jsx(G,{children:e.jsx(M,{variant:"outline",children:"Running"})}),e.jsx(G,{children:"Included in event"}),e.jsx(G,{children:t.version||"—"}),e.jsx(G,{children:l})]},t.id)},wi=lt.length>0?e.jsxs("div",{className:"space-y-2 rounded-lg border border-primary/30 bg-primary/5 px-3 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Your event invitations"}),lt.map(t=>{var n,r,l,m;return e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 break-words [overflow-wrap:anywhere]",children:[e.jsx("div",{className:"font-medium text-foreground",children:((n=t.reservation)==null?void 0:n.enterprise_name)||"Enterprise event"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[((r=t.reservation)==null?void 0:r.max_instances)||"—"," instance slots · ",t.status==="accepted"?`Assigned slot ${t.assigned_slot}`:t.status.replace(/_/g," ")]})]}),["closed","deleting","cleanup_blocked","expired","expired_refunded","declined_refunded","capacity_blocked"].includes(((l=t.reservation)==null?void 0:l.status)||"")?e.jsx(M,{variant:"outline",children:"Event unavailable"}):t.status==="invited"||t.status==="capacity_full"?e.jsx(b,{type:"button",size:"sm",onClick:()=>void Ao(t),disabled:Yt===t.id,children:Yt===t.id?"Checking…":t.status==="capacity_full"?"Try again":"Accept invitation"}):t.access_delivery==="pending_update"?e.jsx(M,{variant:"outline",children:"Access update pending"}):t.access_delivery==="revoked"?e.jsx(M,{variant:"outline",children:"Access revoked"}):["ready","active"].includes(((m=t.reservation)==null?void 0:m.status)||"")?e.jsx(Si,{reservationId:t.reservation_id,accessToken:s==null?void 0:s.access_token}):e.jsx(M,{variant:"outline",children:"Awaiting ready instances"})]},t.id)})]}):null;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Qo,{}),e.jsxs("main",{className:"container mx-auto max-w-7xl px-4 pb-16 pt-28",children:[e.jsxs("section",{className:"mb-8 flex flex-col gap-3 md:flex-row md:items-end md:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-mono text-xs uppercase tracking-[0.3em] text-primary",children:"Client"}),e.jsxs("h1",{className:"mt-2 font-display text-4xl font-bold text-foreground",children:[De," console"]}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm text-muted-foreground",children:"Keep track of your deployments, current run rate, and the next action to take. This view stays focused on your account only."})]}),e.jsxs("div",{className:"flex flex-col gap-3 md:items-end",children:[e.jsx(M,{variant:"outline",className:"w-fit border-primary/30 bg-primary/5 px-3 py-1 text-primary",children:"Customer console"}),Xn.length>1?e.jsxs("div",{className:"w-full md:min-w-[280px]",children:[e.jsx("div",{className:"mb-1 text-xs font-medium uppercase tracking-[0.2em] text-muted-foreground",children:"Enterprise"}),e.jsxs(Ve,{value:g||(c==null?void 0:c.id)||"",onValueChange:Bs,children:[e.jsx(Ye,{className:"bg-background",children:e.jsx(Ge,{placeholder:"Select enterprise"})}),e.jsx(Je,{children:Xn.map(t=>e.jsxs(Ce,{value:t.id,children:[t.enterprise_name||t.name||t.id,t.access_role==="owner"?" (Owner)":""]},t.id))})]})]}):null,e.jsxs("div",{className:"grid w-full grid-cols-3 gap-2 md:w-auto",children:[e.jsx(b,{variant:v==="cloud"?"default":"outline",className:J("w-full",v==="cloud"?"shadow-sm":void 0),asChild:!0,children:e.jsxs(He,{to:"/client/cloud",children:[e.jsx(Ii,{className:"mr-2 h-4 w-4"}),"Cloud"]})}),e.jsx(b,{variant:v==="onprem"?"default":"outline",className:J("w-full",v==="onprem"?"shadow-sm":void 0),asChild:!0,children:e.jsxs(He,{to:"/client/onprem",children:[e.jsx(Pi,{className:"mr-2 h-4 w-4"}),"On-prem"]})}),e.jsx(b,{variant:v==="enterprise"?"default":"outline",className:J("w-full",v==="enterprise"?"shadow-sm":void 0),asChild:!0,children:e.jsxs(He,{to:"/client/enterprise",children:[e.jsx(Lt,{className:"mr-2 h-4 w-4"}),"Enterprise"]})})]}),e.jsxs("div",{className:"flex w-full flex-wrap gap-2 border-t border-border/70 pt-3 md:justify-end",children:[e.jsx(b,{variant:v==="feedback"?"default":"outline",className:v==="feedback"?"shadow-sm":void 0,asChild:!0,children:e.jsxs(He,{to:"/client/feedback",children:[e.jsx(vl,{className:"mr-2 h-4 w-4"}),"Feedback"]})}),e.jsx(b,{variant:v==="profile"?"default":"outline",className:v==="profile"?"shadow-sm":void 0,asChild:!0,children:e.jsxs(He,{to:"/client/profile",children:[e.jsx(Ei,{className:"mr-2 h-4 w-4"}),"My profile"]})})]}),e.jsxs("div",{className:"flex w-full flex-wrap gap-2 border-t border-border/70 pt-3 md:justify-end",children:[e.jsx(b,{variant:h.pathname==="/survey"?"default":"outline",className:h.pathname==="/survey"?"shadow-sm":void 0,asChild:!0,children:e.jsxs(He,{to:"/survey",children:[e.jsx(Jo,{className:"mr-2 h-4 w-4"}),"Survey"]})}),e.jsx(b,{variant:h.pathname==="/terms"?"default":"outline",className:h.pathname==="/terms"?"shadow-sm":void 0,asChild:!0,children:e.jsxs(He,{to:"/terms",children:[e.jsx(Ri,{className:"mr-2 h-4 w-4"}),"Terms"]})})]})]})]}),e.jsxs("section",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-4",children:[e.jsx(Xe,{title:vo,value:bo,subtitle:jo}),e.jsx(Xe,{title:"Current run rate",value:`${j(di)}/mo`,subtitle:"Current monthly charges across your account"}),e.jsx(Xe,{title:"Setup fees",value:j(yo),subtitle:"One-time setup charges for these instances"}),e.jsx(Xe,{title:"Active promotions",value:ci,subtitle:ci>0?"Instances still using promo-backed setup or support":"No promo-backed instances right now"})]}),e.jsxs("section",{className:"mt-8 space-y-6",children:[v==="enterprise"?e.jsxs("section",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lt,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Enterprise"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:ze?"Track capacity, billing, and support.":"Prepay for mixed cloud/on-prem capacity with dedicated support."})]})]}),e.jsxs(K,{className:"border-primary/25",children:[e.jsx(te,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx(se,{children:"Short-term Enterprise event capacity"}),e.jsx(ne,{className:"mt-1",children:"Reserve 5–50 instances for a fixed event window. Pricing includes the required 24-hour preparation day."})]}),e.jsx(M,{variant:"outline",children:"Capacity approval required"})]})}),e.jsxs(B,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"Example package"}),e.jsx("div",{className:"font-semibold text-foreground",children:"5 instances × 2 usage days"})]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"Paid capacity window"}),e.jsx("div",{className:"font-semibold text-foreground",children:"1 prep day + usage days"})]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-muted-foreground",children:"Example price"}),e.jsx("div",{className:"font-semibold text-foreground",children:"$75 one time"})]})]}),e.jsxs(ft,{open:co,onOpenChange:Fn,children:[e.jsx(us,{asChild:!0,children:e.jsxs(b,{type:"button",disabled:!de,children:[e.jsx(Lt,{className:"mr-2 h-4 w-4"}),"Request event capacity"]})}),e.jsxs(_t,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Request short-term Enterprise capacity"}),e.jsx(tt,{children:"Submit the request and pay the one-time quote now. A valid 100% coupon waives payment. Capacity preflight and Management approval happen only after payment or waiver is recorded."})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Enterprise name"}),e.jsx(I,{value:q.enterpriseName,onChange:t=>Pe(n=>({...n,enterpriseName:t.target.value})),placeholder:"Acme AI"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Maximum instances"}),e.jsxs(Ve,{value:String(me.maxInstances),onValueChange:t=>qs(n=>({...n,maxInstances:Number(t)})),children:[e.jsx(Ye,{children:e.jsx(Ge,{})}),e.jsx(Je,{children:pd.map(t=>e.jsxs(Ce,{value:String(t),children:[t," instances"]},t))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Actual usage"}),e.jsxs(Ve,{value:String(me.usageDays),onValueChange:t=>qs(n=>({...n,usageDays:Number(t)})),children:[e.jsx(Ye,{"aria-label":"Actual usage",children:e.jsx(Ge,{})}),e.jsx(Je,{children:hd.map(t=>e.jsxs(Ce,{value:String(t),children:[t," ",t===1?"day":"days"]},t))})]})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Access starts"}
23),e.jsx(I,{type:"datetime-local",value:me.accessStartsAt,onChange:t=>qs(n=>({...n,accessStartsAt:t.target.value}))}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Must be at least 24 hours from now. Times use your browser time zone."})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx($i,{htmlFor:"enterprise-burst-coupon",children:"Optional coupon"}),e.jsx(I,{id:"enterprise-burst-coupon",value:me.promotionCode,onChange:t=>qs(n=>({...n,promotionCode:t.target.value.toUpperCase()})),placeholder:"Coupon code"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Without a full waiver, continuing opens Stripe Checkout. Management cannot approve an unpaid request."})]})]}),le?e.jsxs("div",{className:"space-y-2 rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"text-muted-foreground",children:"One-time quote"}),e.jsx("span",{className:"text-lg font-semibold text-foreground",children:j(le.amount_cents/100)})]}),e.jsxs("div",{className:"text-muted-foreground",children:[le.max_instances," instances × ",le.capacity_days," paid capacity days"," ","(",le.usage_days," usage + one operations day) × $5."]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["The operations day is split into ",le.prep_hours," hours before access and ",le.cleanup_hours," hours after. Faster provisioning becomes early-access grace; the full requested usage window remains protected."]}),e.jsxs("div",{className:"text-muted-foreground",children:["Proposed New York topology: ",le.requested_cluster_count," ",le.requested_cluster_count===1?"cluster":"clusters"," ","(",le.cluster_slot_targets.join(" + ")," slots)."]})]}):e.jsxs(pn,{variant:"destructive",children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx(hn,{children:ni})]}),e.jsxs(st,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>Fn(!1),children:"Cancel"}),e.jsx(b,{type:"button",onClick:()=>void Io(),disabled:vr||!le,children:vr?"Continuing…":me.promotionCode.trim()?"Apply coupon and request":`Continue to pay ${j(((le==null?void 0:le.amount_cents)||0)/100)}`})]})]})]}),wi,qe.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Recent event capacity requests"}),qe.slice(0,3).map(t=>{var m;const n=Nr.filter(o=>o.reservation_id===t.id),r=n.filter(o=>o.status==="accepted").length,l=[...t.preflight_operations||[]].filter(o=>o.capability==="enterprise_capacity_reconcile:provision").sort((o,_)=>Date.parse(_.created_at||"")-Date.parse(o.created_at||""))[0];return e.jsxs("div",{"aria-label":`Owner event request ${t.id}`,className:"min-w-0 space-y-3 break-words rounded-md border border-border px-3 py-3 text-sm [overflow-wrap:anywhere]",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-foreground",children:[t.max_instances," instances for ",t.usage_days," ",t.usage_days===1?"day":"days"]}),e.jsxs("div",{className:"text-muted-foreground",children:["Access ",new Intl.DateTimeFormat("en-US",{timeZone:t.time_zone||void 0,month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}).format(new Date(t.access_starts_at))," · ",j(t.amount_cents/100)]})]}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 [&>button]:min-h-11 [&>button]:max-w-full [&>button]:whitespace-normal",children:[e.jsx(M,{variant:"outline",children:["capacity_pending","checkout_pending"].includes(t.status)?"Awaiting payment":t.status.replace(/_/g," ")}),["ready","active"].includes(t.status)?e.jsx(Si,{reservationId:t.id,accessToken:s==null?void 0:s.access_token}):null,de&&["capacity_pending","checkout_pending"].includes(t.status)?e.jsx(b,{type:"button",size:"sm",onClick:()=>void vi(t),disabled:kr===t.id,children:kr===t.id?"Continuing…":t.status==="checkout_pending"?"Complete payment":q.promotionCode.trim()?"Apply coupon":`Pay ${j(t.amount_cents/100)}`}):null,de&&!t.provisioning_started_at&&!l&&["capacity_pending","capacity_checked","capacity_blocked","checkout_pending","paid_pending_approval","paid_preparing"].includes(t.status)?e.jsx(b,{type:"button",size:"sm",variant:"ghost",onClick:()=>Bn(t),children:"Cancel request"}):null]})]}),l?e.jsxs("div",{role:"status",className:"rounded-md border p-3",children:[e.jsxs("div",{className:"font-medium",children:["Event instances · ",t.max_instances," slots · Provisioning ",l.display_status||l.status]}),t.instance_progress?e.jsxs("div",{children:[t.instance_progress.ready," of ",t.max_instances," instances verified ready · ",t.instance_progress.failed," failed"]}):null,(m=t.runtime_observations)!=null&&m.length?e.jsxs("div",{children:[t.runtime_observations.length," of ",t.max_instances," runtimes verified in latest worker evidence · event access is separate"]}):null,e.jsx("div",{className:"text-xs text-muted-foreground",children:["ready","active"].includes(t.status)?"Verified event instances are available through Open event instances.":"Runtime readiness is not yet confirmed. Cloud shows event batch progress; individual readiness requires verified worker results."})]}):null,de&&t.status==="capacity_pending"?e.jsxs("div",{className:"max-w-sm space-y-1",children:[e.jsx($i,{htmlFor:`event-coupon-${t.id}`,children:"Optional coupon"}),e.jsx(I,{id:`event-coupon-${t.id}`,value:q.promotionCode,onChange:o=>Pe(_=>({..._,promotionCode:o.target.value.toUpperCase()})),placeholder:"Coupon code"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Select Apply coupon to validate a code. A 100% coupon records the request as paid/waived without opening Stripe."})]}):null,de&&["capacity_pending","capacity_checked","checkout_pending","paid_pending_approval","paid_preparing","ready","active"].includes(t.status)?e.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Event users"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[r,"/",t.max_instances," slots accepted · ",n.length," inv
23ited"]})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[e.jsx(ld,{"aria-label":`Invite emails for ${t.enterprise_name}`,value:Hn[t.id]||"",onChange:o=>Cr(_=>({..._,[t.id]:o.target.value})),placeholder:`[email protected]
24[email protected]`,rows:3}),e.jsx(b,{type:"button",size:"sm",onClick:()=>void Eo(t),disabled:Yt===t.id||!(Hn[t.id]||"").trim(),children:Yt===t.id?"Adding…":"Invite users"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Enter one email per line or separate emails with commas. You may invite more people than instances. The first ",t.max_instances," to accept receive slots; later acceptances are held at capacity full until you expand. Ready emails are sent only after provisioned capacity is available."]}),n.length>0?e.jsx("div",{className:"space-y-1",children:n.map(o=>e.jsxs("div",{className:"flex min-w-0 flex-col gap-2 rounded border border-border bg-background px-2 py-1.5 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("span",{className:"min-w-0 break-all",children:o.email}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(M,{variant:"outline",children:o.status==="accepted"?`slot ${o.assigned_slot}`:o.status.replace(/_/g," ")}),o.access_delivery==="pending_update"?e.jsx(M,{variant:"outline",children:"Access update pending"}):o.access_delivery==="owner_access"?e.jsx(M,{variant:"outline",children:"Existing owner access"}):null,o.status==="invited"||o.status==="capacity_full"?e.jsx(b,{type:"button",size:"sm",variant:"ghost",onClick:()=>void Ro(o),disabled:Yt===o.id,children:"Revoke"}):null]})]},o.id))}):e.jsx("div",{className:"text-xs text-muted-foreground",children:"No event users invited yet."})]}):null]},t.id)})]}):null,e.jsx(ms,{open:!!Kn,onOpenChange:t=>{t||Bn(null)},children:e.jsxs(ps,{children:[e.jsxs(hs,{children:[e.jsx(xs,{children:"Cancel this capacity request?"}),e.jsx(gs,{children:"Cancellation is allowed only before provisioning starts. Any collected payment is refunded, a pending Stripe Checkout is expired, and a coupon-waived request is simply closed."})]}),e.jsxs(fs,{children:[e.jsx(_s,{disabled:Wn,children:"Keep request"}),e.jsx(ys,{onClick:()=>void Po(),disabled:Wn,children:Wn?"Cancelling…":"Cancel request"})]})]})}),de?null:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Only the Enterprise owner can request or purchase event capacity."})]})]}),ze?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[e.jsx(Xe,{title:"Included",value:Qt,subtitle:"Cloud and on-prem combined"}),e.jsx(Xe,{title:"In use",value:ga,subtitle:"Across your account"}),e.jsx(Xe,{title:"Remaining",value:nn,subtitle:"Before another package is needed"}),e.jsx(Xe,{title:"Current run rate",value:`${j(di)}/mo`,subtitle:"Current monthly charges across your account"})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]",children:[e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsx(se,{children:"Enterprise account"}),e.jsx(ne,{children:"Identity, billing scope, and included capacity."})]}),e.jsxs(B,{className:"space-y-3",children:[de?e.jsxs(b,{type:"button",className:"w-full",onClick:()=>void To(),disabled:yr,children:[e.jsx(Oe,{className:"mr-2 h-4 w-4"}),yr?"Opening Enterprise…":"Open Enterprise workspace"]}):null,[{label:"Enterprise",value:(c==null?void 0:c.enterprise_name)||(c==null?void 0:c.name)||"Not set"},{label:"Website",value:(c==null?void 0:c.enterprise_website_url)||"Not set"},{label:"Access",value:de?"Owner":"Member"},{label:"Capacity",value:`${Qt} mixed instances`},{label:"Cloud",value:"Dedicated cluster nodes"},{label:"Included maintenance",value:`First ${oi} ${oi===1?"month":"months"}`},{label:"Recurring maintenance",value:`${j(gn())}/mo after the included window`},{label:"Templates",value:"Expanded enterprise catalog"},{label:"Support",value:"Dedicated support path"}].map(t=>e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t.label}),e.jsx("span",{className:"text-right text-sm text-foreground",children:t.value})]},t.label))]})]}),e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsx(se,{children:de?"Settings and members":"Membership"}),e.jsx(ne,{children:de?"Update your enterprise identity and add member emails.":"Your access comes from an enterprise owner."})]}),e.jsxs(B,{className:"space-y-3",children:[de?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Enterprise name"}),e.jsx(I,{value:q.enterpriseName,onChange:t=>Pe(n=>({...n,enterpriseName:t.target.value})),placeholder:"Acme AI"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Company website"}),e.jsx(I,{value:q.enterpriseWebsiteUrl,onChange:t=>Pe(n=>({...n,enterpriseWebsiteUrl:t.target.value})),placeholder:"https://acme.example"})]}),e.jsx(b,{type:"button",variant:"outline",onClick:()=>void Do(),disabled:Ir,children:Ir?"Saving…":"Save enterprise settings"}),e.jsxs("div",{className:"space-y-2 rounded-md border border-border px-3 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Add enterprise member"}),e.jsx(I,{value:ea,onChange:t=>Mr(t.target.value),placeholder:"[email protected]"}),e.jsx(b,{type:"button",size:"sm",onClick:()=>void $o(),disabled:Er,children:Er?"Adding…":"Add member"})]})]}):e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground",children:"You can use the shared enterprise instances in this account, but only the enterprise owner can update billing, invites, or enterprise settings."}),e.jsxs("div",{className:"space-y-2 rounded-md border border-border px-3 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Member emails"}),e.jsx("div",{className:"space-y-2",children:Or.length>0?Or.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm",children:[e.jsx("span",{className:"text-foreground",children:t.email}),de?e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:()=>void Lo(t.id),disabled:Ar===t.id,children:Ar===t.id?"Removing…":"Remove"}):e.jsx("span",{className:"text-muted-foreground",children:"Member"})]},t.id)):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No extra member emails added yet."})})]})]})]})]}),e.jsx(bn,{productLabel:"Enterprise",inviteUrl:Qi,unlocked:ze,extraNote:"After you join the shared enterprise onboarding group, ClawMax will create a dedicated WhatsApp group just for your enterprise support."})]}):qe.length===0&&lt.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,0.85fr)]",children:[e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsx(se,{children:"Upgrade to Enterprise"}),e.jsx(ne,{children:"Prepaid mixed-instance capacity for cloud and on-prem."})]}),e.jsxs(B,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-muted/20 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Included capacity"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold text-foreground",children:we}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"mixed cloud/on-prem instances"})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-muted/20 px-4 py-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Setup fee"}),e.jsx("div",{className:"mt-1 text-2xl font-semibold text-foreground",children:j(Rt(we))}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Prepaid package price"})]})]}),e.jsxs("div",{className:"grid gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:["5 mixed instances starts at ",j(Rt(5))," with 6 months included maintenance."]}),e.jsxs("div",{children:["10 mixed instances is ",j(Rt(10))," with 12 months included maintenance."]}
24),e.jsxs("div",{children:["15 mixed instances is ",j(Rt(15))," with 12 months included maintenance."]}),e.jsxs("div",{children:["20 mixed instances is ",j(Rt(20))," with 12 months included maintenance."]}),e.jsxs("div",{className:"font-medium text-foreground",children:["Recurring maintenance after the included window is ",j(gn()),"/mo."]})]}),e.jsxs(ft,{open:oo,onOpenChange:Ls,children:[e.jsx(us,{asChild:!0,children:e.jsxs(b,{className:"w-full justify-start",children:[e.jsx(Lt,{className:"mr-2 h-4 w-4"}),"Upgrade and pay"]})}),e.jsxs(_t,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-3xl",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Upgrade to enterprise"}),e.jsx(tt,{children:"Choose a mixed-instance package size. Enterprise includes dedicated cloud isolation, a tier-based included maintenance window, and a dedicated support path."})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-[220px_minmax(0,1fr)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"pt-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Enterprise name"}),e.jsx(I,{className:"mt-2 bg-background",value:q.enterpriseName,onChange:t=>Pe(n=>({...n,enterpriseName:t.target.value})),placeholder:"Acme AI"})]}),e.jsxs("div",{className:"pt-1",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Company website"}),e.jsx(I,{className:"mt-2 bg-background",value:q.enterpriseWebsiteUrl,onChange:t=>Pe(n=>({...n,enterpriseWebsiteUrl:t.target.value})),placeholder:"https://acme.example"})]}),e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Included mixed instances"}),e.jsxs(Ve,{value:String(we),onValueChange:t=>Un(Number(t)),children:[e.jsx(Ye,{className:"bg-background",children:e.jsx(Ge,{})}),e.jsx(Je,{children:ud.map(t=>e.jsxs(Ce,{value:String(t),children:[t," instances"]},t))})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Promotion code"}),e.jsx(I,{className:"mt-2 bg-background",value:q.promotionCode,onChange:t=>Pe(n=>({...n,promotionCode:t.target.value.toUpperCase()})),placeholder:"Optional enterprise promo"})]})]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/20 px-4 py-4",children:[e.jsxs("div",{className:"grid gap-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Setup fee:"})," ",j(Rt(we))]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Included maintenance:"})," ",an," ",an===1?"month":"months"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Recurring maintenance:"})," ",j(gn()),"/mo after the included window"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Cloud topology:"})," Dedicated cluster nodes"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Templates:"})," Custom ClawMax template registry to save and share templates"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Support:"})," Dedicated support line and WhatsApp onboarding"]}),q.promotionCode.trim()?e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-foreground",children:"Promotion:"})," ",q.promotionCode.trim()," will be validated at checkout."]}):null]}),e.jsxs("div",{className:"rounded-md border border-primary/30 bg-primary/5 px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-primary",children:"Maintenance"}),e.jsxs("div",{className:"mt-1 font-semibold text-foreground",children:[j(gn()),"/mo after the included ",an," ",an===1?"month":"months"]})]})]})]}),e.jsx(Ka,{accessToken:(s==null?void 0:s.access_token)||null,customerId:g||(y==null?void 0:y.id)||null,customer:y,compact:!0}),e.jsxs(st,{className:"flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(b,{variant:"outline",onClick:()=>Ls(!1),children:"Close"}),e.jsx(b,{onClick:()=>void Mo(),disabled:fr,children:fr?"Redirecting…":"Continue to payment"})]})]})]})]})]}),e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsx(se,{children:"What you get"}),e.jsx(ne,{children:"Main differences from the standard path."})]}),e.jsx(B,{className:"space-y-3",children:["Prepaid mixed cloud/on-prem capacity.","Dedicated cluster nodes for enterprise cloud deployments.","6 to 12 months of included maintenance before recurring maintenance starts, depending on tier.","Expanded templates and a dedicated support path."].map(t=>e.jsx("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-foreground",children:t},t))})]})]}),e.jsx(bn,{productLabel:"Enterprise",inviteUrl:Qi,unlocked:ze})]}):null]}):null,v==="profile"?e.jsxs("section",{className:"grid gap-6 xl:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsxs(se,{className:"flex items-center gap-2",children:[e.jsx(Ei,{className:"h-5 w-5"}),"Your profile"]}),e.jsx(ne,{children:"Account identity."})]}),e.jsx(B,{className:"space-y-3",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-4",children:[a.avatar_url?e.jsx("img",{src:a.avatar_url,alt:"",className:"h-12 w-12 rounded-full border border-border"}):e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full border border-border bg-muted text-lg font-semibold text-muted-foreground",children:(a.full_name||a.github_username||"?").charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:a.full_name||a.github_username||"Unknown"}),a.email?e.jsx("div",{className:"text-sm text-muted-foreground",children:a.email}):null]})]}),[{label:"GitHub",value:a.github_username?`@${a.github_username}`:"Not linked"},{label:"Role",value:a.role==="admin"?"Admin / Founder":"User"},{label:"Member since",value:new Date(a.created_at).toLocaleDateString()}].map(t=>e.jsxs("div",{className:"flex items-start justify-between gap-4 roun
24ded-md border border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t.label}),e.jsx("span",{className:"text-right text-sm text-foreground",children:t.value})]},t.label))]}):e.jsx("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:"Sign in to view your profile."})})]}),e.jsxs(K,{children:[e.jsxs(te,{children:[e.jsx(se,{children:"Billing"}),e.jsx(ne,{children:"Saved billing method and maintenance billing."})]}),e.jsxs(B,{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"rounded-md border border-border px-3 py-3 text-sm",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Billing status"}),e.jsx("div",{className:"mt-2",children:e.jsx(M,{variant:y!=null&&y.stripe_payment_method_ready?"default":"outline",children:y!=null&&y.stripe_payment_method_ready?"Billing method on file":"Billing not set up"})})]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-3 text-sm",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Saved method"}),e.jsx("div",{className:"mt-2 font-medium text-foreground",children:y!=null&&y.stripe_payment_method_ready?cr(y.stripe_default_payment_method_brand,y.stripe_default_payment_method_last4):"No billing method on file"})]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-3 text-sm",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Recurring maintenance"}),e.jsx("div",{className:"mt-2 text-muted-foreground",children:y!=null&&y.stripe_payment_method_ready?"Active cloud and on-prem maintenance subscriptions use this billing profile.":"Set up billing first so maintenance can be activated when needed."})]})]}),[{label:"Billing email",value:(a==null?void 0:a.email)||"Not available"},{label:"Account name",value:(a==null?void 0:a.full_name)||(a==null?void 0:a.github_username)||"Not available"}].map(t=>e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:t.label}),e.jsx("span",{className:"text-right text-sm text-foreground",children:t.value})]},t.label)),e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground",children:y!=null&&y.stripe_payment_method_ready?"Billing is ready. Open Stripe any time to update the saved card or manage subscription changes.":"Billing is not set up yet. Add a saved card so setup charges and maintenance can be handled without delay."}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:e.jsx($t,{accessToken:(s==null?void 0:s.access_token)||null,customerId:g||(y==null?void 0:y.id)||null,customer:y})})]})]}),e.jsxs(K,{className:"xl:col-span-2",children:[e.jsxs(te,{children:[e.jsx(se,{children:"Terms of Service"}),e.jsx(ne,{children:"Current version and acceptance."})]}),e.jsxs(B,{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Current version"}),e.jsx("div",{className:"mt-1 font-medium text-foreground",children:Zo})]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm",children:[e.jsx("div",{className:"text-xs font-medium uppercase tracking-[0.18em] text-muted-foreground",children:"Accepted"}),e.jsx("div",{className:"mt-1 font-medium text-foreground",children:$e})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(b,{variant:"outline",asChild:!0,children:e.jsxs(He,{to:"/terms",children:[e.jsx(Ri,{className:"mr-2 h-4 w-4"}),"Review terms"]})})})]})]})]}):e.jsxs(e.Fragment,{children:[v==="cloud"?e.jsxs("section",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ii,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Your cloud instances"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"See what is running, what it costs, and request another cloud instance when you need one."})]})]}),wi,e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(bn,{productLabel:"Cloud",inviteUrl:kd,unlocked:fo}),e.jsxs(K,{className:"flex h-full flex-col",children:[e.jsxs(te,{children:[e.jsx(se,{children:"Request new cloud instance"}),e.jsx(ne,{children:"Launch another managed cloud instance for a new workspace, team, or environment."})]}),e.jsxs(B,{className:"flex flex-1 flex-col gap-3",children:[e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:"You are not limited to one cloud instance. Each new request appears in the list below once queued."})}),e.jsxs(ft,{open:lo,onOpenChange:yi,children:[e.jsx(us,{asChild:!0,children:e.jsxs(b,{className:"w-full justify-start",children:[e.jsx(Wi,{className:"mr-2 h-4 w-4"}),"Request new cloud instance"]})}),e.jsxs(_t,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-4xl",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Request new cloud instance"}),e.jsx(tt,{children:"Start a new managed cloud deployment for your account. You can run more than one cloud instance at a time."})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-display-name",className:"text-sm font-medium text-foreground",children:"Instance name"}),e.jsx(I,{id:"client-cloud-display-name",value:C.displayName,onChange:t=>re(n=>({...n,displayName:t.target.value})),placeholder:"new-instance"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Region"}),e.jsxs(Ve,{value:C.region,onValueChange:t=>re(n=>({...n,region:t})),children:[e.jsx(Ye,{children:e.jsx(Ge,{})}),e.jsx(Je,{children:vd.map(t=>e.jsx(Ce,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-promo",className:"text-sm font-medium text-foreground",children:"Promotion code"}),e.jsx(I,{id:"client-cloud-promo",value:C.promotionCode,onChange:t=>re(n=>({...n,promotionCode:t.target.value.toUpperCase()})),placeholder:"Optional"})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-[200px_minmax(0,1fr)] sm:items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Access"}),e.jsx(xl,{})]}),e.jsxs(Ve,{value:C.dashboardAuthMode,onValueChange:t=>re(n=>({...n,dashboardAuthMode:t})),children:[e.jsx(Ye,{className:"w-full",children:e.jsx(Ge,{})}),e.jsxs(Je,{children:[e.jsx(Ce,{value:"email_otp",children:"Email OTP"}),e.jsx(Ce,{value:"bypass",children:"Bypass"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Email OTP sends a one-time password to the allowed email address when someone signs in."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-otp-emails",className:"text-sm font-medium text-foreground",children:"Allowed emails"}),e.jsx(I,{id:"client-cloud-otp-emails",value:C.otpAllowedEmails,onChange:t=>re(n=>({...n,otpAllowedEmails:t.target.value})),disabled:C.dashboardAuthMode!=="email_otp",placeholder:"[email protected]",className:"w-full"})]})]}),C.dashboardAuthMode==="bypass"?e.jsx("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:"Bypass leaves the dashboard unsecured. Only use it when you intentionally want no sign-in gate."}):null]}),e.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 px-3 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Cost & budget monitoring"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Cloud maintenance is ",j(_e({useManagedOpik:!0})),"/mo with one ClawMax-managed add-on bundle. The same +",j(Pa()),"/mo covers both managed Opik telemetry and managed Resend email for agent-to-user and agent-to-operator workflows."]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/70 bg-background px-3 py-3",children:[e.jsx(bs,{checked:C.useManagedOpik,onCheckedChange:t=>re(n=>({...n,useManagedOpik:t!==!1,opikApiKey:t!==!1?"":n.opikApiKey,opikWorkspace:t!==!1?"":n.opikWorkspace,opikProject:t!==!1?"":n.opikProject,resendApiKey:t!==!1?"":n.resendApiKey})),className:"mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-sm font-medium text-foreground",children:["Include the ClawMax-managed Opik + Resend bundle (+",j(Pa()),"/mo)"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Leave this on if you want both detailed LLM cost and budget tracking plus managed agent email ready immediately. Uncheck it if you want to use your own keys and save ",j(Pa()),"/mo."]})]})]}),C.useManagedOpik?e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("div",{children:"Managed Opik: ClawMax injects the Comet Opik workspace and project during provisioning."}),e.jsx("div",{className:"mt-1",children:"Managed Resend: ClawMax injects the shared Resend sender defaults and API key for this workspace’s agent-driven email flows."})]}):e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-900 dark:text-emerald-200",children:["You are bringing your own keys, so your recurring maintenance will be ",j(_e({useManagedOpik:!1})),"/mo instead of ",j(_e({useManagedOpik:!0})),"/mo."]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("label",{htmlFor:"client-cloud-opik-key",className:"text-sm font-medium text-foreground",children:"Opik API key"}),e.jsx(I,{id:"client-cloud-opik-key",type:"password",value:C.opikApiKey,onChange:t=>re(n=>({...n,opikApiKey:t.target.value})),placeholder:"Paste your Opik API key"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("label",{htmlFor:"client-cloud-resend-key",className:"text-sm font-medium text-foreground",children:"Resend API key"}),e.jsx(I,{id:"client-cloud-resend-key",type:"password",value:C.resendApiKey,onChange:t=>re(n=>({...n,resendApiKey:t.target.value})),placeholder:"Optional: paste your Resend API key"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Used for agent-to-user and agent-to-operator email. Sender defaults still come from ClawMax for this release."})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-opik-workspace",className:"text-sm font-medium text-foreground",children:"Worksp
24ace"}),e.jsx(I,{id:"client-cloud-opik-workspace",value:C.opikWorkspace,onChange:t=>re(n=>({...n,opikWorkspace:t.target.value})),placeholder:"e.g. product-observability"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-opik-project",className:"text-sm font-medium text-foreground",children:"Project"}),e.jsx(I,{id:"client-cloud-opik-project",value:C.opikProject,onChange:t=>re(n=>({...n,opikProject:t.target.value})),placeholder:"e.g. nyc1-agents"})]})]})]})]})]}),ot?e.jsx(tl,{backups:Sr,selected:C.workspaceBackupIds,onChange:t=>re(n=>({...n,workspaceBackupIds:t}))}):null,e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:Pt?`Your enterprise package already covers ${nn} more mixed instances, so this request can be queued without an extra setup payment. Recurring maintenance after the included enterprise support window will be ${j(_e({useManagedOpik:C.useManagedOpik}))}/mo.`:ya?`You have ${fa} paid or promo cloud replacement slot${fa===1?"":"s"} available, so this request can replace a deleted cloud instance without another setup payment${c!=null&&c.cloud_replacement_support_free_until?` until ${be(c.cloud_replacement_support_free_until)}`:""}. Recurring maintenance after the included first month will be ${j(_e({useManagedOpik:C.useManagedOpik}))}/mo.`:rn?C.promotionCode.trim()?`Promotion ${C.promotionCode.trim()} will be validated before provisioning is queued. If it fully waives setup, checkout will be skipped; otherwise the setup discount will be applied at payment. Recurring maintenance after the included first month will be ${j(_e({useManagedOpik:C.useManagedOpik}))}/mo.`:`Setup fee payment is required before provisioning is queued. Recurring maintenance after the included first month will be ${j(_e({useManagedOpik:C.useManagedOpik}))}/mo.`:`This request can be queued immediately. Recurring maintenance after the included first month will be ${j(_e({useManagedOpik:C.useManagedOpik}))}/mo.`}),rn?e.jsx(Ka,{accessToken:(s==null?void 0:s.access_token)||null,customerId:g||(y==null?void 0:y.id)||null,customer:y,compact:!0}):null,e.jsxs("div",{className:"text-xs text-muted-foreground",children:["By continuing, you agree to the ",e.jsx(Oi,{className:"inline h-auto px-0 text-xs align-baseline"}),"."]}),e.jsxs(st,{className:"flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(b,{variant:"outline",onClick:()=>yi(!1),children:"Cancel"}),e.jsx(b,{onClick:()=>void bi(),disabled:xr,children:xr?"Requesting…":Pt&&!C.promotionCode.trim()?"Request within enterprise":ya?"Replace paid/promo cloud instance":rn?C.promotionCode.trim()?"Continue":"Continue to payment":"Request cloud instance"})]})]})]})]})]})]}),e.jsx(K,{children:e.jsxs(B,{className:"pt-6",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex w-full max-w-xl items-center gap-2",children:[e.jsx(I,{value:ra,onChange:t=>qr(t.target.value),placeholder:"Search your cloud instances","aria-label":"Search cloud instances"}),ra?e.jsx(b,{type:"button",variant:"outline",size:"icon",onClick:()=>qr(""),"aria-label":"Clear cloud search",children:e.jsx(Ai,{className:"h-4 w-4"})}):null]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Ne.length," of ",F.length," cloud instances"]})]}),Ne.length>gt?e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 text-sm text-muted-foreground",children:[e.jsxs("div",{children:["Showing ",(ce-1)*gt+1,"-",Math.min(ce*gt,Ne.length)," of ",Ne.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>Gt(t=>Math.max(1,t-1)),disabled:ce<=1,"aria-label":"Previous cloud page",children:"Previous"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Page ",ce," of ",on]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>Gt(t=>Math.min(on,t+1)),disabled:ce>=on,"aria-label":"Next cloud page",children:"Next"})]})]}):null,i?e.jsxs("div",{className:"space-y-3",children:[Ne.length===0?e.jsx("div",{className:"rounded-md border border-dashed border-border px-4 py-8 text-center text-sm text-muted-foreground",children:F.length===0?"N
24o cloud instances yet":"No cloud instances match your search"}):null,dn.map(t=>{if(Zr.has(t.id))return ji(t,!0);const n=ks(Ae,"cloud_instance",t.id),r=wa(t,n),l=vs(n),m=Ja(t),o=wn(t);return e.jsxs("div",{className:J("rounded-lg border border-border p-4",t.id===H&&"border-primary/50 bg-primary/5"),onClick:()=>{ie(""),Le(t.id),Ws(!0)},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"break-words",onClick:_=>_.stopPropagation(),children:[La(t),Sa(t.billing_target_id,qe)?e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[e.jsx(M,{variant:"outline",children:"Enterprise"}),e.jsx(M,{variant:"outline",children:"Event"})]}):null]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t.region}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[m?e.jsx(M,{variant:m.variant,className:J("w-fit",m.className),children:m.label}):null,o?e.jsx(M,{variant:o.variant,className:J("w-fit",o.className),children:o.label}):null]})]}),e.jsx("div",{onClick:_=>_.stopPropagation(),children:_n({kind:"cloud",onAction:n?void 0:_=>void mi(_,t.id),onOpenCloudOpikSettings:n?void 0:()=>hi(t),onDelete:n?void 0:()=>St({kind:"cloud",id:t.id,label:t.id,detail:t.service_url||t.region})})})]}),e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[fn(r.label,r.variant,r.className,l),r.detail?e.jsx("div",{className:"text-xs text-muted-foreground",children:r.detail}):null]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-muted-foreground",children:"Billing"}),e.jsxs("div",{className:"text-sm text-foreground",children:[j(t.monthly_cost+t.model_monthly_cost+ws(t)),"/mo"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Setup ",j(t.setup_fee)," · ",Dt(t)]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-muted-foreground",children:"Version"}),e.jsx("div",{className:"text-sm text-foreground",children:t.version||"Unknown"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Last deploy ",t.last_deploy_at?be(t.last_deploy_at):"Not yet"]})]})]}),Ns(t)?e.jsxs("a",{href:t.service_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-primary underline-offset-4 hover:underline",onClick:_=>_.stopPropagation(),children:["Open dashboard",e.jsx(Oe,{className:"h-3 w-3"})]}):null]})]},t.id)})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Li,{className:"min-w-[760px]",children:[e.jsx(Ui,{children:e.jsxs(xt,{children:[e.jsx(fe,{children:"Instance"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Billing"}),e.jsx(fe,{children:"Version"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(qi,{children:[Ne.length===0?e.jsx(xt,{children:e.jsx(G,{colSpan:5,className:"py-8 text-center text-sm text-muted-foreground",children:F.length===0?"No cloud instances yet":"No cloud instances match your search"})}):null,dn.map(t=>{if(Zr.has(t.id))return ji(t,!1);const n=ks(Ae,"cloud_instance",t.id),r=wa(t,n),l=vs(n),m=Ja(t),o=wn(t),_=(S==null?void 0:S.kind)==="cloud"&&S.id===t.id&&S.action==="cancel";return e.jsxs(xt,{className:J(t.id===H&&Ji),onClick:()=>{ie(""),Le(t.id),Ws(!0)},children:[e.jsx(G,{className:J(t.id===H&&Zi),children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{onClick:N=>N.stopPropagation(),children:[La(t),Sa(t.billing_target_id,qe)?e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[e.jsx(M,{variant:"outline",children:"Enterprise"}),e.jsx(M,{variant:"outline",children:"Event"})]}):null]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.region}),m?e.jsx(M,{variant:m.variant,className:J("w-fit",m.className),children:m.label}):null,o?e.jsx(M,{variant:o.variant,className:J("w-fit",o.className),children:o.label}):null,Ns(t)?e.jsxs("a",{href:t.service_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-primary underline-offset-4 hover:underline",onClick:N=>N.stopPropagation(),children:["Open dashboard",e.jsx(Oe,{className:"h-3 w-3"})]}):null]})}),e.jsx(G,{children:e.jsxs("div",{className:"space-y-1",children:[fn(r.label,r.variant,r.className,l),r.detail?e.jsx("div",{className:"text-xs text-muted-foreground",children:r.detail}):null]})}),e.jsx(G,{children:e.jsx(Ti,{recurringLabel:"Run",recurringValue:`${j(t.monthly_cost+t.model_monthly_cost+ws(t))}/mo`,setupFee:j(t.setup_fee),supportLabel:(t.recurring_support_enabled,"Support"),supportValue:Dt(t),detailRows:[{label:"Infrastru
24cture",value:`${j(t.monthly_cost)}/mo`},{label:"Model usage",value:Ga(t)},{label:"One-time setup",value:j(t.setup_fee)},{label:"Recurring support",value:Dt(t)},{label:"Coupon",value:t.promotion_code?`${t.promotion_code} applied`:"No active coupon"}],footerActions:t.stripe_subscription_id?e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:_,onClick:()=>Hs({kind:"cloud",id:t.id,label:t.id}),children:_?"Cancelling…":"Cancel recurring maintenance"}):null})}),e.jsx(G,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{children:t.version||"Unknown"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Last deploy ",t.last_deploy_at?be(t.last_deploy_at):"Not yet"]})]})}),e.jsx(G,{children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:_n({kind:"cloud",onAction:n?void 0:N=>void mi(N,t.id),onOpenCloudOpikSettings:n?void 0:()=>hi(t),onDelete:n?void 0:()=>St({kind:"cloud",id:t.id,label:t.id,detail:t.service_url||t.region})})})})]},t.id)})]})]})})]})}),w?(()=>{const t=ks(Ae,"cloud_instance",w.id),n=wa(w,t),r=Zl(w),l=(S==null?void 0:S.kind)==="cloud"&&S.id===w.id,m=`${j(w.monthly_cost+w.model_monthly_cost+ws(w))}/mo`,o=Ns(w)?e.jsxs("a",{href:w.service_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-primary underline-offset-4 hover:underline",children:["Open dashboard",e.jsx(Oe,{className:"h-4 w-4"})]}):w.service_url?"Reported by worker, not publicly ready yet":"Not ready yet",_=!!(y!=null&&y.stripe_payment_method_ready),N=e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx("span",{children:w.stripe_subscription_id?"Recurring active":"Recurring not active"}),w.stripe_subscription_id?e.jsx($t,{accessToken:(s==null?void 0:s.access_token)||null,customerId:w.customer_id||g||(y==null?void 0:y.id)||null,customer:y,triggerLabel:"View billing",triggerVariant:"outline",triggerSize:"sm",returnPath:"/client/cloud",targetType:"cloud_instance",targetId:w.id}):_?e.jsxs(b,{type:"button",size:"sm",variant:"outline",disabled:l,onClick:()=>void cn({kind:"cloud",id:w.id}),children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),l&&(S==null?void 0:S.action)==="activate"?"Activating…":"Activate recurring maintenance"]}):e.jsx($t,{accessToken:(s==null?void 0:s.access_token)||null,customerId:w.customer_id||g||(y==null?void 0:y.id)||null,customer:y,triggerLabel:"Set up billing",triggerVariant:"outline",triggerSize:"sm",returnPath:"/client/cloud",targetType:"cloud_instance",targetId:w.id})]}),$=[{label:"Region",value:w.region},{label:"Provider",value:w.provider},{label:"Billing mode",value:w.billing_mode},{label:"Model usage",value:Ga(w)},{label:"Cost monitoring",value:Jl(w)},...w.cluster_display_name||w.cluster_id?[{label:"Cluster",value:w.cluster_display_name||w.cluster_id||"Unknown"}]:[],...w.cluster_region?[{label:"Cluster region",value:w.cluster_region}]:[],...w.placement_reason?[{label:"Placement",value:Fl(w.placement_reason,w.cluster_region,w.id)}]:[],...w.cpu_limit||w.memory_limit?[{label:"Capacity",value:`CPU ${w.cpu_limit||"n/a"} · RAM ${w.memory_limit||"n/a"}`}]:[],...w.workspace_storage?[{label:"Workspace storage",value:w.workspace_pvc_name?`${w.workspace_storage} · ${w.workspace_pvc_name}`:w.workspace_storage}]:[],...w.last_restart_at?[{label:"Last restart",value:w.last_restart_at}]:[],...w.last_status_summary?[{label:"Latest status",value:w.last_status_summary}]:[]];return e.jsxs("div",{className:"space-y-4",children:[r?e.jsxs(pn,{variant:r.stage==="warning"?"default":"destructive",className:"border-amber-500/40 bg-amber-50/80 dark:bg-amber-950/20",children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx(Oa,{children:r.stage==="delete_queued"?"Deletion is queued for this instance":r.stage==="delete_due"?"This instance is overdue for cleanup":r.stage==="final_warning"?"Final maintenance renewal warning":"Maintenance renewal warning"}),e.jsxs(hn,{children:[e.jsxs("p",{children:["This instance will be deleted at ",be(r.deleteAfter)," unless you register recurring maintenance in billing."]}),e.jsx("div",{className:"mt-3",children:e.jsxs(b,{type:"button",size:"sm",disabled:l,onClick:()=>
24{if(y!=null&&y.stripe_payment_method_ready){cn({kind:"cloud",id:w.id});return}Ss(s==null?void 0:s.access_token,{customerId:w.customer_id||g||(y==null?void 0:y.id)||null,paymentMethodReady:!1,returnPath:"/client/cloud",targetType:"cloud_instance",targetId:w.id})},children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),l&&(S==null?void 0:S.action)==="activate"?"Activating…":y!=null&&y.stripe_payment_method_ready?"Activate recurring maintenance":"Set up billing"]})}),e.jsx("p",{className:"mt-2",children:"If you do not want to keep this instance, export your workspaces before that time so you retain your data."})]})]}):null,e.jsxs(K,{children:[e.jsxs(te,{className:"flex flex-row items-start justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(se,{children:w.id}),e.jsx(ne,{children:"Dashboard, state, versions, billing, and access."})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>Ws(Y=>!Y),"aria-expanded":ut,"aria-controls":"client-cloud-selected-detail",children:ut?"Hide details":"Show details"})]}),ut?e.jsx(B,{id:"client-cloud-selected-detail",className:"space-y-3",children:[{label:"Dashboard",value:o},{label:"Dashboard Link",value:e.jsx("div",{className:"max-w-[28rem] text-right",children:Dd(w)})},{label:"Status",value:n.label},...n.detail?[{label:"Current action",value:n.detail}]:[],...w.version?[{label:"Dashboard version",value:w.version}]:[],{label:"Last deploy",value:w.last_deploy_at||"Not yet"},{label:"Billing",value:N},{label:"Run rate",value:m},{label:"Maintenance",value:Dt(w)},{label:"Setup fee",value:j(w.setup_fee)},...r?[{label:"Scheduled deletion",value:be(r.deleteAfter)}]:[]].map(Y=>e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:Y.label}),e.jsx("span",{className:"text-right text-sm text-foreground",children:Y.value})]},Y.label))}):null]}),ut?ml(Dr,$r):null,ut&&$.length>0?e.jsx(K,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"cursor-pointer list-none text-sm font-medium text-foreground",children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Advanced details",e.jsx("span",{className:"text-xs text-muted-foreground group-open:hidden",children:"Show"}),e.jsx("span",{className:"hidden text-xs text-muted-foreground group-open:inline",children:"Hide"})]})}),e.jsx("div",{className:"mt-4 space-y-3",children:$.map(Y=>e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:Y.label}),e.jsx("span",{className:"text-right text-sm text-foreground",children:Y.value})]},Y.label))})]})})}):null]})})():null]}):null,v==="onprem"?e.jsxs("section",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Pi,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Your on-prem instances"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open the dashboard, sync or reconnect this Mac, and use install steps only when needed."})]})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(bn,{productLabel:"On-Prem",inviteUrl:Nd,unlocked:_o}),e.jsxs(K,{className:"flex h-full flex-col",children:[e.jsxs(te,{children:[e.jsx(se,{children:"Request new on-prem deployment"}),e.jsx(ne,{children:"Register a site, then install or reconnect the local agent on the target machine."})]}),e.jsx(B,{className:"flex flex-1 flex-col gap-3",children:e.jsxs(ft,{open:so,onOpenChange:un,children:[e.jsx(us,{asChild:!0,children:e.jsxs(b,{className:"mt-auto w-full justify-start",children:[e.jsx(Wi,{className:"mr-2 h-4 w-4"}),"Request new on-prem deployment"]})}),e.jsx(_t,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-4xl",children:no?e.jsxs(e.Fragment,{children:[e.jsxs(Qe,{children:[e.jsxs(et,{children:["Next steps for ",k.siteName]}),e.jsx(tt,{children:"Your deployment has been registered. Choose the install path below that matches this machine."})]}),e.jsxs("div",{className:"space-y-4 text-sm text-foreground",children:[e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-4 py-3",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"macOS:"})," use the direct ",e.jsx("strong",{children:Et})," download first, then connect this Mac from the installed app. Update ",e.jsx("strong",{children:"Podman to 5.8.x or newer"})," before connecting."]}),e.jsxs("p",{className:"mt-2",children:[e.jsx("strong",{children:"Linux, Windows, and manual macOS setups:"})," use the ",e.jsx("strong",{children:"Manual"})," path."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:"Jump straight to the install guide below:"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:Mi,target:"_blank",rel:"noopener noreferrer",onClick:()=>ns("installer"),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Download macOS .pkg"]})}),e.jsx(b,{variant:"outline",onClick:()=>ns("homebrew"),children:"Homebrew"}),e.jsx(b,{variant:"outline",onClick:()=>ns("manual"),children:"Manual"})]})]})]}),e.jsx(st,{children:e.jsx(b,{variant:"outline",onClick:()=>un(!1),children:"Close"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Request new on-prem deployment"}),e.jsx(tt,{children:"Name the site and choose how dashboard sign-in should work for that deployment."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Site name"}),e.jsx(I,{placeholder:"new-site",value:k.siteName,onChange:t=>ae(n=>({...n,siteName:t.target.value}))})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Included maintenance"}),e.jsxs(Ve,{value:String(k.supportPackageMonths),onValueChange:t=>ae(n=>({...n,supportPackageMonths:Wa(Number(t))?Number(t):Ol()})),children:[e.jsx(Ye,{className:"w-full",children:e.jsx(Ge,{})}),e.jsxs(Je,{children:[e.jsxs(Ce,{value:"6",children:["6 months included · ",j(Ea(6))]}),e.jsxs(Ce,{value:"12",children:["12 months included · ",j(Ea(12))]})]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Recurring maintenance stays ",j(pe({useManagedOpik:k.useManagedOpik})),"/mo after the included window. The 12-month option includes a longer runway before recurring maintenance starts."]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Models"}),e.jsx("div",{className:"rounded-md border border-input bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:"Bring your own model keys in the dashboard after deploy"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-onprem-promo",className:"text-sm font-medium text-foreground",children:"Promotion code"}),e.jsx(I,{id:"client-onprem-promo",placeholder:"Optional",value:k.promotionCode,onChange:t=>ae(n=>({...n,promotionCode:t.target.value.toUpperCase()}))})]})]}),e.jsxs("div",{className:"space-y-4 rounded-md border border-border/60 bg-muted/30 px-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-[200px_minmax(0,1fr)] sm:items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Access"}),e.jsx(xl,{})]}),e.jsxs(Ve,{value:k.dashboardAuthMode,onValueChange:t=>ae(n=>({...n,dashboardAuthMode:t})),children:[e.jsx(Ye,{className:"w-full",children:e.jsx(Ge,{})}),e.jsxs(Je,{children:[e.jsx(Ce,{value:"email_otp",children:"Email OTP"}),e.jsx(Ce,{value:"bypass",children:"Bypass"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Email OTP sends a one-time password to the allowed email address when someone signs in."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Allowed emails"}),e.jsx(I,{value:k.otpAllowedEmails,onChange:t=>ae(n=>({...n,otpAllowedEmails:t.target.value})),placeholder:"[email protected]",disabled:k.dashboardAuthMode!=="email_otp",className:"w-full"})]})]}),k.dashboardAuthMode==="bypass"?e.jsx("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:"Bypass leaves the dashboard unsecured. Only use it when you intentionally want no sign-in gate."}):null]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-3 rounded-lg border border-border/70 bg-muted/20 px-3 py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"Cost & budget monitoring"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["On-prem maintenance is ",j(pe({useManagedOpik:!0})),"/mo with one ClawMax-managed add-on bundle. The same +",j(Ra()),"/mo covers both managed Opik telemetry and managed Resend email for agent-to-user and agent-to-operator workflows."]})]}),e.jsxs("label",{className:"flex items-start gap-3 rounded-md border border-border/70 bg-background px-3 py-3",children:[e.jsx(bs,{checked:k.useManagedOpik,onCheckedChange:t=>ae(n=>({...n,useManagedOpik:t!==!1,opikApiKey:t!==!1?"":n.opikApiKey,opikWorkspace:t!==!1?"":n.opikWorkspace,opikProject:t!==!1?"":n.opikProject,resendApiKey:t!==!1?"":n.resendApiKey})),className:"mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-sm font-medium text-foreground",children:["Include the ClawMax-managed Opik + Resend bundle (+",j(Ra()),"/mo)"]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Leave this on if you want both detailed LLM cost and budget tracking plus managed agent email ready immediately. Uncheck it if you want to use your own keys and save ",j(Ra()),"/mo."]})]})]}),k.useManagedOpik?e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsx("div",{children:"Managed Opik: ClawMax injects the Comet Opik workspace and project during provisioning."}),e.jsx("div",{className:"mt-1",children:"Managed Resend: ClawMax injects the shared Resend sender defaults and API key for this workspace’s agent-driven email flows."})]}):e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-900 dark:text-emerald-200",children:["You are bringing your own keys, so your recurring maintenance will be ",j(pe({useManagedOpik:!1})),"/mo instead of ",j(pe({useManagedOpik:!0})),"/mo."]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("label",{htmlFor:"client-onprem-opik-key",className:"text-sm font-medium text-foreground",children:"Opik API key"}),e.jsx(I,{id:"client-onprem-opik-key",type:"password",value:k.opikApiKey,onChange:t=>ae(n=>({...n,opikApiKey:t.target.value})),placeholder:"Paste your Opik API key"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx("label",{htmlFor:"client-onprem-resend-key",className:"text-sm font-medium text-foreground",children:"Resend API key"}),e.jsx(I,{id:"client-onprem-resend-key",type:"password",value:k.resendApiKey,onChange:t=>ae(n=>({...n,resendApiKey:t.target.value})),placeholder:"Optional: paste your Resend API key"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Used for agent-to-user and agent-to-operator email. Sender defaults still come from ClawMax for this release."})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-onprem-opik-workspace",className:"text-sm font-medium text-foreground",children:"Worksp
24ace"}),e.jsx(I,{id:"client-onprem-opik-workspace",value:k.opikWorkspace,onChange:t=>ae(n=>({...n,opikWorkspace:t.target.value})),placeholder:"e.g. product-observability"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-onprem-opik-project",className:"text-sm font-medium text-foreground",children:"Project"}),e.jsx(I,{id:"client-onprem-opik-project",value:k.opikProject,onChange:t=>ae(n=>({...n,opikProject:t.target.value})),placeholder:"e.g. nyc1-agents"})]})]})]})]})})]}),ot?e.jsx(tl,{backups:Sr,selected:k.workspaceBackupIds,onChange:t=>ae(n=>({...n,workspaceBackupIds:t}))}):null,e.jsx("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2 text-sm text-muted-foreground",children:Pt?`Your enterprise package already covers ${nn} more mixed instances, so this deployment can be registered without an extra setup payment. Recurring maintenance after the included enterprise support window will be ${j(pe({useManagedOpik:k.useManagedOpik}))}/mo.`:ba?`You have ${_a} paid or promo on-prem replacement slot${_a===1?"":"s"} available, so this deployment can replace a deleted on-prem instance without another setup payment${c!=null&&c.onprem_replacement_support_free_until?` until ${be(c.onprem_replacement_support_free_until)}`:""}. Recurring maintenance after the included first ${k.supportPackageMonths} months will be ${j(pe({useManagedOpik:k.useManagedOpik}))}/mo.`:ln?k.promotionCode.trim()?`Promotion ${k.promotionCode.trim()} will be validated before the deployment request is queued. If it fully waives setup, checkout will be skipped; otherwise the setup discount will be applied at payment. Recurring maintenance after the included first ${k.supportPackageMonths} months will be ${j(pe({useManagedOpik:k.useManagedOpik}))}/mo.`:`Setup fee payment for ${j(Ea(k.supportPackageMonths))} is required before the deployment request is queued. Recurring maintenance after the included first ${k.supportPackageMonths} months will be ${j(pe({useManagedOpik:k.useManagedOpik}))}/mo.`:`This deployment can be registered immediately. Recurring maintenance after the included first ${k.supportPackageMonths} months will be ${j(pe({useManagedOpik:k.useManagedOpik}))}/mo.`}),ln?e.jsx(Ka,{accessToken:(s==null?void 0:s.access_token)||null,customerId:g||(y==null?void 0:y.id)||null,customer:y,compact:!0}):null,e.jsxs("div",{className:"text-xs text-muted-foreground",children:["By continuing, you agree to the ",e.jsx(Oi,{className:"inline h-auto px-0 text-xs align-baseline"}),"."]})]}),e.jsxs(st,{className:"flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(b,{variant:"outline",onClick:()=>un(!1),children:"Cancel"}),e.jsx(b,{onClick:()=>void gi(),disabled:pr,children:pr?"Creating…":Pt&&!k.promotionCode.trim()?"Request within enterprise":ba?"Replace paid/promo on-prem instance":ln?k.promotionCode.trim()?"Continue":"Continue to payment":"Request deployment"})]})]})})]})})]})]}),Gn.some(t=>t.agent_install_status==="Not installed")?e.jsx("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ye,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:"You have deployments waiting for setup"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Download the agent CLI and follow the install guide to bring them online."})]})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("a",{href:"https://github.com/Maximilien-ai/clawmax-cli-releases/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:[e.jsx(ye,{className:"h-4 w-4"}),"Download CLI"]}),e.jsx("button",{type:"button",onClick:()=>{var t;return(t=document.getElementById("install-guide"))==null?void 0:t.scrollIntoView({behavior:"smooth"})},className:"inline-flex items-center rounded-md border border-border px-3 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent",children:"View steps"})]})]})}):null,e.jsx(K,{children:e.jsxs(B,{className:"pt-6",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(ed,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(I,{value:Jt,onChange:t=>Br(t.target.value),placeholder:"Search deployments…",className:"pl-9"}),Jt?e.jsx("button",{type:"button",onClick:()=>Br(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(Ai,{className:"h-3.5 w-3.5"})}):null]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[ts?`${ss.length} of `:"",D.length," on-prem deployments"]})]}),i?e.jsxs("div",{className:"space-y-3",children:[ss.length===0?e.jsx("div",{className:"rounded-md border border-dashed border-border px-4 py-8 text-center text-sm text-muted-foreground",children:ts?`No deployments matching "${Jt}"`:"No on-prem deployments"}):null,ss.map(t=>{var Y;const n=Ya(t,t.id===P?f:null),r=vn(Ae,"onprem_instance",t.id),l=js(t.runtime_status,r),m=vs(r),o=jn(t),_=Xa(t),N=Cs(n),$=Qa(n);return e.jsxs("div",{className:J("rounded-lg border border-border p-4",t.id===P&&"border-primary/50 bg-primary/5"),onClick:()=>{Ue(""),ve(t.id),jt(!0)},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("div",{className:"break-words",onClick:T=>T.stopPropagation(),children:hl(n)}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t.site}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[_?e.jsx(M,{variant:_.variant,className:J("w-fit",_.className),children:_.label}):null,N?e.jsx(M,{variant:"destructive",className:"w-fit",children:"Reconnect Required"}):null]})]}),e.jsx("div",{onClick:T=>T.stopPropagation(),children:_n({kind:"onprem",maintenanceLocked:((Y=yt(t))==null?void 0:Y.stage)==="lapsed",onAction:r?void 0:T=>void pi(T,t.id),onOpenOnPremOpikSettings:r?void 0:()=>xi(t),onDelete:r?void 0:()=>St({kind:"onprem",id:t.id,label:t.id,detail:`Site: ${t.site}`})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-1",children:[$?e.jsxs(e.Fragment,{children:[e.jsxs(b,{type:"button",size:"sm",onClick:T=>{T.stopPropagation(),_i(n)},disabled:Me,children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),"Reconnect this Mac"]}),!N&&Tt(n)?e.jsx("button",{type:"button",className:"text-xs font-medium text-primary underline-offset-4 hover:underline disabled:cursor-not-allowed disabled:opacity-60",disabled:ke===t.id,onClick:T=>{T.stopPropagation(),as(n)},children:ke===t.id?"Syncing local status...":"Sync local agent status"}):null,n.dashboard_url&&Ft(n.dashboard_url)?e.jsx("div",{onClick:T=>T.stopPropagation(),children:ds(n,"inline-flex items-center gap-1 text-xs font-medium text-primary underline-offset-4 hover:underline")}):null]}):e.jsxs(e.Fragment,{children:[n.dashboard_url?e.jsx("div",{onClick:T=>T.stopPropagation(),children:ds(n,"inline-flex items-center gap-1 text-xs font-medium text-primary underline-offset-4 hover:underline")}):null,Tt(n)?e.jsx("button",{type:"button",className:"text-xs font-medium text-primary underline-offset-4 hover:underline disabled:cursor-not-allowed disabled:opacity-60",disabled:ke===t.id,onClick:T=>{T.stopPropagation(),as(n)},children:ke===t.id?"Syncing local status...":"Sync local agent status"}):null]}),t.agent_install_status==="Not installed"?e.jsxs("a",{href:"#install-guide",onClick:T=>{var ue;T.stopPropagation(),rt(!0),(ue=document.getElementById("install-guide"))==null||ue.scrollIntoView({behavior:"smooth"})},className:"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",children:[e.jsx(ye,{className:"h-3 w-3"}),"Setup guide"]}):null]}),e.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-muted-foreground",children:"Setup"}),e.jsx(M,{variant:Sn(t.agent_status),children:t.agent_status}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.agent_install_status," · service ",t.service_load_status.toLowerCase()]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-muted-foreground",children:"Status"}),N?e.jsx(M,{variant:"destructive",children:"Reconnect Required"}):o?e.jsx(M,{variant:o.variant,className:l.className,children:o.label}):fn(l.label,l.variant,l.className,m),e.jsx("div",{className:"text-xs text-muted-foreground",children:N?"Open the reconnect flow to re-establish trust with this Mac.":(o==null?void 0:o.detail)||l.detail||`${t.desired_state} target · ${t.runtime_health}`})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-muted-foreground",children:"Model"}),e.jsx("div",{className:"text-sm text-foreground",children:Ha(t)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.credential_mode}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.model_name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-muted-foreground",children:"Billing"}),e.jsx("div",{className:"text-sm text-foreground",children:t.model_provider==="Ollama"?"No metered cost":t.credential_mode==="BYOK"?"BYOK":t.model_monthly_cost?`${j(t.model_monthly_cost)}/mo`:"Included"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Setup ",j(t.setup_fee)," · ",t.recurring_support_enabled?`${j(t.recurring_support_fee)}/mo`:"Self-supported"]})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx("div",{className:"text-xs uppercase tracking-[0.16em] text-muted-foreground",children:"Versions"}),e.jsxs("div",{className:"text-sm text-foreground",children:["Dashboard ",Ua(t)]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Agent ",qa(t)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:(o==null?void 0:o.seenLabel)||t.last_seen_at})]})]})]},t.id)})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Li,{className:"min-w-[980px]",children:[e.jsx(Ui,{children:e.jsxs(xt,{children:[e.jsx(fe,{children:"Deployment"}),e.jsx(fe,{children:"Setup"}),e.jsx(fe,{children:"Status"}),e.jsx(fe,{children:"Model"}),e.jsx(fe,{children:"Billing"}),e.jsx(fe,{children:"Versions"}),e.jsx(fe,{children:"Actions"})]})}),e.jsxs(qi,{children:[ss.length===0?e.jsx(xt,{children:e.jsx(G,{colSpan:7,className:"py-8 text-center text-sm text-muted-foreground",children:ts?`No deployments matching "${Jt}"`:"No on-prem deployments"})}
24):null,ss.map(t=>{var ue,rs;const n=Ya(t,t.id===P?f:null),r=vn(Ae,"onprem_instance",t.id),l=js(t.runtime_status,r),m=vs(r),o=jn(t),_=Xa(t),N=Cs(n),$=Qa(n),Y=(S==null?void 0:S.kind)==="onprem"&&S.id===t.id&&S.action==="cancel",T=((ue=yt(t))==null?void 0:ue.stage)==="lapsed";return e.jsxs(xt,{className:J(t.id===P&&Ji),onClick:()=>{Ue(""),ve(t.id),jt(!0)},children:[e.jsx(G,{className:J(t.id===P&&Zi),children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{onClick:Z=>Z.stopPropagation(),children:hl(n)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.site}),$?e.jsx("div",{onClick:Z=>Z.stopPropagation(),children:e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsxs(b,{type:"button",size:"sm",onClick:Z=>{Z.stopPropagation(),_i(n)},disabled:Me,children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),"Reconnect this Mac"]}),!N&&Tt(n)?e.jsx("button",{type:"button",className:"text-xs font-medium text-primary underline-offset-4 hover:underline disabled:cursor-not-allowed disabled:opacity-60",disabled:ke===t.id,onClick:Z=>{Z.stopPropagation(),as(n)},children:ke===t.id?"Syncing local status...":"Sync local agent status"}):null,n.dashboard_url&&Ft(n.dashboard_url)?ds(n,"inline-flex items-center gap-1 text-xs font-medium text-primary underline-offset-4 hover:underline"):null]})}):n.dashboard_url?e.jsx("div",{onClick:Z=>Z.stopPropagation(),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[ds(n,"inline-flex items-center gap-1 text-xs font-medium text-primary underline-offset-4 hover:underline"),Tt(n)?e.jsx("button",{type:"button",className:"text-xs font-medium text-primary underline-offset-4 hover:underline disabled:cursor-not-allowed disabled:opacity-60",disabled:ke===t.id,onClick:Z=>{Z.stopPropagation(),as(n)},children:ke===t.id?"Syncing local status...":"Sync local agent status"}):null]})}):null,_?e.jsx(M,{variant:_.variant,className:J("w-fit",_.className),children:_.label}):null,N?e.jsx(M,{variant:"destructive",className:"w-fit",children:"Reconnect Required"}):null,t.agent_install_status==="Not installed"&&!N?e.jsxs("a",{href:"#install-guide",onClick:Z=>{var R;Z.stopPropagation(),rt(!0),(R=document.getElementById("install-guide"))==null||R.scrollIntoView({behavior:"smooth"})},className:"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline",children:[e.jsx(ye,{className:"h-3 w-3"}),"Setup guide"]}):null]})}),e.jsx(G,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{variant:Sn(t.agent_status),children:t.agent_status}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.agent_install_status," · service ",t.service_load_status.toLowerCase()]})]})}),e.jsx(G,{children:e.jsxs("div",{className:"space-y-2",children:[N?e.jsx(M,{variant:"destructive",children:"Reconnect Required"}):o?e.jsx(M,{variant:o.variant,className:l.className,children:o.label}):fn(l.label,l.variant,l.className,m),e.jsx("div",{className:"text-xs text-muted-foreground",children:N?"Reconnect this Mac to re-establish trust. Runtime health may still be OK.":(o==null?void 0:o.detail)||l.detail||`${t.desired_state} target · ${t.runtime_health}`})]})}),e.jsx(G,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{children:Ha(t)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.credential_mode}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.model_name})]})}),e.jsx(G,{children:e.jsx(Ti,{recurringLabel:"Run",recurringValue:t.model_provider==="Ollama"?"No metered cost":t.credential_mode==="BYOK"?"BYOK":t.model_monthly_cost?`${j(t.model_monthly_cost)}/mo`:"Included",setupFee:j(t.setup_fee),supportLabel:"Support",supportValue:((rs=yt(t))==null?void 0:rs.stage)==="lapsed"?kn(t):t.recurring_support_enabled?`${j(t.recurring_support_fee)}/mo · ${Za(t)}`:"Self-supported · No managed metering",detailRows:[{label:"One-time setup",value:j(t.setup_fee)},{label:"Model runtime",value:t.model_provider==="Ollama"?"No metered cost":t.credential_mode==="BYOK"?"BYOK":t.model_monthly_cost?`${j(t.model_monthly_cost)}/mo`:"Included"},{label:"Recurring support",value:kn(t)},{label:"Cost & budget monitoring",value:Za(t)},{label:"Coupon",value:"No active coupon"},{label:"Remote access",value:t.remote_access}],footerActions:t.stripe_subscription_id?e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:Y,onClick:()=>Hs({kind:"onprem",id:t.id,label:t.id}),children:Y?"Cancelling…":"Cancel recurring maintenance"}):null})}),e.jsx(G,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:["Dashboard ",Ua(t)]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Agent ",qa(t)]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:(o==null?void 0:o.seenLabel)||t.last_seen_at})]})}),e.jsx(G,{children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:_n({kind:"onprem",maintenanceLocked:T,onAction:r||T?void 0:Z=>void pi(Z,t.id),onOpenOnPremOpikSettings:r||T?void 0:()=>xi(t),onDelete:r?void 0:()=>St({kind:"onprem",id:t.id,label:t.id,detail:`Site: ${t.site}`})})})})]},t.id)})]})]})})]})}),f?(()=>{const t=vn(Ae,"onprem_instance",f.id),n=js(f.runtime_status,t),r=yt(f),l=(S==null?void 0:S.kind)==="onprem"&&S.id===f.id;return e.jsxs("div",{"data-testid":"onprem-selected-detail",className:"w-full max-w-none space-y-6",children:[mt?e.jsxs(pn,{variant:"destructive",className:"border-destructive/40 bg-destructive/10",children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx(Oa,{children:"Reconnect Required"}),e.jsxs(hn,{children:[e.jsx("p",{children:"ClawMax needs to re-establish trust with this Mac. This is separate from runtime health; the local dashboard can still be running."}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(b,{type:"button",size:"sm",onClick:mn,disabled:!P||Me,children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),Me?"Opening ClawMax…":"Reconnect this Mac"]}),f.reconnect_url?e.jsx(b,{type:"button",size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:f.reconnect_url,children:"Open reconnect link"})}):null]})]})]}):null,r?e.jsxs(pn,{variant:r.stage==="warning"?"default":"destructive",className:"border-amber-500/40 bg-amber-50/80 dark:bg-amber-950/20",children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx(Oa,{children:r.stage==="lapsed"?"Maintenance expired":r.stage==="final_warning"?"Final maintenance renewal warning":"Maintenance renewal warning"}),e.jsxs(hn,{children:[e.jsx("p",{children:r.stage==="lapsed"?`Remote updates and maintenance are paused for this on-prem deployment. It is ${Cn(r.supp
24ortFreeUntil)}.`:`Included maintenance ends ${be(r.supportFreeUntil)}. Restart recurring maintenance to keep remote updates and support active.`}),e.jsx("div",{className:"mt-3",children:e.jsxs(b,{type:"button",size:"sm",disabled:l,onClick:()=>{if(y!=null&&y.stripe_payment_method_ready){cn({kind:"onprem",id:f.id});return}Ss(s==null?void 0:s.access_token,{customerId:f.customer_id||g||(y==null?void 0:y.id)||null,paymentMethodReady:!1,returnPath:"/client/onprem",targetType:"onprem_instance",targetId:f.id})},children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),l&&(S==null?void 0:S.action)==="activate"?"Activating…":y!=null&&y.stripe_payment_method_ready?"Restart maintenance":"Set up billing to restart maintenance"]})}),ti?fi("If this Mac needs the latest agent path before that window, jump straight to the install guide below."):null,e.jsx("p",{className:"mt-2",children:"The local deployment stays on the Mac. ClawMax remote support and update actions require active recurring maintenance."})]})]}):null,ti?e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm text-amber-950 dark:text-amber-100",children:[e.jsx(ls,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Requested release does not match the currently visible local runtime."}),e.jsxs("div",{className:"mt-1 text-amber-900/80 dark:text-amber-100/80",children:["Requested release: ",f.target_release,". Current visible version: ",f.version,". Install and support steps should stay pinned to ",eo(f.runtime_target),", not the ambient local checkout."]}),fi("Update this Mac to the requested agent/runtime path, then reconnect so ClawMax can hand the deployment back to the right local version.",{includeReconnect:!0})]})]}):null,e.jsxs(K,{children:[e.jsxs(te,{className:"flex flex-row items-start justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(se,{children:f.id}),mt?e.jsx(M,{variant:"destructive",children:"Reconnect Required"}):null]}),e.jsx(ne,{children:"Dashboard, state, versions, billing, and this Mac."})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>jt(m=>!m),"aria-expanded":at,"aria-controls":"client-onprem-selected-detail",children:at?"Hide details":"Show details"})]}),at?e.jsx(B,{id:"client-onprem-selected-detail",className:"space-y-3",children:[{label:"Dashboard",value:e.jsxs("div",{className:"flex flex-wrap justify-end gap-x-3 gap-y-1 text-right",children:[e.jsx("span",{children:ds(f)}),Tt(f)?e.jsx("button",{type:"button",className:"font-medium text-primary underline-offset-4 hover:underline disabled:cursor-not-allowed disabled:opacity-60",disabled:ke===f.id,onClick:()=>void as(f),children:ke===f.id?"Syncing local status...":"Sync local agent status"}):null]})},{label:"Dashboard Link",value:e.jsx("div",{className:"max-w-[28rem] text-right",children:Td(f)})},{label:"Status",value:mt?"Reconnect Required":n.label},...mt?[{label:"Recovery",value:"Reconnect this Mac to re-establish trust with the backend."}]:[],...n.detail?[{label:"Current action",value:n.detail}]:[],{label:"Dashboard version",value:Ua(f)},{label:"Agent version",value:qa(f)},{label:"This Mac",value:e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[e.jsxs(b,{type:"button",variant:mt?"default":"outline",size:"sm",onClick:mn,disabled:!P||Me,children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),Me?"Opening ClawMax…":mt||V?"Reconnect":"Connect"]}),V||We?e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>{Na(V?f:We)},children:"Disconnect"}):null]})},{label:"Billing",value:e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsx("span",{children:f.stripe_subscription_id?"Recurring active":"Recurring not active"}),f.stripe_subscription_id?e.jsx($t,{accessToken:(s==null?void 0:s.access_token)||null,customerId:f.customer_id||g||(y==null?void 0:y.id)||null,customer:y,triggerLabel:"View billing",triggerVariant:"outline",triggerSize:"sm",returnPath:"/client/onprem",targetType:"onprem_instance",targetId:f.id}):y!=null&&y.stripe_payment_method_ready?e.jsxs(b,{type:"button",size:"sm",variant:"outline",disabled:(S==null?void 0:S.kind)==="onprem"&&S.id===f.id,onClick:()=>void cn({kind:"onprem",id:f.id}),children:[e.jsx(Ut,{className:"mr-2 h-4 w-4"}),(S==null?void 0:S.kind)==="onprem"&&S.id===f.id&&S.action==="activate"?"Activating…":"Activate recurring maintenance"]}):e.jsx($t,{accessToken:(s==null?void 0:s.access_token)||null,customerId:f.customer_id||g||(y==null?void 0:y.id)||null,customer:y,triggerLabel:"Set up billing",triggerVariant:"outline",triggerSize:"sm",returnPath:"/client/onprem",targetType:"onprem_instance",targetId:f.id})]})},{label:"Maintenance",value:kn(f)},{label:"Last sync",value:f.last_reconcile_at||f.last_seen_at||"Not yet"},...(r==null?void 0:r.stage)==="lapsed"?[{label:"Maintenance gap",value:Cn(r.supp
24ortFreeUntil)}]:[]].map(m=>e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:m.label}),e.jsx("span",{className:"text-right text-sm text-foreground",children:m.value})]},m.label))}):null]}),at?ml(Dr,$r):null,at?e.jsx(K,{children:e.jsx(B,{className:"pt-6",children:e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"cursor-pointer list-none text-sm font-medium text-foreground",children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:["Advanced details",e.jsx("span",{className:"text-xs text-muted-foreground group-open:hidden",children:"Show"}),e.jsx("span",{className:"hidden text-xs text-muted-foreground group-open:inline",children:"Hide"})]})}),e.jsx("div",{className:"mt-4 space-y-3",children:[{label:"Installation status",value:f.agent_install_status},{label:"Runtime target",value:f.runtime_target},{label:"Service / launchd state",value:f.service_load_status},{label:"Desired state",value:f.desired_state},{label:"Runtime health",value:f.runtime_health},{label:"Workspace path",value:f.workspace_path},{label:"Requested release",value:f.target_release},{label:"Installer version",value:f.installer_release},{label:"Last error",value:f.last_error},{label:"Latest note",value:f.recent_log_excerpt},{label:"Support bundle",value:f.support_bundle_status}].map(m=>e.jsxs("div",{className:"flex items-start justify-between gap-4 rounded-md border border-border px-3 py-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:m.label}),e.jsx("span",{className:"text-right text-sm text-foreground",children:m.value})]},m.label))})]})})}):null]})})():null,e.jsx("div",{id:"install-guide"}),e.jsxs(K,{children:[e.jsxs(te,{className:"flex flex-row items-start justify-between gap-4 space-y-0",children:[e.jsxs("div",{children:[e.jsx(se,{children:"Install or update this Mac"}),e.jsx(ne,{children:"Use the installer when you are setting up or updating this Mac. Keep other install methods for edge cases only."})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",onClick:()=>rt(t=>!t),"aria-expanded":zt,"aria-controls":"client-onprem-install-guide",children:zt?"Hide guide":"Show guide"})]}),zt?e.jsxs(B,{id:"client-onprem-install-guide",children:[e.jsxs("div",{className:"mb-4 rounded-md border border-primary/20 bg-primary/8 px-4 py-3 text-sm",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Selected deployment"}),f?e.jsxs("div",{className:"mt-1 text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:f.id}),f.site?e.jsx("span",{children:` · ${f.site}`}):null,e.jsx("span",{children:` · runtime ${gl.clawmax}`}),e.jsx("span",{children:` · installer ${gl.clawmaxCli}`})]}):e.jsx("div",{className:"mt-1 text-muted-foreground",children:"Select an on-prem deployment from the list above to target this install and connect flow."})]}),e.jsxs("div",{className:"mb-4 rounded-md border border-border bg-muted/30 px-4 py-3 text-sm",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Recommended path"}),e.jsx("ol",{className:"mt-2 list-decimal space-y-1 pl-5 text-muted-foreground",children:Xt==="homebrew"?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"Upgrade ClawMax with Homebrew."}),e.jsx("li",{children:"Run the local dependency and agent steps for this deployment."}),e.jsx("li",{children:"Reconnect this Mac to the selected deployment."}),e.jsx("li",{children:"Run one sync if you want the dashboard to confirm local status immediately."})]}):Xt==="manual"?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"Update the local ClawMax CLI binary."}),e.jsx("li",{children:"Run the local dependency and agent steps for this deployment."}),e.jsx("li",{children:"Reconnect this Mac to the selected deployment."}),e.jsx("li",{children:"Run one sync if you want the dashboard to confirm local status immediately."})]}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"Install or update ClawMax.app with the signed macOS installer."}),e.jsx("li",{children:"Open ClawMax.app and let it prepare local dependencies."}),e.jsx("li",{children:"Use Connect or Reconnect for the selected deployment."}),e.jsx("li",{children:"Run one sync if you want the dashboard to confirm local status immediately."})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(b,{type:"button",variant:Xt==="installer"&&Ie==="installer"?"default":"outline",size:"sm",onClick:()=>je("installer"),children:[e.jsx(zi,{className:"mr-2 h-4 w-4"}),"Installer"]}),Xt==="homebrew"?e.jsxs(b,{type:"button",variant:Ie==="homebrew"?"default":"outline",size:"sm",onClick:()=>{je("homebrew"),As(!0)},children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Homebrew"]}):null,Xt==="manual"?e.jsxs(b,{type:"button",variant:Ie==="manual"?"default":"outline",size:"sm",onClick:()=>{je("manual"),As(!0)},children:[e.jsx(Hi,{className:"mr-2 h-4 w-4"}),"Manual"]}):null,e.jsxs(b,{type:"button",variant:Ie==="uninstall"?"default":"outline",size:"sm",onClick:()=>je("uninstall"),children:[e.jsx(Ml,{className:"mr-2 h-4 w-4"}),"Uninstall"]})]}
24),e.jsxs(od,{value:Ie,onValueChange:t=>{!pt&&_l(t)||je(t)},className:"space-y-4",children:[Ie==="installer"?e.jsxs(xn,{value:"installer",className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-primary/20 bg-primary/5 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{className:"font-medium text-foreground",children:"macOS Installer (recommended)"}),"Install the signed macOS package, make sure Podman is healthy, then connect or reconnect this Mac from ClawMax.app. This is the recommended line for future in-app update checks on this Mac."]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"rounded-md border border-border px-4 py-3 text-sm",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Step 1. Install ClawMax.app"}),e.jsxs("div",{className:"mt-1 text-muted-foreground",children:["Install ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:Et}),". The PKG installs both the local app and agent and puts this Mac on the updater-capable line."]}),ri?e.jsxs("div",{className:"mt-2 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-emerald-950 dark:text-emerald-100",children:[e.jsx("strong",{children:"Installed on this Mac:"})," ClawMax already looks installed here. Download the installer again only if you are updating or repairing the local app."]}):null,e.jsxs("div",{className:"mt-3 flex flex-col items-start gap-2",children:[pt?e.jsxs("a",{href:Mi,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90",children:[e.jsx(ye,{className:"h-4 w-4"}),ri?`Download latest installer again (${Et})`:`Download ClawMax Installer (${Et})`]}):e.jsxs(b,{type:"button",disabled:!0,className:"gap-2",children:[e.jsx(ye,{className:"h-4 w-4"}),"Download ClawMax Installer (",Et,")"]}),e.jsxs("a",{href:Ma,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-primary",children:["All releases ",e.jsx(Oe,{className:"h-3 w-3"})]}),e.jsxs("a",{href:Ko,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-primary",children:["Checksum (.sha256) ",e.jsx(Oe,{className:"h-3 w-3"})]})]}),e.jsxs("code",{className:"mt-2 block break-all font-mono text-[11px] text-muted-foreground",children:["SHA-256: ",Bo]})]}),e.jsxs("div",{className:"rounded-md border border-border px-4 py-3 text-sm",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Step 2. Make sure Podman is ready"}),e.jsxs("div",{className:"mt-1 text-muted-foreground",children:["Open ",e.jsx("strong",{children:"ClawMax.app"})," and confirm the local runtime status shows Podman ready before you connect. If the app reports Podman missing or unhealthy, use the app's ",e.jsx("strong",{children:"Repair Podman"})," action first."]})]}),e.jsxs("div",{className:"rounded-md border border-border px-4 py-3 text-sm",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Step 3. Open or reconnect this Mac"}),e.jsxs("div",{className:"mt-1 text-muted-foreground",children:["Launch ",e.jsx("strong",{children:"ClawMax.app"}),", then use the action below to connect or reconnect this Mac to the selected deployment."]}),e.jsxs("div",{className:"mt-3 flex flex-col items-start gap-2",children:[e.jsxs(b,{type:"button",className:"w-full sm:w-auto",onClick:mn,disabled:!P||Me,children:[e.jsx(At,{className:"mr-2 h-4 w-4"}),Me?"Opening ClawMax…":V?"Reconnect this Mac":"Open ClawMax and connect this Mac"]}),V||We?e.jsx(b,{type:"button",variant:"outline",className:"w-full sm:w-auto",onClick:()=>{Na(V?f:We)},children:"Disconnect this Mac"}):null]})]})]}),e.jsxs("div",{className:"space-y-2",children:[pt?null:e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Request a deployment first:"})," The macOS ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:".pkg"})," path is enabled after your account has at least one on-prem deployment to connect."]}),e.jsxs("div",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-sm text-emerald-950 dark:text-emerald-100",children:[e.jsx("strong",{children:"Signed macOS installer:"})," ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:Et})," is signed, notarized, and ready to install."]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("strong",{children:[si.title,":"]}
24)," ",si.description]}),e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-950 dark:text-amber-100",children:[e.jsx("strong",{children:"Podman check:"})," In ",e.jsx("strong",{children:"ClawMax.app"}),", make sure the local runtime status shows Podman ready before you connect. If it does not, click ",e.jsx("strong",{children:"Repair Podman"})," in the app."]}),V?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-950 dark:text-amber-100",children:[e.jsx("strong",{children:"This deployment already looks connected."})," Reconnect only if you are returning to that same Mac. If not, switch deployments first."]}):null,!V&&It.length>0?e.jsxs("div",{className:"rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-950 dark:text-amber-100",children:[e.jsx("strong",{children:"One Mac, one deployment:"})," Another on-prem deployment in this account already looks active. If you are on that same Mac, do not connect this new deployment here."]}):null,V||It.length>0?e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Need to reassign this Mac?"})," Use ",e.jsx("strong",{children:"Disconnect this Mac"})," first, then connect the replacement deployment."]}):null,f?(()=>
24{const t=ql({selectedRecord:f,selectedAlreadyConnected:V,hasConflictingActiveDeployment:It.length>0});return t.length?e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"If the connected Mac needs recovery:"}),e.jsx("div",{className:"mt-2 space-y-2",children:t.map(n=>e.jsx("div",{children:n},n))})]}):null})():null,e.jsxs("details",{className:"group rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",open:ro,onToggle:t=>io(t.currentTarget.open),children:[e.jsx("summary",{className:"cursor-pointer list-none font-medium text-foreground",children:"Advanced connect and troubleshooting"}),e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Verified baseline:"})," Podman ",e.jsx("strong",{children:"5.8.2"})," is the tested recovery baseline for the current on-prem installer flow."]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Updating ClawMax:"})," If ClawMax is already on this Mac, install the latest ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:".pkg"})," first, then reconnect."]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"If setup gets stuck:"})," Start with ",e.jsx("strong",{children:"ClawMax.app"})," and review the local runtime status plus logs there. Use the in-app ",e.jsx("strong",{children:"Repair Podman"})," action before dropping to terminal diagnostics. If app status is unavailable or support asks for it, then run ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"podman --version"}),", ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"podman machine list"}),", and ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"podman info"}),"."]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Internal libpod error or exit 126:"})," In ",e.jsx("strong",{children:"ClawMax.app"}),", download a ",e.jsx("strong",{children:"Support Bundle"})," first, then use the locally confirmed ",e.jsx("strong",{children:"Recreate Podman"})," action before retrying. This replaces only the managed ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"podman-clawmax"})," machine and preserves the ClawMax workspace and protected settings."]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Podman scope:"})," ClawMax only manages the local ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"podman-clawmax"})," machine."]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Known log hint:"})," If your logs mention ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"docker-credential-gcloud"}),", install the latest ClawMax package and retry."]}),U?e.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Latest macOS bootstrap handoff"}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Deep link:"}),e.jsx("code",{className:"ml-1 inline-block max-w-full overflow-x-auto whitespace-pre rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:Qs})]}),e.jsx(Se,{text:Qs,label:"Copy bootstrap deep link"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{children:"App bundle:"}),e.jsx("code",{className:"ml-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:U.app_bundle_path||"/Applications/ClawMax.app"})]}),e.jsx(Se,{text:U.app_bundle_path||"/Applications/ClawMax.app",label:"Copy app bundle path"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Bootstrap token:"}),e.jsx("code",{className:"ml-1 inline-block max-w-full overflow-x-auto whitespace-pre rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:U.bootstrap_token||"Not generated"})]}),U.bootstrap_token?e.jsx(Se,{text:U.bootstrap_token,label:"Copy bootstrap token"}):null]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Signed bootstrap URL:"}),e.jsx("code",{className:"ml-1 inline-block max-w-full overflow-x-auto whitespace-pre rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:U.bootstrap_url||"Not generated"})]}),U.bootstrap_url?e.jsx(Se,{text:U.bootstrap_url,label:"Copy signed bootstrap URL"}):null]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Expires:"}),e.jsx("code",{className:"ml-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:U.expires_at||"No expiry set"})]}),U.expires_at?e.jsx(Se,{text:U.expires_at,label:"Copy bootstrap expiry"}):null]})]}):null,e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Canonical launch contract:"}),e.jsx("code",{className:"ml-1 inline-block max-w-full overflow-x-auto whitespace-pre rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:Qs})]}),e.jsx(Se,{text:Qs})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Fallback: launch the installed executable with the deployment bootstrap token:"}),e.jsx("code",{className:"ml-1 inline-block max-w-full overflow-x-auto whitespace-pre rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:Qr})]}),e.jsx(Se,{text:Qr})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Or launch the installed executable with a signed bootstrap URL:"}),e.jsx("code",{className:"ml-1 inline-block max-w-full overflow-x-auto whitespace-pre rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:ei})]}),e.jsx(Se,{text:ei})]}),e.jsxs("div",{className:"rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsx("strong",{children:"Phase 1 fallback:"})," The resolved bootstrap JSON and ",e.jsx("code",{className:"mx-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"~/.clawmax/agent/bootstrap.json"})," flow still exist as a CLI fallback, but the tray/token handoff is now the intended macOS path."]}),e.jsx("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:e.jsx("div",{children:e.jsx("span",{children:"The bootstrap command persists config into agent state, runs install/start/connect, and removes the bootstrap file on success."})})}),e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Verify agent is running after bootstrap:"}),e.jsx("code",{className:"ml-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"clawmax agent status"})]}),e.jsx(Se,{text:"clawmax agent status"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-sm text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Verify local tooling:"}),e.jsx("code",{className:"ml-1 rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"clawmax doctor"})]}),e.jsx(Se,{text:"clawmax doctor"})]})]})]})]})]}):null,po&&(Ie==="homebrew"||Ie==="manual")?e.jsxs("details",{className:"rounded-md border border-border px-4 py-3",open:ao,onToggle:t=>{const n=t.currentTarget.open;As(n),n&&(en&&!tn?je("homebrew"):tn&&!en&&je("manual"))},children:[e.jsx("summary",{className:"cursor-pointer list-none text-sm font-medium text-foreground",children:ho}),e.jsxs("div",{className:"mt-4 space-y-4",children:[en&&tn?e.jsxs(dd,{className:"grid w-full grid-cols-2",children:[e.jsxs(Fi,{value:"homebrew",className:Xi,disabled:!pt,children:[e.jsx(ye,{className:"h-4 w-4"}),"Homebrew"]}),e.jsxs(Fi,{value:"manual",className:Xi,disabled:!pt,children:[e.jsx(Hi,{className:"h-4 w-4"}),"Manual"]})]}):null,en?e.jsxs(xn,{value:"homebrew",className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-primary/20 bg-primary/5 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Homebrew"}),"Install or upgrade to ",e.jsx("strong",{children:Wo})," using either the ClawMax CLI formula or the ClawMax.app cask via Homebrew. The CLI formula path is best for terminal-first flows; the app cask gives you the signed local app plus CLI. Then run the local dependency auto-fix, bind the local agent to this deployment with the instance key and worker key, start the agent service, and run one reconcile pass."]}),e.jsx(Ba,{title:"",description:"",commands:["# 1. Tap the ClawMax repository and install or upgrade the CLI","brew tap Maximilien-ai/clawmax","brew install clawmax || brew upgrade clawmax","#    Or install / upgrade the signed macOS app cask","brew install --cask clawmax-app || brew upgrade --cask clawmax-app",'"$(brew --prefix)/bin/clawmax" version',"","# 2. Install agent scaffold for this deployment (creates ~/.clawmax/, LaunchAgent)",'"$(brew --prefix)/bin/clawmax" agent install \\',`  --instance-key "${Zs}" \\`,`  --api-url "${cs}" \\`,`  --worker-key "${Xs}"`,"","# 3. Prepare local dependencies (Podman, machine, diagnostics)",'"$(brew --prefix)/bin/clawmax" doctor --fix',"","# 4. Start the agent service",'"$(brew --prefix)/bin/clawmax" agent start',"","# 5. Connect and reconcile the requested runtime target",'"$(brew --prefix)/bin/clawmax" agent connect --once',"","# 6. Verify everything is running",'"$(brew --prefix)/bin/clawmax" agent status','"$(brew --prefix)/bin/clawmax" doctor'],notes:[{text:"Tap and install or upgrade the CLI:",command:"brew tap Maximilien-ai/clawmax && (brew install clawmax || brew upgrade clawmax)"},{text:"Install or upgrade the signed app cask:",command:"brew install --cask clawmax-app || brew upgrade --cask clawmax-app"},{text:"Confirm you are using the Homebrew-installed binary:",command:'"$(brew --prefix)/bin/clawmax" version'},{text:"Install agent scaffold with the deployment instance key and worker key:",command:`"$(brew --prefix)/bin/clawmax" agent install --instance-key "${Zs}" --api-url "${cs}" --worker-key "${Xs}"`},{text:"Auto-fix local dependencies before first start:",command:'"$(brew --prefix)/bin/clawmax" doctor --fix'},{text:"Start agent service:",command:'"$(brew --prefix)/bin/clawmax" agent start'},{text:"Connect and reconcile the requested runtime target:",command:'"$(brew --prefix)/bin/clawmax" agent connect --once'},{text:"Check agent status:",command:'"$(brew --prefix)/bin/clawmax" agent status'},{text:"Verify local tooling:",command:'"$(brew --prefix)/bin/clawmax" doctor'},{text:"To upgrade the CLI later:",command:"brew upgrade clawmax"},{text:"To upgrade the app later:",command:"brew upgrade --cask clawmax-app"},{text:"The agent reports status to the deployment-specific on-prem status endpoint using x-clawmax-worker-key auth. If the instance key is missing, the deployment page will stay stale even when the local runtime is healthy."}]})]}):null,tn?e.jsxs(xn,{value:"manual",className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-primary/20 bg-primary/5 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Manual download"}),"Download the binary from GitHub, extract to ~/.local/bin, run the local dependency auto-fix, then set up the agent. For air-gapped or custom setups."]}),e.jsx(Ba,{title:"",description:"",commands:["# 1. Download the latest release binary","#    Option A: Using GitHub CLI (gh)","ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')","OS=$(uname -s | tr '[:upper:]' '[:lower:]')","gh release download --repo Maximilien-ai/clawmax-cli-releases \\",'  --pattern "clawmax-*-${OS}-${ARCH}.tar.gz" --dir /tmp',"","#    Option B: Direct download from releases page",`#    ${Ma}`,"","# 2. Extract and install to ~/.local/bin","mkdir -p ~/.local/bin","tar -xzf /tmp/clawmax-*-${OS}-${ARCH}.tar.gz \\","  --strip-components=1 -C ~/.local/bin","chmod +x ~/.local/bin/clawmax","","# 3. Ensure ~/.local/bin is in your PATH",`echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc`,"source ~/.zshrc","","# 4. Verify the CLI is working","clawmax --version","","# 5. Install agent scaffold for this deployment","clawmax agent install \\",`  --instance-key "${Zs}" \\`,`  --api-url "${cs}" \\`,`  --worker-key "${Xs}"`,"","# 6. Prepare local dependencies (Podman, machine, diagnostics)","clawmax doctor --fix","","# 7. Start the agent service","clawmax agent start","","# 8. Connect and reconcile the requested runtime target","clawmax agent connect --once","","# 9. Verify everything is running","clawmax agent status","clawmax doctor"],downloadUrl:Ma,notes:[{text:"Download using GitHub CLI:",command:"gh release download --repo Maximilien-ai/clawmax-cli-releases --pattern 'clawmax-*-darwin-arm64.tar.gz' --dir /tmp"},{text:"Or download directly from the releases page (no gh required)."},{text:"Extract to ~/.local/bin:",command:"mkdir -p ~/.local/bin && tar -xzf /tmp/clawmax-*-darwin-arm64.tar.gz --strip-components=1 -C ~/.local/bin"},{text:"Make executable:",command:"chmod +x ~/.local/bin/clawmax"},{text:"Add to PATH (if not already):",command:`echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`},{text:"Verify CLI:",command:"clawmax --version"},{text:"Install agent scaffold with the deployment instance key and worker key:",command:`clawmax agent install --instance-key "${Zs}" --api-url "${cs}" --worker-key "${Xs}"`},{text:"Auto-fix local dependencies before first start:",command:"clawmax doctor --fix"},{text:"Start agent service:",command:"clawmax agent start"},{text:"Connect and reconcile the requested runtime target:",command:"clawmax agent connect --once"},{text:"Check status:",command:"clawmax agent status"},{text:"Capture support bundle:",command:"clawmax agent support-bundle"},{text:"Use the .pkg installer path if you want the tray app and packaged LaunchAgent bootstrap."}]})]}):null]})]}):null,e.jsxs(xn,{value:"uninstall",className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-primary/20 bg-primary/5 px-4 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Uninstall ClawMax from this Mac"}
24),"Use the supported uninstall command to remove the local ClawMax install and runtime from this machine while preserving your workspace files."]}),e.jsx(Ba,{title:"",description:"",commands:["# 1. Open Terminal","","# 2. Run the supported uninstall command","clawmax agent uninstall","","# 3. Follow the prompts"],notes:[{text:"This removes the local ClawMax install and runtime state from the Mac."},{text:"Your workspace is preserved by design at:",command:"~/.clawmax/workspace"},{text:"If prompted, you can also remove the dedicated ClawMax Podman VM."},{text:"If you installed ClawMax with Homebrew, you can also remove the Homebrew package."},{text:"Keep Podman and Homebrew, remove only the local ClawMax install:",command:"clawmax agent uninstall --keep-podman-machine --keep-homebrew"},{text:"Also remove the dedicated ClawMax Podman VM:",command:"clawmax agent uninstall --remove-podman-machine --keep-homebrew"},{text:"Homebrew-managed uninstall:",command:"clawmax agent uninstall --remove-homebrew --remove-homebrew-tap"},{text:"Full workspace deletion is intentionally separate and destructive. The standard uninstall does not erase ~/.clawmax/workspace."}]})]})]})]}):null]})]}):null]})]})]}),e.jsx(ms,{open:!!A,onOpenChange:t=>{t||(St(null),ca(""))},children:e.jsxs(ps,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(hs,{children:[e.jsx(xs,{children:"Delete deployment?"}),e.jsxs(gs,{children:["This will permanently remove ",e.jsx("strong",{children:A==null?void 0:A.label}),A!=null&&A.detail?` (${A.detail})`:"",".",ot?" Before removal, the worker must create and verify an encrypted workspace backup. It will remain available for 90 days when you create another Cloud or On-Prem deployment.":(A==null?void 0:A.kind)==="cloud"?" Export any workspaces you need first. Once cleanup finishes, the cloud instance and its dashboard will no longer be available.":" The agent will no longer appear in your console and any local installation will need to be cleaned up manually."," ","This action cannot be undone."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{htmlFor:"client-delete-confirmation",className:"text-sm font-medium text-foreground",children:["Type ",e.jsx("span",{className:"font-mono",children:A==null?void 0:A.label})," to confirm"]}),e.jsx(I,{id:"client-delete-confirmation",value:Wr,onChange:t=>ca(t.target.value),placeholder:(A==null?void 0:A.label)||"instance-name"})]}),e.jsxs(fs,{children:[e.jsx(_s,{disabled:ua,children:"Cancel"}),e.jsx(ys,{onClick:()=>void ko(),disabled:ua||Wr.trim()!==((A==null?void 0:A.label)||""),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:ua?"Deleting…":"Delete deployment"})]})]})}),e.jsx(ms,{open:!!Ot,onOpenChange:t=>{!t&&!S&&Hs(null)},children:e.jsxs(ps,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-xl",children:[e.jsxs(hs,{children:[e.jsx(xs,{children:"Cancel recurring maintenance?"}),e.jsx(gs,{children:Ot?`ClawMax will stop the next renewal for ${Ot.label}. The current paid month stays covered, and warning emails resume before that paid-through date if you do not reactivate maintenance.`:"ClawMax will stop the next recurring maintenance renewal."})]}),e.jsxs(fs,{children:[e.jsx(_s,{disabled:!!S,children:"Keep maintenance"}),e.jsx(ys,{disabled:!!S||!Ot,onClick:t=>{t.preventDefault(),Ot&&wo(Ot)},children:(S==null?void 0:S.action)==="cancel"?"Cancelling…":"Cancel recurring maintenance"})]})]})}),e.jsx(ms,{open:uo,onOpenChange:Zt,children:e.jsxs(ps,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-2xl",children:[e.jsxs(hs,{children:[e.jsx(xs,{children:V?"This deployment is already connected":"Another deployment already looks active"}),e.jsx(gs,{children:V?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block",children:"The selected deployment already looks connected on a Mac:"}),e.jsxs("span",{className:"mt-2 block font-medium text-foreground",children:[E==null?void 0:E.id," · ",E==null?void 0:E.site]}),e.jsxs("span",{className:"mt-1 block",children:["Status: ",E==null?void 0:E.agent_status," · ",(oe==null?void 0:oe.label)||(E==null?void 0:E.runtime_status)]}),oe!=null&&oe.detail?e.jsx("span",{className:"mt-1 block",children:oe.detail}):null,e.jsx("span",{className:"mt-2 block",children:"Reconnect only if you are returning to that same machine. If you meant to connect a different deployment, cancel and switch instances first."}),e.jsx("span",{className:"mt-2 block",children:"If this Mac is still bound to an older deployment that you replaced in web, disconnect it first before reconnecting the replacement deployment."}),e.jsxs("span",{className:"mt-2 block",children:["On that Mac, open the ClawMax tray menu and choose ",e.jsx("strong",{children:"Disconnect This Mac"}),", then return here and reconnect the replacement deployment."]})]}):xa>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block",children:"You selected this deployment for the current Mac:"}),e.jsxs("span",{className:"mt-2 block font-medium text-foreground",children:[E==null?void 0:E.id," · ",E==null?void 0:E.site]}),e.jsxs("span",{className:"mt-1 block",children:["Status: ",E==null?void 0:E.agent_status," · ",(oe==null?void 0:oe.label)||(E==null?void 0:E.runtime_status)]}),oe!=null&&oe.detail?e.jsx("span",{className:"mt-1 block",children:oe.detail}):null,e.jsxs("span",{className:"mt-3 block",children:["ClawMax currently supports one deployment per Mac. This account already has ",xa," other active on-prem deployment",xa===1?"":"s","."]}),e.jsx("span",{className:"mt-2 block",children:"If you are on that same Mac, do not continue here. Only continue if you are on a different Mac and want to connect the selected deployment above."}),e.jsx("span",{className:"mt-2 block",children:"If you deleted and recreated the old deployment for this same Mac, disconnect the current local binding first, then return and connect the selected deployment."}),e.jsxs("span",{className:"mt-2 block",children:["On that Mac, open the ClawMax tray menu and choose ",e.jsx("strong",{children:"Disconnect This Mac"})," before retrying."]})]}):"Another on-prem deployment in this account already looks active. Only continue if you are on a different Mac."})]}),e.jsxs(fs,{className:"flex-col gap-2 sm:flex-col sm:items-stretch sm:space-x-0",children:[e.jsx(_s,{className:"w-full",children:"Cancel"}),V||We?e.jsx(b,{variant:"outline",className:"w-full",onClick:()=>{Na(V?f:We),Zt(!1)},children:"Disconnect this Mac"}):null,We&&!V?e.jsx(b,{variant:"outline",className:"w-full",onClick:()=>{ve(We.id),Zt(!1)},children:"Review active deployments"}):null,e.jsx(ys,{className:"w-full",onClick:()=>{Zt(!1),ka()},children:V?"Reconnect this Mac":"I'm on a different Mac"})]})]})}),e.jsx(ft,{open:!!xe,onOpenChange:t=>{!t&&!Ys&&(Vs(null),Ke({useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""}))},children:e.jsxs(_t,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-xl",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Managed add-on settings"}),e.jsxs(tt,{children:["Update the managed Opik + Resend bundle for ",e.jsx("span",{className:"font-medium text-foreground",children:xe==null?void 0:xe.id}),". Secrets are write-only here. If you already use your own keys, enter the new values you want applied."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground",children:["Current maintenance billing: ",xe?Dt(xe):"n/a","."," ","Bring your own keys apply the ",j(_e
24({useManagedOpik:!1})),"/mo rate after any included maintenance window. The ClawMax-managed Opik + Resend bundle uses ",j(_e({useManagedOpik:!0})),"/mo."]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border border-border px-3 py-3",children:[e.jsx(bs,{checked:Q.useManagedOpik,onCheckedChange:t=>Ke(n=>({...n,useManagedOpik:t!==!1,opikApiKey:t!==!1?"":n.opikApiKey,opikWorkspace:t!==!1?"":n.opikWorkspace,opikProject:t!==!1?"":n.opikProject,resendApiKey:t!==!1?"":n.resendApiKey})),id:"client-cloud-opik-managed"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"client-cloud-opik-managed",className:"text-sm font-medium text-foreground",children:"Use the ClawMax-managed Opik + Resend bundle"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave this on for managed cost tracking and managed agent email. Turn it off if you want to bring your own keys and use the discounted maintenance rate."})]})]}),Q.useManagedOpik?e.jsxs("div",{className:"rounded-md border border-border bg-primary/5 px-3 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{children:"Managed Opik: ClawMax will inject the telemetry credentials during the next reconcile."}),e.jsx("div",{className:"mt-1",children:"Managed Resend: ClawMax will inject the shared Resend sender defaults and API key for this workspace’s agent-driven email flows."})]}):e.jsxs("div",{className:"space-y-3 rounded-md border border-border px-3 py-3",children:[e.jsx("div",{className:"rounded-md border border-amber-300/40 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100",children:"Existing customer secrets are not readable here. Enter the values you want applied on the next reconcile."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-opik-settings-key",className:"text-sm font-medium text-foreground",children:"Opik API key"}),e.jsx(I,{id:"client-cloud-opik-settings-key",type:"password",value:Q.opikApiKey,onChange:t=>Ke(n=>({...n,opikApiKey:t.target.value})),placeholder:"Paste your Opik API key"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-resend-settings-key",className:"text-sm font-medium text-foreground",children:"Resend API key"}),e.jsx(I,{id:"client-cloud-resend-settings-key",type:"password",value:Q.resendApiKey,onChange:t=>Ke(n=>({...n,resendApiKey:t.target.value})),placeholder:"Optional: paste your Resend API key"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-opik-settings-workspace",className:"text-sm font-medium text-foreground",children:"Workspace"}),e.jsx(I,{id:"client-cloud-opik-settings-workspace",value:Q.opikWorkspace,onChange:t=>Ke(n=>({...n,opikWorkspace:t.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-cloud-opik-settings-project",className:"text-sm font-medium text-foreground",children:"Project"}),e.jsx(I,{id:"client-cloud-opik-settings-project",value:Q.opikProject,onChange:t=>Ke(n=>({...n,opikProject:t.target.value}))})]})]})]})]}),e.jsxs(st,{className:"flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>Vs(null),disabled:Ys,children:"Cancel"}),e.jsx(b,{type:"button",onClick:()=>void No(),disabled:Ys,children:Ys?"Saving…":"Apply on next reconcile"})]})]})}),e.jsx(ft,{open:!!ge,onOpenChange:t=>{!t&&!Js&&(Gs(null),Be({useManagedOpik:!0,opikApiKey:"",opikWorkspace:"",opikProject:"",resendApiKey:""}))},children:e.jsxs(_t,{className:"max-h-[90svh] w-[calc(100vw-2rem)] overflow-y-auto sm:max-w-xl",children:[e.jsxs(Qe,{children:[e.jsx(et,{children:"Managed add-on settings"}),e.jsxs(tt,{children:["Update the managed Opik + Resend bundle for ",e.jsx("span",{className:"font-medium text-foreground",children:ge==null?void 0:ge.id}),". Secrets are write-only here. If you already use your own keys, enter the new values you want applied."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-3 text-sm text-muted-foreground",children:["Current maintenance billing: ",ge?Gl(ge):"n/a","."," ","Bring your own keys apply the ",j(pe({useManagedOpik:!1})),"/mo rate. The ClawMax-managed Opik + Resend bundle uses ",j(pe({useManagedOpik:!0})),"/mo."]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-md border border-border px-3 py-3",children:[e.jsx(bs,{checked:ee.useManagedOpik,onCheckedChange:t=>Be(n=>({...n,useManagedOpik:t!==!1,opikApiKey:t!==!1?"":n.opikApiKey,opikWorkspace:t!==!1?"":n.opikWorkspace,opikProject:t!==!1?"":n.opikProject,resendApiKey:t!==!1?"":n.resendApiKey})),id:"client-onprem-opik-managed"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"client-onprem-opik-managed",className:"text-sm font-medium text-foreground",children:"Use the ClawMax-managed Opik + Resend bundle"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave this on for managed cost tracking and managed agent email. Turn it off if you want to bring your own keys and use the discounted maintenance rate."})]})]}),ee.useManagedOpik?e.jsxs("div",{className:"rounded-md border border-border bg-primary/5 px-3 py-3 text-sm text-muted-foreground",children:[e.jsx("div",{children:"Managed Opik: ClawMax will inject the telemetry credentials during the next on-prem reconcile."}),e.jsx("div",{className:"mt-1",children:"Managed Resend: ClawMax will inject the shared Resend sender defaults and API key for this workspace’s agent-driven email flows."})]}):e.jsxs("div",{className:"space-y-3 rounded-md border border-border px-3 py-3",children:[e.jsx("div",{className:"rounded-md border border-amber-300/40 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-100",children:"Existing customer secrets are not readable here. Enter the values you want applied on the next reconcile."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-onprem-opik-settings-key",className:"text-sm font-medium text-foreground",children:"Opik API key"}),e.jsx(I,{id:"client-onprem-opik-settings-key",type:"password",value:ee.opikApiKey,onChange:t=>Be(n=>({...n,opikApiKey:t.target.value})),placeholder:"Paste your Opik API key"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-onprem-resend-settings-key",className:"text-sm font-medium text-foreground",children:"Resend API key"}),e.jsx(I,{id:"client-onprem-resend-settings-key",type:"password",value:ee.resendApiKey,onChange:t=>Be(n=>({...n,resendApiKey:t.target.value})),placeholder:"Optional: paste your Resend API key"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-onprem-opik-settings-workspace",className:"text-sm font-medium text-foreground",children:"Worksp
24ace"}),e.jsx(I,{id:"client-onprem-opik-settings-workspace",value:ee.opikWorkspace,onChange:t=>Be(n=>({...n,opikWorkspace:t.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"client-onprem-opik-settings-project",className:"text-sm font-medium text-foreground",children:"Project"}),e.jsx(I,{id:"client-onprem-opik-settings-project",value:ee.opikProject,onChange:t=>Be(n=>({...n,opikProject:t.target.value}))})]})]})]})]}),e.jsxs(st,{className:"flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>Gs(null),disabled:Js,children:"Cancel"}),e.jsx(b,{type:"button",onClick:()=>void Co(),disabled:Js,children:Js?"Queueing…":"Apply on next reconcile"})]})]})}),e.jsx(rd,{pageContext:{path:h.pathname==="/client/actions"?"/client/onprem":h.pathname,section:Uo,summary:qo,selected_item:Fo}})]})};export{gc as clientConsolePreviewTestHelpers,fc as default,fl as getCreatedInstanceSelectionId,yn as notifyClientPreviewAction};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.